Fix one layer of closures not being able to constrain opaque types
This commit is contained in:
parent
ef52dc7bb8
commit
b549ba1bd4
3 changed files with 5 additions and 16 deletions
|
@ -322,7 +322,10 @@ fn opaque_types_defined_by<'tcx>(tcx: TyCtxt<'tcx>, item: LocalDefId) -> &'tcx [
|
||||||
| DefKind::GlobalAsm
|
| DefKind::GlobalAsm
|
||||||
| DefKind::Impl { .. } => {}
|
| DefKind::Impl { .. } => {}
|
||||||
DefKind::Closure | DefKind::Generator => {
|
DefKind::Closure | DefKind::Generator => {
|
||||||
return tcx.opaque_types_defined_by(tcx.local_parent(item));
|
// All items in the signature of the parent are ok
|
||||||
|
collector.opaques.extend(tcx.opaque_types_defined_by(tcx.local_parent(item)));
|
||||||
|
// And items in the body of the closure itself
|
||||||
|
collector.collect_taits_declared_in_body();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tcx.arena.alloc_from_iter(collector.opaques)
|
tcx.arena.alloc_from_iter(collector.opaques)
|
||||||
|
|
|
@ -5,6 +5,5 @@ fn main() {
|
||||||
type Tait = impl Sized;
|
type Tait = impl Sized;
|
||||||
let y: Tait = ();
|
let y: Tait = ();
|
||||||
//~^ ERROR: item constrains opaque type that is not in its signature
|
//~^ ERROR: item constrains opaque type that is not in its signature
|
||||||
//~| ERROR: item constrains opaque type that is not in its signature
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,18 +11,5 @@ note: this item must have the opaque type in its signature in order to be able t
|
||||||
LL | fn main() {
|
LL | fn main() {
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
||||||
error: item constrains opaque type that is not in its signature
|
error: aborting due to previous error
|
||||||
--> $DIR/nested_in_closure.rs:6:23
|
|
||||||
|
|
|
||||||
LL | let y: Tait = ();
|
|
||||||
| ^^
|
|
||||||
|
|
|
||||||
= note: this item must have the opaque type in its signature in order to be able to register hidden types
|
|
||||||
note: this item must have the opaque type in its signature in order to be able to register hidden types
|
|
||||||
--> $DIR/nested_in_closure.rs:4:13
|
|
||||||
|
|
|
||||||
LL | let x = || {
|
|
||||||
| ^^
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue