forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#121838 - oli-obk:impl_trait_in_assoc_tys_fi…
…x, r=compiler-errors Use the correct logic for nested impl trait in assoc types Previously we accidentally continued with the TAIT visitor, which allowed more than we wanted to. r? ``@compiler-errors``
- Loading branch information
Showing
3 changed files
with
61 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
tests/ui/type-alias-impl-trait/hidden_behind_struct_field3.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//! This test demonstrates a bug where we accidentally | ||
//! detected opaque types in struct fields, but only if nested | ||
//! in projections of another opaque type. | ||
|
||
#![feature(impl_trait_in_assoc_type)] | ||
|
||
struct Bar; | ||
|
||
trait Trait: Sized { | ||
type Assoc2; | ||
type Assoc; | ||
fn foo() -> Self::Assoc; | ||
} | ||
|
||
impl Trait for Bar { | ||
type Assoc2 = impl std::fmt::Debug; | ||
type Assoc = impl Iterator<Item = Foo>; | ||
fn foo() -> Self::Assoc { | ||
vec![Foo { field: () }].into_iter() | ||
//~^ ERROR item constrains opaque type that is not in its signature | ||
} | ||
} | ||
|
||
struct Foo { | ||
field: <Bar as Trait>::Assoc2, | ||
} | ||
|
||
fn main() {} |
15 changes: 15 additions & 0 deletions
15
tests/ui/type-alias-impl-trait/hidden_behind_struct_field3.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error: item constrains opaque type that is not in its signature | ||
--> $DIR/hidden_behind_struct_field3.rs:19:27 | ||
| | ||
LL | vec![Foo { field: () }].into_iter() | ||
| ^^ | ||
| | ||
= note: this item must mention the opaque type in its signature in order to be able to register hidden types | ||
note: this item must mention the opaque type in its signature in order to be able to register hidden types | ||
--> $DIR/hidden_behind_struct_field3.rs:18:8 | ||
| | ||
LL | fn foo() -> Self::Assoc { | ||
| ^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|