Make weak item traversal deterministic
Fix#81296.
(No test added. The relevant test *is* ui/panic-handler/weak-lang-item.rs, and this change should make it less flaky.)
Refine "remove semicolon" suggestion in trait selection
Don't suggest it if the last statement doesn't have a semicolon
Fixes#81098
See also #54771 for why this suggestion was added
rustc_codegen_ssa: use wall time for codegen_to_LLVM_IR time-passes entry
Use elapsed wall time spent on codegen_to_LLVM_IR for all CGUs as a
whole, rather than the sum for each CGU (the distinction matters for
parallel builds, where some CGUs are processed in parallel).
Enforce that query results implement Debug
Currently, we require that query keys implement `Debug`, but we do not do the same for query values. This can make incremental compilation bugs difficult to debug - there isn't a good place to print out the result loaded from disk.
This PR adds `Debug` bounds to several query-related functions, allowing us to debug-print the query value when an 'unstable fingerprint' error occurs. This required adding `#[derive(Debug)]` to a fairly large number of types - hopefully, this doesn't have much of an impact on compiler bootstrapping times.
Prevent query cycles in the MIR inliner
r? `@eddyb` `@wesleywiser`
cc `@rust-lang/wg-mir-opt`
The general design is that we have a new query that is run on the `validated_mir` instead of on the `optimized_mir`. That query is forced before going into the optimization pipeline, so as to not try to read from a stolen MIR.
The query should not be cached cross crate, as you should never call it for items from other crates. By its very design calls into other crates can never cause query cycles.
This is a pessimistic approach to inlining, since we strictly have more calls in the `validated_mir` than we have in `optimized_mir`, but that's not a problem imo.
Use elapsed wall time spent on codegen_to_LLVM_IR for all CGUs as a
whole, rather than the sum for each CGU (the distinction matters for
parallel builds, where some CGUs are processed in parallel).
Rollup of 14 pull requests
Successful merges:
- #75180 (Implement Error for &(impl Error))
- #78578 (Permit mutable references in all const contexts)
- #79174 (Make std::future a re-export of core::future)
- #79884 (Replace magic numbers with existing constants)
- #80855 (Expand assert!(expr, args..) to include $crate for hygiene on 2021.)
- #80933 (Fix sysroot option not being honored across rustc)
- #81259 (Replace version_check dependency with own version parsing code)
- #81264 (Add unstable option to control doctest run directory)
- #81279 (Small refactor in typeck)
- #81297 (Don't provide backend_optimization_level query for extern crates)
- #81302 (Fix rendering of stabilization version for trait implementors)
- #81310 (Do not mark unit variants as used when in path pattern)
- #81320 (Make bad shlex parsing a pretty error)
- #81338 (Clean up `dominators_given_rpo`)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Do not mark unit variants as used when in path pattern
Record that we are processing a pattern so that code responsible for
handling path resolution can correctly decide whether to mark it as
used or not.
Closes#76788.
Small refactor in typeck
- `check_impl_items_against_trait` only queries and walks through associated items once
- extracted function that reports errors
- don't check specialization validity when trait item does not match
- small additional cleanups
Replace version_check dependency with own version parsing code
This gives compiler maintainers a better degree of control
over how the version gets parsed and is a good way to ensure
that there are no changes of behaviour in the future.
Also, issue a warning if the version is invalid instead of erroring
so that we stay forwards compatible with possible future changes
of the versioning scheme.
Last, this improves the present test a little.
Fixes#79436
r? `@petrochenkov`
Fix sysroot option not being honored across rustc
Change link_sanitizer_runtime() to check if the sanitizer library exists in the specified/session sysroot, and if it doesn't exist, use the default sysroot. (See #79253.)
Expand assert!(expr, args..) to include $crate for hygiene on 2021.
This makes `assert!(expr, args..)` properly hygienic in Rust 2021.
This is part of rust-lang/rfcs#3007, see #80162.
Before edition 2021, this was a breaking change, as `std::panic` and `core::panic` are different. In edition 2021 they will be identical, making it possible to apply proper hygiene here.
Target stack-probe support configurable finely
This adds capability to configure the target's stack probe support in a
more precise manner than just on/off. In particular now we allow
choosing between always inline-asm, always call or either one of those
depending on the LLVM version.
Note that this removes the ability to turn off the generation of the
stack-probe attribute. This is valid to replace it with inline-asm for all targets because
`probe-stack="inline-asm"` will not generate any machine code on targets
that do not currently support stack probes. This makes support for stack
probes on targets that don't have any right now automatic with LLVM
upgrades in the future.
(This is valid to do based on the fact that clang unconditionally sets
this attribute when `-fstack-clash-protection` is used, AFAICT)
cc #77885
r? `@cuviper`
Various ABI refactorings
This includes changes to the rust abi and various refactorings that will hopefully make it easier to use the abi handling infrastructure of rustc in cg_clif. There are several refactorings that I haven't done. I am opening this draft PR to check that I haven't broken any non x86_64 architectures.
r? `@ghost`
This gives compiler maintainers a better degree of control
over how the version gets parsed and is a good way to ensure
that there are no changes of behaviour in the future.
Also, issue a warning if the version is invalid instead of erroring
so that we stay forwards compatible with possible future changes
of the versioning scheme.
Last, this improves the present test a little.
Due to macro expansion, its possible to end up with two distinct
`ExpnId`s that have the same `ExpnData` contents. This violates the
contract of `HashStable`, since two unequal `ExpnId`s will end up with
equal `Fingerprint`s.
This commit adds a `disambiguator` field to `ExpnData`, which is used to
force two otherwise-equivalent `ExpnData`s to be distinct.
Fix <unknown> queries and add more timing info to render_html
Closes https://github.com/rust-lang/rust/issues/81251.
## Fix `<unknown>` queries
This happened because `alloc_query_strings` was never called.
## Add more timing info to render_html
This still has some issues I'm not sure how to work out:
- `create_renderer` and `renderer_after_krate` aren't shown by default.
I want something like `verbose_generic_activity_with_arg`, but it doesn't exist.
I'm also not sure how to show activities that aren't on by default - I
tried `-Z self-profile -Z self-profile-args=all`, but it didn't show up.
r? `@wesleywiser`
This avoids each tool having to separately find and call
`self_profile_alloc_strings`.
- Don't compute the global context if it hasn't yet been computed
This avoids giving extraneous errors about unresolved names if an error
occurs during parsing.
avoid promoting division, modulo and indexing operations that could fail
For division, `x / y` will still be promoted if `y` is a non-zero integer literal; however, `1/(1+1)` will not be promoted any more.
While at it, also see if we can reject promoting floating-point arithmetic (which are [complicated](https://github.com/rust-lang/unsafe-code-guidelines/issues/237) so maybe we should not promote them).
This will need a crater run to see if there's code out there that relies on these things being promoted.
If we can land this, promoteds in `fn`/`const fn` cannot fail to evaluate any more, which should let us do some simplifications in codegen/Miri!
Cc https://github.com/rust-lang/rfcs/pull/3027
Fixes https://github.com/rust-lang/rust/issues/61821
r? `@oli-obk`