Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/rustc_parse/src/parser/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,9 @@ impl<'a> Parser<'a> {
} else {
// Parsing a pattern of the form `(box) (ref) (mut) fieldname`.
let is_box = self.eat_keyword(exp!(Box));
if is_box {
self.psess.gated_spans.gate(sym::box_patterns, self.prev_token.span);
}
let boxed_span = self.token.span;
let mutability = self.parse_mutability();
let by_ref = self.parse_byref();
Expand Down
8 changes: 0 additions & 8 deletions tests/ui/auto-traits/pre-cfg.rs

This file was deleted.

7 changes: 6 additions & 1 deletion tests/ui/feature-gates/feature-gate-box_patterns.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
fn main() {
let box x = Box::new('c'); //~ ERROR box pattern syntax is experimental
println!("x: {}", x);
let _: char = x;

struct Packet { x: Box<i32> }

let Packet { box x } = Packet { x: Box::new(0) }; //~ ERROR box pattern syntax is experimental
let _: i32 = x;
}
12 changes: 11 additions & 1 deletion tests/ui/feature-gates/feature-gate-box_patterns.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ LL | let box x = Box::new('c');
= help: add `#![feature(box_patterns)]` 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: aborting due to 1 previous error
error[E0658]: box pattern syntax is experimental
--> $DIR/feature-gate-box_patterns.rs:7:18
|
LL | let Packet { box x } = Packet { x: Box::new(0) };
| ^^^^^
|
= note: see issue #29641 <https://github.com/rust-lang/rust/issues/29641> for more information
= help: add `#![feature(box_patterns)]` 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: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.
12 changes: 12 additions & 0 deletions tests/ui/feature-gates/soft-feature-gate-auto_traits.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// For historical reasons, auto traits don't have a proper pre-expansion feature gate.
// We're now at least issuing a *warning* for those that only exist before macro expansion.
// FIXME(#154045): Turn their post-expansion feature gate into a proper pre-expansion one.
// As part of this, move these test cases into `feature-gate-auto-traits.rs`.
//@ check-pass

#[cfg(false)]
auto trait Foo {}
//~^ WARN `auto` traits are unstable
//~| WARN unstable syntax can change at any point in the future

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: `auto` traits are unstable
--> $DIR/pre-cfg.rs:4:1
--> $DIR/soft-feature-gate-auto_traits.rs:8:1
|
LL | auto trait Foo {}
| ^^^^
Expand Down
17 changes: 17 additions & 0 deletions tests/ui/feature-gates/soft-feature-gate-box_patterns.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// For historical reasons, box patterns don't have a proper pre-expansion feature gate.
// We're now at least issuing a *warning* for those that only exist before macro expansion.
// FIXME(#154045): Turn their post-expansion feature gate into a proper pre-expansion one.
// As part of this, move these test cases into `feature-gate-box_patterns.rs`.
//@ check-pass

fn main() {
#[cfg(false)]
let box x;
//~^ WARN box pattern syntax is experimental
//~| WARN unstable syntax can change at any point in the future

#[cfg(false)]
let Packet { box x };
//~^ WARN box pattern syntax is experimental
//~| WARN unstable syntax can change at any point in the future
}
26 changes: 26 additions & 0 deletions tests/ui/feature-gates/soft-feature-gate-box_patterns.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
warning: box pattern syntax is experimental
--> $DIR/soft-feature-gate-box_patterns.rs:9:9
|
LL | let box x;
| ^^^^^
|
= note: see issue #29641 <https://github.com/rust-lang/rust/issues/29641> for more information
= help: add `#![feature(box_patterns)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= 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: box pattern syntax is experimental
--> $DIR/soft-feature-gate-box_patterns.rs:14:18
|
LL | let Packet { box x };
| ^^^
|
= note: see issue #29641 <https://github.com/rust-lang/rust/issues/29641> for more information
= help: add `#![feature(box_patterns)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= 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

17 changes: 17 additions & 0 deletions tests/ui/feature-gates/soft-feature-gate-decl_macro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// For historical reasons, decl macros 2.0 don't have a proper pre-expansion feature gate.
// We're now at least issuing a *warning* for those that only exist before macro expansion.
// FIXME(#154045): Turn their post-expansion feature gate into a proper pre-expansion one.
// As part of this, move these test cases into `feature-gate-decl_macro.rs`.
//@ check-pass

#[cfg(false)]
macro make() {}
//~^ WARN `macro` is experimental
//~| WARN unstable syntax can change at any point in the future

#[cfg(false)]
macro create { () => {} }
//~^ WARN `macro` is experimental
//~| WARN unstable syntax can change at any point in the future

fn main() {}
26 changes: 26 additions & 0 deletions tests/ui/feature-gates/soft-feature-gate-decl_macro.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
warning: `macro` is experimental
--> $DIR/soft-feature-gate-decl_macro.rs:8:1
|
LL | macro make() {}
| ^^^^^^^^^^^^^^^
|
= 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
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= 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-feature-gate-decl_macro.rs:13:1
|
LL | macro create { () => {} }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= 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

17 changes: 17 additions & 0 deletions tests/ui/feature-gates/soft-feature-gate-trait_alias.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// For historical reasons, trait aliases don't have a proper pre-expansion feature gate.
// We're now at least issuing a *warning* for those that only exist before macro expansion.
// FIXME(#154045): Turn their post-expansion feature gate into a proper pre-expansion one.
// As part of this, move these test cases into `feature-gate-trait-alias.rs`.
//@ check-pass

#[cfg(false)]
trait Trait =;
//~^ WARN trait aliases are experimental
//~| WARN unstable syntax can change at any point in the future

#[cfg(false)]
trait Trait<T> = Bound where T: Bound;
//~^ WARN trait aliases are experimental
//~| WARN unstable syntax can change at any point in the future

fn main() {}
26 changes: 26 additions & 0 deletions tests/ui/feature-gates/soft-feature-gate-trait_alias.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
warning: trait aliases are experimental
--> $DIR/soft-feature-gate-trait_alias.rs:8:1
|
LL | trait Trait =;
| ^^^^^^^^^^^^^^
|
= note: see issue #41517 <https://github.com/rust-lang/rust/issues/41517> for more information
= help: add `#![feature(trait_alias)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= 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: trait aliases are experimental
--> $DIR/soft-feature-gate-trait_alias.rs:13:1
|
LL | trait Trait<T> = Bound where T: Bound;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #41517 <https://github.com/rust-lang/rust/issues/41517> for more information
= help: add `#![feature(trait_alias)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= 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

13 changes: 13 additions & 0 deletions tests/ui/feature-gates/soft-feature-gate-try_blocks.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// For historical reasons, try blocks don't have a proper pre-expansion feature gate.
// We're now at least issuing a *warning* for those that only exist before macro expansion.
// FIXME(#154045): Turn their post-expansion feature gate into a proper pre-expansion one.
// As part of this, move these test cases into `feature-gate-try_blocks.rs`.
//@ edition: 2018
//@ check-pass

fn main() {
#[cfg(false)]
try {}
//~^ WARN `try` blocks are unstable
//~| WARN unstable syntax can change at any point
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: `try` blocks are unstable
--> $DIR/try-block-homogeneous-pre-expansion.rs:9:5
--> $DIR/soft-feature-gate-try_blocks.rs:10:5
|
LL | try {}
| ^^^^^^
Expand Down
12 changes: 0 additions & 12 deletions tests/ui/try-block/try-block-homogeneous-pre-expansion.rs

This file was deleted.

Loading