Rollup of 10 pull requests
Successful merges:
- #63955 (Make sure interned constants are immutable)
- #64028 (Stabilize `Vec::new` and `String::new` as `const fn`s)
- #64119 (ci: ensure all tool maintainers are assignable on issues)
- #64444 (fix building libstd without backtrace feature)
- #64446 (Fix build script sanitizer check.)
- #64451 (when Miri tests are not passing, do not add Miri component)
- #64467 (Hide diagnostics emitted during --cfg parsing)
- #64497 (Don't print the "total" `-Ztime-passes` output if `--prints=...` is also given)
- #64499 (Use `Symbol` in two more functions.)
- #64504 (use println!() instead of println!(""))
Failed merges:
r? @ghost
when Miri tests are not passing, do not add Miri component
This makes build-manifest query the toolstate repo at https://github.com/rust-lang-nursery/rust-toolstate to figure out if the tests of the Miri component are passing. If they are not, we remove the component from the manifest, to avoid shipping a broken Miri.
I tested this locally by running build-manifest and making sure that it correctly detects the toolstate of 02785dabad as broken.
r? @pietroalbini
Cc @kennytm @alexcrichton
Fixes https://github.com/rust-lang/rust/issues/60301
Fix build script sanitizer check.
#64166 changed the way the sanitizer build scripts work. However, they were changed so that they switch between new-style to old-style cargo fingerprints. This trips up on https://github.com/rust-lang/cargo/issues/6779.
It also causes rustbuild to panic. If you build stage1 std (with sanitizers off), and then enable sanitizers, it panics. (This is because the build scripts don't declare that they need to re-run.)
This PR will trip https://github.com/rust-lang/cargo/issues/6779 again, unfortunately. I've been having way too many unexplained rebuilds in rust-lang/rust recently, but at least I'll know why this time.
This doesn't fix all problems with the build scripts, but arguably they should be fixed in cargo. For example, the build scripts change which rerun-if statements they declare between runs which triggers https://github.com/rust-lang/cargo/issues/7362.
The test for this is:
1. Turn off sanitizers (which is the default)
2. `./x.py build --stage=1 src/libstd`
3. `./x.py build --stage=1 src/libstd` again should be a null build.
4. Enable sanitizers.
5. `./x.py build --stage=1 src/libstd` should rebuild with sanitizers enabled.
6. `./x.py build --stage=1 src/libstd` again should be a null build. This actually rebuilds due to https://github.com/rust-lang/cargo/issues/7362 because the rerun-if directives changed between step 3 and 5. A 3rd attempt should be a null build.
ci: ensure all tool maintainers are assignable on issues
GitHub only allows people explicitly listed as collaborators on the repository or who commented on the issue/PR to be assignees, failing to create the issue if non-assignable people are assigned.
This adds an extra check on CI to make sure all the people listed as tool maintainers can be assigned to toolstate issues. The check won't be executed on PR builds due to the lack of a valid token.
r? @kennytm
Make sure interned constants are immutable
This makes sure that interning for constants (not statics) creates only immutable allocations.
Previously, the "main" allocation of `const FOO: Cell<i32> = Cell::new(0);` was marked as mutable, but I don't think we want that. It can be only copied, not written to.
Also, "leftover" allocations (behind raw pointers etc) were left mutable. I don't think we want to support that. I tried asserting that these are all already immutable (to double-check our static checks), but that failed in this one:
```rust
const NON_NULL_PTR2: NonNull<u8> = unsafe { mem::transmute(&0) };
```
Seems like maybe we want more precise mutability annotation inside Miri for locals (like `&0` here) so that this would actually become immutable to begin with?
I also factored `intern_shallow` out of the visitor so that we don't have to construct a visitor when we do not plan to visit anything. That confused me at first.
GitHub only allows people explicitly listed as collaborators on the
repository or who commented on the issue/PR to be assignees, failing to
create the issue if non-assignable people are assigned.
This adds an extra check on CI to make sure all the people listed as
tool maintainers can be assigned to toolstate issues. The check won't be
executed on PR builds due to the lack of a valid token.
Improve BTreeSet::Intersection::size_hint
A comment on `IntersectionInner` mentions `small_iter` should be smaller than `other_iter` but this condition is broken while iterating because those two iterators can be consumed at a different rate. I added a test to demonstrate this situation.
<del>I made `small_iter.len() < other_iter.len()` always true by swapping two iterators when that condition became false. This change affects the return value of `size_hint`. The previous result was also correct but this new version always returns smaller upper bound than the previous version.</del>
I changed `size_hint` to taking minimum of both lengths of iterators and renamed fields to `a` and `b` to match `Union` iterator.
The commented invariant that an iterator is smaller than other iterator
was violated after next is called and two iterators are consumed at
different rates.
Rollup of 3 pull requests
Successful merges:
- #63872 (Document platform-specific behavior of the iterator returned by std::fs::read_dir)
- #64250 (save-analysis: Nest typeck tables when processing functions/methods)
- #64472 (Don't mark expression with attributes as not needing parentheses)
Failed merges:
r? @ghost
Don't mark expression with attributes as not needing parentheses
This is not perfectly correct as `#[attr] (5)` will still not lint, but it does seem good enough, in particular as the parentheses in that case are not unambiguously incorrect; I might personally prefer to see them for clarity.
Fixes https://github.com/rust-lang/rust/issues/43279.
save-analysis: Nest typeck tables when processing functions/methods
Fixes an issue where we did not nest tables correctly when resolving
associated types in formal argument/return type positions.
This was the minimized reproduction case that I tested the fix on:
```rust
pub trait Trait {
type Assoc;
}
pub struct A;
pub fn func() {
fn _inner1<U: Trait>(_: U::Assoc) {}
fn _inner2<U: Trait>() -> U::Assoc { unimplemented!() }
impl A {
fn _inner1<U: Trait>(self, _: U::Assoc) {}
fn _inner2<U: Trait>(self) -> U::Assoc { unimplemented!() }
}
}
```
using `debug_assertions`-enabled rustc and by additionally passing `-Zsave-analysis`.
Unfortunately the original assertion fired is a *debug* one and from what I can tell we don't run the tests with these on, so I'm not adding a test here. If I missed it and there is a way to run tests with these on, I'd love to add a test case for this.
Closes#63663Closes#50328Closes#43982
Cleanup handling of hygiene for built-in macros
This makes most identifiers generated by built-in macros use def-site hygiene, not only the ones that previously used gensyms.
* `ExtCtxt::ident_of` now takes a `Span` and is preferred to `Ident::{from_str, from_str_and_span}`
* Remove `Span::with_legacy_ctxt`
* `assert` now uses call-site hygiene because it needs to resolve `panic` unhygienically.
* `concat_idents` now uses call-site hygiene because it wouldn't be very useful with def-site hygiene.
* everything else is moved to def-site hygiene
r? @petrochenkov