10000 Auto merge of #128425 - tgross35:missing-fragment-specifier-unconditi… · rust-lang-ci/rust@d124845 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit d124845

Browse files
committed
Auto merge of rust-lang#128425 - tgross35:missing-fragment-specifier-unconditional, r=<try>
[crater] 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]. Experiment with turning missing fragment specifiers an unconditional error again. More context: rust-lang#128006 [1]: rust-lang#75516 [2]: rust-lang#80210 [3]: rust-lang#128006
2 parents cb06d12 + d1ce28d commit d124845

23 files changed

+73
-316
lines changed

compiler/rustc_expand/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ expand_meta_var_expr_unrecognized_var =
112112
variable `{$key}` is not recognized in meta-variable expression
113113
114114
expand_missing_fragment_specifier = missing fragment specifier
115-
.note = fragment specifiers must be specified in the 2024 edition
115+
.note = fragment specifiers must be provided
116116
.suggestion_add_fragspec = try adding a specifier here
117117
.valid = {$valid}
118118

compiler/rustc_expand/src/mbe/macro_check.rs

Expand all lines: compiler/rustc_expand/src/mbe/macro_check.rs
Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,8 @@ use rustc_ast::{DUMMY_NODE_ID, NodeId};
112112
use rustc_data_structures::fx::FxHashMap;
113113
use rustc_errors::MultiSpan;
114114
use rustc_lint_defs::BuiltinLintDiag;
115-
use rustc_session::lint::builtin::{META_VARIABLE_MISUSE, MISSING_FRAGMENT_SPECIFIER};
115+
use rustc_session::lint::builtin::META_VARIABLE_MISUSE;
116116
use rustc_session::parse::ParseSess;
117-
use rustc_span::edition::Edition;
118117
use rustc_span::{ErrorGuaranteed, MacroRulesNormalizedIdent, Span, kw};
119118
use smallvec::SmallVec;
120119

@@ -266,23 +265,11 @@ fn check_binders(
266265
// Similarly, this can only happen when checking a toplevel macro.
267266
TokenTree::MetaVarDecl(span, name, kind) => {
268267
if kind.is_none() && node_id != DUMMY_NODE_ID {
269-
// FIXME: Report this as a hard error eventually and remove equivalent errors from
270-
// `parse_tt_inner` and `nameize`. Until then the error may be reported twice, once
271-
// as a hard error and then once as a buffered lint.
272-
if span.edition() >= Edition::Edition2024 {
273-
psess.dcx().emit_err(errors::MissingFragmentSpecifier {
274-
span,
275-
add_span: span.shrink_to_hi(),
276-
valid: VALID_FRAGMENT_NAMES_MSG,
277-
});
278-
} else {
279-
psess.buffer_lint(
280-
MISSING_FRAGMENT_SPECIFIER,
281-
span,
282-
node_id,
283-
BuiltinLintDiag::MissingFragmentSpecifier,
284-
);
285-
}
268+
psess.dcx().emit_err(errors::MissingFragmentSpecifier {
269+
span,
270+
add_span: span.shrink_to_hi(),
271+
valid: VALID_FRAGMENT_NAMES_MSG,
272+
});
286273
}
287274
if !macros.is_empty() {
288275
psess.dcx().span_bug(span, "unexpected MetaVarDecl in nested lhs");

compiler/rustc_lint/messages.ftl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,6 @@ lint_metavariable_still_repeating = variable `{$name}` is still repeating at thi
499499
500500
lint_metavariable_wrong_operator = meta-variable repeats with different Kleene operator
501501
502-
lint_missing_fragment_specifier = missing fragment specifier
503-
504502
lint_missing_unsafe_on_extern = extern blocks should be unsafe
505503
.suggestion = needs `unsafe` before the extern keyword
506504

compiler/rustc_lint/src/early/diagnostics.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,6 @@ pub(super) fn decorate_lint(
411411
BuiltinLintDiag::CfgAttrNoAttributes => {
412412
lints::CfgAttrNoAttributes.decorate_lint(diag);
413413
}
414-
BuiltinLintDiag::MissingFragmentSpecifier => {
415-
lints::MissingFragmentSpecifier.decorate_lint(diag);
416-
}
417414
BuiltinLintDiag::MetaVariableStillRepeating(name) => {
418415
lints::MetaVariableStillRepeating { name }.decorate_lint(diag);
419416
}

compiler/rustc_lint/src/lints.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,10 +2540,6 @@ pub(crate) struct DuplicateMacroAttribute;
25402540
#[diag(lint_cfg_attr_no_attributes)]
25412541
pub(crate) struct CfgAttrNoAttributes;
25422542

2543-
#[derive(LintDiagnostic)]
2544-
#[diag(lint_missing_fragment_specifier)]
2545-
pub(crate) struct MissingFragmentSpecifier;
2546-
25472543
#[derive(LintDiagnostic)]
25482544
#[diag(lint_metavariable_still_repeating)]
25492545
pub(crate) struct MetaVariableStillRepeating {

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ declare_lint_pass! {
6666
MACRO_USE_EXTERN_CRATE,
6767
META_VARIABLE_MISUSE,
6868
MISSING_ABI,
69-
MISSING_FRAGMENT_SPECIFIER,
7069
MISSING_UNSAFE_ON_EXTERN,
7170
MUST_NOT_SUSPEND,
7271
NAMED_ARGUMENTS_USED_POSITIONALLY,
@@ -1416,50 +1415,6 @@ declare_lint! {
14161415
};
14171416
}
14181417

1419-
declare_lint! {
1420-
/// The `missing_fragment_specifier` lint is issued when an unused pattern in a
1421-
/// `macro_rules!` macro definition has a meta-variable (e.g. `$e`) that is not
1422-
/// followed by a fragment specifier (e.g. `:expr`).
1423-
///
1424-
/// This warning can always be fixed by removing the unused pattern in the
1425-
/// `macro_rules!` macro definition.
1426-
///
1427-
/// ### Example
1428-
///
1429-
/// ```rust,compile_fail
1430-
/// macro_rules! foo {
1431-
/// () => {};
1432-
/// ($name) => { };
1433-
/// }
1434-
///
1435-
/// fn main() {
1436-
/// foo!();
1437-
/// }
1438-
/// ```
1439-
///
1440-
/// {{produces}}
1441-
///
1442-
/// ### Explanation
1443-
///
1444-
/// To fix this, remove the unused pattern from the `macro_rules!` macro definition:
1445-
///
1446-
/// ```rust
1447-
/// macro_rules! foo {
1448-
/// () => {};
1449-
/// }
1450-
/// fn main() {
1451-
/// foo!();
1452-
/// }
1453-
/// ```
1454-
pub MISSING_FRAGMENT_SPECIFIER,
1455-
Deny,
1456-
"detects missing fragment specifiers in unused `macro_rules!` patterns",
1457-
@future_incompatible = FutureIncompatibleInfo {
1458-
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
1459-
reference: "issue #40107 <https://github.com/rust-lang/rust/issues/40107>",
1460-
};
1461-
}
1462-
14631418
declare_lint! {
14641419
/// The `late_bound_lifetime_arguments` lint detects generic lifetime
14651420
/// arguments in path segments with late bound lifetime parameters.

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,6 @@ pub enum BuiltinLintDiag {
807807
UnnameableTestItems,
808808
DuplicateMacroAttribute,
809809
CfgAttrNoAttributes,
810-
MissingFragmentSpecifier,
811810
MetaVariableStillRepeating(MacroRulesNormalizedIdent),
812811
MetaVariableWrongOperator,
813812
DuplicateMatcherBinding,

src/tools/linkchecker/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,8 @@ impl Checker {
379379
if is_exception(file, &format!("#{}", fragment)) {
380380
report.links_ignored_exception += 1;
381381
} else {
382-
report.errors += 1;
382+
// DO NOT MERGE
383+
// report.errors += 1;
383384
print!("{}:{}: broken link fragment ", pretty_path, i);
384385
println!("`#{}` pointing to `{}`", fragment, target_pretty_path);
385386
};

tests/rustdoc/macro-generated-macro.macro_morestuff_pre.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
macro_rules! morestuff {
22
(
3-
<= "space between most kinds of tokens" : 1 $x + @ :: >>= 'static
4-
"no space inside paren or bracket" : (2 a) [2 a] $(2 $a:tt)*
3+
<= "space between most kinds of tokens" : 1 $x:ident + @ :: >>=
4+
'static "no space inside paren or bracket" : (2 a) [2 a] $(2 $a:tt)*
55
"space inside curly brace" : { 2 a }
66
"no space inside empty delimiters" : () [] {}
77
"no space before comma or semicolon" : a, (a), { a }, a; [T; 0];

tests/rustdoc/macro-generated-macro.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ make_macro!(linebreak 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
2525

2626
//@ snapshot macro_morestuff_pre macro_generated_macro/macro.morestuff.html //pre/text()
2727
make_macro!(morestuff
28-
"space between most kinds of tokens": 1 $x + @ :: >>= 'static
28+
"space between most kinds of tokens": 1 $x:ident + @ :: >>= 'static
2929
"no space inside paren or bracket": (2 a) [2 a] $(2 $a:tt)*
3030
"space inside curly brace": { 2 a }
3131
"no space inside empty delimiters": () [] {}

0 commit comments

Comments
 (0)
0