-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New ui tests for new soft feature gates
- Loading branch information
Showing
8 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/test/ui/feature-gates/soft-syntax-gates-with-errors.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,30 @@ | ||
// check-fail | ||
// This file is used to test the behavior of the early-pass syntax warnings. | ||
// If macro syntax is stabilized, replace with a different unstable syntax. | ||
|
||
macro a() {} | ||
//~^ ERROR: `macro` is experimental | ||
|
||
#[cfg(FALSE)] | ||
macro b() {} | ||
|
||
macro_rules! identity { | ||
($($x:tt)*) => ($($x)*); | ||
} | ||
|
||
identity! { | ||
macro c() {} | ||
//~^ ERROR: `macro` is experimental | ||
} | ||
|
||
#[cfg(FALSE)] | ||
identity! { | ||
macro d() {} // No error | ||
} | ||
|
||
identity! { | ||
#[cfg(FALSE)] | ||
macro e() {} | ||
} | ||
|
||
fn main() {} |
21 changes: 21 additions & 0 deletions
21
src/test/ui/feature-gates/soft-syntax-gates-with-errors.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,21 @@ | ||
error[E0658]: `macro` is experimental | ||
--> $DIR/soft-syntax-gates-with-errors.rs:5:1 | ||
| | ||
LL | macro a() {} | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: see issue #39412 <https://github.com/rust-lang/rust/issues/39412> for more information | ||
= help: add `#![feature(decl_macro)]` to the crate attributes to enable | ||
|
||
error[E0658]: `macro` is experimental | ||
--> $DIR/soft-syntax-gates-with-errors.rs:16:5 | ||
| | ||
LL | macro c() {} | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: see issue #39412 <https://github.com/rust-lang/rust/issues/39412> for more information | ||
= help: add `#![feature(decl_macro)]` to the crate attributes to enable | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
26 changes: 26 additions & 0 deletions
26
src/test/ui/feature-gates/soft-syntax-gates-without-errors.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,26 @@ | ||
// check-pass | ||
// This file is used to test the behavior of the early-pass syntax warnings. | ||
// If macro syntax is stabilized, replace with a different unstable syntax. | ||
|
||
#[cfg(FALSE)] | ||
macro b() {} | ||
//~^ WARN: `macro` is experimental | ||
//~| WARN: unstable syntax | ||
|
||
macro_rules! identity { | ||
($($x:tt)*) => ($($x)*); | ||
} | ||
|
||
#[cfg(FALSE)] | ||
identity! { | ||
macro d() {} // No error | ||
} | ||
|
||
identity! { | ||
#[cfg(FALSE)] | ||
macro e() {} | ||
//~^ WARN: `macro` is experimental | ||
//~| WARN: unstable syntax | ||
} | ||
|
||
fn main() {} |
24 changes: 24 additions & 0 deletions
24
src/test/ui/feature-gates/soft-syntax-gates-without-errors.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,24 @@ | ||
warning: `macro` is experimental | ||
--> $DIR/soft-syntax-gates-without-errors.rs:6:1 | ||
| | ||
LL | macro b() {} | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: see issue #39412 <https://github.com/rust-lang/rust/issues/39412> for more information | ||
= help: add `#![feature(decl_macro)]` to the crate attributes to enable | ||
= warning: unstable syntax can change at any point in the future, causing a hard error! | ||
= note: for more information, see issue #65860 <https://github.com/rust-lang/rust/issues/65860> | ||
|
||
warning: `macro` is experimental | ||
--> $DIR/soft-syntax-gates-without-errors.rs:21:5 | ||
| | ||
LL | macro e() {} | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: see issue #39412 <https://github.com/rust-lang/rust/issues/39412> for more information | ||
= help: add `#![feature(decl_macro)]` to the crate attributes to enable | ||
= warning: unstable syntax can change at any point in the future, causing a hard error! | ||
= note: for more information, see issue #65860 <https://github.com/rust-lang/rust/issues/65860> | ||
|
||
warning: 2 warnings emitted | ||
|
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,4 @@ | ||
fn main() { | ||
let _ = 0: i32; //~ ERROR: type ascription is experimental | ||
let _ = 0: i32; // (error only emitted once) | ||
} |
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]: type ascription is experimental | ||
--> $DIR/many-type-ascription.rs:2:13 | ||
| | ||
LL | let _ = 0: i32; | ||
| ^^^^^^ | ||
| | ||
= note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information | ||
= help: add `#![feature(type_ascription)]` 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fn main() { | ||
not rust; //~ ERROR | ||
let _ = 0: i32; // (error hidden by existing error) | ||
#[cfg(FALSE)] | ||
let _ = 0: i32; // (warning hidden by existing error) | ||
} |
8 changes: 8 additions & 0 deletions
8
src/test/ui/suggestions/type-ascription-and-other-error.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,8 @@ | ||
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `rust` | ||
--> $DIR/type-ascription-and-other-error.rs:2:9 | ||
| | ||
LL | not rust; | ||
| ^^^^ expected one of 8 possible tokens | ||
|
||
error: aborting due to previous error | ||
|