From 8daf98b6236bed2db074b8e8beb7e3225201b71a Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sun, 13 Jul 2025 16:26:13 +0000 Subject: Imply always-const host effects the same as any other item bound --- .../rustc_hir_analysis/src/collect/item_bounds.rs | 1 + tests/ui/traits/const-traits/imply-always-const.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/ui/traits/const-traits/imply-always-const.rs diff --git a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs index 7e3fb5448f6..548ba343aae 100644 --- a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs +++ b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs @@ -124,6 +124,7 @@ fn remap_gat_vars_and_recurse_into_nested_projections<'tcx>( ty::ClauseKind::Trait(tr) => tr.self_ty(), ty::ClauseKind::Projection(proj) => proj.projection_term.self_ty(), ty::ClauseKind::TypeOutlives(outlives) => outlives.0, + ty::ClauseKind::HostEffect(host) => host.self_ty(), _ => return None, }; diff --git a/tests/ui/traits/const-traits/imply-always-const.rs b/tests/ui/traits/const-traits/imply-always-const.rs new file mode 100644 index 00000000000..f6cab0681ec --- /dev/null +++ b/tests/ui/traits/const-traits/imply-always-const.rs @@ -0,0 +1,19 @@ +//@ check-pass + +#![feature(const_trait_impl)] + +#[const_trait] +trait A where Self::Assoc: const B { + type Assoc; +} + +#[const_trait] +trait B {} + +fn needs_b() {} + +fn test() { + needs_b::(); +} + +fn main() {} -- cgit 1.4.1-3-g733a5