-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add feature gate for inherent associate types.
- Loading branch information
1 parent
89d32eb
commit 4f4e15d
Showing
12 changed files
with
89 additions
and
45 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
This file was deleted.
Oops, something went wrong.
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
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
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
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
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 |
---|---|---|
@@ -1,9 +1,20 @@ | ||
// Test associated types are, until #8995 is implemented, forbidden in inherent impls. | ||
// Test that inherent associated types work with | ||
// inherent_associated_types feature gate. | ||
|
||
#![feature(inherent_associated_types)] | ||
#![allow(incomplete_features)] | ||
|
||
struct Foo; | ||
|
||
impl Foo { | ||
type Bar = isize; //~ERROR associated types are not yet supported in inherent impls (see #8995) | ||
type Bar = isize; | ||
} | ||
|
||
fn main() {} | ||
impl Foo { | ||
type Baz; //~ ERROR associated type in `impl` without body | ||
} | ||
|
||
fn main() { | ||
let x : Foo::Bar; //~ERROR ambiguous associated type | ||
x = 0isize; | ||
} |
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 |
---|---|---|
@@ -1,9 +1,17 @@ | ||
error[E0202]: associated types are not yet supported in inherent impls (see #8995) | ||
--> $DIR/assoc-inherent.rs:6:5 | ||
error: associated type in `impl` without body | ||
--> $DIR/assoc-inherent.rs:14:5 | ||
| | ||
LL | type Bar = isize; | ||
| ^^^^^^^^^^^^^^^^^ | ||
LL | type Baz; | ||
| ^^^^^^^^- | ||
| | | ||
| help: provide a definition for the type: `= <type>;` | ||
|
||
error: aborting due to previous error | ||
error[E0223]: ambiguous associated type | ||
--> $DIR/assoc-inherent.rs:18:13 | ||
| | ||
LL | let x : Foo::Bar; | ||
| ^^^^^^^^ help: use fully-qualified syntax: `<Foo as Trait>::Bar` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0202`. | ||
For more information about this error, try `rustc --explain E0223`. |
10 changes: 10 additions & 0 deletions
10
src/test/ui/feature-gates/feature-gate-inherent_associated_types.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,10 @@ | ||
// Test that inherent associated types cannot be used when inherent_associated_types | ||
// feature gate is not used. | ||
|
||
struct Foo; | ||
|
||
impl Foo { | ||
type Bar = isize; //~ERROR inherent associated types are unstable | ||
} | ||
|
||
fn main() {} |
12 changes: 12 additions & 0 deletions
12
src/test/ui/feature-gates/feature-gate-inherent_associated_types.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,12 @@ | ||
error[E0658]: inherent associated types are unstable | ||
--> $DIR/feature-gate-inherent_associated_types.rs:7:5 | ||
| | ||
LL | type Bar = isize; | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information | ||
= help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
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
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