diff --git a/Cargo.lock b/Cargo.lock
index 6ea4cd8f5aca..23c7a5bc60f1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2463,7 +2463,7 @@ dependencies = [
"indexmap",
"memchr",
"ruzstd 0.7.0",
- "wasmparser",
+ "wasmparser 0.215.0",
]
[[package]]
@@ -3133,7 +3133,7 @@ dependencies = [
"regex",
"serde_json",
"similar",
- "wasmparser",
+ "wasmparser 0.216.0",
]
[[package]]
@@ -5779,9 +5779,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasi-preview1-component-adapter-provider"
-version = "23.0.2"
+version = "24.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f91d3d13afef569b9fc80cfbb807c87c16ef49bd3ac1a93285ea6a264b600d2d"
+checksum = "36e6cadfa74538edd5409b6f8c79628436529138e9618b7373bec7aae7805835"
[[package]]
name = "wasm-bindgen"
@@ -5840,16 +5840,16 @@ checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484"
[[package]]
name = "wasm-component-ld"
-version = "0.5.6"
+version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "51449c63d1ce69f92b8465a084ed5b91f1a7eb583fa95796650a6bfcffc4f9cb"
+checksum = "13261270d3ac58ffae0219ae34f297a7e24f9ee3b13b29be579132c588a83519"
dependencies = [
"anyhow",
"clap",
"lexopt",
"tempfile",
"wasi-preview1-component-adapter-provider",
- "wasmparser",
+ "wasmparser 0.216.0",
"wat",
"wit-component",
"wit-parser",
@@ -5864,19 +5864,19 @@ dependencies = [
[[package]]
name = "wasm-encoder"
-version = "0.215.0"
+version = "0.216.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4fb56df3e06b8e6b77e37d2969a50ba51281029a9aeb3855e76b7f49b6418847"
+checksum = "04c23aebea22c8a75833ae08ed31ccc020835b12a41999e58c31464271b94a88"
dependencies = [
"leb128",
- "wasmparser",
+ "wasmparser 0.216.0",
]
[[package]]
name = "wasm-metadata"
-version = "0.215.0"
+version = "0.216.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0c6bb07c5576b608f7a2a9baa2294c1a3584a249965d695a9814a496cb6d232f"
+checksum = "47c8154d703a6b0e45acf6bd172fa002fc3c7058a9f7615e517220aeca27c638"
dependencies = [
"anyhow",
"indexmap",
@@ -5885,7 +5885,7 @@ dependencies = [
"serde_json",
"spdx",
"wasm-encoder",
- "wasmparser",
+ "wasmparser 0.216.0",
]
[[package]]
@@ -5893,6 +5893,15 @@ name = "wasmparser"
version = "0.215.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53fbde0881f24199b81cf49b6ff8f9c145ac8eb1b7fc439adb5c099734f7d90e"
+dependencies = [
+ "bitflags 2.6.0",
+]
+
+[[package]]
+name = "wasmparser"
+version = "0.216.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bcdee6bea3619d311fb4b299721e89a986c3470f804b6d534340e412589028e3"
dependencies = [
"ahash",
"bitflags 2.6.0",
@@ -5904,9 +5913,9 @@ dependencies = [
[[package]]
name = "wast"
-version = "215.0.0"
+version = "216.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1ff1d00d893593249e60720be04a7c1f42f1c4dc3806a2869f4e66ab61eb54cb"
+checksum = "f7eb1f2eecd913fdde0dc6c3439d0f24530a98ac6db6cb3d14d92a5328554a08"
dependencies = [
"bumpalo",
"leb128",
@@ -5917,9 +5926,9 @@ dependencies = [
[[package]]
name = "wat"
-version = "1.215.0"
+version = "1.216.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "670bf4d9c8cf76ae242d70ded47c546525b6dafaa6871f9bcb065344bf2b4e3d"
+checksum = "ac0409090fb5154f95fb5ba3235675fd9e579e731524d63b6a2f653e1280c82a"
dependencies = [
"wast",
]
@@ -6206,9 +6215,9 @@ dependencies = [
[[package]]
name = "wit-component"
-version = "0.215.0"
+version = "0.216.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f725e3885fc5890648be5c5cbc1353b755dc932aa5f1aa7de968b912a3280743"
+checksum = "7e2ca3ece38ea2447a9069b43074ba73d96dde1944cba276c54e41371745f9dc"
dependencies = [
"anyhow",
"bitflags 2.6.0",
@@ -6219,15 +6228,15 @@ dependencies = [
"serde_json",
"wasm-encoder",
"wasm-metadata",
- "wasmparser",
+ "wasmparser 0.216.0",
"wit-parser",
]
[[package]]
name = "wit-parser"
-version = "0.215.0"
+version = "0.216.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "935a97eaffd57c3b413aa510f8f0b550a4a9fe7d59e79cd8b89a83dcb860321f"
+checksum = "a4d108165c1167a4ccc8a803dcf5c28e0a51d6739fd228cc7adce768632c764c"
dependencies = [
"anyhow",
"id-arena",
@@ -6238,7 +6247,7 @@ dependencies = [
"serde_derive",
"serde_json",
"unicode-xid",
- "wasmparser",
+ "wasmparser 0.216.0",
]
[[package]]
diff --git a/RELEASES.md b/RELEASES.md
index 5e4827be4ecf..6aba476103e7 100644
--- a/RELEASES.md
+++ b/RELEASES.md
@@ -1,3 +1,117 @@
+Version 1.81.0 (2024-09-05)
+==========================
+
+
+
+Language
+--------
+
+- [Abort on uncaught panics in `extern "C"` functions.](https://github.com/rust-lang/rust/pull/116088/)
+- [Fix ambiguous cases of multiple `&` in elided self lifetimes.](https://github.com/rust-lang/rust/pull/117967/)
+- [Stabilize `#[expect]` for lints (RFC 2383),](https://github.com/rust-lang/rust/pull/120924/) like `#[allow]` with a warning if the lint is _not_ fulfilled.
+- [Change method resolution to constrain hidden types instead of rejecting method candidates.](https://github.com/rust-lang/rust/pull/123962/)
+- [Bump `elided_lifetimes_in_associated_constant` to deny.](https://github.com/rust-lang/rust/pull/124211/)
+- [`offset_from`: always allow pointers to point to the same address.](https://github.com/rust-lang/rust/pull/124921/)
+- [Allow constraining opaque types during subtyping in the trait system.](https://github.com/rust-lang/rust/pull/125447/)
+- [Allow constraining opaque types during various unsizing casts.](https://github.com/rust-lang/rust/pull/125610/)
+- [Deny keyword lifetimes pre-expansion.](https://github.com/rust-lang/rust/pull/126762/)
+
+
+
+Compiler
+--------
+
+- [Make casts of pointers to trait objects stricter.](https://github.com/rust-lang/rust/pull/120248/)
+- [Check alias args for well-formedness even if they have escaping bound vars.](https://github.com/rust-lang/rust/pull/123737/)
+- [Deprecate no-op codegen option `-Cinline-threshold=...`.](https://github.com/rust-lang/rust/pull/124712/)
+- [Re-implement a type-size based limit.](https://github.com/rust-lang/rust/pull/125507/)
+- [Properly account for alignment in `transmute` size checks.](https://github.com/rust-lang/rust/pull/125740/)
+- [Remove the `box_pointers` lint.](https://github.com/rust-lang/rust/pull/126018/)
+- [Ensure the interpreter checks bool/char for validity when they are used in a cast.](https://github.com/rust-lang/rust/pull/126265/)
+- [Improve coverage instrumentation for functions containing nested items.](https://github.com/rust-lang/rust/pull/127199/)
+- Target changes:
+ - [Add Tier 3 `no_std` Xtensa targets:](https://github.com/rust-lang/rust/pull/125141/) `xtensa-esp32-none-elf`, `xtensa-esp32s2-none-elf`, `xtensa-esp32s3-none-elf`
+ - [Add Tier 3 `std` Xtensa targets:](https://github.com/rust-lang/rust/pull/126380/) `xtensa-esp32-espidf`, `xtensa-esp32s2-espidf`, `xtensa-esp32s3-espidf`
+ - [Add Tier 3 i686 Redox OS target:](https://github.com/rust-lang/rust/pull/126192/) `i686-unknown-redox`
+ - [Promote `arm64ec-pc-windows-msvc` to Tier 2.](https://github.com/rust-lang/rust/pull/126039/)
+ - [Promote `wasm32-wasip2` to Tier 2.](https://github.com/rust-lang/rust/pull/126967/)
+ - [Promote `loongarch64-unknown-linux-musl` to Tier 2 with host tools.](https://github.com/rust-lang/rust/pull/126298/)
+ - [Enable full tools and profiler for LoongArch Linux targets.](https://github.com/rust-lang/rust/pull/127078/)
+ - [Unconditionally warn on usage of `wasm32-wasi`.](https://github.com/rust-lang/rust/pull/126662/) (see compatibility note below)
+ - Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.
+
+
+
+Libraries
+---------
+
+- [Split core's `PanicInfo` and std's `PanicInfo`.](https://github.com/rust-lang/rust/pull/115974/) (see compatibility note below)
+- [Generalize `{Rc,Arc}::make_mut()` to unsized types.](https://github.com/rust-lang/rust/pull/116113/)
+- [Replace sort implementations with stable `driftsort` and unstable `ipnsort`.](https://github.com/rust-lang/rust/pull/124032/) All `slice::sort*` and `slice::select_nth*` methods are expected to see significant performance improvements. See the [research project](https://github.com/Voultapher/sort-research-rs) for more details.
+- [Document behavior of `create_dir_all` with respect to empty paths.](https://github.com/rust-lang/rust/pull/125112/)
+- [Fix interleaved output in the default panic hook when multiple threads panic simultaneously.](https://github.com/rust-lang/rust/pull/127397/)
+
+
+
+Stabilized APIs
+---------------
+
+- [`core::error`](https://doc.rust-lang.org/stable/core/error/index.html)
+- [`hint::assert_unchecked`](https://doc.rust-lang.org/stable/core/hint/fn.assert_unchecked.html)
+- [`fs::exists`](https://doc.rust-lang.org/stable/std/fs/fn.exists.html)
+- [`AtomicBool::fetch_not`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicBool.html#method.fetch_not)
+- [`Duration::abs_diff`](https://doc.rust-lang.org/stable/core/time/struct.Duration.html#method.abs_diff)
+- [`IoSlice::advance`](https://doc.rust-lang.org/stable/std/io/struct.IoSlice.html#method.advance)
+- [`IoSlice::advance_slices`](https://doc.rust-lang.org/stable/std/io/struct.IoSlice.html#method.advance_slices)
+- [`IoSliceMut::advance`](https://doc.rust-lang.org/stable/std/io/struct.IoSliceMut.html#method.advance)
+- [`IoSliceMut::advance_slices`](https://doc.rust-lang.org/stable/std/io/struct.IoSliceMut.html#method.advance_slices)
+- [`PanicHookInfo`](https://doc.rust-lang.org/stable/std/panic/struct.PanicHookInfo.html)
+- [`PanicInfo::message`](https://doc.rust-lang.org/stable/core/panic/struct.PanicInfo.html#method.message)
+- [`PanicMessage`](https://doc.rust-lang.org/stable/core/panic/struct.PanicMessage.html)
+
+These APIs are now stable in const contexts:
+
+- [`char::from_u32_unchecked`](https://doc.rust-lang.org/stable/core/char/fn.from_u32_unchecked.html) (function)
+- [`char::from_u32_unchecked`](https://doc.rust-lang.org/stable/core/primitive.char.html#method.from_u32_unchecked) (method)
+- [`CStr::count_bytes`](https://doc.rust-lang.org/stable/core/ffi/c_str/struct.CStr.html#method.count_bytes)
+- [`CStr::from_ptr`](https://doc.rust-lang.org/stable/core/ffi/c_str/struct.CStr.html#method.from_ptr)
+
+
+
+Cargo
+-----
+
+- [Generated `.cargo_vcs_info.json` is always included, even when `--allow-dirty` is passed.](https://github.com/rust-lang/cargo/pull/13960/)
+- [Disallow `package.license-file` and `package.readme` pointing to non-existent files during packaging.](https://github.com/rust-lang/cargo/pull/13921/)
+- [Disallow passing `--release`/`--debug` flag along with the `--profile` flag.](https://github.com/rust-lang/cargo/pull/13971/)
+- [Remove `lib.plugin` key support in `Cargo.toml`. Rust plugin support has been deprecated for four years and was removed in 1.75.0.](https://github.com/rust-lang/cargo/pull/13902/)
+
+
+
+Compatibility Notes
+-------------------
+
+* Usage of the `wasm32-wasi` target will now issue a compiler warning and request users switch to the `wasm32-wasip1` target instead. Both targets are the same, `wasm32-wasi` is only being renamed, and this [change to the WASI target](https://blog.rust-lang.org/2024/04/09/updates-to-rusts-wasi-targets.html) is being done to enable removing `wasm32-wasi` in January 2025.
+
+* We have renamed `std::panic::PanicInfo` to `std::panic::PanicHookInfo`. The old name will continue to work as an alias, but will result in a deprecation warning starting in Rust 1.82.0.
+
+ `core::panic::PanicInfo` will remain unchanged, however, as this is now a *different type*.
+
+ The reason is that these types have different roles: `std::panic::PanicHookInfo` is the argument to the [panic hook](https://doc.rust-lang.org/stable/std/panic/fn.set_hook.html) in std context (where panics can have an arbitrary payload), while `core::panic::PanicInfo` is the argument to the [`#[panic_handler]`](https://doc.rust-lang.org/nomicon/panic-handler.html) in no_std context (where panics always carry a formatted *message*). Separating these types allows us to add more useful methods to these types, such as `std::panic::PanicHookInfo::payload_as_str()` and `core::panic::PanicInfo::message()`.
+
+* The new sort implementations may panic if a type's implementation of [`Ord`](https://doc.rust-lang.org/std/cmp/trait.Ord.html) (or the given comparison function) does not implement a [total order](https://en.wikipedia.org/wiki/Total_order) as the trait requires. `Ord`'s supertraits (`PartialOrd`, `Eq`, and `PartialEq`) must also be consistent. The previous implementations would not "notice" any problem, but the new implementations have a good chance of detecting inconsistencies, throwing a panic rather than returning knowingly unsorted data.
+
+
+
+Internal Changes
+----------------
+
+These changes do not affect any public interfaces of Rust, but they represent
+significant improvements to the performance or internals of rustc and related
+tools.
+
+- [Add a Rust-for Linux `auto` CI job to check kernel builds.](https://github.com/rust-lang/rust/pull/125209/)
+
Version 1.80.0 (2024-07-25)
==========================
diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs
index 43d87b96ead9..f1dddb3acaca 100644
--- a/compiler/rustc_ast/src/token.rs
+++ b/compiler/rustc_ast/src/token.rs
@@ -486,6 +486,9 @@ impl Token {
}
/// Returns `true` if the token can appear at the start of an expression.
+ ///
+ /// **NB**: Take care when modifying this function, since it will change
+ /// the stable set of tokens that are allowed to match an expr nonterminal.
pub fn can_begin_expr(&self) -> bool {
match self.uninterpolate().kind {
Ident(name, is_raw) =>
@@ -504,10 +507,13 @@ impl Token {
PathSep | // global path
Lifetime(..) | // labeled loop
Pound => true, // expression attributes
- Interpolated(ref nt) => matches!(&**nt, NtLiteral(..) |
- NtExpr(..) |
- NtBlock(..) |
- NtPath(..)),
+ Interpolated(ref nt) =>
+ matches!(&**nt,
+ NtBlock(..) |
+ NtExpr(..) |
+ NtLiteral(..) |
+ NtPath(..)
+ ),
_ => false,
}
}
@@ -515,23 +521,32 @@ impl Token {
/// Returns `true` if the token can appear at the start of a pattern.
///
/// Shamelessly borrowed from `can_begin_expr`, only used for diagnostics right now.
- pub fn can_begin_pattern(&self) -> bool {
- match self.uninterpolate().kind {
- Ident(name, is_raw) =>
- ident_can_begin_expr(name, self.span, is_raw), // value name or keyword
- | OpenDelim(Delimiter::Bracket | Delimiter::Parenthesis) // tuple or array
- | Literal(..) // literal
- | BinOp(Minus) // unary minus
- | BinOp(And) // reference
- | AndAnd // double reference
- // DotDotDot is no longer supported
- | DotDot | DotDotDot | DotDotEq // ranges
- | Lt | BinOp(Shl) // associated path
- | PathSep => true, // global path
- Interpolated(ref nt) => matches!(&**nt, NtLiteral(..) |
- NtPat(..) |
- NtBlock(..) |
- NtPath(..)),
+ pub fn can_begin_pattern(&self, pat_kind: NtPatKind) -> bool {
+ match &self.uninterpolate().kind {
+ // box, ref, mut, and other identifiers (can stricten)
+ Ident(..) | NtIdent(..) |
+ OpenDelim(Delimiter::Parenthesis) | // tuple pattern
+ OpenDelim(Delimiter::Bracket) | // slice pattern
+ BinOp(And) | // reference
+ BinOp(Minus) | // negative literal
+ AndAnd | // double reference
+ Literal(_) | // literal
+ DotDot | // range pattern (future compat)
+ DotDotDot | // range pattern (future compat)
+ PathSep | // path
+ Lt | // path (UFCS constant)
+ BinOp(Shl) => true, // path (double UFCS)
+ // leading vert `|` or-pattern
+ BinOp(Or) => matches!(pat_kind, PatWithOr),
+ Interpolated(nt) =>
+ matches!(&**nt,
+ | NtExpr(..)
+ | NtLiteral(..)
+ | NtMeta(..)
+ | NtPat(..)
+ | NtPath(..)
+ | NtTy(..)
+ ),
_ => false,
}
}
diff --git a/compiler/rustc_borrowck/src/borrow_set.rs b/compiler/rustc_borrowck/src/borrow_set.rs
index 51b420c441a7..fbda44550a19 100644
--- a/compiler/rustc_borrowck/src/borrow_set.rs
+++ b/compiler/rustc_borrowck/src/borrow_set.rs
@@ -8,6 +8,7 @@ use rustc_middle::mir::{self, traversal, Body, Local, Location};
use rustc_middle::span_bug;
use rustc_middle::ty::{RegionVid, TyCtxt};
use rustc_mir_dataflow::move_paths::MoveData;
+use tracing::debug;
use crate::path_utils::allow_two_phase_borrow;
use crate::place_ext::PlaceExt;
diff --git a/compiler/rustc_borrowck/src/constraints/mod.rs b/compiler/rustc_borrowck/src/constraints/mod.rs
index 7062632de664..ca435ee08650 100644
--- a/compiler/rustc_borrowck/src/constraints/mod.rs
+++ b/compiler/rustc_borrowck/src/constraints/mod.rs
@@ -5,6 +5,7 @@ use rustc_index::{IndexSlice, IndexVec};
use rustc_middle::mir::ConstraintCategory;
use rustc_middle::ty::{RegionVid, TyCtxt, VarianceDiagInfo};
use rustc_span::Span;
+use tracing::{debug, instrument};
use crate::region_infer::{ConstraintSccs, RegionDefinition, RegionTracker};
use crate::type_check::Locations;
diff --git a/compiler/rustc_borrowck/src/dataflow.rs b/compiler/rustc_borrowck/src/dataflow.rs
index 2795bc7162fc..9bb6109e66d9 100644
--- a/compiler/rustc_borrowck/src/dataflow.rs
+++ b/compiler/rustc_borrowck/src/dataflow.rs
@@ -10,6 +10,7 @@ use rustc_middle::ty::{RegionVid, TyCtxt};
use rustc_mir_dataflow::fmt::DebugWithContext;
use rustc_mir_dataflow::impls::{EverInitializedPlaces, MaybeUninitializedPlaces};
use rustc_mir_dataflow::{Analysis, AnalysisDomain, GenKill, Results, ResultsVisitable};
+use tracing::debug;
use crate::{places_conflict, BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext};
diff --git a/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs
index 52eda7217739..8a4e89d47bdc 100644
--- a/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs
@@ -19,6 +19,7 @@ use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::traits::query::type_op;
use rustc_trait_selection::traits::ObligationCtxt;
use rustc_traits::{type_op_ascribe_user_type_with_span, type_op_prove_predicate_with_cause};
+use tracing::{debug, instrument};
use crate::region_infer::values::RegionElement;
use crate::session_diagnostics::{
diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
index aaeedde2bedc..9951f9fcda69 100644
--- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
@@ -40,6 +40,7 @@ use rustc_trait_selection::error_reporting::traits::FindExprBySpan;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{Obligation, ObligationCause, ObligationCtxt};
+use tracing::{debug, instrument};
use super::explain_borrow::{BorrowExplanation, LaterUseKind};
use super::{DescribePlaceOpt, RegionName, RegionNameSource, UseSpans};
diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
index d85959c9a291..91b02a36d004 100644
--- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
@@ -20,6 +20,7 @@ use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt};
use rustc_span::symbol::{kw, Symbol};
use rustc_span::{sym, DesugaringKind, Span};
use rustc_trait_selection::error_reporting::traits::FindExprBySpan;
+use tracing::{debug, instrument};
use super::{find_use, RegionName, UseSpans};
use crate::borrow_set::BorrowData;
diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs
index 33f91d7ad304..5ab66963409a 100644
--- a/compiler/rustc_borrowck/src/diagnostics/mod.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs
@@ -27,6 +27,7 @@ use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{
type_known_to_meet_bound_modulo_regions, FulfillmentErrorCode,
};
+use tracing::debug;
use super::borrow_set::BorrowData;
use super::MirBorrowckCtxt;
diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs
index 42b1ffd58ad3..3dab027bff05 100644
--- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs
@@ -10,6 +10,7 @@ use rustc_middle::ty::{self, Ty};
use rustc_mir_dataflow::move_paths::{LookupResult, MovePathIndex};
use rustc_span::{BytePos, ExpnKind, MacroKind, Span};
use rustc_trait_selection::error_reporting::traits::FindExprBySpan;
+use tracing::debug;
use crate::diagnostics::{CapturedMessageOpt, DescribePlaceOpt, UseSpans};
use crate::prefixes::PrefixSet;
diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
index 7b791928689c..337125f5ecc1 100644
--- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
@@ -20,6 +20,7 @@ use rustc_target::abi::FieldIdx;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits;
+use tracing::debug;
use crate::diagnostics::BorrowedContentSource;
use crate::util::FindAssignments;
diff --git a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs
index a59b7b3cde91..b205dc9ff492 100644
--- a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs
@@ -10,6 +10,7 @@ use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::Diag;
use rustc_middle::ty::RegionVid;
use smallvec::SmallVec;
+use tracing::debug;
use super::{ErrorConstraintInfo, RegionName, RegionNameSource};
use crate::MirBorrowckCtxt;
diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs
index ab48a09cfa4c..d49d36dedafc 100644
--- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs
@@ -25,6 +25,7 @@ use rustc_trait_selection::error_reporting::infer::region::unexpected_hidden_reg
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{Obligation, ObligationCtxt};
+use tracing::{debug, instrument, trace};
use super::{OutlivesSuggestionBuilder, RegionName, RegionNameSource};
use crate::nll::ConstraintDescription;
diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs
index 12aedf6fe088..cb05812ec7b5 100644
--- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs
@@ -14,6 +14,7 @@ use rustc_middle::{bug, span_bug};
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::{Span, DUMMY_SP};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
+use tracing::{debug, instrument};
use crate::universal_regions::DefiningTy;
use crate::MirBorrowckCtxt;
diff --git a/compiler/rustc_borrowck/src/diagnostics/var_name.rs b/compiler/rustc_borrowck/src/diagnostics/var_name.rs
index 3e9f975b66bb..2a4fa1e00191 100644
--- a/compiler/rustc_borrowck/src/diagnostics/var_name.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/var_name.rs
@@ -3,6 +3,7 @@ use rustc_middle::mir::{Body, Local};
use rustc_middle::ty::{self, RegionVid, TyCtxt};
use rustc_span::symbol::Symbol;
use rustc_span::Span;
+use tracing::debug;
use crate::region_infer::RegionInferenceContext;
diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs
index bb1aea14693e..ffb350b1d1f0 100644
--- a/compiler/rustc_borrowck/src/lib.rs
+++ b/compiler/rustc_borrowck/src/lib.rs
@@ -15,9 +15,6 @@
#![warn(unreachable_pub)]
// tidy-alphabetical-end
-#[macro_use]
-extern crate tracing;
-
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::marker::PhantomData;
@@ -51,6 +48,7 @@ use rustc_session::lint::builtin::UNUSED_MUT;
use rustc_span::{Span, Symbol};
use rustc_target::abi::FieldIdx;
use smallvec::SmallVec;
+use tracing::{debug, instrument};
use self::diagnostics::{AccessKind, IllegalMoveOriginKind, MoveError, RegionName};
use self::location::LocationTable;
@@ -229,7 +227,7 @@ fn do_mir_borrowck<'tcx>(
// Dump MIR results into a file, if that is enabled. This let us
// write unit-tests, as well as helping with debugging.
- nll::dump_mir_results(&infcx, body, ®ioncx, &opt_closure_req);
+ nll::dump_nll_mir(&infcx, body, ®ioncx, &opt_closure_req, &borrow_set);
// We also have a `#[rustc_regions]` annotation that causes us to dump
// information.
diff --git a/compiler/rustc_borrowck/src/location.rs b/compiler/rustc_borrowck/src/location.rs
index 63e59217e5d7..fbe5f94ed42c 100644
--- a/compiler/rustc_borrowck/src/location.rs
+++ b/compiler/rustc_borrowck/src/location.rs
@@ -1,5 +1,6 @@
use rustc_index::IndexVec;
use rustc_middle::mir::{BasicBlock, Body, Location};
+use tracing::debug;
/// Maps between a MIR Location, which identifies a particular
/// statement within a basic block, to a "rich location", which
diff --git a/compiler/rustc_borrowck/src/member_constraints.rs b/compiler/rustc_borrowck/src/member_constraints.rs
index 499c32396d0a..fc621a3b8283 100644
--- a/compiler/rustc_borrowck/src/member_constraints.rs
+++ b/compiler/rustc_borrowck/src/member_constraints.rs
@@ -7,6 +7,7 @@ use rustc_index::{IndexSlice, IndexVec};
use rustc_middle::infer::MemberConstraint;
use rustc_middle::ty::{self, Ty};
use rustc_span::Span;
+use tracing::debug;
/// Compactly stores a set of `R0 member of [R1...Rn]` constraints,
/// indexed by the region `R0`.
diff --git a/compiler/rustc_borrowck/src/nll.rs b/compiler/rustc_borrowck/src/nll.rs
index af37c028879d..6525befc13b9 100644
--- a/compiler/rustc_borrowck/src/nll.rs
+++ b/compiler/rustc_borrowck/src/nll.rs
@@ -9,6 +9,7 @@ use polonius_engine::{Algorithm, Output};
use rustc_data_structures::fx::FxIndexMap;
use rustc_hir::def_id::LocalDefId;
use rustc_index::IndexSlice;
+use rustc_middle::mir::pretty::{dump_mir_with_options, PrettyPrintMirOptions};
use rustc_middle::mir::{
create_dump_file, dump_enabled, dump_mir, Body, ClosureOutlivesSubject,
ClosureRegionRequirements, PassWhere, Promoted,
@@ -19,7 +20,9 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
use rustc_mir_dataflow::move_paths::MoveData;
use rustc_mir_dataflow::points::DenseLocationMap;
use rustc_mir_dataflow::ResultsCursor;
+use rustc_session::config::MirIncludeSpans;
use rustc_span::symbol::sym;
+use tracing::{debug, instrument};
use crate::borrow_set::BorrowSet;
use crate::consumers::ConsumerOptions;
@@ -208,52 +211,90 @@ pub(crate) fn compute_regions<'cx, 'tcx>(
}
}
-pub(super) fn dump_mir_results<'tcx>(
+/// `-Zdump-mir=nll` dumps MIR annotated with NLL specific information:
+/// - free regions
+/// - inferred region values
+/// - region liveness
+/// - inference constraints and their causes
+///
+/// As well as graphviz `.dot` visualizations of:
+/// - the region constraints graph
+/// - the region SCC graph
+pub(super) fn dump_nll_mir<'tcx>(
infcx: &BorrowckInferCtxt<'tcx>,
body: &Body<'tcx>,
regioncx: &RegionInferenceContext<'tcx>,
closure_region_requirements: &Option>,
+ borrow_set: &BorrowSet<'tcx>,
) {
- if !dump_enabled(infcx.tcx, "nll", body.source.def_id()) {
+ let tcx = infcx.tcx;
+ if !dump_enabled(tcx, "nll", body.source.def_id()) {
return;
}
- dump_mir(infcx.tcx, false, "nll", &0, body, |pass_where, out| {
- match pass_where {
- // Before the CFG, dump out the values for each region variable.
- PassWhere::BeforeCFG => {
- regioncx.dump_mir(infcx.tcx, out)?;
- writeln!(out, "|")?;
-
- if let Some(closure_region_requirements) = closure_region_requirements {
- writeln!(out, "| Free Region Constraints")?;
- for_each_region_constraint(
- infcx.tcx,
- closure_region_requirements,
- &mut |msg| writeln!(out, "| {msg}"),
- )?;
+ // We want the NLL extra comments printed by default in NLL MIR dumps (they were removed in
+ // #112346). Specifying `-Z mir-include-spans` on the CLI still has priority: for example,
+ // they're always disabled in mir-opt tests to make working with blessed dumps easier.
+ let options = PrettyPrintMirOptions {
+ include_extra_comments: matches!(
+ infcx.tcx.sess.opts.unstable_opts.mir_include_spans,
+ MirIncludeSpans::On | MirIncludeSpans::Nll
+ ),
+ };
+ dump_mir_with_options(
+ tcx,
+ false,
+ "nll",
+ &0,
+ body,
+ |pass_where, out| {
+ match pass_where {
+ // Before the CFG, dump out the values for each region variable.
+ PassWhere::BeforeCFG => {
+ regioncx.dump_mir(tcx, out)?;
writeln!(out, "|")?;
+
+ if let Some(closure_region_requirements) = closure_region_requirements {
+ writeln!(out, "| Free Region Constraints")?;
+ for_each_region_constraint(tcx, closure_region_requirements, &mut |msg| {
+ writeln!(out, "| {msg}")
+ })?;
+ writeln!(out, "|")?;
+ }
+
+ if borrow_set.len() > 0 {
+ writeln!(out, "| Borrows")?;
+ for (borrow_idx, borrow_data) in borrow_set.iter_enumerated() {
+ writeln!(
+ out,
+ "| {:?}: issued at {:?} in {:?}",
+ borrow_idx, borrow_data.reserve_location, borrow_data.region
+ )?;
+ }
+ writeln!(out, "|")?;
+ }
}
+
+ PassWhere::BeforeLocation(_) => {}
+
+ PassWhere::AfterTerminator(_) => {}
+
+ PassWhere::BeforeBlock(_) | PassWhere::AfterLocation(_) | PassWhere::AfterCFG => {}
}
+ Ok(())
+ },
+ options,
+ );
- PassWhere::BeforeLocation(_) => {}
-
- PassWhere::AfterTerminator(_) => {}
-
- PassWhere::BeforeBlock(_) | PassWhere::AfterLocation(_) | PassWhere::AfterCFG => {}
- }
- Ok(())
- });
-
- // Also dump the inference graph constraints as a graphviz file.
+ // Also dump the region constraint graph as a graphviz file.
let _: io::Result<()> = try {
- let mut file = create_dump_file(infcx.tcx, "regioncx.all.dot", false, "nll", &0, body)?;
+ let mut file = create_dump_file(tcx, "regioncx.all.dot", false, "nll", &0, body)?;
regioncx.dump_graphviz_raw_constraints(&mut file)?;
};
- // Also dump the inference graph constraints as a graphviz file.
+ // Also dump the region constraint SCC graph as a graphviz file.
let _: io::Result<()> = try {
- let mut file = create_dump_file(infcx.tcx, "regioncx.scc.dot", false, "nll", &0, body)?;
+ let mut file = create_dump_file(tcx, "regioncx.scc.dot", false, "nll", &0, body)?;
regioncx.dump_graphviz_scc_constraints(&mut file)?;
};
}
diff --git a/compiler/rustc_borrowck/src/path_utils.rs b/compiler/rustc_borrowck/src/path_utils.rs
index 4afb41be18f1..f387d5cfedcb 100644
--- a/compiler/rustc_borrowck/src/path_utils.rs
+++ b/compiler/rustc_borrowck/src/path_utils.rs
@@ -2,6 +2,7 @@ use rustc_data_structures::graph::dominators::Dominators;
use rustc_middle::mir::{BasicBlock, Body, BorrowKind, Location, Place, PlaceRef, ProjectionElem};
use rustc_middle::ty::TyCtxt;
use rustc_target::abi::FieldIdx;
+use tracing::debug;
use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation};
use crate::{places_conflict, AccessDepth, BorrowIndex};
diff --git a/compiler/rustc_borrowck/src/place_ext.rs b/compiler/rustc_borrowck/src/place_ext.rs
index ce63d51682e5..7f65301986ff 100644
--- a/compiler/rustc_borrowck/src/place_ext.rs
+++ b/compiler/rustc_borrowck/src/place_ext.rs
@@ -2,6 +2,7 @@ use rustc_hir as hir;
use rustc_macros::extension;
use rustc_middle::mir::{Body, Mutability, Place, ProjectionElem};
use rustc_middle::ty::{self, TyCtxt};
+use tracing::debug;
use crate::borrow_set::LocalsStateAtExit;
diff --git a/compiler/rustc_borrowck/src/places_conflict.rs b/compiler/rustc_borrowck/src/places_conflict.rs
index 311f17f15b9e..519ba0b9e0c9 100644
--- a/compiler/rustc_borrowck/src/places_conflict.rs
+++ b/compiler/rustc_borrowck/src/places_conflict.rs
@@ -59,6 +59,7 @@ use rustc_middle::mir::{
Body, BorrowKind, FakeBorrowKind, MutBorrowKind, Place, PlaceElem, PlaceRef, ProjectionElem,
};
use rustc_middle::ty::{self, TyCtxt};
+use tracing::{debug, instrument};
use crate::{AccessDepth, ArtificialField, Deep, Overlap, Shallow};
diff --git a/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs b/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs
index a57041cd04c5..0b9b8768b560 100644
--- a/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs
+++ b/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs
@@ -7,6 +7,7 @@ use rustc_middle::mir::{
TerminatorKind,
};
use rustc_middle::ty::TyCtxt;
+use tracing::debug;
use crate::borrow_set::BorrowSet;
use crate::facts::AllFacts;
diff --git a/compiler/rustc_borrowck/src/polonius/loan_kills.rs b/compiler/rustc_borrowck/src/polonius/loan_kills.rs
index d85c2175bed5..ed9f714e5006 100644
--- a/compiler/rustc_borrowck/src/polonius/loan_kills.rs
+++ b/compiler/rustc_borrowck/src/polonius/loan_kills.rs
@@ -4,6 +4,7 @@ use rustc_middle::mir::{
Terminator, TerminatorKind,
};
use rustc_middle::ty::TyCtxt;
+use tracing::debug;
use crate::borrow_set::BorrowSet;
use crate::facts::AllFacts;
diff --git a/compiler/rustc_borrowck/src/polonius/mod.rs b/compiler/rustc_borrowck/src/polonius/mod.rs
index c590104978c2..6862eb134272 100644
--- a/compiler/rustc_borrowck/src/polonius/mod.rs
+++ b/compiler/rustc_borrowck/src/polonius/mod.rs
@@ -6,6 +6,7 @@
use rustc_middle::mir::{Body, LocalKind, Location, START_BLOCK};
use rustc_middle::ty::TyCtxt;
use rustc_mir_dataflow::move_paths::{InitKind, InitLocation, MoveData};
+use tracing::debug;
use crate::borrow_set::BorrowSet;
use crate::facts::{AllFacts, PoloniusRegionVid};
diff --git a/compiler/rustc_borrowck/src/region_infer/graphviz.rs b/compiler/rustc_borrowck/src/region_infer/graphviz.rs
index 743864dd5350..1936752b63c6 100644
--- a/compiler/rustc_borrowck/src/region_infer/graphviz.rs
+++ b/compiler/rustc_borrowck/src/region_infer/graphviz.rs
@@ -46,7 +46,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
dot::render(&RawConstraints { regioncx: self }, &mut w)
}
- /// Write out the region constraint graph.
+ /// Write out the region constraint SCC graph.
pub(crate) fn dump_graphviz_scc_constraints(&self, mut w: &mut dyn Write) -> io::Result<()> {
let mut nodes_per_scc: IndexVec =
self.constraint_sccs.all_sccs().map(|_| Vec::new()).collect();
diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs
index 6cbdd890b5e8..d6bb006cd7e0 100644
--- a/compiler/rustc_borrowck/src/region_infer/mod.rs
+++ b/compiler/rustc_borrowck/src/region_infer/mod.rs
@@ -21,6 +21,7 @@ use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable, UniverseIndex};
use rustc_mir_dataflow::points::DenseLocationMap;
use rustc_span::Span;
+use tracing::{debug, instrument, trace};
use crate::constraints::graph::{self, NormalConstraintGraph, RegionGraph};
use crate::constraints::{ConstraintSccIndex, OutlivesConstraint, OutlivesConstraintSet};
diff --git a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs
index cd66acd0a8f2..f97f3dfe29f6 100644
--- a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs
+++ b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs
@@ -13,6 +13,7 @@ use rustc_middle::ty::{
use rustc_span::Span;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::traits::ObligationCtxt;
+use tracing::{debug, instrument};
use super::RegionInferenceContext;
use crate::session_diagnostics::{LifetimeMismatchOpaqueParam, NonGenericOpaqueTypeParam};
diff --git a/compiler/rustc_borrowck/src/region_infer/values.rs b/compiler/rustc_borrowck/src/region_infer/values.rs
index 1e91130bdc54..d62f2067729d 100644
--- a/compiler/rustc_borrowck/src/region_infer/values.rs
+++ b/compiler/rustc_borrowck/src/region_infer/values.rs
@@ -8,6 +8,7 @@ use rustc_index::Idx;
use rustc_middle::mir::{BasicBlock, Location};
use rustc_middle::ty::{self, RegionVid};
use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex};
+use tracing::debug;
use crate::BorrowIndex;
diff --git a/compiler/rustc_borrowck/src/renumber.rs b/compiler/rustc_borrowck/src/renumber.rs
index 2a3b51532e54..0a375c7fae8e 100644
--- a/compiler/rustc_borrowck/src/renumber.rs
+++ b/compiler/rustc_borrowck/src/renumber.rs
@@ -4,6 +4,7 @@ use rustc_middle::mir::visit::{MutVisitor, TyContext};
use rustc_middle::mir::{Body, ConstOperand, Location, Promoted};
use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, TypeFoldable};
use rustc_span::Symbol;
+use tracing::{debug, instrument};
use crate::BorrowckInferCtxt;
diff --git a/compiler/rustc_borrowck/src/type_check/canonical.rs b/compiler/rustc_borrowck/src/type_check/canonical.rs
index b58691fbeae3..4b15ce8873d3 100644
--- a/compiler/rustc_borrowck/src/type_check/canonical.rs
+++ b/compiler/rustc_borrowck/src/type_check/canonical.rs
@@ -10,6 +10,7 @@ use rustc_span::Span;
use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
use rustc_trait_selection::traits::query::type_op::{self, TypeOpOutput};
use rustc_trait_selection::traits::ObligationCause;
+use tracing::{debug, instrument};
use super::{Locations, NormalizeLocation, TypeChecker};
use crate::diagnostics::ToUniverseInfo;
diff --git a/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs b/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs
index 9876f44c002d..0f1d79a2c353 100644
--- a/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs
+++ b/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs
@@ -13,6 +13,7 @@ use rustc_span::Span;
use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
use rustc_trait_selection::traits::ScrubbedTraitError;
+use tracing::{debug, instrument};
use crate::constraints::OutlivesConstraint;
use crate::region_infer::TypeTest;
diff --git a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs
index b7fb9964ce74..33cdb1b1f377 100644
--- a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs
+++ b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs
@@ -15,6 +15,7 @@ use rustc_span::{ErrorGuaranteed, Span};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::solve::deeply_normalize;
use rustc_trait_selection::traits::query::type_op::{self, TypeOp};
+use tracing::{debug, instrument};
use type_op::TypeOpOutput;
use crate::type_check::{constraint_conversion, Locations, MirTypeckRegionConstraints};
diff --git a/compiler/rustc_borrowck/src/type_check/input_output.rs b/compiler/rustc_borrowck/src/type_check/input_output.rs
index ba6030bdff77..56f8464628c7 100644
--- a/compiler/rustc_borrowck/src/type_check/input_output.rs
+++ b/compiler/rustc_borrowck/src/type_check/input_output.rs
@@ -15,6 +15,7 @@ use rustc_infer::infer::{BoundRegionConversionTime, RegionVariableOrigin};
use rustc_middle::mir::*;
use rustc_middle::ty::{self, Ty};
use rustc_span::Span;
+use tracing::{debug, instrument};
use super::{Locations, TypeChecker};
use crate::renumber::RegionCtxt;
diff --git a/compiler/rustc_borrowck/src/type_check/liveness/mod.rs b/compiler/rustc_borrowck/src/type_check/liveness/mod.rs
index a320add0636a..a24fd95e3e65 100644
--- a/compiler/rustc_borrowck/src/type_check/liveness/mod.rs
+++ b/compiler/rustc_borrowck/src/type_check/liveness/mod.rs
@@ -11,6 +11,7 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
use rustc_mir_dataflow::move_paths::MoveData;
use rustc_mir_dataflow::points::DenseLocationMap;
use rustc_mir_dataflow::ResultsCursor;
+use tracing::debug;
use super::TypeChecker;
use crate::constraints::OutlivesConstraintSet;
diff --git a/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs b/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs
index 8c13b166c054..7f6aabf8841d 100644
--- a/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs
+++ b/compiler/rustc_borrowck/src/type_check/liveness/polonius.rs
@@ -2,6 +2,7 @@ use rustc_middle::mir::visit::{MutatingUseContext, PlaceContext, Visitor};
use rustc_middle::mir::{Body, Local, Location, Place};
use rustc_middle::ty::GenericArg;
use rustc_mir_dataflow::move_paths::{LookupResult, MoveData, MovePathIndex};
+use tracing::debug;
use super::TypeChecker;
use crate::def_use::{self, DefUse};
diff --git a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs
index f0c521cdcfc5..de3ff8378bcc 100644
--- a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs
+++ b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs
@@ -15,6 +15,7 @@ use rustc_mir_dataflow::ResultsCursor;
use rustc_span::DUMMY_SP;
use rustc_trait_selection::traits::query::type_op::outlives::DropckOutlives;
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
+use tracing::debug;
use crate::location::RichLocation;
use crate::region_infer::values::{self, LiveLoans};
diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs
index d8f74840eb52..224f8d5c893d 100644
--- a/compiler/rustc_borrowck/src/type_check/mod.rs
+++ b/compiler/rustc_borrowck/src/type_check/mod.rs
@@ -45,6 +45,7 @@ use rustc_trait_selection::traits::query::type_op::custom::{
};
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
use rustc_trait_selection::traits::PredicateObligation;
+use tracing::{debug, instrument, trace};
use crate::borrow_set::BorrowSet;
use crate::constraints::{OutlivesConstraint, OutlivesConstraintSet};
diff --git a/compiler/rustc_borrowck/src/type_check/relate_tys.rs b/compiler/rustc_borrowck/src/type_check/relate_tys.rs
index 35d8e2573fe1..bb4a58930e1b 100644
--- a/compiler/rustc_borrowck/src/type_check/relate_tys.rs
+++ b/compiler/rustc_borrowck/src/type_check/relate_tys.rs
@@ -14,6 +14,7 @@ use rustc_middle::ty::fold::FnMutDelegate;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
use rustc_span::symbol::sym;
use rustc_span::{Span, Symbol};
+use tracing::{debug, instrument};
use crate::constraints::OutlivesConstraint;
use crate::diagnostics::UniverseInfo;
diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs
index 2e41c9187743..9eabe817359c 100644
--- a/compiler/rustc_borrowck/src/universal_regions.rs
+++ b/compiler/rustc_borrowck/src/universal_regions.rs
@@ -34,6 +34,7 @@ use rustc_middle::ty::{
use rustc_middle::{bug, span_bug};
use rustc_span::symbol::{kw, sym};
use rustc_span::{ErrorGuaranteed, Symbol};
+use tracing::{debug, instrument};
use crate::renumber::RegionCtxt;
use crate::BorrowckInferCtxt;
diff --git a/compiler/rustc_borrowck/src/used_muts.rs b/compiler/rustc_borrowck/src/used_muts.rs
index e2de6b8b4a92..981e7daf6702 100644
--- a/compiler/rustc_borrowck/src/used_muts.rs
+++ b/compiler/rustc_borrowck/src/used_muts.rs
@@ -3,6 +3,7 @@ use rustc_middle::mir::visit::{PlaceContext, Visitor};
use rustc_middle::mir::{
Local, Location, Place, Statement, StatementKind, Terminator, TerminatorKind,
};
+use tracing::debug;
use crate::MirBorrowckCtxt;
diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs
index f1d885bf1bce..4af4b39cc5b9 100644
--- a/compiler/rustc_codegen_cranelift/src/base.rs
+++ b/compiler/rustc_codegen_cranelift/src/base.rs
@@ -44,8 +44,9 @@ pub(crate) fn codegen_fn<'tcx>(
let _mir_guard = crate::PrintOnPanic(|| {
let mut buf = Vec::new();
with_no_trimmed_paths!({
- rustc_middle::mir::pretty::write_mir_fn(tcx, mir, &mut |_, _| Ok(()), &mut buf)
- .unwrap();
+ use rustc_middle::mir::pretty;
+ let options = pretty::PrettyPrintMirOptions::from_cli(tcx);
+ pretty::write_mir_fn(tcx, mir, &mut |_, _| Ok(()), &mut buf, options).unwrap();
});
String::from_utf8_lossy(&buf).into_owned()
});
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
index dc59e9349b05..17a9630c6557 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
@@ -216,6 +216,8 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
// need to make sure that we don't break existing debuginfo consumers
// by doing that (at least not without a warning period).
let layout_type = if ptr_type.is_box() {
+ // The assertion at the start of this function ensures we have a ZST allocator.
+ // We'll make debuginfo "skip" all ZST allocators, not just the default allocator.
Ty::new_mut_ptr(cx.tcx, pointee_type)
} else {
ptr_type
diff --git a/compiler/rustc_codegen_ssa/Cargo.toml b/compiler/rustc_codegen_ssa/Cargo.toml
index e78039bafd8d..3ab4cd0a0f53 100644
--- a/compiler/rustc_codegen_ssa/Cargo.toml
+++ b/compiler/rustc_codegen_ssa/Cargo.toml
@@ -41,7 +41,7 @@ tempfile = "3.2"
thin-vec = "0.2.12"
thorin-dwp = "0.7"
tracing = "0.1"
-wasm-encoder = "0.215.0"
+wasm-encoder = "0.216.0"
# tidy-alphabetical-end
[target.'cfg(unix)'.dependencies]
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index 4d19425255fa..e8143b9a5f38 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -2,7 +2,7 @@ use std::collections::BTreeSet;
use std::ffi::OsString;
use std::fs::{read, File, OpenOptions};
use std::io::{BufWriter, Write};
-use std::ops::Deref;
+use std::ops::{ControlFlow, Deref};
use std::path::{Path, PathBuf};
use std::process::{ExitStatus, Output, Stdio};
use std::{env, fmt, fs, io, mem, str};
@@ -18,8 +18,8 @@ use rustc_data_structures::temp_dir::MaybeTempDir;
use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, FatalError};
use rustc_fs_util::{fix_windows_verbatim_for_gcc, try_canonicalize};
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
-use rustc_metadata::find_native_static_library;
use rustc_metadata::fs::{copy_to_stdout, emit_wrapper_file, METADATA_FILENAME};
+use rustc_metadata::{find_native_static_library, walk_native_lib_search_dirs};
use rustc_middle::bug;
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
use rustc_middle::middle::dependency_format::Linkage;
@@ -2110,50 +2110,19 @@ fn add_library_search_dirs(
return;
}
- // Library search paths explicitly supplied by user (`-L` on the command line).
- for search_path in sess.target_filesearch(PathKind::Native).cli_search_paths() {
- cmd.include_path(&fix_windows_verbatim_for_gcc(&search_path.dir));
- }
- for search_path in sess.target_filesearch(PathKind::Framework).cli_search_paths() {
- // Contrary to the `-L` docs only framework-specific paths are considered here.
- if search_path.kind != PathKind::All {
- cmd.framework_path(&search_path.dir);
- }
- }
-
- // The toolchain ships some native library components and self-contained linking was enabled.
- // Add the self-contained library directory to search paths.
- if self_contained_components.intersects(
- LinkSelfContainedComponents::LIBC
- | LinkSelfContainedComponents::UNWIND
- | LinkSelfContainedComponents::MINGW,
- ) {
- let lib_path = sess.target_tlib_path.dir.join("self-contained");
- cmd.include_path(&fix_windows_verbatim_for_gcc(&lib_path));
- }
-
- // Toolchains for some targets may ship `libunwind.a`, but place it into the main sysroot
- // library directory instead of the self-contained directories.
- // Sanitizer libraries have the same issue and are also linked by name on Apple targets.
- // The targets here should be in sync with `copy_third_party_objects` in bootstrap.
- // FIXME: implement `-Clink-self-contained=+/-unwind,+/-sanitizers`, move the shipped libunwind
- // and sanitizers to self-contained directory, and stop adding this search path.
- if sess.target.vendor == "fortanix"
- || sess.target.os == "linux"
- || sess.target.os == "fuchsia"
- || sess.target.is_like_osx && !sess.opts.unstable_opts.sanitizer.is_empty()
- {
- cmd.include_path(&fix_windows_verbatim_for_gcc(&sess.target_tlib_path.dir));
- }
-
- // Mac Catalyst uses the macOS SDK, but to link to iOS-specific frameworks
- // we must have the support library stubs in the library search path (#121430).
- if let Some(sdk_root) = apple_sdk_root
- && sess.target.llvm_target.contains("macabi")
- {
- cmd.include_path(&sdk_root.join("System/iOSSupport/usr/lib"));
- cmd.framework_path(&sdk_root.join("System/iOSSupport/System/Library/Frameworks"));
- }
+ walk_native_lib_search_dirs(
+ sess,
+ self_contained_components,
+ apple_sdk_root,
+ |dir, is_framework| {
+ if is_framework {
+ cmd.framework_path(dir);
+ } else {
+ cmd.include_path(&fix_windows_verbatim_for_gcc(dir));
+ }
+ ControlFlow::<()>::Continue(())
+ },
+ );
}
/// Add options making relocation sections in the produced ELF files read-only
diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs
index fbab988a32b0..cb266247e0dd 100644
--- a/compiler/rustc_codegen_ssa/src/back/linker.rs
+++ b/compiler/rustc_codegen_ssa/src/back/linker.rs
@@ -7,7 +7,7 @@ use std::{env, iter, mem, str};
use cc::windows_registry;
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
-use rustc_metadata::find_native_static_library;
+use rustc_metadata::{find_native_static_library, try_find_native_static_library};
use rustc_middle::bug;
use rustc_middle::middle::dependency_format::Linkage;
use rustc_middle::middle::exported_symbols;
@@ -891,9 +891,15 @@ impl<'a> Linker for MsvcLinker<'a> {
}
fn link_staticlib_by_name(&mut self, name: &str, verbatim: bool, whole_archive: bool) {
- let prefix = if whole_archive { "/WHOLEARCHIVE:" } else { "" };
- let suffix = if verbatim { "" } else { ".lib" };
- self.link_arg(format!("{prefix}{name}{suffix}"));
+ // On MSVC-like targets rustc supports static libraries using alternative naming
+ // scheme (`libfoo.a`) unsupported by linker, search for such libraries manually.
+ if let Some(path) = try_find_native_static_library(self.sess, name, verbatim) {
+ self.link_staticlib_by_path(&path, whole_archive);
+ } else {
+ let prefix = if whole_archive { "/WHOLEARCHIVE:" } else { "" };
+ let suffix = if verbatim { "" } else { ".lib" };
+ self.link_arg(format!("{prefix}{name}{suffix}"));
+ }
}
fn link_staticlib_by_path(&mut self, path: &Path, whole_archive: bool) {
diff --git a/compiler/rustc_const_eval/messages.ftl b/compiler/rustc_const_eval/messages.ftl
index db788b6b1519..8a6dfb892490 100644
--- a/compiler/rustc_const_eval/messages.ftl
+++ b/compiler/rustc_const_eval/messages.ftl
@@ -415,8 +415,8 @@ const_eval_unstable_const_fn = `{$def_path}` is not yet stable as a const fn
const_eval_unstable_in_stable =
const-stable function cannot use `#[feature({$gate})]`
- .unstable_sugg = if it is not part of the public API, make this function unstably const
- .bypass_sugg = otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (but requires team approval)
+ .unstable_sugg = if the function is not (yet) meant to be stable, make this function unstably const
+ .bypass_sugg = otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (but requires team approval)
const_eval_unterminated_c_string =
reading a null-terminated string starting at {$pointer} with no null found before end of allocation
diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs
index 6a086a3a7e5a..7cfb101399da 100644
--- a/compiler/rustc_const_eval/src/check_consts/check.rs
+++ b/compiler/rustc_const_eval/src/check_consts/check.rs
@@ -868,9 +868,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
// Calling an unstable function *always* requires that the corresponding gate
// (or implied gate) be enabled, even if the function has
// `#[rustc_allow_const_fn_unstable(the_gate)]`.
- let gate_declared = |gate| {
- tcx.features().declared_lib_features.iter().any(|&(sym, _)| sym == gate)
- };
+ let gate_declared = |gate| tcx.features().declared(gate);
let feature_gate_declared = gate_declared(gate);
let implied_gate_declared = implied_by.is_some_and(gate_declared);
if !feature_gate_declared && !implied_gate_declared {
diff --git a/compiler/rustc_const_eval/src/interpret/machine.rs b/compiler/rustc_const_eval/src/interpret/machine.rs
index 88453245b844..6cfd7be48e62 100644
--- a/compiler/rustc_const_eval/src/interpret/machine.rs
+++ b/compiler/rustc_const_eval/src/interpret/machine.rs
@@ -362,17 +362,7 @@ pub trait Machine<'tcx>: Sized {
ecx: &InterpCx<'tcx, Self>,
id: AllocId,
alloc: &'b Allocation,
- ) -> InterpResult<'tcx, Cow<'b, Allocation>>
- {
- // The default implementation does a copy; CTFE machines have a more efficient implementation
- // based on their particular choice for `Provenance`, `AllocExtra`, and `Bytes`.
- let kind = Self::GLOBAL_KIND
- .expect("if GLOBAL_KIND is None, adjust_global_allocation must be overwritten");
- let alloc = alloc.adjust_from_tcx(&ecx.tcx, |ptr| ecx.global_root_pointer(ptr))?;
- let extra =
- Self::init_alloc_extra(ecx, id, MemoryKind::Machine(kind), alloc.size(), alloc.align)?;
- Ok(Cow::Owned(alloc.with_extra(extra)))
- }
+ ) -> InterpResult<'tcx, Cow<'b, Allocation>>;
/// Initialize the extra state of an allocation.
///
diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs
index 2afdd02c8803..ede6a51c712b 100644
--- a/compiler/rustc_const_eval/src/interpret/place.rs
+++ b/compiler/rustc_const_eval/src/interpret/place.rs
@@ -438,14 +438,16 @@ where
&self,
src: &impl Readable<'tcx, M::Provenance>,
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::Provenance>> {
+ if src.layout().ty.is_box() {
+ // Derefer should have removed all Box derefs.
+ // Some `Box` are not immediates (if they have a custom allocator)
+ // so the code below would fail.
+ bug!("dereferencing {}", src.layout().ty);
+ }
+
let val = self.read_immediate(src)?;
trace!("deref to {} on {:?}", val.layout.ty, *val);
- if val.layout.ty.is_box() {
- // Derefer should have removed all Box derefs
- bug!("dereferencing {}", val.layout.ty);
- }
-
let mplace = self.ref_to_mplace(&val)?;
Ok(mplace)
}
diff --git a/compiler/rustc_const_eval/src/interpret/visitor.rs b/compiler/rustc_const_eval/src/interpret/visitor.rs
index fd649d608c69..b02f12e3c7f0 100644
--- a/compiler/rustc_const_eval/src/interpret/visitor.rs
+++ b/compiler/rustc_const_eval/src/interpret/visitor.rs
@@ -25,14 +25,15 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized {
}
/// This function provides the chance to reorder the order in which fields are visited for
- /// `FieldsShape::Aggregate`: The order of fields will be
- /// `(0..num_fields).map(aggregate_field_order)`.
+ /// `FieldsShape::Aggregate`.
///
- /// The default means we iterate in source declaration order; alternative this can do an inverse
- /// lookup in `memory_index` to use memory field order instead.
+ /// The default means we iterate in source declaration order; alternatively this can do some
+ /// work with `memory_index` to iterate in memory order.
#[inline(always)]
- fn aggregate_field_order(_memory_index: &IndexVec, idx: usize) -> usize {
- idx
+ fn aggregate_field_iter(
+ memory_index: &IndexVec,
+ ) -> impl Iterator + 'static {
+ memory_index.indices()
}
// Recursive actions, ready to be overloaded.
@@ -172,9 +173,9 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized {
&FieldsShape::Union(fields) => {
self.visit_union(v, fields)?;
}
- FieldsShape::Arbitrary { offsets, memory_index } => {
- for idx in 0..offsets.len() {
- let idx = Self::aggregate_field_order(memory_index, idx);
+ FieldsShape::Arbitrary { memory_index, .. } => {
+ for idx in Self::aggregate_field_iter(memory_index) {
+ let idx = idx.as_usize();
let field = self.ecx().project_field(v, idx)?;
self.visit_field(v, idx, &field)?;
}
diff --git a/compiler/rustc_hir_analysis/src/autoderef.rs b/compiler/rustc_hir_analysis/src/autoderef.rs
index 53c8586b52a7..46a0d4f498aa 100644
--- a/compiler/rustc_hir_analysis/src/autoderef.rs
+++ b/compiler/rustc_hir_analysis/src/autoderef.rs
@@ -4,6 +4,7 @@ use rustc_session::Limit;
use rustc_span::def_id::{LocalDefId, LOCAL_CRATE};
use rustc_span::Span;
use rustc_trait_selection::traits::ObligationCtxt;
+use tracing::{debug, instrument};
use crate::errors::AutoDerefReachedRecursionLimit;
use crate::traits;
diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs
index d414bcdb95b3..e47c707ee18d 100644
--- a/compiler/rustc_hir_analysis/src/check/check.rs
+++ b/compiler/rustc_hir_analysis/src/check/check.rs
@@ -27,6 +27,7 @@ use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::traits;
use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _;
use rustc_type_ir::fold::TypeFoldable;
+use tracing::{debug, instrument};
use {rustc_attr as attr, rustc_hir as hir};
use super::compare_impl_item::{check_type_bounds, compare_impl_method, compare_impl_ty};
diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
index 35577613800b..2afed04c5bcd 100644
--- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
+++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
@@ -28,6 +28,7 @@ use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _;
use rustc_trait_selection::traits::{
self, FulfillmentError, ObligationCause, ObligationCauseCode, ObligationCtxt, Reveal,
};
+use tracing::{debug, instrument};
use super::potentially_plural_count;
use crate::errors::{LifetimesOrBoundsMismatchOnTrait, MethodShouldReturnFuture};
diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs
index 678b8c89a505..6820a44f141b 100644
--- a/compiler/rustc_hir_analysis/src/check/mod.rs
+++ b/compiler/rustc_hir_analysis/src/check/mod.rs
@@ -97,6 +97,7 @@ use rustc_trait_selection::error_reporting::infer::ObligationCauseExt as _;
use rustc_trait_selection::error_reporting::traits::suggestions::ReturnsVisitor;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::traits::ObligationCtxt;
+use tracing::debug;
use self::compare_impl_item::collect_return_position_impl_trait_in_trait_tys;
use self::region::region_scope_tree;
diff --git a/compiler/rustc_hir_analysis/src/check/region.rs b/compiler/rustc_hir_analysis/src/check/region.rs
index 483351739792..2d6147cff2a5 100644
--- a/compiler/rustc_hir_analysis/src/check/region.rs
+++ b/compiler/rustc_hir_analysis/src/check/region.rs
@@ -18,6 +18,7 @@ use rustc_middle::bug;
use rustc_middle::middle::region::*;
use rustc_middle::ty::TyCtxt;
use rustc_span::source_map;
+use tracing::debug;
use super::errs::{maybe_expr_static_mut, maybe_stmt_static_mut};
diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
index cb66179ec804..359b4729e50a 100644
--- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs
+++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
@@ -36,6 +36,7 @@ use rustc_trait_selection::traits::{
};
use rustc_type_ir::solve::NoSolution;
use rustc_type_ir::TypeFlags;
+use tracing::{debug, instrument};
use {rustc_ast as ast, rustc_hir as hir};
use crate::autoderef::Autoderef;
diff --git a/compiler/rustc_hir_analysis/src/check_unused.rs b/compiler/rustc_hir_analysis/src/check_unused.rs
index ca9e2e8a3cc6..68b7b44c36d6 100644
--- a/compiler/rustc_hir_analysis/src/check_unused.rs
+++ b/compiler/rustc_hir_analysis/src/check_unused.rs
@@ -4,6 +4,7 @@ use rustc_hir::def_id::LocalDefId;
use rustc_middle::query::Providers;
use rustc_middle::ty::TyCtxt;
use rustc_session::lint;
+use tracing::debug;
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { check_unused_traits, ..*providers };
diff --git a/compiler/rustc_hir_analysis/src/coherence/builtin.rs b/compiler/rustc_hir_analysis/src/coherence/builtin.rs
index 23f1adfe302e..9f01f7be80af 100644
--- a/compiler/rustc_hir_analysis/src/coherence/builtin.rs
+++ b/compiler/rustc_hir_analysis/src/coherence/builtin.rs
@@ -23,6 +23,7 @@ use rustc_trait_selection::traits::misc::{
ConstParamTyImplementationError, CopyImplementationError, InfringingFieldsReason,
};
use rustc_trait_selection::traits::{self, ObligationCause, ObligationCtxt};
+use tracing::debug;
use crate::errors;
diff --git a/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs b/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs
index 00bbbf7130f8..6825c2e33fe7 100644
--- a/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs
+++ b/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs
@@ -10,6 +10,7 @@ use rustc_middle::ty::{self, TyCtxt};
use rustc_span::{ErrorGuaranteed, Symbol};
use rustc_trait_selection::traits::{self, SkipLeakCheck};
use smallvec::SmallVec;
+use tracing::debug;
pub(crate) fn crate_inherent_impls_overlap_check(
tcx: TyCtxt<'_>,
diff --git a/compiler/rustc_hir_analysis/src/coherence/mod.rs b/compiler/rustc_hir_analysis/src/coherence/mod.rs
index 3d800bb165cb..db809e4837d6 100644
--- a/compiler/rustc_hir_analysis/src/coherence/mod.rs
+++ b/compiler/rustc_hir_analysis/src/coherence/mod.rs
@@ -13,6 +13,7 @@ use rustc_middle::query::Providers;
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
use rustc_session::parse::feature_err;
use rustc_span::{sym, ErrorGuaranteed};
+use tracing::debug;
use crate::errors;
diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs
index dcd0e3111a48..5fdaba41fb26 100644
--- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs
+++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs
@@ -14,6 +14,7 @@ use rustc_span::def_id::{DefId, LocalDefId};
use rustc_trait_selection::traits::{
self, IsFirstInputType, OrphanCheckErr, OrphanCheckMode, UncoveredTyParams,
};
+use tracing::{debug, instrument};
use crate::errors;
diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs
index 3acf2c631459..53105f337c4a 100644
--- a/compiler/rustc_hir_analysis/src/collect.rs
+++ b/compiler/rustc_hir_analysis/src/collect.rs
@@ -42,6 +42,7 @@ use rustc_target::spec::abi;
use rustc_trait_selection::error_reporting::traits::suggestions::NextTypeParamName;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::ObligationCtxt;
+use tracing::{debug, instrument};
use crate::check::intrinsic::intrinsic_operation_unsafety;
use crate::errors;
@@ -420,7 +421,7 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
span: Span,
def_id: LocalDefId,
assoc_name: Ident,
- ) -> ty::GenericPredicates<'tcx> {
+ ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
self.tcx.at(span).type_param_predicates((self.item_def_id, def_id, assoc_name))
}
diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs
index 28d6cab4b439..be6c3f048dce 100644
--- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs
+++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs
@@ -10,6 +10,7 @@ use rustc_middle::ty::{self, TyCtxt};
use rustc_session::lint;
use rustc_span::symbol::{kw, Symbol};
use rustc_span::Span;
+use tracing::{debug, instrument};
use crate::delegation::inherit_generics_for_delegation_item;
use crate::middle::resolve_bound_vars as rbv;
diff --git a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs
index ec48c781c0e4..d62727e76b58 100644
--- a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs
+++ b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs
@@ -8,6 +8,7 @@ use rustc_middle::{bug, span_bug};
use rustc_span::def_id::{DefId, LocalDefId};
use rustc_span::Span;
use rustc_type_ir::Upcast;
+use tracing::{debug, instrument};
use super::ItemCtxt;
use crate::hir_ty_lowering::{HirTyLowerer, PredicateFilter};
diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs
index bba8b0497be5..a47aaf25e95a 100644
--- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs
+++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs
@@ -10,6 +10,7 @@ use rustc_middle::ty::{self, GenericPredicates, ImplTraitInTraitData, Ty, TyCtxt
use rustc_middle::{bug, span_bug};
use rustc_span::symbol::Ident;
use rustc_span::{Span, DUMMY_SP};
+use tracing::{debug, instrument, trace};
use crate::bounds::Bounds;
use crate::collect::ItemCtxt;
@@ -580,24 +581,24 @@ pub(super) fn explicit_predicates_of<'tcx>(
/// Ensures that the super-predicates of the trait with a `DefId`
/// of `trait_def_id` are lowered and stored. This also ensures that
/// the transitive super-predicates are lowered.
-pub(super) fn explicit_super_predicates_of(
- tcx: TyCtxt<'_>,
+pub(super) fn explicit_super_predicates_of<'tcx>(
+ tcx: TyCtxt<'tcx>,
trait_def_id: LocalDefId,
-) -> ty::GenericPredicates<'_> {
+) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
implied_predicates_with_filter(tcx, trait_def_id.to_def_id(), PredicateFilter::SelfOnly)
}
-pub(super) fn explicit_supertraits_containing_assoc_item(
- tcx: TyCtxt<'_>,
+pub(super) fn explicit_supertraits_containing_assoc_item<'tcx>(
+ tcx: TyCtxt<'tcx>,
(trait_def_id, assoc_name): (DefId, Ident),
-) -> ty::GenericPredicates<'_> {
+) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
implied_predicates_with_filter(tcx, trait_def_id, PredicateFilter::SelfThatDefines(assoc_name))
}
-pub(super) fn explicit_implied_predicates_of(
- tcx: TyCtxt<'_>,
+pub(super) fn explicit_implied_predicates_of<'tcx>(
+ tcx: TyCtxt<'tcx>,
trait_def_id: LocalDefId,
-) -> ty::GenericPredicates<'_> {
+) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
implied_predicates_with_filter(
tcx,
trait_def_id.to_def_id(),
@@ -612,11 +613,11 @@ pub(super) fn explicit_implied_predicates_of(
/// Ensures that the super-predicates of the trait with a `DefId`
/// of `trait_def_id` are lowered and stored. This also ensures that
/// the transitive super-predicates are lowered.
-pub(super) fn implied_predicates_with_filter(
- tcx: TyCtxt<'_>,
+pub(super) fn implied_predicates_with_filter<'tcx>(
+ tcx: TyCtxt<'tcx>,
trait_def_id: DefId,
filter: PredicateFilter,
-) -> ty::GenericPredicates<'_> {
+) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
let Some(trait_def_id) = trait_def_id.as_local() else {
// if `assoc_name` is None, then the query should've been redirected to an
// external provider
@@ -679,20 +680,16 @@ pub(super) fn implied_predicates_with_filter(
_ => {}
}
- ty::GenericPredicates {
- parent: None,
- predicates: implied_bounds,
- effects_min_tys: ty::List::empty(),
- }
+ ty::EarlyBinder::bind(implied_bounds)
}
/// Returns the predicates defined on `item_def_id` of the form
/// `X: Foo` where `X` is the type parameter `def_id`.
#[instrument(level = "trace", skip(tcx))]
-pub(super) fn type_param_predicates(
- tcx: TyCtxt<'_>,
+pub(super) fn type_param_predicates<'tcx>(
+ tcx: TyCtxt<'tcx>,
(item_def_id, def_id, assoc_name): (LocalDefId, LocalDefId, Ident),
-) -> ty::GenericPredicates<'_> {
+) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
use rustc_hir::*;
use rustc_middle::ty::Ty;
@@ -713,18 +710,20 @@ pub(super) fn type_param_predicates(
tcx.generics_of(item_def_id).parent.map(|def_id| def_id.expect_local())
};
- let mut result = parent
- .map(|parent| {
- let icx = ItemCtxt::new(tcx, parent);
- icx.probe_ty_param_bounds(DUMMY_SP, def_id, assoc_name)
- })
- .unwrap_or_default();
+ let result = if let Some(parent) = parent {
+ let icx = ItemCtxt::new(tcx, parent);
+ icx.probe_ty_param_bounds(DUMMY_SP, def_id, assoc_name)
+ } else {
+ ty::EarlyBinder::bind(&[] as &[_])
+ };
let mut extend = None;
let item_hir_id = tcx.local_def_id_to_hir_id(item_def_id);
let hir_node = tcx.hir_node(item_hir_id);
- let Some(hir_generics) = hir_node.generics() else { return result };
+ let Some(hir_generics) = hir_node.generics() else {
+ return result;
+ };
if let Node::Item(item) = hir_node
&& let ItemKind::Trait(..) = item.kind
// Implied `Self: Trait` and supertrait bounds.
@@ -748,9 +747,10 @@ pub(super) fn type_param_predicates(
_ => false,
}),
);
- result.predicates =
- tcx.arena.alloc_from_iter(result.predicates.iter().copied().chain(extra_predicates));
- result
+
+ ty::EarlyBinder::bind(
+ tcx.arena.alloc_from_iter(result.skip_binder().iter().copied().chain(extra_predicates)),
+ )
}
impl<'tcx> ItemCtxt<'tcx> {
diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs
index e38492d9e649..fe46eb583f1d 100644
--- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs
+++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs
@@ -24,6 +24,7 @@ use rustc_middle::{bug, span_bug};
use rustc_span::def_id::{DefId, LocalDefId};
use rustc_span::symbol::{sym, Ident};
use rustc_span::Span;
+use tracing::{debug, debug_span, instrument};
use crate::errors;
@@ -1761,7 +1762,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
break Some((bound_vars.into_iter().collect(), assoc_item));
}
let predicates = tcx.explicit_supertraits_containing_assoc_item((def_id, assoc_name));
- let obligations = predicates.predicates.iter().filter_map(|&(pred, _)| {
+ let obligations = predicates.iter_identity_copied().filter_map(|(pred, _)| {
let bound_predicate = pred.kind();
match bound_predicate.skip_binder() {
ty::ClauseKind::Trait(data) => {
diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs
index 96256b91b9f9..5cb90e97eefe 100644
--- a/compiler/rustc_hir_analysis/src/collect/type_of.rs
+++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs
@@ -11,6 +11,7 @@ use rustc_middle::ty::{self, Article, IsSuggestable, Ty, TyCtxt, TypeVisitableEx
use rustc_middle::{bug, span_bug};
use rustc_span::symbol::Ident;
use rustc_span::{Span, DUMMY_SP};
+use tracing::debug;
use super::{bad_placeholder, ItemCtxt};
use crate::errors::TypeofReservedKeywordUsed;
diff --git a/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs b/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs
index c8b0f03a9290..7f4a8208faae 100644
--- a/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs
+++ b/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs
@@ -7,6 +7,7 @@ use rustc_middle::bug;
use rustc_middle::hir::nested_filter;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
use rustc_span::DUMMY_SP;
+use tracing::{debug, instrument, trace};
use crate::errors::{TaitForwardCompat, TaitForwardCompat2, UnconstrainedOpaqueType};
diff --git a/compiler/rustc_hir_analysis/src/constrained_generic_params.rs b/compiler/rustc_hir_analysis/src/constrained_generic_params.rs
index edf652456641..6a9ae0de1c1a 100644
--- a/compiler/rustc_hir_analysis/src/constrained_generic_params.rs
+++ b/compiler/rustc_hir_analysis/src/constrained_generic_params.rs
@@ -4,6 +4,7 @@ use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitor};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::Span;
use rustc_type_ir::fold::TypeFoldable;
+use tracing::debug;
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub(crate) struct Parameter(pub u32);
diff --git a/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs b/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs
index f8b2469dfea4..da89f5769d1f 100644
--- a/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs
+++ b/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs
@@ -5,6 +5,7 @@ use rustc_errors::{pluralize, Applicability, Diag, Diagnostic, EmissionGuarantee
use rustc_hir as hir;
use rustc_middle::ty::{self as ty, AssocItems, AssocKind, TyCtxt};
use rustc_span::def_id::DefId;
+use tracing::debug;
use GenericArgsInfo::*;
/// Handles the `wrong number of type / lifetime / ... arguments` family of error messages.
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
index 7f4c75d3a6a2..70a3c744c78a 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
@@ -13,6 +13,7 @@ use rustc_span::{sym, ErrorGuaranteed, Span, Symbol};
use rustc_trait_selection::traits;
use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
use smallvec::SmallVec;
+use tracing::{debug, instrument};
use crate::bounds::Bounds;
use crate::errors;
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs
index a59e9aa85fd7..8d5f98c7372e 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs
@@ -11,6 +11,7 @@ use rustc_middle::ty::{
use rustc_session::lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS;
use rustc_span::symbol::{kw, sym};
use smallvec::SmallVec;
+use tracing::{debug, instrument};
use super::{HirTyLowerer, IsMethodCall};
use crate::errors::wrong_number_of_generic_args::{GenericArgsInfo, WrongNumberOfGenericArgs};
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
index 0cdd3e4a1c6c..36c26f91089c 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
@@ -50,6 +50,7 @@ use rustc_target::spec::abi;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::wf::object_region_bounds;
use rustc_trait_selection::traits::{self, ObligationCtxt};
+use tracing::{debug, debug_span, instrument};
use crate::bounds::Bounds;
use crate::errors::{AmbiguousLifetimeBound, WildPatTy};
@@ -136,7 +137,7 @@ pub trait HirTyLowerer<'tcx> {
span: Span,
def_id: LocalDefId,
assoc_name: Ident,
- ) -> ty::GenericPredicates<'tcx>;
+ ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]>;
/// Lower an associated type to a projection.
///
@@ -831,13 +832,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
debug!(?ty_param_def_id, ?assoc_name, ?span);
let tcx = self.tcx();
- let predicates = &self.probe_ty_param_bounds(span, ty_param_def_id, assoc_name).predicates;
+ let predicates = &self.probe_ty_param_bounds(span, ty_param_def_id, assoc_name);
debug!("predicates={:#?}", predicates);
self.probe_single_bound_for_assoc_item(
|| {
let trait_refs = predicates
- .iter()
+ .iter_identity_copied()
.filter_map(|(p, _)| Some(p.as_trait_clause()?.map_bound(|t| t.trait_ref)));
traits::transitive_bounds_that_define_assoc_item(tcx, trait_refs, assoc_name)
},
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/object_safety.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/object_safety.rs
index 52e167379b5d..885388637103 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/object_safety.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/object_safety.rs
@@ -14,6 +14,7 @@ use rustc_span::{ErrorGuaranteed, Span};
use rustc_trait_selection::error_reporting::traits::report_object_safety_error;
use rustc_trait_selection::traits::{self, hir_ty_lowering_object_safety_violations};
use smallvec::{smallvec, SmallVec};
+use tracing::{debug, instrument};
use super::HirTyLowerer;
use crate::bounds::Bounds;
diff --git a/compiler/rustc_hir_analysis/src/hir_wf_check.rs b/compiler/rustc_hir_analysis/src/hir_wf_check.rs
index 3ecf61501f6d..2fa4ca680737 100644
--- a/compiler/rustc_hir_analysis/src/hir_wf_check.rs
+++ b/compiler/rustc_hir_analysis/src/hir_wf_check.rs
@@ -8,6 +8,7 @@ use rustc_middle::query::Providers;
use rustc_middle::ty::{self, TyCtxt};
use rustc_span::def_id::LocalDefId;
use rustc_trait_selection::traits::{self, ObligationCtxt};
+use tracing::debug;
use crate::collect::ItemCtxt;
diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs
index f44a78bac4de..147646930dde 100644
--- a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs
+++ b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs
@@ -77,6 +77,7 @@ use rustc_span::{ErrorGuaranteed, Span};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _;
use rustc_trait_selection::traits::{self, translate_args_with_cause, wf, ObligationCtxt};
+use tracing::{debug, instrument};
use crate::errors::GenericArgsOnOverriddenImpl;
use crate::{constrained_generic_params as cgp, errors};
diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs
index 891e4fcd019c..1481a4dd141b 100644
--- a/compiler/rustc_hir_analysis/src/lib.rs
+++ b/compiler/rustc_hir_analysis/src/lib.rs
@@ -75,9 +75,6 @@ This API is completely unstable and subject to change.
#![warn(unreachable_pub)]
// tidy-alphabetical-end
-#[macro_use]
-extern crate tracing;
-
// These are used by Clippy.
pub mod check;
diff --git a/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs b/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs
index 454c20d3e648..c2377b4781c2 100644
--- a/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs
+++ b/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs
@@ -3,6 +3,7 @@ use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
use rustc_middle::ty::{self, GenericArg, GenericArgKind, Ty, TyCtxt};
use rustc_span::Span;
+use tracing::debug;
use super::explicit::ExplicitPredicatesMap;
use super::utils::*;
diff --git a/compiler/rustc_hir_analysis/src/variance/constraints.rs b/compiler/rustc_hir_analysis/src/variance/constraints.rs
index 4fb7a02f8c93..415b23d812b5 100644
--- a/compiler/rustc_hir_analysis/src/variance/constraints.rs
+++ b/compiler/rustc_hir_analysis/src/variance/constraints.rs
@@ -8,6 +8,7 @@ use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, Ty, TyCtxt};
use rustc_middle::{bug, span_bug};
+use tracing::{debug, instrument};
use super::terms::VarianceTerm::*;
use super::terms::*;
diff --git a/compiler/rustc_hir_analysis/src/variance/mod.rs b/compiler/rustc_hir_analysis/src/variance/mod.rs
index e8e2caf7e62a..12bb9a3f9e0f 100644
--- a/compiler/rustc_hir_analysis/src/variance/mod.rs
+++ b/compiler/rustc_hir_analysis/src/variance/mod.rs
@@ -12,6 +12,7 @@ use rustc_middle::span_bug;
use rustc_middle::ty::{
self, CrateVariancesMap, GenericArgsRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable,
};
+use tracing::{debug, instrument};
/// Defines the `TermsContext` basically houses an arena where we can
/// allocate terms.
diff --git a/compiler/rustc_hir_analysis/src/variance/solve.rs b/compiler/rustc_hir_analysis/src/variance/solve.rs
index 4f1bac17e71b..d0bdca867792 100644
--- a/compiler/rustc_hir_analysis/src/variance/solve.rs
+++ b/compiler/rustc_hir_analysis/src/variance/solve.rs
@@ -7,6 +7,7 @@
use rustc_hir::def_id::DefIdMap;
use rustc_middle::ty;
+use tracing::debug;
use super::constraints::*;
use super::terms::VarianceTerm::*;
diff --git a/compiler/rustc_hir_analysis/src/variance/terms.rs b/compiler/rustc_hir_analysis/src/variance/terms.rs
index 597699b37b1c..cf38957bf24a 100644
--- a/compiler/rustc_hir_analysis/src/variance/terms.rs
+++ b/compiler/rustc_hir_analysis/src/variance/terms.rs
@@ -15,6 +15,7 @@ use rustc_arena::DroplessArena;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{LocalDefId, LocalDefIdMap};
use rustc_middle::ty::{self, TyCtxt};
+use tracing::debug;
use self::VarianceTerm::*;
diff --git a/compiler/rustc_hir_typeck/src/_match.rs b/compiler/rustc_hir_typeck/src/_match.rs
index 7427fb147166..afaa4a1ac6d8 100644
--- a/compiler/rustc_hir_typeck/src/_match.rs
+++ b/compiler/rustc_hir_typeck/src/_match.rs
@@ -8,6 +8,7 @@ use rustc_span::Span;
use rustc_trait_selection::traits::{
IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode,
};
+use tracing::{debug, instrument};
use crate::coercion::{AsCoercionSite, CoerceMany};
use crate::{Diverges, Expectation, FnCtxt, Needs};
diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs
index fc08b872efc2..a4eec5f05a8f 100644
--- a/compiler/rustc_hir_typeck/src/callee.rs
+++ b/compiler/rustc_hir_typeck/src/callee.rs
@@ -20,6 +20,7 @@ use rustc_target::spec::abi;
use rustc_trait_selection::error_reporting::traits::DefIdOrName;
use rustc_trait_selection::infer::InferCtxtExt as _;
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
+use tracing::{debug, instrument, trace};
use super::method::probe::ProbeScope;
use super::method::MethodCallee;
diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs
index 3a309d2ec0b4..1db2c865b407 100644
--- a/compiler/rustc_hir_typeck/src/cast.rs
+++ b/compiler/rustc_hir_typeck/src/cast.rs
@@ -44,6 +44,7 @@ use rustc_span::def_id::LOCAL_CRATE;
use rustc_span::symbol::sym;
use rustc_span::{Span, DUMMY_SP};
use rustc_trait_selection::infer::InferCtxtExt;
+use tracing::{debug, instrument};
use super::FnCtxt;
use crate::{errors, type_error_struct};
diff --git a/compiler/rustc_hir_typeck/src/check.rs b/compiler/rustc_hir_typeck/src/check.rs
index cd357e4a7adb..9346ff2d6ef6 100644
--- a/compiler/rustc_hir_typeck/src/check.rs
+++ b/compiler/rustc_hir_typeck/src/check.rs
@@ -12,6 +12,7 @@ use rustc_span::def_id::LocalDefId;
use rustc_span::symbol::sym;
use rustc_target::spec::abi::Abi;
use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode};
+use tracing::{debug, instrument};
use crate::coercion::CoerceMany;
use crate::gather_locals::GatherLocalsVisitor;
diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs
index 6b813dc64cec..5117eef9ed8f 100644
--- a/compiler/rustc_hir_typeck/src/closure.rs
+++ b/compiler/rustc_hir_typeck/src/closure.rs
@@ -19,6 +19,7 @@ use rustc_target::spec::abi::Abi;
use rustc_trait_selection::error_reporting::traits::ArgKind;
use rustc_trait_selection::traits;
use rustc_type_ir::ClosureKind;
+use tracing::{debug, instrument, trace};
use super::{check_fn, CoroutineTypes, Expectation, FnCtxt};
diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs
index 54ddff988692..865e9be0a67d 100644
--- a/compiler/rustc_hir_typeck/src/coercion.rs
+++ b/compiler/rustc_hir_typeck/src/coercion.rs
@@ -66,6 +66,7 @@ use rustc_trait_selection::traits::{
self, NormalizeExt, ObligationCause, ObligationCauseCode, ObligationCtxt,
};
use smallvec::{smallvec, SmallVec};
+use tracing::{debug, instrument};
use crate::errors::SuggestBoxingForReturnImplTrait;
use crate::FnCtxt;
diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs
index 89f27e807749..0da299f01794 100644
--- a/compiler/rustc_hir_typeck/src/demand.rs
+++ b/compiler/rustc_hir_typeck/src/demand.rs
@@ -13,6 +13,7 @@ use rustc_span::symbol::sym;
use rustc_span::{Span, DUMMY_SP};
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::ObligationCause;
+use tracing::instrument;
use super::method::probe;
use crate::FnCtxt;
diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs
index dd33b947b0d0..1362d3626efd 100644
--- a/compiler/rustc_hir_typeck/src/expr.rs
+++ b/compiler/rustc_hir_typeck/src/expr.rs
@@ -34,6 +34,7 @@ use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{self, ObligationCauseCode, ObligationCtxt};
use smallvec::SmallVec;
+use tracing::{debug, instrument, trace};
use {rustc_ast as ast, rustc_hir as hir};
use crate::coercion::{CoerceMany, DynamicCoerceMany};
diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs
index 548d5a7cc4cc..da8c0ad3a30e 100644
--- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs
+++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs
@@ -26,6 +26,7 @@ use rustc_middle::{bug, span_bug};
use rustc_span::{ErrorGuaranteed, Span};
use rustc_target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT};
use rustc_trait_selection::infer::InferCtxtExt;
+use tracing::{debug, trace};
use ty::BorrowKind::ImmBorrow;
use crate::fn_ctxt::FnCtxt;
diff --git a/compiler/rustc_hir_typeck/src/fallback.rs b/compiler/rustc_hir_typeck/src/fallback.rs
index b1dc19b37774..79b02a7f0459 100644
--- a/compiler/rustc_hir_typeck/src/fallback.rs
+++ b/compiler/rustc_hir_typeck/src/fallback.rs
@@ -14,6 +14,7 @@ use rustc_session::lint;
use rustc_span::def_id::LocalDefId;
use rustc_span::{Span, DUMMY_SP};
use rustc_trait_selection::traits::{ObligationCause, ObligationCtxt};
+use tracing::debug;
use crate::{errors, FnCtxt, TypeckRootCtxt};
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
index 2d205d1ede9c..97c27680959f 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
@@ -38,6 +38,7 @@ use rustc_trait_selection::error_reporting::infer::need_type_info::TypeAnnotatio
use rustc_trait_selection::traits::{
self, NormalizeExt, ObligationCauseCode, ObligationCtxt, StructurallyNormalizeExt,
};
+use tracing::{debug, instrument};
use crate::callee::{self, DeferredCallResolution};
use crate::errors::{self, CtorIsPrivate};
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
index 5333982c4202..eebb0217990d 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
@@ -26,6 +26,7 @@ use rustc_span::{sym, Span, DUMMY_SP};
use rustc_trait_selection::error_reporting::infer::{FailureCode, ObligationCauseExt};
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{self, ObligationCauseCode, SelectionContext};
+use tracing::debug;
use {rustc_ast as ast, rustc_hir as hir};
use crate::coercion::CoerceMany;
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs
index be4db2934b7b..2dcab9ed0044 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs
@@ -7,6 +7,7 @@ use rustc_span::Span;
use rustc_trait_selection::solve::inspect::{
InspectConfig, InspectGoal, ProofTreeInferCtxtExt, ProofTreeVisitor,
};
+use tracing::{debug, instrument, trace};
use crate::FnCtxt;
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
index 8e69a075030b..a43d7aa31a52 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
@@ -263,27 +263,24 @@ impl<'tcx> HirTyLowerer<'tcx> for FnCtxt<'_, 'tcx> {
_: Span,
def_id: LocalDefId,
_: Ident,
- ) -> ty::GenericPredicates<'tcx> {
+ ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
let tcx = self.tcx;
let item_def_id = tcx.hir().ty_param_owner(def_id);
let generics = tcx.generics_of(item_def_id);
let index = generics.param_def_id_to_index[&def_id.to_def_id()];
// HACK(eddyb) should get the original `Span`.
let span = tcx.def_span(def_id);
- ty::GenericPredicates {
- parent: None,
- predicates: tcx.arena.alloc_from_iter(
- self.param_env.caller_bounds().iter().filter_map(|predicate| {
- match predicate.kind().skip_binder() {
- ty::ClauseKind::Trait(data) if data.self_ty().is_param(index) => {
- Some((predicate, span))
- }
- _ => None,
+
+ ty::EarlyBinder::bind(tcx.arena.alloc_from_iter(
+ self.param_env.caller_bounds().iter().filter_map(|predicate| {
+ match predicate.kind().skip_binder() {
+ ty::ClauseKind::Trait(data) if data.self_ty().is_param(index) => {
+ Some((predicate, span))
}
- }),
- ),
- effects_min_tys: ty::List::empty(),
- }
+ _ => None,
+ }
+ }),
+ ))
}
fn lower_assoc_ty(
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
index 031aa6159d2b..4454703645e7 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
@@ -31,6 +31,7 @@ use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits;
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
+use tracing::{debug, instrument};
use super::FnCtxt;
use crate::fn_ctxt::rustc_span::BytePos;
diff --git a/compiler/rustc_hir_typeck/src/gather_locals.rs b/compiler/rustc_hir_typeck/src/gather_locals.rs
index 0fd450e869aa..4ea22884cf37 100644
--- a/compiler/rustc_hir_typeck/src/gather_locals.rs
+++ b/compiler/rustc_hir_typeck/src/gather_locals.rs
@@ -5,6 +5,7 @@ use rustc_infer::traits::ObligationCauseCode;
use rustc_middle::ty::{Ty, UserType};
use rustc_span::def_id::LocalDefId;
use rustc_span::Span;
+use tracing::debug;
use crate::FnCtxt;
diff --git a/compiler/rustc_hir_typeck/src/intrinsicck.rs b/compiler/rustc_hir_typeck/src/intrinsicck.rs
index 62aa29e673de..f39d83a2a6f7 100644
--- a/compiler/rustc_hir_typeck/src/intrinsicck.rs
+++ b/compiler/rustc_hir_typeck/src/intrinsicck.rs
@@ -7,6 +7,7 @@ use rustc_middle::bug;
use rustc_middle::ty::layout::{LayoutError, SizeSkeleton};
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
use rustc_target::abi::{Pointer, VariantIdx};
+use tracing::trace;
use super::FnCtxt;
diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs
index 8e6484f1e293..caf09c1177fd 100644
--- a/compiler/rustc_hir_typeck/src/lib.rs
+++ b/compiler/rustc_hir_typeck/src/lib.rs
@@ -11,9 +11,6 @@
#![warn(unreachable_pub)]
// tidy-alphabetical-end
-#[macro_use]
-extern crate tracing;
-
mod _match;
mod autoderef;
mod callee;
@@ -60,6 +57,7 @@ use rustc_middle::{bug, span_bug};
use rustc_session::config;
use rustc_span::def_id::LocalDefId;
use rustc_span::Span;
+use tracing::{debug, instrument};
use typeck_root_ctxt::TypeckRootCtxt;
use crate::check::check_fn;
diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs
index 2c3cfcf3cbd6..faeabdc08210 100644
--- a/compiler/rustc_hir_typeck/src/method/confirm.rs
+++ b/compiler/rustc_hir_typeck/src/method/confirm.rs
@@ -22,6 +22,7 @@ use rustc_middle::ty::{
use rustc_middle::{bug, span_bug};
use rustc_span::{Span, DUMMY_SP};
use rustc_trait_selection::traits;
+use tracing::debug;
use super::{probe, MethodCallee};
use crate::{callee, FnCtxt};
diff --git a/compiler/rustc_hir_typeck/src/method/mod.rs b/compiler/rustc_hir_typeck/src/method/mod.rs
index 39307a29dad1..7019b718b16e 100644
--- a/compiler/rustc_hir_typeck/src/method/mod.rs
+++ b/compiler/rustc_hir_typeck/src/method/mod.rs
@@ -22,6 +22,7 @@ use rustc_span::symbol::Ident;
use rustc_span::Span;
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
use rustc_trait_selection::traits::{self, NormalizeExt};
+use tracing::{debug, instrument};
use self::probe::{IsSuggestion, ProbeScope};
pub(crate) use self::MethodError::*;
diff --git a/compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs b/compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs
index 0a4c3dc8af96..0790c6f9a599 100644
--- a/compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs
+++ b/compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs
@@ -12,6 +12,7 @@ use rustc_span::symbol::kw::{Empty, Underscore};
use rustc_span::symbol::{sym, Ident};
use rustc_span::Span;
use rustc_trait_selection::infer::InferCtxtExt;
+use tracing::debug;
use crate::method::probe::{self, Pick};
use crate::FnCtxt;
diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs
index 48e33c81b852..0cf5403b3c08 100644
--- a/compiler/rustc_hir_typeck/src/method/probe.rs
+++ b/compiler/rustc_hir_typeck/src/method/probe.rs
@@ -36,6 +36,7 @@ use rustc_trait_selection::traits::query::method_autoderef::{
use rustc_trait_selection::traits::query::CanonicalTyGoal;
use rustc_trait_selection::traits::{self, ObligationCause, ObligationCtxt};
use smallvec::{smallvec, SmallVec};
+use tracing::{debug, instrument};
use self::CandidateKind::*;
pub(crate) use self::PickKind::*;
diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs
index b78bb8cb98db..9ea57e4aa616 100644
--- a/compiler/rustc_hir_typeck/src/method/suggest.rs
+++ b/compiler/rustc_hir_typeck/src/method/suggest.rs
@@ -37,6 +37,7 @@ use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _
use rustc_trait_selection::traits::{
supertraits, FulfillmentError, Obligation, ObligationCause, ObligationCauseCode,
};
+use tracing::{debug, info, instrument};
use super::probe::{AutorefOrPtrAdjustment, IsSuggestion, Mode, ProbeScope};
use super::{CandidateSource, MethodError, NoMatchData};
diff --git a/compiler/rustc_hir_typeck/src/op.rs b/compiler/rustc_hir_typeck/src/op.rs
index fb0d30d5b0ef..c74270fc0e6a 100644
--- a/compiler/rustc_hir_typeck/src/op.rs
+++ b/compiler/rustc_hir_typeck/src/op.rs
@@ -17,6 +17,7 @@ use rustc_span::Span;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{FulfillmentError, ObligationCtxt};
use rustc_type_ir::TyKind::*;
+use tracing::debug;
use {rustc_ast as ast, rustc_hir as hir};
use super::method::MethodCallee;
diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs
index 206de455cd57..25f9340eeb71 100644
--- a/compiler/rustc_hir_typeck/src/pat.rs
+++ b/compiler/rustc_hir_typeck/src/pat.rs
@@ -24,6 +24,7 @@ use rustc_span::{BytePos, Span, DUMMY_SP};
use rustc_target::abi::FieldIdx;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode};
+use tracing::{debug, instrument, trace};
use ty::VariantDef;
use super::report_unexpected_variant_res;
diff --git a/compiler/rustc_hir_typeck/src/place_op.rs b/compiler/rustc_hir_typeck/src/place_op.rs
index bb2272725842..e7f47ee56c9b 100644
--- a/compiler/rustc_hir_typeck/src/place_op.rs
+++ b/compiler/rustc_hir_typeck/src/place_op.rs
@@ -9,6 +9,7 @@ use rustc_middle::ty::adjustment::{
use rustc_middle::ty::{self, Ty};
use rustc_span::symbol::{sym, Ident};
use rustc_span::Span;
+use tracing::debug;
use {rustc_ast as ast, rustc_hir as hir};
use crate::method::MethodCallee;
diff --git a/compiler/rustc_hir_typeck/src/rvalue_scopes.rs b/compiler/rustc_hir_typeck/src/rvalue_scopes.rs
index fb0fe23be65f..d65aaef4e8b3 100644
--- a/compiler/rustc_hir_typeck/src/rvalue_scopes.rs
+++ b/compiler/rustc_hir_typeck/src/rvalue_scopes.rs
@@ -4,6 +4,7 @@ use rustc_hir as hir;
use rustc_middle::bug;
use rustc_middle::middle::region::{RvalueCandidateType, Scope, ScopeTree};
use rustc_middle::ty::RvalueScopes;
+use tracing::debug;
use super::FnCtxt;
diff --git a/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs b/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs
index e6b8da3e5d6b..52fa30a352f8 100644
--- a/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs
+++ b/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs
@@ -15,6 +15,7 @@ use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
use rustc_trait_selection::traits::{
self, FulfillmentError, PredicateObligation, TraitEngine, TraitEngineExt as _,
};
+use tracing::{debug, instrument};
use super::callee::DeferredCallResolution;
diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs
index 5350affb3bc4..986453397ffc 100644
--- a/compiler/rustc_hir_typeck/src/upvar.rs
+++ b/compiler/rustc_hir_typeck/src/upvar.rs
@@ -52,6 +52,7 @@ use rustc_session::lint;
use rustc_span::{sym, BytePos, Pos, Span, Symbol};
use rustc_target::abi::FIRST_VARIANT;
use rustc_trait_selection::infer::InferCtxtExt;
+use tracing::{debug, instrument};
use super::FnCtxt;
use crate::expr_use_visitor as euv;
diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs
index 0853ed9b05bf..c2555d2bb47d 100644
--- a/compiler/rustc_hir_typeck/src/writeback.rs
+++ b/compiler/rustc_hir_typeck/src/writeback.rs
@@ -19,6 +19,7 @@ use rustc_span::symbol::sym;
use rustc_span::Span;
use rustc_trait_selection::error_reporting::infer::need_type_info::TypeAnnotationNeeded;
use rustc_trait_selection::solve;
+use tracing::{debug, instrument};
use crate::FnCtxt;
diff --git a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs
index db5139172b02..9d77afa5d2f0 100644
--- a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs
+++ b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs
@@ -13,6 +13,7 @@ use rustc_middle::ty::{
self, BoundVar, GenericArg, InferConst, List, Ty, TyCtxt, TypeFlags, TypeVisitableExt,
};
use smallvec::SmallVec;
+use tracing::debug;
use crate::infer::canonical::{
Canonical, CanonicalTyVarKind, CanonicalVarInfo, CanonicalVarKind, OriginalQueryValues,
diff --git a/compiler/rustc_infer/src/infer/canonical/query_response.rs b/compiler/rustc_infer/src/infer/canonical/query_response.rs
index 85e3cfbcce1c..95d7bb7eb383 100644
--- a/compiler/rustc_infer/src/infer/canonical/query_response.rs
+++ b/compiler/rustc_infer/src/infer/canonical/query_response.rs
@@ -17,6 +17,7 @@ use rustc_middle::mir::ConstraintCategory;
use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::{self, BoundVar, GenericArg, GenericArgKind, Ty, TyCtxt};
use rustc_middle::{bug, span_bug};
+use tracing::{debug, instrument};
use crate::infer::canonical::instantiate::{instantiate_value, CanonicalExt};
use crate::infer::canonical::{
diff --git a/compiler/rustc_infer/src/infer/free_regions.rs b/compiler/rustc_infer/src/infer/free_regions.rs
index 9a5674369dab..5452ba67497b 100644
--- a/compiler/rustc_infer/src/infer/free_regions.rs
+++ b/compiler/rustc_infer/src/infer/free_regions.rs
@@ -5,6 +5,7 @@
use rustc_data_structures::transitive_relation::TransitiveRelation;
use rustc_middle::ty::{Region, TyCtxt};
+use tracing::debug;
/// Combines a `FreeRegionMap` and a `TyCtxt`.
///
diff --git a/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs b/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs
index e5533213400c..aab64883bc50 100644
--- a/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs
+++ b/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs
@@ -16,6 +16,7 @@ use rustc_middle::ty::{
};
use rustc_middle::{bug, span_bug};
use rustc_span::Span;
+use tracing::{debug, instrument};
use super::outlives::test_type_match;
use crate::infer::region_constraints::{
diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs
index 5aa7f2596853..234dc5133f8d 100644
--- a/compiler/rustc_infer/src/infer/mod.rs
+++ b/compiler/rustc_infer/src/infer/mod.rs
@@ -44,6 +44,7 @@ use rustc_middle::{bug, span_bug};
use rustc_span::symbol::Symbol;
use rustc_span::Span;
use snapshot::undo_log::InferCtxtUndoLogs;
+use tracing::{debug, instrument};
use type_variable::TypeVariableOrigin;
pub use BoundRegionConversionTime::*;
pub use RegionVariableOrigin::*;
diff --git a/compiler/rustc_infer/src/infer/opaque_types/mod.rs b/compiler/rustc_infer/src/infer/opaque_types/mod.rs
index e9726ee8ebf3..88db7237647c 100644
--- a/compiler/rustc_infer/src/infer/opaque_types/mod.rs
+++ b/compiler/rustc_infer/src/infer/opaque_types/mod.rs
@@ -11,6 +11,7 @@ use rustc_middle::ty::{
TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
};
use rustc_span::Span;
+use tracing::{debug, instrument};
use crate::errors::OpaqueHiddenTypeDiag;
use crate::infer::{InferCtxt, InferOk};
diff --git a/compiler/rustc_infer/src/infer/opaque_types/table.rs b/compiler/rustc_infer/src/infer/opaque_types/table.rs
index 7b4e546d8318..4aa2ccab0e7b 100644
--- a/compiler/rustc_infer/src/infer/opaque_types/table.rs
+++ b/compiler/rustc_infer/src/infer/opaque_types/table.rs
@@ -1,6 +1,7 @@
use rustc_data_structures::undo_log::UndoLogs;
use rustc_middle::bug;
use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey, Ty};
+use tracing::instrument;
use super::{OpaqueTypeDecl, OpaqueTypeMap};
use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, UndoLog};
diff --git a/compiler/rustc_infer/src/infer/outlives/env.rs b/compiler/rustc_infer/src/infer/outlives/env.rs
index cc763707c9cf..77c711e57bb6 100644
--- a/compiler/rustc_infer/src/infer/outlives/env.rs
+++ b/compiler/rustc_infer/src/infer/outlives/env.rs
@@ -2,6 +2,7 @@ use rustc_data_structures::fx::FxIndexSet;
use rustc_data_structures::transitive_relation::TransitiveRelationBuilder;
use rustc_middle::bug;
use rustc_middle::ty::{self, Region};
+use tracing::{debug, instrument};
use super::explicit_outlives_bounds;
use crate::infer::free_regions::FreeRegionMap;
diff --git a/compiler/rustc_infer/src/infer/outlives/mod.rs b/compiler/rustc_infer/src/infer/outlives/mod.rs
index e4eefbc7a1a8..f5c873b03755 100644
--- a/compiler/rustc_infer/src/infer/outlives/mod.rs
+++ b/compiler/rustc_infer/src/infer/outlives/mod.rs
@@ -2,6 +2,7 @@
use rustc_middle::traits::query::{NoSolution, OutlivesBound};
use rustc_middle::ty;
+use tracing::instrument;
use self::env::OutlivesEnvironment;
use super::region_constraints::RegionConstraintData;
diff --git a/compiler/rustc_infer/src/infer/outlives/obligations.rs b/compiler/rustc_infer/src/infer/outlives/obligations.rs
index 88b004adc941..0c397350067c 100644
--- a/compiler/rustc_infer/src/infer/outlives/obligations.rs
+++ b/compiler/rustc_infer/src/infer/outlives/obligations.rs
@@ -70,6 +70,7 @@ use rustc_middle::ty::{
use rustc_span::DUMMY_SP;
use rustc_type_ir::outlives::{push_outlives_components, Component};
use smallvec::smallvec;
+use tracing::{debug, instrument};
use super::env::OutlivesEnvironment;
use crate::infer::outlives::env::RegionBoundPairs;
diff --git a/compiler/rustc_infer/src/infer/outlives/test_type_match.rs b/compiler/rustc_infer/src/infer/outlives/test_type_match.rs
index 835e34a3535b..bfdd282d7e11 100644
--- a/compiler/rustc_infer/src/infer/outlives/test_type_match.rs
+++ b/compiler/rustc_infer/src/infer/outlives/test_type_match.rs
@@ -3,6 +3,7 @@ use std::collections::hash_map::Entry;
use rustc_data_structures::fx::FxHashMap;
use rustc_middle::ty::error::TypeError;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
+use tracing::instrument;
use crate::infer::region_constraints::VerifyIfEq;
use crate::infer::relate::{self as relate, Relate, RelateResult, TypeRelation};
diff --git a/compiler/rustc_infer/src/infer/outlives/verify.rs b/compiler/rustc_infer/src/infer/outlives/verify.rs
index 1908e1e09c3d..711f20444def 100644
--- a/compiler/rustc_infer/src/infer/outlives/verify.rs
+++ b/compiler/rustc_infer/src/infer/outlives/verify.rs
@@ -3,6 +3,7 @@ use std::assert_matches::assert_matches;
use rustc_middle::ty::{self, OutlivesPredicate, Ty, TyCtxt};
use rustc_type_ir::outlives::{compute_alias_components_recursive, Component};
use smallvec::smallvec;
+use tracing::{debug, instrument, trace};
use crate::infer::outlives::env::RegionBoundPairs;
use crate::infer::region_constraints::VerifyIfEq;
diff --git a/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs b/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs
index 3d2a0a3356fd..7913f0e340e0 100644
--- a/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs
+++ b/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs
@@ -4,6 +4,7 @@ use rustc_data_structures::graph::vec_graph::VecGraph;
use rustc_index::Idx;
use rustc_middle::span_bug;
use rustc_middle::ty::error::TypeError;
+use tracing::{debug, instrument};
use super::*;
use crate::infer::relate::RelateResult;
diff --git a/compiler/rustc_infer/src/infer/region_constraints/mod.rs b/compiler/rustc_infer/src/infer/region_constraints/mod.rs
index 6ee95c73cfbd..82f7668b2d2e 100644
--- a/compiler/rustc_infer/src/infer/region_constraints/mod.rs
+++ b/compiler/rustc_infer/src/infer/region_constraints/mod.rs
@@ -13,6 +13,7 @@ use rustc_middle::infer::unify_key::{RegionVariableValue, RegionVidKey};
use rustc_middle::ty::{self, ReBound, ReStatic, ReVar, Region, RegionVid, Ty, TyCtxt};
use rustc_middle::{bug, span_bug};
use rustc_span::Span;
+use tracing::{debug, instrument};
use self::CombineMapType::*;
use self::UndoLog::*;
diff --git a/compiler/rustc_infer/src/infer/relate/combine.rs b/compiler/rustc_infer/src/infer/relate/combine.rs
index 5751ce466d98..70b59322f5be 100644
--- a/compiler/rustc_infer/src/infer/relate/combine.rs
+++ b/compiler/rustc_infer/src/infer/relate/combine.rs
@@ -24,6 +24,7 @@ use rustc_middle::traits::solve::Goal;
use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::{self, InferConst, IntType, Ty, TyCtxt, TypeVisitableExt, UintType, Upcast};
pub use rustc_next_trait_solver::relate::combine::*;
+use tracing::debug;
use super::glb::Glb;
use super::lub::Lub;
diff --git a/compiler/rustc_infer/src/infer/relate/generalize.rs b/compiler/rustc_infer/src/infer/relate/generalize.rs
index 6fa10a95313c..f257141ea658 100644
--- a/compiler/rustc_infer/src/infer/relate/generalize.rs
+++ b/compiler/rustc_infer/src/infer/relate/generalize.rs
@@ -11,6 +11,7 @@ use rustc_middle::ty::{
self, AliasRelationDirection, InferConst, Term, Ty, TyCtxt, TypeVisitable, TypeVisitableExt,
};
use rustc_span::Span;
+use tracing::{debug, instrument, warn};
use super::{
PredicateEmittingRelation, Relate, RelateResult, StructurallyRelateAliases, TypeRelation,
diff --git a/compiler/rustc_infer/src/infer/relate/glb.rs b/compiler/rustc_infer/src/infer/relate/glb.rs
index 4f2cf2c43e7c..7b12003643eb 100644
--- a/compiler/rustc_infer/src/infer/relate/glb.rs
+++ b/compiler/rustc_infer/src/infer/relate/glb.rs
@@ -4,6 +4,7 @@ use rustc_middle::traits::solve::Goal;
use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation};
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
use rustc_span::Span;
+use tracing::{debug, instrument};
use super::combine::{CombineFields, PredicateEmittingRelation};
use super::lattice::{self, LatticeDir};
diff --git a/compiler/rustc_infer/src/infer/relate/higher_ranked.rs b/compiler/rustc_infer/src/infer/relate/higher_ranked.rs
index c808ab5e6dd1..ab6a19265f3f 100644
--- a/compiler/rustc_infer/src/infer/relate/higher_ranked.rs
+++ b/compiler/rustc_infer/src/infer/relate/higher_ranked.rs
@@ -3,6 +3,7 @@
use rustc_middle::ty::fold::FnMutDelegate;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
+use tracing::{debug, instrument};
use super::RelateResult;
use crate::infer::snapshot::CombinedSnapshot;
diff --git a/compiler/rustc_infer/src/infer/relate/lattice.rs b/compiler/rustc_infer/src/infer/relate/lattice.rs
index 1eafbb9acb33..1d3f45465d63 100644
--- a/compiler/rustc_infer/src/infer/relate/lattice.rs
+++ b/compiler/rustc_infer/src/infer/relate/lattice.rs
@@ -19,6 +19,7 @@
use rustc_middle::ty::relate::RelateResult;
use rustc_middle::ty::{self, Ty, TyVar};
+use tracing::instrument;
use super::combine::PredicateEmittingRelation;
use crate::infer::{DefineOpaqueTypes, InferCtxt};
diff --git a/compiler/rustc_infer/src/infer/relate/lub.rs b/compiler/rustc_infer/src/infer/relate/lub.rs
index 046e93b63e4c..bf4d68b94286 100644
--- a/compiler/rustc_infer/src/infer/relate/lub.rs
+++ b/compiler/rustc_infer/src/infer/relate/lub.rs
@@ -4,6 +4,7 @@ use rustc_middle::traits::solve::Goal;
use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation};
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
use rustc_span::Span;
+use tracing::{debug, instrument};
use super::combine::{CombineFields, PredicateEmittingRelation};
use super::lattice::{self, LatticeDir};
diff --git a/compiler/rustc_infer/src/infer/relate/type_relating.rs b/compiler/rustc_infer/src/infer/relate/type_relating.rs
index ec600c60b240..be16fca45216 100644
--- a/compiler/rustc_infer/src/infer/relate/type_relating.rs
+++ b/compiler/rustc_infer/src/infer/relate/type_relating.rs
@@ -4,6 +4,7 @@ use rustc_middle::ty::relate::{
};
use rustc_middle::ty::{self, Ty, TyCtxt, TyVar};
use rustc_span::Span;
+use tracing::{debug, instrument};
use super::combine::CombineFields;
use crate::infer::relate::{PredicateEmittingRelation, StructurallyRelateAliases};
diff --git a/compiler/rustc_infer/src/infer/snapshot/fudge.rs b/compiler/rustc_infer/src/infer/snapshot/fudge.rs
index fdf55447f798..8e330a084c65 100644
--- a/compiler/rustc_infer/src/infer/snapshot/fudge.rs
+++ b/compiler/rustc_infer/src/infer/snapshot/fudge.rs
@@ -4,6 +4,7 @@ use rustc_data_structures::{snapshot_vec as sv, unify as ut};
use rustc_middle::infer::unify_key::{ConstVariableValue, ConstVidKey};
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
use rustc_middle::ty::{self, ConstVid, FloatVid, IntVid, RegionVid, Ty, TyCtxt, TyVid};
+use tracing::instrument;
use ut::UnifyKey;
use crate::infer::type_variable::TypeVariableOrigin;
diff --git a/compiler/rustc_infer/src/infer/snapshot/mod.rs b/compiler/rustc_infer/src/infer/snapshot/mod.rs
index d76b9b00001a..20db6583a2ba 100644
--- a/compiler/rustc_infer/src/infer/snapshot/mod.rs
+++ b/compiler/rustc_infer/src/infer/snapshot/mod.rs
@@ -1,5 +1,6 @@
use rustc_data_structures::undo_log::UndoLogs;
use rustc_middle::ty;
+use tracing::{debug, instrument};
use super::region_constraints::RegionSnapshot;
use super::InferCtxt;
diff --git a/compiler/rustc_infer/src/infer/snapshot/undo_log.rs b/compiler/rustc_infer/src/infer/snapshot/undo_log.rs
index 366af913ddc1..9aa02f89d2a7 100644
--- a/compiler/rustc_infer/src/infer/snapshot/undo_log.rs
+++ b/compiler/rustc_infer/src/infer/snapshot/undo_log.rs
@@ -4,6 +4,7 @@ use rustc_data_structures::undo_log::{Rollback, UndoLogs};
use rustc_data_structures::{snapshot_vec as sv, unify as ut};
use rustc_middle::infer::unify_key::{ConstVidKey, EffectVidKey, RegionVidKey};
use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey};
+use tracing::debug;
use crate::infer::{region_constraints, type_variable, InferCtxtInner};
use crate::traits;
diff --git a/compiler/rustc_infer/src/infer/type_variable.rs b/compiler/rustc_infer/src/infer/type_variable.rs
index f022b8ab637e..7eb2c20e0d8e 100644
--- a/compiler/rustc_infer/src/infer/type_variable.rs
+++ b/compiler/rustc_infer/src/infer/type_variable.rs
@@ -9,6 +9,7 @@ use rustc_index::IndexVec;
use rustc_middle::bug;
use rustc_middle::ty::{self, Ty, TyVid};
use rustc_span::Span;
+use tracing::debug;
use crate::infer::InferCtxtUndoLogs;
diff --git a/compiler/rustc_infer/src/lib.rs b/compiler/rustc_infer/src/lib.rs
index 94aa2ddd92fc..051bba585186 100644
--- a/compiler/rustc_infer/src/lib.rs
+++ b/compiler/rustc_infer/src/lib.rs
@@ -31,9 +31,6 @@
#![warn(unreachable_pub)]
// tidy-alphabetical-end
-#[macro_use]
-extern crate tracing;
-
mod errors;
pub mod infer;
pub mod traits;
diff --git a/compiler/rustc_infer/src/traits/project.rs b/compiler/rustc_infer/src/traits/project.rs
index 3d4ec9e51db2..f6b05340952a 100644
--- a/compiler/rustc_infer/src/traits/project.rs
+++ b/compiler/rustc_infer/src/traits/project.rs
@@ -4,6 +4,7 @@ use rustc_data_structures::snapshot_map::{self, SnapshotMapRef, SnapshotMapStora
use rustc_data_structures::undo_log::Rollback;
use rustc_middle::traits::EvaluationResult;
use rustc_middle::ty;
+use tracing::{debug, info};
use super::PredicateObligation;
use crate::infer::snapshot::undo_log::InferCtxtUndoLogs;
diff --git a/compiler/rustc_infer/src/traits/util.rs b/compiler/rustc_infer/src/traits/util.rs
index 335c65da054c..3e4f9b481666 100644
--- a/compiler/rustc_infer/src/traits/util.rs
+++ b/compiler/rustc_infer/src/traits/util.rs
@@ -123,7 +123,7 @@ pub fn transitive_bounds_that_define_assoc_item<'tcx>(
stack.extend(
tcx.explicit_supertraits_containing_assoc_item((trait_ref.def_id(), assoc_name))
- .instantiate_own_identity()
+ .iter_identity_copied()
.map(|(clause, _)| clause.instantiate_supertrait(tcx, trait_ref))
.filter_map(|clause| clause.as_trait_clause())
// FIXME: Negative supertraits are elaborated here lol
diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs
index 844d8ef02e06..42fed98df010 100644
--- a/compiler/rustc_interface/src/tests.rs
+++ b/compiler/rustc_interface/src/tests.rs
@@ -12,9 +12,10 @@ use rustc_session::config::{
CollapseMacroDebuginfo, CoverageLevel, CoverageOptions, DebugInfo, DumpMonoStatsFormat,
ErrorOutputType, ExternEntry, ExternLocation, Externs, FmtDebug, FunctionReturn,
InliningThreshold, Input, InstrumentCoverage, InstrumentXRay, LinkSelfContained,
- LinkerPluginLto, LocationDetail, LtoCli, NextSolverConfig, OomStrategy, Options, OutFileName,
- OutputType, OutputTypes, PAuthKey, PacRet, Passes, PatchableFunctionEntry, Polonius,
- ProcMacroExecutionStrategy, Strip, SwitchWithOptPath, SymbolManglingVersion, WasiExecModel,
+ LinkerPluginLto, LocationDetail, LtoCli, MirIncludeSpans, NextSolverConfig, OomStrategy,
+ Options, OutFileName, OutputType, OutputTypes, PAuthKey, PacRet, Passes,
+ PatchableFunctionEntry, Polonius, ProcMacroExecutionStrategy, Strip, SwitchWithOptPath,
+ SymbolManglingVersion, WasiExecModel,
};
use rustc_session::lint::Level;
use rustc_session::search_paths::SearchPath;
@@ -705,7 +706,7 @@ fn test_unstable_options_tracking_hash() {
untracked!(ls, vec!["all".to_owned()]);
untracked!(macro_backtrace, true);
untracked!(meta_stats, true);
- untracked!(mir_include_spans, true);
+ untracked!(mir_include_spans, MirIncludeSpans::On);
untracked!(nll_facts, true);
untracked!(no_analysis, true);
untracked!(no_leak_check, true);
diff --git a/compiler/rustc_lint/src/foreign_modules.rs b/compiler/rustc_lint/src/foreign_modules.rs
index 5da1cbc2283b..a60fc0ffbbb3 100644
--- a/compiler/rustc_lint/src/foreign_modules.rs
+++ b/compiler/rustc_lint/src/foreign_modules.rs
@@ -265,8 +265,6 @@ fn structurally_same_type_impl<'tcx>(
} else {
// Do a full, depth-first comparison between the two.
use rustc_type_ir::TyKind::*;
- let a_kind = a.kind();
- let b_kind = b.kind();
let compare_layouts = |a, b| -> Result> {
debug!("compare_layouts({:?}, {:?})", a, b);
@@ -281,12 +279,11 @@ fn structurally_same_type_impl<'tcx>(
Ok(a_layout == b_layout)
};
- #[allow(rustc::usage_of_ty_tykind)]
let is_primitive_or_pointer =
- |kind: &ty::TyKind<'_>| kind.is_primitive() || matches!(kind, RawPtr(..) | Ref(..));
+ |ty: Ty<'tcx>| ty.is_primitive() || matches!(ty.kind(), RawPtr(..) | Ref(..));
ensure_sufficient_stack(|| {
- match (a_kind, b_kind) {
+ match (a.kind(), b.kind()) {
(Adt(a_def, _), Adt(b_def, _)) => {
// We can immediately rule out these types as structurally same if
// their layouts differ.
@@ -382,17 +379,21 @@ fn structurally_same_type_impl<'tcx>(
// An Adt and a primitive or pointer type. This can be FFI-safe if non-null
// enum layout optimisation is being applied.
- (Adt(..), other_kind) | (other_kind, Adt(..))
- if is_primitive_or_pointer(other_kind) =>
- {
- let (primitive, adt) =
- if is_primitive_or_pointer(a.kind()) { (a, b) } else { (b, a) };
- if let Some(ty) = types::repr_nullable_ptr(tcx, param_env, adt, ckind) {
- ty == primitive
+ (Adt(..), _) if is_primitive_or_pointer(b) => {
+ if let Some(ty) = types::repr_nullable_ptr(tcx, param_env, a, ckind) {
+ ty == b
} else {
compare_layouts(a, b).unwrap_or(false)
}
}
+ (_, Adt(..)) if is_primitive_or_pointer(a) => {
+ if let Some(ty) = types::repr_nullable_ptr(tcx, param_env, b, ckind) {
+ ty == a
+ } else {
+ compare_layouts(a, b).unwrap_or(false)
+ }
+ }
+
// Otherwise, just compare the layouts. This may fail to lint for some
// incompatible types, but at the very least, will stop reads into
// uninitialised memory.
diff --git a/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs b/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs
index 978109aba5f9..78468020c4d5 100644
--- a/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs
+++ b/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs
@@ -45,8 +45,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleSupertraitUpcastable {
let direct_super_traits_iter = cx
.tcx
.explicit_super_predicates_of(def_id)
- .predicates
- .into_iter()
+ .iter_identity_copied()
.filter_map(|(pred, _)| pred.as_trait_clause());
if direct_super_traits_iter.count() > 1 {
cx.emit_span_lint(
diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs
index 44c72e0c4fe3..04fd7c9c627e 100644
--- a/compiler/rustc_lint_defs/src/builtin.rs
+++ b/compiler/rustc_lint_defs/src/builtin.rs
@@ -4771,7 +4771,7 @@ declare_lint! {
/// version of Rust this will be fixed and therefore dependencies relying
/// on the non-spec-compliant C ABI will stop functioning.
pub WASM_C_ABI,
- Warn,
+ Deny,
"detects dependencies that are incompatible with the Wasm C ABI",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
index c7306b0516fa..da27db29c87a 100644
--- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
@@ -1212,7 +1212,11 @@ struct LLVMRustThinLTOData {
// Not 100% sure what these are, but they impact what's internalized and
// what's inlined across modules, I believe.
#if LLVM_VERSION_GE(18, 0)
+#if LLVM_VERSION_GE(20, 0)
+ FunctionImporter::ImportListsTy ImportLists;
+#else
DenseMap ImportLists;
+#endif
DenseMap ExportLists;
DenseMap ModuleToDefinedGVSummaries;
#else
@@ -1421,13 +1425,13 @@ LLVMRustPrepareThinLTOInternalize(const LLVMRustThinLTOData *Data,
return true;
}
-extern "C" bool LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data,
+extern "C" bool LLVMRustPrepareThinLTOImport(LLVMRustThinLTOData *Data,
LLVMModuleRef M,
LLVMTargetMachineRef TM) {
Module &Mod = *unwrap(M);
TargetMachine &Target = *unwrap(TM);
- const auto &ImportList = Data->ImportLists.lookup(Mod.getModuleIdentifier());
+ const auto &ImportList = Data->ImportLists[Mod.getModuleIdentifier()];
auto Loader = [&](StringRef Identifier) {
const auto &Memory = Data->ModuleMap.lookup(Identifier);
auto &Context = Mod.getContext();
@@ -1610,7 +1614,7 @@ extern "C" void LLVMRustComputeLTOCacheKey(RustStringRef KeyOut,
LLVMRustThinLTOData *Data) {
SmallString<40> Key;
llvm::lto::Config conf;
- const auto &ImportList = Data->ImportLists.lookup(ModId);
+ const auto &ImportList = Data->ImportLists[ModId];
const auto &ExportList = Data->ExportLists.lookup(ModId);
const auto &ResolvedODR = Data->ResolvedODR.lookup(ModId);
const auto &DefinedGlobals = Data->ModuleToDefinedGVSummaries.lookup(ModId);
diff --git a/compiler/rustc_metadata/src/lib.rs b/compiler/rustc_metadata/src/lib.rs
index c798ca00bcce..58b352f263de 100644
--- a/compiler/rustc_metadata/src/lib.rs
+++ b/compiler/rustc_metadata/src/lib.rs
@@ -3,6 +3,7 @@
#![allow(rustc::potential_query_instability)]
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)]
+#![feature(control_flow_enum)]
#![feature(coroutines)]
#![feature(decl_macro)]
#![feature(error_iter)]
@@ -35,7 +36,9 @@ pub mod locator;
pub use creader::{load_symbol_from_dylib, DylibError};
pub use fs::{emit_wrapper_file, METADATA_FILENAME};
-pub use native_libs::find_native_static_library;
+pub use native_libs::{
+ find_native_static_library, try_find_native_static_library, walk_native_lib_search_dirs,
+};
pub use rmeta::{encode_metadata, rendered_const, EncodedMetadata, METADATA_HEADER};
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs
index 34497f5ac53f..a6ad449cb53e 100644
--- a/compiler/rustc_metadata/src/native_libs.rs
+++ b/compiler/rustc_metadata/src/native_libs.rs
@@ -1,4 +1,5 @@
-use std::path::PathBuf;
+use std::ops::ControlFlow;
+use std::path::{Path, PathBuf};
use rustc_ast::{NestedMetaItem, CRATE_NODE_ID};
use rustc_attr as attr;
@@ -16,10 +17,68 @@ use rustc_session::Session;
use rustc_span::def_id::{DefId, LOCAL_CRATE};
use rustc_span::symbol::{sym, Symbol};
use rustc_target::spec::abi::Abi;
+use rustc_target::spec::LinkSelfContainedComponents;
use crate::{errors, fluent_generated};
-pub fn find_native_static_library(name: &str, verbatim: bool, sess: &Session) -> PathBuf {
+pub fn walk_native_lib_search_dirs(
+ sess: &Session,
+ self_contained_components: LinkSelfContainedComponents,
+ apple_sdk_root: Option<&Path>,
+ mut f: impl FnMut(&Path, bool /*is_framework*/) -> ControlFlow,
+) -> ControlFlow {
+ // Library search paths explicitly supplied by user (`-L` on the command line).
+ for search_path in sess.target_filesearch(PathKind::Native).cli_search_paths() {
+ f(&search_path.dir, false)?;
+ }
+ for search_path in sess.target_filesearch(PathKind::Framework).cli_search_paths() {
+ // Frameworks are looked up strictly in framework-specific paths.
+ if search_path.kind != PathKind::All {
+ f(&search_path.dir, true)?;
+ }
+ }
+
+ // The toolchain ships some native library components and self-contained linking was enabled.
+ // Add the self-contained library directory to search paths.
+ if self_contained_components.intersects(
+ LinkSelfContainedComponents::LIBC
+ | LinkSelfContainedComponents::UNWIND
+ | LinkSelfContainedComponents::MINGW,
+ ) {
+ f(&sess.target_tlib_path.dir.join("self-contained"), false)?;
+ }
+
+ // Toolchains for some targets may ship `libunwind.a`, but place it into the main sysroot
+ // library directory instead of the self-contained directories.
+ // Sanitizer libraries have the same issue and are also linked by name on Apple targets.
+ // The targets here should be in sync with `copy_third_party_objects` in bootstrap.
+ // FIXME: implement `-Clink-self-contained=+/-unwind,+/-sanitizers`, move the shipped libunwind
+ // and sanitizers to self-contained directory, and stop adding this search path.
+ if sess.target.vendor == "fortanix"
+ || sess.target.os == "linux"
+ || sess.target.os == "fuchsia"
+ || sess.target.is_like_osx && !sess.opts.unstable_opts.sanitizer.is_empty()
+ {
+ f(&sess.target_tlib_path.dir, false)?;
+ }
+
+ // Mac Catalyst uses the macOS SDK, but to link to iOS-specific frameworks
+ // we must have the support library stubs in the library search path (#121430).
+ if let Some(sdk_root) = apple_sdk_root
+ && sess.target.llvm_target.contains("macabi")
+ {
+ f(&sdk_root.join("System/iOSSupport/usr/lib"), false)?;
+ f(&sdk_root.join("System/iOSSupport/System/Library/Frameworks"), true)?;
+ }
+
+ ControlFlow::Continue(())
+}
+
+pub fn try_find_native_static_library(
+ sess: &Session,
+ name: &str,
+ verbatim: bool,
+) -> Option {
let formats = if verbatim {
vec![("".into(), "".into())]
} else {
@@ -30,16 +89,29 @@ pub fn find_native_static_library(name: &str, verbatim: bool, sess: &Session) ->
if os == unix { vec![os] } else { vec![os, unix] }
};
- for path in sess.target_filesearch(PathKind::Native).search_paths() {
- for (prefix, suffix) in &formats {
- let test = path.dir.join(format!("{prefix}{name}{suffix}"));
- if test.exists() {
- return test;
+ // FIXME: Account for self-contained linking settings and Apple SDK.
+ walk_native_lib_search_dirs(
+ sess,
+ LinkSelfContainedComponents::empty(),
+ None,
+ |dir, is_framework| {
+ if !is_framework {
+ for (prefix, suffix) in &formats {
+ let test = dir.join(format!("{prefix}{name}{suffix}"));
+ if test.exists() {
+ return ControlFlow::Break(test);
+ }
+ }
}
- }
- }
+ ControlFlow::Continue(())
+ },
+ )
+ .break_value()
+}
- sess.dcx().emit_fatal(errors::MissingNativeLibrary::new(name, verbatim));
+pub fn find_native_static_library(name: &str, verbatim: bool, sess: &Session) -> PathBuf {
+ try_find_native_static_library(sess, name, verbatim)
+ .unwrap_or_else(|| sess.dcx().emit_fatal(errors::MissingNativeLibrary::new(name, verbatim)))
}
fn find_bundled_library(
diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs
index 09aea2337185..f3ae24a5895a 100644
--- a/compiler/rustc_metadata/src/rmeta/decoder.rs
+++ b/compiler/rustc_metadata/src/rmeta/decoder.rs
@@ -1070,34 +1070,6 @@ impl<'a> CrateMetadataRef<'a> {
)
}
- fn get_explicit_item_bounds<'tcx>(
- self,
- index: DefIndex,
- tcx: TyCtxt<'tcx>,
- ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
- let lazy = self.root.tables.explicit_item_bounds.get(self, index);
- let output = if lazy.is_default() {
- &mut []
- } else {
- tcx.arena.alloc_from_iter(lazy.decode((self, tcx)))
- };
- ty::EarlyBinder::bind(&*output)
- }
-
- fn get_explicit_item_super_predicates<'tcx>(
- self,
- index: DefIndex,
- tcx: TyCtxt<'tcx>,
- ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
- let lazy = self.root.tables.explicit_item_super_predicates.get(self, index);
- let output = if lazy.is_default() {
- &mut []
- } else {
- tcx.arena.alloc_from_iter(lazy.decode((self, tcx)))
- };
- ty::EarlyBinder::bind(&*output)
- }
-
fn get_variant(
self,
kind: DefKind,
@@ -1323,10 +1295,6 @@ impl<'a> CrateMetadataRef<'a> {
self.root.tables.optimized_mir.get(self, id).is_some()
}
- fn cross_crate_inlinable(self, id: DefIndex) -> bool {
- self.root.tables.cross_crate_inlinable.get(self, id)
- }
-
fn get_fn_has_self_parameter(self, id: DefIndex, sess: &'a Session) -> bool {
self.root
.tables
diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
index 27625f791082..a82340e3d613 100644
--- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
+++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
@@ -32,13 +32,20 @@ trait ProcessQueryValue<'tcx, T> {
fn process_decoded(self, _tcx: TyCtxt<'tcx>, _err: impl Fn() -> !) -> T;
}
-impl ProcessQueryValue<'_, Option> for Option {
+impl ProcessQueryValue<'_, T> for T {
#[inline(always)]
- fn process_decoded(self, _tcx: TyCtxt<'_>, _err: impl Fn() -> !) -> Option {
+ fn process_decoded(self, _tcx: TyCtxt<'_>, _err: impl Fn() -> !) -> T {
self
}
}
+impl<'tcx, T> ProcessQueryValue<'tcx, ty::EarlyBinder<'tcx, T>> for T {
+ #[inline(always)]
+ fn process_decoded(self, _tcx: TyCtxt<'_>, _err: impl Fn() -> !) -> ty::EarlyBinder<'tcx, T> {
+ ty::EarlyBinder::bind(self)
+ }
+}
+
impl ProcessQueryValue<'_, T> for Option {
#[inline(always)]
fn process_decoded(self, _tcx: TyCtxt<'_>, err: impl Fn() -> !) -> T {
@@ -69,6 +76,24 @@ impl<'a, 'tcx, T: Copy + Decodable>> ProcessQueryValue<'
}
}
+impl<'a, 'tcx, T: Copy + Decodable>>
+ ProcessQueryValue<'tcx, ty::EarlyBinder<'tcx, &'tcx [T]>>
+ for Option>
+{
+ #[inline(always)]
+ fn process_decoded(
+ self,
+ tcx: TyCtxt<'tcx>,
+ _err: impl Fn() -> !,
+ ) -> ty::EarlyBinder<'tcx, &'tcx [T]> {
+ ty::EarlyBinder::bind(if let Some(iter) = self {
+ tcx.arena.alloc_from_iter(iter)
+ } else {
+ &[]
+ })
+ }
+}
+
impl<'a, 'tcx, T: Copy + Decodable>>
ProcessQueryValue<'tcx, Option<&'tcx [T]>> for Option>
{
@@ -103,7 +128,12 @@ macro_rules! provide_one {
provide_one! {
$tcx, $def_id, $other, $cdata, $name => {
let lazy = $cdata.root.tables.$name.get($cdata, $def_id.index);
- if lazy.is_default() { &[] } else { $tcx.arena.alloc_from_iter(lazy.decode(($cdata, $tcx))) }
+ let value = if lazy.is_default() {
+ &[] as &[_]
+ } else {
+ $tcx.arena.alloc_from_iter(lazy.decode(($cdata, $tcx)))
+ };
+ value.process_decoded($tcx, || panic!("{:?} does not have a {:?}", $def_id, stringify!($name)))
}
}
};
@@ -212,15 +242,15 @@ impl IntoArgs for (CrateNum, SimplifiedType) {
}
provide! { tcx, def_id, other, cdata,
- explicit_item_bounds => { cdata.get_explicit_item_bounds(def_id.index, tcx) }
- explicit_item_super_predicates => { cdata.get_explicit_item_super_predicates(def_id.index, tcx) }
+ explicit_item_bounds => { table_defaulted_array }
+ explicit_item_super_predicates => { table_defaulted_array }
explicit_predicates_of => { table }
generics_of => { table }
inferred_outlives_of => { table_defaulted_array }
explicit_super_predicates_of => { table }
explicit_implied_predicates_of => { table }
type_of => { table }
- type_alias_is_lazy => { cdata.root.tables.type_alias_is_lazy.get(cdata, def_id.index) }
+ type_alias_is_lazy => { table_direct }
variances_of => { table }
fn_sig => { table }
codegen_fn_attrs => { table }
@@ -241,7 +271,7 @@ provide! { tcx, def_id, other, cdata,
lookup_default_body_stability => { table }
lookup_deprecation_entry => { table }
params_in_repr => { table }
- unused_generic_params => { cdata.root.tables.unused_generic_params.get(cdata, def_id.index) }
+ unused_generic_params => { table_direct }
def_kind => { cdata.def_kind(def_id.index) }
impl_parent => { table }
defaultness => { table_direct }
@@ -287,9 +317,7 @@ provide! { tcx, def_id, other, cdata,
.process_decoded(tcx, || panic!("{def_id:?} does not have trait_impl_trait_tys")))
}
- associated_type_for_effects => {
- table
- }
+ associated_type_for_effects => { table }
associated_types_for_impl_traits_in_associated_fn => { table_defaulted_array }
visibility => { cdata.get_visibility(def_id.index) }
@@ -310,7 +338,7 @@ provide! { tcx, def_id, other, cdata,
item_attrs => { tcx.arena.alloc_from_iter(cdata.get_item_attrs(def_id.index, tcx.sess)) }
is_mir_available => { cdata.is_item_mir_available(def_id.index) }
is_ctfe_mir_available => { cdata.is_ctfe_mir_available(def_id.index) }
- cross_crate_inlinable => { cdata.cross_crate_inlinable(def_id.index) }
+ cross_crate_inlinable => { table_direct }
dylib_dependency_formats => { cdata.get_dylib_dependency_formats(tcx) }
is_private_dep => { cdata.private_dep }
diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs
index d9a844ad8374..919623cff609 100644
--- a/compiler/rustc_metadata/src/rmeta/encoder.rs
+++ b/compiler/rustc_metadata/src/rmeta/encoder.rs
@@ -1446,8 +1446,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
}
if let DefKind::Trait = def_kind {
record!(self.tables.trait_def[def_id] <- self.tcx.trait_def(def_id));
- record!(self.tables.explicit_super_predicates_of[def_id] <- self.tcx.explicit_super_predicates_of(def_id));
- record!(self.tables.explicit_implied_predicates_of[def_id] <- self.tcx.explicit_implied_predicates_of(def_id));
+ record_array!(self.tables.explicit_super_predicates_of[def_id] <-
+ self.tcx.explicit_super_predicates_of(def_id).skip_binder());
+ record_array!(self.tables.explicit_implied_predicates_of[def_id] <-
+ self.tcx.explicit_implied_predicates_of(def_id).skip_binder());
let module_children = self.tcx.module_children_local(local_id);
record_array!(self.tables.module_children_non_reexports[def_id] <-
@@ -1455,8 +1457,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
}
if let DefKind::TraitAlias = def_kind {
record!(self.tables.trait_def[def_id] <- self.tcx.trait_def(def_id));
- record!(self.tables.explicit_super_predicates_of[def_id] <- self.tcx.explicit_super_predicates_of(def_id));
- record!(self.tables.explicit_implied_predicates_of[def_id] <- self.tcx.explicit_implied_predicates_of(def_id));
+ record_array!(self.tables.explicit_super_predicates_of[def_id] <-
+ self.tcx.explicit_super_predicates_of(def_id).skip_binder());
+ record_array!(self.tables.explicit_implied_predicates_of[def_id] <-
+ self.tcx.explicit_implied_predicates_of(def_id).skip_binder());
}
if let DefKind::Trait | DefKind::Impl { .. } = def_kind {
let associated_item_def_ids = self.tcx.associated_item_def_ids(def_id);
diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs
index aec728d42624..987ee3f07e92 100644
--- a/compiler/rustc_metadata/src/rmeta/mod.rs
+++ b/compiler/rustc_metadata/src/rmeta/mod.rs
@@ -419,10 +419,10 @@ define_tables! {
lookup_deprecation_entry: Table>,
explicit_predicates_of: Table>>,
generics_of: Table>,
- explicit_super_predicates_of: Table>>,
+ explicit_super_predicates_of: Table, Span)>>,
// As an optimization, we only store this for trait aliases,
// since it's identical to explicit_super_predicates_of for traits.
- explicit_implied_predicates_of: Table>>,
+ explicit_implied_predicates_of: Table, Span)>>,
type_of: Table>>>,
variances_of: Table>,
fn_sig: Table>>>,
diff --git a/compiler/rustc_middle/src/mir/interpret/allocation.rs b/compiler/rustc_middle/src/mir/interpret/allocation.rs
index 3e101c0c6354..5fb8af576ae9 100644
--- a/compiler/rustc_middle/src/mir/interpret/allocation.rs
+++ b/compiler/rustc_middle/src/mir/interpret/allocation.rs
@@ -358,10 +358,11 @@ impl Allocation {
pub fn adjust_from_tcx(
&self,
cx: &impl HasDataLayout,
+ mut alloc_bytes: impl FnMut(&[u8], Align) -> Result,
mut adjust_ptr: impl FnMut(Pointer) -> Result, Err>,
) -> Result, Err> {
// Copy the data.
- let mut bytes = Bytes::from_bytes(Cow::Borrowed(&*self.bytes), self.align);
+ let mut bytes = alloc_bytes(&*self.bytes, self.align)?;
// Adjust provenance of pointers stored in this allocation.
let mut new_provenance = Vec::with_capacity(self.provenance.ptrs().len());
let ptr_size = cx.data_layout().pointer_size.bytes_usize();
diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs
index 6785805c27df..9906be60e3e9 100644
--- a/compiler/rustc_middle/src/mir/pretty.rs
+++ b/compiler/rustc_middle/src/mir/pretty.rs
@@ -43,8 +43,23 @@ pub enum PassWhere {
AfterTerminator(BasicBlock),
}
-/// If the session is properly configured, dumps a human-readable
-/// representation of the mir into:
+/// Cosmetic options for pretty-printing the MIR contents, gathered from the CLI. Each pass can
+/// override these when dumping its own specific MIR information with [`dump_mir_with_options`].
+#[derive(Copy, Clone)]
+pub struct PrettyPrintMirOptions {
+ /// Whether to include extra comments, like span info. From `-Z mir-include-spans`.
+ pub include_extra_comments: bool,
+}
+
+impl PrettyPrintMirOptions {
+ /// Create the default set of MIR pretty-printing options from the CLI flags.
+ pub fn from_cli(tcx: TyCtxt<'_>) -> Self {
+ Self { include_extra_comments: tcx.sess.opts.unstable_opts.mir_include_spans.is_enabled() }
+ }
+}
+
+/// If the session is properly configured, dumps a human-readable representation of the MIR (with
+/// default pretty-printing options) into:
///
/// ```text
/// rustc.node...
@@ -77,12 +92,40 @@ pub fn dump_mir<'tcx, F>(
extra_data: F,
) where
F: FnMut(PassWhere, &mut dyn io::Write) -> io::Result<()>,
+{
+ dump_mir_with_options(
+ tcx,
+ pass_num,
+ pass_name,
+ disambiguator,
+ body,
+ extra_data,
+ PrettyPrintMirOptions::from_cli(tcx),
+ );
+}
+
+/// If the session is properly configured, dumps a human-readable representation of the MIR, with
+/// the given [pretty-printing options][PrettyPrintMirOptions].
+///
+/// See [`dump_mir`] for more details.
+///
+#[inline]
+pub fn dump_mir_with_options<'tcx, F>(
+ tcx: TyCtxt<'tcx>,
+ pass_num: bool,
+ pass_name: &str,
+ disambiguator: &dyn Display,
+ body: &Body<'tcx>,
+ extra_data: F,
+ options: PrettyPrintMirOptions,
+) where
+ F: FnMut(PassWhere, &mut dyn io::Write) -> io::Result<()>,
{
if !dump_enabled(tcx, pass_name, body.source.def_id()) {
return;
}
- dump_matched_mir_node(tcx, pass_num, pass_name, disambiguator, body, extra_data);
+ dump_matched_mir_node(tcx, pass_num, pass_name, disambiguator, body, extra_data, options);
}
pub fn dump_enabled(tcx: TyCtxt<'_>, pass_name: &str, def_id: DefId) -> bool {
@@ -112,6 +155,7 @@ fn dump_matched_mir_node<'tcx, F>(
disambiguator: &dyn Display,
body: &Body<'tcx>,
mut extra_data: F,
+ options: PrettyPrintMirOptions,
) where
F: FnMut(PassWhere, &mut dyn io::Write) -> io::Result<()>,
{
@@ -133,7 +177,7 @@ fn dump_matched_mir_node<'tcx, F>(
writeln!(file)?;
extra_data(PassWhere::BeforeCFG, &mut file)?;
write_user_type_annotations(tcx, body, &mut file)?;
- write_mir_fn(tcx, body, &mut extra_data, &mut file)?;
+ write_mir_fn(tcx, body, &mut extra_data, &mut file, options)?;
extra_data(PassWhere::AfterCFG, &mut file)?;
};
@@ -243,12 +287,15 @@ pub fn create_dump_file<'tcx>(
///////////////////////////////////////////////////////////////////////////
// Whole MIR bodies
-/// Write out a human-readable textual representation for the given MIR.
+/// Write out a human-readable textual representation for the given MIR, with the default
+/// [PrettyPrintMirOptions].
pub fn write_mir_pretty<'tcx>(
tcx: TyCtxt<'tcx>,
single: Option,
w: &mut dyn io::Write,
) -> io::Result<()> {
+ let options = PrettyPrintMirOptions::from_cli(tcx);
+
writeln!(w, "// WARNING: This output format is intended for human consumers only")?;
writeln!(w, "// and is subject to change without notice. Knock yourself out.")?;
@@ -262,11 +309,11 @@ pub fn write_mir_pretty<'tcx>(
}
let render_body = |w: &mut dyn io::Write, body| -> io::Result<()> {
- write_mir_fn(tcx, body, &mut |_, _| Ok(()), w)?;
+ write_mir_fn(tcx, body, &mut |_, _| Ok(()), w, options)?;
for body in tcx.promoted_mir(def_id) {
writeln!(w)?;
- write_mir_fn(tcx, body, &mut |_, _| Ok(()), w)?;
+ write_mir_fn(tcx, body, &mut |_, _| Ok(()), w, options)?;
}
Ok(())
};
@@ -278,7 +325,7 @@ pub fn write_mir_pretty<'tcx>(
writeln!(w, "// MIR FOR CTFE")?;
// Do not use `render_body`, as that would render the promoteds again, but these
// are shared between mir_for_ctfe and optimized_mir
- write_mir_fn(tcx, tcx.mir_for_ctfe(def_id), &mut |_, _| Ok(()), w)?;
+ write_mir_fn(tcx, tcx.mir_for_ctfe(def_id), &mut |_, _| Ok(()), w, options)?;
} else {
let instance_mir = tcx.instance_mir(ty::InstanceKind::Item(def_id));
render_body(w, instance_mir)?;
@@ -293,14 +340,15 @@ pub fn write_mir_fn<'tcx, F>(
body: &Body<'tcx>,
extra_data: &mut F,
w: &mut dyn io::Write,
+ options: PrettyPrintMirOptions,
) -> io::Result<()>
where
F: FnMut(PassWhere, &mut dyn io::Write) -> io::Result<()>,
{
- write_mir_intro(tcx, body, w)?;
+ write_mir_intro(tcx, body, w, options)?;
for block in body.basic_blocks.indices() {
extra_data(PassWhere::BeforeBlock(block), w)?;
- write_basic_block(tcx, block, body, extra_data, w)?;
+ write_basic_block(tcx, block, body, extra_data, w, options)?;
if block.index() + 1 != body.basic_blocks.len() {
writeln!(w)?;
}
@@ -321,6 +369,7 @@ fn write_scope_tree(
w: &mut dyn io::Write,
parent: SourceScope,
depth: usize,
+ options: PrettyPrintMirOptions,
) -> io::Result<()> {
let indent = depth * INDENT.len();
@@ -333,7 +382,7 @@ fn write_scope_tree(
let indented_debug_info = format!("{0:1$}debug {2:?};", INDENT, indent, var_debug_info);
- if tcx.sess.opts.unstable_opts.mir_include_spans {
+ if options.include_extra_comments {
writeln!(
w,
"{0:1$} // in {2}",
@@ -373,7 +422,7 @@ fn write_scope_tree(
let local_name = if local == RETURN_PLACE { " return place" } else { "" };
- if tcx.sess.opts.unstable_opts.mir_include_spans {
+ if options.include_extra_comments {
writeln!(
w,
"{0:1$} //{2} in {3}",
@@ -410,7 +459,7 @@ fn write_scope_tree(
let indented_header = format!("{0:1$}scope {2}{3} {{", "", indent, child.index(), special);
- if tcx.sess.opts.unstable_opts.mir_include_spans {
+ if options.include_extra_comments {
if let Some(span) = span {
writeln!(
w,
@@ -426,7 +475,7 @@ fn write_scope_tree(
writeln!(w, "{indented_header}")?;
}
- write_scope_tree(tcx, body, scope_tree, w, child, depth + 1)?;
+ write_scope_tree(tcx, body, scope_tree, w, child, depth + 1, options)?;
writeln!(w, "{0:1$}}}", "", depth * INDENT.len())?;
}
@@ -449,10 +498,11 @@ impl Debug for VarDebugInfo<'_> {
/// Write out a human-readable textual representation of the MIR's `fn` type and the types of its
/// local variables (both user-defined bindings and compiler temporaries).
-pub fn write_mir_intro<'tcx>(
+fn write_mir_intro<'tcx>(
tcx: TyCtxt<'tcx>,
body: &Body<'_>,
w: &mut dyn io::Write,
+ options: PrettyPrintMirOptions,
) -> io::Result<()> {
write_mir_sig(tcx, body, w)?;
writeln!(w, "{{")?;
@@ -468,7 +518,7 @@ pub fn write_mir_intro<'tcx>(
}
}
- write_scope_tree(tcx, body, &scope_tree, w, OUTERMOST_SOURCE_SCOPE, 1)?;
+ write_scope_tree(tcx, body, &scope_tree, w, OUTERMOST_SOURCE_SCOPE, 1, options)?;
// Add an empty line before the first block is printed.
writeln!(w)?;
@@ -651,12 +701,13 @@ pub fn dump_mir_def_ids(tcx: TyCtxt<'_>, single: Option) -> Vec {
// Basic blocks and their parts (statements, terminators, ...)
/// Write out a human-readable textual representation for the given basic block.
-pub fn write_basic_block<'tcx, F>(
+fn write_basic_block<'tcx, F>(
tcx: TyCtxt<'tcx>,
block: BasicBlock,
body: &Body<'tcx>,
extra_data: &mut F,
w: &mut dyn io::Write,
+ options: PrettyPrintMirOptions,
) -> io::Result<()>
where
F: FnMut(PassWhere, &mut dyn io::Write) -> io::Result<()>,
@@ -672,7 +723,7 @@ where
for statement in &data.statements {
extra_data(PassWhere::BeforeLocation(current_location), w)?;
let indented_body = format!("{INDENT}{INDENT}{statement:?};");
- if tcx.sess.opts.unstable_opts.mir_include_spans {
+ if options.include_extra_comments {
writeln!(
w,
"{:A$} // {}{}",
@@ -689,9 +740,14 @@ where
writeln!(w, "{indented_body}")?;
}
- write_extra(tcx, w, |visitor| {
- visitor.visit_statement(statement, current_location);
- })?;
+ write_extra(
+ tcx,
+ w,
+ |visitor| {
+ visitor.visit_statement(statement, current_location);
+ },
+ options,
+ )?;
extra_data(PassWhere::AfterLocation(current_location), w)?;
@@ -701,7 +757,7 @@ where
// Terminator at the bottom.
extra_data(PassWhere::BeforeLocation(current_location), w)?;
let indented_terminator = format!("{0}{0}{1:?};", INDENT, data.terminator().kind);
- if tcx.sess.opts.unstable_opts.mir_include_spans {
+ if options.include_extra_comments {
writeln!(
w,
"{:A$} // {}{}",
@@ -718,9 +774,14 @@ where
writeln!(w, "{indented_terminator}")?;
}
- write_extra(tcx, w, |visitor| {
- visitor.visit_terminator(data.terminator(), current_location);
- })?;
+ write_extra(
+ tcx,
+ w,
+ |visitor| {
+ visitor.visit_terminator(data.terminator(), current_location);
+ },
+ options,
+ )?;
extra_data(PassWhere::AfterLocation(current_location), w)?;
extra_data(PassWhere::AfterTerminator(block), w)?;
@@ -1271,11 +1332,12 @@ fn write_extra<'tcx, F>(
tcx: TyCtxt<'tcx>,
write: &mut dyn io::Write,
mut visit_op: F,
+ options: PrettyPrintMirOptions,
) -> io::Result<()>
where
F: FnMut(&mut ExtraComments<'tcx>),
{
- if tcx.sess.opts.unstable_opts.mir_include_spans {
+ if options.include_extra_comments {
let mut extra_comments = ExtraComments { tcx, comments: vec![] };
visit_op(&mut extra_comments);
for comment in extra_comments.comments {
@@ -1890,7 +1952,7 @@ pub(crate) fn pretty_print_const_value<'tcx>(
///////////////////////////////////////////////////////////////////////////
// Miscellaneous
-/// Calc converted u64 decimal into hex and return it's length in chars
+/// Calc converted u64 decimal into hex and return its length in chars.
///
/// ```ignore (cannot-test-private-function)
/// assert_eq!(1, hex_number_length(0));
diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs
index 6434bd0d7bfe..b6443778c936 100644
--- a/compiler/rustc_middle/src/query/mod.rs
+++ b/compiler/rustc_middle/src/query/mod.rs
@@ -651,7 +651,7 @@ rustc_queries! {
/// is a subset of the full list of predicates. We store these in a separate map
/// because we must evaluate them even during type conversion, often before the full
/// predicates are available (note that super-predicates must not be cyclic).
- query explicit_super_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
+ query explicit_super_predicates_of(key: DefId) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
desc { |tcx| "computing the super predicates of `{}`", tcx.def_path_str(key) }
cache_on_disk_if { key.is_local() }
separate_provide_extern
@@ -662,7 +662,7 @@ rustc_queries! {
/// of the trait. For regular traits, this includes all super-predicates and their
/// associated type bounds. For trait aliases, currently, this includes all of the
/// predicates of the trait alias.
- query explicit_implied_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
+ query explicit_implied_predicates_of(key: DefId) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
desc { |tcx| "computing the implied predicates of `{}`", tcx.def_path_str(key) }
cache_on_disk_if { key.is_local() }
separate_provide_extern
@@ -671,7 +671,9 @@ rustc_queries! {
/// The Ident is the name of an associated type.The query returns only the subset
/// of supertraits that define the given associated type. This is used to avoid
/// cycles in resolving type-dependent associated item paths like `T::Item`.
- query explicit_supertraits_containing_assoc_item(key: (DefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
+ query explicit_supertraits_containing_assoc_item(
+ key: (DefId, rustc_span::symbol::Ident)
+ ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
desc { |tcx| "computing the super traits of `{}` with associated type name `{}`",
tcx.def_path_str(key.0),
key.1
@@ -680,7 +682,9 @@ rustc_queries! {
/// To avoid cycles within the predicates of a single item we compute
/// per-type-parameter predicates for resolving `T::AssocTy`.
- query type_param_predicates(key: (LocalDefId, LocalDefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
+ query type_param_predicates(
+ key: (LocalDefId, LocalDefId, rustc_span::symbol::Ident)
+ ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
desc { |tcx| "computing the bounds for type parameter `{}`", tcx.hir().ty_param_name(key.1) }
}
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index 70df205d8932..43dda252f835 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -349,16 +349,14 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
self,
def_id: DefId,
) -> ty::EarlyBinder<'tcx, impl IntoIterator, Span)>> {
- ty::EarlyBinder::bind(self.explicit_super_predicates_of(def_id).instantiate_identity(self))
+ self.explicit_super_predicates_of(def_id).map_bound(|preds| preds.into_iter().copied())
}
fn explicit_implied_predicates_of(
self,
def_id: DefId,
) -> ty::EarlyBinder<'tcx, impl IntoIterator, Span)>> {
- ty::EarlyBinder::bind(
- self.explicit_implied_predicates_of(def_id).instantiate_identity(self),
- )
+ self.explicit_implied_predicates_of(def_id).map_bound(|preds| preds.into_iter().copied())
}
fn has_target_features(self, def_id: DefId) -> bool {
@@ -3095,10 +3093,7 @@ impl<'tcx> TyCtxt<'tcx> {
Some(stability) if stability.is_const_unstable() => {
// has a `rustc_const_unstable` attribute, check whether the user enabled the
// corresponding feature gate.
- self.features()
- .declared_lib_features
- .iter()
- .any(|&(sym, _)| sym == stability.feature)
+ self.features().declared(stability.feature)
}
// functions without const stability are either stable user written
// const fn or the user is using feature gates and we thus don't
diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs
index d60bfb9faa1a..b144fd0feb00 100644
--- a/compiler/rustc_middle/src/ty/sty.rs
+++ b/compiler/rustc_middle/src/ty/sty.rs
@@ -1000,7 +1000,7 @@ impl<'tcx> Ty<'tcx> {
#[inline]
pub fn is_primitive(self) -> bool {
- self.kind().is_primitive()
+ matches!(self.kind(), Bool | Char | Int(_) | Uint(_) | Float(_))
}
#[inline]
@@ -1149,7 +1149,10 @@ impl<'tcx> Ty<'tcx> {
}
}
- /// Tests whether this is a Box using the global allocator.
+ /// Tests whether this is a Box definitely using the global allocator.
+ ///
+ /// If the allocator is still generic, the answer is `false`, but it may
+ /// later turn out that it does use the global allocator.
#[inline]
pub fn is_box_global(self, tcx: TyCtxt<'tcx>) -> bool {
match self.kind() {
diff --git a/compiler/rustc_mir_transform/src/add_call_guards.rs b/compiler/rustc_mir_transform/src/add_call_guards.rs
index a47c8d94bba2..df5312d155c1 100644
--- a/compiler/rustc_mir_transform/src/add_call_guards.rs
+++ b/compiler/rustc_mir_transform/src/add_call_guards.rs
@@ -1,6 +1,7 @@
use rustc_index::{Idx, IndexVec};
use rustc_middle::mir::*;
use rustc_middle::ty::TyCtxt;
+use tracing::debug;
#[derive(PartialEq)]
pub enum AddCallGuards {
diff --git a/compiler/rustc_mir_transform/src/add_moves_for_packed_drops.rs b/compiler/rustc_mir_transform/src/add_moves_for_packed_drops.rs
index cd850e2d7318..61a1d8cc9024 100644
--- a/compiler/rustc_mir_transform/src/add_moves_for_packed_drops.rs
+++ b/compiler/rustc_mir_transform/src/add_moves_for_packed_drops.rs
@@ -1,6 +1,7 @@
use rustc_middle::mir::patch::MirPatch;
use rustc_middle::mir::*;
use rustc_middle::ty::TyCtxt;
+use tracing::debug;
use crate::util;
diff --git a/compiler/rustc_mir_transform/src/add_retag.rs b/compiler/rustc_mir_transform/src/add_retag.rs
index 12a68790374e..79bc21cab147 100644
--- a/compiler/rustc_mir_transform/src/add_retag.rs
+++ b/compiler/rustc_mir_transform/src/add_retag.rs
@@ -137,6 +137,8 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
// Using `is_box_global` here is a bit sketchy: if this code is
// generic over the allocator, we'll not add a retag! This is a hack
// to make Stacked Borrows compatible with custom allocator code.
+ // It means the raw pointer inherits the tag of the box, which mostly works
+ // but can sometimes lead to unexpected aliasing errors.
// Long-term, we'll want to move to an aliasing model where "cast to
// raw pointer" is a complete NOP, and then this will no longer be
// an issue.
diff --git a/compiler/rustc_mir_transform/src/check_alignment.rs b/compiler/rustc_mir_transform/src/check_alignment.rs
index 5dfdcfc8b944..ad362f22ce19 100644
--- a/compiler/rustc_mir_transform/src/check_alignment.rs
+++ b/compiler/rustc_mir_transform/src/check_alignment.rs
@@ -5,6 +5,7 @@ use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceC
use rustc_middle::mir::*;
use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt};
use rustc_session::Session;
+use tracing::{debug, trace};
pub struct CheckAlignment;
diff --git a/compiler/rustc_mir_transform/src/copy_prop.rs b/compiler/rustc_mir_transform/src/copy_prop.rs
index c1f9313a377d..5c267f853783 100644
--- a/compiler/rustc_mir_transform/src/copy_prop.rs
+++ b/compiler/rustc_mir_transform/src/copy_prop.rs
@@ -3,6 +3,7 @@ use rustc_index::IndexSlice;
use rustc_middle::mir::visit::*;
use rustc_middle::mir::*;
use rustc_middle::ty::TyCtxt;
+use tracing::{debug, instrument};
use crate::ssa::SsaLocals;
diff --git a/compiler/rustc_mir_transform/src/coroutine.rs b/compiler/rustc_mir_transform/src/coroutine.rs
index d9d2abc554a6..8051fca9e7c9 100644
--- a/compiler/rustc_mir_transform/src/coroutine.rs
+++ b/compiler/rustc_mir_transform/src/coroutine.rs
@@ -78,6 +78,7 @@ use rustc_target::spec::PanicStrategy;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::TyCtxtInferExt as _;
use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode, ObligationCtxt};
+use tracing::{debug, instrument, trace};
use crate::deref_separator::deref_finder;
use crate::{abort_unwinding_calls, errors, pass_manager as pm, simplify};
diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs
index a8b0f4a8d6df..ea1c0d2df451 100644
--- a/compiler/rustc_mir_transform/src/coverage/counters.rs
+++ b/compiler/rustc_mir_transform/src/coverage/counters.rs
@@ -6,6 +6,7 @@ use rustc_data_structures::graph::DirectedGraph;
use rustc_index::IndexVec;
use rustc_middle::bug;
use rustc_middle::mir::coverage::{CounterId, CovTerm, Expression, ExpressionId, Op};
+use tracing::{debug, debug_span, instrument};
use crate::coverage::graph::{BasicCoverageBlock, CoverageGraph, TraverseCoverageGraphWithLoops};
diff --git a/compiler/rustc_mir_transform/src/coverage/graph.rs b/compiler/rustc_mir_transform/src/coverage/graph.rs
index 31b207751942..0d874a6c8bab 100644
--- a/compiler/rustc_mir_transform/src/coverage/graph.rs
+++ b/compiler/rustc_mir_transform/src/coverage/graph.rs
@@ -10,6 +10,7 @@ use rustc_index::bit_set::BitSet;
use rustc_index::IndexVec;
use rustc_middle::bug;
use rustc_middle::mir::{self, BasicBlock, Terminator, TerminatorKind};
+use tracing::debug;
/// A coverage-specific simplification of the MIR control flow graph (CFG). The `CoverageGraph`s
/// nodes are `BasicCoverageBlock`s, which encompass one or more MIR `BasicBlock`s.
diff --git a/compiler/rustc_mir_transform/src/coverage/mod.rs b/compiler/rustc_mir_transform/src/coverage/mod.rs
index af0f1e38a754..bba354d29363 100644
--- a/compiler/rustc_mir_transform/src/coverage/mod.rs
+++ b/compiler/rustc_mir_transform/src/coverage/mod.rs
@@ -23,6 +23,7 @@ use rustc_middle::ty::TyCtxt;
use rustc_span::def_id::LocalDefId;
use rustc_span::source_map::SourceMap;
use rustc_span::{BytePos, Pos, RelativeBytePos, Span, Symbol};
+use tracing::{debug, debug_span, instrument, trace};
use crate::coverage::counters::{CounterIncrementSite, CoverageCounters};
use crate::coverage::graph::CoverageGraph;
diff --git a/compiler/rustc_mir_transform/src/coverage/query.rs b/compiler/rustc_mir_transform/src/coverage/query.rs
index 1fce2abbbbf7..e65a5fdd5e7f 100644
--- a/compiler/rustc_mir_transform/src/coverage/query.rs
+++ b/compiler/rustc_mir_transform/src/coverage/query.rs
@@ -7,6 +7,7 @@ use rustc_middle::ty::{self, TyCtxt};
use rustc_middle::util::Providers;
use rustc_span::def_id::LocalDefId;
use rustc_span::sym;
+use tracing::trace;
/// Registers query/hook implementations related to coverage.
pub(crate) fn provide(providers: &mut Providers) {
diff --git a/compiler/rustc_mir_transform/src/coverage/spans.rs b/compiler/rustc_mir_transform/src/coverage/spans.rs
index 092ec1e06d24..fcc774503f45 100644
--- a/compiler/rustc_mir_transform/src/coverage/spans.rs
+++ b/compiler/rustc_mir_transform/src/coverage/spans.rs
@@ -4,6 +4,7 @@ use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxHashSet;
use rustc_middle::mir;
use rustc_span::Span;
+use tracing::{debug, debug_span, instrument};
use crate::coverage::graph::{BasicCoverageBlock, CoverageGraph};
use crate::coverage::spans::from_mir::{
diff --git a/compiler/rustc_mir_transform/src/ctfe_limit.rs b/compiler/rustc_mir_transform/src/ctfe_limit.rs
index ff9fc776e541..bf522fd5ef4e 100644
--- a/compiler/rustc_mir_transform/src/ctfe_limit.rs
+++ b/compiler/rustc_mir_transform/src/ctfe_limit.rs
@@ -6,6 +6,7 @@ use rustc_middle::mir::{
BasicBlock, BasicBlockData, Body, Statement, StatementKind, TerminatorKind,
};
use rustc_middle::ty::TyCtxt;
+use tracing::instrument;
use crate::MirPass;
diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs
index f207216d6f42..b16d25c93bb9 100644
--- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs
+++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs
@@ -19,6 +19,7 @@ use rustc_mir_dataflow::value_analysis::{
use rustc_mir_dataflow::{Analysis, Results, ResultsVisitor};
use rustc_span::DUMMY_SP;
use rustc_target::abi::{Abi, FieldIdx, Size, VariantIdx, FIRST_VARIANT};
+use tracing::{debug, debug_span, instrument};
// These constants are somewhat random guesses and have not been optimized.
// If `tcx.sess.mir_opt_level() >= 4`, we ignore the limits (this can become very expensive).
@@ -382,7 +383,7 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> {
place: PlaceIndex,
mut operand: OpTy<'tcx>,
projection: &[PlaceElem<'tcx>],
- ) -> Option {
+ ) {
for &(mut proj_elem) in projection {
if let PlaceElem::Index(index) = proj_elem {
if let FlatSet::Elem(index) = state.get(index.into(), &self.map)
@@ -391,10 +392,14 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> {
{
proj_elem = PlaceElem::ConstantIndex { offset, min_length, from_end: false };
} else {
- return None;
+ return;
}
}
- operand = self.ecx.project(&operand, proj_elem).ok()?;
+ operand = if let Ok(operand) = self.ecx.project(&operand, proj_elem) {
+ operand
+ } else {
+ return;
+ }
}
self.map.for_each_projection_value(
@@ -426,8 +431,6 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> {
}
},
);
-
- None
}
fn binary_op(
diff --git a/compiler/rustc_mir_transform/src/deduplicate_blocks.rs b/compiler/rustc_mir_transform/src/deduplicate_blocks.rs
index 4a94c3eca865..b38f4a4a823b 100644
--- a/compiler/rustc_mir_transform/src/deduplicate_blocks.rs
+++ b/compiler/rustc_mir_transform/src/deduplicate_blocks.rs
@@ -9,6 +9,7 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_middle::mir::visit::MutVisitor;
use rustc_middle::mir::*;
use rustc_middle::ty::TyCtxt;
+use tracing::debug;
use super::simplify::simplify_cfg;
diff --git a/compiler/rustc_mir_transform/src/dest_prop.rs b/compiler/rustc_mir_transform/src/dest_prop.rs
index ed924761892c..a530dccf96b2 100644
--- a/compiler/rustc_mir_transform/src/dest_prop.rs
+++ b/compiler/rustc_mir_transform/src/dest_prop.rs
@@ -144,6 +144,7 @@ use rustc_middle::ty::TyCtxt;
use rustc_mir_dataflow::impls::MaybeLiveLocals;
use rustc_mir_dataflow::points::{save_as_intervals, DenseLocationMap, PointIndex};
use rustc_mir_dataflow::Analysis;
+use tracing::{debug, trace};
use crate::MirPass;
diff --git a/compiler/rustc_mir_transform/src/early_otherwise_branch.rs b/compiler/rustc_mir_transform/src/early_otherwise_branch.rs
index 49e41c35f1f2..67b81efd6147 100644
--- a/compiler/rustc_mir_transform/src/early_otherwise_branch.rs
+++ b/compiler/rustc_mir_transform/src/early_otherwise_branch.rs
@@ -3,6 +3,7 @@ use std::fmt::Debug;
use rustc_middle::mir::patch::MirPatch;
use rustc_middle::mir::*;
use rustc_middle::ty::{Ty, TyCtxt};
+use tracing::trace;
use super::simplify::simplify_cfg;
diff --git a/compiler/rustc_mir_transform/src/elaborate_drops.rs b/compiler/rustc_mir_transform/src/elaborate_drops.rs
index 5a22ef779034..d0809d9388de 100644
--- a/compiler/rustc_mir_transform/src/elaborate_drops.rs
+++ b/compiler/rustc_mir_transform/src/elaborate_drops.rs
@@ -15,6 +15,7 @@ use rustc_mir_dataflow::{
};
use rustc_span::Span;
use rustc_target::abi::{FieldIdx, VariantIdx};
+use tracing::{debug, instrument};
use crate::deref_separator::deref_finder;
diff --git a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs
index 9a2cc057232f..81875e3d0124 100644
--- a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs
+++ b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs
@@ -6,6 +6,7 @@ use rustc_middle::{bug, span_bug};
use rustc_session::lint::builtin::FFI_UNWIND_CALLS;
use rustc_target::spec::abi::Abi;
use rustc_target::spec::PanicStrategy;
+use tracing::debug;
use crate::errors;
diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs
index 90e3ba26a438..fb9baeeb3ed8 100644
--- a/compiler/rustc_mir_transform/src/gvn.rs
+++ b/compiler/rustc_mir_transform/src/gvn.rs
@@ -105,6 +105,7 @@ use rustc_span::def_id::DefId;
use rustc_span::DUMMY_SP;
use rustc_target::abi::{self, Abi, FieldIdx, Size, VariantIdx, FIRST_VARIANT};
use smallvec::SmallVec;
+use tracing::{debug, instrument, trace};
use crate::ssa::{AssignedValue, SsaLocals};
diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs
index 2d6950be55d8..4482801826ab 100644
--- a/compiler/rustc_mir_transform/src/inline.rs
+++ b/compiler/rustc_mir_transform/src/inline.rs
@@ -20,6 +20,7 @@ use rustc_span::source_map::Spanned;
use rustc_span::sym;
use rustc_target::abi::FieldIdx;
use rustc_target::spec::abi::Abi;
+use tracing::{debug, instrument, trace, trace_span};
use crate::cost_checker::CostChecker;
use crate::deref_separator::deref_finder;
diff --git a/compiler/rustc_mir_transform/src/inline/cycle.rs b/compiler/rustc_mir_transform/src/inline/cycle.rs
index c65cc993b19f..9828e90de883 100644
--- a/compiler/rustc_mir_transform/src/inline/cycle.rs
+++ b/compiler/rustc_mir_transform/src/inline/cycle.rs
@@ -5,6 +5,7 @@ use rustc_middle::mir::TerminatorKind;
use rustc_middle::ty::{self, GenericArgsRef, InstanceKind, TyCtxt, TypeVisitableExt};
use rustc_session::Limit;
use rustc_span::sym;
+use tracing::{instrument, trace};
// FIXME: check whether it is cheaper to precompute the entire call graph instead of invoking
// this query ridiculously often.
diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs
index 96c52845a4a3..435b6a011634 100644
--- a/compiler/rustc_mir_transform/src/jump_threading.rs
+++ b/compiler/rustc_mir_transform/src/jump_threading.rs
@@ -51,6 +51,7 @@ use rustc_mir_dataflow::lattice::HasBottom;
use rustc_mir_dataflow::value_analysis::{Map, PlaceIndex, State, TrackElem};
use rustc_span::DUMMY_SP;
use rustc_target::abi::{TagEncoding, Variants};
+use tracing::{debug, instrument, trace};
use crate::cost_checker::CostChecker;
@@ -191,26 +192,26 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
/// Recursion entry point to find threading opportunities.
#[instrument(level = "trace", skip(self))]
- fn start_from_switch(&mut self, bb: BasicBlock) -> Option {
+ fn start_from_switch(&mut self, bb: BasicBlock) {
let bbdata = &self.body[bb];
if bbdata.is_cleanup || self.loop_headers.contains(bb) {
- return None;
+ return;
}
- let (discr, targets) = bbdata.terminator().kind.as_switch()?;
- let discr = discr.place()?;
+ let Some((discr, targets)) = bbdata.terminator().kind.as_switch() else { return };
+ let Some(discr) = discr.place() else { return };
debug!(?discr, ?bb);
let discr_ty = discr.ty(self.body, self.tcx).ty;
- let discr_layout = self.ecx.layout_of(discr_ty).ok()?;
+ let Ok(discr_layout) = self.ecx.layout_of(discr_ty) else { return };
- let discr = self.map.find(discr.as_ref())?;
+ let Some(discr) = self.map.find(discr.as_ref()) else { return };
debug!(?discr);
let cost = CostChecker::new(self.tcx, self.param_env, None, self.body);
let mut state = State::new_reachable();
let conds = if let Some((value, then, else_)) = targets.as_static_if() {
- let value = ScalarInt::try_from_uint(value, discr_layout.size)?;
+ let Some(value) = ScalarInt::try_from_uint(value, discr_layout.size) else { return };
self.arena.alloc_from_iter([
Condition { value, polarity: Polarity::Eq, target: then },
Condition { value, polarity: Polarity::Ne, target: else_ },
@@ -225,7 +226,6 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
state.insert_value_idx(discr, conds, self.map);
self.find_opportunity(bb, state, cost, 0);
- None
}
/// Recursively walk statements backwards from this bb's terminator to find threading
@@ -364,18 +364,17 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
lhs: PlaceIndex,
rhs: ImmTy<'tcx>,
state: &mut State>,
- ) -> Option {
+ ) {
let register_opportunity = |c: Condition| {
debug!(?bb, ?c.target, "register");
self.opportunities.push(ThreadingOpportunity { chain: vec![bb], target: c.target })
};
- let conditions = state.try_get_idx(lhs, self.map)?;
- if let Immediate::Scalar(Scalar::Int(int)) = *rhs {
+ if let Some(conditions) = state.try_get_idx(lhs, self.map)
+ && let Immediate::Scalar(Scalar::Int(int)) = *rhs
+ {
conditions.iter_matches(int).for_each(register_opportunity);
}
-
- None
}
/// If we expect `lhs ?= A`, we have an opportunity if we assume `constant == A`.
@@ -428,22 +427,23 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
lhs: PlaceIndex,
rhs: &Operand<'tcx>,
state: &mut State>,
- ) -> Option {
+ ) {
match rhs {
// If we expect `lhs ?= A`, we have an opportunity if we assume `constant == A`.
Operand::Constant(constant) => {
- let constant =
- self.ecx.eval_mir_constant(&constant.const_, constant.span, None).ok()?;
+ let Ok(constant) =
+ self.ecx.eval_mir_constant(&constant.const_, constant.span, None)
+ else {
+ return;
+ };
self.process_constant(bb, lhs, constant, state);
}
// Transfer the conditions on the copied rhs.
Operand::Move(rhs) | Operand::Copy(rhs) => {
- let rhs = self.map.find(rhs.as_ref())?;
+ let Some(rhs) = self.map.find(rhs.as_ref()) else { return };
state.insert_place_idx(rhs, lhs, self.map);
}
}
-
- None
}
#[instrument(level = "trace", skip(self))]
@@ -453,16 +453,14 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
lhs_place: &Place<'tcx>,
rhs: &Rvalue<'tcx>,
state: &mut State>,
- ) -> Option {
- let lhs = self.map.find(lhs_place.as_ref())?;
+ ) {
+ let Some(lhs) = self.map.find(lhs_place.as_ref()) else { return };
match rhs {
- Rvalue::Use(operand) => self.process_operand(bb, lhs, operand, state)?,
+ Rvalue::Use(operand) => self.process_operand(bb, lhs, operand, state),
// Transfer the conditions on the copy rhs.
- Rvalue::CopyForDeref(rhs) => {
- self.process_operand(bb, lhs, &Operand::Copy(*rhs), state)?
- }
+ Rvalue::CopyForDeref(rhs) => self.process_operand(bb, lhs, &Operand::Copy(*rhs), state),
Rvalue::Discriminant(rhs) => {
- let rhs = self.map.find_discr(rhs.as_ref())?;
+ let Some(rhs) = self.map.find_discr(rhs.as_ref()) else { return };
state.insert_place_idx(rhs, lhs, self.map);
}
// If we expect `lhs ?= A`, we have an opportunity if we assume `constant == A`.
@@ -470,7 +468,7 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
let agg_ty = lhs_place.ty(self.body, self.tcx).ty;
let lhs = match kind {
// Do not support unions.
- AggregateKind::Adt(.., Some(_)) => return None,
+ AggregateKind::Adt(.., Some(_)) => return,
AggregateKind::Adt(_, variant_index, ..) if agg_ty.is_enum() => {
if let Some(discr_target) = self.map.apply(lhs, TrackElem::Discriminant)
&& let Ok(discr_value) =
@@ -478,7 +476,11 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
{
self.process_immediate(bb, discr_target, discr_value, state);
}
- self.map.apply(lhs, TrackElem::Variant(*variant_index))?
+ if let Some(idx) = self.map.apply(lhs, TrackElem::Variant(*variant_index)) {
+ idx
+ } else {
+ return;
+ }
}
_ => lhs,
};
@@ -490,8 +492,8 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
}
// Transfer the conditions on the copy rhs, after inversing polarity.
Rvalue::UnaryOp(UnOp::Not, Operand::Move(place) | Operand::Copy(place)) => {
- let conditions = state.try_get_idx(lhs, self.map)?;
- let place = self.map.find(place.as_ref())?;
+ let Some(conditions) = state.try_get_idx(lhs, self.map) else { return };
+ let Some(place) = self.map.find(place.as_ref()) else { return };
let conds = conditions.map(self.arena, Condition::inv);
state.insert_value_idx(place, conds, self.map);
}
@@ -502,21 +504,25 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
box (Operand::Move(place) | Operand::Copy(place), Operand::Constant(value))
| box (Operand::Constant(value), Operand::Move(place) | Operand::Copy(place)),
) => {
- let conditions = state.try_get_idx(lhs, self.map)?;
- let place = self.map.find(place.as_ref())?;
+ let Some(conditions) = state.try_get_idx(lhs, self.map) else { return };
+ let Some(place) = self.map.find(place.as_ref()) else { return };
let equals = match op {
BinOp::Eq => ScalarInt::TRUE,
BinOp::Ne => ScalarInt::FALSE,
- _ => return None,
+ _ => return,
};
if value.const_.ty().is_floating_point() {
// Floating point equality does not follow bit-patterns.
// -0.0 and NaN both have special rules for equality,
// and therefore we cannot use integer comparisons for them.
// Avoid handling them, though this could be extended in the future.
- return None;
+ return;
}
- let value = value.const_.normalize(self.tcx, self.param_env).try_to_scalar_int()?;
+ let Some(value) =
+ value.const_.normalize(self.tcx, self.param_env).try_to_scalar_int()
+ else {
+ return;
+ };
let conds = conditions.map(self.arena, |c| Condition {
value,
polarity: if c.matches(equals) { Polarity::Eq } else { Polarity::Ne },
@@ -527,8 +533,6 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
_ => {}
}
-
- None
}
#[instrument(level = "trace", skip(self))]
@@ -537,7 +541,7 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
bb: BasicBlock,
stmt: &Statement<'tcx>,
state: &mut State>,
- ) -> Option {
+ ) {
let register_opportunity = |c: Condition| {
debug!(?bb, ?c.target, "register");
self.opportunities.push(ThreadingOpportunity { chain: vec![bb], target: c.target })
@@ -550,12 +554,12 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
// If we expect `discriminant(place) ?= A`,
// we have an opportunity if `variant_index ?= A`.
StatementKind::SetDiscriminant { box place, variant_index } => {
- let discr_target = self.map.find_discr(place.as_ref())?;
+ let Some(discr_target) = self.map.find_discr(place.as_ref()) else { return };
let enum_ty = place.ty(self.body, self.tcx).ty;
// `SetDiscriminant` may be a no-op if the assigned variant is the untagged variant
// of a niche encoding. If we cannot ensure that we write to the discriminant, do
// nothing.
- let enum_layout = self.ecx.layout_of(enum_ty).ok()?;
+ let Ok(enum_layout) = self.ecx.layout_of(enum_ty) else { return };
let writes_discriminant = match enum_layout.variants {
Variants::Single { index } => {
assert_eq!(index, *variant_index);
@@ -568,24 +572,25 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
} => *variant_index != untagged_variant,
};
if writes_discriminant {
- let discr = self.ecx.discriminant_for_variant(enum_ty, *variant_index).ok()?;
- self.process_immediate(bb, discr_target, discr, state)?;
+ let Ok(discr) = self.ecx.discriminant_for_variant(enum_ty, *variant_index)
+ else {
+ return;
+ };
+ self.process_immediate(bb, discr_target, discr, state);
}
}
// If we expect `lhs ?= true`, we have an opportunity if we assume `lhs == true`.
StatementKind::Intrinsic(box NonDivergingIntrinsic::Assume(
Operand::Copy(place) | Operand::Move(place),
)) => {
- let conditions = state.try_get(place.as_ref(), self.map)?;
+ let Some(conditions) = state.try_get(place.as_ref(), self.map) else { return };
conditions.iter_matches(ScalarInt::TRUE).for_each(register_opportunity);
}
StatementKind::Assign(box (lhs_place, rhs)) => {
- self.process_assign(bb, lhs_place, rhs, state)?;
+ self.process_assign(bb, lhs_place, rhs, state);
}
_ => {}
}
-
- None
}
#[instrument(level = "trace", skip(self, state, cost))]
@@ -638,17 +643,17 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
targets: &SwitchTargets,
target_bb: BasicBlock,
state: &mut State>,
- ) -> Option {
+ ) {
debug_assert_ne!(target_bb, START_BLOCK);
debug_assert_eq!(self.body.basic_blocks.predecessors()[target_bb].len(), 1);
- let discr = discr.place()?;
+ let Some(discr) = discr.place() else { return };
let discr_ty = discr.ty(self.body, self.tcx).ty;
- let discr_layout = self.ecx.layout_of(discr_ty).ok()?;
- let conditions = state.try_get(discr.as_ref(), self.map)?;
+ let Ok(discr_layout) = self.ecx.layout_of(discr_ty) else { return };
+ let Some(conditions) = state.try_get(discr.as_ref(), self.map) else { return };
if let Some((value, _)) = targets.iter().find(|&(_, target)| target == target_bb) {
- let value = ScalarInt::try_from_uint(value, discr_layout.size)?;
+ let Some(value) = ScalarInt::try_from_uint(value, discr_layout.size) else { return };
debug_assert_eq!(targets.iter().filter(|&(_, target)| target == target_bb).count(), 1);
// We are inside `target_bb`. Since we have a single predecessor, we know we passed
@@ -662,7 +667,7 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
} else if let Some((value, _, else_bb)) = targets.as_static_if()
&& target_bb == else_bb
{
- let value = ScalarInt::try_from_uint(value, discr_layout.size)?;
+ let Some(value) = ScalarInt::try_from_uint(value, discr_layout.size) else { return };
// We only know that `discr != value`. That's much weaker information than
// the equality we had in the previous arm. All we can conclude is that
@@ -675,8 +680,6 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
}
}
}
-
- None
}
}
diff --git a/compiler/rustc_mir_transform/src/known_panics_lint.rs b/compiler/rustc_mir_transform/src/known_panics_lint.rs
index 7eed47cf2398..443d97d004e1 100644
--- a/compiler/rustc_mir_transform/src/known_panics_lint.rs
+++ b/compiler/rustc_mir_transform/src/known_panics_lint.rs
@@ -22,6 +22,7 @@ use rustc_middle::ty::layout::{LayoutError, LayoutOf, LayoutOfHelpers, TyAndLayo
use rustc_middle::ty::{self, ConstInt, ParamEnv, ScalarInt, Ty, TyCtxt, TypeVisitableExt};
use rustc_span::Span;
use rustc_target::abi::{Abi, FieldIdx, HasDataLayout, Size, TargetDataLayout, VariantIdx};
+use tracing::{debug, instrument, trace};
use crate::errors::{AssertLint, AssertLintKind};
use crate::MirLint;
@@ -469,12 +470,12 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
msg: &AssertKind>,
cond: &Operand<'tcx>,
location: Location,
- ) -> Option {
- let value = &self.eval_operand(cond)?;
+ ) {
+ let Some(value) = &self.eval_operand(cond) else { return };
trace!("assertion on {:?} should be {:?}", value, expected);
let expected = Scalar::from_bool(expected);
- let value_const = self.use_ecx(|this| this.ecx.read_scalar(value))?;
+ let Some(value_const) = self.use_ecx(|this| this.ecx.read_scalar(value)) else { return };
if expected != value_const {
// Poison all places this operand references so that further code
@@ -516,14 +517,12 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
AssertKind::BoundsCheck { len, index }
}
// Remaining overflow errors are already covered by checks on the binary operators.
- AssertKind::Overflow(..) | AssertKind::OverflowNeg(_) => return None,
+ AssertKind::Overflow(..) | AssertKind::OverflowNeg(_) => return,
// Need proper const propagator for these.
- _ => return None,
+ _ => return,
};
self.report_assert_as_lint(location, AssertLintKind::UnconditionalPanic, msg);
}
-
- None
}
fn ensure_not_propagated(&self, local: Local) {
diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs
index 88094b44edf2..7a531977267e 100644
--- a/compiler/rustc_mir_transform/src/lib.rs
+++ b/compiler/rustc_mir_transform/src/lib.rs
@@ -15,9 +15,6 @@
#![feature(yeet_expr)]
// tidy-alphabetical-end
-#[macro_use]
-extern crate tracing;
-
use hir::ConstContext;
use required_consts::RequiredConstsVisitor;
use rustc_const_eval::util;
@@ -39,6 +36,7 @@ use rustc_middle::{bug, query, span_bug};
use rustc_span::source_map::Spanned;
use rustc_span::{sym, DUMMY_SP};
use rustc_trait_selection::traits;
+use tracing::{debug, trace};
#[macro_use]
mod pass_manager;
diff --git a/compiler/rustc_mir_transform/src/nrvo.rs b/compiler/rustc_mir_transform/src/nrvo.rs
index 885dbd5f3393..dd1875f2a78a 100644
--- a/compiler/rustc_mir_transform/src/nrvo.rs
+++ b/compiler/rustc_mir_transform/src/nrvo.rs
@@ -6,6 +6,7 @@ use rustc_middle::bug;
use rustc_middle::mir::visit::{MutVisitor, NonUseContext, PlaceContext, Visitor};
use rustc_middle::mir::{self, BasicBlock, Local, Location};
use rustc_middle::ty::TyCtxt;
+use tracing::{debug, trace};
use crate::MirPass;
diff --git a/compiler/rustc_mir_transform/src/pass_manager.rs b/compiler/rustc_mir_transform/src/pass_manager.rs
index d092477e340a..51e276004047 100644
--- a/compiler/rustc_mir_transform/src/pass_manager.rs
+++ b/compiler/rustc_mir_transform/src/pass_manager.rs
@@ -1,6 +1,7 @@
use rustc_middle::mir::{self, Body, MirPhase, RuntimePhase};
use rustc_middle::ty::TyCtxt;
use rustc_session::Session;
+use tracing::trace;
use crate::lint::lint_body;
use crate::{validate, MirPass};
diff --git a/compiler/rustc_mir_transform/src/promote_consts.rs b/compiler/rustc_mir_transform/src/promote_consts.rs
index 6e84914ef972..f2610fd52bc1 100644
--- a/compiler/rustc_mir_transform/src/promote_consts.rs
+++ b/compiler/rustc_mir_transform/src/promote_consts.rs
@@ -27,6 +27,7 @@ use rustc_middle::ty::{self, GenericArgs, List, Ty, TyCtxt, TypeVisitableExt};
use rustc_middle::{bug, mir, span_bug};
use rustc_span::source_map::Spanned;
use rustc_span::Span;
+use tracing::{debug, instrument};
/// A `MirPass` for promotion.
///
diff --git a/compiler/rustc_mir_transform/src/ref_prop.rs b/compiler/rustc_mir_transform/src/ref_prop.rs
index 973a191d786e..2b07c04a1213 100644
--- a/compiler/rustc_mir_transform/src/ref_prop.rs
+++ b/compiler/rustc_mir_transform/src/ref_prop.rs
@@ -10,6 +10,7 @@ use rustc_middle::ty::TyCtxt;
use rustc_mir_dataflow::impls::MaybeStorageDead;
use rustc_mir_dataflow::storage::always_storage_live_locals;
use rustc_mir_dataflow::Analysis;
+use tracing::{debug, instrument};
use crate::ssa::{SsaLocals, StorageLiveLocals};
diff --git a/compiler/rustc_mir_transform/src/remove_noop_landing_pads.rs b/compiler/rustc_mir_transform/src/remove_noop_landing_pads.rs
index 1df5737e8597..33c7d1695c02 100644
--- a/compiler/rustc_mir_transform/src/remove_noop_landing_pads.rs
+++ b/compiler/rustc_mir_transform/src/remove_noop_landing_pads.rs
@@ -3,6 +3,7 @@ use rustc_middle::mir::patch::MirPatch;
use rustc_middle::mir::*;
use rustc_middle::ty::TyCtxt;
use rustc_target::spec::PanicStrategy;
+use tracing::debug;
/// A pass that removes noop landing pads and replaces jumps to them with
/// `UnwindAction::Continue`. This is important because otherwise LLVM generates
diff --git a/compiler/rustc_mir_transform/src/remove_place_mention.rs b/compiler/rustc_mir_transform/src/remove_place_mention.rs
index 78335b3b5e06..6c0b50fafdb4 100644
--- a/compiler/rustc_mir_transform/src/remove_place_mention.rs
+++ b/compiler/rustc_mir_transform/src/remove_place_mention.rs
@@ -2,6 +2,7 @@
use rustc_middle::mir::*;
use rustc_middle::ty::TyCtxt;
+use tracing::trace;
pub struct RemovePlaceMention;
diff --git a/compiler/rustc_mir_transform/src/remove_storage_markers.rs b/compiler/rustc_mir_transform/src/remove_storage_markers.rs
index f68e592db154..af89395dddd2 100644
--- a/compiler/rustc_mir_transform/src/remove_storage_markers.rs
+++ b/compiler/rustc_mir_transform/src/remove_storage_markers.rs
@@ -2,6 +2,7 @@
use rustc_middle::mir::*;
use rustc_middle::ty::TyCtxt;
+use tracing::trace;
pub struct RemoveStorageMarkers;
diff --git a/compiler/rustc_mir_transform/src/remove_unneeded_drops.rs b/compiler/rustc_mir_transform/src/remove_unneeded_drops.rs
index 2778d91e17b9..9adcb5a38fd8 100644
--- a/compiler/rustc_mir_transform/src/remove_unneeded_drops.rs
+++ b/compiler/rustc_mir_transform/src/remove_unneeded_drops.rs
@@ -6,6 +6,7 @@
use rustc_middle::mir::*;
use rustc_middle::ty::TyCtxt;
+use tracing::{debug, trace};
use super::simplify::simplify_cfg;
diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs
index 86eada0183f8..8c70e4291185 100644
--- a/compiler/rustc_mir_transform/src/shim.rs
+++ b/compiler/rustc_mir_transform/src/shim.rs
@@ -17,6 +17,7 @@ use rustc_span::source_map::Spanned;
use rustc_span::{Span, DUMMY_SP};
use rustc_target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT};
use rustc_target::spec::abi::Abi;
+use tracing::{debug, instrument};
use crate::{
abort_unwinding_calls, add_call_guards, add_moves_for_packed_drops, deref_separator,
diff --git a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs
index 9c3f903e0eab..50810f23113f 100644
--- a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs
+++ b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs
@@ -19,6 +19,7 @@ use rustc_span::source_map::respan;
use rustc_span::{Span, Symbol};
use rustc_target::abi::{FieldIdx, VariantIdx};
use rustc_target::spec::PanicStrategy;
+use tracing::debug;
use super::{local_decls_for_sig, new_body};
diff --git a/compiler/rustc_mir_transform/src/simplify.rs b/compiler/rustc_mir_transform/src/simplify.rs
index 4fe8cf6213f8..d1c2c91e00fd 100644
--- a/compiler/rustc_mir_transform/src/simplify.rs
+++ b/compiler/rustc_mir_transform/src/simplify.rs
@@ -33,6 +33,7 @@ use rustc_middle::mir::*;
use rustc_middle::ty::TyCtxt;
use rustc_span::DUMMY_SP;
use smallvec::SmallVec;
+use tracing::{debug, trace};
pub enum SimplifyCfg {
Initial,
diff --git a/compiler/rustc_mir_transform/src/simplify_branches.rs b/compiler/rustc_mir_transform/src/simplify_branches.rs
index c746041ebd8a..7c8a686d0077 100644
--- a/compiler/rustc_mir_transform/src/simplify_branches.rs
+++ b/compiler/rustc_mir_transform/src/simplify_branches.rs
@@ -1,5 +1,6 @@
use rustc_middle::mir::*;
use rustc_middle::ty::TyCtxt;
+use tracing::trace;
pub enum SimplifyConstCondition {
AfterConstProp,
diff --git a/compiler/rustc_mir_transform/src/simplify_comparison_integral.rs b/compiler/rustc_mir_transform/src/simplify_comparison_integral.rs
index 59f67d8e73f4..ac892adebec1 100644
--- a/compiler/rustc_mir_transform/src/simplify_comparison_integral.rs
+++ b/compiler/rustc_mir_transform/src/simplify_comparison_integral.rs
@@ -7,6 +7,7 @@ use rustc_middle::mir::{
TerminatorKind,
};
use rustc_middle::ty::{Ty, TyCtxt};
+use tracing::trace;
use super::MirPass;
diff --git a/compiler/rustc_mir_transform/src/sroa.rs b/compiler/rustc_mir_transform/src/sroa.rs
index c2108795372f..906e2c23f3b8 100644
--- a/compiler/rustc_mir_transform/src/sroa.rs
+++ b/compiler/rustc_mir_transform/src/sroa.rs
@@ -9,6 +9,7 @@ use rustc_middle::mir::*;
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_mir_dataflow::value_analysis::{excluded_locals, iter_fields};
use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
+use tracing::{debug, instrument};
pub struct ScalarReplacementOfAggregates;
diff --git a/compiler/rustc_mir_transform/src/ssa.rs b/compiler/rustc_mir_transform/src/ssa.rs
index 76591f526250..c1254766f0a9 100644
--- a/compiler/rustc_mir_transform/src/ssa.rs
+++ b/compiler/rustc_mir_transform/src/ssa.rs
@@ -14,6 +14,7 @@ use rustc_middle::middle::resolve_bound_vars::Set1;
use rustc_middle::mir::visit::*;
use rustc_middle::mir::*;
use rustc_middle::ty::{ParamEnv, TyCtxt};
+use tracing::{debug, instrument, trace};
pub struct SsaLocals {
/// Assignments to each local. This defines whether the local is SSA.
diff --git a/compiler/rustc_mir_transform/src/unreachable_enum_branching.rs b/compiler/rustc_mir_transform/src/unreachable_enum_branching.rs
index 81baf58a5e0a..2427fbac5eef 100644
--- a/compiler/rustc_mir_transform/src/unreachable_enum_branching.rs
+++ b/compiler/rustc_mir_transform/src/unreachable_enum_branching.rs
@@ -10,6 +10,7 @@ use rustc_middle::mir::{
use rustc_middle::ty::layout::TyAndLayout;
use rustc_middle::ty::{Ty, TyCtxt};
use rustc_target::abi::{Abi, Variants};
+use tracing::trace;
use crate::MirPass;
diff --git a/compiler/rustc_parse/src/parser/nonterminal.rs b/compiler/rustc_parse/src/parser/nonterminal.rs
index 999f6f0eeb0c..e66d0df012bc 100644
--- a/compiler/rustc_parse/src/parser/nonterminal.rs
+++ b/compiler/rustc_parse/src/parser/nonterminal.rs
@@ -86,25 +86,7 @@ impl<'a> Parser<'a> {
token::Interpolated(nt) => may_be_ident(nt),
_ => false,
},
- NonterminalKind::Pat(pat_kind) => match &token.kind {
- // box, ref, mut, and other identifiers (can stricten)
- token::Ident(..) | token::NtIdent(..) |
- token::OpenDelim(Delimiter::Parenthesis) | // tuple pattern
- token::OpenDelim(Delimiter::Bracket) | // slice pattern
- token::BinOp(token::And) | // reference
- token::BinOp(token::Minus) | // negative literal
- token::AndAnd | // double reference
- token::Literal(_) | // literal
- token::DotDot | // range pattern (future compat)
- token::DotDotDot | // range pattern (future compat)
- token::PathSep | // path
- token::Lt | // path (UFCS constant)
- token::BinOp(token::Shl) => true, // path (double UFCS)
- // leading vert `|` or-pattern
- token::BinOp(token::Or) => matches!(pat_kind, PatWithOr),
- token::Interpolated(nt) => may_be_ident(nt),
- _ => false,
- },
+ NonterminalKind::Pat(pat_kind) => token.can_begin_pattern(pat_kind),
NonterminalKind::Lifetime => match &token.kind {
token::Lifetime(_) | token::NtLifetime(..) => true,
_ => false,
diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs
index cc68ae237ba1..8233f9a79435 100644
--- a/compiler/rustc_parse/src/parser/pat.rs
+++ b/compiler/rustc_parse/src/parser/pat.rs
@@ -444,7 +444,11 @@ impl<'a> Parser<'a> {
let mut lo = self.token.span;
- if self.token.is_keyword(kw::Let) && self.look_ahead(1, |tok| tok.can_begin_pattern()) {
+ if self.token.is_keyword(kw::Let)
+ && self.look_ahead(1, |tok| {
+ tok.can_begin_pattern(token::NtPatKind::PatParam { inferred: false })
+ })
+ {
self.bump();
self.dcx().emit_err(RemoveLet { span: lo });
lo = self.token.span;
diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs
index d8bf10e6021c..8ee40ecd77e3 100644
--- a/compiler/rustc_parse/src/parser/path.rs
+++ b/compiler/rustc_parse/src/parser/path.rs
@@ -378,7 +378,10 @@ impl<'a> Parser<'a> {
if self.may_recover()
&& prev_token_before_parsing == token::PathSep
&& (style == PathStyle::Expr && self.token.can_begin_expr()
- || style == PathStyle::Pat && self.token.can_begin_pattern())
+ || style == PathStyle::Pat
+ && self.token.can_begin_pattern(token::NtPatKind::PatParam {
+ inferred: false,
+ }))
{
snapshot = Some(self.create_snapshot_for_diagnostic());
}
diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs
index 4d58590ca3b0..ba4c300ea61a 100644
--- a/compiler/rustc_passes/src/stability.rs
+++ b/compiler/rustc_passes/src/stability.rs
@@ -544,9 +544,8 @@ impl<'tcx> MissingStabilityAnnotations<'tcx> {
let is_stable =
self.tcx.lookup_stability(def_id).is_some_and(|stability| stability.level.is_stable());
let missing_const_stability_attribute = self.tcx.lookup_const_stability(def_id).is_none();
- let is_reachable = self.effective_visibilities.is_reachable(def_id);
- if is_const && is_stable && missing_const_stability_attribute && is_reachable {
+ if is_const && is_stable && missing_const_stability_attribute {
let descr = self.tcx.def_descr(def_id.to_def_id());
self.tcx.dcx().emit_err(errors::MissingConstStabAttr { span, descr });
}
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
index fbdb3cb1534e..945bab6887e6 100644
--- a/compiler/rustc_session/src/config.rs
+++ b/compiler/rustc_session/src/config.rs
@@ -3369,3 +3369,25 @@ pub enum FunctionReturn {
/// Replace returns with jumps to thunk, without emitting the thunk.
ThunkExtern,
}
+
+/// Whether extra span comments are included when dumping MIR, via the `-Z mir-include-spans` flag.
+/// By default, only enabled in the NLL MIR dumps, and disabled in all other passes.
+#[derive(Clone, Copy, Default, PartialEq, Debug)]
+pub enum MirIncludeSpans {
+ Off,
+ On,
+ /// Default: include extra comments in NLL MIR dumps only. Can be ignored and considered as
+ /// `Off` in all other cases.
+ #[default]
+ Nll,
+}
+
+impl MirIncludeSpans {
+ /// Unless opting into extra comments for all passes, they can be considered disabled.
+ /// The cases where a distinction between on/off and a per-pass value can exist will be handled
+ /// in the passes themselves: i.e. the `Nll` value is considered off for all intents and
+ /// purposes, except for the NLL MIR dump pass.
+ pub fn is_enabled(self) -> bool {
+ self == MirIncludeSpans::On
+ }
+}
diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs
index 4492ad09357b..37077901e0c3 100644
--- a/compiler/rustc_session/src/options.rs
+++ b/compiler/rustc_session/src/options.rs
@@ -445,6 +445,8 @@ mod desc {
pub const parse_llvm_module_flag: &str = ":::. Type must currently be `u32`. Behavior should be one of (`error`, `warning`, `require`, `override`, `append`, `appendunique`, `max`, `min`)";
pub const parse_function_return: &str = "`keep` or `thunk-extern`";
pub const parse_wasm_c_abi: &str = "`legacy` or `spec`";
+ pub const parse_mir_include_spans: &str =
+ "either a boolean (`yes`, `no`, `on`, `off`, etc), or `nll` (default: `nll`)";
}
mod parse {
@@ -1488,6 +1490,17 @@ mod parse {
}
true
}
+
+ pub(crate) fn parse_mir_include_spans(slot: &mut MirIncludeSpans, v: Option<&str>) -> bool {
+ *slot = match v {
+ Some("on" | "yes" | "y" | "true") | None => MirIncludeSpans::On,
+ Some("off" | "no" | "n" | "false") => MirIncludeSpans::Off,
+ Some("nll") => MirIncludeSpans::Nll,
+ _ => return false,
+ };
+
+ true
+ }
}
options! {
@@ -1848,8 +1861,9 @@ options! {
specified passes to be enabled, overriding all other checks. In particular, this will \
enable unsound (known-buggy and hence usually disabled) passes without further warning! \
Passes that are not specified are enabled or disabled by other flags as usual."),
- mir_include_spans: bool = (false, parse_bool, [UNTRACKED],
- "use line numbers relative to the function in mir pretty printing"),
+ mir_include_spans: MirIncludeSpans = (MirIncludeSpans::default(), parse_mir_include_spans, [UNTRACKED],
+ "include extra comments in mir pretty printing, like line numbers and statement indices, \
+ details about types, etc. (boolean for all passes, 'nll' to enable in NLL MIR only, default: 'nll')"),
mir_keep_place_mention: bool = (false, parse_bool, [TRACKED],
"keep place mention MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \
(default: no)"),
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs
index 5193333be8e9..bff2a184b19f 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs
@@ -68,6 +68,7 @@ use rustc_middle::ty::{
};
use rustc_span::{sym, BytePos, DesugaringKind, Pos, Span};
use rustc_target::spec::abi;
+use tracing::{debug, instrument};
use crate::error_reporting::TypeErrCtxt;
use crate::errors::{ObligationCauseFailureCode, TypeErrorAdditionalDiags};
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs
index 53f013ac153b..a93b633ce1a9 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs
@@ -19,6 +19,7 @@ use rustc_middle::ty::{
};
use rustc_span::symbol::{sym, Ident};
use rustc_span::{BytePos, FileName, Span, DUMMY_SP};
+use tracing::{debug, instrument, warn};
use crate::error_reporting::TypeErrCtxt;
use crate::errors::{
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/different_lifetimes.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/different_lifetimes.rs
index 8f84d7712160..47e9a3755e89 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/different_lifetimes.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/different_lifetimes.rs
@@ -5,6 +5,7 @@ use rustc_errors::{Diag, ErrorGuaranteed, Subdiagnostic};
use rustc_hir::def_id::LocalDefId;
use rustc_hir::Ty;
use rustc_middle::ty::{Region, TyCtxt};
+use tracing::debug;
use crate::error_reporting::infer::nice_region_error::find_anon_type::find_anon_type;
use crate::error_reporting::infer::nice_region_error::util::AnonymousParamInfo;
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/find_anon_type.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/find_anon_type.rs
index cd61747917a8..7a44c2ad661d 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/find_anon_type.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/find_anon_type.rs
@@ -7,6 +7,7 @@ use rustc_middle::hir::map::Map;
use rustc_middle::hir::nested_filter;
use rustc_middle::middle::resolve_bound_vars as rbv;
use rustc_middle::ty::{self, Region, TyCtxt};
+use tracing::debug;
/// This function calls the `visit_ty` method for the parameters
/// corresponding to the anonymous regions. The `nested_visitor.found_type`
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mismatched_static_lifetime.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mismatched_static_lifetime.rs
index 221f6675d22c..4fe26fa81af0 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mismatched_static_lifetime.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mismatched_static_lifetime.rs
@@ -7,6 +7,7 @@ use rustc_hir as hir;
use rustc_hir::intravisit::Visitor;
use rustc_middle::bug;
use rustc_middle::ty::TypeVisitor;
+use tracing::debug;
use crate::error_reporting::infer::nice_region_error::NiceRegionError;
use crate::errors::{
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs
index f91a81f76f42..a7a1fa1c2b45 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs
@@ -4,6 +4,7 @@
use rustc_errors::Diag;
use rustc_middle::ty;
use rustc_span::symbol::kw;
+use tracing::debug;
use crate::error_reporting::infer::nice_region_error::find_anon_type::find_anon_type;
use crate::error_reporting::infer::nice_region_error::NiceRegionError;
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs
index 8da0edbeb02a..2b7927367d8c 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs
@@ -8,6 +8,7 @@ use rustc_middle::bug;
use rustc_middle::ty::error::ExpectedFound;
use rustc_middle::ty::print::{FmtPrinter, Print, PrintTraitRefExt as _, RegionHighlightMode};
use rustc_middle::ty::{self, GenericArgsRef, RePlaceholder, Region, TyCtxt};
+use tracing::{debug, instrument};
use crate::error_reporting::infer::nice_region_error::NiceRegionError;
use crate::errors::{
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs
index dc775b824da4..95ebeab13ef8 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs
@@ -14,6 +14,7 @@ use rustc_middle::ty::{
use rustc_span::def_id::LocalDefId;
use rustc_span::symbol::Ident;
use rustc_span::Span;
+use tracing::debug;
use crate::error_reporting::infer::nice_region_error::NiceRegionError;
use crate::errors::{
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/trait_impl_difference.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/trait_impl_difference.rs
index 09af00beba7a..592ade8ede20 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/trait_impl_difference.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/trait_impl_difference.rs
@@ -11,6 +11,7 @@ use rustc_middle::ty::error::ExpectedFound;
use rustc_middle::ty::print::RegionHighlightMode;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitor};
use rustc_span::Span;
+use tracing::debug;
use crate::error_reporting::infer::nice_region_error::NiceRegionError;
use crate::errors::{ConsiderBorrowingParamHelp, RelationshipHelp, TraitImplDiff};
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/util.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/util.rs
index 30fa98c55265..90b354305ffd 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/util.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/util.rs
@@ -5,6 +5,7 @@ use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId;
use rustc_middle::ty::{self, Binder, Region, Ty, TyCtxt, TypeFoldable};
use rustc_span::Span;
+use tracing::instrument;
use crate::error_reporting::infer::nice_region_error::NiceRegionError;
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/note.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/note.rs
index 600da730845e..e38b8e2f3d6d 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/note.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/note.rs
@@ -4,6 +4,7 @@ use rustc_middle::traits::ObligationCauseCode;
use rustc_middle::ty::error::TypeError;
use rustc_middle::ty::{self, IsSuggestable, Region, Ty};
use rustc_span::symbol::kw;
+use tracing::debug;
use super::ObligationCauseAsDiagArg;
use crate::error_reporting::infer::{note_and_explain_region, TypeErrCtxt};
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs
index 05c79170902d..db71331d07f0 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs
@@ -9,6 +9,7 @@ use rustc_middle::ty::print::{FmtPrinter, Printer};
use rustc_middle::ty::{self, suggest_constraining_type_param, Ty};
use rustc_span::def_id::DefId;
use rustc_span::{sym, BytePos, Span, Symbol};
+use tracing::debug;
use crate::error_reporting::TypeErrCtxt;
use crate::infer::InferCtxtExt;
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs
index ada44b632d4c..e4a4ec125a5c 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs
@@ -15,6 +15,7 @@ use rustc_middle::ty::{self, IsSuggestable, Region, Ty, TyCtxt, TypeVisitableExt
use rustc_span::symbol::kw;
use rustc_span::{BytePos, ErrorGuaranteed, Span, Symbol};
use rustc_type_ir::Upcast as _;
+use tracing::{debug, instrument};
use super::nice_region_error::find_anon_type;
use super::ObligationCauseAsDiagArg;
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs
index ba656493d462..50cbdcc61518 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs
@@ -15,6 +15,7 @@ use rustc_middle::traits::{
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{self as ty, GenericArgKind, IsSuggestable, Ty, TypeVisitableExt};
use rustc_span::{sym, Span};
+use tracing::debug;
use crate::error_reporting::infer::hir::Path;
use crate::error_reporting::TypeErrCtxt;
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs
index 9ab470578592..79c1f7222809 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs
@@ -15,6 +15,7 @@ use rustc_infer::traits::{
};
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable as _, TypeVisitableExt as _};
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
+use tracing::{debug, instrument};
use crate::error_reporting::infer::need_type_info::TypeAnnotationNeeded;
use crate::error_reporting::traits::{to_pretty_impl_header, FindExprBySpan};
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
index def9d6e9a311..3fdfca50dceb 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
@@ -28,6 +28,7 @@ use rustc_middle::ty::{
use rustc_middle::{bug, span_bug};
use rustc_span::symbol::sym;
use rustc_span::{BytePos, Span, Symbol, DUMMY_SP};
+use tracing::{debug, instrument};
use super::on_unimplemented::{AppendConstMessage, OnUnimplementedNote};
use super::suggestions::get_explanation_based_on_obligation;
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs
index 40a1c1840099..9aa6d1f3d465 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs
@@ -18,6 +18,7 @@ use rustc_infer::traits::{
use rustc_middle::ty::print::{with_no_trimmed_paths, PrintTraitRefExt as _};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::{ErrorGuaranteed, ExpnKind, Span};
+use tracing::{info, instrument};
pub use self::overflow::*;
use crate::error_reporting::TypeErrCtxt;
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs
index f656f9b0e383..efbc2695fd95 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs
@@ -14,6 +14,7 @@ use rustc_parse_format::{ParseMode, Parser, Piece, Position};
use rustc_session::lint::builtin::UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES;
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::Span;
+use tracing::{debug, info};
use {rustc_attr as attr, rustc_hir as hir};
use super::{ObligationCauseCode, PredicateObligation};
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/overflow.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/overflow.rs
index 16fbff7816a9..51fb9f3c6229 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/overflow.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/overflow.rs
@@ -11,6 +11,7 @@ use rustc_middle::ty::{self, TyCtxt};
use rustc_session::Limit;
use rustc_span::Span;
use rustc_type_ir::Upcast;
+use tracing::debug;
use crate::error_reporting::TypeErrCtxt;
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
index 3cb95294fb69..f2c457aa377f 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
@@ -38,6 +38,7 @@ use rustc_span::def_id::LocalDefId;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{BytePos, DesugaringKind, ExpnKind, MacroKind, Span, DUMMY_SP};
use rustc_target::spec::abi;
+use tracing::{debug, instrument};
use super::{
DefIdOrName, FindExprBySpan, ImplCandidate, Obligation, ObligationCause, ObligationCauseCode,
diff --git a/compiler/rustc_trait_selection/src/infer.rs b/compiler/rustc_trait_selection/src/infer.rs
index c22925b73e35..f232a896f969 100644
--- a/compiler/rustc_trait_selection/src/infer.rs
+++ b/compiler/rustc_trait_selection/src/infer.rs
@@ -9,6 +9,7 @@ use rustc_middle::infer::canonical::{Canonical, CanonicalQueryResponse, QueryRes
use rustc_middle::traits::query::NoSolution;
use rustc_middle::ty::{self, GenericArg, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, Upcast};
use rustc_span::DUMMY_SP;
+use tracing::instrument;
use crate::infer::at::ToTrace;
use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
diff --git a/compiler/rustc_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs
index c98d6c5f1dfd..aea47c9e987a 100644
--- a/compiler/rustc_trait_selection/src/lib.rs
+++ b/compiler/rustc_trait_selection/src/lib.rs
@@ -34,9 +34,6 @@
#![recursion_limit = "512"] // For rustdoc
// tidy-alphabetical-end
-#[macro_use]
-extern crate tracing;
-
pub mod error_reporting;
pub mod errors;
pub mod infer;
diff --git a/compiler/rustc_trait_selection/src/solve/delegate.rs b/compiler/rustc_trait_selection/src/solve/delegate.rs
index ade26a409205..a7b0719d8d4a 100644
--- a/compiler/rustc_trait_selection/src/solve/delegate.rs
+++ b/compiler/rustc_trait_selection/src/solve/delegate.rs
@@ -13,6 +13,7 @@ use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt as _};
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
use rustc_type_ir::solve::{Certainty, NoSolution, SolverMode};
+use tracing::trace;
use crate::traits::specialization_graph;
diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs
index de8951ef7204..f5f36f40f7e6 100644
--- a/compiler/rustc_trait_selection/src/solve/fulfill.rs
+++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs
@@ -13,6 +13,7 @@ use rustc_middle::bug;
use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::{self, TyCtxt};
use rustc_next_trait_solver::solve::{GenerateProofTree, SolverDelegateEvalExt as _};
+use tracing::instrument;
use super::delegate::SolverDelegate;
use super::inspect::{self, ProofTreeInferCtxtExt, ProofTreeVisitor};
diff --git a/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs b/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs
index 51dda25d8adc..49c37a684b57 100644
--- a/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs
+++ b/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs
@@ -23,6 +23,7 @@ use rustc_next_trait_solver::resolve::EagerResolver;
use rustc_next_trait_solver::solve::inspect::{self, instantiate_canonical_state};
use rustc_next_trait_solver::solve::{GenerateProofTree, MaybeCause, SolverDelegateEvalExt as _};
use rustc_span::{Span, DUMMY_SP};
+use tracing::instrument;
use crate::solve::delegate::SolverDelegate;
use crate::traits::ObligationCtxt;
diff --git a/compiler/rustc_trait_selection/src/solve/normalize.rs b/compiler/rustc_trait_selection/src/solve/normalize.rs
index c93c40b48268..938ba2dde849 100644
--- a/compiler/rustc_trait_selection/src/solve/normalize.rs
+++ b/compiler/rustc_trait_selection/src/solve/normalize.rs
@@ -11,6 +11,7 @@ use rustc_middle::ty::{
self, FallibleTypeFolder, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable,
TypeVisitableExt, UniverseIndex,
};
+use tracing::instrument;
use super::{FulfillmentCtxt, NextSolverError};
use crate::error_reporting::traits::OverflowCause;
diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs
index 38d338598a17..f68e05833079 100644
--- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs
+++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs
@@ -9,6 +9,7 @@ use rustc_data_structures::unord::UnordSet;
use rustc_infer::infer::DefineOpaqueTypes;
use rustc_middle::mir::interpret::ErrorHandled;
use rustc_middle::ty::{Region, RegionVid};
+use tracing::debug;
use super::*;
use crate::errors::UnableToConstructConstantValue;
diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs
index 2d843d8f1740..bf4b0482081d 100644
--- a/compiler/rustc_trait_selection/src/traits/coherence.rs
+++ b/compiler/rustc_trait_selection/src/traits/coherence.rs
@@ -21,6 +21,7 @@ use rustc_middle::ty::{self, Ty, TyCtxt};
pub use rustc_next_trait_solver::coherence::*;
use rustc_span::symbol::sym;
use rustc_span::{Span, DUMMY_SP};
+use tracing::{debug, instrument, warn};
use super::ObligationCtxt;
use crate::error_reporting::traits::suggest_new_overflow_limit;
diff --git a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs
index f93bd0a396dd..4289384725f7 100644
--- a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs
+++ b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs
@@ -17,6 +17,7 @@ use rustc_middle::traits::ObligationCause;
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
use rustc_middle::ty::{self, TyCtxt, TypeVisitable, TypeVisitableExt, TypeVisitor};
use rustc_span::{Span, DUMMY_SP};
+use tracing::{debug, instrument};
use crate::traits::ObligationCtxt;
diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs
index a6db22ec15a3..f72ae94fffc7 100644
--- a/compiler/rustc_trait_selection/src/traits/fulfill.rs
+++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs
@@ -13,6 +13,7 @@ use rustc_middle::mir::interpret::ErrorHandled;
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::{self, Binder, Const, GenericArgsRef, TypeVisitableExt};
+use tracing::{debug, debug_span, instrument};
use super::project::{self, ProjectAndUnifyResult};
use super::select::SelectionContext;
diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs
index a350b76a7049..c82eaa5143d6 100644
--- a/compiler/rustc_trait_selection/src/traits/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/mod.rs
@@ -37,6 +37,7 @@ use rustc_middle::ty::{
};
use rustc_span::def_id::DefId;
use rustc_span::Span;
+use tracing::{debug, instrument};
pub use self::coherence::{
add_placeholder_note, orphan_check_trait_ref, overlapping_impls, InCrate, IsFirstInputType,
diff --git a/compiler/rustc_trait_selection/src/traits/normalize.rs b/compiler/rustc_trait_selection/src/traits/normalize.rs
index 81f8633ba955..aad47df73696 100644
--- a/compiler/rustc_trait_selection/src/traits/normalize.rs
+++ b/compiler/rustc_trait_selection/src/traits/normalize.rs
@@ -11,6 +11,7 @@ use rustc_middle::traits::{ObligationCause, ObligationCauseCode, Reveal};
use rustc_middle::ty::{
self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitable, TypeVisitableExt,
};
+use tracing::{debug, instrument};
use super::{
project, with_replaced_escaping_bound_vars, BoundVarReplacer, PlaceholderReplacer,
diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs
index 8e1fc0d7fe68..fa696dcd2f59 100644
--- a/compiler/rustc_trait_selection/src/traits/object_safety.rs
+++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs
@@ -24,6 +24,7 @@ use rustc_span::symbol::Symbol;
use rustc_span::Span;
use rustc_target::abi::Abi;
use smallvec::SmallVec;
+use tracing::{debug, instrument};
use super::elaborate;
use crate::infer::TyCtxtInferExt;
@@ -185,12 +186,11 @@ fn predicates_reference_self(
) -> SmallVec<[Span; 1]> {
let trait_ref = ty::Binder::dummy(ty::TraitRef::identity(tcx, trait_def_id));
let predicates = if supertraits_only {
- tcx.explicit_super_predicates_of(trait_def_id)
+ tcx.explicit_super_predicates_of(trait_def_id).skip_binder()
} else {
- tcx.predicates_of(trait_def_id)
+ tcx.predicates_of(trait_def_id).predicates
};
predicates
- .predicates
.iter()
.map(|&(predicate, sp)| (predicate.instantiate_supertrait(tcx, trait_ref), sp))
.filter_map(|(clause, sp)| {
@@ -266,9 +266,8 @@ fn super_predicates_have_non_lifetime_binders(
return SmallVec::new();
}
tcx.explicit_super_predicates_of(trait_def_id)
- .predicates
- .iter()
- .filter_map(|(pred, span)| pred.has_non_region_bound_vars().then_some(*span))
+ .iter_identity_copied()
+ .filter_map(|(pred, span)| pred.has_non_region_bound_vars().then_some(span))
.collect()
}
diff --git a/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs b/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs
index 0fe750599040..ee1b0fc6f2e5 100644
--- a/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs
+++ b/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs
@@ -7,6 +7,7 @@ use rustc_middle::span_bug;
pub use rustc_middle::traits::query::OutlivesBound;
use rustc_middle::ty::{self, ParamEnv, Ty, TypeFolder, TypeVisitableExt};
use rustc_span::def_id::LocalDefId;
+use tracing::{debug, instrument};
use crate::infer::InferCtxt;
use crate::traits::{ObligationCause, ObligationCtxt};
diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs
index 568214fe0229..4702fd866c1b 100644
--- a/compiler/rustc_trait_selection/src/traits/project.rs
+++ b/compiler/rustc_trait_selection/src/traits/project.rs
@@ -18,6 +18,7 @@ use rustc_middle::ty::visit::{MaxUniverse, TypeVisitable, TypeVisitableExt};
use rustc_middle::ty::{self, Term, Ty, TyCtxt, Upcast};
use rustc_middle::{bug, span_bug};
use rustc_span::symbol::sym;
+use tracing::{debug, instrument};
use super::{
specialization_graph, translate_args, util, MismatchedProjectionTypes, Normalized,
diff --git a/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs b/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs
index 7d30e6524490..7036df024659 100644
--- a/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs
+++ b/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs
@@ -2,6 +2,7 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_middle::traits::query::{DropckConstraint, DropckOutlivesResult};
use rustc_middle::ty::{self, EarlyBinder, ParamEnvAnd, Ty, TyCtxt};
use rustc_span::{Span, DUMMY_SP};
+use tracing::{debug, instrument};
use crate::traits::query::normalize::QueryNormalizeExt;
use crate::traits::query::NoSolution;
diff --git a/compiler/rustc_trait_selection/src/traits/query/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs
index cb96db5f7a22..f1b524d1325c 100644
--- a/compiler/rustc_trait_selection/src/traits/query/normalize.rs
+++ b/compiler/rustc_trait_selection/src/traits/query/normalize.rs
@@ -10,6 +10,7 @@ use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable
use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt};
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitor};
use rustc_span::DUMMY_SP;
+use tracing::{debug, info, instrument};
use super::NoSolution;
use crate::error_reporting::traits::OverflowCause;
diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs
index 5e4de43d04fc..2b3c11d4c48a 100644
--- a/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs
+++ b/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs
@@ -5,6 +5,7 @@ use rustc_middle::traits::query::NoSolution;
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, UserArgs, UserSelfTy, UserType};
use rustc_span::{Span, DUMMY_SP};
+use tracing::{debug, instrument};
use crate::infer::canonical::{Canonical, CanonicalQueryResponse};
use crate::traits::ObligationCtxt;
diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs
index 34e678e93d1e..6efc2d07843e 100644
--- a/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs
+++ b/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs
@@ -5,6 +5,7 @@ use rustc_infer::infer::region_constraints::RegionConstraintData;
use rustc_middle::traits::query::NoSolution;
use rustc_middle::ty::{TyCtxt, TypeFoldable};
use rustc_span::Span;
+use tracing::info;
use crate::infer::canonical::query_response;
use crate::infer::InferCtxt;
diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs
index b5b209c1af79..a493615a1dfb 100644
--- a/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs
+++ b/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs
@@ -9,6 +9,7 @@ use rustc_span::def_id::CRATE_DEF_ID;
use rustc_span::DUMMY_SP;
use rustc_type_ir::outlives::{push_outlives_components, Component};
use smallvec::{smallvec, SmallVec};
+use tracing::debug;
use crate::traits::query::NoSolution;
use crate::traits::{wf, ObligationCtxt};
diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
index a21feec4b1a3..7895a420476f 100644
--- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
@@ -16,6 +16,7 @@ use rustc_infer::traits::{Obligation, ObligationCause, PolyTraitObligation, Sele
use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams};
use rustc_middle::ty::{self, ToPolyTraitRef, Ty, TypeVisitableExt};
use rustc_middle::{bug, span_bug};
+use tracing::{debug, instrument, trace};
use super::SelectionCandidate::*;
use super::{BuiltinImplConditions, SelectionCandidateSet, SelectionContext, TraitObligationStack};
diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs
index f19cd19c99a8..daf0700ec0cd 100644
--- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs
@@ -21,6 +21,7 @@ use rustc_middle::ty::{
};
use rustc_middle::{bug, span_bug};
use rustc_span::def_id::DefId;
+use tracing::{debug, instrument};
use super::SelectionCandidate::{self, *};
use super::{BuiltinImplConditions, SelectionContext};
@@ -600,21 +601,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// Check supertraits hold. This is so that their associated type bounds
// will be checked in the code below.
- for super_trait in tcx
+ for (supertrait, _) in tcx
.explicit_super_predicates_of(trait_predicate.def_id())
- .instantiate(tcx, trait_predicate.trait_ref.args)
- .predicates
- .into_iter()
+ .iter_instantiated_copied(tcx, trait_predicate.trait_ref.args)
{
- let normalized_super_trait = normalize_with_depth_to(
+ let normalized_supertrait = normalize_with_depth_to(
self,
obligation.param_env,
obligation.cause.clone(),
obligation.recursion_depth + 1,
- super_trait,
+ supertrait,
&mut nested,
);
- nested.push(obligation.with(tcx, normalized_super_trait));
+ nested.push(obligation.with(tcx, normalized_supertrait));
}
let assoc_types: Vec<_> = tcx
diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs
index f002fa27db27..91fe19c20f77 100644
--- a/compiler/rustc_trait_selection/src/traits/select/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs
@@ -31,6 +31,7 @@ use rustc_middle::ty::{
};
use rustc_span::symbol::sym;
use rustc_span::Symbol;
+use tracing::{debug, instrument, trace};
use self::EvaluationResult::*;
use self::SelectionCandidate::*;
diff --git a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs
index 4c8c5a2eb17f..7337b59f8704 100644
--- a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs
@@ -10,6 +10,7 @@
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/specialization.html
pub mod specialization_graph;
+
use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::codes::*;
use rustc_errors::{Diag, EmissionGuarantee};
@@ -22,6 +23,7 @@ use rustc_middle::ty::{self, GenericArgsRef, ImplSubject, Ty, TyCtxt, TypeVisita
use rustc_session::lint::builtin::{COHERENCE_LEAK_CHECK, ORDER_DEPENDENT_TRAIT_OBJECTS};
use rustc_span::{sym, ErrorGuaranteed, Span, DUMMY_SP};
use specialization_graph::GraphExt;
+use tracing::{debug, instrument};
use super::{util, SelectionContext};
use crate::error_reporting::traits::to_pretty_impl_header;
diff --git a/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs b/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs
index 732f1b0a3d7c..0fdaf40b136d 100644
--- a/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs
+++ b/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs
@@ -5,6 +5,7 @@ use rustc_middle::bug;
pub use rustc_middle::traits::specialization_graph::*;
use rustc_middle::ty::fast_reject::{self, SimplifiedType, TreatParams};
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
+use tracing::{debug, instrument};
use super::OverlapError;
use crate::traits;
diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs
index 52f87699b164..0689b880f330 100644
--- a/compiler/rustc_trait_selection/src/traits/util.rs
+++ b/compiler/rustc_trait_selection/src/traits/util.rs
@@ -12,6 +12,7 @@ use rustc_middle::ty::{
};
use rustc_span::Span;
use smallvec::{smallvec, SmallVec};
+use tracing::debug;
use super::{NormalizeExt, ObligationCause, PredicateObligation, SelectionContext};
@@ -131,7 +132,7 @@ impl<'tcx> TraitAliasExpander<'tcx> {
let predicates = tcx.explicit_super_predicates_of(trait_ref.def_id());
debug!(?predicates);
- let items = predicates.predicates.iter().rev().filter_map(|(pred, span)| {
+ let items = predicates.skip_binder().iter().rev().filter_map(|(pred, span)| {
pred.instantiate_supertrait(tcx, trait_ref)
.as_trait_clause()
.map(|trait_ref| item.clone_and_push(trait_ref.map_bound(|t| t.trait_ref), *span))
diff --git a/compiler/rustc_trait_selection/src/traits/vtable.rs b/compiler/rustc_trait_selection/src/traits/vtable.rs
index 1729d8d307a5..f525c17e0531 100644
--- a/compiler/rustc_trait_selection/src/traits/vtable.rs
+++ b/compiler/rustc_trait_selection/src/traits/vtable.rs
@@ -10,6 +10,7 @@ use rustc_middle::ty::{
};
use rustc_span::{sym, Span, DUMMY_SP};
use smallvec::{smallvec, SmallVec};
+use tracing::debug;
use crate::errors::DumpVTableEntries;
use crate::traits::{impossible_predicates, is_vtable_safe_method};
@@ -120,8 +121,7 @@ fn prepare_vtable_segments_inner<'tcx, T>(
let mut direct_super_traits_iter = tcx
.explicit_super_predicates_of(inner_most_trait_ref.def_id())
- .predicates
- .into_iter()
+ .iter_identity_copied()
.filter_map(move |(pred, _)| {
pred.instantiate_supertrait(tcx, inner_most_trait_ref).as_trait_clause()
});
diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs
index a3982c3d987e..889e4ed7fcc6 100644
--- a/compiler/rustc_trait_selection/src/traits/wf.rs
+++ b/compiler/rustc_trait_selection/src/traits/wf.rs
@@ -10,6 +10,7 @@ use rustc_middle::ty::{
};
use rustc_span::def_id::{DefId, LocalDefId, CRATE_DEF_ID};
use rustc_span::{Span, DUMMY_SP};
+use tracing::{debug, instrument, trace};
use crate::infer::InferCtxt;
use crate::traits;
diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs
index 328b6739d975..80c3565911e9 100644
--- a/compiler/rustc_type_ir/src/ty_kind.rs
+++ b/compiler/rustc_type_ir/src/ty_kind.rs
@@ -254,13 +254,6 @@ pub enum TyKind {
Error(I::ErrorGuaranteed),
}
-impl TyKind {
- #[inline]
- pub fn is_primitive(&self) -> bool {
- matches!(self, Bool | Char | Int(_) | Uint(_) | Float(_))
- }
-}
-
// This is manually implemented because a derive would require `I: Debug`
impl fmt::Debug for TyKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
diff --git a/library/alloc/benches/lib.rs b/library/alloc/benches/lib.rs
index 0561f49c967e..ae9608ec7bd5 100644
--- a/library/alloc/benches/lib.rs
+++ b/library/alloc/benches/lib.rs
@@ -1,6 +1,3 @@
-// Disabling on android for the time being
-// See https://github.com/rust-lang/rust/issues/73535#event-3477699747
-#![cfg(not(target_os = "android"))]
// Disabling in Miri as these would take too long.
#![cfg(not(miri))]
#![feature(btree_extract_if)]
diff --git a/library/alloc/tests/string.rs b/library/alloc/tests/string.rs
index c5bc4185a367..dc03c4860e84 100644
--- a/library/alloc/tests/string.rs
+++ b/library/alloc/tests/string.rs
@@ -723,7 +723,6 @@ fn test_reserve_exact() {
#[test]
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
-#[cfg_attr(target_os = "android", ignore)] // Android used in CI has a broken dlmalloc
fn test_try_with_capacity() {
let string = String::try_with_capacity(1000).unwrap();
assert_eq!(0, string.len());
@@ -734,7 +733,6 @@ fn test_try_with_capacity() {
#[test]
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
-#[cfg_attr(target_os = "android", ignore)] // Android used in CI has a broken dlmalloc
fn test_try_reserve() {
// These are the interesting cases:
// * exactly isize::MAX should never trigger a CapacityOverflow (can be OOM)
@@ -803,7 +801,6 @@ fn test_try_reserve() {
#[test]
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
-#[cfg_attr(target_os = "android", ignore)] // Android used in CI has a broken dlmalloc
fn test_try_reserve_exact() {
// This is exactly the same as test_try_reserve with the method changed.
// See that test for comments.
diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs
index fd2ddbf59e42..3722fb06a6a8 100644
--- a/library/alloc/tests/vec.rs
+++ b/library/alloc/tests/vec.rs
@@ -1695,7 +1695,6 @@ fn test_reserve_exact() {
#[test]
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
-#[cfg_attr(target_os = "android", ignore)] // Android used in CI has a broken dlmalloc
fn test_try_with_capacity() {
let mut vec: Vec = Vec::try_with_capacity(5).unwrap();
assert_eq!(0, vec.len());
@@ -1707,7 +1706,6 @@ fn test_try_with_capacity() {
#[test]
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
-#[cfg_attr(target_os = "android", ignore)] // Android used in CI has a broken dlmalloc
fn test_try_reserve() {
// These are the interesting cases:
// * exactly isize::MAX should never trigger a CapacityOverflow (can be OOM)
@@ -1803,7 +1801,6 @@ fn test_try_reserve() {
#[test]
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
-#[cfg_attr(target_os = "android", ignore)] // Android used in CI has a broken dlmalloc
fn test_try_reserve_exact() {
// This is exactly the same as test_try_reserve with the method changed.
// See that test for comments.
diff --git a/library/alloc/tests/vec_deque.rs b/library/alloc/tests/vec_deque.rs
index db972122fef2..f32ba8d5aa46 100644
--- a/library/alloc/tests/vec_deque.rs
+++ b/library/alloc/tests/vec_deque.rs
@@ -1185,7 +1185,6 @@ fn test_reserve_exact_2() {
#[test]
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
-#[cfg_attr(target_os = "android", ignore)] // Android used in CI has a broken dlmalloc
fn test_try_with_capacity() {
let vec: VecDeque = VecDeque::try_with_capacity(5).unwrap();
assert_eq!(0, vec.len());
@@ -1196,7 +1195,6 @@ fn test_try_with_capacity() {
#[test]
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
-#[cfg_attr(target_os = "android", ignore)] // Android used in CI has a broken dlmalloc
fn test_try_reserve() {
// These are the interesting cases:
// * exactly isize::MAX should never trigger a CapacityOverflow (can be OOM)
@@ -1292,7 +1290,6 @@ fn test_try_reserve() {
#[test]
#[cfg_attr(miri, ignore)] // Miri does not support signalling OOM
-#[cfg_attr(target_os = "android", ignore)] // Android used in CI has a broken dlmalloc
fn test_try_reserve_exact() {
// This is exactly the same as test_try_reserve with the method changed.
// See that test for comments.
diff --git a/library/backtrace b/library/backtrace
index 72265bea2108..230570f2dac8 160000
--- a/library/backtrace
+++ b/library/backtrace
@@ -1 +1 @@
-Subproject commit 72265bea210891ae47bbe6d4f17b493ef0606619
+Subproject commit 230570f2dac80a601f5c0b30da00cc9480bd35eb
diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs
index e602b497d171..fed484ae3cd1 100644
--- a/library/core/src/mem/mod.rs
+++ b/library/core/src/mem/mod.rs
@@ -612,7 +612,7 @@ pub const fn needs_drop() -> bool {
///
/// There is no guarantee that an all-zero byte-pattern represents a valid value
/// of some type `T`. For example, the all-zero byte-pattern is not a valid value
-/// for reference types (`&T`, `&mut T`) and functions pointers. Using `zeroed`
+/// for reference types (`&T`, `&mut T`) and function pointers. Using `zeroed`
/// on such types causes immediate [undefined behavior][ub] because [the Rust
/// compiler assumes][inv] that there always is a valid value in a variable it
/// considers initialized.
diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs
index fe6ed7e0cf36..a7037b2a119f 100644
--- a/library/core/src/primitive_docs.rs
+++ b/library/core/src/primitive_docs.rs
@@ -1127,7 +1127,7 @@ impl (T,) {}
#[rustc_doc_primitive = "f16"]
#[doc(alias = "half")]
-/// A 16-bit floating point type (specifically, the "binary16" type defined in IEEE 754-2008).
+/// A 16-bit floating-point type (specifically, the "binary16" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`] but has decreased precision because it uses half as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on half-precision
@@ -1147,11 +1147,11 @@ mod prim_f16 {}
#[rustc_doc_primitive = "f32"]
#[doc(alias = "single")]
-/// A 32-bit floating point type (specifically, the "binary32" type defined in IEEE 754-2008).
+/// A 32-bit floating-point type (specifically, the "binary32" type defined in IEEE 754-2008).
///
/// This type can represent a wide range of decimal numbers, like `3.5`, `27`,
/// `-113.75`, `0.0078125`, `34359738368`, `0`, `-1`. So unlike integer types
-/// (such as `i32`), floating point types can represent non-integer numbers,
+/// (such as `i32`), floating-point types can represent non-integer numbers,
/// too.
///
/// However, being able to represent this wide range of numbers comes at the
@@ -1165,8 +1165,8 @@ mod prim_f16 {}
///
/// Additionally, `f32` can represent some special values:
///
-/// - −0.0: IEEE 754 floating point numbers have a bit that indicates their sign, so −0.0 is a
-/// possible value. For comparison −0.0 = +0.0, but floating point operations can carry
+/// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a
+/// possible value. For comparison −0.0 = +0.0, but floating-point operations can carry
/// the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and
/// a negative number rounded to a value smaller than a float can represent also produces −0.0.
/// - [∞](#associatedconstant.INFINITY) and
@@ -1211,7 +1211,7 @@ mod prim_f16 {}
/// both arguments were negative, then it is -0.0. Subtraction `a - b` is
/// regarded as a sum `a + (-b)`.
///
-/// For more information on floating point numbers, see [Wikipedia][wikipedia].
+/// For more information on floating-point numbers, see [Wikipedia][wikipedia].
///
/// *[See also the `std::f32::consts` module](crate::f32::consts).*
///
@@ -1219,39 +1219,43 @@ mod prim_f16 {}
///
/// # NaN bit patterns
///
-/// This section defines the possible NaN bit patterns returned by non-"bitwise" floating point
-/// operations. The bitwise operations are unary `-`, `abs`, `copysign`; those are guaranteed to
-/// exactly preserve the bit pattern of their input except for possibly changing the sign bit.
+/// This section defines the possible NaN bit patterns returned by floating-point operations.
///
-/// A floating-point NaN value consists of:
-/// - a sign bit
-/// - a quiet/signaling bit
+/// The bit pattern of a floating-point NaN value is defined by:
+/// - a sign bit.
+/// - a quiet/signaling bit. Rust assumes that the quiet/signaling bit being set to `1` indicates a
+/// quiet NaN (QNaN), and a value of `0` indicates a signaling NaN (SNaN). In the following we
+/// will hence just call it the "quiet bit".
/// - a payload, which makes up the rest of the significand (i.e., the mantissa) except for the
-/// quiet/signaling bit.
+/// quiet bit.
///
-/// Rust assumes that the quiet/signaling bit being set to `1` indicates a quiet NaN (QNaN), and a
-/// value of `0` indicates a signaling NaN (SNaN). In the following we will hence just call it the
-/// "quiet bit".
+/// The rules for NaN values differ between *arithmetic* and *non-arithmetic* (or "bitwise")
+/// operations. The non-arithmetic operations are unary `-`, `abs`, `copysign`, `signum`,
+/// `{to,from}_bits`, `{to,from}_{be,le,ne}_bytes` and `is_sign_{positive,negative}`. These
+/// operations are guaranteed to exactly preserve the bit pattern of their input except for possibly
+/// changing the sign bit.
///
-/// The following rules apply when a NaN value is returned: the result has a non-deterministic sign.
-/// The quiet bit and payload are non-deterministically chosen from the following set of options:
+/// The following rules apply when a NaN value is returned from an arithmetic operation:
+/// - The result has a non-deterministic sign.
+/// - The quiet bit and payload are non-deterministically chosen from
+/// the following set of options:
///
-/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
-/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
-/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
-/// `as` casts), then
-/// - If the output is smaller than the input, low-order bits of the payload get dropped.
-/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
-/// bits.
-/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
-/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
-/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
-/// than the input, droppig the low-order bits may result in a payload of 0; a payload of 0 is not
-/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
-/// propagation cannot occur with some inputs.
-/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
-/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
-/// See the table below for the concrete NaNs this set contains on various targets.
+/// - **Preferred NaN**: The quiet bit is set and the payload is all-zero.
+/// - **Quieting NaN propagation**: The quiet bit is set and the payload is copied from any input
+/// operand that is a NaN. If the inputs and outputs do not have the same payload size (i.e., for
+/// `as` casts), then
+/// - If the output is smaller than the input, low-order bits of the payload get dropped.
+/// - If the output is larger than the input, the payload gets filled up with 0s in the low-order
+/// bits.
+/// - **Unchanged NaN propagation**: The quiet bit and payload are copied from any input operand
+/// that is a NaN. If the inputs and outputs do not have the same size (i.e., for `as` casts), the
+/// same rules as for "quieting NaN propagation" apply, with one caveat: if the output is smaller
+/// than the input, droppig the low-order bits may result in a payload of 0; a payload of 0 is not
+/// possible with a signaling NaN (the all-0 significand encodes an infinity) so unchanged NaN
+/// propagation cannot occur with some inputs.
+/// - **Target-specific NaN**: The quiet bit is set and the payload is picked from a target-specific
+/// set of "extra" possible NaN payloads. The set can depend on the input operand values.
+/// See the table below for the concrete NaNs this set contains on various targets.
///
/// In particular, if all input NaNs are quiet (or if there are no input NaNs), then the output NaN
/// is definitely quiet. Signaling NaN outputs can only occur if they are provided as an input
@@ -1259,7 +1263,7 @@ mod prim_f16 {}
/// does not have any "extra" NaN payloads, then the output NaN is guaranteed to be preferred.
///
/// The non-deterministic choice happens when the operation is executed; i.e., the result of a
-/// NaN-producing floating point operation is a stable bit pattern (looking at these bits multiple
+/// NaN-producing floating-point operation is a stable bit pattern (looking at these bits multiple
/// times will yield consistent results), but running the same operation twice with the same inputs
/// can produce different results.
///
@@ -1273,10 +1277,10 @@ mod prim_f16 {}
/// (e.g. `min`, `minimum`, `max`, `maximum`); other aspects of their semantics and which IEEE 754
/// operation they correspond to are documented with the respective functions.
///
-/// When a floating-point operation is executed in `const` context, the same rules apply: no
-/// guarantee is made about which of the NaN bit patterns described above will be returned. The
-/// result does not have to match what happens when executing the same code at runtime, and the
-/// result can vary depending on factors such as compiler version and flags.
+/// When an arithmetic floating-point operation is executed in `const` context, the same rules
+/// apply: no guarantee is made about which of the NaN bit patterns described above will be
+/// returned. The result does not have to match what happens when executing the same code at
+/// runtime, and the result can vary depending on factors such as compiler version and flags.
///
/// ### Target-specific "extra" NaN values
// FIXME: Is there a better place to put this?
@@ -1294,7 +1298,7 @@ mod prim_f32 {}
#[rustc_doc_primitive = "f64"]
#[doc(alias = "double")]
-/// A 64-bit floating point type (specifically, the "binary64" type defined in IEEE 754-2008).
+/// A 64-bit floating-point type (specifically, the "binary64" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`], but has increased precision by using twice as many
/// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision
@@ -1308,7 +1312,7 @@ mod prim_f64 {}
#[rustc_doc_primitive = "f128"]
#[doc(alias = "quad")]
-/// A 128-bit floating point type (specifically, the "binary128" type defined in IEEE 754-2008).
+/// A 128-bit floating-point type (specifically, the "binary128" type defined in IEEE 754-2008).
///
/// This type is very similar to [`prim@f32`] and [`prim@f64`], but has increased precision by using twice
/// as many bits as `f64`. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on
diff --git a/library/core/tests/num/int_log.rs b/library/core/tests/num/int_log.rs
index 2320a7acc35a..60902752dab6 100644
--- a/library/core/tests/num/int_log.rs
+++ b/library/core/tests/num/int_log.rs
@@ -1,7 +1,4 @@
-//! This tests the `Integer::{ilog,log2,log10}` methods. These tests are in a
-//! separate file because there's both a large number of them, and not all tests
-//! can be run on Android. This is because in Android `ilog2` uses an imprecise
-//! approximation:https://github.com/rust-lang/rust/blob/4825e12fc9c79954aa0fe18f5521efa6c19c7539/src/libstd/sys/unix/android.rs#L27-L53
+//! Tests for the `Integer::{ilog,log2,log10}` methods.
#[test]
fn checked_ilog() {
@@ -48,6 +45,10 @@ fn checked_ilog2() {
assert_eq!(0i8.checked_ilog2(), None);
assert_eq!(0i16.checked_ilog2(), None);
+ assert_eq!(8192u16.checked_ilog2(), Some((8192f32).log2() as u32));
+ assert_eq!(32768u16.checked_ilog2(), Some((32768f32).log2() as u32));
+ assert_eq!(8192i16.checked_ilog2(), Some((8192f32).log2() as u32));
+
for i in 1..=u8::MAX {
assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32), "checking {i}");
}
@@ -77,15 +78,6 @@ fn checked_ilog2() {
}
}
-// Validate cases that fail on Android's imprecise float ilog2 implementation.
-#[test]
-#[cfg(not(target_os = "android"))]
-fn checked_ilog2_not_android() {
- assert_eq!(8192u16.checked_ilog2(), Some((8192f32).log2() as u32));
- assert_eq!(32768u16.checked_ilog2(), Some((32768f32).log2() as u32));
- assert_eq!(8192i16.checked_ilog2(), Some((8192f32).log2() as u32));
-}
-
#[test]
fn checked_ilog10() {
assert_eq!(0u8.checked_ilog10(), None);
diff --git a/library/profiler_builtins/build.rs b/library/profiler_builtins/build.rs
index c1e0e5c1c897..dd85239fa8cf 100644
--- a/library/profiler_builtins/build.rs
+++ b/library/profiler_builtins/build.rs
@@ -1,14 +1,15 @@
//! Compiles the profiler part of the `compiler-rt` library.
//!
-//! See the build.rs for libcompiler_builtins crate for details.
+//! Loosely based on:
+//! - LLVM's `compiler-rt/lib/profile/CMakeLists.txt`
+//! - .
use std::env;
use std::path::PathBuf;
fn main() {
- println!("cargo:rerun-if-env-changed=LLVM_PROFILER_RT_LIB");
- if let Ok(rt) = env::var("LLVM_PROFILER_RT_LIB") {
- println!("cargo:rustc-link-lib=static:+verbatim={rt}");
+ if let Ok(rt) = tracked_env_var("LLVM_PROFILER_RT_LIB") {
+ println!("cargo::rustc-link-lib=static:+verbatim={rt}");
return;
}
@@ -16,13 +17,13 @@ fn main() {
let target_env = env::var("CARGO_CFG_TARGET_ENV").expect("CARGO_CFG_TARGET_ENV was not set");
let cfg = &mut cc::Build::new();
- // FIXME: `rerun-if-changed` directives are not currently emitted and the build script
- // will not rerun on changes in these source files or headers included into them.
- let mut profile_sources = vec![
+ let profile_sources = vec![
+ // tidy-alphabetical-start
"GCDAProfiling.c",
"InstrProfiling.c",
"InstrProfilingBuffer.c",
"InstrProfilingFile.c",
+ "InstrProfilingInternal.c",
"InstrProfilingMerge.c",
"InstrProfilingMergeFile.c",
"InstrProfilingNameVar.c",
@@ -37,15 +38,13 @@ fn main() {
"InstrProfilingValue.c",
"InstrProfilingVersionVar.c",
"InstrProfilingWriter.c",
- // These files were added in LLVM 11.
- "InstrProfilingInternal.c",
- "InstrProfilingBiasVar.c",
+ "WindowsMMap.c",
+ // tidy-alphabetical-end
];
if target_env == "msvc" {
// Don't pull in extra libraries on MSVC
cfg.flag("/Zl");
- profile_sources.push("WindowsMMap.c");
cfg.define("strdup", Some("_strdup"));
cfg.define("open", Some("_open"));
cfg.define("fdopen", Some("_fdopen"));
@@ -60,8 +59,6 @@ fn main() {
if target_os != "windows" {
cfg.flag("-fvisibility=hidden");
cfg.define("COMPILER_RT_HAS_UNAME", Some("1"));
- } else {
- profile_sources.push("WindowsMMap.c");
}
}
@@ -80,26 +77,33 @@ fn main() {
}
// Get the LLVM `compiler-rt` directory from bootstrap.
- println!("cargo:rerun-if-env-changed=RUST_COMPILER_RT_FOR_PROFILER");
- let root = PathBuf::from(env::var("RUST_COMPILER_RT_FOR_PROFILER").unwrap_or_else(|_| {
- let path = "../../src/llvm-project/compiler-rt";
- println!("RUST_COMPILER_RT_FOR_PROFILER was not set; falling back to {path:?}");
- path.to_owned()
- }));
+ let root = PathBuf::from(tracked_env_var_or_fallback(
+ "RUST_COMPILER_RT_FOR_PROFILER",
+ "../../src/llvm-project/compiler-rt",
+ ));
let src_root = root.join("lib").join("profile");
assert!(src_root.exists(), "profiler runtime source directory not found: {src_root:?}");
- let mut n_sources_found = 0u32;
- for src in profile_sources {
- let path = src_root.join(src);
- if path.exists() {
- cfg.file(path);
- n_sources_found += 1;
- }
+ println!("cargo::rerun-if-changed={}", src_root.display());
+ for file in profile_sources {
+ cfg.file(src_root.join(file));
}
- assert!(n_sources_found > 0, "couldn't find any profiler runtime source files in {src_root:?}");
- cfg.include(root.join("include"));
+ let include = root.join("include");
+ println!("cargo::rerun-if-changed={}", include.display());
+ cfg.include(include);
+
cfg.warnings(false);
cfg.compile("profiler-rt");
}
+
+fn tracked_env_var(key: &str) -> Result {
+ println!("cargo::rerun-if-env-changed={key}");
+ env::var(key)
+}
+fn tracked_env_var_or_fallback(key: &str, fallback: &str) -> String {
+ tracked_env_var(key).unwrap_or_else(|_| {
+ println!("cargo::warning={key} was not set; falling back to {fallback:?}");
+ fallback.to_owned()
+ })
+}
diff --git a/library/std/src/io/buffered/bufreader.rs b/library/std/src/io/buffered/bufreader.rs
index 0b12e5777c84..cf226bd28d00 100644
--- a/library/std/src/io/buffered/bufreader.rs
+++ b/library/std/src/io/buffered/bufreader.rs
@@ -94,7 +94,9 @@ impl BufReader {
pub fn with_capacity(capacity: usize, inner: R) -> BufReader {
BufReader { inner, buf: Buffer::with_capacity(capacity) }
}
+}
+impl BufReader {
/// Attempt to look ahead `n` bytes.
///
/// `n` must be less than `capacity`.
diff --git a/library/std/src/sys/pal/wasi/thread.rs b/library/std/src/sys/pal/wasi/thread.rs
index 31c9cbd4699b..4b83870fdea6 100644
--- a/library/std/src/sys/pal/wasi/thread.rs
+++ b/library/std/src/sys/pal/wasi/thread.rs
@@ -136,36 +136,37 @@ impl Thread {
}
pub fn sleep(dur: Duration) {
- let nanos = dur.as_nanos();
- assert!(nanos <= u64::MAX as u128);
+ let mut nanos = dur.as_nanos();
+ while nanos > 0 {
+ const USERDATA: wasi::Userdata = 0x0123_45678;
- const USERDATA: wasi::Userdata = 0x0123_45678;
+ let clock = wasi::SubscriptionClock {
+ id: wasi::CLOCKID_MONOTONIC,
+ timeout: u64::try_from(nanos).unwrap_or(u64::MAX),
+ precision: 0,
+ flags: 0,
+ };
+ nanos -= u128::from(clock.timeout);
- let clock = wasi::SubscriptionClock {
- id: wasi::CLOCKID_MONOTONIC,
- timeout: nanos as u64,
- precision: 0,
- flags: 0,
- };
-
- let in_ = wasi::Subscription {
- userdata: USERDATA,
- u: wasi::SubscriptionU { tag: 0, u: wasi::SubscriptionUU { clock } },
- };
- unsafe {
- let mut event: wasi::Event = mem::zeroed();
- let res = wasi::poll_oneoff(&in_, &mut event, 1);
- match (res, event) {
- (
- Ok(1),
- wasi::Event {
- userdata: USERDATA,
- error: wasi::ERRNO_SUCCESS,
- type_: wasi::EVENTTYPE_CLOCK,
- ..
- },
- ) => {}
- _ => panic!("thread::sleep(): unexpected result of poll_oneoff"),
+ let in_ = wasi::Subscription {
+ userdata: USERDATA,
+ u: wasi::SubscriptionU { tag: 0, u: wasi::SubscriptionUU { clock } },
+ };
+ unsafe {
+ let mut event: wasi::Event = mem::zeroed();
+ let res = wasi::poll_oneoff(&in_, &mut event, 1);
+ match (res, event) {
+ (
+ Ok(1),
+ wasi::Event {
+ userdata: USERDATA,
+ error: wasi::ERRNO_SUCCESS,
+ type_: wasi::EVENTTYPE_CLOCK,
+ ..
+ },
+ ) => {}
+ _ => panic!("thread::sleep(): unexpected result of poll_oneoff"),
+ }
}
}
}
diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs
index cc01afd4c18c..84a6b26a491e 100644
--- a/src/bootstrap/src/core/build_steps/test.rs
+++ b/src/bootstrap/src/core/build_steps/test.rs
@@ -14,9 +14,8 @@ use crate::core::build_steps::synthetic_targets::MirOptPanicAbortSyntheticTarget
use crate::core::build_steps::tool::{self, SourceType, Tool};
use crate::core::build_steps::toolstate::ToolState;
use crate::core::build_steps::{compile, dist, llvm};
-use crate::core::builder;
use crate::core::builder::{
- crate_description, Builder, Compiler, Kind, RunConfig, ShouldRun, Step,
+ self, crate_description, Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step,
};
use crate::core::config::flags::{get_completion, Subcommand};
use crate::core::config::TargetSelection;
@@ -2435,18 +2434,14 @@ impl Step for CrateLibrustc {
const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
- run.crate_or_deps("rustc-main")
+ run.crate_or_deps("rustc-main").path("compiler")
}
fn make_run(run: RunConfig<'_>) {
let builder = run.builder;
let host = run.build_triple();
let compiler = builder.compiler_for(builder.top_stage, host, host);
- let crates = run
- .paths
- .iter()
- .map(|p| builder.crate_paths[&p.assert_single_path().path].clone())
- .collect();
+ let crates = run.make_run_crates(Alias::Compiler);
builder.ensure(CrateLibrustc { compiler, target: run.target, crates });
}
diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs
index c42d4c56c381..60ec57d0d443 100644
--- a/src/bootstrap/src/core/sanity.rs
+++ b/src/bootstrap/src/core/sanity.rs
@@ -8,9 +8,7 @@
//! In theory if we get past this phase it's a bug if a build fails, but in
//! practice that's likely not true!
-use std::collections::HashMap;
-#[cfg(not(feature = "bootstrap-self-test"))]
-use std::collections::HashSet;
+use std::collections::{HashMap, HashSet};
use std::ffi::{OsStr, OsString};
use std::path::PathBuf;
use std::{env, fs};
@@ -34,7 +32,6 @@ pub struct Finder {
// it might not yet be included in stage0. In such cases, we handle the targets missing from stage0 in this list.
//
// Targets can be removed from this list once they are present in the stage0 compiler (usually by updating the beta compiler of the bootstrap).
-#[cfg(not(feature = "bootstrap-self-test"))]
const STAGE0_MISSING_TARGETS: &[&str] = &[
// just a dummy comment so the list doesn't get onelined
];
@@ -205,7 +202,6 @@ than building it.
.map(|p| cmd_finder.must_have(p))
.or_else(|| cmd_finder.maybe_have("reuse"));
- #[cfg(not(feature = "bootstrap-self-test"))]
let stage0_supported_target_list: HashSet = crate::utils::helpers::output(
command(&build.config.initial_rustc).args(["--print", "target-list"]).as_command_mut(),
)
@@ -234,8 +230,7 @@ than building it.
}
// Ignore fake targets that are only used for unit tests in bootstrap.
- #[cfg(not(feature = "bootstrap-self-test"))]
- {
+ if cfg!(not(feature = "bootstrap-self-test")) && !skip_target_sanity {
let mut has_target = false;
let target_str = target.to_string();
diff --git a/src/ci/scripts/dump-environment.sh b/src/ci/scripts/dump-environment.sh
index 812690181e9b..7afaa472f6e3 100755
--- a/src/ci/scripts/dump-environment.sh
+++ b/src/ci/scripts/dump-environment.sh
@@ -15,9 +15,7 @@ df -h
echo
echo "biggest files in the working dir:"
-set +o pipefail
-du . | sort -nr | head -n100
-set -o pipefail
+du . | sort -n | tail -n100 | sort -nr # because piping sort to head gives a broken pipe
echo
if isMacOS
diff --git a/src/ci/scripts/select-xcode.sh b/src/ci/scripts/select-xcode.sh
index 569c4a4136d9..d635d4384727 100755
--- a/src/ci/scripts/select-xcode.sh
+++ b/src/ci/scripts/select-xcode.sh
@@ -1,5 +1,6 @@
#!/bin/bash
# This script selects the Xcode instance to use.
+# It also tries to do some cleanup in CI jobs of unused Xcodes.
set -euo pipefail
IFS=$'\n\t'
@@ -7,5 +8,21 @@ IFS=$'\n\t'
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
if isMacOS; then
+ # This additional step is to try to remove an Xcode we aren't using because each one is HUGE
+ old_xcode="$(xcode-select --print-path)"
+ old_xcode="${old_xcode%/*}" # pop a dir
+ old_xcode="${old_xcode%/*}" # twice
+ if [[ $old_xcode =~ $SELECT_XCODE ]]; then
+ echo "xcode-select.sh's brutal hack may not be necessary?"
+ exit 1
+ elif [[ $SELECT_XCODE =~ "16" ]]; then
+ echo "Using Xcode 16? Please fix xcode-select.sh"
+ exit 1
+ fi
+ if [ $CI ]; then # just in case someone sources this on their real computer
+ sudo rm -rf "${old_xcode}"
+ xcode_16="${old_xcode%/*}/Xcode-16.0.0.app"
+ sudo rm -rf "${xcode_16}"
+ fi
sudo xcode-select -s "${SELECT_XCODE}"
fi
diff --git a/src/ci/scripts/upload-artifacts.sh b/src/ci/scripts/upload-artifacts.sh
index c9c85ec20b45..61c187fa77c0 100755
--- a/src/ci/scripts/upload-artifacts.sh
+++ b/src/ci/scripts/upload-artifacts.sh
@@ -19,18 +19,18 @@ fi
if [[ "${DEPLOY-0}" -eq "1" ]] || [[ "${DEPLOY_ALT-0}" -eq "1" ]]; then
dist_dir="${build_dir}/dist"
rm -rf "${dist_dir}/doc"
- cp -r "${dist_dir}"/* "${upload_dir}"
+ mv "${dist_dir}"/* "${upload_dir}"
fi
# CPU usage statistics.
-cp build/cpu-usage.csv "${upload_dir}/cpu-${CI_JOB_NAME}.csv"
+mv build/cpu-usage.csv "${upload_dir}/cpu-${CI_JOB_NAME}.csv"
# Build metrics generated by x.py.
-cp "${build_dir}/metrics.json" "${upload_dir}/metrics-${CI_JOB_NAME}.json"
+mv "${build_dir}/metrics.json" "${upload_dir}/metrics-${CI_JOB_NAME}.json"
# Toolstate data.
if [[ -n "${DEPLOY_TOOLSTATES_JSON+x}" ]]; then
- cp /tmp/toolstate/toolstates.json "${upload_dir}/${DEPLOY_TOOLSTATES_JSON}"
+ mv /tmp/toolstate/toolstates.json "${upload_dir}/${DEPLOY_TOOLSTATES_JSON}"
fi
echo "Files that will be uploaded:"
@@ -55,7 +55,7 @@ then
echo "# CI artifacts" >> "${GITHUB_STEP_SUMMARY}"
for filename in "${upload_dir}"/*.xz; do
- filename=`basename "${filename}"`
+ filename=$(basename "${filename}")
echo "- [${filename}](${access_url}/${filename})" >> "${GITHUB_STEP_SUMMARY}"
done
fi
diff --git a/src/doc/rustc/src/command-line-arguments.md b/src/doc/rustc/src/command-line-arguments.md
index fa23e3e414d9..e5631ba42741 100644
--- a/src/doc/rustc/src/command-line-arguments.md
+++ b/src/doc/rustc/src/command-line-arguments.md
@@ -47,7 +47,7 @@ KIND=PATH` where `KIND` may be one of:
directory.
- `native` — Only search for native libraries in this directory.
- `framework` — Only search for macOS frameworks in this directory.
-- `all` — Search for all library kinds in this directory. This is the default
+- `all` — Search for all library kinds in this directory, except frameworks. This is the default
if `KIND` is not specified.
diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs
index 577b10a31ae4..654901080278 100644
--- a/src/librustdoc/clean/auto_trait.rs
+++ b/src/librustdoc/clean/auto_trait.rs
@@ -7,6 +7,7 @@ use rustc_span::def_id::DefId;
use rustc_span::symbol::{kw, Symbol};
use rustc_trait_selection::traits::auto_trait::{self, RegionTarget};
use thin_vec::ThinVec;
+use tracing::{debug, instrument};
use crate::clean::{
self, clean_generic_param_def, clean_middle_ty, clean_predicate,
diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl.rs
index 96e7f5c61c3e..1f5f6602b9f2 100644
--- a/src/librustdoc/clean/blanket_impl.rs
+++ b/src/librustdoc/clean/blanket_impl.rs
@@ -6,6 +6,7 @@ use rustc_span::def_id::DefId;
use rustc_span::DUMMY_SP;
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
use thin_vec::ThinVec;
+use tracing::{debug, instrument, trace};
use crate::clean;
use crate::clean::{
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs
index 962a5a05737f..d22c4cc4b76b 100644
--- a/src/librustdoc/clean/inline.rs
+++ b/src/librustdoc/clean/inline.rs
@@ -14,6 +14,7 @@ use rustc_span::def_id::LOCAL_CRATE;
use rustc_span::hygiene::MacroKind;
use rustc_span::symbol::{sym, Symbol};
use thin_vec::{thin_vec, ThinVec};
+use tracing::{debug, trace};
use {rustc_ast as ast, rustc_hir as hir};
use super::Item;
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 3cb02f379e4f..710bd4a5fdff 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -52,6 +52,7 @@ use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::ExpnKind;
use rustc_trait_selection::traits::wf::object_region_bounds;
use thin_vec::ThinVec;
+use tracing::{debug, instrument};
use utils::*;
use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir};
diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs
index b59f939025e1..b8db82e540c6 100644
--- a/src/librustdoc/clean/simplify.rs
+++ b/src/librustdoc/clean/simplify.rs
@@ -14,7 +14,6 @@
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::unord::UnordSet;
use rustc_hir::def_id::DefId;
-use rustc_middle::ty;
use thin_vec::ThinVec;
use crate::clean;
@@ -113,18 +112,9 @@ fn trait_is_same_or_supertrait(cx: &DocContext<'_>, child: DefId, trait_: DefId)
return true;
}
let predicates = cx.tcx.explicit_super_predicates_of(child);
- debug_assert!(cx.tcx.generics_of(child).has_self);
- let self_ty = cx.tcx.types.self_param;
predicates
- .predicates
- .iter()
- .filter_map(|(pred, _)| {
- if let ty::ClauseKind::Trait(pred) = pred.kind().skip_binder() {
- if pred.trait_ref.self_ty() == self_ty { Some(pred.def_id()) } else { None }
- } else {
- None
- }
- })
+ .iter_identity_copied()
+ .filter_map(|(pred, _)| Some(pred.as_trait_clause()?.def_id()))
.any(|did| trait_is_same_or_supertrait(cx, did, trait_))
}
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs
index 51da252da24e..58fcfc4ed8df 100644
--- a/src/librustdoc/clean/types.rs
+++ b/src/librustdoc/clean/types.rs
@@ -31,6 +31,7 @@ use rustc_span::{FileName, Loc, DUMMY_SP};
use rustc_target::abi::VariantIdx;
use rustc_target::spec::abi::Abi;
use thin_vec::ThinVec;
+use tracing::{debug, trace};
use {rustc_ast as ast, rustc_hir as hir};
pub(crate) use self::ItemKind::*;
diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs
index d826171aa61c..5686307d83dd 100644
--- a/src/librustdoc/clean/utils.rs
+++ b/src/librustdoc/clean/utils.rs
@@ -11,6 +11,7 @@ use rustc_middle::mir;
use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, TyCtxt, TypeVisitableExt};
use rustc_span::symbol::{kw, sym, Symbol};
use thin_vec::{thin_vec, ThinVec};
+use tracing::{debug, warn};
use {rustc_ast as ast, rustc_hir as hir};
use crate::clean::auto_trait::synthesize_auto_trait_impls;
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs
index 760514f40fda..2cde0ac5c535 100644
--- a/src/librustdoc/core.rs
+++ b/src/librustdoc/core.rs
@@ -25,6 +25,7 @@ pub(crate) use rustc_session::config::{Options, UnstableOptions};
use rustc_session::{lint, Session};
use rustc_span::symbol::sym;
use rustc_span::{source_map, Span};
+use tracing::{debug, info};
use crate::clean::inline::build_external_trait;
use crate::clean::{self, ItemId};
diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs
index 1ae66fddda62..8b6588ea75c8 100644
--- a/src/librustdoc/doctest.rs
+++ b/src/librustdoc/doctest.rs
@@ -26,6 +26,7 @@ use rustc_span::symbol::sym;
use rustc_span::FileName;
use rustc_target::spec::{Target, TargetTriple};
use tempfile::{Builder as TempFileBuilder, TempDir};
+use tracing::debug;
use self::rust::HirCollector;
use crate::config::Options as RustdocOptions;
diff --git a/src/librustdoc/doctest/make.rs b/src/librustdoc/doctest/make.rs
index 9de312a413a4..f4d9b78cc32a 100644
--- a/src/librustdoc/doctest/make.rs
+++ b/src/librustdoc/doctest/make.rs
@@ -14,6 +14,7 @@ use rustc_span::edition::Edition;
use rustc_span::source_map::SourceMap;
use rustc_span::symbol::sym;
use rustc_span::FileName;
+use tracing::debug;
use super::GlobalTestOptions;
use crate::html::markdown::LangString;
diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs
index 90942d87f728..c5e2b33ccf87 100644
--- a/src/librustdoc/formats/cache.rs
+++ b/src/librustdoc/formats/cache.rs
@@ -4,6 +4,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet};
use rustc_middle::ty::{self, TyCtxt};
use rustc_span::Symbol;
+use tracing::debug;
use crate::clean::types::ExternalLocation;
use crate::clean::{self, ExternalCrate, ItemId, PrimitiveType};
diff --git a/src/librustdoc/formats/renderer.rs b/src/librustdoc/formats/renderer.rs
index 2535668b83f5..cc57dca86c34 100644
--- a/src/librustdoc/formats/renderer.rs
+++ b/src/librustdoc/formats/renderer.rs
@@ -1,4 +1,5 @@
use rustc_middle::ty::TyCtxt;
+use tracing::debug;
use crate::clean;
use crate::config::RenderOptions;
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index 530241f9a137..cf362272d7de 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -24,6 +24,7 @@ use rustc_middle::ty::TyCtxt;
use rustc_span::symbol::kw;
use rustc_span::{sym, Symbol};
use rustc_target::spec::abi::Abi;
+use tracing::{debug, trace};
use {rustc_ast as ast, rustc_hir as hir};
use super::url_parts_builder::{estimate_item_path_byte_length, UrlPartsBuilder};
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index 364d4e077b18..e37c24c1438e 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -46,6 +46,7 @@ pub(crate) use rustc_resolve::rustdoc::main_body_opts;
use rustc_resolve::rustdoc::may_be_doc_link;
use rustc_span::edition::Edition;
use rustc_span::{Span, Symbol};
+use tracing::{debug, trace};
use crate::clean::RenderedLink;
use crate::doctest;
diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs
index 0ed8921b1e8d..19386fe5e69e 100644
--- a/src/librustdoc/html/render/context.rs
+++ b/src/librustdoc/html/render/context.rs
@@ -12,6 +12,7 @@ use rustc_middle::ty::TyCtxt;
use rustc_session::Session;
use rustc_span::edition::Edition;
use rustc_span::{sym, FileName, Symbol};
+use tracing::info;
use super::print_item::{full_path, item_path, print_item};
use super::sidebar::{print_sidebar, sidebar_module_like, Sidebar};
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index 47f321a4c4a2..fc4033f83204 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -57,6 +57,7 @@ use rustc_span::symbol::{sym, Symbol};
use rustc_span::{BytePos, FileName, RealFileName, DUMMY_SP};
use serde::ser::SerializeMap;
use serde::{Serialize, Serializer};
+use tracing::{debug, info};
pub(crate) use self::context::*;
pub(crate) use self::span_map::{collect_spans_and_sources, LinkFromSrc};
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index d8b111471b85..a0a72d59d123 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -15,6 +15,7 @@ use rustc_middle::ty::{self, TyCtxt};
use rustc_span::hygiene::MacroKind;
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_target::abi::VariantIdx;
+use tracing::{debug, info};
use super::type_layout::document_type_layout;
use super::{
diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs
index d7682bd1c191..bfdf457c529d 100644
--- a/src/librustdoc/html/render/search_index.rs
+++ b/src/librustdoc/html/render/search_index.rs
@@ -11,6 +11,7 @@ use rustc_span::sym;
use rustc_span::symbol::{kw, Symbol};
use serde::ser::{Serialize, SerializeSeq, SerializeStruct, Serializer};
use thin_vec::ThinVec;
+use tracing::instrument;
use crate::clean;
use crate::clean::types::{Function, Generics, ItemId, Type, WherePredicate};
diff --git a/src/librustdoc/html/render/sidebar.rs b/src/librustdoc/html/render/sidebar.rs
index 101cc839f098..5b9c93ef74aa 100644
--- a/src/librustdoc/html/render/sidebar.rs
+++ b/src/librustdoc/html/render/sidebar.rs
@@ -6,6 +6,7 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_hir::def::CtorKind;
use rustc_hir::def_id::DefIdSet;
use rustc_middle::ty::{self, TyCtxt};
+use tracing::debug;
use super::{item_ty_to_section, Context, ItemSection};
use crate::clean;
diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs
index 22f115f92cc8..ae65dd76b5fb 100644
--- a/src/librustdoc/html/sources.rs
+++ b/src/librustdoc/html/sources.rs
@@ -11,6 +11,7 @@ use rustc_hir::def_id::LOCAL_CRATE;
use rustc_middle::ty::TyCtxt;
use rustc_session::Session;
use rustc_span::{sym, FileName};
+use tracing::info;
use crate::clean;
use crate::clean::utils::has_doc_flag;
diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js
index 75f2a1418cd8..c3e219f2c87b 100644
--- a/src/librustdoc/html/static/js/main.js
+++ b/src/librustdoc/html/static/js/main.js
@@ -1878,9 +1878,15 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
if (elem === null) {
return;
}
- const buttons = elem.querySelector(".button-holder");
+ let buttons = elem.querySelector(".button-holder");
if (buttons === null) {
- return;
+ // On mobile, you can't hover an element so buttons need to be created on click
+ // if they're not already there.
+ addCopyButton(event);
+ buttons = elem.querySelector(".button-holder");
+ if (buttons === null) {
+ return;
+ }
}
buttons.classList.toggle("keep-visible");
}
diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js
index be0ec425946c..6f575e60ed42 100644
--- a/src/librustdoc/html/static/js/search.js
+++ b/src/librustdoc/html/static/js/search.js
@@ -16,6 +16,7 @@ if (!Array.prototype.toSpliced) {
}
(function() {
+// ==================== Core search logic begin ====================
// This mapping table should match the discriminants of
// `rustdoc::formats::item_type::ItemType` type in Rust.
const itemTypes = [
@@ -48,35 +49,6 @@ const itemTypes = [
"generic",
];
-const longItemTypes = [
- "keyword",
- "primitive type",
- "module",
- "extern crate",
- "re-export",
- "struct",
- "enum",
- "function",
- "type alias",
- "static",
- "trait",
- "",
- "trait method",
- "method",
- "struct field",
- "enum variant",
- "macro",
- "assoc type",
- "constant",
- "assoc const",
- "union",
- "foreign type",
- "existential type",
- "attribute macro",
- "derive macro",
- "trait alias",
-];
-
// used for special search precedence
const TY_GENERIC = itemTypes.indexOf("generic");
const TY_IMPORT = itemTypes.indexOf("import");
@@ -93,44 +65,8 @@ const UNBOXING_LIMIT = 5;
const REGEX_IDENT = /\p{ID_Start}\p{ID_Continue}*|_\p{ID_Continue}+/uy;
const REGEX_INVALID_TYPE_FILTER = /[^a-z]/ui;
-// In the search display, allows to switch between tabs.
-function printTab(nb) {
- let iter = 0;
- let foundCurrentTab = false;
- let foundCurrentResultSet = false;
- onEachLazy(document.getElementById("search-tabs").childNodes, elem => {
- if (nb === iter) {
- addClass(elem, "selected");
- foundCurrentTab = true;
- } else {
- removeClass(elem, "selected");
- }
- iter += 1;
- });
- const isTypeSearch = (nb > 0 || iter === 1);
- iter = 0;
- onEachLazy(document.getElementById("results").childNodes, elem => {
- if (nb === iter) {
- addClass(elem, "active");
- foundCurrentResultSet = true;
- } else {
- removeClass(elem, "active");
- }
- iter += 1;
- });
- if (foundCurrentTab && foundCurrentResultSet) {
- searchState.currentTab = nb;
- // Corrections only kick in on type-based searches.
- const correctionsElem = document.getElementsByClassName("search-corrections");
- if (isTypeSearch) {
- removeClass(correctionsElem[0], "hidden");
- } else {
- addClass(correctionsElem[0], "hidden");
- }
- } else if (nb !== 0) {
- printTab(0);
- }
-}
+const MAX_RESULTS = 200;
+const NO_TYPE_FILTER = -1;
/**
* The [edit distance] is a metric for measuring the difference between two strings.
@@ -240,75 +176,1016 @@ function editDistance(a, b, limit) {
return editDistanceState.calculate(a, b, limit);
}
-function initSearch(rawSearchIndex) {
- const MAX_RESULTS = 200;
- const NO_TYPE_FILTER = -1;
- /**
- * @type {Array}
- */
- let searchIndex;
- /**
- * @type {Map}
- */
- let searchIndexDeprecated;
- /**
- * @type {Map}
- */
- let searchIndexEmptyDesc;
- /**
- * @type {Uint32Array}
- */
- let functionTypeFingerprint;
- let currentResults;
- /**
- * Map from normalized type names to integers. Used to make type search
- * more efficient.
- *
- * @type {Map}
- */
- const typeNameIdMap = new Map();
- const ALIASES = new Map();
+function isEndCharacter(c) {
+ return "=,>-])".indexOf(c) !== -1;
+}
- /**
- * Special type name IDs for searching by array.
- */
- const typeNameIdOfArray = buildTypeMapIndex("array");
- /**
- * Special type name IDs for searching by slice.
- */
- const typeNameIdOfSlice = buildTypeMapIndex("slice");
- /**
- * Special type name IDs for searching by both array and slice (`[]` syntax).
- */
- const typeNameIdOfArrayOrSlice = buildTypeMapIndex("[]");
- /**
- * Special type name IDs for searching by tuple.
- */
- const typeNameIdOfTuple = buildTypeMapIndex("tuple");
- /**
- * Special type name IDs for searching by unit.
- */
- const typeNameIdOfUnit = buildTypeMapIndex("unit");
- /**
- * Special type name IDs for searching by both tuple and unit (`()` syntax).
- */
- const typeNameIdOfTupleOrUnit = buildTypeMapIndex("()");
- /**
- * Special type name IDs for searching `fn`.
- */
- const typeNameIdOfFn = buildTypeMapIndex("fn");
- /**
- * Special type name IDs for searching `fnmut`.
- */
- const typeNameIdOfFnMut = buildTypeMapIndex("fnmut");
- /**
- * Special type name IDs for searching `fnonce`.
- */
- const typeNameIdOfFnOnce = buildTypeMapIndex("fnonce");
- /**
- * Special type name IDs for searching higher order functions (`->` syntax).
- */
- const typeNameIdOfHof = buildTypeMapIndex("->");
+/**
+ * Returns `true` if the given `c` character is a separator.
+ *
+ * @param {string} c
+ *
+ * @return {boolean}
+ */
+function isSeparatorCharacter(c) {
+ return c === "," || c === "=";
+}
+
+/**
+ * Returns `true` if the current parser position is starting with "->".
+ *
+ * @param {ParserState} parserState
+ *
+ * @return {boolean}
+ */
+function isReturnArrow(parserState) {
+ return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) === "->";
+}
+
+/**
+ * Increase current parser position until it doesn't find a whitespace anymore.
+ *
+ * @param {ParserState} parserState
+ */
+function skipWhitespace(parserState) {
+ while (parserState.pos < parserState.userQuery.length) {
+ const c = parserState.userQuery[parserState.pos];
+ if (c !== " ") {
+ break;
+ }
+ parserState.pos += 1;
+ }
+}
+
+/**
+ * Returns `true` if the previous character is `lookingFor`.
+ *
+ * @param {ParserState} parserState
+ * @param {String} lookingFor
+ *
+ * @return {boolean}
+ */
+function prevIs(parserState, lookingFor) {
+ let pos = parserState.pos;
+ while (pos > 0) {
+ const c = parserState.userQuery[pos - 1];
+ if (c === lookingFor) {
+ return true;
+ } else if (c !== " ") {
+ break;
+ }
+ pos -= 1;
+ }
+ return false;
+}
+
+/**
+ * Returns `true` if the last element in the `elems` argument has generics.
+ *
+ * @param {Array} elems
+ * @param {ParserState} parserState
+ *
+ * @return {boolean}
+ */
+function isLastElemGeneric(elems, parserState) {
+ return (elems.length > 0 && elems[elems.length - 1].generics.length > 0) ||
+ prevIs(parserState, ">");
+}
+
+function getFilteredNextElem(query, parserState, elems, isInGenerics) {
+ const start = parserState.pos;
+ if (parserState.userQuery[parserState.pos] === ":" && !isPathStart(parserState)) {
+ throw ["Expected type filter before ", ":"];
+ }
+ getNextElem(query, parserState, elems, isInGenerics);
+ if (parserState.userQuery[parserState.pos] === ":" && !isPathStart(parserState)) {
+ if (parserState.typeFilter !== null) {
+ throw [
+ "Unexpected ",
+ ":",
+ " (expected path after type filter ",
+ parserState.typeFilter + ":",
+ ")",
+ ];
+ }
+ if (elems.length === 0) {
+ throw ["Expected type filter before ", ":"];
+ } else if (query.literalSearch) {
+ throw ["Cannot use quotes on type filter"];
+ }
+ // The type filter doesn't count as an element since it's a modifier.
+ const typeFilterElem = elems.pop();
+ checkExtraTypeFilterCharacters(start, parserState);
+ parserState.typeFilter = typeFilterElem.name;
+ parserState.pos += 1;
+ parserState.totalElems -= 1;
+ query.literalSearch = false;
+ getNextElem(query, parserState, elems, isInGenerics);
+ }
+}
+
+/**
+ * This function parses the next query element until it finds `endChar`,
+ * calling `getNextElem` to collect each element.
+ *
+ * If there is no `endChar`, this function will implicitly stop at the end
+ * without raising an error.
+ *
+ * @param {ParsedQuery} query
+ * @param {ParserState} parserState
+ * @param {Array} elems - This is where the new {QueryElement} will be added.
+ * @param {string} endChar - This function will stop when it'll encounter this
+ * character.
+ * @returns {{foundSeparator: bool}}
+ */
+function getItemsBefore(query, parserState, elems, endChar) {
+ let foundStopChar = true;
+ let foundSeparator = false;
+
+ // If this is a generic, keep the outer item's type filter around.
+ const oldTypeFilter = parserState.typeFilter;
+ parserState.typeFilter = null;
+ const oldIsInBinding = parserState.isInBinding;
+ parserState.isInBinding = null;
+
+ // ML-style Higher Order Function notation
+ //
+ // a way to search for any closure or fn pointer regardless of
+ // which closure trait is used
+ //
+ // Looks like this:
+ //
+ // `option, (t -> u) -> option`
+ // ^^^^^^
+ //
+ // The Rust-style closure notation is implemented in getNextElem
+ let hofParameters = null;
+
+ let extra = "";
+ if (endChar === ">") {
+ extra = "<";
+ } else if (endChar === "]") {
+ extra = "[";
+ } else if (endChar === ")") {
+ extra = "(";
+ } else if (endChar === "") {
+ extra = "->";
+ } else {
+ extra = endChar;
+ }
+
+ while (parserState.pos < parserState.length) {
+ const c = parserState.userQuery[parserState.pos];
+ if (c === endChar) {
+ if (parserState.isInBinding) {
+ throw ["Unexpected ", endChar, " after ", "="];
+ }
+ break;
+ } else if (endChar !== "" && isReturnArrow(parserState)) {
+ // ML-style HOF notation only works when delimited in something,
+ // otherwise a function arrow starts the return type of the top
+ if (parserState.isInBinding) {
+ throw ["Unexpected ", "->", " after ", "="];
+ }
+ hofParameters = [...elems];
+ elems.length = 0;
+ parserState.pos += 2;
+ foundStopChar = true;
+ foundSeparator = false;
+ continue;
+ } else if (c === " ") {
+ parserState.pos += 1;
+ continue;
+ } else if (isSeparatorCharacter(c)) {
+ parserState.pos += 1;
+ foundStopChar = true;
+ foundSeparator = true;
+ continue;
+ } else if (c === ":" && isPathStart(parserState)) {
+ throw ["Unexpected ", "::", ": paths cannot start with ", "::"];
+ } else if (isEndCharacter(c)) {
+ throw ["Unexpected ", c, " after ", extra];
+ }
+ if (!foundStopChar) {
+ let extra = [];
+ if (isLastElemGeneric(query.elems, parserState)) {
+ extra = [" after ", ">"];
+ } else if (prevIs(parserState, "\"")) {
+ throw ["Cannot have more than one element if you use quotes"];
+ }
+ if (endChar !== "") {
+ throw [
+ "Expected ",
+ ",",
+ ", ",
+ "=",
+ ", or ",
+ endChar,
+ ...extra,
+ ", found ",
+ c,
+ ];
+ }
+ throw [
+ "Expected ",
+ ",",
+ " or ",
+ "=",
+ ...extra,
+ ", found ",
+ c,
+ ];
+ }
+ const posBefore = parserState.pos;
+ getFilteredNextElem(query, parserState, elems, endChar !== "");
+ if (endChar !== "" && parserState.pos >= parserState.length) {
+ throw ["Unclosed ", extra];
+ }
+ // This case can be encountered if `getNextElem` encountered a "stop character"
+ // right from the start. For example if you have `,,` or `<>`. In this case,
+ // we simply move up the current position to continue the parsing.
+ if (posBefore === parserState.pos) {
+ parserState.pos += 1;
+ }
+ foundStopChar = false;
+ }
+ if (parserState.pos >= parserState.length && endChar !== "") {
+ throw ["Unclosed ", extra];
+ }
+ // We are either at the end of the string or on the `endChar` character, let's move
+ // forward in any case.
+ parserState.pos += 1;
+
+ if (hofParameters) {
+ // Commas in a HOF don't cause wrapping parens to become a tuple.
+ // If you want a one-tuple with a HOF in it, write `((a -> b),)`.
+ foundSeparator = false;
+ // HOFs can't have directly nested bindings.
+ if ([...elems, ...hofParameters].some(x => x.bindingName)
+ || parserState.isInBinding) {
+ throw ["Unexpected ", "=", " within ", "->"];
+ }
+ // HOFs are represented the same way closures are.
+ // The arguments are wrapped in a tuple, and the output
+ // is a binding, even though the compiler doesn't technically
+ // represent fn pointers that way.
+ const hofElem = makePrimitiveElement("->", {
+ generics: hofParameters,
+ bindings: new Map([["output", [...elems]]]),
+ typeFilter: null,
+ });
+ elems.length = 0;
+ elems[0] = hofElem;
+ }
+
+ parserState.typeFilter = oldTypeFilter;
+ parserState.isInBinding = oldIsInBinding;
+
+ return { foundSeparator };
+}
+
+/**
+ * @param {ParsedQuery} query
+ * @param {ParserState} parserState
+ * @param {Array} elems - This is where the new {QueryElement} will be added.
+ * @param {boolean} isInGenerics
+ */
+function getNextElem(query, parserState, elems, isInGenerics) {
+ const generics = [];
+
+ skipWhitespace(parserState);
+ let start = parserState.pos;
+ let end;
+ if ("[(".indexOf(parserState.userQuery[parserState.pos]) !== -1) {
+ let endChar = ")";
+ let name = "()";
+ let friendlyName = "tuple";
+
+ if (parserState.userQuery[parserState.pos] === "[") {
+ endChar = "]";
+ name = "[]";
+ friendlyName = "slice";
+ }
+ parserState.pos += 1;
+ const { foundSeparator } = getItemsBefore(query, parserState, generics, endChar);
+ const typeFilter = parserState.typeFilter;
+ const bindingName = parserState.isInBinding;
+ parserState.typeFilter = null;
+ parserState.isInBinding = null;
+ for (const gen of generics) {
+ if (gen.bindingName !== null) {
+ throw ["Type parameter ", "=", ` cannot be within ${friendlyName} `, name];
+ }
+ }
+ if (name === "()" && !foundSeparator && generics.length === 1
+ && typeFilter === null) {
+ elems.push(generics[0]);
+ } else if (name === "()" && generics.length === 1 && generics[0].name === "->") {
+ // `primitive:(a -> b)` parser to `primitive:"->"