-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Fix TAIT & ATPIT feature gating in the presence of anon consts #139063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
26 changes: 15 additions & 11 deletions
26
tests/ui/feature-gates/feature-gate-type_alias_impl_trait.rs
This file contains hidden or 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 |
|---|---|---|
| @@ -1,38 +1,42 @@ | ||
| //@ check-pass | ||
| #![feature(type_alias_impl_trait)] | ||
| use std::fmt::Debug; | ||
|
|
||
| type Foo = impl Debug; | ||
| type Foo = impl Debug; //~ ERROR `impl Trait` in type aliases is unstable | ||
|
|
||
| struct Bar(Foo); | ||
| #[define_opaque(Foo)] | ||
| #[define_opaque(Foo)] //~ ERROR use of unstable library feature `type_alias_impl_trait` | ||
| fn define() -> Bar { | ||
| Bar(42) | ||
| } | ||
|
|
||
| type Foo2 = impl Debug; | ||
| type Foo2 = impl Debug; //~ ERROR `impl Trait` in type aliases is unstable | ||
|
|
||
| #[define_opaque(Foo2)] | ||
| #[define_opaque(Foo2)] //~ ERROR use of unstable library feature `type_alias_impl_trait` | ||
| fn define2() { | ||
| let x = || -> Foo2 { 42 }; | ||
| } | ||
|
|
||
| type Foo3 = impl Debug; | ||
| type Foo3 = impl Debug; //~ ERROR `impl Trait` in type aliases is unstable | ||
|
|
||
| #[define_opaque(Foo3)] | ||
| #[define_opaque(Foo3)] //~ ERROR use of unstable library feature `type_alias_impl_trait` | ||
| fn define3(x: Foo3) { | ||
| let y: i32 = x; | ||
| } | ||
| #[define_opaque(Foo3)] | ||
| #[define_opaque(Foo3)] //~ ERROR use of unstable library feature `type_alias_impl_trait` | ||
| fn define3_1() { | ||
| define3(42) | ||
| } | ||
|
|
||
| type Foo4 = impl Debug; | ||
| type Foo4 = impl Debug; //~ ERROR `impl Trait` in type aliases is unstable | ||
|
|
||
| #[define_opaque(Foo4)] | ||
| #[define_opaque(Foo4)] //~ ERROR use of unstable library feature `type_alias_impl_trait` | ||
| fn define4(_: Foo4) { | ||
| let y: Foo4 = 42; | ||
| } | ||
|
|
||
| type Foo5 = [(); { | ||
| type Foo = impl Debug; //~ ERROR `impl Trait` in type aliases is unstable | ||
| //~^ ERROR unconstrained opaque type | ||
| 0 | ||
| }]; | ||
|
|
||
| fn main() {} | ||
111 changes: 111 additions & 0 deletions
111
tests/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr
This file contains hidden or 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,111 @@ | ||
| error[E0658]: use of unstable library feature `type_alias_impl_trait`: `type_alias_impl_trait` has open design concerns | ||
| --> $DIR/feature-gate-type_alias_impl_trait.rs:6:3 | ||
| | | ||
| LL | #[define_opaque(Foo)] | ||
| | ^^^^^^^^^^^^^ | ||
| | | ||
| = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information | ||
| = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable | ||
| = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
|
||
| error[E0658]: use of unstable library feature `type_alias_impl_trait`: `type_alias_impl_trait` has open design concerns | ||
| --> $DIR/feature-gate-type_alias_impl_trait.rs:13:3 | ||
| | | ||
| LL | #[define_opaque(Foo2)] | ||
| | ^^^^^^^^^^^^^ | ||
| | | ||
| = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information | ||
| = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable | ||
| = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
|
||
| error[E0658]: use of unstable library feature `type_alias_impl_trait`: `type_alias_impl_trait` has open design concerns | ||
| --> $DIR/feature-gate-type_alias_impl_trait.rs:20:3 | ||
| | | ||
| LL | #[define_opaque(Foo3)] | ||
| | ^^^^^^^^^^^^^ | ||
| | | ||
| = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information | ||
| = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable | ||
| = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
|
||
| error[E0658]: use of unstable library feature `type_alias_impl_trait`: `type_alias_impl_trait` has open design concerns | ||
| --> $DIR/feature-gate-type_alias_impl_trait.rs:24:3 | ||
| | | ||
| LL | #[define_opaque(Foo3)] | ||
| | ^^^^^^^^^^^^^ | ||
| | | ||
| = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information | ||
| = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable | ||
| = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
|
||
| error[E0658]: use of unstable library feature `type_alias_impl_trait`: `type_alias_impl_trait` has open design concerns | ||
| --> $DIR/feature-gate-type_alias_impl_trait.rs:31:3 | ||
| | | ||
| LL | #[define_opaque(Foo4)] | ||
| | ^^^^^^^^^^^^^ | ||
| | | ||
| = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information | ||
| = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable | ||
| = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
|
||
| error[E0658]: `impl Trait` in type aliases is unstable | ||
| --> $DIR/feature-gate-type_alias_impl_trait.rs:3:12 | ||
| | | ||
| LL | type Foo = impl Debug; | ||
| | ^^^^^^^^^^ | ||
| | | ||
| = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information | ||
| = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable | ||
| = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
|
||
| error[E0658]: `impl Trait` in type aliases is unstable | ||
| --> $DIR/feature-gate-type_alias_impl_trait.rs:11:13 | ||
| | | ||
| LL | type Foo2 = impl Debug; | ||
| | ^^^^^^^^^^ | ||
| | | ||
| = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information | ||
| = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable | ||
| = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
|
||
| error[E0658]: `impl Trait` in type aliases is unstable | ||
| --> $DIR/feature-gate-type_alias_impl_trait.rs:18:13 | ||
| | | ||
| LL | type Foo3 = impl Debug; | ||
| | ^^^^^^^^^^ | ||
| | | ||
| = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information | ||
| = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable | ||
| = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
|
||
| error[E0658]: `impl Trait` in type aliases is unstable | ||
| --> $DIR/feature-gate-type_alias_impl_trait.rs:29:13 | ||
| | | ||
| LL | type Foo4 = impl Debug; | ||
| | ^^^^^^^^^^ | ||
| | | ||
| = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information | ||
| = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable | ||
| = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
|
||
| error[E0658]: `impl Trait` in type aliases is unstable | ||
| --> $DIR/feature-gate-type_alias_impl_trait.rs:37:16 | ||
| | | ||
| LL | type Foo = impl Debug; | ||
| | ^^^^^^^^^^ | ||
| | | ||
| = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information | ||
| = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable | ||
| = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
|
||
| error: unconstrained opaque type | ||
| --> $DIR/feature-gate-type_alias_impl_trait.rs:37:16 | ||
| | | ||
| LL | type Foo = impl Debug; | ||
| | ^^^^^^^^^^ | ||
| | | ||
| = note: `Foo` must be used in combination with a concrete type within the same crate | ||
|
|
||
| error: aborting due to 11 previous errors | ||
|
|
||
| For more information about this error, try `rustc --explain E0658`. |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,25 @@ | ||
| // Ensure we don't misclassify `impl Trait` as TAIT/ATPIT if located inside an anon const in a | ||
| // type alias/assoc type. | ||
| // issue: <https://github.com/rust-lang/rust/issues/139055> | ||
| //@ check-pass | ||
| #![forbid(unstable_features)] | ||
|
|
||
| struct Girder<const N: usize>; | ||
|
|
||
| type Alias = Girder<{ | ||
| fn pass(input: impl Sized) -> impl Sized { input } | ||
| 0 | ||
| }>; | ||
|
|
||
| trait Trait { | ||
| type Assoc; | ||
| } | ||
|
|
||
| impl Trait for () { | ||
| type Assoc = [(); { | ||
| fn pass(input: impl Sized) -> impl Sized { input } | ||
| 0 | ||
| }]; | ||
| } | ||
|
|
||
| fn main() {} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops