Make missing_fragment_specifier an unconditional error

This was attempted in [1] then reverted in [2] because of fallout.
Recently, this was made an edition-dependent error in [3].

Make missing fragment specifiers an unconditional error again.

[1]: https://github.com/rust-lang/rust/pull/75516
[2]: https://github.com/rust-lang/rust/pull/80210
[3]: https://github.com/rust-lang/rust/pull/128006
This commit is contained in:
Trevor Gross 2024-07-30 23:04:23 -04:00
parent 208cb5da15
commit 841f7ce69a
23 changed files with 108 additions and 345 deletions

View file

@ -5,10 +5,6 @@ macro_rules! foo {
( $($i:ident)* ) => { $($i)+ }; //~ WARN meta-variable repeats with different Kleene operator
}
#[warn(missing_fragment_specifier)]
macro_rules! m { ($i) => {} } //~ WARN missing fragment specifier
//~| WARN this was previously accepted
#[deprecated = "reason"]
macro_rules! deprecated {
() => {}

View file

@ -12,20 +12,6 @@ note: the lint level is defined here
LL | #[warn(meta_variable_misuse)]
| ^^^^^^^^^^^^^^^^^^^^
warning: missing fragment specifier
--> $DIR/expansion-time.rs:9:19
|
LL | macro_rules! m { ($i) => {} }
| ^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
note: the lint level is defined here
--> $DIR/expansion-time.rs:8:8
|
LL | #[warn(missing_fragment_specifier)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: include macro expected single expression in source
--> $DIR/expansion-time-include.rs:4:1
|
@ -33,25 +19,10 @@ LL | 2
| ^
|
note: the lint level is defined here
--> $DIR/expansion-time.rs:22:8
--> $DIR/expansion-time.rs:18:8
|
LL | #[warn(incomplete_include)]
| ^^^^^^^^^^^^^^^^^^
warning: 3 warnings emitted
Future incompatibility report: Future breakage diagnostic:
warning: missing fragment specifier
--> $DIR/expansion-time.rs:9:19
|
LL | macro_rules! m { ($i) => {} }
| ^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
note: the lint level is defined here
--> $DIR/expansion-time.rs:8:8
|
LL | #[warn(missing_fragment_specifier)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: 2 warnings emitted

View file

@ -4,14 +4,23 @@
// lints for changes that are not tied to an edition
#![deny(future_incompatible)]
// Error since this is a `future_incompatible` lint
macro_rules! m {
($i) => {};
//~^ ERROR missing fragment specifier
enum E { V }
trait Tr1 {
type V;
fn foo() -> Self::V;
}
impl Tr1 for E {
type V = u8;
// Error since this is a `future_incompatible` lint
fn foo() -> Self::V { 0 }
//~^ ERROR ambiguous associated item
//~| WARN this was previously accepted
}
trait Tr {
trait Tr2 {
// Warn only since this is not a `future_incompatible` lint
fn f(u8) {}
//~^ WARN anonymous parameters are deprecated

View file

@ -1,20 +1,5 @@
error: missing fragment specifier
--> $DIR/future-incompatible-lint-group.rs:9:6
|
LL | ($i) => {};
| ^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
note: the lint level is defined here
--> $DIR/future-incompatible-lint-group.rs:5:9
|
LL | #![deny(future_incompatible)]
| ^^^^^^^^^^^^^^^^^^^
= note: `#[deny(missing_fragment_specifier)]` implied by `#[deny(future_incompatible)]`
warning: anonymous parameters are deprecated and will be removed in the next edition
--> $DIR/future-incompatible-lint-group.rs:16:10
--> $DIR/future-incompatible-lint-group.rs:25:10
|
LL | fn f(u8) {}
| ^^ help: try naming the parameter or explicitly ignoring it: `_: u8`
@ -23,21 +8,30 @@ LL | fn f(u8) {}
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
= note: `#[warn(anonymous_parameters)]` on by default
error: aborting due to 1 previous error; 1 warning emitted
Future incompatibility report: Future breakage diagnostic:
error: missing fragment specifier
--> $DIR/future-incompatible-lint-group.rs:9:6
error: ambiguous associated item
--> $DIR/future-incompatible-lint-group.rs:18:17
|
LL | ($i) => {};
| ^^
LL | fn foo() -> Self::V { 0 }
| ^^^^^^^ help: use fully-qualified syntax: `<E as Tr1>::V`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
= note: for more information, see issue #57644 <https://github.com/rust-lang/rust/issues/57644>
note: `V` could refer to the variant defined here
--> $DIR/future-incompatible-lint-group.rs:7:10
|
LL | enum E { V }
| ^
note: `V` could also refer to the associated type defined here
--> $DIR/future-incompatible-lint-group.rs:10:5
|
LL | type V;
| ^^^^^^
note: the lint level is defined here
--> $DIR/future-incompatible-lint-group.rs:5:9
|
LL | #![deny(future_incompatible)]
| ^^^^^^^^^^^^^^^^^^^
= note: `#[deny(missing_fragment_specifier)]` implied by `#[deny(future_incompatible)]`
= note: `#[deny(ambiguous_associated_items)]` implied by `#[deny(future_incompatible)]`
error: aborting due to 1 previous error; 1 warning emitted

View file

@ -1,7 +1,7 @@
#![allow(unused)]
macro_rules! m { ($i) => {} }
//~^ ERROR missing fragment specifier
//~| WARN previously accepted
macro_rules! m {
($i) => {}; //~ ERROR missing fragment specifier
}
fn main() {}

View file

@ -1,23 +1,15 @@
error: missing fragment specifier
--> $DIR/issue-39404.rs:3:19
--> $DIR/issue-39404.rs:4:6
|
LL | macro_rules! m { ($i) => {} }
| ^^
LL | ($i) => {};
| ^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
= note: `#[deny(missing_fragment_specifier)]` on by default
= note: fragment specifiers must be provided
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility
help: try adding a specifier here
|
LL | ($i:spec) => {};
| +++++
error: aborting due to 1 previous error
Future incompatibility report: Future breakage diagnostic:
error: missing fragment specifier
--> $DIR/issue-39404.rs:3:19
|
LL | macro_rules! m { ($i) => {} }
| ^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
= note: `#[deny(missing_fragment_specifier)]` on by default

View file

@ -3,8 +3,6 @@ macro_rules! test {
//~^ ERROR missing fragment
//~| ERROR missing fragment
//~| ERROR missing fragment
//~| WARN this was previously accepted
//~| WARN this was previously accepted
()
};
}

View file

@ -1,18 +1,15 @@
error: missing fragment specifier
--> $DIR/macro-match-nonterminal.rs:2:6
|
LL | ($a, $b) => {
| ^^
error: missing fragment specifier
--> $DIR/macro-match-nonterminal.rs:2:6
|
LL | ($a, $b) => {
| ^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
= note: `#[deny(missing_fragment_specifier)]` on by default
= note: fragment specifiers must be provided
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility
help: try adding a specifier here
|
LL | ($a:spec, $b) => {
| +++++
error: missing fragment specifier
--> $DIR/macro-match-nonterminal.rs:2:10
@ -20,30 +17,18 @@ error: missing fragment specifier
LL | ($a, $b) => {
| ^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
= note: fragment specifiers must be provided
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility
help: try adding a specifier here
|
LL | ($a, $b:spec) => {
| +++++
error: missing fragment specifier
--> $DIR/macro-match-nonterminal.rs:2:6
|
LL | ($a, $b) => {
| ^^
error: aborting due to 3 previous errors
Future incompatibility report: Future breakage diagnostic:
error: missing fragment specifier
--> $DIR/macro-match-nonterminal.rs:2:6
|
LL | ($a, $b) => {
| ^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
= note: `#[deny(missing_fragment_specifier)]` on by default
Future breakage diagnostic:
error: missing fragment specifier
--> $DIR/macro-match-nonterminal.rs:2:10
|
LL | ($a, $b) => {
| ^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
= note: `#[deny(missing_fragment_specifier)]` on by default

View file

@ -1,10 +1,8 @@
//@ compile-flags: -Zdeduplicate-diagnostics=yes
macro_rules! m {
($name) => {}
//~^ ERROR missing fragment
//~| ERROR missing fragment
//~| WARN this was previously accepted
($name) => {}; //~ ERROR missing fragment
//~| ERROR missing fragment
}
fn main() {

View file

@ -1,29 +1,21 @@
error: missing fragment specifier
--> $DIR/macro-missing-fragment-deduplication.rs:4:6
|
LL | ($name) => {}
LL | ($name) => {};
| ^^^^^
|
= note: fragment specifiers must be provided
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility
help: try adding a specifier here
|
LL | ($name:spec) => {};
| +++++
error: missing fragment specifier
--> $DIR/macro-missing-fragment-deduplication.rs:4:6
|
LL | ($name) => {}
LL | ($name) => {};
| ^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
= note: `#[deny(missing_fragment_specifier)]` on by default
error: aborting due to 2 previous errors
Future incompatibility report: Future breakage diagnostic:
error: missing fragment specifier
--> $DIR/macro-missing-fragment-deduplication.rs:4:6
|
LL | ($name) => {}
| ^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
= note: `#[deny(missing_fragment_specifier)]` on by default

View file

@ -1,85 +0,0 @@
error: missing fragment specifier
--> $DIR/macro-missing-fragment.rs:8:20
|
LL | ( $( any_token $field_rust_type )* ) => {};
| ^^^^^^^^^^^^^^^^
warning: missing fragment specifier
--> $DIR/macro-missing-fragment.rs:8:20
|
LL | ( $( any_token $field_rust_type )* ) => {};
| ^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
note: the lint level is defined here
--> $DIR/macro-missing-fragment.rs:5:9
|
LL | #![warn(missing_fragment_specifier)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: missing fragment specifier
--> $DIR/macro-missing-fragment.rs:18:7
|
LL | ( $name ) => {};
| ^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
warning: missing fragment specifier
--> $DIR/macro-missing-fragment.rs:25:7
|
LL | ( $name ) => {};
| ^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
error: aborting due to 1 previous error; 3 warnings emitted
Future incompatibility report: Future breakage diagnostic:
warning: missing fragment specifier
--> $DIR/macro-missing-fragment.rs:8:20
|
LL | ( $( any_token $field_rust_type )* ) => {};
| ^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
note: the lint level is defined here
--> $DIR/macro-missing-fragment.rs:5:9
|
LL | #![warn(missing_fragment_specifier)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
Future breakage diagnostic:
warning: missing fragment specifier
--> $DIR/macro-missing-fragment.rs:18:7
|
LL | ( $name ) => {};
| ^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
note: the lint level is defined here
--> $DIR/macro-missing-fragment.rs:5:9
|
LL | #![warn(missing_fragment_specifier)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
Future breakage diagnostic:
warning: missing fragment specifier
--> $DIR/macro-missing-fragment.rs:25:7
|
LL | ( $name ) => {};
| ^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
note: the lint level is defined here
--> $DIR/macro-missing-fragment.rs:5:9
|
LL | #![warn(missing_fragment_specifier)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,31 +1,17 @@
//@ revisions: e2015 e2024
//@[e2015] edition:2015
//@[e2024] edition:2024
#![warn(missing_fragment_specifier)]
//! Ensure that macros produce an error if fragment specifiers are missing.
macro_rules! used_arm {
( $( any_token $field_rust_type )* ) => {};
//[e2015]~^ ERROR missing fragment
//[e2015]~| WARN missing fragment
//[e2015]~| WARN this was previously accepted
//[e2024]~^^^^ ERROR missing fragment
//[e2024]~| ERROR missing fragment
( $( any_token $field_rust_type )* ) => {}; //~ ERROR missing fragment
//~| ERROR missing fragment
}
macro_rules! used_macro_unused_arm {
() => {};
( $name ) => {};
//[e2015]~^ WARN missing fragment
//[e2015]~| WARN this was previously accepted
//[e2024]~^^^ ERROR missing fragment
( $name ) => {}; //~ ERROR missing fragment
}
macro_rules! unused_macro {
( $name ) => {};
//[e2015]~^ WARN missing fragment
//[e2015]~| WARN this was previously accepted
//[e2024]~^^^ ERROR missing fragment
( $name ) => {}; //~ ERROR missing fragment
}
fn main() {

View file

@ -1,10 +1,10 @@
error: missing fragment specifier
--> $DIR/macro-missing-fragment.rs:8:20
--> $DIR/macro-missing-fragment.rs:4:20
|
LL | ( $( any_token $field_rust_type )* ) => {};
| ^^^^^^^^^^^^^^^^
|
= note: fragment specifiers must be specified in the 2024 edition
= note: fragment specifiers must be provided
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility
help: try adding a specifier here
|
@ -12,12 +12,12 @@ LL | ( $( any_token $field_rust_type:spec )* ) => {};
| +++++
error: missing fragment specifier
--> $DIR/macro-missing-fragment.rs:18:7
--> $DIR/macro-missing-fragment.rs:10:7
|
LL | ( $name ) => {};
| ^^^^^
|
= note: fragment specifiers must be specified in the 2024 edition
= note: fragment specifiers must be provided
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility
help: try adding a specifier here
|
@ -25,12 +25,12 @@ LL | ( $name:spec ) => {};
| +++++
error: missing fragment specifier
--> $DIR/macro-missing-fragment.rs:25:7
--> $DIR/macro-missing-fragment.rs:14:7
|
LL | ( $name ) => {};
| ^^^^^
|
= note: fragment specifiers must be specified in the 2024 edition
= note: fragment specifiers must be provided
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility
help: try adding a specifier here
|
@ -38,7 +38,7 @@ LL | ( $name:spec ) => {};
| +++++
error: missing fragment specifier
--> $DIR/macro-missing-fragment.rs:8:20
--> $DIR/macro-missing-fragment.rs:4:20
|
LL | ( $( any_token $field_rust_type )* ) => {};
| ^^^^^^^^^^^^^^^^

View file

@ -2,7 +2,6 @@ macro_rules! foo {
{ $+ } => { //~ ERROR expected identifier, found `+`
//~^ ERROR missing fragment specifier
//~| ERROR missing fragment specifier
//~| WARN this was previously accepted
$(x)(y) //~ ERROR expected one of: `*`, `+`, or `?`
}
}

View file

@ -5,7 +5,7 @@ LL | { $+ } => {
| ^
error: expected one of: `*`, `+`, or `?`
--> $DIR/issue-33569.rs:6:13
--> $DIR/issue-33569.rs:5:13
|
LL | $(x)(y)
| ^^^
@ -15,27 +15,19 @@ error: missing fragment specifier
|
LL | { $+ } => {
| ^
|
= note: fragment specifiers must be provided
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility
help: try adding a specifier here
|
LL | { $+:spec } => {
| +++++
error: missing fragment specifier
--> $DIR/issue-33569.rs:2:8
|
LL | { $+ } => {
| ^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
= note: `#[deny(missing_fragment_specifier)]` on by default
error: aborting due to 4 previous errors
Future incompatibility report: Future breakage diagnostic:
error: missing fragment specifier
--> $DIR/issue-33569.rs:2:8
|
LL | { $+ } => {
| ^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
= note: `#[deny(missing_fragment_specifier)]` on by default