diff --git a/RELEASES.md b/RELEASES.md
index 81310c20c5ef9..940fa7c6072a9 100644
--- a/RELEASES.md
+++ b/RELEASES.md
@@ -1,3 +1,100 @@
+Version 1.98.0 (2026-08-20)
+==========================
+
+
+
+Language
+--------
+- [Allow shortening lifetime of `&mut` when unsize-coercing, even in an invariant position.](https://github.com/rust-lang/rust/pull/149219) For example, you can now coerce a `Cell<&'long mut i32>` to a `Cell<&'short mut dyn Send>`. Such shortenings were already previously allowed when coercing a `&mut` to a `&`, or coercing a `&` to a `&`.
+- [Add deny-by-default `invalid_runtime_symbol_definitions` lint and warn-by-default `suspicious_runtime_symbol_definitions` lint](https://github.com/rust-lang/rust/pull/155521)
+ - The lints currently specifically targets `core` runtime symbols like `memcmp`, `memset`, `strlen`, ... and is planned to be expanded in the next few releases.
+- [Add warn-by-default `c_void_returns` lint to check `core::ffi::c_void` as a return type](https://github.com/rust-lang/rust/pull/156379)
+
+
+
+
+Platform Support
+----------------
+- [Add `powerpc64-unknown-linux-gnuelfv2` as Tier 3](https://github.com/rust-lang/rust/pull/144220)
+- [Add `aarch64-unknown-linux-pauthtest` as Tier 3 target](https://github.com/rust-lang/rust/pull/155722)
+- [Promote `thumbv7a-none-eabi` to Tier 2](https://github.com/rust-lang/rust/pull/155763)
+- [Promote `thumbv7a-none-eabihf` to Tier 2](https://github.com/rust-lang/rust/pull/155763)
+- [Promote `thumbv7r-none-eabi` to Tier 2](https://github.com/rust-lang/rust/pull/155763)
+- [Promote `thumbv7r-none-eabihf` to Tier 2](https://github.com/rust-lang/rust/pull/155763)
+- [Promote `thumbv8r-none-eabihf` to Tier 2](https://github.com/rust-lang/rust/pull/155763)
+
+
+Refer to Rust's [platform support page][platform-support-doc]
+for more information on Rust's tiered platform support.
+
+[platform-support-doc]: https://doc.rust-lang.org/rustc/platform-support.html
+
+
+
+Libraries
+---------
+- [Change `Location<'_>` lifetime to `'static` in `Panic[Hook]Info`](https://github.com/rust-lang/rust/pull/146561)
+- [Document panic in `RangeInclusive::from(legacy::RangeInclusive)`](https://github.com/rust-lang/rust/pull/155421)
+- [Document that `ManuallyDrop`'s `Box` interaction has been fixed](https://github.com/rust-lang/rust/pull/155750)
+- [Stabilize LoongArch CRC Intrinsics](https://github.com/rust-lang/rust/issues/156908)
+- [The `derive` macro is available at `{core,std}::derive`.](https://github.com/rust-lang/rust/issues/154645) This was previously [unintentionally stabilized in 1.96](https://github.com/rust-lang/rust/issues/159856), but is now [explicitly accepted](https://github.com/rust-lang/rust/issues/154645) as a stabilized API.
+ - Please note that the MSRV for `{core,std}::derive` will be 1.96, and not 1.98.
+
+
+
+
+Stabilized APIs
+---------------
+
+- [`str::substr_range`](https://doc.rust-lang.org/stable/std/primitive.str.html#method.substr_range)
+- [`[T]::subslice_range`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.subslice_range)
+- [`core::fmt::NumBuffer`](https://doc.rust-lang.org/stable/core/fmt/struct.NumBuffer.html)
+- [`<{integer}>::format_into`](https://doc.rust-lang.org/stable/core/primitive.usize.html#method.format_into)
+- [`Send/Sync for std::process::CommandArgs`](https://doc.rust-lang.org/stable/std/process/struct.CommandArgs.html#impl-Send-for-CommandArgs%3C'a%3E)
+- [`{fN}::algebraic_add`](https://doc.rust-lang.org/stable/core/primitive.f32.html#method.algebraic_add)
+- [`{fN}::algebraic_sub`](https://doc.rust-lang.org/stable/core/primitive.f32.html#method.algebraic_sub)
+- [`{fN}::algebraic_mul`](https://doc.rust-lang.org/stable/core/primitive.f32.html#method.algebraic_mul)
+- [`{fN}::algebraic_div`](https://doc.rust-lang.org/stable/core/primitive.f32.html#method.algebraic_div)
+- [`{fN}::algebraic_rem`](https://doc.rust-lang.org/stable/core/primitive.f32.html#method.algebraic_rem)
+- [`NonZero<{integer}>::from_str_radix`](https://doc.rust-lang.org/stable/core/num/struct.NonZero.html#method.from_str_radix-4)
+- [`String::from_utf16le`](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.from_utf16le)
+- [`String::from_utf16le_lossy`](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.from_utf16le_lossy)
+- [`String::from_utf16be`](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.from_utf16be)
+- [`String::from_utf16be_lossy`](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.from_utf16be_lossy)
+- [`[T]::strip_circumfix`](https://doc.rust-lang.org/stable/core/primitive.slice.html#method.strip_circumfix)
+- [`str::strip_circumfix`](https://doc.rust-lang.org/stable/core/primitive.str.html#method.strip_circumfix)
+- [`Atomic::from_mut`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.Atomic.html#method.from_mut)
+- [`Atomic::get_mut_slice`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.Atomic.html#method.get_mut_slice)
+- [`Atomic::from_mut_slice`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.Atomic.html#method.from_mut_slice)
+- [`std::range::legacy`](https://doc.rust-lang.org/stable/std/range/legacy/index.html)
+
+
+
+
+Compatibility Notes
+-------------------
+- [If fully elided, lifetime bounds of trait object types may now resolve differently or even get rejected in very specific niche scenarios](https://github.com/rust-lang/rust/pull/129543)
+- [Error in more cases of ambiguous imports](https://github.com/rust-lang/rust/pull/145108)
+- [Switch the destructors implementation for thread locals on Windows to use Fiber Local Storage (FLS)](https://github.com/rust-lang/rust/pull/148799)
+- [Convert some cases of the `ambiguous_glob_imports` lint into a hard error](https://github.com/rust-lang/rust/pull/149195)
+- [Where-bounds of the form `Type = Type` and `Type == Type` are no longer syntactically allowed](https://github.com/rust-lang/rust/pull/153513)
+- [Ensure Send/Sync is not implemented for std::env::Vars{,Os}](https://github.com/rust-lang/rust/pull/155153)
+- [Fix that in some attributes, arguments were not properly rejected](https://github.com/rust-lang/rust/pull/155193)
+- [`repr(transparent)` is now more strict about which fields have "trivial" layout and hence can be ignored: `repr(C)` types, types with private fields, and `#[non_exhaustive]` types are no longer considered "trivial"](https://github.com/rust-lang/rust/pull/155299)
+- [Correctly check whether types have equal size in `transmute()` when some `repr` attributes are involved.](https://github.com/rust-lang/rust/pull/155418)
+- [More characters are escaped when printing strings and chars](https://github.com/rust-lang/rust/pull/155527)
+- [Implement fast path for `derive(PartialOrd)` when deriving `Ord`](https://github.com/rust-lang/rust/pull/155598)
+ This can break crates in practice where a type's PartialOrd and Ord impls were inconsistent with each other.
+- [Add temporary scope to `assert_eq` and `assert_ne`](https://github.com/rust-lang/rust/pull/155739)
+- Closed a hole in the pattern matching [structural equality](https://doc.rust-lang.org/reference/patterns.html#constant-patterns) check, preventing cases where a match of a constant would be allowed, despite disagreeing with a manually written `PartialEq` implementation, when a `derive(PartialEq)` implementation for that type also exists.
+- [On Emscripten the WASM exception handling ABI is now unconditionally used](https://github.com/rust-lang/rust/pull/156928) The `-Zemscripten-wasm-eh=false` flag to switch back to JS exceptions has been removed.
+- [The UNSAFE_CODE lint is now consistently emitted for all unsafe attributes](https://github.com/rust-lang/rust/pull/157201)
+- [Solaris: remove `File::lock` implementation, it has the wrong semantics (return "unsupported" instead)](https://github.com/rust-lang/rust/pull/157509)
+- [Windows-gnu targets now specify baseline tools versions](https://github.com/rust-lang/rust/pull/158020)
+- [rustfmt now discovers module files that are defined in `cfg_select!`](https://github.com/rust-lang/rust/pull/158372)
+ This may cause more code to be formatted which was previously ignored.
+
+
Version 1.97.1 (2026-07-16)
==========================
diff --git a/REUSE.toml b/REUSE.toml
index 7d72caa6d5c45..30b6ce6bee232 100644
--- a/REUSE.toml
+++ b/REUSE.toml
@@ -208,3 +208,12 @@ SPDX-FileCopyrightText = [
"Copyright (C) 2000-2024 Free Software Foundation, Inc.",
]
SPDX-License-Identifier = "GCC-exception-3.1"
+
+ [[annotations]]
+ path = "compiler/rustc_middle/src/ptrauth/llvm_siphash/tests.rs"
+ precedence = "override"
+ SPDX-FileCopyrightText = [
+ "2003-2019 University of Illinois at Urbana-Champaign.",
+ "The Rust Project Developers (see https://thanks.rust-lang.org)",
+ ]
+ SPDX-License-Identifier = "Apache-2.0 WITH LLVM-exception AND (Apache-2.0 OR MIT)"
diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs
index 589c5a5cb1229..ba5119ee228ad 100644
--- a/compiler/rustc_abi/src/lib.rs
+++ b/compiler/rustc_abi/src/lib.rs
@@ -1041,7 +1041,6 @@ impl Step for Size {
}
#[inline]
- #[cfg(not(bootstrap))]
fn forward_overflowing(start: Self, count: usize) -> (Self, bool) {
let (s, o) = u64::forward_overflowing(start.bytes(), count);
(Self::from_bytes(s), o)
@@ -1063,7 +1062,6 @@ impl Step for Size {
}
#[inline]
- #[cfg(not(bootstrap))]
fn backward_overflowing(start: Self, count: usize) -> (Self, bool) {
let (s, o) = u64::backward_overflowing(start.bytes(), count);
(Self::from_bytes(s), o)
@@ -2171,8 +2169,8 @@ pub struct LayoutData {
pub max_repr_align: Option,
/// The alignment the type would have, ignoring any `repr(align)` but including `repr(packed)`.
- /// Only used on aarch64-linux, where the argument passing ABI ignores the requested alignment
- /// in some cases.
+ /// Only used on aarch64-linux and arm, where the argument passing ABI ignores the requested
+ /// alignment in some cases.
pub unadjusted_abi_align: Align,
/// The randomization seed based on this type's own repr and its fields.
diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
index 7267ae113de3e..0e2024f822b96 100644
--- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
@@ -691,7 +691,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
if !clauses.instantiate_identity(tcx).clauses.iter().any(|clause| {
clause.as_trait_clause().is_some_and(|tc| {
tc.self_ty().skip_binder().is_param(param.index)
- && tc.polarity() == ty::PredicatePolarity::Positive
+ && tc.polarity() == ty::ClausePolarity::Positive
&& supertrait_def_ids(tcx, tc.def_id())
.flat_map(|trait_did| tcx.associated_items(trait_did).in_definition_order())
.any(|item| item.is_method())
diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
index 49e6dc334ff80..62cad6a874866 100644
--- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
@@ -1228,7 +1228,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
tcx.clauses_of(callee_def_id).instantiate(tcx, generic_args).clauses.iter().any(
|clause| {
clause.as_trait_clause().is_some_and(|trait_pred| {
- trait_pred.polarity() == ty::PredicatePolarity::Positive
+ trait_pred.polarity() == ty::ClausePolarity::Positive
&& tcx.fn_trait_kind_from_def_id(trait_pred.def_id())
== Some(ty::ClosureKind::Fn)
&& trait_pred.self_ty().skip_binder().peel_refs()
diff --git a/compiler/rustc_borrowck/src/type_check/canonical.rs b/compiler/rustc_borrowck/src/type_check/canonical.rs
index bc2c75f0c01a4..e4307e0481e5c 100644
--- a/compiler/rustc_borrowck/src/type_check/canonical.rs
+++ b/compiler/rustc_borrowck/src/type_check/canonical.rs
@@ -131,9 +131,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
category: ConstraintCategory<'tcx>,
) {
self.prove_clause(
- ty::ClauseKind::Trait(ty::TraitPredicate {
+ ty::ClauseKind::Trait(ty::TraitClause {
trait_ref,
- polarity: ty::PredicatePolarity::Positive,
+ polarity: ty::ClausePolarity::Positive,
}),
locations,
category,
diff --git a/compiler/rustc_codegen_cranelift/rust-toolchain.toml b/compiler/rustc_codegen_cranelift/rust-toolchain.toml
index ff51f49edc4ca..ea4ff67c93c89 100644
--- a/compiler/rustc_codegen_cranelift/rust-toolchain.toml
+++ b/compiler/rustc_codegen_cranelift/rust-toolchain.toml
@@ -1,4 +1,4 @@
[toolchain]
-channel = "nightly-2026-08-17"
+channel = "nightly-2026-08-19"
components = ["rust-src", "rustc-dev", "llvm-tools", "rustfmt"]
profile = "minimal"
diff --git a/compiler/rustc_codegen_gcc/src/context.rs b/compiler/rustc_codegen_gcc/src/context.rs
index 8045e8ae9d28f..19fbe37c27b9e 100644
--- a/compiler/rustc_codegen_gcc/src/context.rs
+++ b/compiler/rustc_codegen_gcc/src/context.rs
@@ -495,7 +495,9 @@ impl<'gcc, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
let entry_name = self.sess().target.entry_name.as_ref();
if !self.functions.borrow().contains_key(entry_name) {
let conv = cfg_select! {
- feature = "master" => conv_to_fn_attribute(self.sess(), self.sess().target.entry_abi),
+ feature = "master" => {
+ conv_to_fn_attribute(self.sess(), self.sess().target.entry_abi)
+ }
_ => None,
};
Some(self.declare_entry_fn(entry_name, fn_type, conv))
diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs
index d62c5c713f9ea..db7708c781ad4 100644
--- a/compiler/rustc_codegen_ssa/src/lib.rs
+++ b/compiler/rustc_codegen_ssa/src/lib.rs
@@ -7,7 +7,6 @@
#![feature(try_blocks)]
#![recursion_limit = "256"]
// tidy-alphabetical-end
-#![cfg_attr(bootstrap, feature(string_from_utf8_lossy_owned))]
//! This crate contains codegen code that is used by all codegen backends (LLVM and others).
//! The backend-agnostic functions of this crate use functions defined in various traits that
diff --git a/compiler/rustc_data_structures/src/obligation_forest/graphviz.rs b/compiler/rustc_data_structures/src/obligation_forest/graphviz.rs
index 65a24366db837..9def3d98fe09d 100644
--- a/compiler/rustc_data_structures/src/obligation_forest/graphviz.rs
+++ b/compiler/rustc_data_structures/src/obligation_forest/graphviz.rs
@@ -18,8 +18,8 @@ impl ObligationForest {
/// A few post-processing that you might want to do make the forest easier to visualize:
///
/// * `sed 's,std::[a-z]*::,,g'` — Deletes the `std::::` prefix of paths.
- /// * `sed 's,"Binder(TraitPredicate(<\(.*\)>)) (\([^)]*\))","\1 (\2)",'` — Transforms
- /// `Binder(TraitPredicate())` into just ``.
+ /// * `sed 's,"Binder(TraitClause(<\(.*\)>)) (\([^)]*\))","\1 (\2)",'` — Transforms
+ /// `Binder(TraitClause())` into just ``.
#[allow(dead_code)]
pub fn dump_graphviz>(&self, dir: P, description: &str) {
static COUNTER: AtomicUsize = AtomicUsize::new(0);
diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs
index 30ae99a56f6ad..f57a280968322 100644
--- a/compiler/rustc_feature/src/accepted.rs
+++ b/compiler/rustc_feature/src/accepted.rs
@@ -97,10 +97,10 @@ declare_features! (
/// Allows `extern "C-unwind" fn` to enable unwinding across ABI boundaries and treat `extern "C" fn` as nounwind.
(accepted, c_unwind, "1.81.0", Some(74990)),
/// Allows using C-variadics.
- (accepted, c_variadic, "CURRENT_RUSTC_VERSION", Some(44930)),
+ (accepted, c_variadic, "1.99.0", Some(44930)),
/// Allows defining c-variadic naked functions with any extern ABI that is allowed
/// on c-variadic foreign functions.
- (accepted, c_variadic_naked_functions, "CURRENT_RUSTC_VERSION", Some(148767)),
+ (accepted, c_variadic_naked_functions, "1.99.0", Some(148767)),
/// Allows `#[cfg_attr(predicate, multiple, attributes, here)]`.
(accepted, cfg_attr_multi, "1.33.0", Some(54881)),
/// Allows the use of `#[cfg()]`.
diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs
index 8ba571df5d5a5..00ca1e07c93fd 100644
--- a/compiler/rustc_feature/src/unstable.rs
+++ b/compiler/rustc_feature/src/unstable.rs
@@ -255,7 +255,7 @@ declare_features! (
/// Allows checking whether or not the backend correctly supports unstable float types.
(internal, cfg_target_has_reliable_f16_f128, "1.88.0", None),
/// Allows checking whether or not the target might have thread support.
- (internal, cfg_target_has_threads, "CURRENT_RUSTC_VERSION", None),
+ (internal, cfg_target_has_threads, "1.99.0", None),
/// Allows identifying the `compiler_builtins` crate.
(internal, compiler_builtins, "1.13.0", None),
/// Allows skipping `ConstParamTy_` trait implementation checks
@@ -397,7 +397,7 @@ declare_features! (
/// Target features on arm.
(unstable, arm_target_feature, "1.27.0", Some(150246)),
/// Allows using `const` operands with pointer in inline assembly.
- (unstable, asm_const_ptr, "CURRENT_RUSTC_VERSION", Some(128464)),
+ (unstable, asm_const_ptr, "1.99.0", Some(128464)),
/// Enables experimental inline assembly support for additional architectures.
(unstable, asm_experimental_arch, "1.58.0", Some(93335)),
/// Enables experimental register support in inline assembly.
@@ -452,7 +452,7 @@ declare_features! (
/// Allows to use the `#[cfi_encoding = ""]` attribute.
(unstable, cfi_encoding, "1.71.0", Some(89653)),
/// Allow to have type alias types for inter-crate use.
- (incomplete, checked_type_aliases, "CURRENT_RUSTC_VERSION", Some(112792)),
+ (incomplete, checked_type_aliases, "1.99.0", Some(112792)),
/// The `clflushopt` target feature on x86.
(unstable, clflushopt_target_feature, "1.98.0", Some(157096)),
/// Allows `for<...>` on closures and coroutines.
@@ -518,7 +518,7 @@ declare_features! (
/// Allows macros to customize macro argument matcher diagnostics.
(unstable, diagnostic_on_unmatched_args, "1.97.0", Some(155642)),
// Used by macros to not show their bodies in error messages. No-op with `-Z macro-backtrace`.
- (unstable, diagnostic_opaque, "CURRENT_RUSTC_VERSION", Some(158813)),
+ (unstable, diagnostic_opaque, "1.99.0", Some(158813)),
/// Allows `#[doc(cfg(...))]`.
(unstable, doc_cfg, "1.21.0", Some(43781)),
/// Allows `#[doc(masked)]`.
@@ -630,7 +630,7 @@ declare_features! (
/// Provides a way to concatenate identifiers using metavariable expressions.
(unstable, macro_metavar_expr_concat, "1.81.0", Some(124225)),
/// Allows directly represented generic_const_args without the `direct_const_arg!` macro.
- (incomplete, macroless_generic_const_args, "CURRENT_RUSTC_VERSION", Some(159006)),
+ (incomplete, macroless_generic_const_args, "1.99.0", Some(159006)),
/// Allows `#[marker]` on certain traits allowing overlapping implementations.
(unstable, marker_trait_attr, "1.30.0", Some(29864)),
/// Enable mgca `type const` syntax before expansion.
@@ -660,13 +660,13 @@ declare_features! (
/// Allows `mut ref` and `mut ref mut` identifier patterns.
(incomplete, mut_ref, "1.79.0", Some(123076)),
/// Allows `mut(crate) field: Type` restrictions.
- (unstable, mut_restriction, "CURRENT_RUSTC_VERSION", Some(105077)),
+ (unstable, mut_restriction, "1.99.0", Some(105077)),
/// Allows using `#[naked]` on `extern "Rust"` functions.
(unstable, naked_functions_rustic_abi, "1.88.0", Some(138997)),
/// Allows using `#[target_feature(enable = "...")]` on `#[naked]` on functions.
(unstable, naked_functions_target_feature, "1.86.0", Some(138568)),
/// Allows providing names to parameters of `impl Fn` etc
- (incomplete, named_fn_trait_parameters, "CURRENT_RUSTC_VERSION", Some(158499)),
+ (incomplete, named_fn_trait_parameters, "1.99.0", Some(158499)),
/// Allows specifying the as-needed link modifier
(unstable, native_link_modifiers_as_needed, "1.53.0", Some(81490)),
/// Allow negative trait implementations.
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 2f65b443dd5ec..8c2896e78289a 100644
--- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
+++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
@@ -2726,7 +2726,7 @@ fn param_env_with_gat_bounds<'tcx>(
}
_ => clauses.push(
ty::Binder::bind_with_vars(
- ty::ProjectionPredicate {
+ ty::ProjectionClause {
projection_term: ty::AliasTerm::new_from_def_id(
tcx,
trait_ty.def_id,
diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
index d1c011d22a6b1..f2f3fc5fe0527 100644
--- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs
+++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
@@ -1323,7 +1323,7 @@ fn check_impl<'tcx>(
trait_ref,
);
let trait_pred =
- ty::TraitPredicate { trait_ref, polarity: ty::PredicatePolarity::Positive };
+ ty::TraitClause { trait_ref, polarity: ty::ClausePolarity::Positive };
let mut obligations = traits::wf::trait_obligations(
wfcx.infcx,
wfcx.param_env,
diff --git a/compiler/rustc_hir_analysis/src/coherence/builtin.rs b/compiler/rustc_hir_analysis/src/coherence/builtin.rs
index 3b57f45e684f7..06d336298a42c 100644
--- a/compiler/rustc_hir_analysis/src/coherence/builtin.rs
+++ b/compiler/rustc_hir_analysis/src/coherence/builtin.rs
@@ -924,9 +924,9 @@ fn infringing_fields_error<'tcx>(
.or_default()
.push(error.obligation.cause.span);
}
- if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(ty::TraitPredicate {
+ if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(ty::TraitClause {
trait_ref,
- polarity: ty::PredicatePolarity::Positive,
+ polarity: ty::ClausePolarity::Positive,
..
})) = error_predicate.kind().skip_binder()
{
diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs
index 25ba0c810489e..c955d131fa09a 100644
--- a/compiler/rustc_hir_analysis/src/collect.rs
+++ b/compiler/rustc_hir_analysis/src/collect.rs
@@ -262,7 +262,7 @@ impl<'tcx> ItemCtxt<'tcx> {
ItemCtxt::new_internal(tcx, item_def_id, true)
}
- pub(crate) fn lower_ty(&self, hir_ty: &hir::Ty<'tcx>) -> Ty<'tcx> {
+ pub(crate) fn lower_ty(&self, hir_ty: &hir::Ty<'_>) -> Ty<'tcx> {
self.lowerer().lower_ty(hir_ty)
}
@@ -451,7 +451,7 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
&self,
span: Span,
item_def_id: DefId,
- item_segment: &rustc_hir::PathSegment<'tcx>,
+ item_segment: &rustc_hir::PathSegment<'_>,
poly_trait_ref: ty::PolyTraitRef<'tcx>,
) -> Result<(DefId, ty::GenericArgsRef<'tcx>), ErrorGuaranteed> {
if let Some(trait_ref) = poly_trait_ref.no_bound_vars() {
@@ -549,7 +549,7 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
fn lower_fn_sig(
&self,
- decl: &hir::FnDecl<'tcx>,
+ decl: &hir::FnDecl<'_>,
_generics: Option<&hir::Generics<'_>>,
hir_id: rustc_hir::HirId,
_hir_ty: Option<&hir::Ty<'_>>,
diff --git a/compiler/rustc_hir_analysis/src/collect/clauses_of.rs b/compiler/rustc_hir_analysis/src/collect/clauses_of.rs
index 1ee647fd61a33..488b9a09e6106 100644
--- a/compiler/rustc_hir_analysis/src/collect/clauses_of.rs
+++ b/compiler/rustc_hir_analysis/src/collect/clauses_of.rs
@@ -720,7 +720,7 @@ pub(super) fn implied_clauses_with_filter<'tcx>(
for &(clause, span) in implied_bounds {
debug!("superbound: {:?}", clause);
if let ty::ClauseKind::Trait(bound) = clause.kind().skip_binder()
- && bound.polarity == ty::PredicatePolarity::Positive
+ && bound.polarity == ty::ClausePolarity::Positive
{
tcx.at(span).explicit_super_clauses_of(bound.def_id());
}
@@ -730,7 +730,7 @@ pub(super) fn implied_clauses_with_filter<'tcx>(
for &(clause, span) in implied_bounds {
debug!("superbound: {:?}", clause);
if let ty::ClauseKind::Trait(bound) = clause.kind().skip_binder()
- && bound.polarity == ty::PredicatePolarity::Positive
+ && bound.polarity == ty::ClausePolarity::Positive
{
tcx.at(span).explicit_implied_clauses_of(bound.def_id());
}
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 613202ef35345..c12bafd9d5d57 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
@@ -107,7 +107,7 @@ fn collect_bounds<'a, 'tcx>(
fn collect_sizedness_bounds<'tcx>(
tcx: TyCtxt<'tcx>,
- hir_bounds: &'tcx [hir::GenericBound<'tcx>],
+ hir_bounds: &[hir::GenericBound<'_>],
context: ImpliedBoundsContext<'tcx>,
span: Span,
) -> CollectedSizednessBounds {
@@ -150,7 +150,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
&self,
bounds: &mut Vec<(ty::Clause<'tcx>, Span)>,
self_ty: Ty<'tcx>,
- hir_bounds: &'tcx [hir::GenericBound<'tcx>],
+ hir_bounds: &[hir::GenericBound<'_>],
context: ImpliedBoundsContext<'tcx>,
span: Span,
) {
@@ -212,7 +212,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
&self,
bounds: &mut Vec<(ty::Clause<'tcx>, Span)>,
self_ty: Ty<'tcx>,
- hir_bounds: &[hir::GenericBound<'tcx>],
+ hir_bounds: &[hir::GenericBound<'_>],
context: ImpliedBoundsContext<'tcx>,
span: Span,
) {
@@ -229,7 +229,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
trait_: LangItem,
bounds: &mut Vec<(ty::Clause<'tcx>, Span)>,
self_ty: Ty<'tcx>,
- hir_bounds: &[hir::GenericBound<'tcx>],
+ hir_bounds: &[hir::GenericBound<'_>],
context: ImpliedBoundsContext<'tcx>,
span: Span,
) {
@@ -251,10 +251,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
}
/// Returns `true` if default trait bound should be added.
- fn should_add_default_traits<'a>(
+ fn should_add_default_traits(
&self,
trait_def_id: DefId,
- hir_bounds: &'a [hir::GenericBound<'tcx>],
+ hir_bounds: &[hir::GenericBound<'_>],
context: ImpliedBoundsContext<'tcx>,
) -> bool {
let collected = collect_bounds(hir_bounds, context, trait_def_id);
@@ -308,7 +308,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
/// There is an implied binder around `param_ty` and `hir_bounds`.
/// See `lower_poly_trait_ref` for more details.
#[instrument(level = "debug", skip(self, hir_bounds, bounds))]
- pub(crate) fn lower_bounds<'hir, I: IntoIterator- >>(
+ pub(crate) fn lower_bounds<'a, I: IntoIterator
- >>(
&self,
param_ty: Ty<'tcx>,
hir_bounds: I,
@@ -316,9 +316,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
bound_vars: &'tcx ty::List>,
predicate_filter: PredicateFilter,
overlapping_assoc_constraints: OverlappingAsssocItemConstraints,
- ) where
- 'tcx: 'hir,
- {
+ ) {
for hir_bound in hir_bounds {
// In order to avoid cycles, when we're lowering `SelfTraitThatDefines`,
// we skip over any traits that don't define the given associated type.
@@ -379,7 +377,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
&self,
hir_ref_id: hir::HirId,
trait_ref: ty::PolyTraitRef<'tcx>,
- constraint: &hir::AssocItemConstraint<'tcx>,
+ constraint: &hir::AssocItemConstraint<'_>,
bounds: &mut Vec<(ty::Clause<'tcx>, Span)>,
duplicates: Option<&mut FxIndexMap>,
path_span: Span,
@@ -547,7 +545,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
| PredicateFilter::SelfOnly
| PredicateFilter::SelfAndAssociatedTypeBounds => {
let bound = projection_term.map_bound(|projection_term| {
- ty::ClauseKind::Projection(ty::ProjectionPredicate {
+ ty::ClauseKind::Projection(ty::ProjectionClause {
projection_term,
term,
})
@@ -616,7 +614,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
/// Lower a type, possibly specially handling the type if it's a return type notation
/// which we otherwise deny in other positions.
- pub fn lower_ty_maybe_return_type_notation(&self, hir_ty: &hir::Ty<'tcx>) -> Ty<'tcx> {
+ pub fn lower_ty_maybe_return_type_notation(&self, hir_ty: &hir::Ty<'_>) -> Ty<'tcx> {
let hir::TyKind::Path(qpath) = hir_ty.kind else {
return self.lower_ty(hir_ty);
};
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs
index 3d8c23ebdf8d3..de36ddbe1d10f 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs
@@ -37,7 +37,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
&self,
span: Span,
hir_id: hir::HirId,
- hir_bounds: &[hir::PolyTraitRef<'tcx>],
+ hir_bounds: &[hir::PolyTraitRef<'_>],
lifetime: &hir::Lifetime,
syntax: TraitObjectSyntax,
) -> Ty<'tcx> {
@@ -207,7 +207,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
if let Some((principal_trait, ref spans)) = principal_trait {
let principal_trait = principal_trait.map_bound(|trait_pred| {
- assert_eq!(trait_pred.polarity, ty::PredicatePolarity::Positive);
+ assert_eq!(trait_pred.polarity, ty::ClausePolarity::Positive);
trait_pred.trait_ref
});
@@ -350,7 +350,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let principal_trait_ref = principal_trait.map(|(trait_pred, spans)| {
trait_pred.map_bound(|trait_pred| {
let trait_ref = trait_pred.trait_ref;
- assert_eq!(trait_pred.polarity, ty::PredicatePolarity::Positive);
+ assert_eq!(trait_pred.polarity, ty::ClausePolarity::Positive);
assert_eq!(trait_ref.self_ty(), dummy_self);
let span = *spans.first().unwrap();
@@ -423,7 +423,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let mut auto_trait_predicates: Vec<_> = auto_traits
.into_iter()
.map(|(trait_pred, _)| {
- assert_eq!(trait_pred.polarity(), ty::PredicatePolarity::Positive);
+ assert_eq!(trait_pred.polarity(), ty::ClausePolarity::Positive);
assert_eq!(trait_pred.self_ty().skip_binder(), dummy_self);
ty::Binder::dummy(ty::ExistentialPredicate::AutoTrait(trait_pred.def_id()))
@@ -476,7 +476,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
/// `elaborated-predicates-unconstrained-late-bound.rs` for a test.
fn check_elaborated_projection_mentions_input_lifetimes(
&self,
- pred: ty::PolyProjectionPredicate<'tcx>,
+ pred: ty::PolyProjectionClause<'tcx>,
span: Span,
supertrait_span: Span,
) {
@@ -569,7 +569,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
&self,
span: Span,
hir_id: hir::HirId,
- hir_bounds: &[hir::PolyTraitRef<'tcx>],
+ hir_bounds: &[hir::PolyTraitRef<'_>],
) -> Option {
struct TraitObjectWithoutDyn<'a, 'tcx> {
span: Span,
@@ -871,7 +871,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
&self,
span: Span,
hir_id: hir::HirId,
- hir_bounds: &[hir::PolyTraitRef<'tcx>],
+ hir_bounds: &[hir::PolyTraitRef<'_>],
diag: &mut Diag<'_>,
) -> bool {
let tcx = self.tcx();
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
index e5dbae16d07d4..0bedff530212e 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
@@ -120,7 +120,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
assoc_tag: ty::AssocTag,
assoc_ident: Ident,
span: Span,
- constraint: Option<&hir::AssocItemConstraint<'tcx>>,
+ constraint: Option<&hir::AssocItemConstraint<'_>>,
) -> ErrorGuaranteed
where
I: Iterator
- >,
@@ -349,7 +349,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
assoc_tag: ty::AssocTag,
ident: Ident,
span: Span,
- constraint: Option<&hir::AssocItemConstraint<'tcx>>,
+ constraint: Option<&hir::AssocItemConstraint<'_>>,
) -> ErrorGuaranteed {
let tcx = self.tcx();
@@ -415,7 +415,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
assoc_tag: ty::AssocTag,
assoc_ident: Ident,
span: Span,
- constraint: Option<&hir::AssocItemConstraint<'tcx>>,
+ constraint: Option<&hir::AssocItemConstraint<'_>>,
) -> ErrorGuaranteed {
let tcx = self.tcx();
@@ -544,7 +544,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
&self,
trait_def_id: DefId,
span: Span,
- item_segment: &hir::PathSegment<'tcx>,
+ item_segment: &hir::PathSegment<'_>,
assoc_tag: ty::AssocTag,
) -> ErrorGuaranteed {
let tcx = self.tcx();
@@ -1485,7 +1485,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
pub fn report_trait_object_addition_traits(
&self,
- regular_traits: &Vec<(ty::PolyTraitPredicate<'tcx>, SmallVec<[Span; 1]>)>,
+ regular_traits: &Vec<(ty::PolyTraitClause<'tcx>, SmallVec<[Span; 1]>)>,
) -> ErrorGuaranteed {
// we use the last span to point at the traits themselves,
// and all other preceding spans are trait alias expansions.
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 c65e9bdbd211e..c2cf7136bd4a0 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
@@ -199,13 +199,13 @@ pub trait HirTyLowerer<'tcx> {
&self,
span: Span,
item_def_id: DefId,
- item_segment: &hir::PathSegment<'tcx>,
+ item_segment: &hir::PathSegment<'_>,
poly_trait_ref: ty::PolyTraitRef<'tcx>,
) -> Result<(DefId, GenericArgsRef<'tcx>), ErrorGuaranteed>;
fn lower_fn_sig(
&self,
- decl: &hir::FnDecl<'tcx>,
+ decl: &hir::FnDecl<'_>,
generics: Option<&hir::Generics<'_>>,
hir_id: HirId,
hir_ty: Option<&hir::Ty<'_>>,
@@ -366,13 +366,13 @@ pub struct GenericArgCountResult {
/// Its only consumer is [`generics::lower_generic_args`].
/// Read its documentation to learn more.
pub trait GenericArgsLowerer<'a, 'tcx> {
- fn args_for_def_id(&mut self, def_id: DefId) -> (Option<&'a GenericArgs<'tcx>>, bool);
+ fn args_for_def_id(&mut self, def_id: DefId) -> (Option<&'a GenericArgs<'a>>, bool);
fn provided_kind(
&mut self,
preceding_args: &[ty::GenericArg<'tcx>],
param: &ty::GenericParamDef,
- arg: &GenericArg<'tcx>,
+ arg: &GenericArg<'_>,
) -> ty::GenericArg<'tcx>;
fn inferred_kind(
@@ -625,7 +625,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
&self,
span: Span,
def_id: DefId,
- item_segment: &hir::PathSegment<'tcx>,
+ item_segment: &hir::PathSegment<'_>,
) -> GenericArgsRef<'tcx> {
let (args, _) = self.lower_generic_args_of_path(span, def_id, &[], item_segment, None);
if let Some(c) = item_segment.args().constraints.first() {
@@ -674,7 +674,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
span: Span,
def_id: DefId,
parent_args: &[ty::GenericArg<'tcx>],
- segment: &hir::PathSegment<'tcx>,
+ segment: &hir::PathSegment<'_>,
self_ty: Option>,
) -> (GenericArgsRef<'tcx>, GenericArgCountResult) {
// If the type is parameterized by this region, then replace this
@@ -718,7 +718,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
struct GenericArgsCtxt<'a, 'tcx> {
lowerer: &'a dyn HirTyLowerer<'tcx>,
def_id: DefId,
- generic_args: &'a GenericArgs<'tcx>,
+ generic_args: &'a GenericArgs<'a>,
span: Span,
infer_args: bool,
create_synth_args: bool,
@@ -726,7 +726,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
}
impl<'a, 'tcx> GenericArgsLowerer<'a, 'tcx> for GenericArgsCtxt<'a, 'tcx> {
- fn args_for_def_id(&mut self, did: DefId) -> (Option<&'a GenericArgs<'tcx>>, bool) {
+ fn args_for_def_id(&mut self, did: DefId) -> (Option<&'a GenericArgs<'a>>, bool) {
if did == self.def_id {
(Some(self.generic_args), self.infer_args)
} else {
@@ -739,7 +739,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
&mut self,
preceding_args: &[ty::GenericArg<'tcx>],
param: &ty::GenericParamDef,
- arg: &GenericArg<'tcx>,
+ arg: &GenericArg<'_>,
) -> ty::GenericArg<'tcx> {
let tcx = self.lowerer.tcx();
@@ -749,7 +749,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
}
}
- let handle_ty_args = |has_default, ty: &hir::Ty<'tcx>| {
+ let handle_ty_args = |has_default, ty: &hir::Ty<'_>| {
if has_default {
tcx.check_optional_stability(
param.def_id,
@@ -896,7 +896,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
&self,
span: Span,
item_def_id: DefId,
- item_segment: &hir::PathSegment<'tcx>,
+ item_segment: &hir::PathSegment<'_>,
parent_args: GenericArgsRef<'tcx>,
) -> GenericArgsRef<'tcx> {
let (args, _) =
@@ -959,7 +959,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
modifiers: hir::TraitBoundModifiers { constness, polarity },
trait_ref,
span,
- }: &hir::PolyTraitRef<'tcx>,
+ }: &hir::PolyTraitRef<'_>,
self_ty: Ty<'tcx>,
bounds: &mut Vec<(ty::Clause<'tcx>, Span)>,
predicate_filter: PredicateFilter,
@@ -996,9 +996,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let polarity = match polarity {
hir::BoundPolarity::Positive | hir::BoundPolarity::Maybe(_) => {
- ty::PredicatePolarity::Positive
+ ty::ClausePolarity::Positive
}
- hir::BoundPolarity::Negative(_) => ty::PredicatePolarity::Negative,
+ hir::BoundPolarity::Negative(_) => ty::ClausePolarity::Negative,
};
let [leading_segments @ .., segment] = trait_ref.path.segments else { bug!() };
@@ -1047,7 +1047,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
| PredicateFilter::SelfTraitThatDefines(..)
| PredicateFilter::SelfAndAssociatedTypeBounds => {
let bound = poly_trait_ref.map_bound(|trait_ref| {
- ty::ClauseKind::Trait(ty::TraitPredicate { trait_ref, polarity })
+ ty::ClauseKind::Trait(ty::TraitClause { trait_ref, polarity })
});
let bound = (bound.upcast(tcx), span);
// FIXME(-Znext-solver): We can likely remove this hack once the
@@ -1102,7 +1102,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
| PredicateFilter::SelfAndAssociatedTypeBounds => {
match constness {
hir::BoundConstness::Always(_) => {
- if polarity == ty::PredicatePolarity::Positive {
+ if polarity == ty::ClausePolarity::Positive {
bounds.push((
poly_trait_ref
.to_host_effect_clause(tcx, ty::BoundConstness::Const),
@@ -1128,7 +1128,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => {
match constness {
hir::BoundConstness::Maybe(_) => {
- if polarity == ty::PredicatePolarity::Positive {
+ if polarity == ty::ClausePolarity::Positive {
bounds.push((
poly_trait_ref
.to_host_effect_clause(tcx, ty::BoundConstness::Maybe),
@@ -1150,7 +1150,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// Don't register any associated item constraints for negative bounds,
// since we should have emitted an error for them earlier, and they
// would not be well-formed!
- if polarity == ty::PredicatePolarity::Negative {
+ if polarity == ty::ClausePolarity::Negative {
self.dcx().span_delayed_bug(
constraint.span,
"negative trait bounds should not have assoc item constraints",
@@ -1182,7 +1182,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
span: Span,
trait_def_id: DefId,
self_ty: Ty<'tcx>,
- trait_segment: &hir::PathSegment<'tcx>,
+ trait_segment: &hir::PathSegment<'_>,
is_impl: bool,
) -> ty::TraitRef<'tcx> {
self.report_internal_fn_trait(span, trait_def_id, trait_segment, is_impl);
@@ -1211,7 +1211,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
&self,
span: Span,
def_id: DefId,
- item_segment: &hir::PathSegment<'tcx>,
+ item_segment: &hir::PathSegment<'_>,
) -> Ty<'tcx> {
let tcx = self.tcx();
let args = self.lower_generic_args_of_path_segment(span, def_id, item_segment);
@@ -1348,7 +1348,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
assoc_tag: ty::AssocTag,
assoc_ident: Ident,
span: Span,
- constraint: Option<&hir::AssocItemConstraint<'tcx>>,
+ constraint: Option<&hir::AssocItemConstraint<'_>>,
) -> Result, ErrorGuaranteed>
where
I: Iterator
- >,
@@ -1419,8 +1419,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
pub fn lower_type_relative_ty_path(
&self,
self_ty: Ty<'tcx>,
- hir_self_ty: &'tcx hir::Ty<'tcx>,
- segment: &'tcx hir::PathSegment<'tcx>,
+ hir_self_ty: &hir::Ty<'_>,
+ segment: &hir::PathSegment<'_>,
qpath_hir_id: HirId,
span: Span,
permit_variants: PermitVariants,
@@ -1461,8 +1461,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
fn lower_type_relative_const_path(
&self,
self_ty: Ty<'tcx>,
- hir_self_ty: &'tcx hir::Ty<'tcx>,
- segment: &'tcx hir::PathSegment<'tcx>,
+ hir_self_ty: &hir::Ty<'_>,
+ segment: &hir::PathSegment<'_>,
qpath_hir_id: HirId,
span: Span,
) -> Result, ErrorGuaranteed> {
@@ -1507,8 +1507,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
fn lower_type_relative_path(
&self,
self_ty: Ty<'tcx>,
- hir_self_ty: &'tcx hir::Ty<'tcx>,
- segment: &'tcx hir::PathSegment<'tcx>,
+ hir_self_ty: &hir::Ty<'_>,
+ segment: &hir::PathSegment<'_>,
qpath_hir_id: HirId,
span: Span,
mode: LowerTypeRelativePathMode,
@@ -1612,9 +1612,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
fn resolve_type_relative_path(
&self,
self_ty: Ty<'tcx>,
- hir_self_ty: &'tcx hir::Ty<'tcx>,
+ hir_self_ty: &hir::Ty<'_>,
assoc_tag: ty::AssocTag,
- segment: &'tcx hir::PathSegment<'tcx>,
+ segment: &hir::PathSegment<'_>,
qpath_hir_id: HirId,
span: Span,
variant_def_id: Option,
@@ -1679,7 +1679,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
/// Search for inherent associated items for use at the type level.
fn probe_inherent_assoc_item(
&self,
- segment: &hir::PathSegment<'tcx>,
+ segment: &hir::PathSegment<'_>,
adt_did: DefId,
self_ty: Ty<'tcx>,
block: HirId,
@@ -1904,8 +1904,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
span: Span,
opt_self_ty: Option>,
item_def_id: DefId,
- trait_segment: Option<&hir::PathSegment<'tcx>>,
- item_segment: &hir::PathSegment<'tcx>,
+ trait_segment: Option<&hir::PathSegment<'_>>,
+ item_segment: &hir::PathSegment<'_>,
) -> Ty<'tcx> {
match self.lower_resolved_assoc_item_path(
span,
@@ -1929,8 +1929,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
span: Span,
opt_self_ty: Option>,
item_def_id: DefId,
- trait_segment: Option<&hir::PathSegment<'tcx>>,
- item_segment: &hir::PathSegment<'tcx>,
+ trait_segment: Option<&hir::PathSegment<'_>>,
+ item_segment: &hir::PathSegment<'_>,
) -> Result, ErrorGuaranteed> {
let tcx = self.tcx();
let (item_def_id, item_args) = self.lower_resolved_assoc_item_path(
@@ -1957,8 +1957,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
span: Span,
opt_self_ty: Option>,
item_def_id: DefId,
- trait_segment: Option<&hir::PathSegment<'tcx>>,
- item_segment: &hir::PathSegment<'tcx>,
+ trait_segment: Option<&hir::PathSegment<'_>>,
+ item_segment: &hir::PathSegment<'_>,
assoc_tag: ty::AssocTag,
) -> Result<(DefId, GenericArgsRef<'tcx>), ErrorGuaranteed> {
let tcx = self.tcx();
@@ -2183,7 +2183,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
pub fn lower_resolved_ty_path(
&self,
opt_self_ty: Option>,
- path: &hir::Path<'tcx>,
+ path: &hir::Path<'_>,
hir_id: HirId,
permit_variants: PermitVariants,
) -> Ty<'tcx> {
@@ -2381,7 +2381,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
/// Lower a [`hir::ConstArg`] to a (type-level) [`ty::Const`].
#[instrument(skip(self), level = "debug")]
- pub fn lower_const_arg(&self, const_arg: &hir::ConstArg<'tcx>, ty: Ty<'tcx>) -> Const<'tcx> {
+ pub fn lower_const_arg(&self, const_arg: &hir::ConstArg<'_>, ty: Ty<'tcx>) -> Const<'tcx> {
let tcx = self.tcx();
if let hir::ConstArgKind::Anon(anon) = &const_arg.kind {
@@ -2475,7 +2475,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
fn lower_const_arg_array(
&self,
- array_expr: &'tcx hir::ConstArgArrayExpr<'tcx>,
+ array_expr: &hir::ConstArgArrayExpr<'_>,
ty: Ty<'tcx>,
) -> Const<'tcx> {
let tcx = self.tcx();
@@ -2524,8 +2524,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
fn lower_const_arg_tuple_call(
&self,
hir_id: HirId,
- qpath: hir::QPath<'tcx>,
- args: &'tcx [&'tcx hir::ConstArg<'tcx>],
+ qpath: hir::QPath<'_>,
+ args: &[&hir::ConstArg<'_>],
span: Span,
) -> Const<'tcx> {
let tcx = self.tcx();
@@ -2625,7 +2625,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
fn lower_const_arg_tup(
&self,
- exprs: &'tcx [&'tcx hir::ConstArg<'tcx>],
+ exprs: &[&hir::ConstArg<'_>],
ty: Ty<'tcx>,
span: Span,
) -> Const<'tcx> {
@@ -2667,8 +2667,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
fn lower_const_arg_struct(
&self,
hir_id: HirId,
- qpath: hir::QPath<'tcx>,
- inits: &'tcx [&'tcx hir::ConstArgExprField<'tcx>],
+ qpath: hir::QPath<'_>,
+ inits: &[&hir::ConstArgExprField<'_>],
span: Span,
) -> Const<'tcx> {
// FIXME(mgca): try to deduplicate this function with
@@ -2809,7 +2809,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
pub fn lower_path_for_struct_expr(
&self,
- qpath: hir::QPath<'tcx>,
+ qpath: hir::QPath<'_>,
path_span: Span,
hir_id: HirId,
) -> ResolvedStructPath<'tcx> {
@@ -2846,7 +2846,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
fn lower_resolved_const_path(
&self,
opt_self_ty: Option>,
- path: &hir::Path<'tcx>,
+ path: &hir::Path<'_>,
hir_id: HirId,
) -> Const<'tcx> {
let tcx = self.tcx();
@@ -3152,7 +3152,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
}
}
- fn lower_delegation_ty(&self, infer: hir::InferDelegation<'tcx>) -> Ty<'tcx> {
+ fn lower_delegation_ty(&self, infer: hir::InferDelegation<'_>) -> Ty<'tcx> {
match infer {
hir::InferDelegation::DefId(def_id) => {
self.tcx().type_of(def_id).instantiate_identity().skip_norm_wip()
@@ -3170,7 +3170,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
/// Lower a type from the HIR to our internal notion of a type.
#[instrument(level = "debug", skip(self), ret)]
- pub fn lower_ty(&self, hir_ty: &hir::Ty<'tcx>) -> Ty<'tcx> {
+ pub fn lower_ty(&self, hir_ty: &hir::Ty<'_>) -> Ty<'tcx> {
let tcx = self.tcx();
let result_ty = match &hir_ty.kind {
@@ -3428,7 +3428,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
&self,
ty: Ty<'tcx>,
ty_span: Span,
- pat: &hir::TyPat<'tcx>,
+ pat: &hir::TyPat<'_>,
) -> Result, ErrorGuaranteed> {
let tcx = self.tcx();
match pat.kind {
@@ -3669,7 +3669,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
hir_id: HirId,
safety: hir::Safety,
abi: rustc_abi::ExternAbi,
- decl: &hir::FnDecl<'tcx>,
+ decl: &hir::FnDecl<'_>,
generics: Option<&hir::Generics<'_>>,
hir_ty: Option<&hir::Ty<'_>>,
) -> ty::PolyFnSig<'tcx> {
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 5788983811f03..cec65615111a7 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
@@ -414,7 +414,7 @@ fn check_specialization_on<'tcx>(
_ if clause.is_global() => Ok(()),
// We allow specializing on explicitly marked traits with no associated
// items.
- ty::ClauseKind::Trait(ty::TraitPredicate { trait_ref, polarity: _ }) => {
+ ty::ClauseKind::Trait(ty::TraitClause { trait_ref, polarity: _ }) => {
if matches!(
trait_specialization_kind(tcx, clause),
Some(TraitSpecializationKind::Marker)
@@ -433,7 +433,7 @@ fn check_specialization_on<'tcx>(
.emit())
}
}
- ty::ClauseKind::Projection(ty::ProjectionPredicate { projection_term, term }) => Err(tcx
+ ty::ClauseKind::Projection(ty::ProjectionClause { projection_term, term }) => Err(tcx
.dcx()
.struct_span_err(
span,
@@ -463,7 +463,7 @@ fn trait_specialization_kind<'tcx>(
clause: ty::Clause<'tcx>,
) -> Option {
match clause.kind().skip_binder() {
- ty::ClauseKind::Trait(ty::TraitPredicate { trait_ref, polarity: _ }) => {
+ ty::ClauseKind::Trait(ty::TraitClause { trait_ref, polarity: _ }) => {
Some(tcx.trait_def(trait_ref.def_id).specialization_kind)
}
ty::ClauseKind::RegionOutlives(_)
diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs
index 572200dbd7634..dc0b895ea1aa9 100644
--- a/compiler/rustc_hir_analysis/src/lib.rs
+++ b/compiler/rustc_hir_analysis/src/lib.rs
@@ -226,7 +226,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
/// It's used in rustdoc and Clippy.
///
///
-pub fn lower_ty<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: &hir::Ty<'tcx>) -> Ty<'tcx> {
+pub fn lower_ty<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: &hir::Ty<'_>) -> Ty<'tcx> {
// In case there are any projections, etc., find the "environment"
// def-ID that will be used to determine the traits/predicates in
// scope. This is derived from the enclosing item-like thing.
@@ -240,7 +240,7 @@ pub fn lower_ty<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: &hir::Ty<'tcx>) -> Ty<'tcx> {
// FIXME(const_generics): having special methods for rustdoc in `rustc_hir_analysis` is cursed
pub fn lower_const_arg_for_rustdoc<'tcx>(
tcx: TyCtxt<'tcx>,
- hir_ct: &hir::ConstArg<'tcx>,
+ hir_ct: &hir::ConstArg<'_>,
ty: Ty<'tcx>,
) -> Const<'tcx> {
let env_def_id = tcx.hir_get_parent_item(hir_ct.hir_id);
diff --git a/compiler/rustc_hir_analysis/src/variance/mod.rs b/compiler/rustc_hir_analysis/src/variance/mod.rs
index c733292df7d98..163cd5ab5bfbc 100644
--- a/compiler/rustc_hir_analysis/src/variance/mod.rs
+++ b/compiler/rustc_hir_analysis/src/variance/mod.rs
@@ -194,7 +194,7 @@ fn variance_of_opaque(
// which thus mentions `'a` and should thus accept hidden types that borrow 'a
// instead of requiring an additional `+ 'a`.
match clause.kind().skip_binder() {
- ty::ClauseKind::Trait(ty::TraitPredicate {
+ ty::ClauseKind::Trait(ty::TraitClause {
trait_ref: ty::TraitRef { def_id: _, args, .. },
polarity: _,
})
@@ -206,7 +206,7 @@ fn variance_of_opaque(
arg.visit_with(&mut collector);
}
}
- ty::ClauseKind::Projection(ty::ProjectionPredicate {
+ ty::ClauseKind::Projection(ty::ProjectionClause {
projection_term: ty::AliasTerm { args, .. },
term,
}) => {
diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs
index a9ce46b68527f..de2f152011dbe 100644
--- a/compiler/rustc_hir_typeck/src/closure.rs
+++ b/compiler/rustc_hir_typeck/src/closure.rs
@@ -483,7 +483,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self,
cause_span: Option,
closure_kind: hir::ClosureKind,
- projection: ty::PolyProjectionPredicate<'tcx>,
+ projection: ty::PolyProjectionClause<'tcx>,
) -> Option> {
let def_id = projection.item_def_id();
@@ -515,7 +515,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn extract_sig_from_projection(
&self,
cause_span: Option,
- projection: ty::PolyProjectionPredicate<'tcx>,
+ projection: ty::PolyProjectionClause<'tcx>,
) -> Option> {
let projection = self.resolve_vars_if_possible(projection);
@@ -560,7 +560,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn extract_sig_from_projection_and_future_bound(
&self,
cause_span: Option,
- projection: ty::PolyProjectionPredicate<'tcx>,
+ projection: ty::PolyProjectionClause<'tcx>,
) -> Option> {
let projection = self.resolve_vars_if_possible(projection);
@@ -1031,7 +1031,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn deduce_future_output_from_projection(
&self,
cause_span: Span,
- predicate: ty::PolyProjectionPredicate<'tcx>,
+ predicate: ty::PolyProjectionClause<'tcx>,
) -> Option> {
debug!("deduce_future_output_from_projection(predicate={:?})", predicate);
diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs
index cbbd66f648eb8..6ebf382083f25 100644
--- a/compiler/rustc_hir_typeck/src/expr.rs
+++ b/compiler/rustc_hir_typeck/src/expr.rs
@@ -3575,9 +3575,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ocx.register_obligations(traits::predicates_for_generics(
|idx, span| {
cause.clone().derived_cause(
- ty::Binder::dummy(ty::TraitPredicate {
+ ty::Binder::dummy(ty::TraitClause {
trait_ref: impl_trait_ref,
- polarity: ty::PredicatePolarity::Positive,
+ polarity: ty::ClausePolarity::Positive,
}),
|derived| {
ObligationCauseCode::ImplDerived(Box::new(traits::ImplDerivedCause {
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
index 8ff4c3bf28c34..49559304d6ba3 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
@@ -569,7 +569,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
- pub(crate) fn lower_ty(&self, hir_ty: &hir::Ty<'tcx>) -> LoweredTy<'tcx> {
+ pub(crate) fn lower_ty(&self, hir_ty: &hir::Ty<'_>) -> LoweredTy<'tcx> {
let ty = self.lowerer().lower_ty(hir_ty);
self.register_wf_obligation(ty.into(), hir_ty.span, ObligationCauseCode::WellFormed(None));
LoweredTy::from_raw(self, hir_ty.span, ty)
@@ -629,7 +629,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub(crate) fn lower_const_arg(
&self,
- const_arg: &'tcx hir::ConstArg<'tcx>,
+ const_arg: &hir::ConstArg<'_>,
ty: Ty<'tcx>,
) -> ty::Const<'tcx> {
let ct = self.lowerer().lower_const_arg(const_arg, ty);
@@ -1346,7 +1346,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&mut self,
preceding_args: &[ty::GenericArg<'tcx>],
param: &ty::GenericParamDef,
- arg: &GenericArg<'tcx>,
+ arg: &GenericArg<'_>,
) -> ty::GenericArg<'tcx> {
match (¶m.kind, arg) {
(GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => self
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 e6de8b55ef2f9..8b76a5eb44db7 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs
@@ -171,11 +171,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
predicate: ty::Predicate<'tcx>,
) -> Option {
// The predicates we are looking for look like
- // `TraitPredicate(>, polarity:Positive)`.
+ // `TraitClause(>, polarity:Positive)`.
// They will have no bound variables.
match predicate.kind().no_bound_vars() {
- Some(ty::PredicateKind::Clause(ty::ClauseKind::Trait(ty::TraitPredicate {
- polarity: ty::PredicatePolarity::Positive,
+ Some(ty::PredicateKind::Clause(ty::ClauseKind::Trait(ty::TraitClause {
+ polarity: ty::ClausePolarity::Positive,
trait_ref,
}))) if trait_ref.def_id == from_trait
&& self.shallow_resolve(trait_ref.self_ty()).kind()
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
index 20fa6d5f7a344..e488f8c9a7887 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
@@ -387,7 +387,7 @@ impl<'tcx> HirTyLowerer<'tcx> for FnCtxt<'_, 'tcx> {
&self,
span: Span,
item_def_id: DefId,
- item_segment: &rustc_hir::PathSegment<'tcx>,
+ item_segment: &rustc_hir::PathSegment<'_>,
poly_trait_ref: ty::PolyTraitRef<'tcx>,
) -> Result<(DefId, ty::GenericArgsRef<'tcx>), ErrorGuaranteed> {
let trait_ref = self.instantiate_binder_with_fresh_vars(
@@ -452,7 +452,7 @@ impl<'tcx> HirTyLowerer<'tcx> for FnCtxt<'_, 'tcx> {
fn lower_fn_sig(
&self,
- decl: &rustc_hir::FnDecl<'tcx>,
+ decl: &rustc_hir::FnDecl<'_>,
_generics: Option<&rustc_hir::Generics<'_>>,
_hir_id: rustc_hir::HirId,
_hir_ty: Option<&hir::Ty<'_>>,
diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs
index e31692492c263..fd1e37b842893 100644
--- a/compiler/rustc_hir_typeck/src/method/confirm.rs
+++ b/compiler/rustc_hir_typeck/src/method/confirm.rs
@@ -451,7 +451,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
&mut self,
preceding_args: &[ty::GenericArg<'tcx>],
param: &ty::GenericParamDef,
- arg: &GenericArg<'tcx>,
+ arg: &GenericArg<'_>,
) -> ty::GenericArg<'tcx> {
match (¶m.kind, arg) {
(GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => self
diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs
index b2e0a3bd7a195..8cf6cfbc8fffa 100644
--- a/compiler/rustc_hir_typeck/src/method/probe.rs
+++ b/compiler/rustc_hir_typeck/src/method/probe.rs
@@ -1139,7 +1139,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
for (bound_trait_pred, _) in
traits::expand_trait_aliases(self.tcx, [(trait_ref.upcast(self.tcx), self.span)]).0
{
- assert_eq!(bound_trait_pred.polarity(), ty::PredicatePolarity::Positive);
+ assert_eq!(bound_trait_pred.polarity(), ty::ClausePolarity::Positive);
let bound_trait_ref = bound_trait_pred.map_bound(|pred| pred.trait_ref);
for item in self.impl_or_trait_item(bound_trait_ref.def_id()) {
if !self.has_applicable_self(&item) {
diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs
index a22b6f746a952..05062155915d6 100644
--- a/compiler/rustc_hir_typeck/src/method/suggest.rs
+++ b/compiler/rustc_hir_typeck/src/method/suggest.rs
@@ -121,7 +121,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_pred)) =
predicate.kind().as_ref().skip_binder()
{
- let ty::TraitPredicate { trait_ref: ty::TraitRef { args, .. }, .. } = trait_pred;
+ let ty::TraitClause { trait_ref: ty::TraitRef { args, .. }, .. } = trait_pred;
if args.is_empty() {
return false;
}
@@ -1949,7 +1949,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
match pred.kind().skip_binder() {
ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) => {
self.tcx.is_lang_item(pred.def_id(), LangItem::Sized)
- && pred.polarity == ty::PredicatePolarity::Positive
+ && pred.polarity == ty::ClausePolarity::Positive
}
_ => false,
}
@@ -3543,7 +3543,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
foreign_preds
- .sort_by_key(|(_, pred): &(_, ty::TraitPredicate<'_>)| pred.trait_ref.to_string());
+ .sort_by_key(|(_, pred): &(_, ty::TraitClause<'_>)| pred.trait_ref.to_string());
for (_, pred) in &foreign_preds {
let ty = pred.self_ty();
@@ -3587,7 +3587,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// Returns Some(list_of_derives) if possible, or None if not.
fn consider_suggesting_derives_for_ty(
&self,
- trait_pred: ty::TraitPredicate<'tcx>,
+ trait_pred: ty::TraitClause<'tcx>,
adt: ty::AdtDef<'tcx>,
) -> Option> {
let diagnostic_name = self.tcx.get_diagnostic_name(trait_pred.def_id())?;
@@ -4848,9 +4848,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}),
);
- let trait_pred = ty::Binder::dummy(ty::TraitPredicate {
+ let trait_pred = ty::Binder::dummy(ty::TraitClause {
trait_ref,
- polarity: ty::PredicatePolarity::Positive,
+ polarity: ty::ClausePolarity::Positive,
});
let obligation = Obligation::new(self.tcx, self.misc(rcvr.span), self.param_env, trait_ref);
self.err_ctxt().note_different_trait_with_same_name(err, &obligation, trait_pred)
@@ -4947,7 +4947,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn suggest_hashmap_on_unsatisfied_hashset_buildhasher(
&self,
err: &mut Diag<'_>,
- pred: &ty::TraitPredicate<'_>,
+ pred: &ty::TraitClause<'_>,
adt: ty::AdtDef<'_>,
) -> bool {
if self.tcx.is_diagnostic_item(sym::HashSet, adt.did())
diff --git a/compiler/rustc_index_macros/src/newtype.rs b/compiler/rustc_index_macros/src/newtype.rs
index 076dc4c6f81e5..aaa025bd7cbdb 100644
--- a/compiler/rustc_index_macros/src/newtype.rs
+++ b/compiler/rustc_index_macros/src/newtype.rs
@@ -138,14 +138,12 @@ impl Parse for Newtype {
}
#[inline]
- #[cfg(not(bootstrap))]
fn forward_overflowing(start: Self, u: usize) -> (Self, bool) {
let (s, o) = Self::index(start).overflowing_add(u);
(Self::from_usize(s), o)
}
#[inline]
- #[cfg(not(bootstrap))]
fn backward_overflowing(start: Self, u: usize) -> (Self, bool) {
let (s, o) = Self::index(start).overflowing_sub(u);
(Self::from_usize(s), o)
diff --git a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs
index e0adcfc06a0ed..770520413c666 100644
--- a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs
+++ b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs
@@ -46,7 +46,7 @@ impl<'tcx> InferCtxt<'tcx> {
V: TypeFoldable>,
{
let ty::ParamEnvAnd { param_env, value } = value;
- let canonical_param_env = self.tcx.canonical_param_env_cache.get_or_insert(
+ let canonical_param_env = self.tcx.caches.canonical_param_env_cache.get_or_insert(
self.tcx,
param_env,
query_state,
diff --git a/compiler/rustc_infer/src/infer/canonical/instantiate.rs b/compiler/rustc_infer/src/infer/canonical/instantiate.rs
index 9df7b35211df0..7e670cc233752 100644
--- a/compiler/rustc_infer/src/infer/canonical/instantiate.rs
+++ b/compiler/rustc_infer/src/infer/canonical/instantiate.rs
@@ -143,17 +143,18 @@ impl<'tcx> TypeFolder> for CanonicalInstantiator<'tcx> {
// is both expensive (depending on the size of the clauses) and a pure function.
let index = *self
.tcx
+ .caches
.highest_var_in_clauses_cache
.lock()
.entry(c)
.or_insert_with(|| highest_var_in_clauses(c));
let c_args = &self.var_values[..=index];
- if let Some(c) = self.tcx.clauses_cache.lock().get(&(c, c_args)) {
+ if let Some(c) = self.tcx.caches.clauses_cache.lock().get(&(c, c_args)) {
c
} else {
let folded = c.super_fold_with(self);
- self.tcx.clauses_cache.lock().insert((c, c_args), folded);
+ self.tcx.caches.clauses_cache.lock().insert((c, c_args), folded);
folded
}
}
diff --git a/compiler/rustc_infer/src/infer/opaque_types/mod.rs b/compiler/rustc_infer/src/infer/opaque_types/mod.rs
index 08c7c49417124..70423ca7da1be 100644
--- a/compiler/rustc_infer/src/infer/opaque_types/mod.rs
+++ b/compiler/rustc_infer/src/infer/opaque_types/mod.rs
@@ -335,7 +335,7 @@ impl<'tcx> InferCtxt<'tcx> {
goals.push(Goal::new(
self.tcx,
param_env,
- ty::ProjectionPredicate {
+ ty::ProjectionClause {
projection_term: projection_ty.into(),
term: ty_var.into(),
},
diff --git a/compiler/rustc_infer/src/infer/projection.rs b/compiler/rustc_infer/src/infer/projection.rs
index 43870ccbdd39b..5736b0a24eff3 100644
--- a/compiler/rustc_infer/src/infer/projection.rs
+++ b/compiler/rustc_infer/src/infer/projection.rs
@@ -29,7 +29,7 @@ impl<'tcx> InferCtxt<'tcx> {
self.next_const_var(span).into()
};
- let projection = ty::ProjectionPredicate { projection_term: alias_term, term: infer_var };
+ let projection = ty::ProjectionClause { projection_term: alias_term, term: infer_var };
let obligation =
Obligation::with_depth(self.tcx, cause, recursion_depth, param_env, projection);
obligations.push(obligation);
diff --git a/compiler/rustc_infer/src/infer/relate/generalize.rs b/compiler/rustc_infer/src/infer/relate/generalize.rs
index 0e4ebdfb90085..afdabb38c3b20 100644
--- a/compiler/rustc_infer/src/infer/relate/generalize.rs
+++ b/compiler/rustc_infer/src/infer/relate/generalize.rs
@@ -171,7 +171,7 @@ impl<'tcx> InferCtxt<'tcx> {
// instead create a new inference variable `?normalized_source`, emitting
// `Projection(normalized_source, ?ty_normalized)` and
// `?normalized_source <: generalized_term`.
- relation.register_predicates([ty::ProjectionPredicate {
+ relation.register_predicates([ty::ProjectionClause {
projection_term: source_alias,
term: generalized_term,
}]);
diff --git a/compiler/rustc_infer/src/traits/mod.rs b/compiler/rustc_infer/src/traits/mod.rs
index 86aae77adcf8e..b3552bc68d517 100644
--- a/compiler/rustc_infer/src/traits/mod.rs
+++ b/compiler/rustc_infer/src/traits/mod.rs
@@ -87,8 +87,8 @@ impl Hash for Obligation<'_, T> {
}
pub type PredicateObligation<'tcx> = Obligation<'tcx, ty::Predicate<'tcx>>;
-pub type TraitObligation<'tcx> = Obligation<'tcx, ty::TraitPredicate<'tcx>>;
-pub type PolyTraitObligation<'tcx> = Obligation<'tcx, ty::PolyTraitPredicate<'tcx>>;
+pub type TraitObligation<'tcx> = Obligation<'tcx, ty::TraitClause<'tcx>>;
+pub type PolyTraitObligation<'tcx> = Obligation<'tcx, ty::PolyTraitClause<'tcx>>;
pub type PredicateObligations<'tcx> = ThinVec>;
@@ -175,7 +175,7 @@ impl<'tcx, O> Obligation<'tcx, O> {
}
impl<'tcx> PolyTraitObligation<'tcx> {
- pub fn polarity(&self) -> ty::PredicatePolarity {
+ pub fn polarity(&self) -> ty::ClausePolarity {
self.predicate.skip_binder().polarity
}
diff --git a/compiler/rustc_infer/src/traits/util.rs b/compiler/rustc_infer/src/traits/util.rs
index 2630c8b125418..cc29546adb880 100644
--- a/compiler/rustc_infer/src/traits/util.rs
+++ b/compiler/rustc_infer/src/traits/util.rs
@@ -81,7 +81,7 @@ impl<'tcx> Elaboratable> for PredicateObligation<'tcx> {
&self,
clause: ty::Clause<'tcx>,
span: Span,
- parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
+ parent_trait_pred: ty::PolyTraitClause<'tcx>,
index: usize,
) -> Self {
let cause = self.cause.clone().derived_cause(parent_trait_pred, |derived| {
@@ -126,7 +126,7 @@ pub fn transitive_bounds_that_define_assoc_item<'tcx>(
.map(Unnormalized::skip_norm_wip)
.map(|(clause, _)| clause.instantiate_supertrait(tcx, trait_ref))
.filter_map(|clause| clause.as_trait_clause())
- .filter(|clause| clause.polarity() == ty::PredicatePolarity::Positive)
+ .filter(|clause| clause.polarity() == ty::ClausePolarity::Positive)
.map(|clause| clause.map_bound(|clause| clause.trait_ref)),
);
diff --git a/compiler/rustc_interface/src/callbacks.rs b/compiler/rustc_interface/src/callbacks.rs
index b2ad70bc4811b..2fad0297e31e0 100644
--- a/compiler/rustc_interface/src/callbacks.rs
+++ b/compiler/rustc_interface/src/callbacks.rs
@@ -12,7 +12,7 @@
use std::fmt;
use rustc_errors::DiagInner;
-use rustc_middle::dep_graph::{DepNodeIndex, QuerySideEffect, TaskDepsRef};
+use rustc_middle::dep_graph::{QuerySideEffect, TaskDepsRef};
use rustc_middle::ty::tls;
use rustc_span::Symbol;
@@ -59,13 +59,13 @@ fn track_feature(feature: Symbol) {
};
let tcx = icx.tcx;
- if let Some(dep_node_index) = tcx.sess.used_features.lock().get(&feature).copied() {
- tcx.dep_graph.read_index(DepNodeIndex::from_u32(dep_node_index));
+ if let Some(dep_node_index) = tcx.query_system.used_features.lock().get(&feature).copied() {
+ tcx.dep_graph.read_index(dep_node_index);
} else {
let dep_node_index = tcx
.dep_graph
.encode_side_effect(tcx, QuerySideEffect::CheckFeature { symbol: feature });
- tcx.sess.used_features.lock().insert(feature, dep_node_index.as_u32());
+ tcx.query_system.used_features.lock().insert(feature, dep_node_index);
tcx.dep_graph.read_index(dep_node_index);
}
})
diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs
index b059cae647341..fa9d2f8e852b5 100644
--- a/compiler/rustc_interface/src/passes.rs
+++ b/compiler/rustc_interface/src/passes.rs
@@ -1011,8 +1011,8 @@ pub fn create_and_enter_global_ctxt FnOnce(TyCtxt<'tcx>) -> T>(
untracked,
incr_comp_session.as_ref(),
dep_graph,
- rustc_query_impl::make_dep_kind_vtables(&arena),
rustc_query_impl::query_system(
+ &arena,
providers.queries,
providers.extern_queries,
query_result_on_disk_cache,
diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs
index 627fb962d5dbf..370614d5d8ebc 100644
--- a/compiler/rustc_lint/src/builtin.rs
+++ b/compiler/rustc_lint/src/builtin.rs
@@ -557,7 +557,7 @@ fn type_implements_negative_copy_modulo_regions<'tcx>(
) -> bool {
let (infcx, param_env) = tcx.infer_ctxt().build_with_typing_env(typing_env);
let trait_ref = ty::TraitRef::new(tcx, tcx.require_lang_item(LangItem::Copy, DUMMY_SP), [ty]);
- let pred = ty::TraitPredicate { trait_ref, polarity: ty::PredicatePolarity::Negative };
+ let pred = ty::TraitClause { trait_ref, polarity: ty::ClausePolarity::Negative };
let obligation = traits::Obligation {
cause: traits::ObligationCause::dummy(),
param_env,
diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs
index 454e99f2d29e0..2cac8551f1bfb 100644
--- a/compiler/rustc_lint/src/internal.rs
+++ b/compiler/rustc_lint/src/internal.rs
@@ -7,7 +7,7 @@ use rustc_hir as hir;
use rustc_hir::def::Res;
use rustc_hir::def_id::DefId;
use rustc_hir::{Expr, ExprKind, HirId, find_attr};
-use rustc_middle::ty::{self, GenericArgsRef, PredicatePolarity};
+use rustc_middle::ty::{self, ClausePolarity, GenericArgsRef};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::hygiene::{ExpnKind, MacroKind};
use rustc_span::{Span, sym};
@@ -135,7 +135,7 @@ fn has_unstable_into_iter_predicate<'tcx>(
continue;
};
if trait_clause.def_id() != into_iterator_def_id
- || trait_clause.polarity() != PredicatePolarity::Positive
+ || trait_clause.polarity() != ClausePolarity::Positive
{
continue;
}
diff --git a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs
index d9dfe5fa7de0c..78030e9b17b1b 100644
--- a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs
+++ b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs
@@ -1,7 +1,7 @@
use rustc_hir::{self as hir, AmbigArg};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_macros::{Diagnostic, Subdiagnostic};
-use rustc_middle::ty::print::{PrintTraitPredicateExt as _, TraitPredPrintModifiersAndPath};
+use rustc_middle::ty::print::{PrintTraitClauseExt as _, TraitClausePrintModifiersAndPath};
use rustc_middle::ty::{self, BottomUpFolder, Ty, TypeFoldable, Unnormalized};
use rustc_session::{declare_lint, declare_lint_pass};
use rustc_span::{Span, kw};
@@ -229,5 +229,5 @@ struct OpaqueHiddenInferredBoundLint<'tcx> {
struct AddBound<'tcx> {
#[primary_span]
suggest_span: Span,
- trait_ref: TraitPredPrintModifiersAndPath<'tcx>,
+ trait_ref: TraitClausePrintModifiersAndPath<'tcx>,
}
diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs
index da2220cf7a5fd..5ee3c5a741bdc 100644
--- a/compiler/rustc_lint_defs/src/builtin.rs
+++ b/compiler/rustc_lint_defs/src/builtin.rs
@@ -4560,16 +4560,13 @@ declare_lint! {
///
/// ### Example
///
- // FIXME(bootstrap): Use a regular Rust doc code block after stage 0 emits
- // `malformed_diagnostic_filters` instead of E0232 for this example.
- #[cfg_attr(bootstrap, doc = "```rust,ignore (stage 0 emits E0232)")]
- #[cfg_attr(not(bootstrap), doc = "```rust")]
+ /// ```rust
/// #![feature(rustc_attrs)]
/// #![allow(internal_features)]
///
/// #[rustc_on_unimplemented(on(invalid, message = "unused"))]
/// trait Trait {}
- #[doc = "```"]
+ /// ```
///
/// {{produces}}
///
@@ -5650,13 +5647,12 @@ declare_lint! {
///
/// ### Example
///
- #[cfg_attr(bootstrap, doc = "```rust,compile_fail")]
- #[cfg_attr(not(bootstrap), doc = "```rust,no_run")]
+ /// ```rust,no_run
/// fn main() {
/// let x = panic!();
/// x.clone();
/// }
- #[doc = "```"]
+ /// ```
///
/// {{produces}}
///
diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs
index f4d3380594c9f..8a565369d7610 100644
--- a/compiler/rustc_metadata/src/rmeta/decoder.rs
+++ b/compiler/rustc_metadata/src/rmeta/decoder.rs
@@ -411,12 +411,12 @@ impl<'a, 'tcx> TyDecoder<'tcx> for MetadataDecodeContext<'a, 'tcx> {
let key = ty::CReaderCacheKey { cnum: Some(self.cdata.cnum), pos: shorthand };
- if let Some(&ty) = tcx.ty_rcache.borrow().get(&key) {
+ if let Some(&ty) = tcx.caches.ty_rcache.borrow().get(&key) {
return ty;
}
let ty = or_insert_with(self);
- tcx.ty_rcache.borrow_mut().insert(key, ty);
+ tcx.caches.ty_rcache.borrow_mut().insert(key, ty);
ty
}
diff --git a/compiler/rustc_middle/src/dep_graph/graph.rs b/compiler/rustc_middle/src/dep_graph/graph.rs
index 08bb5efc685ee..a4165d793069d 100644
--- a/compiler/rustc_middle/src/dep_graph/graph.rs
+++ b/compiler/rustc_middle/src/dep_graph/graph.rs
@@ -48,7 +48,7 @@ pub enum QuerySideEffect {
/// effect dep node as a dependency.
Diagnostic(DiagInner),
/// Records the feature used during query execution.
- /// This feature will be inserted into `sess.used_features`
+ /// This feature will be inserted into `query_system.used_features`
/// if we mark the query as green, as that query will have
/// the side effect dep node as a dependency.
CheckFeature { symbol: Symbol },
@@ -779,7 +779,7 @@ impl DepGraphData {
tcx.dcx().emit_diagnostic(diagnostic.clone());
}
QuerySideEffect::CheckFeature { symbol } => {
- tcx.sess.used_features.lock().insert(*symbol, dep_node_index.as_u32());
+ tcx.query_system.used_features.lock().insert(*symbol, dep_node_index);
}
}
@@ -1230,8 +1230,7 @@ impl CurrentDepGraph {
CurrentDepGraph {
encoder: GraphEncoder::new(session, encoder, prev_index_space_len, previous),
anon_node_to_index: ShardedHashMap::with_capacity(
- // FIXME: The count estimate is off as anon nodes are only a portion of the nodes.
- new_node_count_estimate,
+ 3 * new_node_count_estimate / 100, // Reserve capacity for 3% anon nodes
),
anon_id_seed,
#[cfg(debug_assertions)]
diff --git a/compiler/rustc_middle/src/dep_graph/mod.rs b/compiler/rustc_middle/src/dep_graph/mod.rs
index 3389c3ec91a5a..e63a281002f0d 100644
--- a/compiler/rustc_middle/src/dep_graph/mod.rs
+++ b/compiler/rustc_middle/src/dep_graph/mod.rs
@@ -80,7 +80,7 @@ where
impl<'tcx> TyCtxt<'tcx> {
#[inline]
pub fn dep_kind_vtable(self, dk: DepKind) -> &'tcx DepKindVTable<'tcx> {
- &self.dep_kind_vtables[dk.as_usize()]
+ &self.query_system.dep_kind_vtables[dk.as_usize()]
}
#[inline(always)]
diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs
index 0f30498ee09cb..60fb7fb53a533 100644
--- a/compiler/rustc_middle/src/lib.rs
+++ b/compiler/rustc_middle/src/lib.rs
@@ -81,6 +81,7 @@ pub mod metadata;
pub mod middle;
pub mod mir;
pub mod mono;
+pub mod ptrauth;
pub mod queries;
pub mod query;
pub mod thir;
diff --git a/compiler/rustc_middle/src/mir/graphviz.rs b/compiler/rustc_middle/src/mir/graphviz.rs
index 4002d0ebd392d..1cd34c35bb313 100644
--- a/compiler/rustc_middle/src/mir/graphviz.rs
+++ b/compiler/rustc_middle/src/mir/graphviz.rs
@@ -65,8 +65,8 @@ where
// Graph label
let mut label = String::from("");
- // FIXME: remove this unwrap
- write_graph_label(tcx, body, &mut label).unwrap();
+ write_graph_label(tcx, body, &mut label)
+ .map_err(|_| io::Error::other("failed to write graph label"))?;
let g = mir_fn_to_generic_graph(tcx, body);
let settings = GraphvizSettings {
graph_attrs: Some(graph_attrs.join(" ")),
diff --git a/compiler/rustc_middle/src/ptrauth/discriminator.rs b/compiler/rustc_middle/src/ptrauth/discriminator.rs
new file mode 100644
index 0000000000000..7501f1b072188
--- /dev/null
+++ b/compiler/rustc_middle/src/ptrauth/discriminator.rs
@@ -0,0 +1,491 @@
+//! Function pointer type discrimination for pointer authentication.
+
+//! This module implements Rust's equivalent of Clang's function pointer type
+//! discriminator computation used in pointer authentication.
+//!
+//! Compatibility with Clang is a primary goal. The discriminator produced for a
+//! given external "C" function type must match the value computed by Clang so that
+//! function pointers can be exchanged safely between Rust and C code while
+//! preserving pointer authentication semantics.
+//!
+//! The implementation mirrors Clang's behavior in
+//! `ASTContext::encodeTypeForFunctionPointerAuth`, ensuring that identical
+//! C-compatible function types produce identical discriminators. See:
+//! .
+//!
+//! ## Overview
+//!
+//! The computation is structured into three conceptual stages:
+//!
+//! ### 1. Type normalization and lowering
+//! Rust types are converted into a language-independent representation
+//! (`ClangDiscTy`) that mirrors the type categories used by Clang when computing
+//! function pointer discriminators. This includes canonicalization such as
+//! treating all pointer-like types uniformly and mapping Rust constructs onto
+//! their closest C equivalents.
+//! One notable exception is C `_Complex`. Rust has no corresponding native type,
+//! so there is no canonical Rust representation to map onto Clang's `_Complex`
+//! type category. Rather than infer one (for example, by treating `(f32, f32)`
+//! or `(f64, f64)` as complex numbers), this implementation leaves such
+//! representation choices to users and does not provide dedicated `_Complex`
+//! encoding.
+//!
+//! ### 2. Type encoding
+//! The lowered representation is serialized into a byte stream using rules
+//! intended to match Clang's implementation in:
+//! `encodeTypeForFunctionPointerAuth`. The resulting encoding describes the
+//! function signature in a target-independent form suitable for hashing.
+//!
+//! ### 3. Discriminator hashing
+//! The encoded byte stream is hashed using LLVM's stable SipHash-2-4 based
+//! discriminator algorithm. The implementation here is a direct translation
+//! of LLVM/Clang's logic and must remain bit-for-bit compatible. See:
+//! .
+//! Defined in `llvm_siphash.rs`.
+//!
+//! ## Module structure
+//!
+//! - High-level API
+//! - `FnPtrDiscriminatorSource`
+//! - `ptrauth_compute_fn_ptr_type_discriminator_for`
+//! - `ptrauth_clone_discriminated_schema_for`
+//!
+//! - Low-level API
+//! - `FnPtrTypeDiscriminatorInput`
+//! - `compute_fn_ptr_type_discriminator`
+//!
+//! - Signature extraction
+//! - `extract_fn_ptr_type`
+//!
+//! - Clang-compatible type model
+//! - `ClangDiscTy`
+//! - `canonicalize_c_type`
+//! - `to_clang_disc_ty`
+//!
+//! - Encoding
+//! - `PtrauthEncoder`
+//! - `encode_ty`
+//!
+//! ## Compatibility requirements
+//!
+//! Any changes to the encoding or hashing logic should be validated against Clang's
+//! discriminator computation. Divergence from Clang will result in incompatible
+//! pointer authentication values across language boundaries.
+//!
+//! This implementation intentionally approximates Clang's behavior for extern "C"
+//! function types only. It does NOT attempt to model full type system rules.
+
+use rustc_abi::ExternAbi;
+use rustc_middle::ty::{self, Instance, Ty, TyCtxt, Unnormalized};
+use rustc_session::PointerAuthSchema;
+use rustc_span::sym;
+
+use crate::ptrauth::llvm_siphash::llvm_pointer_auth_stable_siphash;
+
+/// Types that can serve as a source for function pointer type discrimination.
+///
+/// This trait abstracts over the different compiler representations from which
+/// a function signature can be obtained. Implementations construct the
+/// canonical `FnPtrTypeDiscriminatorInput` consumed by the discriminator
+/// computation.
+///
+/// This is intended primarily for ergonomic use at call sites, allowing code
+/// to compute discriminators directly from an `Instance`, `Ty`, or `FnSig`
+/// without manually constructing the intermediate representation.
+pub trait FnPtrDiscriminatorSource<'tcx>: Sized {
+ fn discriminator_input(self, tcx: TyCtxt<'tcx>) -> Option>;
+}
+
+/// Enables discriminator computation directly from Rust function types.
+///
+/// Accepts both:
+/// - `FnPtr`: actual function pointer types
+/// - `FnDef`: function items
+///
+/// FnDef is only accepted for convenience; the discriminator is still computed
+/// from the instantiated function signature.
+impl<'tcx> FnPtrDiscriminatorSource<'tcx> for Ty<'tcx> {
+ fn discriminator_input(self, tcx: TyCtxt<'tcx>) -> Option> {
+ let ty = extract_fn_ptr_type(tcx, self)?;
+
+ match ty.kind() {
+ ty::FnPtr(sig, header) => {
+ let sig = sig.skip_binder();
+ Some(FnPtrTypeDiscriminatorInput::from_sig_tys(sig, header))
+ }
+
+ ty::FnDef(def_id, args) => {
+ let sig = tcx.fn_sig(*def_id).instantiate(tcx, args.skip_binder()).skip_binder();
+
+ Some(FnPtrTypeDiscriminatorInput::from_sig(sig))
+ }
+
+ _ => None,
+ }
+ }
+}
+/// Enables discriminator computation directly from monomorphized function
+/// instances.
+///
+/// The instance's signature is instantiated using its generic arguments and
+/// normalized before constructing the canonical discriminator input.
+impl<'tcx> FnPtrDiscriminatorSource<'tcx> for Instance<'tcx> {
+ fn discriminator_input(self, tcx: TyCtxt<'tcx>) -> Option> {
+ let sig = tcx
+ .instantiate_and_normalize_erasing_regions(
+ self.args,
+ ty::TypingEnv::fully_monomorphized(),
+ tcx.fn_sig(self.def_id()),
+ )
+ .skip_binder();
+
+ Some(FnPtrTypeDiscriminatorInput::from_sig(sig))
+ }
+}
+/// Enables discriminator computation directly from instantiated function
+/// signatures.
+///
+/// The signature is assumed to already be instantiated and normalized.
+impl<'tcx> FnPtrDiscriminatorSource<'tcx> for ty::FnSig<'tcx> {
+ fn discriminator_input(self, _: TyCtxt<'tcx>) -> Option> {
+ Some(FnPtrTypeDiscriminatorInput::from_sig(self))
+ }
+}
+
+/// Computes the function pointer type discriminator directly from a supported
+/// source.
+///
+/// This is a convenience wrapper around
+/// `FnPtrDiscriminatorSource::discriminator_input` and
+/// `compute_fn_ptr_type_discriminator`.
+///
+/// Returns `None` if the supplied source does not represent a function pointer
+/// type (for example, a non-function `Ty`).
+pub fn ptrauth_compute_fn_ptr_type_discriminator_for<'tcx, S>(
+ tcx: TyCtxt<'tcx>,
+ source: S,
+) -> Option
+where
+ S: FnPtrDiscriminatorSource<'tcx>,
+{
+ let input = source.discriminator_input(tcx)?;
+ Some(compute_fn_ptr_type_discriminator(tcx, &input))
+}
+
+/// Clones a pointer authentication schema and updates its constant
+/// discriminator.
+///
+/// If `schema` is `Some`, the function computes a function pointer type
+/// discriminator from `source` and stores it in the cloned schema's
+/// `constant_discriminator` field.
+///
+/// If no discriminator can be computed (for example, because `source` does not
+/// represent a function pointer type), the schema is returned unchanged.
+///
+/// This is intended as a convenience helper for code generation sites that need
+/// to attach function pointer type discrimination to a generic schema before
+/// calling `get_fn_addr`.
+pub fn ptrauth_clone_discriminated_schema_for<'tcx, S>(
+ tcx: TyCtxt<'tcx>,
+ mut schema: Option,
+ source: S,
+) -> Option
+where
+ S: FnPtrDiscriminatorSource<'tcx>,
+{
+ if let Some(ref mut s) = schema {
+ if let Some(disc) = ptrauth_compute_fn_ptr_type_discriminator_for(tcx, source) {
+ s.constant_discriminator = disc;
+ }
+ }
+
+ schema
+}
+
+/// Canonical representation of a function signature used for pointer
+/// authentication discriminator generation.
+#[derive(Debug)]
+pub struct FnPtrTypeDiscriminatorInput<'tcx> {
+ inputs: &'tcx [Ty<'tcx>],
+ output: Ty<'tcx>,
+ abi: ExternAbi,
+ c_variadic: bool,
+}
+
+impl<'tcx> FnPtrTypeDiscriminatorInput<'tcx> {
+ fn from_sig(sig: ty::FnSig<'tcx>) -> Self {
+ FnPtrTypeDiscriminatorInput {
+ inputs: sig.inputs(),
+ output: sig.output(),
+ abi: sig.abi(),
+ c_variadic: sig.c_variadic(),
+ }
+ }
+
+ fn from_sig_tys(sig: ty::FnSigTys>, header: &ty::FnHeader>) -> Self {
+ FnPtrTypeDiscriminatorInput {
+ inputs: sig.inputs(),
+ output: sig.output(),
+ abi: header.abi(),
+ c_variadic: header.c_variadic(),
+ }
+ }
+}
+
+/// Unwraps optional function pointers and normalizes the type.
+///
+/// Only `Option` is supported for nullability modeling, matching C ABI
+/// null pointer conventions.
+fn extract_fn_ptr_type<'tcx>(tcx: TyCtxt<'tcx>, mut ty: Ty<'tcx>) -> Option> {
+ ty = tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), Unnormalized::new(ty));
+
+ loop {
+ match ty.kind() {
+ ty::Adt(def, args) if tcx.lang_items().option_type() == Some(def.did()) => {
+ ty = args.type_at(0);
+ continue;
+ }
+
+ ty::FnPtr(..) | ty::FnDef(..) => {
+ return Some(ty);
+ }
+
+ _ => return None,
+ }
+ }
+}
+
+/// Computes the Clang-compatible function pointer type discriminator.
+///
+/// This is the low-level discriminator computation routine operating on an
+/// already constructed `FnPtrTypeDiscriminatorInput`.
+fn compute_fn_ptr_type_discriminator<'tcx>(
+ tcx: TyCtxt<'tcx>,
+ input: &FnPtrTypeDiscriminatorInput<'tcx>,
+) -> u16 {
+ if !matches!(input.abi, ExternAbi::C { .. } | ExternAbi::System { .. }) {
+ return 0;
+ }
+
+ let mut enc = PtrauthEncoder::new();
+ enc.push(b'F');
+
+ encode_ty(&mut enc, tcx, input.output);
+
+ for &arg in input.inputs {
+ encode_ty(&mut enc, tcx, arg);
+ }
+
+ if input.c_variadic {
+ enc.push(b'z');
+ }
+
+ enc.push(b'E');
+
+ let hash = enc.finish();
+
+ hash.into()
+}
+
+// Clang disc type.
+#[derive(Debug)]
+enum ClangDiscTy<'tcx> {
+ Int,
+ Float(&'tcx ty::FloatTy),
+ Bool,
+ Char,
+
+ // Pointer-like types in the C ABI sense.
+ // This includes:
+ // - raw pointers (`*const T`, `*mut T`)
+ // - Rust references (`&T`, `&mut T`)
+ // - function pointers
+ // All collapse to a single Clang-compatible 'P' node.
+ Pointer,
+
+ Array { elem: Ty<'tcx> },
+
+ // FIXME(jchlands) Decide if to support Complex types in future. Clang has
+ // dedicated node for this `Type::Complex`, Rust does not. So we could match
+ // against a Tuple(FP_TYPE, FP_TYPE).
+ // Complex(Ty<'tcx>),
+ Vector { bytes: u64 },
+
+ EnumLikeInt,
+ AdtName(String),
+ Opaque,
+ Void,
+}
+
+// Canonicalize Option-wrapped pointer types used to model C nullable pointers.
+//
+// Rust and Clang should compute identical discriminators for equivalent C APIs.
+// Clang does not distinguish nullable from non-nullable pointer types when
+// computing function pointer authentication discriminators, so
+// `Option` and `Option<*mut T>` are encoded identically to their
+// underlying pointer types.
+//
+// Although `Option<*mut T>` is not considered FFI-safe by Rust and triggers the
+// `improper_ctypes`/`improper_ctypes_definitions` lints, this is a warning
+// rather than a hard error. Canonicalizing it here preserves Clang-compatible
+// discriminator computation.
+//
+// Please see the following tests for sample use cases:
+// pauth-fn-ptr-type-discrimination-option-callback.rs,
+// pauth-fn-ptr-type-discrimination-option-return.rs and pauth-fn-ptr-type-discrimination-option.rs
+fn canonicalize_c_type<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
+ if let ty::Adt(def, args) = ty.kind()
+ && tcx.is_diagnostic_item(sym::Option, def.did())
+ {
+ let inner = args.type_at(0);
+
+ match inner.kind() {
+ ty::FnPtr(..) | ty::RawPtr(..) => return inner,
+ _ => {}
+ }
+ }
+
+ ty
+}
+
+/// Lowers a Rust type into a Clang-compatible discriminator type.
+///
+/// This is not a full semantic translation of Rust types. It is a lossy mapping
+/// that intentionally matches Clang's function pointer authentication encoding
+/// rules where Rust has a direct language-level equivalent.
+///
+/// In particular C `_Complex`, without a canonical Rust equivalent, is not
+/// recognized. This avoids introducing heuristics for user-defined
+/// representations that may vary across codebases.
+///
+/// Important invariants:
+/// - All pointer-like types (Rust refs, raw pointers, fn pointers) collapse to
+/// `Pointer`.
+/// - Struct/union types are encoded using name only, not layout.
+/// - Enums are treated as integers.
+/// - SIMD types are encoded only by total byte size (no lane semantics).
+/// - No attempt is made to recognize user-defined representations of C
+/// `_Complex` types.
+/// This must remain in sync with Clang's `encodeTypeForFunctionPointerAuth`.
+fn to_clang_disc_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> ClangDiscTy<'tcx> {
+ let ty = canonicalize_c_type(tcx, ty);
+ match ty.kind() {
+ // C void / Rust ()
+ _ if ty.is_unit() => ClangDiscTy::Void,
+
+ // scalars
+ ty::Bool => ClangDiscTy::Bool,
+ ty::Char => ClangDiscTy::Char,
+
+ ty::Int(_) | ty::Uint(_) => ClangDiscTy::Int,
+ ty::Float(f) => ClangDiscTy::Float(f),
+
+ // everything pointer-like collapses
+ ty::RawPtr(..) | ty::Ref(..) | ty::FnPtr(..) | ty::Dynamic(..) | ty::Slice(_) | ty::Str => {
+ ClangDiscTy::Pointer
+ }
+
+ // arrays ignore size
+ ty::Array(elem, _) => ClangDiscTy::Array { elem: *elem },
+
+ // enums to integer collapse
+ ty::Adt(def, _) if def.is_enum() => ClangDiscTy::EnumLikeInt,
+ // simd vectors
+ ty::Adt(def, args) if def.repr().simd() => {
+ // Clang encodes SIMD vectors by their total size
+ let input = ty::PseudoCanonicalInput {
+ typing_env: ty::TypingEnv::fully_monomorphized(),
+ value: ty,
+ };
+
+ let Ok(layout) = tcx.layout_of(input) else {
+ tcx.dcx().delayed_bug("could not compute SIMD layout");
+ return ClangDiscTy::Opaque;
+ };
+
+ let bytes = layout.size.bytes();
+
+ ClangDiscTy::Vector { bytes }
+ }
+ // structs/unions to name-based identity
+ ty::Adt(def, _) => {
+ let name = tcx.item_name(def.did()).to_string();
+ ClangDiscTy::AdtName(name)
+ }
+
+ ty::Foreign(_) => ClangDiscTy::Opaque,
+
+ _ => ClangDiscTy::Opaque,
+ }
+}
+
+// Encoder
+struct PtrauthEncoder {
+ buf: Vec,
+}
+
+impl PtrauthEncoder {
+ fn new() -> Self {
+ Self { buf: Vec::new() }
+ }
+
+ fn push(&mut self, b: u8) {
+ self.buf.push(b);
+ }
+
+ fn push_str(&mut self, s: &str) {
+ self.buf.extend_from_slice(s.as_bytes());
+ }
+
+ fn finish(&self) -> u16 {
+ llvm_pointer_auth_stable_siphash(&self.buf)
+ }
+}
+
+/// Encodes a ClangDiscTy into the discriminator byte stream.
+///
+/// This format is intended to be bit-for-bit compatible with Clang's
+/// `encodeTypeForFunctionPointerAuth`.
+fn encode_ty<'tcx>(enc: &mut PtrauthEncoder, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) {
+ let cty = to_clang_disc_ty(tcx, ty);
+
+ match cty {
+ // scalars
+ ClangDiscTy::Bool | ClangDiscTy::Char | ClangDiscTy::Int => enc.push(b'i'),
+
+ ClangDiscTy::Float(f) => match f.bit_width() {
+ 16 => enc.push_str("Dh"),
+ 32 => enc.push(b'f'),
+ 64 => enc.push(b'd'),
+ 128 => enc.push(b'g'),
+ _ => enc.push(b'?'),
+ },
+
+ ClangDiscTy::Void => enc.push(b'v'),
+
+ // pointer boundary (NO RECURSION)
+ ClangDiscTy::Pointer => enc.push(b'P'),
+
+ // arrays ignore size
+ ClangDiscTy::Array { elem } => {
+ enc.push(b'A');
+ encode_ty(enc, tcx, elem);
+ }
+
+ // enums collapse
+ ClangDiscTy::EnumLikeInt => enc.push(b'i'),
+
+ // ADT identity
+ ClangDiscTy::AdtName(name) => {
+ enc.push_str(&name.len().to_string());
+ enc.push_str(&name);
+ }
+
+ ClangDiscTy::Opaque => enc.push(b'?'),
+
+ ClangDiscTy::Vector { bytes } => {
+ enc.push_str("Dv");
+ enc.push_str(&bytes.to_string());
+ }
+ }
+}
diff --git a/compiler/rustc_middle/src/ptrauth/llvm_siphash/llvm_siphash_vectors.rs b/compiler/rustc_middle/src/ptrauth/llvm_siphash/llvm_siphash_vectors.rs
new file mode 100644
index 0000000000000..3dc799f07b27d
--- /dev/null
+++ b/compiler/rustc_middle/src/ptrauth/llvm_siphash/llvm_siphash_vectors.rs
@@ -0,0 +1,68 @@
+pub(super) const TEST_KEY: [u8; 16] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
+
+pub(super) const EXPECTED64: [[u8; 8]; 64] = [
+ [0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72],
+ [0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74],
+ [0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d],
+ [0x2d, 0x7e, 0xfb, 0xd7, 0x96, 0x66, 0x67, 0x85],
+ [0xb7, 0x87, 0x71, 0x27, 0xe0, 0x94, 0x27, 0xcf],
+ [0x8d, 0xa6, 0x99, 0xcd, 0x64, 0x55, 0x76, 0x18],
+ [0xce, 0xe3, 0xfe, 0x58, 0x6e, 0x46, 0xc9, 0xcb],
+ [0x37, 0xd1, 0x01, 0x8b, 0xf5, 0x00, 0x02, 0xab],
+ [0x62, 0x24, 0x93, 0x9a, 0x79, 0xf5, 0xf5, 0x93],
+ [0xb0, 0xe4, 0xa9, 0x0b, 0xdf, 0x82, 0x00, 0x9e],
+ [0xf3, 0xb9, 0xdd, 0x94, 0xc5, 0xbb, 0x5d, 0x7a],
+ [0xa7, 0xad, 0x6b, 0x22, 0x46, 0x2f, 0xb3, 0xf4],
+ [0xfb, 0xe5, 0x0e, 0x86, 0xbc, 0x8f, 0x1e, 0x75],
+ [0x90, 0x3d, 0x84, 0xc0, 0x27, 0x56, 0xea, 0x14],
+ [0xee, 0xf2, 0x7a, 0x8e, 0x90, 0xca, 0x23, 0xf7],
+ [0xe5, 0x45, 0xbe, 0x49, 0x61, 0xca, 0x29, 0xa1],
+ [0xdb, 0x9b, 0xc2, 0x57, 0x7f, 0xcc, 0x2a, 0x3f],
+ [0x94, 0x47, 0xbe, 0x2c, 0xf5, 0xe9, 0x9a, 0x69],
+ [0x9c, 0xd3, 0x8d, 0x96, 0xf0, 0xb3, 0xc1, 0x4b],
+ [0xbd, 0x61, 0x79, 0xa7, 0x1d, 0xc9, 0x6d, 0xbb],
+ [0x98, 0xee, 0xa2, 0x1a, 0xf2, 0x5c, 0xd6, 0xbe],
+ [0xc7, 0x67, 0x3b, 0x2e, 0xb0, 0xcb, 0xf2, 0xd0],
+ [0x88, 0x3e, 0xa3, 0xe3, 0x95, 0x67, 0x53, 0x93],
+ [0xc8, 0xce, 0x5c, 0xcd, 0x8c, 0x03, 0x0c, 0xa8],
+ [0x94, 0xaf, 0x49, 0xf6, 0xc6, 0x50, 0xad, 0xb8],
+ [0xea, 0xb8, 0x85, 0x8a, 0xde, 0x92, 0xe1, 0xbc],
+ [0xf3, 0x15, 0xbb, 0x5b, 0xb8, 0x35, 0xd8, 0x17],
+ [0xad, 0xcf, 0x6b, 0x07, 0x63, 0x61, 0x2e, 0x2f],
+ [0xa5, 0xc9, 0x1d, 0xa7, 0xac, 0xaa, 0x4d, 0xde],
+ [0x71, 0x65, 0x95, 0x87, 0x66, 0x50, 0xa2, 0xa6],
+ [0x28, 0xef, 0x49, 0x5c, 0x53, 0xa3, 0x87, 0xad],
+ [0x42, 0xc3, 0x41, 0xd8, 0xfa, 0x92, 0xd8, 0x32],
+ [0xce, 0x7c, 0xf2, 0x72, 0x2f, 0x51, 0x27, 0x71],
+ [0xe3, 0x78, 0x59, 0xf9, 0x46, 0x23, 0xf3, 0xa7],
+ [0x38, 0x12, 0x05, 0xbb, 0x1a, 0xb0, 0xe0, 0x12],
+ [0xae, 0x97, 0xa1, 0x0f, 0xd4, 0x34, 0xe0, 0x15],
+ [0xb4, 0xa3, 0x15, 0x08, 0xbe, 0xff, 0x4d, 0x31],
+ [0x81, 0x39, 0x62, 0x29, 0xf0, 0x90, 0x79, 0x02],
+ [0x4d, 0x0c, 0xf4, 0x9e, 0xe5, 0xd4, 0xdc, 0xca],
+ [0x5c, 0x73, 0x33, 0x6a, 0x76, 0xd8, 0xbf, 0x9a],
+ [0xd0, 0xa7, 0x04, 0x53, 0x6b, 0xa9, 0x3e, 0x0e],
+ [0x92, 0x59, 0x58, 0xfc, 0xd6, 0x42, 0x0c, 0xad],
+ [0xa9, 0x15, 0xc2, 0x9b, 0xc8, 0x06, 0x73, 0x18],
+ [0x95, 0x2b, 0x79, 0xf3, 0xbc, 0x0a, 0xa6, 0xd4],
+ [0xf2, 0x1d, 0xf2, 0xe4, 0x1d, 0x45, 0x35, 0xf9],
+ [0x87, 0x57, 0x75, 0x19, 0x04, 0x8f, 0x53, 0xa9],
+ [0x10, 0xa5, 0x6c, 0xf5, 0xdf, 0xcd, 0x9a, 0xdb],
+ [0xeb, 0x75, 0x09, 0x5c, 0xcd, 0x98, 0x6c, 0xd0],
+ [0x51, 0xa9, 0xcb, 0x9e, 0xcb, 0xa3, 0x12, 0xe6],
+ [0x96, 0xaf, 0xad, 0xfc, 0x2c, 0xe6, 0x66, 0xc7],
+ [0x72, 0xfe, 0x52, 0x97, 0x5a, 0x43, 0x64, 0xee],
+ [0x5a, 0x16, 0x45, 0xb2, 0x76, 0xd5, 0x92, 0xa1],
+ [0xb2, 0x74, 0xcb, 0x8e, 0xbf, 0x87, 0x87, 0x0a],
+ [0x6f, 0x9b, 0xb4, 0x20, 0x3d, 0xe7, 0xb3, 0x81],
+ [0xea, 0xec, 0xb2, 0xa3, 0x0b, 0x22, 0xa8, 0x7f],
+ [0x99, 0x24, 0xa4, 0x3c, 0xc1, 0x31, 0x57, 0x24],
+ [0xbd, 0x83, 0x8d, 0x3a, 0xaf, 0xbf, 0x8d, 0xb7],
+ [0x0b, 0x1a, 0x2a, 0x32, 0x65, 0xd5, 0x1a, 0xea],
+ [0x13, 0x50, 0x79, 0xa3, 0x23, 0x1c, 0xe6, 0x60],
+ [0x93, 0x2b, 0x28, 0x46, 0xe4, 0xd7, 0x06, 0x66],
+ [0xe1, 0x91, 0x5f, 0x5c, 0xb1, 0xec, 0xa4, 0x6c],
+ [0xf3, 0x25, 0x96, 0x5c, 0xa1, 0x6d, 0x62, 0x9f],
+ [0x57, 0x5f, 0xf2, 0x8e, 0x60, 0x38, 0x1b, 0xe5],
+ [0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95],
+];
diff --git a/compiler/rustc_middle/src/ptrauth/llvm_siphash/mod.rs b/compiler/rustc_middle/src/ptrauth/llvm_siphash/mod.rs
new file mode 100644
index 0000000000000..a835325e3c82c
--- /dev/null
+++ b/compiler/rustc_middle/src/ptrauth/llvm_siphash/mod.rs
@@ -0,0 +1,151 @@
+// LLVM SipHash-2-4 (64 bit version)
+pub fn llvm_pointer_auth_stable_siphash(data: &[u8]) -> u16 {
+ let raw = llvm_siphash_2_4_64(data);
+
+ ((raw % 0xFFFF) + 1) as u16
+}
+
+const SIPHASH_KEY: [u8; 16] = [
+ 0xb5, 0xd4, 0xc9, 0xeb, 0x79, 0x10, 0x4a, 0x79, 0x6f, 0xec, 0x8b, 0x1b, 0x42, 0x87, 0x81, 0xd4,
+];
+
+#[inline(always)]
+fn rotl(x: u64, b: u32) -> u64 {
+ (x << b) | (x >> (64 - b))
+}
+
+#[inline(always)]
+fn sipround(v0: &mut u64, v1: &mut u64, v2: &mut u64, v3: &mut u64) {
+ *v0 = v0.wrapping_add(*v1);
+ *v1 = rotl(*v1, 13);
+ *v1 ^= *v0;
+ *v0 = rotl(*v0, 32);
+
+ *v2 = v2.wrapping_add(*v3);
+ *v3 = rotl(*v3, 16);
+ *v3 ^= *v2;
+
+ *v0 = v0.wrapping_add(*v3);
+ *v3 = rotl(*v3, 21);
+ *v3 ^= *v0;
+
+ *v2 = v2.wrapping_add(*v1);
+ *v1 = rotl(*v1, 17);
+ *v1 ^= *v2;
+ *v2 = rotl(*v2, 32);
+}
+
+fn u64_from_le(bytes: &[u8]) -> u64 {
+ u64::from_le_bytes(bytes.try_into().unwrap())
+}
+
+fn load_u64_partial(bytes: &[u8]) -> u64 {
+ let mut b = 0u64;
+
+ match bytes.len() {
+ 7 => {
+ b |= (bytes[6] as u64) << 48;
+ b |= (bytes[5] as u64) << 40;
+ b |= (bytes[4] as u64) << 32;
+ b |= (bytes[3] as u64) << 24;
+ b |= (bytes[2] as u64) << 16;
+ b |= (bytes[1] as u64) << 8;
+ b |= bytes[0] as u64;
+ }
+ 6 => {
+ b |= (bytes[5] as u64) << 40;
+ b |= (bytes[4] as u64) << 32;
+ b |= (bytes[3] as u64) << 24;
+ b |= (bytes[2] as u64) << 16;
+ b |= (bytes[1] as u64) << 8;
+ b |= bytes[0] as u64;
+ }
+ 5 => {
+ b |= (bytes[4] as u64) << 32;
+ b |= (bytes[3] as u64) << 24;
+ b |= (bytes[2] as u64) << 16;
+ b |= (bytes[1] as u64) << 8;
+ b |= bytes[0] as u64;
+ }
+ 4 => {
+ b |= (bytes[3] as u64) << 24;
+ b |= (bytes[2] as u64) << 16;
+ b |= (bytes[1] as u64) << 8;
+ b |= bytes[0] as u64;
+ }
+ 3 => {
+ b |= (bytes[2] as u64) << 16;
+ b |= (bytes[1] as u64) << 8;
+ b |= bytes[0] as u64;
+ }
+ 2 => {
+ b |= (bytes[1] as u64) << 8;
+ b |= bytes[0] as u64;
+ }
+ 1 => {
+ b |= bytes[0] as u64;
+ }
+ _ => {}
+ }
+
+ b
+}
+
+fn siphash_2_4_64_with_key(data: &[u8], key: &[u8; 16]) -> u64 {
+ let k0 = u64_from_le(&key[0..8]);
+ let k1 = u64_from_le(&key[8..16]);
+
+ let mut v0: u64 = 0x736f6d6570736575 ^ k0;
+ let mut v1: u64 = 0x646f72616e646f6d ^ k1;
+ let mut v2: u64 = 0x6c7967656e657261 ^ k0;
+ let mut v3: u64 = 0x7465646279746573 ^ k1;
+
+ let mut b: u64 = (data.len() as u64) << 56;
+ let mut i = 0;
+
+ // compression
+ while i + 8 <= data.len() {
+ let m = u64_from_le(&data[i..i + 8]);
+ i += 8;
+
+ v3 ^= m;
+
+ for _ in 0..2 {
+ sipround(&mut v0, &mut v1, &mut v2, &mut v3);
+ }
+
+ v0 ^= m;
+ }
+
+ // tail
+ let tail = &data[i..];
+
+ b |= load_u64_partial(tail);
+
+ v3 ^= b;
+
+ for _ in 0..2 {
+ sipround(&mut v0, &mut v1, &mut v2, &mut v3);
+ }
+
+ v0 ^= b;
+
+ // finalization
+ v2 ^= 0xff;
+
+ for _ in 0..4 {
+ sipround(&mut v0, &mut v1, &mut v2, &mut v3);
+ }
+
+ v0 ^ v1 ^ v2 ^ v3
+}
+// LLVM siphash<2,4> 64-bit output
+fn llvm_siphash_2_4_64(data: &[u8]) -> u64 {
+ siphash_2_4_64_with_key(data, &SIPHASH_KEY)
+}
+
+#[cfg(test)]
+mod llvm_siphash_vectors;
+
+#[cfg(test)]
+mod tests;
diff --git a/compiler/rustc_middle/src/ptrauth/llvm_siphash/tests.rs b/compiler/rustc_middle/src/ptrauth/llvm_siphash/tests.rs
new file mode 100644
index 0000000000000..d26b0850798bb
--- /dev/null
+++ b/compiler/rustc_middle/src/ptrauth/llvm_siphash/tests.rs
@@ -0,0 +1,63 @@
+// Derived from code in LLVM, which is:
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Derived from:
+// * https://github.com/llvm/llvm-project/blob/f2453af624353273325fe888d794a925ea9fe852/llvm/unittests/Support/SipHashTest.cpp
+
+use llvm_siphash_vectors::{EXPECTED64, TEST_KEY};
+
+use super::*;
+
+// These tests mirror the SipHash tests from LLVM's Support/SipHashTest.cpp.
+// The implementation here is a faithful Rust translation of the LLVM 64-bit
+// SipHash-2-4 implementation used for pointer authentication discriminators.
+//
+// TEST_KEY and EXPECTED64 are copied from the upstream SipHash reference
+// vectors. Keeping these values identical ensures that the Rust implementation
+// produces the same SipHash output as LLVM.
+//
+// Run with:
+// x.py test compiler/rustc_middle --test-args siphash
+
+#[test]
+fn siphash24_reference_vectors_64() {
+ // Validate the SipHash-2-4 implementation against the upstream SipHash
+ // reference vectors.
+ //
+ // Each input is the byte sequence [0, 1, ..., len-1] and is hashed using
+ // the reference key TEST_KEY ([0, 1, ..., 15]). The expected values are
+ // compared byte-for-byte with the LLVM reference implementation output
+ // (EXPECTED64).
+ //
+ // This test verifies the correctness of the SipHash primitive itself,
+ // independently of the pointer authentication discriminator logic.
+ let mut input = [0u8; 64];
+
+ for len in 0..EXPECTED64.len() {
+ input[len] = len as u8;
+
+ let hash = siphash_2_4_64_with_key(&input[..len], &TEST_KEY);
+
+ assert_eq!(hash.to_le_bytes(), EXPECTED64[len]);
+ }
+}
+
+#[test]
+fn pointer_auth_stable_siphash() {
+ // Validate the rustc pointer-authentication SipHash wrapper against the
+ // values used by the LLVM implementation.
+ //
+ // The returned value is a 16-bit discriminator derived from the stable
+ // SipHash-2-4 output.
+ assert_eq!(llvm_pointer_auth_stable_siphash(b""), 0xE793);
+ assert_eq!(llvm_pointer_auth_stable_siphash(b"strlen"), 0xF468);
+ assert_eq!(llvm_pointer_auth_stable_siphash(b"_ZN1 ind; f"), 0x2D15);
+ assert_eq!(llvm_pointer_auth_stable_siphash(b"isa"), 0x6AE1);
+ assert_eq!(llvm_pointer_auth_stable_siphash(b"objc_class:superclass"), 0xB5AB,);
+ assert_eq!(llvm_pointer_auth_stable_siphash(b"block_descriptor"), 0xC0BB,);
+ assert_eq!(llvm_pointer_auth_stable_siphash(b"method_list_t"), 0xC310,);
+ assert_eq!(llvm_pointer_auth_stable_siphash(b"_Zptrkvttf"), 1);
+ assert_eq!(llvm_pointer_auth_stable_siphash(b"_Zaflhllod"), 0xFFFF);
+}
diff --git a/compiler/rustc_middle/src/ptrauth/mod.rs b/compiler/rustc_middle/src/ptrauth/mod.rs
new file mode 100644
index 0000000000000..0eeef5e07f61c
--- /dev/null
+++ b/compiler/rustc_middle/src/ptrauth/mod.rs
@@ -0,0 +1,7 @@
+pub mod discriminator;
+pub mod llvm_siphash;
+
+pub use discriminator::{
+ FnPtrDiscriminatorSource, FnPtrTypeDiscriminatorInput, ptrauth_clone_discriminated_schema_for,
+ ptrauth_compute_fn_ptr_type_discriminator_for,
+};
diff --git a/compiler/rustc_middle/src/query/on_disk_cache.rs b/compiler/rustc_middle/src/query/on_disk_cache.rs
index 1dd510da06886..4f89ce529a586 100644
--- a/compiler/rustc_middle/src/query/on_disk_cache.rs
+++ b/compiler/rustc_middle/src/query/on_disk_cache.rs
@@ -497,13 +497,13 @@ impl<'a, 'tcx> TyDecoder<'tcx> for CacheDecoder<'a, 'tcx> {
let cache_key = ty::CReaderCacheKey { cnum: None, pos: shorthand };
- if let Some(&ty) = tcx.ty_rcache.borrow().get(&cache_key) {
+ if let Some(&ty) = tcx.caches.ty_rcache.borrow().get(&cache_key) {
return ty;
}
let ty = or_insert_with(self);
// This may overwrite the entry, but it should overwrite with the same value.
- tcx.ty_rcache.borrow_mut().insert_same(cache_key, ty);
+ tcx.caches.ty_rcache.borrow_mut().insert_same(cache_key, ty);
ty
}
diff --git a/compiler/rustc_middle/src/query/plumbing.rs b/compiler/rustc_middle/src/query/plumbing.rs
index 2e121f0246b29..e72770ad1d217 100644
--- a/compiler/rustc_middle/src/query/plumbing.rs
+++ b/compiler/rustc_middle/src/query/plumbing.rs
@@ -2,15 +2,17 @@ use std::fmt;
use std::ops::Deref;
use rustc_data_structures::fingerprint::Fingerprint;
-use rustc_data_structures::fx::FxIndexMap;
+use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
use rustc_data_structures::hash_table::HashTable;
use rustc_data_structures::sharded::Sharded;
use rustc_data_structures::sync::{AtomicU64, Lock, WorkerLocal};
use rustc_errors::Diag;
use rustc_hir::def_id::LocalDefId;
-use rustc_span::Span;
+use rustc_span::{Span, Symbol};
-use crate::dep_graph::{DepKind, DepNodeIndex, QuerySideEffect, SerializedDepNodeIndex};
+use crate::dep_graph::{
+ DepKind, DepKindVTable, DepNodeIndex, QuerySideEffect, SerializedDepNodeIndex,
+};
use crate::ich::StableHashState;
use crate::queries::{ExternProviders, Providers, QueryArenas, QueryVTables, TaggedQueryKey};
use crate::query::on_disk_cache::OnDiskCache;
@@ -144,6 +146,7 @@ impl<'tcx, C: QueryCache> fmt::Debug for QueryVTable<'tcx, C> {
pub struct QuerySystem<'tcx> {
pub arenas: WorkerLocal>,
+ pub dep_kind_vtables: &'tcx [DepKindVTable<'tcx>],
pub query_vtables: QueryVTables<'tcx>,
/// Side-effect associated with each [`DepKind::SideEffect`] node in the
@@ -153,6 +156,11 @@ pub struct QuerySystem<'tcx> {
/// Always empty if incremental compilation is off.
pub side_effects: Lock>,
+ /// Enabled features that are used in the current compilation.
+ ///
+ /// The value is the `DepNodeIndex` of the node that encodes the used feature.
+ pub used_features: Lock>,
+
/// This provides access to the incremental compilation on-disk cache for query results.
/// Do not access this directly. It is only meant to be used by
/// `DepGraph::try_mark_green()` and the query infrastructure.
diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs
index b8cd0791a783e..47b248f26c300 100644
--- a/compiler/rustc_middle/src/traits/mod.rs
+++ b/compiler/rustc_middle/src/traits/mod.rs
@@ -105,7 +105,7 @@ impl<'tcx> ObligationCause<'tcx> {
pub fn derived_cause(
mut self,
- parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
+ parent_trait_pred: ty::PolyTraitClause<'tcx>,
variant: impl FnOnce(DerivedCause<'tcx>) -> ObligationCauseCode<'tcx>,
) -> ObligationCause<'tcx> {
/*!
@@ -491,7 +491,7 @@ impl<'tcx> ObligationCauseCode<'tcx> {
/// Returns the base obligation and the base trait predicate, if any, ignoring
/// derived obligations.
- pub fn peel_derives_with_predicate(&self) -> (&Self, Option>) {
+ pub fn peel_derives_with_predicate(&self) -> (&Self, Option>) {
let mut base_cause = self;
let mut base_trait_pred = None;
while let Some((parent_code, parent_pred)) = base_cause.parent_with_predicate() {
@@ -504,7 +504,7 @@ impl<'tcx> ObligationCauseCode<'tcx> {
(base_cause, base_trait_pred)
}
- pub fn parent_with_predicate(&self) -> Option<(&Self, Option>)> {
+ pub fn parent_with_predicate(&self) -> Option<(&Self, Option>)> {
match self {
ObligationCauseCode::FunctionArg { parent_code, .. } => Some((parent_code, None)),
ObligationCauseCode::BuiltinDerived(derived)
@@ -577,7 +577,7 @@ pub struct DerivedCause<'tcx> {
/// current obligation. Note that only trait obligations lead to
/// derived obligations, so we just store the trait predicate here
/// directly.
- pub parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
+ pub parent_trait_pred: ty::PolyTraitClause<'tcx>,
/// The parent trait had this cause.
pub parent_code: ObligationCauseCodeHandle<'tcx>,
diff --git a/compiler/rustc_middle/src/traits/select.rs b/compiler/rustc_middle/src/traits/select.rs
index a2eecebcc3501..e56dbb4ec3020 100644
--- a/compiler/rustc_middle/src/traits/select.rs
+++ b/compiler/rustc_middle/src/traits/select.rs
@@ -12,13 +12,11 @@ use super::{SelectionError, SelectionResult};
use crate::traits::cache::WithDepNodeCache;
use crate::ty;
-pub type SelectionCache<'tcx, ENV> = WithDepNodeCache<
- (ENV, ty::TraitPredicate<'tcx>),
- SelectionResult<'tcx, SelectionCandidate<'tcx>>,
->;
+pub type SelectionCache<'tcx, ENV> =
+ WithDepNodeCache<(ENV, ty::TraitClause<'tcx>), SelectionResult<'tcx, SelectionCandidate<'tcx>>>;
pub type EvaluationCache<'tcx, ENV> =
- WithDepNodeCache<(ENV, ty::PolyTraitPredicate<'tcx>), EvaluationResult>;
+ WithDepNodeCache<(ENV, ty::PolyTraitClause<'tcx>), EvaluationResult>;
/// The selection process begins by considering all impls, where
/// clauses, and so forth that might resolve an obligation. Sometimes
@@ -114,7 +112,7 @@ pub enum SelectionCandidate<'tcx> {
/// Implementation of transmutability trait.
TransmutabilityCandidate,
- ParamCandidate(ty::PolyTraitPredicate<'tcx>),
+ ParamCandidate(ty::PolyTraitClause<'tcx>),
ImplCandidate(DefId),
AutoImplCandidate,
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index 75aa5aaaa4352..2c1d6cc1ff4dc 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -49,7 +49,7 @@ use tracing::{debug, instrument};
use crate::arena::Arena;
use crate::dep_graph::dep_node::make_metadata;
-use crate::dep_graph::{DepGraph, DepKindVTable, DepNodeIndex};
+use crate::dep_graph::{DepGraph, DepNodeIndex};
use crate::hir::{ProjectedMaybeOwner, ProjectedOwnerInfo};
use crate::ich::StableHashState;
use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarKind};
@@ -66,11 +66,11 @@ use crate::traits::solve::{ExternalConstraints, ExternalConstraintsData, Predefi
use crate::ty::predicate::ExistentialPredicateStableCmpExt as _;
use crate::ty::region::RegionExt;
use crate::ty::{
- self, AdtDef, AdtDefData, AdtKind, Binder, Clause, Clauses, Const, FnSigKind, GenericArg,
- GenericArgs, GenericArgsRef, GenericParamDefKind, List, ListWithCachedTypeInfo, ParamConst,
- Pattern, PatternKind, PolyExistentialPredicate, PolyFnSig, Predicate, PredicateKind,
- PredicatePolarity, Region, RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind, TyVid,
- ValTree, ValTreeKind, Visibility,
+ self, AdtDef, AdtDefData, AdtKind, Binder, Clause, ClausePolarity, Clauses, Const, FnSigKind,
+ GenericArg, GenericArgs, GenericArgsRef, GenericParamDefKind, List, ListWithCachedTypeInfo,
+ ParamConst, Pattern, PatternKind, PolyExistentialPredicate, PolyFnSig, Predicate,
+ PredicateKind, Region, RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind, TyVid, ValTree,
+ ValTreeKind, Visibility,
};
impl<'tcx> rustc_type_ir::inherent::DefId> for DefId {
@@ -654,6 +654,38 @@ impl<'tcx> TyCtxtFeed<'tcx, LocalDefId> {
}
}
+/// An assortment of global caches used by various parts of the compiler.
+///
+/// The individual fields are mostly unrelated to each other, but have been grouped together to
+/// reduce the number of top-level fields in [`GlobalCtxt`].
+#[derive(Default)]
+pub struct GlobalCaches<'tcx> {
+ // Internal caches for metadata decoding. No need to track deps on this.
+ pub ty_rcache: Lock>>,
+
+ /// Caches the results of trait selection. This cache is used
+ /// for things that do not have to do with the parameters in scope.
+ pub selection_cache: traits::SelectionCache<'tcx, ty::TypingEnv<'tcx>>,
+
+ /// Caches the results of trait evaluation. This cache is used
+ /// for things that do not have to do with the parameters in scope.
+ /// Merge this with `selection_cache`?
+ pub evaluation_cache: traits::EvaluationCache<'tcx, ty::TypingEnv<'tcx>>,
+
+ /// Caches the results of goal evaluation in the new solver.
+ new_solver_evaluation_cache: Lock>>,
+ new_solver_canonical_param_env_cache: Lock>>,
+
+ pub canonical_param_env_cache: CanonicalParamEnvCache<'tcx>,
+
+ /// Caches the index of the highest bound var in clauses in a canonical binder.
+ pub highest_var_in_clauses_cache: Lock, usize>>,
+
+ /// Caches the instantiation of a canonical binder given a set of args.
+ pub clauses_cache:
+ Lock, &'tcx [ty::GenericArg<'tcx>]), ty::Clauses<'tcx>>>,
+}
+
/// The central data structure of the compiler. It stores references
/// to the various **arenas** and also houses the results of the
/// various **compiler queries** that have been performed. See the
@@ -715,6 +747,8 @@ pub struct GlobalCtxt<'tcx> {
pub incr_comp_session: Option<&'tcx IncrCompSession>,
pub dep_graph: DepGraph,
+ /// This duplicates `Session::prof` because this field is hot enough that accessing it via
+ /// `self.sess.prof` is a measurable slowdown (see #161332).
pub prof: SelfProfilerRef,
/// Common types, pre-interned for your convenience.
@@ -733,31 +767,8 @@ pub struct GlobalCtxt<'tcx> {
untracked: Untracked,
pub query_system: QuerySystem<'tcx>,
- pub(crate) dep_kind_vtables: &'tcx [DepKindVTable<'tcx>],
-
- // Internal caches for metadata decoding. No need to track deps on this.
- pub ty_rcache: Lock>>,
-
- /// Caches the results of trait selection. This cache is used
- /// for things that do not have to do with the parameters in scope.
- pub selection_cache: traits::SelectionCache<'tcx, ty::TypingEnv<'tcx>>,
- /// Caches the results of trait evaluation. This cache is used
- /// for things that do not have to do with the parameters in scope.
- /// Merge this with `selection_cache`?
- pub evaluation_cache: traits::EvaluationCache<'tcx, ty::TypingEnv<'tcx>>,
-
- /// Caches the results of goal evaluation in the new solver.
- pub new_solver_evaluation_cache: Lock>>,
- pub new_solver_canonical_param_env_cache: Lock>>,
-
- pub canonical_param_env_cache: CanonicalParamEnvCache<'tcx>,
-
- /// Caches the index of the highest bound var in clauses in a canonical binder.
- pub highest_var_in_clauses_cache: Lock, usize>>,
- /// Caches the instantiation of a canonical binder given a set of args.
- pub clauses_cache:
- Lock, &'tcx [ty::GenericArg<'tcx>]), ty::Clauses<'tcx>>>,
+ pub caches: GlobalCaches<'tcx>,
/// Data layout specification for the current target.
pub data_layout: TargetDataLayout,
@@ -937,7 +948,6 @@ impl<'tcx> TyCtxt<'tcx> {
untracked: Untracked,
incr_comp_session: Option<&'tcx IncrCompSession>,
dep_graph: DepGraph,
- dep_kind_vtables: &'tcx [DepKindVTable<'tcx>],
query_system: QuerySystem<'tcx>,
hooks: crate::hooks::Providers,
current_gcx: CurrentGcx,
@@ -967,15 +977,7 @@ impl<'tcx> TyCtxt<'tcx> {
consts: common_consts,
untracked,
query_system,
- dep_kind_vtables,
- ty_rcache: Default::default(),
- selection_cache: Default::default(),
- evaluation_cache: Default::default(),
- new_solver_evaluation_cache: Default::default(),
- new_solver_canonical_param_env_cache: Default::default(),
- canonical_param_env_cache: Default::default(),
- highest_var_in_clauses_cache: Default::default(),
- clauses_cache: Default::default(),
+ caches: Default::default(),
data_layout,
alloc_map: interpret::AllocMap::new(),
current_gcx,
@@ -1612,7 +1614,7 @@ impl<'tcx> TyCtxt<'tcx> {
}
// Collect first to avoid holding the lock while linting.
- let used_features = self.sess.used_features.lock();
+ let used_features = self.query_system.used_features.lock();
let unused_features = self
.features()
.enabled_features_iter_stable_order()
@@ -2073,7 +2075,7 @@ impl<'tcx> TyCtxt<'tcx> {
return false;
};
trait_predicate.trait_ref.def_id == future_trait
- && trait_predicate.polarity == PredicatePolarity::Positive
+ && trait_predicate.polarity == ClausePolarity::Positive
})
}
diff --git a/compiler/rustc_middle/src/ty/context/impl_interner.rs b/compiler/rustc_middle/src/ty/context/impl_interner.rs
index a47d39dba5531..c32aee98e7169 100644
--- a/compiler/rustc_middle/src/ty/context/impl_interner.rs
+++ b/compiler/rustc_middle/src/ty/context/impl_interner.rs
@@ -144,14 +144,14 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
}
fn with_global_cache(self, f: impl FnOnce(&mut search_graph::GlobalCache) -> R) -> R {
- f(&mut *self.new_solver_evaluation_cache.lock())
+ f(&mut *self.caches.new_solver_evaluation_cache.lock())
}
fn with_canonical_param_env_cache(
self,
f: impl FnOnce(&mut ty::CanonicalParamEnvCache) -> R,
) -> R {
- f(&mut *self.new_solver_canonical_param_env_cache.lock())
+ f(&mut *self.caches.new_solver_canonical_param_env_cache.lock())
}
fn assert_evaluation_is_concurrent(&self) {
diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs
index 94a6ae918a703..1f2a9aca60142 100644
--- a/compiler/rustc_middle/src/ty/diagnostics.rs
+++ b/compiler/rustc_middle/src/ty/diagnostics.rs
@@ -14,8 +14,8 @@ use rustc_type_ir::TyKind::*;
use crate::ty::{
self, AliasTy, Const, ConstKind, FallibleTypeFolder, InferConst, InferTy, Instance, Opaque,
- PolyTraitPredicate, Projection, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable,
- TypeSuperVisitable, TypeVisitable, TypeVisitor,
+ PolyTraitClause, Projection, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, TypeSuperVisitable,
+ TypeVisitable, TypeVisitor,
};
impl IntoDiagArg for Ty<'_> {
@@ -133,7 +133,7 @@ pub fn suggest_arbitrary_trait_bound<'tcx>(
tcx: TyCtxt<'tcx>,
generics: &hir::Generics<'_>,
err: &mut Diag<'_>,
- trait_pred: PolyTraitPredicate<'tcx>,
+ trait_pred: PolyTraitClause<'tcx>,
associated_ty: Option<(&'static str, Ty<'tcx>)>,
) -> bool {
if !trait_pred.is_suggestable(tcx, false) {
diff --git a/compiler/rustc_middle/src/ty/elaborate_impl.rs b/compiler/rustc_middle/src/ty/elaborate_impl.rs
index 8c89a2d884b30..cd76d49cefecb 100644
--- a/compiler/rustc_middle/src/ty/elaborate_impl.rs
+++ b/compiler/rustc_middle/src/ty/elaborate_impl.rs
@@ -16,7 +16,7 @@ impl<'tcx> Elaboratable> for ty::Clause<'tcx> {
&self,
clause: ty::Clause<'tcx>,
_span: Span,
- _parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
+ _parent_trait_pred: ty::PolyTraitClause<'tcx>,
_index: usize,
) -> Self {
clause
@@ -36,7 +36,7 @@ impl<'tcx> Elaboratable> for ty::Predicate<'tcx> {
&self,
clause: ty::Clause<'tcx>,
_span: Span,
- _parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
+ _parent_trait_pred: ty::PolyTraitClause<'tcx>,
_index: usize,
) -> Self {
clause.as_predicate()
@@ -56,7 +56,7 @@ impl<'tcx> Elaboratable> for (ty::Predicate<'tcx>, Span) {
&self,
clause: ty::Clause<'tcx>,
_span: Span,
- _parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
+ _parent_trait_pred: ty::PolyTraitClause<'tcx>,
_index: usize,
) -> Self {
(clause.as_predicate(), self.1)
@@ -76,7 +76,7 @@ impl<'tcx> Elaboratable> for (ty::Clause<'tcx>, Span) {
&self,
clause: ty::Clause<'tcx>,
_span: Span,
- _parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
+ _parent_trait_pred: ty::PolyTraitClause<'tcx>,
_index: usize,
) -> Self {
(clause, self.1)
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs
index cd9e5f6903478..36631861e8108 100644
--- a/compiler/rustc_middle/src/ty/mod.rs
+++ b/compiler/rustc_middle/src/ty/mod.rs
@@ -89,9 +89,9 @@ pub use self::predicate::{
ExistentialPredicate, ExistentialPredicateStableCmpExt, ExistentialProjection,
ExistentialTraitRef, HostEffectClause, NormalizesTo, OutlivesClause, PolyCoercePredicate,
PolyExistentialPredicate, PolyExistentialProjection, PolyExistentialTraitRef,
- PolyProjectionPredicate, PolyRegionOutlivesClause, PolySubtypePredicate, PolyTraitPredicate,
- PolyTraitRef, PolyTypeOutlivesClause, Predicate, PredicateKind, ProjectionPredicate,
- RegionConstraint, RegionEqPredicate, RegionOutlivesClause, SubtypePredicate, TraitPredicate,
+ PolyProjectionClause, PolyRegionOutlivesClause, PolySubtypePredicate, PolyTraitClause,
+ PolyTraitRef, PolyTypeOutlivesClause, Predicate, PredicateKind, ProjectionClause,
+ RegionConstraint, RegionEqPredicate, RegionOutlivesClause, SubtypePredicate, TraitClause,
TraitRef, TypeOutlivesClause,
};
pub use self::region::{
diff --git a/compiler/rustc_middle/src/ty/predicate.rs b/compiler/rustc_middle/src/ty/predicate.rs
index 990a424289e9b..3ccf185405209 100644
--- a/compiler/rustc_middle/src/ty/predicate.rs
+++ b/compiler/rustc_middle/src/ty/predicate.rs
@@ -10,11 +10,11 @@ use crate::ty::{self, EarlyBinder, Ty, TyCtxt, TypeFlags, Upcast, UpcastFrom, Wi
pub type TraitRef<'tcx> = ir::TraitRef>;
pub type AliasTerm<'tcx> = ir::AliasTerm>;
pub type AliasTermKind<'tcx> = ir::AliasTermKind>;
-pub type ProjectionPredicate<'tcx> = ir::ProjectionPredicate>;
+pub type ProjectionClause<'tcx> = ir::ProjectionClause>;
pub type ExistentialPredicate<'tcx> = ir::ExistentialPredicate>;
pub type ExistentialTraitRef<'tcx> = ir::ExistentialTraitRef>;
pub type ExistentialProjection<'tcx> = ir::ExistentialProjection>;
-pub type TraitPredicate<'tcx> = ir::TraitPredicate>;
+pub type TraitClause<'tcx> = ir::TraitClause>;
pub type HostEffectClause<'tcx> = ir::HostEffectClause>;
pub type ClauseKind<'tcx> = ir::ClauseKind>;
pub type PredicateKind<'tcx> = ir::PredicateKind>;
@@ -27,12 +27,12 @@ pub type TypeOutlivesClause<'tcx> = OutlivesClause<'tcx, Ty<'tcx>>;
pub type ArgOutlivesClause<'tcx> = OutlivesClause<'tcx, ty::GenericArg<'tcx>>;
pub type RegionEqPredicate<'tcx> = ir::RegionEqPredicate>;
pub type RegionConstraint<'tcx> = ir::RegionConstraint>;
-pub type PolyTraitPredicate<'tcx> = ty::Binder<'tcx, TraitPredicate<'tcx>>;
+pub type PolyTraitClause<'tcx> = ty::Binder<'tcx, TraitClause<'tcx>>;
pub type PolyRegionOutlivesClause<'tcx> = ty::Binder<'tcx, RegionOutlivesClause<'tcx>>;
pub type PolyTypeOutlivesClause<'tcx> = ty::Binder<'tcx, TypeOutlivesClause<'tcx>>;
pub type PolySubtypePredicate<'tcx> = ty::Binder<'tcx, SubtypePredicate<'tcx>>;
pub type PolyCoercePredicate<'tcx> = ty::Binder<'tcx, CoercePredicate<'tcx>>;
-pub type PolyProjectionPredicate<'tcx> = ty::Binder<'tcx, ProjectionPredicate<'tcx>>;
+pub type PolyProjectionClause<'tcx> = ty::Binder<'tcx, ProjectionClause<'tcx>>;
/// A statement that can be proven by a trait solver. This includes things that may
/// show up in where clauses, such as trait predicates and projection predicates,
@@ -84,13 +84,12 @@ impl<'tcx> Predicate<'tcx> {
let kind = self
.kind()
.map_bound(|kind| match kind {
- PredicateKind::Clause(ClauseKind::Trait(TraitPredicate {
- trait_ref,
- polarity,
- })) => Some(PredicateKind::Clause(ClauseKind::Trait(TraitPredicate {
- trait_ref,
- polarity: polarity.flip(),
- }))),
+ PredicateKind::Clause(ClauseKind::Trait(TraitClause { trait_ref, polarity })) => {
+ Some(PredicateKind::Clause(ClauseKind::Trait(TraitClause {
+ trait_ref,
+ polarity: polarity.flip(),
+ })))
+ }
_ => None,
})
@@ -177,7 +176,7 @@ impl<'tcx> Clause<'tcx> {
})
}
- pub fn as_trait_clause(self) -> Option>> {
+ pub fn as_trait_clause(self) -> Option>> {
let clause = self.kind();
if let ty::ClauseKind::Trait(trait_clause) = clause.skip_binder() {
Some(clause.rebind(trait_clause))
@@ -186,7 +185,7 @@ impl<'tcx> Clause<'tcx> {
}
}
- pub fn as_projection_clause(self) -> Option>> {
+ pub fn as_projection_clause(self) -> Option>> {
let clause = self.kind();
if let ty::ClauseKind::Projection(projection_clause) = clause.skip_binder() {
Some(clause.rebind(projection_clause))
@@ -500,39 +499,39 @@ impl<'tcx> UpcastFrom, TraitRef<'tcx>> for Clause<'tcx> {
impl<'tcx> UpcastFrom, ty::Binder<'tcx, TraitRef<'tcx>>> for Predicate<'tcx> {
fn upcast_from(from: ty::Binder<'tcx, TraitRef<'tcx>>, tcx: TyCtxt<'tcx>) -> Self {
- let pred: PolyTraitPredicate<'tcx> = from.upcast(tcx);
+ let pred: PolyTraitClause<'tcx> = from.upcast(tcx);
pred.upcast(tcx)
}
}
impl<'tcx> UpcastFrom, ty::Binder<'tcx, TraitRef<'tcx>>> for Clause<'tcx> {
fn upcast_from(from: ty::Binder<'tcx, TraitRef<'tcx>>, tcx: TyCtxt<'tcx>) -> Self {
- let pred: PolyTraitPredicate<'tcx> = from.upcast(tcx);
+ let pred: PolyTraitClause<'tcx> = from.upcast(tcx);
pred.upcast(tcx)
}
}
-impl<'tcx> UpcastFrom, TraitPredicate<'tcx>> for Predicate<'tcx> {
- fn upcast_from(from: TraitPredicate<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
+impl<'tcx> UpcastFrom, TraitClause<'tcx>> for Predicate<'tcx> {
+ fn upcast_from(from: TraitClause<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
PredicateKind::Clause(ClauseKind::Trait(from)).upcast(tcx)
}
}
-impl<'tcx> UpcastFrom, PolyTraitPredicate<'tcx>> for Predicate<'tcx> {
- fn upcast_from(from: PolyTraitPredicate<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
+impl<'tcx> UpcastFrom, PolyTraitClause<'tcx>> for Predicate<'tcx> {
+ fn upcast_from(from: PolyTraitClause<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
from.map_bound(|p| PredicateKind::Clause(ClauseKind::Trait(p))).upcast(tcx)
}
}
-impl<'tcx> UpcastFrom, TraitPredicate<'tcx>> for Clause<'tcx> {
- fn upcast_from(from: TraitPredicate<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
+impl<'tcx> UpcastFrom, TraitClause<'tcx>> for Clause<'tcx> {
+ fn upcast_from(from: TraitClause<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
let p: Predicate<'tcx> = from.upcast(tcx);
p.expect_clause()
}
}
-impl<'tcx> UpcastFrom, PolyTraitPredicate<'tcx>> for Clause<'tcx> {
- fn upcast_from(from: PolyTraitPredicate<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
+impl<'tcx> UpcastFrom, PolyTraitClause<'tcx>> for Clause<'tcx> {
+ fn upcast_from(from: PolyTraitClause<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
let p: Predicate<'tcx> = from.upcast(tcx);
p.expect_clause()
}
@@ -556,27 +555,27 @@ impl<'tcx> UpcastFrom, TypeOutlivesClause<'tcx>> for Predicate<'tcx
}
}
-impl<'tcx> UpcastFrom, ProjectionPredicate<'tcx>> for Predicate<'tcx> {
- fn upcast_from(from: ProjectionPredicate<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
+impl<'tcx> UpcastFrom, ProjectionClause<'tcx>> for Predicate<'tcx> {
+ fn upcast_from(from: ProjectionClause<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
ty::Binder::dummy(PredicateKind::Clause(ClauseKind::Projection(from))).upcast(tcx)
}
}
-impl<'tcx> UpcastFrom, PolyProjectionPredicate<'tcx>> for Predicate<'tcx> {
- fn upcast_from(from: PolyProjectionPredicate<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
+impl<'tcx> UpcastFrom, PolyProjectionClause<'tcx>> for Predicate<'tcx> {
+ fn upcast_from(from: PolyProjectionClause<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
from.map_bound(|p| PredicateKind::Clause(ClauseKind::Projection(p))).upcast(tcx)
}
}
-impl<'tcx> UpcastFrom, ProjectionPredicate<'tcx>> for Clause<'tcx> {
- fn upcast_from(from: ProjectionPredicate<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
+impl<'tcx> UpcastFrom, ProjectionClause<'tcx>> for Clause<'tcx> {
+ fn upcast_from(from: ProjectionClause<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
let p: Predicate<'tcx> = from.upcast(tcx);
p.expect_clause()
}
}
-impl<'tcx> UpcastFrom, PolyProjectionPredicate<'tcx>> for Clause<'tcx> {
- fn upcast_from(from: PolyProjectionPredicate<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
+impl<'tcx> UpcastFrom, PolyProjectionClause<'tcx>> for Clause<'tcx> {
+ fn upcast_from(from: PolyProjectionClause<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
let p: Predicate<'tcx> = from.upcast(tcx);
p.expect_clause()
}
@@ -603,7 +602,7 @@ impl<'tcx> UpcastFrom, NormalizesTo<'tcx>> for Predicate<'tcx> {
}
impl<'tcx> Predicate<'tcx> {
- pub fn as_trait_clause(self) -> Option> {
+ pub fn as_trait_clause(self) -> Option> {
let predicate = self.kind();
match predicate.skip_binder() {
PredicateKind::Clause(ClauseKind::Trait(t)) => Some(predicate.rebind(t)),
@@ -611,7 +610,7 @@ impl<'tcx> Predicate<'tcx> {
}
}
- pub fn as_projection_clause(self) -> Option> {
+ pub fn as_projection_clause(self) -> Option> {
let predicate = self.kind();
match predicate.skip_binder() {
PredicateKind::Clause(ClauseKind::Projection(t)) => Some(predicate.rebind(t)),
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs
index 4ab474fd89fe6..84437a237c28a 100644
--- a/compiler/rustc_middle/src/ty/print/pretty.rs
+++ b/compiler/rustc_middle/src/ty/print/pretty.rs
@@ -26,7 +26,7 @@ use crate::mir::interpret::{AllocRange, GlobalAlloc, Pointer, Provenance, Scalar
use crate::query::{IntoQueryKey, Providers};
use crate::ty::region::RegionExt;
use crate::ty::{
- ConstInt, Expr, GenericArgKind, ParamConst, ScalarInt, Term, TermKind, TraitPredicate,
+ ConstInt, Expr, GenericArgKind, ParamConst, ScalarInt, Term, TermKind, TraitClause,
TypeFoldable, TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
};
@@ -1060,11 +1060,11 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
// `MetaSized`, and skip sizedness bounds to be added at the end.
match tcx.as_lang_item(pred.def_id()) {
Some(LangItem::Sized) => match pred.polarity {
- ty::PredicatePolarity::Positive => {
+ ty::ClausePolarity::Positive => {
has_sized_bound = true;
continue;
}
- ty::PredicatePolarity::Negative => has_negative_sized_bound = true,
+ ty::ClausePolarity::Negative => has_negative_sized_bound = true,
},
Some(LangItem::MetaSized) => {
has_meta_sized_bound = true;
@@ -1085,9 +1085,9 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
}
ty::ClauseKind::Projection(pred) => {
let proj = bound_predicate.rebind(pred);
- let trait_ref = proj.map_bound(|proj| TraitPredicate {
+ let trait_ref = proj.map_bound(|proj| TraitClause {
trait_ref: proj.projection_term.trait_ref(tcx),
- polarity: ty::PredicatePolarity::Positive,
+ polarity: ty::ClausePolarity::Positive,
});
self.insert_trait_and_projection(
@@ -1151,8 +1151,8 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
} else {
// Otherwise, render this like a regular trait.
traits.insert(
- bound_args_and_self_ty.map_bound(|(args, self_ty)| ty::TraitPredicate {
- polarity: ty::PredicatePolarity::Positive,
+ bound_args_and_self_ty.map_bound(|(args, self_ty)| ty::TraitClause {
+ polarity: ty::ClausePolarity::Positive,
trait_ref: ty::TraitRef::new(
tcx,
trait_def_id,
@@ -1169,7 +1169,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
write!(self, "{}", if first { "" } else { " + " })?;
self.wrap_binder(&trait_pred, WrapBinderMode::ForAll, |trait_pred, p| {
- if trait_pred.polarity == ty::PredicatePolarity::Negative {
+ if trait_pred.polarity == ty::ClausePolarity::Negative {
write!(p, "!")?;
}
trait_pred.trait_ref.print_only_trait_name().print(p)?;
@@ -1257,10 +1257,10 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
/// traits map or fn_traits map, depending on if the trait is in the Fn* family of traits.
fn insert_trait_and_projection(
&mut self,
- trait_pred: ty::PolyTraitPredicate<'tcx>,
+ trait_pred: ty::PolyTraitClause<'tcx>,
proj_ty: Option<(DefId, ty::Binder<'tcx, Term<'tcx>>)>,
traits: &mut FxIndexMap<
- ty::PolyTraitPredicate<'tcx>,
+ ty::PolyTraitClause<'tcx>,
FxIndexMap>>,
>,
fn_traits: &mut FxIndexMap<
@@ -1279,7 +1279,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
None
};
- if trait_pred.polarity() == ty::PredicatePolarity::Positive
+ if trait_pred.polarity() == ty::ClausePolarity::Positive
&& let Some((kind, is_async)) = fn_trait_and_async
&& let ty::Tuple(types) = *trait_pred.skip_binder().trait_ref.args.type_at(1).kind()
{
@@ -3076,46 +3076,46 @@ impl<'tcx> ty::Binder<'tcx, ty::TraitRef<'tcx>> {
}
#[derive(Copy, Clone, TypeFoldable, TypeVisitable, Lift, Hash)]
-pub struct TraitPredPrintModifiersAndPath<'tcx>(ty::TraitPredicate<'tcx>);
+pub struct TraitClausePrintModifiersAndPath<'tcx>(ty::TraitClause<'tcx>);
-impl<'tcx> fmt::Debug for TraitPredPrintModifiersAndPath<'tcx> {
+impl<'tcx> fmt::Debug for TraitClausePrintModifiersAndPath<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(self, f)
}
}
-#[extension(pub trait PrintTraitPredicateExt<'tcx>)]
-impl<'tcx> ty::TraitPredicate<'tcx> {
- fn print_modifiers_and_trait_path(self) -> TraitPredPrintModifiersAndPath<'tcx> {
- TraitPredPrintModifiersAndPath(self)
+#[extension(pub trait PrintTraitClauseExt<'tcx>)]
+impl<'tcx> ty::TraitClause<'tcx> {
+ fn print_modifiers_and_trait_path(self) -> TraitClausePrintModifiersAndPath<'tcx> {
+ TraitClausePrintModifiersAndPath(self)
}
}
#[derive(Copy, Clone, TypeFoldable, TypeVisitable, Lift, Hash)]
-pub struct TraitPredPrintWithBoundConstness<'tcx>(
- ty::TraitPredicate<'tcx>,
+pub struct TraitClausePrintWithBoundConstness<'tcx>(
+ ty::TraitClause<'tcx>,
Option,
);
-impl<'tcx> fmt::Debug for TraitPredPrintWithBoundConstness<'tcx> {
+impl<'tcx> fmt::Debug for TraitClausePrintWithBoundConstness<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(self, f)
}
}
-#[extension(pub trait PrintPolyTraitPredicateExt<'tcx>)]
-impl<'tcx> ty::PolyTraitPredicate<'tcx> {
+#[extension(pub trait PrintPolyTraitClauseExt<'tcx>)]
+impl<'tcx> ty::PolyTraitClause<'tcx> {
fn print_modifiers_and_trait_path(
self,
- ) -> ty::Binder<'tcx, TraitPredPrintModifiersAndPath<'tcx>> {
- self.map_bound(TraitPredPrintModifiersAndPath)
+ ) -> ty::Binder<'tcx, TraitClausePrintModifiersAndPath<'tcx>> {
+ self.map_bound(TraitClausePrintModifiersAndPath)
}
fn print_with_bound_constness(
self,
constness: Option,
- ) -> ty::Binder<'tcx, TraitPredPrintWithBoundConstness<'tcx>> {
- self.map_bound(|trait_pred| TraitPredPrintWithBoundConstness(trait_pred, constness))
+ ) -> ty::Binder<'tcx, TraitClausePrintWithBoundConstness<'tcx>> {
+ self.map_bound(|trait_pred| TraitClausePrintWithBoundConstness(trait_pred, constness))
}
}
@@ -3214,10 +3214,10 @@ define_print! {
}
}
- ty::TraitPredicate<'tcx> {
+ ty::TraitClause<'tcx> {
self.trait_ref.self_ty().print(p)?;
write!(p, ": ")?;
- if let ty::PredicatePolarity::Negative = self.polarity {
+ if let ty::ClausePolarity::Negative = self.polarity {
write!(p, "!")?;
}
self.trait_ref.print_trait_sugared().print(p)?;
@@ -3314,7 +3314,7 @@ define_print! {
self.term.print(p)?;
}
- ty::ProjectionPredicate<'tcx> {
+ ty::ProjectionClause<'tcx> {
self.projection_term.print(p)?;
write!(p, " == ")?;
p.reset_type_limit();
@@ -3389,20 +3389,20 @@ define_print_and_forward_display! {
p.print_def_path(self.0.def_id, &[])?;
}
- TraitPredPrintModifiersAndPath<'tcx> {
- if let ty::PredicatePolarity::Negative = self.0.polarity {
+ TraitClausePrintModifiersAndPath<'tcx> {
+ if let ty::ClausePolarity::Negative = self.0.polarity {
write!(p, "!")?;
}
self.0.trait_ref.print_trait_sugared().print(p)?;
}
- TraitPredPrintWithBoundConstness<'tcx> {
+ TraitClausePrintWithBoundConstness<'tcx> {
self.0.trait_ref.self_ty().print(p)?;
write!(p, ": ")?;
if let Some(constness) = self.1 {
p.pretty_print_bound_constness(constness)?;
}
- if let ty::PredicatePolarity::Negative = self.0.polarity {
+ if let ty::ClausePolarity::Negative = self.0.polarity {
write!(p, "!")?;
}
self.0.trait_ref.print_trait_sugared().print(p)?;
diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs
index 7dc717649dc1c..d40c5dfab7c14 100644
--- a/compiler/rustc_middle/src/ty/structural_impls.rs
+++ b/compiler/rustc_middle/src/ty/structural_impls.rs
@@ -186,7 +186,7 @@ TrivialLiftImpls! {
rustc_middle::mir::ConstValue,
rustc_span::Symbol,
rustc_type_ir::BoundConstness,
- rustc_type_ir::PredicatePolarity,
+ rustc_type_ir::ClausePolarity,
// tidy-alphabetical-end
}
diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs
index adf153b68dae6..2e31e666f8f48 100644
--- a/compiler/rustc_middle/src/ty/util.rs
+++ b/compiler/rustc_middle/src/ty/util.rs
@@ -1040,7 +1040,7 @@ impl<'tcx> TypeFolder> for OpaqueTypeExpander<'tcx> {
&& let ty::ClauseKind::Projection(projection_pred) = clause
{
p.kind()
- .rebind(ty::ProjectionPredicate {
+ .rebind(ty::ProjectionClause {
projection_term: projection_pred.projection_term.fold_with(self),
// Don't fold the term on the RHS of the projection predicate.
// This is because for default trait methods with RPITITs, we
diff --git a/compiler/rustc_mir_transform/src/coroutine/drop.rs b/compiler/rustc_mir_transform/src/coroutine/drop.rs
index 41b973476af94..6b26a1f242cf0 100644
--- a/compiler/rustc_mir_transform/src/coroutine/drop.rs
+++ b/compiler/rustc_mir_transform/src/coroutine/drop.rs
@@ -27,6 +27,23 @@ impl<'tcx> MutVisitor<'tcx> for FixReturnPendingVisitor<'tcx> {
&& let AggregateKind::Adt(_, _, ref mut args, _, _) = **kind
{
*args = self.tcx.mk_args(&[self.tcx.types.unit.into()]);
+ } else if let Rvalue::Use(Operand::Constant(constant), _) = rvalue {
+ if let Some(async_gen_pending_def_id) = self.tcx.lang_items().async_gen_pending()
+ && let Const::Unevaluated(unevaluated, _) = constant.const_
+ && unevaluated.def == async_gen_pending_def_id
+ {
+ let poll_def_id = self.tcx.lang_items().poll().unwrap();
+ *rvalue = Rvalue::Aggregate(
+ Box::new(AggregateKind::Adt(
+ poll_def_id,
+ VariantIdx::from_u32(1),
+ self.tcx.mk_args(&[self.tcx.types.unit.into()]),
+ None,
+ None,
+ )),
+ IndexVec::new(),
+ );
+ }
}
}
}
diff --git a/compiler/rustc_mir_transform/src/impossible_clauses.rs b/compiler/rustc_mir_transform/src/impossible_clauses.rs
index 39f864d8a8219..bb6644716bf05 100644
--- a/compiler/rustc_mir_transform/src/impossible_clauses.rs
+++ b/compiler/rustc_mir_transform/src/impossible_clauses.rs
@@ -58,7 +58,7 @@ fn has_structurally_impossible_sized_clause<'tcx>(
};
let trait_predicate = trait_predicate.skip_binder();
- trait_predicate.polarity == ty::PredicatePolarity::Positive
+ trait_predicate.polarity == ty::ClausePolarity::Positive
&& trait_predicate.def_id() == sized_trait
&& is_structurally_unsized(tcx, trait_predicate.self_ty())
}
diff --git a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs
index aa26a122817bb..17172c5333502 100644
--- a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs
@@ -964,7 +964,7 @@ struct ReplaceProjectionWith<'a, 'b, I: Interner, D: SolverDelegate,
param_env: I::ParamEnv,
self_ty: I::Ty,
- mapping: &'a HashMap>>>,
+ mapping: &'a HashMap>>>,
nested: Vec>,
}
@@ -975,7 +975,7 @@ where
{
fn projection_may_match(
&mut self,
- source_projection: ty::Binder>,
+ source_projection: ty::Binder>,
target_projection: ty::AliasTerm,
) -> Result {
if source_projection.item_def_id() != target_projection.expect_projection_def_id() {
diff --git a/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs b/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs
index 488d1b9215016..2fe983afc25ef 100644
--- a/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs
@@ -485,7 +485,7 @@ where
goal: Goal>,
) -> QueryResultOrRerunNonErased {
let (_, proven_via) = self.probe(|_| ProbeKind::ShadowedEnvProbing).enter(|ecx| {
- let trait_goal: Goal> =
+ let trait_goal: Goal> =
goal.with(ecx.cx(), goal.predicate.trait_ref);
ecx.compute_trait_goal(trait_goal).map_err(Into::into)
})?;
diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
index 78d3ab86cc250..be90d21e715ae 100644
--- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
@@ -1711,7 +1711,7 @@ where
let infcx = self.delegate.deref();
let mut folder = NormalizationFolder::new(infcx, vec![], |alias_term| {
let infer_term = self.next_term_infer_of_alias_kind(alias_term);
- let pred = ty::ProjectionPredicate { projection_term: alias_term, term: infer_term };
+ let pred = ty::ProjectionClause { projection_term: alias_term, term: infer_term };
let goal = Goal::new(self.cx(), param_env, pred);
self.inspect.add_goal(self.delegate, self.max_input_universe, source, goal);
let GoalEvaluation { goal, certainty, has_changed: _, stalled_on } =
diff --git a/compiler/rustc_next_trait_solver/src/solve/mod.rs b/compiler/rustc_next_trait_solver/src/solve/mod.rs
index 3504882834268..84c128ad0f45f 100644
--- a/compiler/rustc_next_trait_solver/src/solve/mod.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/mod.rs
@@ -394,7 +394,7 @@ where
let projection_goal = Goal::new(
self.cx(),
param_env,
- ty::ProjectionPredicate { projection_term: alias, term: normalized_term },
+ ty::ProjectionClause { projection_term: alias, term: normalized_term },
);
// We normalize the self type to be able to relate it with
// types from candidates.
diff --git a/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs b/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs
index 08c634620300a..20986813668d3 100644
--- a/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs
@@ -41,7 +41,7 @@ where
let trait_ref = goal.predicate.alias.trait_ref(cx);
let (_, proven_via) = self.probe(|_| ProbeKind::ShadowedEnvProbing).enter(|ecx| {
- let trait_goal: Goal> = goal.with(cx, trait_ref);
+ let trait_goal: Goal> = goal.with(cx, trait_ref);
ecx.compute_trait_goal(trait_goal)
})?;
self.assemble_and_merge_candidates(
@@ -536,7 +536,7 @@ where
let output_is_sized_pred =
ty::TraitRef::new(cx, cx.require_trait_lang_item(SolverTraitLangItem::Sized), [output]);
- let pred = ty::ProjectionPredicate {
+ let pred = ty::ProjectionClause {
projection_term: ty::AliasTerm::new(
cx,
goal.predicate.alias.kind,
@@ -625,7 +625,7 @@ where
} else {
panic!("no such associated type in `AsyncFn*`: {:?}", def_id)
};
- let pred = ty::ProjectionPredicate { projection_term, term }.upcast(cx);
+ let pred = ty::ProjectionClause { projection_term, term }.upcast(cx);
Self::probe_and_consider_implied_clause(
ecx,
@@ -821,7 +821,7 @@ where
ecx,
CandidateSource::BuiltinImpl(BuiltinImplSource::Misc),
goal,
- ty::ProjectionPredicate {
+ ty::ProjectionClause {
projection_term: ty::AliasTerm::new(
ecx.cx(),
cx.alias_term_kind_from_def_id(
@@ -859,7 +859,7 @@ where
ecx,
CandidateSource::BuiltinImpl(BuiltinImplSource::Misc),
goal,
- ty::ProjectionPredicate {
+ ty::ProjectionClause {
projection_term: ty::AliasTerm::new(
ecx.cx(),
cx.alias_term_kind_from_def_id(
@@ -950,7 +950,7 @@ where
ecx,
CandidateSource::BuiltinImpl(BuiltinImplSource::Misc),
goal,
- ty::ProjectionPredicate {
+ ty::ProjectionClause {
projection_term: ty::AliasTerm::new(
ecx.cx(),
goal.predicate.alias.kind,
diff --git a/compiler/rustc_next_trait_solver/src/solve/project_goals/anon_const.rs b/compiler/rustc_next_trait_solver/src/solve/project_goals/anon_const.rs
index fc0c34e63e187..5c6e9cc2045c2 100644
--- a/compiler/rustc_next_trait_solver/src/solve/project_goals/anon_const.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/project_goals/anon_const.rs
@@ -13,7 +13,7 @@ where
#[instrument(level = "trace", skip(self), ret)]
pub(super) fn normalize_anon_const(
&mut self,
- goal: Goal>,
+ goal: Goal>,
) -> QueryResultOrRerunNonErased {
let alias_const = goal.predicate.projection_term.expect_ct();
self.evaluate_const_and_instantiate_projection_term(
diff --git a/compiler/rustc_next_trait_solver/src/solve/project_goals/free_alias.rs b/compiler/rustc_next_trait_solver/src/solve/project_goals/free_alias.rs
index 7f5d258ccc706..efc630a106ee3 100644
--- a/compiler/rustc_next_trait_solver/src/solve/project_goals/free_alias.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/project_goals/free_alias.rs
@@ -17,7 +17,7 @@ where
{
pub(super) fn normalize_free_alias(
&mut self,
- goal: Goal>,
+ goal: Goal>,
) -> QueryResultOrRerunNonErased {
let cx = self.cx();
let free_alias = goal.predicate.projection_term;
diff --git a/compiler/rustc_next_trait_solver/src/solve/project_goals/inherent.rs b/compiler/rustc_next_trait_solver/src/solve/project_goals/inherent.rs
index afdc0c20a7132..a7480cded0514 100644
--- a/compiler/rustc_next_trait_solver/src/solve/project_goals/inherent.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/project_goals/inherent.rs
@@ -18,7 +18,7 @@ where
{
pub(super) fn normalize_inherent_associated_term(
&mut self,
- goal: Goal>,
+ goal: Goal>,
) -> QueryResultOrRerunNonErased {
let cx = self.cx();
let inherent = goal.predicate.projection_term;
diff --git a/compiler/rustc_next_trait_solver/src/solve/project_goals/mod.rs b/compiler/rustc_next_trait_solver/src/solve/project_goals/mod.rs
index 41fe4105cb745..6ec82aefb523f 100644
--- a/compiler/rustc_next_trait_solver/src/solve/project_goals/mod.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/project_goals/mod.rs
@@ -5,7 +5,7 @@ mod opaque_types;
use rustc_type_ir::search_graph::LowerAvailableDepth;
use rustc_type_ir::solve::QueryResultOrRerunNonErased;
-use rustc_type_ir::{self as ty, Interner, ProjectionPredicate};
+use rustc_type_ir::{self as ty, Interner, ProjectionClause};
use tracing::{instrument, trace};
use crate::delegate::SolverDelegate;
@@ -21,7 +21,7 @@ where
#[instrument(level = "trace", skip(self), ret)]
pub(super) fn compute_projection_goal(
&mut self,
- goal: Goal>,
+ goal: Goal>,
) -> QueryResultOrRerunNonErased {
match goal.predicate.projection_term.kind {
ty::AliasTermKind::ProjectionTy { .. } | ty::AliasTermKind::ProjectionConst { .. } => {
@@ -42,9 +42,9 @@ where
fn normalize_associated_term(
&mut self,
- goal: Goal>,
+ goal: Goal>,
) -> QueryResultOrRerunNonErased {
- let ty::ProjectionPredicate { projection_term: alias, term } = goal.predicate;
+ let ty::ProjectionClause { projection_term: alias, term } = goal.predicate;
let unconstrained_term = self.next_term_infer_of_alias_kind(alias);
let normalizes_to =
goal.with(self.cx(), ty::NormalizesTo { alias, term: unconstrained_term });
diff --git a/compiler/rustc_next_trait_solver/src/solve/project_goals/opaque_types.rs b/compiler/rustc_next_trait_solver/src/solve/project_goals/opaque_types.rs
index 3387c8599b911..126bffb720dbc 100644
--- a/compiler/rustc_next_trait_solver/src/solve/project_goals/opaque_types.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/project_goals/opaque_types.rs
@@ -16,7 +16,7 @@ where
#[tracing::instrument(skip(self))]
pub(super) fn normalize_opaque_type(
&mut self,
- goal: Goal>,
+ goal: Goal>,
) -> QueryResultOrRerunNonErased {
let cx = self.cx();
let opaque_ty = goal.predicate.projection_term;
diff --git a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs
index 07a87d1194d13..335263b1d169d 100644
--- a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs
@@ -10,9 +10,9 @@ use rustc_type_ir::solve::{
RerunReason, RerunResultExt, SizedTraitKind,
};
use rustc_type_ir::{
- self as ty, ExistentialPredicate, FieldInfo, Interner, MayBeErased, Movability,
- PredicatePolarity, Region, TraitPredicate, TraitRef, TypeVisitableExt as _, TypingMode,
- Unnormalized, Upcast as _, elaborate,
+ self as ty, ClausePolarity, ExistentialPredicate, FieldInfo, Interner, MayBeErased, Movability,
+ Region, TraitClause, TraitRef, TypeVisitableExt as _, TypingMode, Unnormalized, Upcast as _,
+ elaborate,
};
use tracing::{debug, instrument, trace, warn};
@@ -28,7 +28,7 @@ use crate::solve::{
has_only_region_constraints,
};
-impl assembly::GoalKind for TraitPredicate
+impl assembly::GoalKind for TraitClause
where
D: SolverDelegate,
I: Interner,
@@ -59,7 +59,7 @@ where
fn consider_impl_candidate(
ecx: &mut EvalCtxt<'_, D>,
- goal: Goal>,
+ goal: Goal>,
goal_trait_ref: TraitRef,
impl_def_id: I::ImplId,
then: impl FnOnce(&mut EvalCtxt<'_, D>, Certainty) -> QueryResultOrRerunNonErased,
@@ -87,8 +87,8 @@ where
}
// Impl matches polarity
- (ty::ImplPolarity::Positive, ty::PredicatePolarity::Positive)
- | (ty::ImplPolarity::Negative, ty::PredicatePolarity::Negative) => {
+ (ty::ImplPolarity::Positive, ty::ClausePolarity::Positive)
+ | (ty::ImplPolarity::Negative, ty::ClausePolarity::Negative) => {
if ecx.typing_mode().is_reflection()
&& !cx.is_fully_generic_for_reflection(impl_def_id)
{
@@ -99,8 +99,8 @@ where
}
// Impl doesn't match polarity
- (ty::ImplPolarity::Positive, ty::PredicatePolarity::Negative)
- | (ty::ImplPolarity::Negative, ty::PredicatePolarity::Positive) => {
+ (ty::ImplPolarity::Positive, ty::ClausePolarity::Negative)
+ | (ty::ImplPolarity::Negative, ty::ClausePolarity::Positive) => {
return Err(NoSolution.into());
}
};
@@ -151,14 +151,14 @@ where
cx: I,
clause_def_id: I::TraitId,
goal_def_id: I::TraitId,
- polarity: PredicatePolarity,
+ polarity: ClausePolarity,
) -> bool {
clause_def_id == goal_def_id
// PERF(sized-hierarchy): Sizedness supertraits aren't elaborated to improve perf, so
// check for a `MetaSized` supertrait being matched against a `Sized` assumption.
//
// `PointeeSized` bounds are syntactic sugar for a lack of bounds so don't need this.
- || (polarity == PredicatePolarity::Positive
+ || (polarity == ClausePolarity::Positive
&& cx.is_trait_lang_item(clause_def_id, SolverTraitLangItem::Sized)
&& cx.is_trait_lang_item(goal_def_id, SolverTraitLangItem::MetaSized))
}
@@ -214,7 +214,7 @@ where
goal: Goal,
) -> Result, NoSolutionOrRerunNonErased> {
let cx = ecx.cx();
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
@@ -280,7 +280,7 @@ where
ecx: &mut EvalCtxt<'_, D>,
goal: Goal,
) -> Result, NoSolutionOrRerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
@@ -307,7 +307,7 @@ where
goal: Goal,
sizedness: SizedTraitKind,
) -> Result, NoSolutionOrRerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
@@ -326,7 +326,7 @@ where
ecx: &mut EvalCtxt<'_, D>,
goal: Goal,
) -> Result, NoSolutionOrRerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
@@ -349,7 +349,7 @@ where
let self_ty = goal.predicate.self_ty();
match goal.predicate.polarity {
// impl FnPtr for FnPtr {}
- ty::PredicatePolarity::Positive => {
+ ty::ClausePolarity::Positive => {
if self_ty.is_fn_ptr() {
ecx.probe_builtin_trait_candidate(BuiltinImplSource::Misc).enter(|ecx| {
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
@@ -359,7 +359,7 @@ where
}
}
// impl !FnPtr for T where T != FnPtr && T is rigid {}
- ty::PredicatePolarity::Negative => {
+ ty::ClausePolarity::Negative => {
// If a type is rigid and not a fn ptr, then we know for certain
// that it does *not* implement `FnPtr`.
if !self_ty.is_fn_ptr() && self_ty.is_known_rigid() {
@@ -378,7 +378,7 @@ where
goal: Goal,
goal_kind: ty::ClosureKind,
) -> Result, NoSolutionOrRerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
@@ -416,7 +416,7 @@ where
goal: Goal,
goal_kind: ty::ClosureKind,
) -> Result, NoSolutionOrRerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
@@ -492,7 +492,7 @@ where
ecx: &mut EvalCtxt<'_, D>,
goal: Goal,
) -> Result, NoSolutionOrRerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
@@ -508,7 +508,7 @@ where
ecx: &mut EvalCtxt<'_, D>,
goal: Goal,
) -> Result, NoSolutionOrRerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
@@ -520,7 +520,7 @@ where
ecx: &mut EvalCtxt<'_, D>,
goal: Goal,
) -> Result, NoSolutionOrRerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
@@ -545,7 +545,7 @@ where
ecx: &mut EvalCtxt<'_, D>,
goal: Goal,
) -> Result, NoSolutionOrRerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
@@ -570,7 +570,7 @@ where
ecx: &mut EvalCtxt<'_, D>,
goal: Goal,
) -> Result, NoSolutionOrRerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
@@ -593,7 +593,7 @@ where
ecx: &mut EvalCtxt<'_, D>,
goal: Goal,
) -> Result, NoSolutionOrRerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
@@ -618,7 +618,7 @@ where
ecx: &mut EvalCtxt<'_, D>,
goal: Goal,
) -> Result, NoSolutionOrRerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
@@ -650,7 +650,7 @@ where
ecx: &mut EvalCtxt<'_, D>,
goal: Goal,
) -> Result, NoSolutionOrRerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
@@ -663,7 +663,7 @@ where
ecx: &mut EvalCtxt<'_, D>,
goal: Goal,
) -> Result, NoSolutionOrRerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
@@ -677,7 +677,7 @@ where
ecx: &mut EvalCtxt<'_, D>,
goal: Goal,
) -> Result, NoSolutionOrRerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
@@ -725,7 +725,7 @@ where
ecx: &mut EvalCtxt<'_, D>,
goal: Goal,
) -> Result, NoSolutionOrRerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
@@ -818,7 +818,7 @@ where
ecx: &mut EvalCtxt<'_, D>,
goal: Goal,
) -> Result>, RerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Ok(vec![]);
}
@@ -878,7 +878,7 @@ where
ecx: &mut EvalCtxt<'_, D>,
goal: Goal,
) -> Result, NoSolutionOrRerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
let cx = ecx.cx();
@@ -921,7 +921,7 @@ where
ecx: &mut EvalCtxt<'_, D>,
goal: Goal,
) -> Result, NoSolutionOrRerunNonErased> {
- if goal.predicate.polarity != ty::PredicatePolarity::Positive {
+ if goal.predicate.polarity != ty::ClausePolarity::Positive {
return Err(NoSolution.into());
}
if let ty::Adt(def, args) = goal.predicate.self_ty().kind()
@@ -976,11 +976,11 @@ where
#[inline(always)]
fn trait_predicate_with_def_id(
cx: I,
- clause: ty::Binder>,
+ clause: ty::Binder>,
did: I::TraitId,
) -> I::Clause {
clause
- .map_bound(|c| TraitPredicate {
+ .map_bound(|c| TraitClause {
trait_ref: TraitRef::new_from_args(cx, did, c.trait_ref.args),
polarity: c.polarity,
})
@@ -1305,7 +1305,7 @@ where
// the type's constituent types.
fn disqualify_auto_trait_candidate_due_to_possible_impl(
&mut self,
- goal: Goal>,
+ goal: Goal>,
) -> Option, NoSolutionOrRerunNonErased>> {
let self_ty = goal.predicate.self_ty();
let check_impls = || {
@@ -1417,7 +1417,7 @@ where
fn probe_and_evaluate_goal_for_constituent_tys(
&mut self,
source: CandidateSource,
- goal: Goal>,
+ goal: Goal>,
constituent_tys: impl Fn(
&EvalCtxt<'_, D>,
I::Ty,
@@ -1633,7 +1633,7 @@ where
#[instrument(level = "trace", skip(self))]
pub(super) fn compute_trait_goal(
&mut self,
- goal: Goal>,
+ goal: Goal>,
) -> Result<(CanonicalResponse, Option), NoSolutionOrRerunNonErased>
{
let (candidates, failed_candidate_info) =
diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs
index 879b239047fdc..c11a4b162971f 100644
--- a/compiler/rustc_privacy/src/lib.rs
+++ b/compiler/rustc_privacy/src/lib.rs
@@ -130,14 +130,14 @@ where
fn visit_clause(&mut self, clause: ty::Clause<'tcx>) -> V::Result {
match clause.kind().skip_binder() {
- ty::ClauseKind::Trait(ty::TraitPredicate { trait_ref, polarity: _ }) => {
+ ty::ClauseKind::Trait(ty::TraitClause { trait_ref, polarity: _ }) => {
self.visit_trait(trait_ref)
}
ty::ClauseKind::HostEffect(clause) => {
try_visit!(self.visit_trait(clause.trait_ref));
clause.constness.visit_with(self)
}
- ty::ClauseKind::Projection(ty::ProjectionPredicate {
+ ty::ClauseKind::Projection(ty::ProjectionClause {
projection_term: projection_ty,
term,
}) => {
diff --git a/compiler/rustc_public/src/ty/tys.rs b/compiler/rustc_public/src/ty/tys.rs
index 35792ce2fcc23..75e4272ead57a 100644
--- a/compiler/rustc_public/src/ty/tys.rs
+++ b/compiler/rustc_public/src/ty/tys.rs
@@ -1231,10 +1231,10 @@ pub enum PredicateKind {
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub enum ClauseKind {
- Trait(TraitPredicate),
+ Trait(TraitClause),
RegionOutlives(RegionOutlivesClause),
TypeOutlives(TypeOutlivesClause),
- Projection(ProjectionPredicate),
+ Projection(ProjectionClause),
ConstArgHasType(TyConst, Ty),
WellFormed(TermKind),
ConstEvaluatable(TyConst),
@@ -1260,11 +1260,14 @@ pub struct CoercePredicate {
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
-pub struct TraitPredicate {
+pub struct TraitClause {
pub trait_ref: TraitRef,
- pub polarity: PredicatePolarity,
+ pub polarity: ClausePolarity,
}
+#[deprecated = "renamed to [`TraitClause`]"]
+pub type TraitPredicate = TraitClause;
+
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct OutlivesClause(pub A, pub B);
@@ -1279,11 +1282,14 @@ pub type RegionOutlivesPredicate = RegionOutlivesClause;
pub type TypeOutlivesPredicate = TypeOutlivesClause;
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
-pub struct ProjectionPredicate {
+pub struct ProjectionClause {
pub projection_term: AliasTerm,
pub term: TermKind,
}
+#[deprecated = "renamed to [`ProjectionClause`]"]
+pub type ProjectionPredicate = ProjectionClause;
+
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub enum ImplPolarity {
Positive,
@@ -1292,11 +1298,14 @@ pub enum ImplPolarity {
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
-pub enum PredicatePolarity {
+pub enum ClausePolarity {
Positive,
Negative,
}
+#[deprecated = "renamed to [`ClausePolarity`]"]
+pub type PredicatePolarity = ClausePolarity;
+
macro_rules! index_impl {
($name:ident) => {
impl crate::IndexedVal for $name {
diff --git a/compiler/rustc_public/src/unstable/convert/stable/ty.rs b/compiler/rustc_public/src/unstable/convert/stable/ty.rs
index 160487400c38c..9eed22dc15d05 100644
--- a/compiler/rustc_public/src/unstable/convert/stable/ty.rs
+++ b/compiler/rustc_public/src/unstable/convert/stable/ty.rs
@@ -840,16 +840,16 @@ impl<'tcx> Stable<'tcx> for ty::CoercePredicate<'tcx> {
}
}
-impl<'tcx> Stable<'tcx> for ty::TraitPredicate<'tcx> {
- type T = crate::ty::TraitPredicate;
+impl<'tcx> Stable<'tcx> for ty::TraitClause<'tcx> {
+ type T = crate::ty::TraitClause;
fn stable<'cx>(
&self,
tables: &mut Tables<'cx, BridgeTys>,
cx: &CompilerCtxt<'cx, BridgeTys>,
) -> Self::T {
- let ty::TraitPredicate { trait_ref, polarity } = self;
- crate::ty::TraitPredicate {
+ let ty::TraitClause { trait_ref, polarity } = self;
+ crate::ty::TraitClause {
trait_ref: trait_ref.stable(tables, cx),
polarity: polarity.stable(tables, cx),
}
@@ -872,16 +872,16 @@ where
}
}
-impl<'tcx> Stable<'tcx> for ty::ProjectionPredicate<'tcx> {
- type T = crate::ty::ProjectionPredicate;
+impl<'tcx> Stable<'tcx> for ty::ProjectionClause<'tcx> {
+ type T = crate::ty::ProjectionClause;
fn stable<'cx>(
&self,
tables: &mut Tables<'cx, BridgeTys>,
cx: &CompilerCtxt<'cx, BridgeTys>,
) -> Self::T {
- let ty::ProjectionPredicate { projection_term, term } = self;
- crate::ty::ProjectionPredicate {
+ let ty::ProjectionClause { projection_term, term } = self;
+ crate::ty::ProjectionClause {
projection_term: projection_term.stable(tables, cx),
term: term.kind().stable(tables, cx),
}
@@ -901,14 +901,14 @@ impl<'tcx> Stable<'tcx> for ty::ImplPolarity {
}
}
-impl<'tcx> Stable<'tcx> for ty::PredicatePolarity {
- type T = crate::ty::PredicatePolarity;
+impl<'tcx> Stable<'tcx> for ty::ClausePolarity {
+ type T = crate::ty::ClausePolarity;
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T {
- use rustc_middle::ty::PredicatePolarity::*;
+ use rustc_middle::ty::ClausePolarity::*;
match self {
- Positive => crate::ty::PredicatePolarity::Positive,
- Negative => crate::ty::PredicatePolarity::Negative,
+ Positive => crate::ty::ClausePolarity::Positive,
+ Negative => crate::ty::ClausePolarity::Negative,
}
}
}
diff --git a/compiler/rustc_query_impl/src/dep_kind_vtables.rs b/compiler/rustc_query_impl/src/dep_kind_vtables.rs
index 495524c3f142a..e44f16441634b 100644
--- a/compiler/rustc_query_impl/src/dep_kind_vtables.rs
+++ b/compiler/rustc_query_impl/src/dep_kind_vtables.rs
@@ -180,7 +180,7 @@ macro_rules! define_dep_kind_vtables {
}
// Create an array of vtables, one for each dep kind (non-query and query).
-pub fn make_dep_kind_vtables<'tcx>(arena: &'tcx Arena<'tcx>) -> &'tcx [DepKindVTable<'tcx>] {
+pub(crate) fn make_dep_kind_vtables<'tcx>(arena: &'tcx Arena<'tcx>) -> &'tcx [DepKindVTable<'tcx>] {
let (nq_vtables, q_vtables) =
rustc_middle::queries::rustc_with_all_queries! { define_dep_kind_vtables! };
diff --git a/compiler/rustc_query_impl/src/lib.rs b/compiler/rustc_query_impl/src/lib.rs
index 259810b59c435..eed772cae580d 100644
--- a/compiler/rustc_query_impl/src/lib.rs
+++ b/compiler/rustc_query_impl/src/lib.rs
@@ -7,11 +7,11 @@
// tidy-alphabetical-end
use rustc_data_structures::sync::{AtomicU64, Lock};
+use rustc_middle::arena::Arena;
use rustc_middle::queries::{ExternProviders, Providers};
use rustc_middle::query::QuerySystem;
use rustc_middle::query::on_disk_cache::OnDiskCache;
-pub use crate::dep_kind_vtables::make_dep_kind_vtables;
pub use crate::job::{
CollectActiveJobsKind, QueryJobMap, break_query_cycle, collect_active_query_jobs,
print_query_stack,
@@ -27,6 +27,7 @@ mod query_vtables;
mod self_profile;
pub fn query_system<'tcx>(
+ arena: &'tcx Arena<'tcx>,
local_providers: Providers,
extern_providers: ExternProviders,
on_disk_cache: Option,
@@ -34,8 +35,10 @@ pub fn query_system<'tcx>(
) -> QuerySystem<'tcx> {
QuerySystem {
arenas: Default::default(),
+ dep_kind_vtables: dep_kind_vtables::make_dep_kind_vtables(arena),
query_vtables: query_vtables::make_query_vtables(incremental),
side_effects: Default::default(),
+ used_features: Default::default(),
on_disk_cache,
local_providers,
extern_providers,
diff --git a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs
index 1d4accd8ad3b6..8a44589f5052c 100644
--- a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs
+++ b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs
@@ -262,7 +262,7 @@ fn trait_object_ty<'tcx>(tcx: TyCtxt<'tcx>, poly_trait_ref: ty::PolyTraitRef<'tc
ty::ExistentialPredicate::Projection(
ty::ExistentialProjection::erase_self_ty(
tcx,
- ty::ProjectionPredicate { projection_term, term },
+ ty::ProjectionClause { projection_term, term },
),
)
})
diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs
index 40679f12e5ef8..99ff5d4b691ae 100644
--- a/compiler/rustc_session/src/session.rs
+++ b/compiler/rustc_session/src/session.rs
@@ -412,11 +412,6 @@ pub struct Session {
/// optimization-pass execution candidate during this compilation.
pub mir_opt_bisect_eval_count: AtomicUsize,
- /// Enabled features that are used in the current compilation.
- ///
- /// The value is the `DepNodeIndex` of the node encodes the used feature.
- pub used_features: Lock>,
-
/// Whether the test harness removed a user-written `#[rustc_main]` attribute
/// while generating the synthetic test entry point.
pub removed_rustc_main_attr: AtomicBool,
@@ -1388,7 +1383,6 @@ pub fn build_session(
fallback_intrinsics: FxHashSet::default(), // filled by `run_compiler`
thin_lto_supported: true, // filled by `run_compiler`
mir_opt_bisect_eval_count: AtomicUsize::new(0),
- used_features: Lock::default(),
removed_rustc_main_attr: AtomicBool::new(false),
pointer_auth_config,
};
diff --git a/compiler/rustc_target/src/callconv/arm.rs b/compiler/rustc_target/src/callconv/arm.rs
index 41c3a0a0210fb..66f0ded3874f9 100644
--- a/compiler/rustc_target/src/callconv/arm.rs
+++ b/compiler/rustc_target/src/callconv/arm.rs
@@ -1,7 +1,14 @@
use rustc_abi::{ArmCall, CanonAbi, HasDataLayout, TyAbiInterface};
use crate::callconv::{ArgAbi, FnAbi, Reg, RegKind, Uniform};
-use crate::spec::HasTargetSpec;
+use crate::spec::{CfgAbi, HasTargetSpec, Os};
+
+#[derive(Clone, Copy)]
+enum ArmAbiKind {
+ Aapcs,
+ AapcsVfp,
+ Aapcs16Vfp,
+}
fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>) -> Option
where
@@ -26,7 +33,7 @@ where
})
}
-fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>, vfp: bool)
+fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>, abi_kind: ArmAbiKind, vfp: bool)
where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout,
@@ -49,14 +56,21 @@ where
let size = ret.layout.size;
let bits = size.bits();
+
if bits <= 32 {
+ // Aggregates <= 4 bytes are returned in r0; other aggregates are returned indirectly.
ret.cast_to(Uniform::new(Reg::i32(), size));
return;
+ } else if matches!(abi_kind, ArmAbiKind::Aapcs16Vfp) && bits <= 128 {
+ // watchOS returns the remaining aggregates of up to 128 bits in GPRs.
+ ret.cast_to(Uniform::consecutive(Reg::i32(), size));
+ return;
}
+
ret.make_indirect();
}
-fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>, vfp: bool)
+fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>, abi_kind: ArmAbiKind, vfp: bool)
where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout,
@@ -74,14 +88,27 @@ where
return;
}
- if vfp {
+ // watchOS also passes homogeneous aggregates in VFP registers, and unlike `AapcsVfp` it does
+ // so even for variadics and for `extern "aapcs"`: the backend will use GPRs if needed.
+ if vfp || matches!(abi_kind, ArmAbiKind::Aapcs16Vfp) {
if let Some(uniform) = is_homogeneous_aggregate(cx, arg) {
arg.cast_to(uniform);
return;
}
}
- let align = arg.layout.align.bytes();
+ // For the composites that are left, watchOS adopts the 64-bit AAPCS rule: those larger than
+ // 128 bits are placed in space allocated by the caller, and a pointer is passed.
+ if matches!(abi_kind, ArmAbiKind::Aapcs16Vfp) && arg.layout.size.bits() > 128 {
+ arg.make_indirect();
+ return;
+ }
+
+ let align = match abi_kind {
+ ArmAbiKind::Aapcs | ArmAbiKind::AapcsVfp => arg.layout.unadjusted_abi_align.bytes(),
+ ArmAbiKind::Aapcs16Vfp => arg.layout.align.bytes(),
+ };
+
let total = arg.layout.size;
arg.cast_to(Uniform::consecutive(if align <= 4 { Reg::i32() } else { Reg::i64() }, total));
}
@@ -91,20 +118,37 @@ where
Ty: TyAbiInterface<'a, C> + Copy,
C: HasDataLayout + HasTargetSpec,
{
- // If this is a target with a hard-float ABI, and the function is not explicitly
- // `extern "aapcs"`, then we must use the VFP registers for homogeneous aggregates.
- let vfp = cx.target_spec().llvm_target.ends_with("hf")
- && fn_abi.conv != CanonAbi::Arm(ArmCall::Aapcs)
- && !fn_abi.c_variadic;
+ let abi_kind = if cx.target_spec().os == Os::WatchOs {
+ ArmAbiKind::Aapcs16Vfp
+ } else if cx.target_spec().cfg_abi == CfgAbi::EabiHf {
+ ArmAbiKind::AapcsVfp
+ } else {
+ ArmAbiKind::Aapcs
+ };
+
+ // Whether we must use the VFP registers for homogeneous aggregates.
+ let is_effectively_vfp = |accept_aapcs16| {
+ // When the user requested aapcs explicitly, honor that.
+ if matches!(fn_abi.conv, CanonAbi::Arm(ArmCall::Aapcs)) {
+ return false;
+ }
+
+ match abi_kind {
+ ArmAbiKind::AapcsVfp => true,
+ ArmAbiKind::Aapcs16Vfp => accept_aapcs16,
+ ArmAbiKind::Aapcs => false,
+ }
+ };
if !fn_abi.ret.is_ignore() {
- classify_ret(cx, &mut fn_abi.ret, vfp);
+ classify_ret(cx, &mut fn_abi.ret, abi_kind, !fn_abi.c_variadic && is_effectively_vfp(true));
}
+ let is_arg_vfp = !fn_abi.c_variadic && is_effectively_vfp(false);
for arg in fn_abi.args.iter_mut() {
if arg.is_ignore() {
continue;
}
- classify_arg(cx, arg, vfp);
+ classify_arg(cx, arg, abi_kind, is_arg_vfp);
}
}
diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs
index b3865eeaf6bf8..ff6cade232523 100644
--- a/compiler/rustc_target/src/spec/mod.rs
+++ b/compiler/rustc_target/src/spec/mod.rs
@@ -2651,8 +2651,8 @@ pub struct TargetOptions {
/// Use LLVM intrinsic for mcount function name
pub llvm_mcount_intrinsic: Option>,
- /// LLVM ABI name, corresponds to the '-mabi' parameter available in multilib C compilers
- /// and the `-target-abi` flag in llc. In the LLVM API this is `MCOptions.ABIName`.
+ /// LLVM ABI name, corresponds to the '-mabi' parameter available in multilib C compilers and
+ /// the `-target-abi` flag in llc. In the LLVM API this is `MCTargetOptions::ABIName`.
pub llvm_abiname: LlvmAbi,
/// Control the float ABI to use, for architectures that support it. The only architecture we
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 c28970829f0a4..45ae86b39f35e 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
@@ -386,8 +386,7 @@ impl Trait for X {
.iter()
.any(|(pred, _span)| match pred.kind().skip_binder() {
ty::ClauseKind::Trait(trait_predicate)
- if trait_predicate.polarity
- == ty::PredicatePolarity::Positive =>
+ if trait_predicate.polarity == ty::ClausePolarity::Positive =>
{
trait_predicate.def_id() == def_id
}
@@ -524,7 +523,7 @@ impl Trait for X {
else {
continue;
};
- if trait_predicate.polarity != ty::PredicatePolarity::Positive {
+ if trait_predicate.polarity != ty::ClausePolarity::Positive {
continue;
}
let def_id = trait_predicate.def_id();
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 06d882a309489..2e0fc64c5445f 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs
@@ -11,7 +11,7 @@ use rustc_infer::traits::util::elaborate;
use rustc_infer::traits::{
Obligation, ObligationCause, ObligationCauseCode, PolyTraitObligation, PredicateObligation,
};
-use rustc_middle::ty::print::PrintPolyTraitPredicateExt;
+use rustc_middle::ty::print::PrintPolyTraitClauseExt;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable as _, TypeVisitableExt as _, Unnormalized};
use rustc_session::diagnostics::feature_err_unstable_feature_bound;
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span};
@@ -67,8 +67,8 @@ pub fn compute_applicable_impls_for_diagnostics<'tcx>(
let impl_polarity = impl_trait_header.polarity;
match (impl_polarity, predicate_polarity) {
- (ty::ImplPolarity::Positive, ty::PredicatePolarity::Positive)
- | (ty::ImplPolarity::Negative, ty::PredicatePolarity::Negative) => {}
+ (ty::ImplPolarity::Positive, ty::ClausePolarity::Positive)
+ | (ty::ImplPolarity::Negative, ty::ClausePolarity::Negative) => {}
_ => return false,
}
@@ -99,7 +99,7 @@ pub fn compute_applicable_impls_for_diagnostics<'tcx>(
})
};
- let param_env_candidate_may_apply = |poly_trait_predicate: ty::PolyTraitPredicate<'tcx>| {
+ let param_env_candidate_may_apply = |poly_trait_predicate: ty::PolyTraitClause<'tcx>| {
let ocx = ObligationCtxt::new(infcx);
infcx.enter_forall(obligation.predicate, |placeholder_obligation| {
let obligation_trait_ref = ocx.normalize(
@@ -791,7 +791,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
fn applicable_impls_to_mention(
&self,
obligation: &PredicateObligation<'tcx>,
- trait_pred: ty::PolyTraitPredicate<'tcx>,
+ trait_pred: ty::PolyTraitClause<'tcx>,
) -> Option> {
let mut ambiguities = compute_applicable_impls_for_diagnostics(
self.infcx,
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 6293c85f595d8..082c312c7c75e 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
@@ -26,7 +26,7 @@ use rustc_middle::traits::select::OverflowError;
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::print::{
- PrintPolyTraitPredicateExt, PrintPolyTraitRefExt as _, PrintTraitPredicateExt as _,
+ PrintPolyTraitClauseExt, PrintPolyTraitRefExt as _, PrintTraitClauseExt as _,
PrintTraitRefExt as _, with_forced_trimmed_paths,
};
use rustc_middle::ty::{
@@ -865,9 +865,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
// FIXME(const_trait_impl): We should recompute the clause with `[const]`
// if it's `const`, and if it holds, explain that this bound only
// *conditionally* holds.
- let trait_ref = clause.map_bound(|clause| ty::TraitPredicate {
+ let trait_ref = clause.map_bound(|clause| ty::TraitClause {
trait_ref: clause.trait_ref,
- polarity: ty::PredicatePolarity::Positive,
+ polarity: ty::ClausePolarity::Positive,
});
let mut file = None;
@@ -980,7 +980,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
fn emit_specialized_closure_kind_error(
&self,
obligation: &PredicateObligation<'tcx>,
- mut trait_pred: ty::PolyTraitPredicate<'tcx>,
+ mut trait_pred: ty::PolyTraitClause<'tcx>,
) -> Option {
// If we end up on an `AsyncFnKindHelper` goal, try to unwrap the parent
// `AsyncFn*` goal.
@@ -1097,7 +1097,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
fn detect_negative_literal(
&self,
obligation: &PredicateObligation<'tcx>,
- trait_pred: ty::PolyTraitPredicate<'tcx>,
+ trait_pred: ty::PolyTraitClause<'tcx>,
err: &mut Diag<'_>,
) -> bool {
if let ObligationCauseCode::UnOp { hir_id, .. } = obligation.cause.code()
@@ -1132,7 +1132,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
fn try_conversion_context(
&self,
obligation: &PredicateObligation<'tcx>,
- trait_pred: ty::PolyTraitPredicate<'tcx>,
+ trait_pred: ty::PolyTraitClause<'tcx>,
err: &mut Diag<'_>,
) -> (bool, bool) {
let span = obligation.cause.span;
@@ -1343,7 +1343,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
err: &mut Diag<'_>,
self_ty: Ty<'_>,
found_ty: Option>,
- trait_pred: ty::PolyTraitPredicate<'tcx>,
+ trait_pred: ty::PolyTraitClause<'tcx>,
) -> bool {
match (self_ty.kind(), found_ty) {
(ty::Adt(def, _), Some(ty))
@@ -1492,8 +1492,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
fn can_match_trait(
&self,
param_env: ty::ParamEnv<'tcx>,
- goal: ty::TraitPredicate<'tcx>,
- assumption: ty::PolyTraitPredicate<'tcx>,
+ goal: ty::TraitClause<'tcx>,
+ assumption: ty::PolyTraitClause<'tcx>,
) -> bool {
// Fast path
if goal.polarity != assumption.polarity() {
@@ -1537,8 +1537,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
fn can_match_projection(
&self,
param_env: ty::ParamEnv<'tcx>,
- goal: ty::ProjectionPredicate<'tcx>,
- assumption: ty::PolyProjectionPredicate<'tcx>,
+ goal: ty::ProjectionClause<'tcx>,
+ assumption: ty::PolyProjectionClause<'tcx>,
) -> bool {
let assumption = self.instantiate_binder_with_fresh_vars(
DUMMY_SP,
@@ -1612,9 +1612,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
if !error.projection_term.kind.is_trait_projection() {
return false;
}
- let trait_pred = ty::TraitPredicate {
+ let trait_pred = ty::TraitClause {
trait_ref: error.projection_term.trait_ref(self.tcx),
- polarity: ty::PredicatePolarity::Positive,
+ polarity: ty::ClausePolarity::Positive,
};
// Elaborating is what pairs a failing `C: FnMut(..)` with the
// `>::Output` projection resting on it. A supertrait can hold
@@ -2087,7 +2087,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
pub(super) fn find_similar_impl_candidates(
&self,
- trait_pred: ty::PolyTraitPredicate<'tcx>,
+ trait_pred: ty::PolyTraitClause<'tcx>,
) -> Vec> {
let mut candidates: Vec<_> = self
.tcx
@@ -2119,7 +2119,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
&self,
impl_candidates: &[ImplCandidate<'tcx>],
obligation: &PredicateObligation<'tcx>,
- trait_pred: ty::PolyTraitPredicate<'tcx>,
+ trait_pred: ty::PolyTraitClause<'tcx>,
body_def_id: LocalDefId,
err: &mut Diag<'_>,
other: bool,
@@ -2704,7 +2704,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
fn report_similar_impl_candidates_for_root_obligation(
&self,
obligation: &PredicateObligation<'tcx>,
- trait_predicate: ty::Binder<'tcx, ty::TraitPredicate<'tcx>>,
+ trait_predicate: ty::Binder<'tcx, ty::TraitClause<'tcx>>,
body_def_id: LocalDefId,
err: &mut Diag<'_>,
) {
@@ -2772,7 +2772,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
fn check_same_trait_different_version(
&self,
err: &mut Diag<'_>,
- trait_pred: ty::PolyTraitPredicate<'tcx>,
+ trait_pred: ty::PolyTraitClause<'tcx>,
) -> bool {
let get_trait_impls = |trait_def_id| {
let mut trait_impls = vec![];
@@ -2809,11 +2809,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
err.span_note(sp, crate_msg);
}
- fn note_adt_version_mismatch(
- &self,
- err: &mut Diag<'_>,
- trait_pred: ty::PolyTraitPredicate<'tcx>,
- ) {
+ fn note_adt_version_mismatch(&self, err: &mut Diag<'_>, trait_pred: ty::PolyTraitClause<'tcx>) {
let ty::Adt(impl_self_def, _) = trait_pred.self_ty().skip_binder().peel_refs().kind()
else {
return;
@@ -2875,7 +2871,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
&self,
err: &mut Diag<'_>,
obligation: &PredicateObligation<'tcx>,
- trait_pred: ty::PolyTraitPredicate<'tcx>,
+ trait_pred: ty::PolyTraitClause<'tcx>,
) -> bool {
let mut suggested = false;
let trait_def_id = trait_pred.def_id();
@@ -2912,7 +2908,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
self.tcx,
obligation.cause.clone(),
obligation.param_env,
- trait_pred.map_bound(|tr| ty::TraitPredicate {
+ trait_pred.map_bound(|tr| ty::TraitClause {
trait_ref: ty::TraitRef::new(self.tcx, def_id, tr.trait_ref.args),
..tr
}),
@@ -2937,7 +2933,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
&self,
err: &mut Diag<'_>,
obligation: &PredicateObligation<'tcx>,
- trait_pred: ty::PolyTraitPredicate<'tcx>,
+ trait_pred: ty::PolyTraitClause<'tcx>,
) -> bool {
if self.check_same_trait_different_version(err, trait_pred) {
return true;
@@ -2958,7 +2954,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
pub(super) fn mk_trait_obligation_with_new_self_ty(
&self,
param_env: ty::ParamEnv<'tcx>,
- trait_ref_and_ty: ty::Binder<'tcx, (ty::TraitPredicate<'tcx>, Ty<'tcx>)>,
+ trait_ref_and_ty: ty::Binder<'tcx, (ty::TraitClause<'tcx>, Ty<'tcx>)>,
) -> PredicateObligation<'tcx> {
let trait_pred = trait_ref_and_ty
.map_bound(|(tr, new_self_ty)| tr.with_replaced_self_ty(self.tcx, new_self_ty));
@@ -3089,7 +3085,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
fn get_standard_error_message(
&self,
- trait_predicate: ty::PolyTraitPredicate<'tcx>,
+ trait_predicate: ty::PolyTraitClause<'tcx>,
predicate_constness: Option,
post_message: String,
long_ty_path: &mut Option,
@@ -3106,9 +3102,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
fn select_transmute_obligation_for_reporting(
&self,
obligation: &PredicateObligation<'tcx>,
- trait_predicate: ty::PolyTraitPredicate<'tcx>,
+ trait_predicate: ty::PolyTraitClause<'tcx>,
root_obligation: &PredicateObligation<'tcx>,
- ) -> (PredicateObligation<'tcx>, ty::PolyTraitPredicate<'tcx>) {
+ ) -> (PredicateObligation<'tcx>, ty::PolyTraitClause<'tcx>) {
if obligation.predicate.has_non_region_param() || obligation.has_non_region_infer() {
return (obligation.clone(), trait_predicate);
}
@@ -3153,7 +3149,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
fn get_safe_transmute_error_and_reason(
&self,
obligation: PredicateObligation<'tcx>,
- trait_pred: ty::PolyTraitPredicate<'tcx>,
+ trait_pred: ty::PolyTraitClause<'tcx>,
span: Span,
) -> GetSafeTransmuteErrorAndReason {
use rustc_transmute::Answer;
@@ -3338,7 +3334,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
self.tcx,
ObligationCause::dummy(),
param_env,
- ty::TraitPredicate { trait_ref, polarity: ty::PredicatePolarity::Positive },
+ ty::TraitClause { trait_ref, polarity: ty::ClausePolarity::Positive },
);
self.predicate_must_hold_modulo_regions(&obligation)
@@ -3368,7 +3364,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
&self,
root_obligation: &PredicateObligation<'tcx>,
obligation: &PredicateObligation<'tcx>,
- trait_predicate: ty::PolyTraitPredicate<'tcx>,
+ trait_predicate: ty::PolyTraitClause<'tcx>,
err: &mut Diag<'_>,
span: Span,
is_fn_trait: bool,
@@ -3411,13 +3407,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
&& self.tcx.trait_impls_of(trait_def_id).is_empty()
&& !self.tcx.trait_is_auto(trait_def_id)
&& !self.tcx.trait_is_alias(trait_def_id)
- && trait_predicate.polarity() == ty::PredicatePolarity::Positive
+ && trait_predicate.polarity() == ty::ClausePolarity::Positive
{
err.span_help(
self.tcx.def_span(trait_def_id),
msg!("this trait has no implementations, consider adding one"),
);
- } else if !suggested && trait_predicate.polarity() == ty::PredicatePolarity::Positive {
+ } else if !suggested && trait_predicate.polarity() == ty::ClausePolarity::Positive {
// Can't show anything else useful, try to find similar impls.
let impl_candidates = self.find_similar_impl_candidates(trait_predicate);
if !self.report_similar_impl_candidates(
@@ -3452,7 +3448,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
fn add_help_message_for_fn_trait(
&self,
- trait_pred: ty::PolyTraitPredicate<'tcx>,
+ trait_pred: ty::PolyTraitClause<'tcx>,
err: &mut Diag<'_>,
implemented_kind: ty::ClosureKind,
params: ty::Binder<'tcx, Ty<'tcx>>,
@@ -3884,7 +3880,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
&self,
param_env: ty::ParamEnv<'tcx>,
ty: ty::Binder<'tcx, Ty<'tcx>>,
- polarity: ty::PredicatePolarity,
+ polarity: ty::ClausePolarity,
) -> Result<(ty::ClosureKind, ty::Binder<'tcx, Ty<'tcx>>), ()> {
self.commit_if_ok(|_| {
for trait_def_id in [
@@ -3902,7 +3898,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
self.tcx,
ObligationCause::dummy(),
param_env,
- ty.rebind(ty::TraitPredicate { trait_ref, polarity }),
+ ty.rebind(ty::TraitClause { trait_ref, polarity }),
);
let ocx = ObligationCtxt::new(self);
ocx.register_obligation(obligation);
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 f7e4ec6164c99..ed22d4f4ef246 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
@@ -33,11 +33,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
pub fn on_unimplemented_note(
&self,
- trait_pred: ty::PolyTraitPredicate<'tcx>,
+ trait_pred: ty::PolyTraitClause<'tcx>,
obligation: &PredicateObligation<'tcx>,
long_ty_path: &mut Option,
) -> CustomDiagnostic {
- if trait_pred.polarity() != ty::PredicatePolarity::Positive {
+ if trait_pred.polarity() != ty::ClausePolarity::Positive {
return CustomDiagnostic::default();
}
// This is needed as `on_unimplemented` is currently not allowed on trait aliases,
@@ -59,7 +59,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
pub(crate) fn on_unimplemented_components(
&self,
- trait_pred: ty::PolyTraitPredicate<'tcx>,
+ trait_pred: ty::PolyTraitClause<'tcx>,
obligation: &PredicateObligation<'tcx>,
long_ty_path: &mut Option,
print_infer_ty_var: bool,
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 35bedea6c565e..01b3026ff4e5b 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
@@ -27,7 +27,7 @@ use rustc_middle::traits::IsConstable;
use rustc_middle::ty::adjustment::{Adjust, DerefAdjustKind};
use rustc_middle::ty::error::TypeError;
use rustc_middle::ty::print::{
- PrintPolyTraitPredicateExt as _, PrintPolyTraitRefExt, PrintTraitPredicateExt as _,
+ PrintPolyTraitClauseExt as _, PrintPolyTraitRefExt, PrintTraitClauseExt as _,
PrintTraitRefExt as _, with_forced_trimmed_paths, with_no_trimmed_paths,
with_types_for_suggestion,
};
@@ -128,7 +128,7 @@ pub fn suggest_restriction<'tcx, G: EmissionGuarantee>(
err: &mut Diag<'_, G>,
fn_sig: Option<&hir::FnSig<'_>>,
projection: Option>,
- trait_pred: ty::PolyTraitPredicate<'tcx>,
+ trait_pred: ty::PolyTraitClause<'tcx>,
// When we are dealing with a trait, `super_traits` will be `Some`:
// Given `trait T: A + B + C {}`
// - ^^^^^^^^^ GenericBounds
@@ -464,11 +464,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
pub fn suggest_restricting_param_bound(
&self,
err: &mut Diag<'_>,
- trait_pred: ty::PolyTraitPredicate<'tcx>,
+ trait_pred: ty::PolyTraitClause<'tcx>,
associated_ty: Option<(&'static str, Ty<'tcx>)>,
mut body_def_id: LocalDefId,
) {
- if trait_pred.skip_binder().polarity != ty::PredicatePolarity::Positive {
+ if trait_pred.skip_binder().polarity != ty::ClausePolarity::Positive {
return;
}
@@ -703,7 +703,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut Diag<'_>,
- trait_pred: ty::PolyTraitPredicate<'tcx>,
+ trait_pred: ty::PolyTraitClause<'tcx>,
) -> bool {
let mut code = obligation.cause.code();
if let ObligationCauseCode::FunctionArg { arg_hir_id, call_hir_id, .. } = code
@@ -853,7 +853,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
// one at a time to account for cases such as &Box