Skip to content

Commit be4804b

Browse files
author
Jethro Beekman
committed
Revert "Add SEMICOLON_IN_EXPRESSIONS_FROM_MACROS lint"
This reverts commit f902551.
1 parent 4635369 commit be4804b

File tree

10 files changed

+1
-149
lines changed

10 files changed

+1
-149
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -3747,7 +3747,6 @@ dependencies = [
37473747
"rustc_errors",
37483748
"rustc_feature",
37493749
"rustc_lexer",
3750-
"rustc_lint_defs",
37513750
"rustc_macros",
37523751
"rustc_parse",
37533752
"rustc_serialize",

compiler/rustc_expand/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ rustc_attr = { path = "../rustc_attr" }
1818
rustc_data_structures = { path = "../rustc_data_structures" }
1919
rustc_errors = { path = "../rustc_errors" }
2020
rustc_feature = { path = "../rustc_feature" }
21-
rustc_lint_defs = { path = "../rustc_lint_defs" }
2221
rustc_macros = { path = "../rustc_macros" }
2322
rustc_lexer = { path = "../rustc_lexer" }
2423
rustc_parse = { path = "../rustc_parse" }

compiler/rustc_expand/src/mbe/macro_rules.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ use crate::mbe::transcribe::transcribe;
1111
use rustc_ast as ast;
1212
use rustc_ast::token::{self, NonterminalKind, NtTT, Token, TokenKind::*};
1313
use rustc_ast::tokenstream::{DelimSpan, TokenStream};
14-
use rustc_ast::NodeId;
1514
use rustc_ast_pretty::pprust;
1615
use rustc_attr::{self as attr, TransparencyError};
1716
use rustc_data_structures::fx::FxHashMap;
1817
use rustc_data_structures::sync::Lrc;
1918
use rustc_errors::{Applicability, DiagnosticBuilder};
2019
use rustc_feature::Features;
21-
use rustc_lint_defs::builtin::SEMICOLON_IN_EXPRESSIONS_FROM_MACROS;
2220
use rustc_parse::parser::Parser;
2321
use rustc_session::parse::ParseSess;
2422
use rustc_session::Session;
@@ -39,7 +37,6 @@ crate struct ParserAnyMacro<'a> {
3937
site_span: Span,
4038
/// The ident of the macro we're parsing
4139
macro_ident: Ident,
42-
lint_node_id: NodeId,
4340
arm_span: Span,
4441
}
4542

@@ -113,8 +110,7 @@ fn emit_frag_parse_err(
113110

114111
impl<'a> ParserAnyMacro<'a> {
115112
crate fn make(mut self: Box<ParserAnyMacro<'a>>, kind: AstFragmentKind) -> AstFragment {
116-
let ParserAnyMacro { site_span, macro_ident, ref mut parser, lint_node_id, arm_span } =
117-
*self;
113+
let ParserAnyMacro { site_span, macro_ident, ref mut parser, arm_span } = *self;
118114
let snapshot = &mut parser.clone();
119115
let fragment = match parse_ast_fragment(parser, kind) {
120116
Ok(f) => f,
@@ -128,12 +124,6 @@ impl<'a> ParserAnyMacro<'a> {
128124
// `macro_rules! m { () => { panic!(); } }` isn't parsed by `.parse_expr()`,
129125
// but `m!()` is allowed in expression positions (cf. issue #34706).
130126
if kind == AstFragmentKind::Expr && parser.token == token::Semi {
131-
parser.sess.buffer_lint(
132-
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
133-
parser.token.span,
134-
lint_node_id,
135-
"trailing semicolon in macro used in expression position",
136-
);
137127
parser.bump();
138128
}
139129

@@ -286,7 +276,6 @@ fn generic_extension<'cx>(
286276

287277
let mut p = Parser::new(sess, tts, false, None);
288278
p.last_type_ascription = cx.current_expansion.prior_type_ascription;
289-
let lint_node_id = cx.resolver.lint_node_id(cx.current_expansion.id);
290279

291280
// Let the context choose how to interpret the result.
292281
// Weird, but useful for X-macros.
@@ -298,7 +287,6 @@ fn generic_extension<'cx>(
298287
// macro leaves unparsed tokens.
299288
site_span: sp,
300289
macro_ident: name,
301-
lint_node_id,
302290
arm_span,
303291
});
304292
}

compiler/rustc_lint_defs/src/builtin.rs

-47
Original file line numberDiff line numberDiff line change
@@ -2834,52 +2834,6 @@ declare_lint! {
28342834
"detects `#[unstable]` on stable trait implementations for stable types"
28352835
}
28362836

2837-
declare_lint! {
2838-
/// The `semicolon_in_expressions_from_macros` lint detects trailing semicolons
2839-
/// in macro bodies when the macro is invoked in expression position.
2840-
/// This was previous accepted, but is being phased out.
2841-
///
2842-
/// ### Example
2843-
///
2844-
/// ```rust,compile_fail
2845-
/// #![deny(semicolon_in_expressions_from_macros)]
2846-
/// macro_rules! foo {
2847-
/// () => { true; }
2848-
/// }
2849-
///
2850-
/// fn main() {
2851-
/// let val = match true {
2852-
/// true => false,
2853-
/// _ => foo!()
2854-
/// };
2855-
/// }
2856-
/// ```
2857-
///
2858-
/// {{produces}}
2859-
///
2860-
/// ### Explanation
2861-
///
2862-
/// Previous, Rust ignored trailing semicolon in a macro
2863-
/// body when a macro was invoked in expression position.
2864-
/// However, this makes the treatment of semicolons in the language
2865-
/// inconsistent, and could lead to unexpected runtime behavior
2866-
/// in some circumstances (e.g. if the macro author expects
2867-
/// a value to be dropped).
2868-
///
2869-
/// This is a [future-incompatible] lint to transition this
2870-
/// to a hard error in the future. See [issue #79813] for more details.
2871-
///
2872-
/// [issue #79813]: https://github.com/rust-lang/rust/issues/79813
2873-
/// [future-incompatible]: ../index.md#future-incompatible-lints
2874-
pub SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
2875-
Allow,
2876-
"trailing semicolon in macro body used as expression",
2877-
@future_incompatible = FutureIncompatibleInfo {
2878-
reference: "issue #79813 <https://github.com/rust-lang/rust/issues/79813>",
2879-
edition: None,
2880-
};
2881-
}
2882-
28832837
declare_lint_pass! {
28842838
/// Does nothing as a lint pass, but registers some `Lint`s
28852839
/// that are used by other parts of the compiler.
@@ -2967,7 +2921,6 @@ declare_lint_pass! {
29672921
USELESS_DEPRECATED,
29682922
UNSUPPORTED_NAKED_FUNCTIONS,
29692923
MISSING_ABI,
2970-
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
29712924
DISJOINT_CAPTURE_DROP_REORDER,
29722925
]
29732926
}

compiler/rustc_resolve/src/macros.rs

-2
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,6 @@ impl<'a> ResolverExpand for Resolver<'a> {
344344
}
345345

346346
fn lint_node_id(&mut self, expn_id: ExpnId) -> NodeId {
347-
// FIXME - make this more precise. This currently returns the NodeId of the
348-
// nearest closing item - we should try to return the closest parent of the ExpnId
349347
self.invocation_parents
350348
.get(&expn_id)
351349
.map_or(ast::CRATE_NODE_ID, |id| self.def_id_to_node_id[*id])

src/bootstrap/bootstrap.py

-1
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,6 @@ def build_bootstrap(self):
834834
target_linker = self.get_toml("linker", build_section)
835835
if target_linker is not None:
836836
env["RUSTFLAGS"] += " -C linker=" + target_linker
837-
# cfg(bootstrap): Add `-Wsemicolon_in_expressions_from_macros` after the next beta bump
838837
env["RUSTFLAGS"] += " -Wrust_2018_idioms -Wunused_lifetimes"
839838
if self.get_toml("deny-warnings", "rust") != "false":
840839
env["RUSTFLAGS"] += " -Dwarnings"

src/bootstrap/builder.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1258,12 +1258,6 @@ impl<'a> Builder<'a> {
12581258
// some code doesn't go through this `rustc` wrapper.
12591259
lint_flags.push("-Wrust_2018_idioms");
12601260
lint_flags.push("-Wunused_lifetimes");
1261-
// cfg(bootstrap): unconditionally enable this warning after the next beta bump
1262-
// This is currently disabled for the stage1 libstd, since build scripts
1263-
// will end up using the bootstrap compiler (which doesn't yet support this lint)
1264-
if compiler.stage != 0 && mode != Mode::Std {
1265-
lint_flags.push("-Wsemicolon_in_expressions_from_macros");
1266-
}
12671261

12681262
if self.config.deny_warnings {
12691263
lint_flags.push("-Dwarnings");

src/test/ui/lint/semicolon-in-expressions-from-macros/allow-semicolon-in-expressions-from-macros.rs

-15
This file was deleted.

src/test/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.rs

-30
This file was deleted.

src/test/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.stderr

-33
This file was deleted.

0 commit comments

Comments
 (0)