diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-05-24 06:05:39 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-24 06:05:39 +0200 |
| commit | 8227c4fd6eb1b5b9350c1ae171bca5c1a602e8ab (patch) | |
| tree | 56d1c49cbc8dd7f42fbf7e31deb7a1fd1f12b0c2 /compiler/rustc_trait_selection/src/traits | |
| parent | 783bea940b190e8e66c52157e740dc486aaa01ab (diff) | |
| parent | 3a2710cdb6cb10d5bc5cffbc75be895b6dd21e26 (diff) | |
| download | rust-8227c4fd6eb1b5b9350c1ae171bca5c1a602e8ab.tar.gz rust-8227c4fd6eb1b5b9350c1ae171bca5c1a602e8ab.zip | |
Rollup merge of #111880 - compiler-errors:pointer-like-param-env, r=jackh726
Don't ICE when computing PointerLike trait when region vars are in param-env Fixes #111877
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index aa230936903..8bc82b9f549 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -967,16 +967,18 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ) { // The regions of a type don't affect the size of the type let tcx = self.tcx(); - let self_ty = - tcx.erase_regions(tcx.erase_late_bound_regions(obligation.predicate.self_ty())); - + let self_ty = tcx.erase_late_bound_regions(obligation.predicate.self_ty()); + // We should erase regions from both the param-env and type, since both + // may have infer regions. Specifically, after canonicalizing and instantiating, + // early bound regions turn into region vars in both the new and old solver. + let key = tcx.erase_regions(obligation.param_env.and(self_ty)); // But if there are inference variables, we have to wait until it's resolved. - if self_ty.has_non_region_infer() { + if key.has_non_region_infer() { candidates.ambiguous = true; return; } - if let Ok(layout) = tcx.layout_of(obligation.param_env.and(self_ty)) + if let Ok(layout) = tcx.layout_of(key) && layout.layout.is_pointer_like(&tcx.data_layout) { candidates.vec.push(BuiltinCandidate { has_nested: false }); |
