Add user seed to `-Z randomize-layout`
Allows users of -`Z randomize-layout` to provide `-Z layout-seed=<seed>` in order to further randomizing type layout randomization. Extension of [compiler-team/#457](https://github.com/rust-lang/compiler-team/issues/457), allows users to change struct layouts without changing code and hoping that item path hashes change, aiding in detecting layout errors
Update browser-ui-test version and improve rustdoc-gui tests readability
Since the `0.5.1`, we can use trailing commas. I also used the opportunity to clean up the existing tests.
r? `@notriddle`
Avoid sorting in hash map stable hashing
Suggested by `@the8472` [here](https://github.com/rust-lang/rust/pull/89404#issuecomment-991813333). I hope that I understood it right, I replaced the sort with modular multiplication, which should be commutative.
Can I ask for a perf. run? However, locally it didn't help at all. Creating the `StableHasher` all over again is probably slowing it down quite a lot. And using `FxHasher` is not straightforward, because the keys and values only implement `HashStable` (and probably they shouldn't be just hashed via `Hash` anyway for it to actually be stable).
Maybe the `StableHash` interface could be changed somehow to better suppor these scenarios where the hasher is short-lived. Or the `StableHasher` implementation could have variants with e.g. a shorter buffer for these scenarios.
Rollup of 7 pull requests
Successful merges:
- #91566 (Apply path remapping to DW_AT_GNU_dwo_name when producing split DWARF)
- #91926 (Remove `in_band_lifetimes` from `rustc_metadata`)
- #91931 (Remove `in_band_lifetimes` from `rustc_codegen_llvm`)
- #92024 (rustc_codegen_llvm: Give each codegen unit a unique DWARF name on all platforms, not just Apple ones.)
- #92037 (Use a const ParamEnv when in default_method_body_is_const)
- #92047 (Set `RUST_BACKTRACE=0` when running location-detail tests)
- #92050 (Add a space and 2 grave accents )
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
For a data section, the object crate will set the SHF_ALLOC by
default, which is exactly what we don't want. Explicitly set
sh_flags to zero to avoid this.
`render/context` always runs after `run_global_context`, so it was always set to `true`.
This is a holdover from when rustdoc allowed configuring passes, but the `collapse-docs` pass was
removed ages ago, and the ability to configure passes is about to be removed.
Rollup of 7 pull requests
Successful merges:
- #91858 (pass -Wl,-z,origin to set DF_ORIGIN when using rpath)
- #91923 (Remove `in_band_lifetimes` from `rustc_query_impl`)
- #91925 (Remove `in_band_lifetimes` from `rustc_privacy`)
- #91977 (Clean up search code and unify function returned values)
- #92018 (Fix typo in "new region bound" suggestion)
- #92022 (Eliminate duplicate codes of expected_found_bool)
- #92032 (hir: Do not introduce dummy type names for `extern` blocks in def paths)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Add a space and 2 grave accents
I only noticed this because I have this implementation copy pasted in some places in my code and I really can't wait for this to be stabilized...
Use a const ParamEnv when in default_method_body_is_const
r? `@oli-obk`
This PR fixes the param_env function to return `constness: Const` correctly for trait methods marked with `#[default_method_body_is_const]`. The snippet below is erroneously accepted by the compiler and has been fixed by this change. ([Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=12dc6681b2eeee5f604203d96259eeb4))
```rust
#![feature(const_fn_trait_bound)]
#![feature(const_trait_impl)]
trait Tr {}
impl Tr for () {}
const fn foo<T>() where T: ~const Tr {}
pub trait Foo {
#[default_method_body_is_const]
fn foo() {
foo::<()>();
}
}
```
rustc_codegen_llvm: Give each codegen unit a unique DWARF name on all platforms, not just Apple ones.
To avoid breaking split DWARF, we need to ensure that each codegen unit has a
unique `DW_AT_name`. This is because there's a remote chance that different
codegen units for the same module will have entirely identical DWARF entries
for the purpose of the DWO ID, which would violate Appendix F ("Split Dwarf
Object Files") of the DWARF 5 specification. LLVM uses the algorithm specified
in section 7.32 "Type Signature Computation" to compute the DWO ID, which does
not include any fields that would distinguish compilation units. So we must
embed the codegen unit name into the `DW_AT_name`.
Closes#88521.
Remove `in_band_lifetimes` from `rustc_codegen_llvm`
See #91867 for more information.
This one took a while. This crate has dozens of functions not associated with any type, and most of them were using in-band lifetimes for `'ll` and `'tcx`.
Apply path remapping to DW_AT_GNU_dwo_name when producing split DWARF
`--remap-path-prefix` doesn't apply to paths to `.o` (in case of packed) or `.dwo` (in case of unpacked) files in `DW_AT_GNU_dwo_name`. GCC also has this bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91888
hir: Do not introduce dummy type names for `extern` blocks in def paths
Use a separate nameless `DefPathData` variant instead.
Extracted from https://github.com/rust-lang/rust/pull/91795.
Clean up search code and unify function returned values
This PR is a cleanup: there is no changes in the search results or in the UI.
Depending if it was "literal search" or not, it was either returning booleans or integers. It's pretty bad so instead it all returns integers.
Another thing I did was to move the add and checks into a `addIntoResults` function to simplify things.
Last thing: I removed a loop in the `sortResults` function and moved its code directly into the first loop.
All these changes are done to make #90630 much smaller.
r? `@jsha`
pass -Wl,-z,origin to set DF_ORIGIN when using rpath
DF_ORIGIN flag signifies that the object being loaded may make reference to the $ORIGIN substitution string.
Some implementations are just ignoring [DF_ORIGIN](http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#df_flags) and do [substitution](http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#substitution) for $ORIGIN if present (whatever DF_ORIGIN presence or not) like glibc. But some others mandate the present of DF_ORIGIN for the substitution (like OpenBSD).
Set the flag inconditionally if rpath is wanted.
One possible fallout is if the linker rejects `-z origin` option.
Update stdlib to the 2021 edition
progress towards https://github.com/rust-lang/rust/issues/88638
I couldnt find a way to run the 2018 style panic tests against 2018 so I just deleted them, maybe theres a way to do it that I missed though?
Improve suggestion to change struct field to &mut
r? ``@estebank``
Now displays a proper underline style suggestion instead of including the code change inline with the message.
Mark defaulted `PartialEq`/`PartialOrd` methods as const
WIthout it, `const` impls of these traits are unpleasant to write. I think this kind of change is allowed now. although it looks like it might require some Miri tweaks. Let's find out.
r? ```@fee1-dead```
Rollup of 7 pull requests
Successful merges:
- #87901 (Fix suggestion of additional `pub` when using `pub pub fn ...`)
- #89090 (Lint bare traits in AstConv.)
- #91818 (Show the unused type for `unused_results` lint)
- #91910 (miri: lift restriction on extern types being the only field in a struct)
- #91928 (Constify (most) `Option` methods)
- #91975 (Move generator check earlier in inlining.)
- #92016 (builtin_macros: allow external consumers for AsmArgs parsing)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Move generator check earlier in inlining.
Inlining into generator may create references to other generators. For instance, inlining `Pin::<&mut from_generator::GenFuture<[generator1]>>::new_unchecked` into `generator2`. This cross reference can then create cycles when computing inlining for `generator1`.
In order to avoid this kind of surprises, we forbid all inlining into generators, and rely on LLVM to do the right thing. The existing `remove-zst-query-cycle` already ICEs in inline-mir mode, so we use it as test.
Split from #91743.
Show the unused type for `unused_results` lint
I think it's helpful to know what type was unused when looking at these
warnings. The type will likely determine whether the result *should* be
used, or whether it should just be ignored.
Including the type also matches the behavior of the `must_use` lint:
unused `SomeType` that must be used.
Lint bare traits in AstConv.
Removing the lint from lowering allows to:
- make lowering querification easier;
- have the lint implementation in only one place.
r? `@estebank`
Fix suggestion of additional `pub` when using `pub pub fn ...`
Fix#87694.
Marked as draft to start with because I want to explore doing the same fix for `const const fn` and other repeated-but-valid keywords.
`@rustbot` label A-diagnostics D-invalid-suggestion T-compiler