Erase regions even if normalization fails in writeback
This commit is contained in:
parent
5683791ebb
commit
c92342d58d
@ -136,7 +136,10 @@ fn tcx(&self) -> TyCtxt<'tcx> {
|
|||||||
|
|
||||||
fn write_ty_to_typeck_results(&mut self, hir_id: hir::HirId, ty: Ty<'tcx>) {
|
fn write_ty_to_typeck_results(&mut self, hir_id: hir::HirId, ty: Ty<'tcx>) {
|
||||||
debug!("write_ty_to_typeck_results({:?}, {:?})", hir_id, ty);
|
debug!("write_ty_to_typeck_results({:?}, {:?})", hir_id, ty);
|
||||||
assert!(!ty.has_infer() && !ty.has_placeholders() && !ty.has_free_regions());
|
assert!(
|
||||||
|
!ty.has_infer() && !ty.has_placeholders() && !ty.has_free_regions(),
|
||||||
|
"{ty} can't be put into typeck results"
|
||||||
|
);
|
||||||
self.typeck_results.node_types_mut().insert(hir_id, ty);
|
self.typeck_results.node_types_mut().insert(hir_id, ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -803,7 +806,11 @@ fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
|||||||
// We must normalize erasing regions here, since later lints
|
// We must normalize erasing regions here, since later lints
|
||||||
// expect that types that show up in the typeck are fully
|
// expect that types that show up in the typeck are fully
|
||||||
// normalized.
|
// normalized.
|
||||||
self.fcx.tcx.try_normalize_erasing_regions(self.fcx.param_env, t).unwrap_or(t)
|
if let Ok(t) = self.fcx.tcx.try_normalize_erasing_regions(self.fcx.param_env, t) {
|
||||||
|
t
|
||||||
|
} else {
|
||||||
|
EraseEarlyRegions { tcx: self.fcx.tcx }.fold_ty(t)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(t) => {
|
Ok(t) => {
|
||||||
// Do not anonymize late-bound regions
|
// Do not anonymize late-bound regions
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error[E0277]: the size for values of type `dyn Iterator<Item = &'a mut u8>` cannot be known at compilation time
|
error[E0277]: the size for values of type `dyn Iterator<Item = &'a mut u8>` cannot be known at compilation time
|
||||||
--> $DIR/issue-20605.rs:2:17
|
--> $DIR/issue-20605.rs:5:17
|
||||||
|
|
|
|
||||||
LL | for item in *things { *item = 0 }
|
LL | for item in *things { *item = 0 }
|
||||||
| ^^^^^^^ the trait `IntoIterator` is not implemented for `dyn Iterator<Item = &'a mut u8>`
|
| ^^^^^^^ the trait `IntoIterator` is not implemented for `dyn Iterator<Item = &'a mut u8>`
|
25
tests/ui/issues/issue-20605.next.stderr
Normal file
25
tests/ui/issues/issue-20605.next.stderr
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
error[E0277]: the trait bound `dyn Iterator<Item = &'a mut u8>: IntoIterator` is not satisfied
|
||||||
|
--> $DIR/issue-20605.rs:5:17
|
||||||
|
|
|
||||||
|
LL | for item in *things { *item = 0 }
|
||||||
|
| ^^^^^^^ the trait `IntoIterator` is not implemented for `dyn Iterator<Item = &'a mut u8>`
|
||||||
|
|
||||||
|
error[E0277]: the size for values of type `<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter` cannot be known at compilation time
|
||||||
|
--> $DIR/issue-20605.rs:5:17
|
||||||
|
|
|
||||||
|
LL | for item in *things { *item = 0 }
|
||||||
|
| ^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
||||||
|
= help: the trait `Sized` is not implemented for `<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter`
|
||||||
|
= note: all local variables must have a statically known size
|
||||||
|
= help: unsized locals are gated as an unstable feature
|
||||||
|
|
||||||
|
error: the type `<_ as IntoIterator>::IntoIter` is not well-formed
|
||||||
|
--> $DIR/issue-20605.rs:5:17
|
||||||
|
|
|
||||||
|
LL | for item in *things { *item = 0 }
|
||||||
|
| ^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0277`.
|
@ -1,6 +1,11 @@
|
|||||||
|
// revisions: current next
|
||||||
|
//[next] compile-flags: -Ztrait-solver=next
|
||||||
|
|
||||||
fn changer<'a>(mut things: Box<dyn Iterator<Item=&'a mut u8>>) {
|
fn changer<'a>(mut things: Box<dyn Iterator<Item=&'a mut u8>>) {
|
||||||
for item in *things { *item = 0 }
|
for item in *things { *item = 0 }
|
||||||
//~^ ERROR the size for values of type
|
//~^ ERROR the size for values of type
|
||||||
|
//[next]~^^ ERROR the type `<_ as IntoIterator>::IntoIter` is not well-formed
|
||||||
|
//[next]~| ERROR the trait bound `dyn Iterator<Item = &'a mut u8>: IntoIterator` is not satisfied
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user