Fix one layer of closures not being able to constrain opaque types
This commit is contained in:
parent
ef52dc7bb8
commit
b549ba1bd4
@ -322,7 +322,10 @@ fn opaque_types_defined_by<'tcx>(tcx: TyCtxt<'tcx>, item: LocalDefId) -> &'tcx [
|
||||
| DefKind::GlobalAsm
|
||||
| DefKind::Impl { .. } => {}
|
||||
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)
|
||||
|
@ -5,6 +5,5 @@ fn main() {
|
||||
type Tait = impl Sized;
|
||||
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
|
||||
};
|
||||
}
|
||||
|
@ -11,18 +11,5 @@ note: this item must have the opaque type in its signature in order to be able t
|
||||
LL | fn main() {
|
||||
| ^^^^
|
||||
|
||||
error: item constrains opaque type that is not in its signature
|
||||
--> $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
|
||||
error: aborting due to previous error
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user