mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Treat opaque types failing the signature defining scope check as defining, as we already errored and can hide subsequent errors this way.
This commit is contained in:
parent
41881aece2
commit
a71628c114
@ -72,14 +72,15 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
|
|||||||
if !self.seen.insert(alias_ty.def_id.expect_local()) {
|
if !self.seen.insert(alias_ty.def_id.expect_local()) {
|
||||||
return ControlFlow::Continue(());
|
return ControlFlow::Continue(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.opaques.push(alias_ty.def_id.expect_local());
|
||||||
|
|
||||||
match self.tcx.uses_unique_generic_params(alias_ty.substs, CheckRegions::Bound) {
|
match self.tcx.uses_unique_generic_params(alias_ty.substs, CheckRegions::Bound) {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
// FIXME: implement higher kinded lifetime bounds on nested opaque types. They are not
|
// FIXME: implement higher kinded lifetime bounds on nested opaque types. They are not
|
||||||
// supported at all, so this is sound to do, but once we want to support them, you'll
|
// supported at all, so this is sound to do, but once we want to support them, you'll
|
||||||
// start seeing the error below.
|
// start seeing the error below.
|
||||||
|
|
||||||
self.opaques.push(alias_ty.def_id.expect_local());
|
|
||||||
|
|
||||||
// Collect opaque types nested within the associated type bounds of this opaque type.
|
// Collect opaque types nested within the associated type bounds of this opaque type.
|
||||||
for (pred, span) in self
|
for (pred, span) in self
|
||||||
.tcx
|
.tcx
|
||||||
|
@ -19,5 +19,4 @@ impl<'a> A<'a> for C {
|
|||||||
type B<'b> = impl Clone;
|
type B<'b> = impl Clone;
|
||||||
|
|
||||||
fn a(&'a self) -> Self::B<'a> {} //~ ERROR: non-defining opaque type use in defining scope
|
fn a(&'a self) -> Self::B<'a> {} //~ ERROR: non-defining opaque type use in defining scope
|
||||||
//~^ ERROR: mismatched types
|
|
||||||
}
|
}
|
||||||
|
@ -10,25 +10,5 @@ note: for this opaque type
|
|||||||
LL | type B<'b> = impl Clone;
|
LL | type B<'b> = impl Clone;
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error: aborting due to previous error
|
||||||
--> $DIR/issue-88595.rs:21:23
|
|
||||||
|
|
|
||||||
LL | type B<'b> = impl Clone;
|
|
||||||
| ---------- the expected opaque type
|
|
||||||
LL |
|
|
||||||
LL | fn a(&'a self) -> Self::B<'a> {}
|
|
||||||
| - ^^^^^^^^^^^ expected opaque type, found `()`
|
|
||||||
| |
|
|
||||||
| implicitly returns `()` as its body has no tail or `return` expression
|
|
||||||
|
|
|
||||||
= note: expected opaque type `<C as A<'a>>::B<'a>`
|
|
||||||
found unit type `()`
|
|
||||||
note: this item must have the opaque type in its signature in order to be able to register hidden types
|
|
||||||
--> $DIR/issue-88595.rs:21:8
|
|
||||||
|
|
|
||||||
LL | fn a(&'a self) -> Self::B<'a> {}
|
|
||||||
| ^
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0308`.
|
|
||||||
|
@ -17,7 +17,6 @@ impl Foo for () {
|
|||||||
fn foo() -> (Self::Bar<u32>, Self::Baz) {
|
fn foo() -> (Self::Bar<u32>, Self::Baz) {
|
||||||
//~^ ERROR non-defining opaque type use
|
//~^ ERROR non-defining opaque type use
|
||||||
((), ())
|
((), ())
|
||||||
//~^ ERROR mismatched types
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,23 +10,5 @@ note: for this opaque type
|
|||||||
LL | type Bar<T> = impl Sized;
|
LL | type Bar<T> = impl Sized;
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error: aborting due to previous error
|
||||||
--> $DIR/multi-error.rs:19:10
|
|
||||||
|
|
|
||||||
LL | type Bar<T> = impl Sized;
|
|
||||||
| ---------- the expected opaque type
|
|
||||||
...
|
|
||||||
LL | ((), ())
|
|
||||||
| ^^ expected opaque type, found `()`
|
|
||||||
|
|
|
||||||
= note: expected opaque type `<() as Foo>::Bar<u32>`
|
|
||||||
found unit type `()`
|
|
||||||
note: this item must have the opaque type in its signature in order to be able to register hidden types
|
|
||||||
--> $DIR/multi-error.rs:17:8
|
|
||||||
|
|
|
||||||
LL | fn foo() -> (Self::Bar<u32>, Self::Baz) {
|
|
||||||
| ^^^
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0308`.
|
|
||||||
|
@ -15,7 +15,6 @@ impl Foo for () {
|
|||||||
type Bar<T> = impl Sized;
|
type Bar<T> = impl Sized;
|
||||||
fn foo() -> Self::Bar<u32> {}
|
fn foo() -> Self::Bar<u32> {}
|
||||||
//~^ ERROR non-defining opaque type use
|
//~^ ERROR non-defining opaque type use
|
||||||
//~| ERROR mismatched types
|
|
||||||
fn bar<T>() -> Self::Bar<T> {}
|
fn bar<T>() -> Self::Bar<T> {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,24 +10,5 @@ note: for this opaque type
|
|||||||
LL | type Bar<T> = impl Sized;
|
LL | type Bar<T> = impl Sized;
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error: aborting due to previous error
|
||||||
--> $DIR/non-defining-method.rs:16:17
|
|
||||||
|
|
|
||||||
LL | type Bar<T> = impl Sized;
|
|
||||||
| ---------- the expected opaque type
|
|
||||||
LL | fn foo() -> Self::Bar<u32> {}
|
|
||||||
| --- ^^^^^^^^^^^^^^ expected opaque type, found `()`
|
|
||||||
| |
|
|
||||||
| implicitly returns `()` as its body has no tail or `return` expression
|
|
||||||
|
|
|
||||||
= note: expected opaque type `<() as Foo>::Bar<u32>`
|
|
||||||
found unit type `()`
|
|
||||||
note: this item must have the opaque type in its signature in order to be able to register hidden types
|
|
||||||
--> $DIR/non-defining-method.rs:16:8
|
|
||||||
|
|
|
||||||
LL | fn foo() -> Self::Bar<u32> {}
|
|
||||||
| ^^^
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0308`.
|
|
||||||
|
Loading…
Reference in New Issue
Block a user