diff options
| author | Michael Goulet <michael@errs.io> | 2025-01-25 21:42:29 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-02-11 19:24:07 +0000 |
| commit | ef9d992a0d8a7a093a398e51b42dbea8eed72847 (patch) | |
| tree | ae56ab103fcb7af01a9e432196c43f9dd5ab7152 | |
| parent | ce0c952e968777004fc59f45653be2fda116fee1 (diff) | |
| download | rust-ef9d992a0d8a7a093a398e51b42dbea8eed72847.tar.gz rust-ef9d992a0d8a7a093a398e51b42dbea8eed72847.zip | |
Deeply normalize in impl header
| -rw-r--r-- | compiler/rustc_borrowck/src/type_check/free_region_relations.rs | 2 | ||||
| -rw-r--r-- | tests/ui/borrowck/implied-bound-from-impl-header.rs | 28 |
2 files changed, 29 insertions, 1 deletions
diff --git a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs index a7f8d9c2884..b8008f18a39 100644 --- a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs +++ b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs @@ -301,7 +301,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> { if matches!(tcx.def_kind(defining_ty_def_id), DefKind::AssocFn | DefKind::AssocConst) { for &(ty, _) in tcx.assumed_wf_types(tcx.local_parent(defining_ty_def_id)) { let result: Result<_, ErrorGuaranteed> = param_env - .and(type_op::normalize::Normalize { value: ty }) + .and(DeeplyNormalize { value: ty }) .fully_perform(self.infcx, span); let Ok(TypeOpOutput { output: norm_ty, constraints: c, .. }) = result else { continue; diff --git a/tests/ui/borrowck/implied-bound-from-impl-header.rs b/tests/ui/borrowck/implied-bound-from-impl-header.rs new file mode 100644 index 00000000000..326a62b22f0 --- /dev/null +++ b/tests/ui/borrowck/implied-bound-from-impl-header.rs @@ -0,0 +1,28 @@ +//@ check-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +// Make sure that we can normalize `<T as Ref<'a>>::Assoc` to `&'a T` and get +// its implied bounds in impl header. + +trait Ref<'a> { + type Assoc; +} +impl<'a, T> Ref<'a> for T where T: 'a { + type Assoc = &'a T; +} + +fn outlives<'a, T: 'a>() {} + +trait Trait<'a, T> { + fn test(); +} + +impl<'a, T> Trait<'a, T> for <T as Ref<'a>>::Assoc { + fn test() { + outlives::<'a, T>(); + } +} + +fn main() {} |
