Skip to content

Commit fad9400

Browse files
authored
Rollup merge of rust-lang#120378 - lcnr:normalize-ast, r=compiler-errors
always normalize `LoweredTy` in the new solver I currently expect us to stop using alias bound candidates of normalizable aliases due to rust-lang/trait-system-refactor-initiative#77 by landing rust-lang#119744. At this point it mostly doesn't matter whether we eagerly normalize (and replace with infer vars in case of ambiguity). cc rust-lang#113473 previous attempt The infer var replacement for ambiguous projections can in very rare cases: - weaken inference rust-lang/trait-system-refactor-initiative#81 - strengthen inference rust-lang/trait-system-refactor-initiative#7 I do not expect this impact on inference to significantly affect real crates. r? ``@compiler-errors``
2 parents a7f5bde + 7b6ac8b commit fad9400

16 files changed

+60
-36
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,14 @@ pub struct LoweredTy<'tcx> {
369369

370370
impl<'tcx> LoweredTy<'tcx> {
371371
pub fn from_raw(fcx: &FnCtxt<'_, 'tcx>, span: Span, raw: Ty<'tcx>) -> LoweredTy<'tcx> {
372-
LoweredTy { raw, normalized: fcx.normalize(span, raw) }
372+
// FIXME(-Znext-solver): We're still figuring out how to best handle
373+
// normalization and this doesn't feel too great. We should look at this
374+
// code again before stabilizing it.
375+
let normalized = if fcx.next_trait_solver() {
376+
fcx.try_structurally_resolve_type(span, raw)
377+
} else {
378+
fcx.normalize(span, raw)
379+
};
380+
LoweredTy { raw, normalized }
373381
}
374382
}

tests/ui/for/issue-20605.next.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,11 @@ error: the type `&mut <dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIte
3434
LL | for item in *things { *item = 0 }
3535
| ^^^^^^^
3636

37-
error[E0277]: the size for values of type `<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item` cannot be known at compilation time
38-
--> $DIR/issue-20605.rs:5:9
37+
error: the type `Option<<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item>` is not well-formed
38+
--> $DIR/issue-20605.rs:5:17
3939
|
4040
LL | for item in *things { *item = 0 }
41-
| ^^^^ doesn't have a size known at compile-time
42-
|
43-
= help: the trait `Sized` is not implemented for `<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item`
44-
= note: all local variables must have a statically known size
45-
= help: unsized locals are gated as an unstable feature
41+
| ^^^^^^^
4642

4743
error[E0277]: the size for values of type `<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item` cannot be known at compilation time
4844
--> $DIR/issue-20605.rs:5:5
@@ -54,11 +50,15 @@ LL | for item in *things { *item = 0 }
5450
note: required by a bound in `None`
5551
--> $SRC_DIR/core/src/option.rs:LL:COL
5652

57-
error: the type `Option<<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item>` is not well-formed
58-
--> $DIR/issue-20605.rs:5:17
53+
error[E0277]: the size for values of type `<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item` cannot be known at compilation time
54+
--> $DIR/issue-20605.rs:5:9
5955
|
6056
LL | for item in *things { *item = 0 }
61-
| ^^^^^^^
57+
| ^^^^ doesn't have a size known at compile-time
58+
|
59+
= help: the trait `Sized` is not implemented for `<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item`
60+
= note: all local variables must have a statically known size
61+
= help: unsized locals are gated as an unstable feature
6262

6363
error[E0614]: type `<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item` cannot be dereferenced
6464
--> $DIR/issue-20605.rs:5:27

tests/ui/traits/next-solver/tait-eq-proj-2.rs renamed to tests/ui/traits/next-solver/alias-relate/tait-eq-proj-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#![feature(type_alias_impl_trait)]
55

6-
// Similar to tests/ui/traits/next-solver/tait-eq-proj.rs
6+
// Similar to tests/ui/traits/next-solver/alias-relate/tait-eq-proj.rs
77
// but check the alias-sub relation in the other direction.
88

99
type Tait = impl Iterator<Item = impl Sized>;

0 commit comments

Comments
 (0)