Skip to content

Commit

Permalink
New ui tests for new soft feature gates
Browse files Browse the repository at this point in the history
  • Loading branch information
CAD97 committed Aug 17, 2022
1 parent 767239f commit 944c6b6
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/test/ui/feature-gates/soft-syntax-gates-with-errors.rs
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 src/test/ui/feature-gates/soft-syntax-gates-with-errors.stderr
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 src/test/ui/feature-gates/soft-syntax-gates-without-errors.rs
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 src/test/ui/feature-gates/soft-syntax-gates-without-errors.stderr
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

4 changes: 4 additions & 0 deletions src/test/ui/suggestions/many-type-ascription.rs
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)
}
12 changes: 12 additions & 0 deletions src/test/ui/suggestions/many-type-ascription.stderr
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`.
6 changes: 6 additions & 0 deletions src/test/ui/suggestions/type-ascription-and-other-error.rs
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)
}
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

0 comments on commit 944c6b6

Please sign in to comment.