From 6a66ad4829aedd6f085a410f8b35dbde8cc97694 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 16:35:46 +0200 Subject: [PATCH 01/12] missing_fragment_specifier -> error --- src/doc/rustc/src/lints/listing/deny-by-default.md | 10 ---------- src/librustc/lint/builtin.rs | 7 ------- src/librustc_interface/passes.rs | 13 ------------- src/librustc_lint/lib.rs | 7 ++----- src/libsyntax/ext/tt/macro_parser.rs | 11 ++--------- src/libsyntax/ext/tt/quoted.rs | 4 +++- src/libsyntax/parse/lexer/tests.rs | 3 +-- src/libsyntax/parse/mod.rs | 2 -- src/test/ui/issues/issue-39404.rs | 3 --- src/test/ui/issues/issue-39404.stderr | 6 +----- src/test/ui/macros/macro-match-nonterminal.rs | 5 ++++- src/test/ui/macros/macro-match-nonterminal.stderr | 14 +++++++++++++- src/test/ui/macros/macro-missing-fragment.rs | 4 +++- src/test/ui/macros/macro-missing-fragment.stderr | 8 +++++++- src/test/ui/parser/macro/issue-33569.rs | 1 + src/test/ui/parser/macro/issue-33569.stderr | 10 ++++++++-- 16 files changed, 45 insertions(+), 63 deletions(-) diff --git a/src/doc/rustc/src/lints/listing/deny-by-default.md b/src/doc/rustc/src/lints/listing/deny-by-default.md index 6574267f18511..794c773424ca1 100644 --- a/src/doc/rustc/src/lints/listing/deny-by-default.md +++ b/src/doc/rustc/src/lints/listing/deny-by-default.md @@ -91,16 +91,6 @@ The legacy_directory_ownership warning is issued when The warning can be fixed by renaming the parent module to "mod.rs" and moving it into its own directory if appropriate. - -## missing-fragment-specifier - -The missing_fragment_specifier warning is issued when an unused pattern in a -`macro_rules!` macro definition has a meta-variable (e.g. `$e`) that is not -followed by a fragment specifier (e.g. `:expr`). - -This warning can always be fixed by removing the unused pattern in the -`macro_rules!` macro definition. - ## mutable-transmutes This lint catches transmuting from `&T` to `&mut T` because it is undefined diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 6d9a6bb77dd55..faa4b58777d03 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -182,12 +182,6 @@ declare_lint! { "detects use of struct constructors that would be invisible with new visibility rules" } -declare_lint! { - pub MISSING_FRAGMENT_SPECIFIER, - Deny, - "detects missing fragment specifiers in unused `macro_rules!` patterns" -} - declare_lint! { pub PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, Deny, @@ -428,7 +422,6 @@ declare_lint_pass! { PATTERNS_IN_FNS_WITHOUT_BODY, LEGACY_DIRECTORY_OWNERSHIP, LEGACY_CONSTRUCTOR_VISIBILITY, - MISSING_FRAGMENT_SPECIFIER, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, LATE_BOUND_LIFETIME_ARGUMENTS, ORDER_DEPENDENT_TRAIT_OBJECTS, diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index b91c5e403841d..1d3dc8350bffd 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -432,19 +432,6 @@ fn configure_and_expand_inner<'a>( ecx.check_unused_macros(); }); - let mut missing_fragment_specifiers: Vec<_> = ecx.parse_sess - .missing_fragment_specifiers - .borrow() - .iter() - .cloned() - .collect(); - missing_fragment_specifiers.sort(); - - for span in missing_fragment_specifiers { - let lint = lint::builtin::MISSING_FRAGMENT_SPECIFIER; - let msg = "missing fragment specifier"; - sess.buffer_lint(lint, ast::CRATE_NODE_ID, span, msg); - } if cfg!(windows) { env::set_var("PATH", &old_path); } diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 78bc164ba1a0f..1d62b43c4b212 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -341,11 +341,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { reference: "issue #39207 ", edition: None, }, - FutureIncompatibleInfo { - id: LintId::of(MISSING_FRAGMENT_SPECIFIER), - reference: "issue #40107 ", - edition: None, - }, FutureIncompatibleInfo { id: LintId::of(ILLEGAL_FLOATING_POINT_LITERAL_PATTERN), reference: "issue #41620 ", @@ -488,6 +483,8 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { "converted into hard error, see https://github.com/rust-lang/rust/issues/57742"); store.register_removed("incoherent_fundamental_impls", "converted into hard error, see https://github.com/rust-lang/rust/issues/46205"); + store.register_removed("missing_fragment_specifier", + "converted into hard error, see https://github.com/rust-lang/rust/issues/40107"); } pub fn register_internals(store: &mut lint::LintStore, sess: Option<&Session>) { diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index dbf14daa30e75..c1ece22256a7f 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -382,9 +382,7 @@ fn nameize>( n_rec(sess, next_m, res.by_ref(), ret_val)?; }, TokenTree::MetaVarDecl(span, _, id) if id.name == kw::Invalid => { - if sess.missing_fragment_specifiers.borrow_mut().remove(&span) { - return Err((span, "missing fragment specifier".to_string())); - } + return Err((span, "missing fragment specifier".to_string())); } TokenTree::MetaVarDecl(sp, bind_name, _) => { match ret_val.entry(bind_name) { @@ -444,7 +442,6 @@ fn token_name_eq(t1: &Token, t2: &Token) -> bool { /// /// # Parameters /// -/// - `sess`: the parsing session into which errors are emitted. /// - `cur_items`: the set of current items to be processed. This should be empty by the end of a /// successful execution of this function. /// - `next_items`: the set of newly generated items. These are used to replenish `cur_items` in @@ -459,7 +456,6 @@ fn token_name_eq(t1: &Token, t2: &Token) -> bool { /// /// A `ParseResult`. Note that matches are kept track of through the items generated. fn inner_parse_loop<'root, 'tt>( - sess: &ParseSess, cur_items: &mut SmallVec<[MatcherPosHandle<'root, 'tt>; 1]>, next_items: &mut Vec>, eof_items: &mut SmallVec<[MatcherPosHandle<'root, 'tt>; 1]>, @@ -585,9 +581,7 @@ fn inner_parse_loop<'root, 'tt>( // We need to match a metavar (but the identifier is invalid)... this is an error TokenTree::MetaVarDecl(span, _, id) if id.name == kw::Invalid => { - if sess.missing_fragment_specifiers.borrow_mut().remove(&span) { - return Error(span, "missing fragment specifier".to_string()); - } + return Error(span, "missing fragment specifier".to_string()); } // We need to match a metavar with a valid ident... call out to the black-box @@ -689,7 +683,6 @@ pub fn parse( // parsing from the black-box parser done. The result is that `next_items` will contain a // bunch of possible next matcher positions in `next_items`. match inner_parse_loop( - sess, &mut cur_items, &mut next_items, &mut eof_items, diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index cad94a0e4c120..df0822cc22d67 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -241,7 +241,9 @@ pub fn parse( } tree => tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(start_sp), }; - sess.missing_fragment_specifiers.borrow_mut().insert(span); + + sess.span_diagnostic.span_err(span, "missing fragment specifier"); + result.push(TokenTree::MetaVarDecl(span, ident, ast::Ident::invalid())); } diff --git a/src/libsyntax/parse/lexer/tests.rs b/src/libsyntax/parse/lexer/tests.rs index fc47e4f0b185a..2aa101e09de01 100644 --- a/src/libsyntax/parse/lexer/tests.rs +++ b/src/libsyntax/parse/lexer/tests.rs @@ -10,7 +10,7 @@ use crate::with_default_globals; use std::io; use std::path::PathBuf; use syntax_pos::{BytePos, Span, NO_EXPANSION, edition::Edition}; -use rustc_data_structures::fx::{FxHashSet, FxHashMap}; +use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::{Lock, Once}; fn mk_sess(sm: Lrc) -> ParseSess { @@ -25,7 +25,6 @@ fn mk_sess(sm: Lrc) -> ParseSess { config: CrateConfig::default(), included_mod_stack: Lock::new(Vec::new()), source_map: sm, - missing_fragment_specifiers: Lock::new(FxHashSet::default()), raw_identifier_spans: Lock::new(Vec::new()), registered_diagnostics: Lock::new(ErrorMap::new()), buffered_lints: Lock::new(vec![]), diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 80aa7a35266eb..6cc309b6887ee 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -44,7 +44,6 @@ pub struct ParseSess { pub unstable_features: UnstableFeatures, pub config: CrateConfig, pub edition: Edition, - pub missing_fragment_specifiers: Lock>, /// Places where raw identifiers were used. This is used for feature-gating raw identifiers. pub raw_identifier_spans: Lock>, /// The registered diagnostics codes. @@ -80,7 +79,6 @@ impl ParseSess { span_diagnostic: handler, unstable_features: UnstableFeatures::from_environment(), config: FxHashSet::default(), - missing_fragment_specifiers: Lock::new(FxHashSet::default()), raw_identifier_spans: Lock::new(Vec::new()), registered_diagnostics: Lock::new(ErrorMap::new()), included_mod_stack: Lock::new(vec![]), diff --git a/src/test/ui/issues/issue-39404.rs b/src/test/ui/issues/issue-39404.rs index 2229f2c3900c3..095590daec573 100644 --- a/src/test/ui/issues/issue-39404.rs +++ b/src/test/ui/issues/issue-39404.rs @@ -1,7 +1,4 @@ -#![allow(unused)] - macro_rules! m { ($i) => {} } //~^ ERROR missing fragment specifier -//~| WARN previously accepted fn main() {} diff --git a/src/test/ui/issues/issue-39404.stderr b/src/test/ui/issues/issue-39404.stderr index d2f2a823c2a6b..e95474f3405d2 100644 --- a/src/test/ui/issues/issue-39404.stderr +++ b/src/test/ui/issues/issue-39404.stderr @@ -1,12 +1,8 @@ error: missing fragment specifier - --> $DIR/issue-39404.rs:3:19 + --> $DIR/issue-39404.rs:1:19 | LL | macro_rules! m { ($i) => {} } | ^^ - | - = note: `#[deny(missing_fragment_specifier)]` on by default - = 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 error: aborting due to previous error diff --git a/src/test/ui/macros/macro-match-nonterminal.rs b/src/test/ui/macros/macro-match-nonterminal.rs index 6d4b32c9bc9a0..36640a6c70057 100644 --- a/src/test/ui/macros/macro-match-nonterminal.rs +++ b/src/test/ui/macros/macro-match-nonterminal.rs @@ -1,4 +1,7 @@ -macro_rules! test { ($a, $b) => (()); } //~ ERROR missing fragment +macro_rules! test { ($a, $b) => (()); } +//~^ ERROR missing fragment +//~| ERROR missing fragment +//~| ERROR missing fragment fn main() { test!() diff --git a/src/test/ui/macros/macro-match-nonterminal.stderr b/src/test/ui/macros/macro-match-nonterminal.stderr index 1de8c5bd4b472..815471a79d6a3 100644 --- a/src/test/ui/macros/macro-match-nonterminal.stderr +++ b/src/test/ui/macros/macro-match-nonterminal.stderr @@ -4,5 +4,17 @@ error: missing fragment specifier LL | macro_rules! test { ($a, $b) => (()); } | ^ -error: aborting due to previous error +error: missing fragment specifier + --> $DIR/macro-match-nonterminal.rs:1:26 + | +LL | macro_rules! test { ($a, $b) => (()); } + | ^^ + +error: missing fragment specifier + --> $DIR/macro-match-nonterminal.rs:1:24 + | +LL | macro_rules! test { ($a, $b) => (()); } + | ^ + +error: aborting due to 3 previous errors diff --git a/src/test/ui/macros/macro-missing-fragment.rs b/src/test/ui/macros/macro-missing-fragment.rs index 1d0b0889b4cef..846dbe35cbc8c 100644 --- a/src/test/ui/macros/macro-missing-fragment.rs +++ b/src/test/ui/macros/macro-missing-fragment.rs @@ -1,5 +1,7 @@ macro_rules! m { - ( $( any_token $field_rust_type )* ) => {}; //~ ERROR missing fragment + ( $( any_token $field_rust_type )* ) => {}; + //~^ ERROR missing fragment + //~| ERROR missing fragment } fn main() { diff --git a/src/test/ui/macros/macro-missing-fragment.stderr b/src/test/ui/macros/macro-missing-fragment.stderr index b7871c0ec3a6f..b0459e21f1148 100644 --- a/src/test/ui/macros/macro-missing-fragment.stderr +++ b/src/test/ui/macros/macro-missing-fragment.stderr @@ -4,5 +4,11 @@ error: missing fragment specifier LL | ( $( any_token $field_rust_type )* ) => {}; | ^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error: missing fragment specifier + --> $DIR/macro-missing-fragment.rs:2:20 + | +LL | ( $( any_token $field_rust_type )* ) => {}; + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors diff --git a/src/test/ui/parser/macro/issue-33569.rs b/src/test/ui/parser/macro/issue-33569.rs index 9ed53519ceb31..d2581398f4403 100644 --- a/src/test/ui/parser/macro/issue-33569.rs +++ b/src/test/ui/parser/macro/issue-33569.rs @@ -1,6 +1,7 @@ macro_rules! foo { { $+ } => { //~ ERROR expected identifier, found `+` //~^ ERROR missing fragment specifier + //~| ERROR missing fragment specifier $(x)(y) //~ ERROR expected one of: `*`, `+`, or `?` } } diff --git a/src/test/ui/parser/macro/issue-33569.stderr b/src/test/ui/parser/macro/issue-33569.stderr index b4d38d3ce4806..e0e84fee4ea3f 100644 --- a/src/test/ui/parser/macro/issue-33569.stderr +++ b/src/test/ui/parser/macro/issue-33569.stderr @@ -4,8 +4,14 @@ error: expected identifier, found `+` LL | { $+ } => { | ^ +error: missing fragment specifier + --> $DIR/issue-33569.rs:2:8 + | +LL | { $+ } => { + | ^ + error: expected one of: `*`, `+`, or `?` - --> $DIR/issue-33569.rs:4:13 + --> $DIR/issue-33569.rs:5:13 | LL | $(x)(y) | ^^^ @@ -16,5 +22,5 @@ error: missing fragment specifier LL | { $+ } => { | ^ -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors From a35e900b872dfabda0f8cc6cb98221b3406d669b Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 16:59:05 +0200 Subject: [PATCH 02/12] legacy_ctor_visibility -> error --- .../src/lints/listing/deny-by-default.md | 35 ------------------- src/librustc/lint/builtin.rs | 7 ---- src/librustc_lint/lib.rs | 7 ++-- src/librustc_resolve/lib.rs | 19 +--------- src/test/ui/privacy/legacy-ctor-visibility.rs | 7 +--- .../ui/privacy/legacy-ctor-visibility.stderr | 11 +++--- 6 files changed, 8 insertions(+), 78 deletions(-) diff --git a/src/doc/rustc/src/lints/listing/deny-by-default.md b/src/doc/rustc/src/lints/listing/deny-by-default.md index 794c773424ca1..325517a08fb87 100644 --- a/src/doc/rustc/src/lints/listing/deny-by-default.md +++ b/src/doc/rustc/src/lints/listing/deny-by-default.md @@ -45,41 +45,6 @@ error: defaults for type parameters are only allowed in `struct`, `enum`, `type` = note: for more information, see issue #36887 ``` -## legacy-constructor-visibility - -[RFC 1506](https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md) modified some -visibility rules, and changed the visibility of struct constructors. Some -example code that triggers this lint: - -```rust,ignore -mod m { - pub struct S(u8); - - fn f() { - // this is trying to use S from the 'use' line, but because the `u8` is - // not pub, it is private - ::S; - } -} - -use m::S; -``` - -This will produce: - -```text -error: private struct constructors are not usable through re-exports in outer modules - --> src/main.rs:5:9 - | -5 | ::S; - | ^^^ - | - = note: `#[deny(legacy_constructor_visibility)]` on by default - = 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 #39207 -``` - - ## legacy-directory-ownership The legacy_directory_ownership warning is issued when diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index faa4b58777d03..cfae92a356157 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -176,12 +176,6 @@ declare_lint! { not named `mod.rs`" } -declare_lint! { - pub LEGACY_CONSTRUCTOR_VISIBILITY, - Deny, - "detects use of struct constructors that would be invisible with new visibility rules" -} - declare_lint! { pub PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, Deny, @@ -421,7 +415,6 @@ declare_lint_pass! { SAFE_PACKED_BORROWS, PATTERNS_IN_FNS_WITHOUT_BODY, LEGACY_DIRECTORY_OWNERSHIP, - LEGACY_CONSTRUCTOR_VISIBILITY, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, LATE_BOUND_LIFETIME_ARGUMENTS, ORDER_DEPENDENT_TRAIT_OBJECTS, diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 1d62b43c4b212..e95032e2fc097 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -336,11 +336,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { reference: "issue #37872 ", edition: None, }, - FutureIncompatibleInfo { - id: LintId::of(LEGACY_CONSTRUCTOR_VISIBILITY), - reference: "issue #39207 ", - edition: None, - }, FutureIncompatibleInfo { id: LintId::of(ILLEGAL_FLOATING_POINT_LITERAL_PATTERN), reference: "issue #41620 ", @@ -485,6 +480,8 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { "converted into hard error, see https://github.com/rust-lang/rust/issues/46205"); store.register_removed("missing_fragment_specifier", "converted into hard error, see https://github.com/rust-lang/rust/issues/40107"); + store.register_removed("legacy_constructor_visibility", + "converted into hard error, see https://github.com/rust-lang/rust/issues/39207"); } pub fn register_internals(store: &mut lint::LintStore, sess: Option<&Session>) { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index a49be7c27c94a..c44b554982c9a 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -3495,24 +3495,7 @@ impl<'a> Resolver<'a> { if is_expected(partial_res.base_res()) || partial_res.base_res() == Res::Err { partial_res } else { - // Add a temporary hack to smooth the transition to new struct ctor - // visibility rules. See #38932 for more details. - let mut res = None; - if let Res::Def(DefKind::Struct, def_id) = partial_res.base_res() { - if let Some((ctor_res, ctor_vis)) - = self.struct_constructors.get(&def_id).cloned() { - if is_expected(ctor_res) && self.is_accessible(ctor_vis) { - let lint = lint::builtin::LEGACY_CONSTRUCTOR_VISIBILITY; - self.session.buffer_lint(lint, id, span, - "private struct constructors are not usable through \ - re-exports in outer modules", - ); - res = Some(PartialRes::new(ctor_res)); - } - } - } - - res.unwrap_or_else(|| report_errors(self, Some(partial_res.base_res()))) + report_errors(self, Some(partial_res.base_res())) } } Some(partial_res) if source.defer_to_typeck() => { diff --git a/src/test/ui/privacy/legacy-ctor-visibility.rs b/src/test/ui/privacy/legacy-ctor-visibility.rs index 7db4be729e8fa..a2746993c1b93 100644 --- a/src/test/ui/privacy/legacy-ctor-visibility.rs +++ b/src/test/ui/privacy/legacy-ctor-visibility.rs @@ -1,7 +1,3 @@ -// ignore-tidy-linelength - -#![allow(unused)] - use m::S; mod m { @@ -11,8 +7,7 @@ mod m { use S; fn f() { S(10); - //~^ ERROR private struct constructors are not usable through re-exports in outer modules - //~| WARN this was previously accepted + //~^ ERROR expected function, found struct `S` } } } diff --git a/src/test/ui/privacy/legacy-ctor-visibility.stderr b/src/test/ui/privacy/legacy-ctor-visibility.stderr index 69b6e08befc67..5ac295797c609 100644 --- a/src/test/ui/privacy/legacy-ctor-visibility.stderr +++ b/src/test/ui/privacy/legacy-ctor-visibility.stderr @@ -1,12 +1,9 @@ -error: private struct constructors are not usable through re-exports in outer modules - --> $DIR/legacy-ctor-visibility.rs:13:13 +error[E0423]: expected function, found struct `S` + --> $DIR/legacy-ctor-visibility.rs:9:13 | LL | S(10); - | ^ - | - = note: `#[deny(legacy_constructor_visibility)]` on by default - = 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 #39207 + | ^ help: a function with a similar name exists: `f` error: aborting due to previous error +For more information about this error, try `rustc --explain E0423`. From 006f40b0bbe24c18f888a3de033081b0689bbc47 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 17:42:17 +0200 Subject: [PATCH 03/12] legacy_directory_ownership -> error --- .../src/lints/listing/deny-by-default.md | 11 --- src/librustc/lint/builtin.rs | 8 --- src/librustc_lint/lib.rs | 17 +---- src/librustc_passes/ast_validation.rs | 5 -- src/libsyntax/ext/expand.rs | 2 +- src/libsyntax/parse/mod.rs | 2 +- src/libsyntax/parse/parser.rs | 72 +++++++++---------- src/libsyntax_pos/symbol.rs | 1 - 8 files changed, 39 insertions(+), 79 deletions(-) diff --git a/src/doc/rustc/src/lints/listing/deny-by-default.md b/src/doc/rustc/src/lints/listing/deny-by-default.md index 325517a08fb87..add8e460cba23 100644 --- a/src/doc/rustc/src/lints/listing/deny-by-default.md +++ b/src/doc/rustc/src/lints/listing/deny-by-default.md @@ -45,17 +45,6 @@ error: defaults for type parameters are only allowed in `struct`, `enum`, `type` = note: for more information, see issue #36887 ``` -## legacy-directory-ownership - -The legacy_directory_ownership warning is issued when - -* There is a non-inline module with a `#[path]` attribute (e.g. `#[path = "foo.rs"] mod bar;`), -* The module's file ("foo.rs" in the above example) is not named "mod.rs", and -* The module's file contains a non-inline child module without a `#[path]` attribute. - -The warning can be fixed by renaming the parent module to "mod.rs" and moving -it into its own directory if appropriate. - ## mutable-transmutes This lint catches transmuting from `&T` to `&mut T` because it is undefined diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index cfae92a356157..f0c97880d8331 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -169,13 +169,6 @@ declare_lint! { "patterns in functions without body were erroneously allowed" } -declare_lint! { - pub LEGACY_DIRECTORY_OWNERSHIP, - Deny, - "non-inline, non-`#[path]` modules (e.g., `mod foo;`) were erroneously allowed in some files \ - not named `mod.rs`" -} - declare_lint! { pub PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, Deny, @@ -414,7 +407,6 @@ declare_lint_pass! { SAFE_EXTERN_STATICS, SAFE_PACKED_BORROWS, PATTERNS_IN_FNS_WITHOUT_BODY, - LEGACY_DIRECTORY_OWNERSHIP, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, LATE_BOUND_LIFETIME_ARGUMENTS, ORDER_DEPENDENT_TRAIT_OBJECTS, diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index e95032e2fc097..59fcf394f9f6d 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -331,21 +331,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { reference: "issue #36887 ", edition: None, }, - FutureIncompatibleInfo { - id: LintId::of(LEGACY_DIRECTORY_OWNERSHIP), - reference: "issue #37872 ", - edition: None, - }, - FutureIncompatibleInfo { - id: LintId::of(ILLEGAL_FLOATING_POINT_LITERAL_PATTERN), - reference: "issue #41620 ", - edition: None, - }, - FutureIncompatibleInfo { - id: LintId::of(ANONYMOUS_PARAMETERS), - reference: "issue #41686 ", - edition: Some(Edition::Edition2018), - }, FutureIncompatibleInfo { id: LintId::of(PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES), reference: "issue #42238 ", @@ -482,6 +467,8 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { "converted into hard error, see https://github.com/rust-lang/rust/issues/40107"); store.register_removed("legacy_constructor_visibility", "converted into hard error, see https://github.com/rust-lang/rust/issues/39207"); + store.register_removed("legacy_disrectory_ownership", + "converted into hard error, see https://github.com/rust-lang/rust/issues/37872"); } pub fn register_internals(store: &mut lint::LintStore, sess: Option<&Session>) { diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index 3c31bcef32b7a..8c147a368faba 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -651,11 +651,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> { ItemKind::Mod(_) => { // Ensure that `path` attributes on modules are recorded as used (cf. issue #35584). attr::first_attr_value_str_by_name(&item.attrs, sym::path); - if attr::contains_name(&item.attrs, sym::warn_directory_ownership) { - let lint = lint::builtin::LEGACY_DIRECTORY_OWNERSHIP; - let msg = "cannot declare a new module at this location"; - self.session.buffer_lint(lint, item.id, item.span, msg); - } } ItemKind::Union(ref vdata, _) => { if let VariantData::Tuple(..) | VariantData::Unit(..) = vdata { diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 1e9e16d72f829..2091c1e706e04 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1113,7 +1113,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { Some(_) => DirectoryOwnership::Owned { relative: Some(item.ident), }, - None => DirectoryOwnership::UnownedViaMod(false), + None => DirectoryOwnership::UnownedViaMod, }; path.pop(); module.directory = path; diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 6cc309b6887ee..643207961ae66 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -146,7 +146,7 @@ pub enum DirectoryOwnership { relative: Option, }, UnownedViaBlock, - UnownedViaMod(bool /* legacy warnings? */), + UnownedViaMod, } // a bunch of utility functions of the form parse__from_ diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 880dd6e164982..edab39fe0b8bb 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -435,7 +435,6 @@ pub struct ModulePath { pub struct ModulePathSuccess { pub path: PathBuf, pub directory_ownership: DirectoryOwnership, - warn: bool, } #[derive(Debug)] @@ -6389,17 +6388,10 @@ impl<'a> Parser<'a> { if self.eat(&token::Semi) { if in_cfg && self.recurse_into_file_modules { // This mod is in an external file. Let's go get it! - let ModulePathSuccess { path, directory_ownership, warn } = + let ModulePathSuccess { path, directory_ownership } = self.submod_path(id, &outer_attrs, id_span)?; - let (module, mut attrs) = + let (module, attrs) = self.eval_src_mod(path, directory_ownership, id.to_string(), id_span)?; - // Record that we fetched the mod from an external file - if warn { - let attr = attr::mk_attr_outer( - attr::mk_word_item(Ident::with_empty_ctxt(sym::warn_directory_ownership))); - attr::mark_known(&attr); - attrs.push(attr); - } Ok((id, ItemKind::Mod(module), Some(attrs))) } else { let placeholder = ast::Mod { @@ -6493,14 +6485,12 @@ impl<'a> Parser<'a> { directory_ownership: DirectoryOwnership::Owned { relative: Some(id), }, - warn: false, }), (false, true) => Ok(ModulePathSuccess { path: secondary_path, directory_ownership: DirectoryOwnership::Owned { relative: None, }, - warn: false, }), (false, false) => Err(Error::FileNotFoundForModule { mod_name: mod_name.clone(), @@ -6522,11 +6512,12 @@ impl<'a> Parser<'a> { } } - fn submod_path(&mut self, - id: ast::Ident, - outer_attrs: &[Attribute], - id_sp: Span) - -> PResult<'a, ModulePathSuccess> { + fn submod_path( + &mut self, + id: ast::Ident, + outer_attrs: &[Attribute], + id_sp: Span + ) -> PResult<'a, ModulePathSuccess> { if let Some(path) = Parser::submod_path_from_attr(outer_attrs, &self.directory.path) { return Ok(ModulePathSuccess { directory_ownership: match path.file_name().and_then(|s| s.to_str()) { @@ -6538,20 +6529,23 @@ impl<'a> Parser<'a> { // `#[path]` included and contains a `mod foo;` declaration. // If you encounter this, it's your own darn fault :P Some(_) => DirectoryOwnership::Owned { relative: None }, - _ => DirectoryOwnership::UnownedViaMod(true), + _ => DirectoryOwnership::UnownedViaMod, }, path, - warn: false, }); } let relative = match self.directory.ownership { DirectoryOwnership::Owned { relative } => relative, DirectoryOwnership::UnownedViaBlock | - DirectoryOwnership::UnownedViaMod(_) => None, + DirectoryOwnership::UnownedViaMod => None, }; let paths = Parser::default_submod_path( - id, relative, &self.directory.path, self.sess.source_map()); + id, + relative, + &self.directory.path, + self.sess.source_map() + ); match self.directory.ownership { DirectoryOwnership::Owned { .. } => { @@ -6569,14 +6563,11 @@ impl<'a> Parser<'a> { } Err(err) } - DirectoryOwnership::UnownedViaMod(warn) => { - if warn { - if let Ok(result) = paths.result { - return Ok(ModulePathSuccess { warn: true, ..result }); - } - } - let mut err = self.diagnostic().struct_span_err(id_sp, - "cannot declare a new module at this location"); + DirectoryOwnership::UnownedViaMod => { + let mut err = self.struct_span_err( + id_sp, + "cannot declare a new module at this location" + ); if !id_sp.is_dummy() { let src_path = self.sess.source_map().span_to_filename(id_sp); if let FileName::Real(src_path) = src_path { @@ -6584,18 +6575,25 @@ impl<'a> Parser<'a> { let mut dest_path = src_path.clone(); dest_path.set_file_name(stem); dest_path.push("mod.rs"); - err.span_note(id_sp, - &format!("maybe move this module `{}` to its own \ - directory via `{}`", src_path.display(), - dest_path.display())); + err.span_note( + id_sp, + &format!( + "maybe move this module `{}` to its own \ + directory via `{}`", src_path.display(), + dest_path.display(), + ) + ); } } } if paths.path_exists { - err.span_note(id_sp, - &format!("... or maybe `use` the module `{}` instead \ - of possibly redeclaring it", - paths.name)); + err.span_note( + id_sp, + &format!( + "... or maybe `use` the module `{}` instead of possibly redeclaring it", + paths.name, + ) + ); } Err(err) } diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 12c4ba059feb6..00327c63b81c2 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -720,7 +720,6 @@ symbols! { visible_private_types, volatile, warn, - warn_directory_ownership, wasm_import_module, wasm_target_feature, while_let, From 1d08c8e69a5ab6e483f8d27e5960478c39724aa6 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 18:25:19 +0200 Subject: [PATCH 04/12] invalid_type_param_default -> error --- .../src/lints/listing/deny-by-default.md | 24 ------------------- src/librustc/lint/builtin.rs | 7 ------ src/librustc_lint/lib.rs | 11 +++++++-- src/librustc_typeck/collect.rs | 5 +--- ...re-gate-default_type_parameter_fallback.rs | 8 ++----- ...ate-default_type_parameter_fallback.stderr | 15 ++++-------- 6 files changed, 16 insertions(+), 54 deletions(-) diff --git a/src/doc/rustc/src/lints/listing/deny-by-default.md b/src/doc/rustc/src/lints/listing/deny-by-default.md index add8e460cba23..1cb9b608e0345 100644 --- a/src/doc/rustc/src/lints/listing/deny-by-default.md +++ b/src/doc/rustc/src/lints/listing/deny-by-default.md @@ -22,29 +22,6 @@ error: bitshift exceeds the type's number of bits | ``` -## invalid-type-param-default - -This lint detects type parameter default erroneously allowed in invalid location. Some -example code that triggers this lint: - -```rust,ignore -fn foo(t: T) {} -``` - -This will produce: - -```text -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions. - --> src/main.rs:4:8 - | -4 | fn foo(t: T) {} - | ^ - | - = note: `#[deny(invalid_type_param_default)]` on by default - = 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 #36887 -``` - ## mutable-transmutes This lint catches transmuting from `&T` to `&mut T` because it is undefined @@ -67,7 +44,6 @@ error: mutating transmuted &mut T from &T may cause undefined behavior, consider | ``` - ## no-mangle-const-items This lint detects any `const` items with the `#[no_mangle]` attribute. diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index f0c97880d8331..599612ab03fc8 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -139,12 +139,6 @@ declare_lint! { "detect public re-exports of private extern crates" } -declare_lint! { - pub INVALID_TYPE_PARAM_DEFAULT, - Deny, - "type parameter default erroneously allowed in invalid location" -} - declare_lint! { pub RENAMED_AND_REMOVED_LINTS, Warn, @@ -401,7 +395,6 @@ declare_lint_pass! { PRIVATE_IN_PUBLIC, EXPORTED_PRIVATE_DEPENDENCIES, PUB_USE_OF_PRIVATE_EXTERN_CRATE, - INVALID_TYPE_PARAM_DEFAULT, CONST_ERR, RENAMED_AND_REMOVED_LINTS, SAFE_EXTERN_STATICS, diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 59fcf394f9f6d..dbae5a2c9d8de 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -327,10 +327,15 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { edition: None, }, FutureIncompatibleInfo { - id: LintId::of(INVALID_TYPE_PARAM_DEFAULT), - reference: "issue #36887 ", + id: LintId::of(ILLEGAL_FLOATING_POINT_LITERAL_PATTERN), + reference: "issue #41620 ", edition: None, }, + FutureIncompatibleInfo { + id: LintId::of(ANONYMOUS_PARAMETERS), + reference: "issue #41686 ", + edition: Some(Edition::Edition2018), + }, FutureIncompatibleInfo { id: LintId::of(PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES), reference: "issue #42238 ", @@ -469,6 +474,8 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { "converted into hard error, see https://github.com/rust-lang/rust/issues/39207"); store.register_removed("legacy_disrectory_ownership", "converted into hard error, see https://github.com/rust-lang/rust/issues/37872"); + store.register_removed("invalid_type_param_default", + "converted into hard error, see https://github.com/rust-lang/rust/issues/36887"); } pub fn register_internals(store: &mut lint::LintStore, sess: Option<&Session>) { diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 15687eaa943e1..57b1c1061f0cb 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -17,7 +17,6 @@ use crate::astconv::{AstConv, Bounds, SizedByDefault}; use crate::constrained_generic_params as cgp; use crate::check::intrinsic::intrisic_operation_unsafety; -use crate::lint; use crate::middle::resolve_lifetime as rl; use crate::middle::weak_lang_items; use rustc::mir::mono::Linkage; @@ -1014,9 +1013,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics { if !allow_defaults && default.is_some() { if !tcx.features().default_type_parameter_fallback { - tcx.lint_hir( - lint::builtin::INVALID_TYPE_PARAM_DEFAULT, - param.hir_id, + tcx.sess.span_err( param.span, &format!( "defaults for type parameters are only allowed in \ diff --git a/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.rs b/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.rs index 33038e24bc62b..4c18a95a6ad49 100644 --- a/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.rs +++ b/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.rs @@ -1,12 +1,8 @@ -#![allow(unused)] - -fn avg(_: T) {} +fn avg(_: T) {} //~^ ERROR defaults for type parameters are only allowed -//~| WARN this was previously accepted struct S(T); -impl S {} +impl S {} //~^ ERROR defaults for type parameters are only allowed -//~| WARN this was previously accepted fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr b/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr index f13803b80f308..4680e78d7450b 100644 --- a/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr +++ b/src/test/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr @@ -1,21 +1,14 @@ error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions. - --> $DIR/feature-gate-default_type_parameter_fallback.rs:3:8 + --> $DIR/feature-gate-default_type_parameter_fallback.rs:1:8 | -LL | fn avg(_: T) {} +LL | fn avg(_: T) {} | ^ - | - = note: `#[deny(invalid_type_param_default)]` on by default - = 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 #36887 error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions. - --> $DIR/feature-gate-default_type_parameter_fallback.rs:8:6 + --> $DIR/feature-gate-default_type_parameter_fallback.rs:5:6 | -LL | impl S {} +LL | impl S {} | ^ - | - = 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 #36887 error: aborting due to 2 previous errors From 3b9128d02c8090b53233d661922dc8df3ac2339f Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 19:34:21 +0200 Subject: [PATCH 05/12] safe_extern_static -> error --- .../src/lints/listing/deny-by-default.md | 5 --- src/librustc/lint/builtin.rs | 7 ---- src/librustc/mir/mod.rs | 1 - src/librustc_lint/lib.rs | 7 +--- src/librustc_mir/transform/check_unsafety.rs | 40 ++++++------------- src/test/ui/issues/issue-14227.rs | 5 +-- src/test/ui/issues/issue-14227.stderr | 10 +++-- src/test/ui/issues/issue-16538.rs | 3 +- src/test/ui/issues/issue-16538.stderr | 16 ++++++-- src/test/ui/issues/issue-28324.rs | 5 +-- src/test/ui/issues/issue-28324.stderr | 10 +++-- src/test/ui/safe-extern-statics.rs | 6 --- src/test/ui/safe-extern-statics.stderr | 34 ++++++---------- 13 files changed, 55 insertions(+), 94 deletions(-) diff --git a/src/doc/rustc/src/lints/listing/deny-by-default.md b/src/doc/rustc/src/lints/listing/deny-by-default.md index 1cb9b608e0345..acf6a91760000 100644 --- a/src/doc/rustc/src/lints/listing/deny-by-default.md +++ b/src/doc/rustc/src/lints/listing/deny-by-default.md @@ -118,11 +118,6 @@ To fix it, remove the `()`s. This lint detects a specific situation of re-exporting a private `extern crate`; -## safe-extern-statics - -In older versions of Rust, there was a soundness issue where `extern static`s were allowed -to be accessed in safe code. This lint now catches and denies this kind of code. - ## unknown-crate-types This lint detects an unknown crate type found in a `#[crate_type]` directive. Some diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 599612ab03fc8..6434975e5d536 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -145,12 +145,6 @@ declare_lint! { "lints that have been renamed or removed" } -declare_lint! { - pub SAFE_EXTERN_STATICS, - Deny, - "safe access to extern statics was erroneously allowed" -} - declare_lint! { pub SAFE_PACKED_BORROWS, Warn, @@ -397,7 +391,6 @@ declare_lint_pass! { PUB_USE_OF_PRIVATE_EXTERN_CRATE, CONST_ERR, RENAMED_AND_REMOVED_LINTS, - SAFE_EXTERN_STATICS, SAFE_PACKED_BORROWS, PATTERNS_IN_FNS_WITHOUT_BODY, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 1e2ec08301cf9..a56918d7e5f87 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -2803,7 +2803,6 @@ pub enum UnsafetyViolationKind { General, /// Permitted in const fn and regular fns. GeneralAndConstFn, - ExternStatic(hir::HirId), BorrowPacked(hir::HirId), } diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index dbae5a2c9d8de..0900424b2c4f2 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -321,11 +321,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { reference: "issue #49716 ", edition: Some(Edition::Edition2018), }, - FutureIncompatibleInfo { - id: LintId::of(SAFE_EXTERN_STATICS), - reference: "issue #36247 ", - edition: None, - }, FutureIncompatibleInfo { id: LintId::of(ILLEGAL_FLOATING_POINT_LITERAL_PATTERN), reference: "issue #41620 ", @@ -476,6 +471,8 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { "converted into hard error, see https://github.com/rust-lang/rust/issues/37872"); store.register_removed("invalid_type_param_default", "converted into hard error, see https://github.com/rust-lang/rust/issues/36887"); + store.register_removed("safe_extern_statics", + "converted into hard error, see https://github.com/rust-lang/rust/issues/36247"); } pub fn register_internals(store: &mut lint::LintStore, sess: Option<&Session>) { diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index d5c5267a119d3..6a446de781673 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -8,7 +8,7 @@ use rustc::ty::cast::CastTy; use rustc::hir; use rustc::hir::Node; use rustc::hir::def_id::DefId; -use rustc::lint::builtin::{SAFE_EXTERN_STATICS, SAFE_PACKED_BORROWS, UNUSED_UNSAFE}; +use rustc::lint::builtin::{SAFE_PACKED_BORROWS, UNUSED_UNSAFE}; use rustc::mir::*; use rustc::mir::visit::{PlaceContext, Visitor, MutatingUseContext}; @@ -210,23 +210,19 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> { } PlaceBase::Static(box Static { kind: StaticKind::Static(def_id), .. }) => { if self.tcx.is_mutable_static(*def_id) { - self.require_unsafe("use of mutable static", + self.require_unsafe( + "use of mutable static", "mutable statics can be mutated by multiple threads: aliasing \ violations or data races will cause undefined behavior", - UnsafetyViolationKind::General); + UnsafetyViolationKind::General, + ); } else if self.tcx.is_foreign_item(*def_id) { - let source_info = self.source_info; - let lint_root = - self.source_scope_local_data[source_info.scope].lint_root; - self.register_violations(&[UnsafetyViolation { - source_info, - description: InternedString::intern("use of extern static"), - details: InternedString::intern( - "extern statics are not controlled by the Rust type system: \ - invalid data, aliasing violations or data races will cause \ - undefined behavior"), - kind: UnsafetyViolationKind::ExternStatic(lint_root) - }], &[]); + self.require_unsafe( + "use of extern static", + "extern statics are not controlled by the Rust type system: invalid \ + data, aliasing violations or data races will cause undefined behavior", + UnsafetyViolationKind::General + ); } } } @@ -352,8 +348,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> { match violation.kind { UnsafetyViolationKind::GeneralAndConstFn | UnsafetyViolationKind::General => {}, - UnsafetyViolationKind::BorrowPacked(_) | - UnsafetyViolationKind::ExternStatic(_) => if self.min_const_fn { + UnsafetyViolationKind::BorrowPacked(_) => if self.min_const_fn { // const fns don't need to be backwards compatible and can // emit these violations as a hard error instead of a backwards // compat lint @@ -381,8 +376,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> { UnsafetyViolationKind::GeneralAndConstFn => {}, // these things are forbidden in const fns UnsafetyViolationKind::General | - UnsafetyViolationKind::BorrowPacked(_) | - UnsafetyViolationKind::ExternStatic(_) => { + UnsafetyViolationKind::BorrowPacked(_) => { let mut violation = violation.clone(); // const fns don't need to be backwards compatible and can // emit these violations as a hard error instead of a backwards @@ -646,14 +640,6 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: DefId) { .note(&details.as_str()[..]) .emit(); } - UnsafetyViolationKind::ExternStatic(lint_hir_id) => { - tcx.lint_node_note(SAFE_EXTERN_STATICS, - lint_hir_id, - source_info.span, - &format!("{} is unsafe and requires unsafe function or block \ - (error E0133)", &description.as_str()[..]), - &details.as_str()[..]); - } UnsafetyViolationKind::BorrowPacked(lint_hir_id) => { if let Some(impl_def_id) = builtin_derive_def_id(tcx, def_id) { tcx.unsafe_derive_on_repr_packed(impl_def_id); diff --git a/src/test/ui/issues/issue-14227.rs b/src/test/ui/issues/issue-14227.rs index 5de3867f95c22..d80eefc41bf53 100644 --- a/src/test/ui/issues/issue-14227.rs +++ b/src/test/ui/issues/issue-14227.rs @@ -1,10 +1,7 @@ -#![allow(safe_extern_statics, warnings)] - extern { pub static symbol: u32; } static CRASH: u32 = symbol; -//~^ ERROR could not evaluate static initializer -//~| tried to read from foreign (extern) static +//~^ ERROR use of extern static is unsafe and requires fn main() {} diff --git a/src/test/ui/issues/issue-14227.stderr b/src/test/ui/issues/issue-14227.stderr index 88e99e213bf74..f9cdbe452df9c 100644 --- a/src/test/ui/issues/issue-14227.stderr +++ b/src/test/ui/issues/issue-14227.stderr @@ -1,9 +1,11 @@ -error[E0080]: could not evaluate static initializer - --> $DIR/issue-14227.rs:6:21 +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/issue-14227.rs:4:21 | LL | static CRASH: u32 = symbol; - | ^^^^^^ tried to read from foreign (extern) static + | ^^^^^^ use of extern static + | + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior error: aborting due to previous error -For more information about this error, try `rustc --explain E0080`. +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/issues/issue-16538.rs b/src/test/ui/issues/issue-16538.rs index a990c078a7986..54d9a732912c7 100644 --- a/src/test/ui/issues/issue-16538.rs +++ b/src/test/ui/issues/issue-16538.rs @@ -1,5 +1,3 @@ -#![allow(safe_extern_statics)] - mod Y { pub type X = usize; extern { @@ -13,5 +11,6 @@ mod Y { static foo: *const Y::X = Y::foo(Y::x as *const Y::X); //~^ ERROR `*const usize` cannot be shared between threads safely [E0277] //~| ERROR E0015 +//~| ERROR use of extern static is unsafe and requires fn main() {} diff --git a/src/test/ui/issues/issue-16538.stderr b/src/test/ui/issues/issue-16538.stderr index 2d8b5bf2f6fb8..5e1f95a989ee0 100644 --- a/src/test/ui/issues/issue-16538.stderr +++ b/src/test/ui/issues/issue-16538.stderr @@ -1,11 +1,11 @@ error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants - --> $DIR/issue-16538.rs:13:27 + --> $DIR/issue-16538.rs:11:27 | LL | static foo: *const Y::X = Y::foo(Y::x as *const Y::X); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: `*const usize` cannot be shared between threads safely - --> $DIR/issue-16538.rs:13:1 + --> $DIR/issue-16538.rs:11:1 | LL | static foo: *const Y::X = Y::foo(Y::x as *const Y::X); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const usize` cannot be shared between threads safely @@ -13,7 +13,15 @@ LL | static foo: *const Y::X = Y::foo(Y::x as *const Y::X); = help: the trait `std::marker::Sync` is not implemented for `*const usize` = note: shared static variables must have a type that implements `Sync` -error: aborting due to 2 previous errors +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/issue-16538.rs:11:34 + | +LL | static foo: *const Y::X = Y::foo(Y::x as *const Y::X); + | ^^^^ use of extern static + | + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior + +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0015, E0277. +Some errors have detailed explanations: E0015, E0133, E0277. For more information about an error, try `rustc --explain E0015`. diff --git a/src/test/ui/issues/issue-28324.rs b/src/test/ui/issues/issue-28324.rs index 73e8cd6ab0da1..bb48508a4a438 100644 --- a/src/test/ui/issues/issue-28324.rs +++ b/src/test/ui/issues/issue-28324.rs @@ -1,11 +1,8 @@ -#![allow(safe_extern_statics)] - extern { static error_message_count: u32; } pub static BAZ: u32 = *&error_message_count; -//~^ ERROR could not evaluate static initializer -//~| tried to read from foreign (extern) static +//~^ ERROR use of extern static is unsafe and requires fn main() {} diff --git a/src/test/ui/issues/issue-28324.stderr b/src/test/ui/issues/issue-28324.stderr index bbd02ba03f489..d7dad99215204 100644 --- a/src/test/ui/issues/issue-28324.stderr +++ b/src/test/ui/issues/issue-28324.stderr @@ -1,9 +1,11 @@ -error[E0080]: could not evaluate static initializer - --> $DIR/issue-28324.rs:7:23 +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/issue-28324.rs:5:24 | LL | pub static BAZ: u32 = *&error_message_count; - | ^^^^^^^^^^^^^^^^^^^^^ tried to read from foreign (extern) static + | ^^^^^^^^^^^^^^^^^^^^ use of extern static + | + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior error: aborting due to previous error -For more information about this error, try `rustc --explain E0080`. +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/safe-extern-statics.rs b/src/test/ui/safe-extern-statics.rs index eda309444681b..0535a078d2c31 100644 --- a/src/test/ui/safe-extern-statics.rs +++ b/src/test/ui/safe-extern-statics.rs @@ -1,7 +1,5 @@ // aux-build:extern-statics.rs -#![allow(unused)] - extern crate extern_statics; use extern_statics::*; @@ -11,11 +9,7 @@ extern { fn main() { let a = A; //~ ERROR use of extern static is unsafe - //~^ WARN this was previously accepted by the compiler let ra = &A; //~ ERROR use of extern static is unsafe - //~^ WARN this was previously accepted by the compiler let xa = XA; //~ ERROR use of extern static is unsafe - //~^ WARN this was previously accepted by the compiler let xra = &XA; //~ ERROR use of extern static is unsafe - //~^ WARN this was previously accepted by the compiler } diff --git a/src/test/ui/safe-extern-statics.stderr b/src/test/ui/safe-extern-statics.stderr index 0948fad74e50e..b42572ea3eeb5 100644 --- a/src/test/ui/safe-extern-statics.stderr +++ b/src/test/ui/safe-extern-statics.stderr @@ -1,43 +1,35 @@ -error: use of extern static is unsafe and requires unsafe function or block (error E0133) - --> $DIR/safe-extern-statics.rs:13:13 +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics.rs:11:13 | LL | let a = A; - | ^ + | ^ use of extern static | - = note: `#[deny(safe_extern_statics)]` on by default - = 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 #36247 = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior -error: use of extern static is unsafe and requires unsafe function or block (error E0133) - --> $DIR/safe-extern-statics.rs:15:14 +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics.rs:12:14 | LL | let ra = &A; - | ^^ + | ^^ use of extern static | - = 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 #36247 = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior -error: use of extern static is unsafe and requires unsafe function or block (error E0133) - --> $DIR/safe-extern-statics.rs:17:14 +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics.rs:13:14 | LL | let xa = XA; - | ^^ + | ^^ use of extern static | - = 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 #36247 = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior -error: use of extern static is unsafe and requires unsafe function or block (error E0133) - --> $DIR/safe-extern-statics.rs:19:15 +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics.rs:14:15 | LL | let xra = &XA; - | ^^^ + | ^^^ use of extern static | - = 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 #36247 = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior error: aborting due to 4 previous errors +For more information about this error, try `rustc --explain E0133`. From 29b777b3f0ce1b032d82aaaf718d49f88eb85304 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 19:58:26 +0200 Subject: [PATCH 06/12] parenthesized_params_in_types_and_modules -> error --- .../src/lints/listing/deny-by-default.md | 25 ------- src/librustc/hir/lowering.rs | 39 +++-------- src/librustc/lint/builtin.rs | 7 -- src/librustc_lint/lib.rs | 7 +- src/test/ui/issues/issue-32995-2.rs | 5 -- src/test/ui/issues/issue-32995-2.stderr | 29 +++------ src/test/ui/issues/issue-32995.rs | 9 --- src/test/ui/issues/issue-32995.stderr | 65 +++++++------------ src/test/ui/type/ascription/issue-34255-1.rs | 1 - .../ui/type/ascription/issue-34255-1.stderr | 10 +-- 10 files changed, 46 insertions(+), 151 deletions(-) diff --git a/src/doc/rustc/src/lints/listing/deny-by-default.md b/src/doc/rustc/src/lints/listing/deny-by-default.md index acf6a91760000..e592cd3ce67b3 100644 --- a/src/doc/rustc/src/lints/listing/deny-by-default.md +++ b/src/doc/rustc/src/lints/listing/deny-by-default.md @@ -89,31 +89,6 @@ error: literal out of range for u8 | ``` -## parenthesized-params-in-types-and-modules - -This lint detects incorrect parentheses. Some example code that triggers this -lint: - -```rust,ignore -let x = 5 as usize(); -``` - -This will produce: - -```text -error: parenthesized parameters may only be used with a trait - --> src/main.rs:2:21 - | -2 | let x = 5 as usize(); - | ^^ - | - = note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default - = 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 #42238 -``` - -To fix it, remove the `()`s. - ## pub-use-of-private-extern-crate This lint detects a specific situation of re-exporting a private `extern crate`; diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index f76de96cd10da..d2e8d072efc1d 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -40,8 +40,7 @@ use crate::hir::def_id::{DefId, DefIndex, CRATE_DEF_INDEX}; use crate::hir::def::{Res, DefKind, PartialRes, PerNS}; use crate::hir::{GenericArg, ConstArg}; use crate::hir::ptr::P; -use crate::lint::builtin::{self, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, - ELIDED_LIFETIMES_IN_PATHS}; +use crate::lint::builtin::{self, ELIDED_LIFETIMES_IN_PATHS}; use crate::middle::cstore::CrateStore; use crate::session::Session; use crate::session::config::nightly_options; @@ -286,7 +285,6 @@ enum ParamMode { enum ParenthesizedGenericArgs { Ok, - Warn, Err, } @@ -2057,29 +2055,19 @@ impl<'a> LoweringContext<'a> { }; let parenthesized_generic_args = match partial_res.base_res() { // `a::b::Trait(Args)` - Res::Def(DefKind::Trait, _) - if i + 1 == proj_start => ParenthesizedGenericArgs::Ok, + Res::Def(DefKind::Trait, _) if i + 1 == proj_start => { + ParenthesizedGenericArgs::Ok + } // `a::b::Trait(Args)::TraitItem` - Res::Def(DefKind::Method, _) - | Res::Def(DefKind::AssocConst, _) - | Res::Def(DefKind::AssocTy, _) - if i + 2 == proj_start => - { + Res::Def(DefKind::Method, _) | + Res::Def(DefKind::AssocConst, _) | + Res::Def(DefKind::AssocTy, _) if i + 2 == proj_start => { ParenthesizedGenericArgs::Ok } // Avoid duplicated errors. Res::Err => ParenthesizedGenericArgs::Ok, // An error - Res::Def(DefKind::Struct, _) - | Res::Def(DefKind::Enum, _) - | Res::Def(DefKind::Union, _) - | Res::Def(DefKind::TyAlias, _) - | Res::Def(DefKind::Variant, _) if i + 1 == proj_start => - { - ParenthesizedGenericArgs::Err - } - // A warning for now, for compatibility reasons. - _ => ParenthesizedGenericArgs::Warn, + _ => ParenthesizedGenericArgs::Err, }; let num_lifetimes = type_def_id.map_or(0, |def_id| { @@ -2142,7 +2130,7 @@ impl<'a> LoweringContext<'a> { segment, param_mode, 0, - ParenthesizedGenericArgs::Warn, + ParenthesizedGenericArgs::Err, itctx.reborrow(), None, )); @@ -2218,15 +2206,6 @@ impl<'a> LoweringContext<'a> { } GenericArgs::Parenthesized(ref data) => match parenthesized_generic_args { ParenthesizedGenericArgs::Ok => self.lower_parenthesized_parameter_data(data), - ParenthesizedGenericArgs::Warn => { - self.sess.buffer_lint( - PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, - CRATE_NODE_ID, - data.span, - msg.into(), - ); - (hir::GenericArgs::none(), true) - } ParenthesizedGenericArgs::Err => { let mut err = struct_span_err!(self.sess, data.span, E0214, "{}", msg); err.span_label(data.span, "only `Fn` traits may use parentheses"); diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 6434975e5d536..1dae7cb5e6077 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -157,12 +157,6 @@ declare_lint! { "patterns in functions without body were erroneously allowed" } -declare_lint! { - pub PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, - Deny, - "detects parenthesized generic parameters in type and module names" -} - declare_lint! { pub LATE_BOUND_LIFETIME_ARGUMENTS, Warn, @@ -393,7 +387,6 @@ declare_lint_pass! { RENAMED_AND_REMOVED_LINTS, SAFE_PACKED_BORROWS, PATTERNS_IN_FNS_WITHOUT_BODY, - PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, LATE_BOUND_LIFETIME_ARGUMENTS, ORDER_DEPENDENT_TRAIT_OBJECTS, DEPRECATED, diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 0900424b2c4f2..b986b654312a3 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -331,11 +331,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { reference: "issue #41686 ", edition: Some(Edition::Edition2018), }, - FutureIncompatibleInfo { - id: LintId::of(PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES), - reference: "issue #42238 ", - edition: None, - }, FutureIncompatibleInfo { id: LintId::of(LATE_BOUND_LIFETIME_ARGUMENTS), reference: "issue #42868 ", @@ -473,6 +468,8 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { "converted into hard error, see https://github.com/rust-lang/rust/issues/36887"); store.register_removed("safe_extern_statics", "converted into hard error, see https://github.com/rust-lang/rust/issues/36247"); + store.register_removed("parenthesized_params_in_types_and_modules", + "converted into hard error, see https://github.com/rust-lang/rust/issues/42238"); } pub fn register_internals(store: &mut lint::LintStore, sess: Option<&Session>) { diff --git a/src/test/ui/issues/issue-32995-2.rs b/src/test/ui/issues/issue-32995-2.rs index 2234f68f24629..e713a64d3f5a6 100644 --- a/src/test/ui/issues/issue-32995-2.rs +++ b/src/test/ui/issues/issue-32995-2.rs @@ -1,13 +1,9 @@ -#![allow(unused)] - fn main() { { fn f() {} } //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| WARN previously accepted { fn f() -> impl ::std::marker()::Send { } } //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| WARN previously accepted } #[derive(Clone)] @@ -15,4 +11,3 @@ struct X; impl ::std::marker()::Copy for X {} //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait -//~| WARN previously accepted diff --git a/src/test/ui/issues/issue-32995-2.stderr b/src/test/ui/issues/issue-32995-2.stderr index 4a580b09bf372..d752a4d2a6c8d 100644 --- a/src/test/ui/issues/issue-32995-2.stderr +++ b/src/test/ui/issues/issue-32995-2.stderr @@ -1,30 +1,21 @@ -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995-2.rs:4:28 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995-2.rs:2:28 | LL | { fn f() {} } - | ^^ - | - = note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default - = 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 #42238 + | ^^ only `Fn` traits may use parentheses -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995-2.rs:8:35 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995-2.rs:5:35 | LL | { fn f() -> impl ::std::marker()::Send { } } - | ^^ - | - = 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 #42238 + | ^^ only `Fn` traits may use parentheses -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995-2.rs:16:19 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995-2.rs:12:19 | LL | impl ::std::marker()::Copy for X {} - | ^^ - | - = 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 #42238 + | ^^ only `Fn` traits may use parentheses error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0214`. diff --git a/src/test/ui/issues/issue-32995.rs b/src/test/ui/issues/issue-32995.rs index 3526deffc79ab..0d07a76939f2a 100644 --- a/src/test/ui/issues/issue-32995.rs +++ b/src/test/ui/issues/issue-32995.rs @@ -1,33 +1,24 @@ -#![allow(unused)] - fn main() { let x: usize() = 1; //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| WARN previously accepted let b: ::std::boxed()::Box<_> = Box::new(1); //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| WARN previously accepted let p = ::std::str::()::from_utf8(b"foo").unwrap(); //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| WARN previously accepted let p = ::std::str::from_utf8::()(b"foo").unwrap(); //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| WARN previously accepted let o : Box = Box::new(1); //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| WARN previously accepted let o : Box = Box::new(1); //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| WARN previously accepted } fn foo() { let d : X() = Default::default(); //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| WARN previously accepted } diff --git a/src/test/ui/issues/issue-32995.stderr b/src/test/ui/issues/issue-32995.stderr index 59d93ece06742..ca4a12e1ea162 100644 --- a/src/test/ui/issues/issue-32995.stderr +++ b/src/test/ui/issues/issue-32995.stderr @@ -1,66 +1,45 @@ -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:4:17 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995.rs:2:17 | LL | let x: usize() = 1; - | ^^ - | - = note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default - = 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 #42238 + | ^^ only `Fn` traits may use parentheses -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:8:24 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995.rs:5:24 | LL | let b: ::std::boxed()::Box<_> = Box::new(1); - | ^^ - | - = 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 #42238 + | ^^ only `Fn` traits may use parentheses -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:12:25 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995.rs:8:25 | LL | let p = ::std::str::()::from_utf8(b"foo").unwrap(); - | ^^ - | - = 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 #42238 + | ^^ only `Fn` traits may use parentheses -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:16:36 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995.rs:11:36 | LL | let p = ::std::str::from_utf8::()(b"foo").unwrap(); - | ^^ - | - = 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 #42238 + | ^^ only `Fn` traits may use parentheses -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:20:35 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995.rs:14:35 | LL | let o : Box = Box::new(1); - | ^^ - | - = 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 #42238 + | ^^ only `Fn` traits may use parentheses -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:24:41 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995.rs:17:41 | LL | let o : Box = Box::new(1); - | ^^ - | - = 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 #42238 + | ^^ only `Fn` traits may use parentheses -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:30:14 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995.rs:22:14 | LL | let d : X() = Default::default(); - | ^^ - | - = 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 #42238 + | ^^ only `Fn` traits may use parentheses error: aborting due to 7 previous errors +For more information about this error, try `rustc --explain E0214`. diff --git a/src/test/ui/type/ascription/issue-34255-1.rs b/src/test/ui/type/ascription/issue-34255-1.rs index c11a248d3c7d1..38f8ec43147d0 100644 --- a/src/test/ui/type/ascription/issue-34255-1.rs +++ b/src/test/ui/type/ascription/issue-34255-1.rs @@ -8,7 +8,6 @@ impl Reactor { //~^ ERROR cannot find value `input_cells` in this scope //~| ERROR parenthesized type parameters may only be used with a `Fn` trait //~| ERROR wrong number of type arguments: expected 1, found 0 - //~| WARNING this was previously accepted by the compiler but is being phased out } } diff --git a/src/test/ui/type/ascription/issue-34255-1.stderr b/src/test/ui/type/ascription/issue-34255-1.stderr index 531455b82b424..8bc64036e5626 100644 --- a/src/test/ui/type/ascription/issue-34255-1.stderr +++ b/src/test/ui/type/ascription/issue-34255-1.stderr @@ -4,15 +4,11 @@ error[E0425]: cannot find value `input_cells` in this scope LL | input_cells: Vec::new() | ^^^^^^^^^^^ a field by this name exists in `Self` -error: parenthesized type parameters may only be used with a `Fn` trait +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait --> $DIR/issue-34255-1.rs:7:30 | LL | input_cells: Vec::new() - | ^^ - | - = note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default - = 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 #42238 + | ^^ only `Fn` traits may use parentheses error[E0601]: `main` function not found in crate `issue_34255_1` | @@ -26,5 +22,5 @@ LL | input_cells: Vec::new() error: aborting due to 4 previous errors -Some errors have detailed explanations: E0107, E0425, E0601. +Some errors have detailed explanations: E0107, E0214, E0425, E0601. For more information about an error, try `rustc --explain E0107`. From 261f8a38c54eeb8a04abc2529a359b59053a7c54 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 20:29:45 +0200 Subject: [PATCH 07/12] duplicate_macro_exports -> error --- src/librustc/lint/builtin.rs | 12 ------------ src/librustc_lint/lib.rs | 7 ++----- src/librustc_resolve/resolve_imports.rs | 18 +++++++----------- .../ui/issues/auxiliary/issue-38715-modern.rs | 7 ------- src/test/ui/issues/auxiliary/issue-38715.rs | 7 ------- src/test/ui/issues/issue-38715-rpass.rs | 15 --------------- src/test/ui/issues/issue-38715.rs | 1 - src/test/ui/issues/issue-38715.stderr | 3 --- 8 files changed, 9 insertions(+), 61 deletions(-) delete mode 100644 src/test/ui/issues/auxiliary/issue-38715-modern.rs delete mode 100644 src/test/ui/issues/auxiliary/issue-38715.rs delete mode 100644 src/test/ui/issues/issue-38715-rpass.rs diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 1dae7cb5e6077..d261b41da60fc 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -255,12 +255,6 @@ declare_lint! { "detects labels that are never used" } -declare_lint! { - pub DUPLICATE_MACRO_EXPORTS, - Deny, - "detects duplicate macro exports" -} - declare_lint! { pub INTRA_DOC_LINK_RESOLUTION_FAILURE, Warn, @@ -402,7 +396,6 @@ declare_lint_pass! { ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE, UNSTABLE_NAME_COLLISIONS, IRREFUTABLE_LET_PATTERNS, - DUPLICATE_MACRO_EXPORTS, INTRA_DOC_LINK_RESOLUTION_FAILURE, MISSING_DOC_CODE_EXAMPLES, PRIVATE_DOC_TESTS, @@ -427,7 +420,6 @@ pub enum BuiltinLintDiagnostics { Normal, BareTraitObject(Span, /* is_global */ bool), AbsPathWithModule(Span), - DuplicatedMacroExports(ast::Ident, Span, Span), ProcMacroDeriveResolutionFallback(Span), MacroExpandedMacroExportsAccessedByAbsolutePaths(Span), ElidedLifetimesInPaths(usize, Span, bool, Span, String), @@ -510,10 +502,6 @@ impl BuiltinLintDiagnostics { }; db.span_suggestion(span, "use `crate`", sugg, app); } - BuiltinLintDiagnostics::DuplicatedMacroExports(ident, earlier_span, later_span) => { - db.span_label(later_span, format!("`{}` already exported", ident)); - db.span_note(earlier_span, "previous macro export is now shadowed"); - } BuiltinLintDiagnostics::ProcMacroDeriveResolutionFallback(span) => { db.span_label(span, "names from parent modules are not \ accessible without an explicit import"); diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index b986b654312a3..3f1dad9624179 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -311,11 +311,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { reference: "issue #35203 ", edition: None, }, - FutureIncompatibleInfo { - id: LintId::of(DUPLICATE_MACRO_EXPORTS), - reference: "issue #35896 ", - edition: Some(Edition::Edition2018), - }, FutureIncompatibleInfo { id: LintId::of(KEYWORD_IDENTS), reference: "issue #49716 ", @@ -470,6 +465,8 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { "converted into hard error, see https://github.com/rust-lang/rust/issues/36247"); store.register_removed("parenthesized_params_in_types_and_modules", "converted into hard error, see https://github.com/rust-lang/rust/issues/42238"); + store.register_removed("duplicate_macro_exports", + "converted into hard error, see https://github.com/rust-lang/rust/issues/35896"); } pub fn register_internals(store: &mut lint::LintStore, sess: Option<&Session>) { diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 59438883d60bc..f9a7b6d1705d5 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -16,18 +16,14 @@ use errors::Applicability; use rustc_data_structures::ptr_key::PtrKey; use rustc::ty; use rustc::lint::builtin::BuiltinLintDiagnostics; -use rustc::lint::builtin::{ - DUPLICATE_MACRO_EXPORTS, - PUB_USE_OF_PRIVATE_EXTERN_CRATE, - UNUSED_IMPORTS, -}; +use rustc::lint::builtin::{PUB_USE_OF_PRIVATE_EXTERN_CRATE, UNUSED_IMPORTS}; use rustc::hir::def_id::DefId; use rustc::hir::def::{self, PartialRes, Export}; use rustc::session::DiagnosticMessageId; use rustc::util::nodemap::FxHashSet; use rustc::{bug, span_bug}; -use syntax::ast::{self, Ident, Name, NodeId, CRATE_NODE_ID}; +use syntax::ast::{self, Ident, Name, NodeId}; use syntax::ext::hygiene::ExpnId; use syntax::symbol::kw; use syntax::util::lev_distance::find_best_match_for_name; @@ -537,13 +533,13 @@ impl<'a> Resolver<'a> { if let (&NameBindingKind::Res(_, true), &NameBindingKind::Res(_, true)) = (&old_binding.kind, &binding.kind) { - this.session.buffer_lint_with_diagnostic( - DUPLICATE_MACRO_EXPORTS, - CRATE_NODE_ID, + this.session.struct_span_err( binding.span, &format!("a macro named `{}` has already been exported", ident), - BuiltinLintDiagnostics::DuplicatedMacroExports( - ident, old_binding.span, binding.span)); + ) + .span_label(binding.span, format!("`{}` already exported", ident)) + .span_note(old_binding.span, "previous macro export is now shadowed") + .emit(); resolution.binding = Some(binding); } else { diff --git a/src/test/ui/issues/auxiliary/issue-38715-modern.rs b/src/test/ui/issues/auxiliary/issue-38715-modern.rs deleted file mode 100644 index 15d072957cbd8..0000000000000 --- a/src/test/ui/issues/auxiliary/issue-38715-modern.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![allow(duplicate_macro_exports)] - -#[macro_export] -macro_rules! foo_modern { ($i:ident) => {} } - -#[macro_export] -macro_rules! foo_modern { () => {} } diff --git a/src/test/ui/issues/auxiliary/issue-38715.rs b/src/test/ui/issues/auxiliary/issue-38715.rs deleted file mode 100644 index 5c15073f5a5e6..0000000000000 --- a/src/test/ui/issues/auxiliary/issue-38715.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![allow(duplicate_macro_exports)] - -#[macro_export] -macro_rules! foo { ($i:ident) => {} } - -#[macro_export] -macro_rules! foo { () => {} } diff --git a/src/test/ui/issues/issue-38715-rpass.rs b/src/test/ui/issues/issue-38715-rpass.rs deleted file mode 100644 index e3c3a027f3cd0..0000000000000 --- a/src/test/ui/issues/issue-38715-rpass.rs +++ /dev/null @@ -1,15 +0,0 @@ -// run-pass -// aux-build:issue-38715.rs -// aux-build:issue-38715-modern.rs - -// Test that `#[macro_export] macro_rules!` shadow earlier `#[macro_export] macro_rules!` - -#[macro_use] -extern crate issue_38715; -#[macro_use] -extern crate issue_38715_modern; - -fn main() { - foo!(); - foo_modern!(); -} diff --git a/src/test/ui/issues/issue-38715.rs b/src/test/ui/issues/issue-38715.rs index 850ffcdabe4cb..7e9defab58864 100644 --- a/src/test/ui/issues/issue-38715.rs +++ b/src/test/ui/issues/issue-38715.rs @@ -3,6 +3,5 @@ macro_rules! foo { ($i:ident) => {} } #[macro_export] macro_rules! foo { () => {} } //~ ERROR a macro named `foo` has already been exported - //~| WARN this was previously accepted fn main() {} diff --git a/src/test/ui/issues/issue-38715.stderr b/src/test/ui/issues/issue-38715.stderr index 02b96d2d2449c..d7c4f88ff5079 100644 --- a/src/test/ui/issues/issue-38715.stderr +++ b/src/test/ui/issues/issue-38715.stderr @@ -4,9 +4,6 @@ error: a macro named `foo` has already been exported LL | macro_rules! foo { () => {} } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `foo` already exported | - = note: `#[deny(duplicate_macro_exports)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue #35896 note: previous macro export is now shadowed --> $DIR/issue-38715.rs:2:1 | From 6ebc330a3e414967bfeb0b31f7cac040df905a5a Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 20:55:23 +0200 Subject: [PATCH 08/12] macro_expanded_macro_exports_accessed_by_absolute_paths -> error --- src/librustc/lint/builtin.rs | 12 ------------ src/librustc_lint/lib.rs | 7 ++----- src/librustc_resolve/lib.rs | 15 +++++++-------- .../ui/imports/local-modularized-tricky-fail-3.rs | 2 -- .../local-modularized-tricky-fail-3.stderr | 7 +------ 5 files changed, 10 insertions(+), 33 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index d261b41da60fc..d1f9de081fd05 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -292,13 +292,6 @@ declare_lint! { via the module system" } -declare_lint! { - pub MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS, - Deny, - "macro-expanded `macro_export` macros from the current crate \ - cannot be referred to by absolute paths" -} - declare_lint! { pub EXPLICIT_OUTLIVES_REQUIREMENTS, Allow, @@ -402,7 +395,6 @@ declare_lint_pass! { WHERE_CLAUSES_OBJECT_SAFETY, PROC_MACRO_DERIVE_RESOLUTION_FALLBACK, MACRO_USE_EXTERN_CRATE, - MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS, parser::ILL_FORMED_ATTRIBUTE_INPUT, parser::META_VARIABLE_MISUSE, DEPRECATED_IN_FUTURE, @@ -421,7 +413,6 @@ pub enum BuiltinLintDiagnostics { BareTraitObject(Span, /* is_global */ bool), AbsPathWithModule(Span), ProcMacroDeriveResolutionFallback(Span), - MacroExpandedMacroExportsAccessedByAbsolutePaths(Span), ElidedLifetimesInPaths(usize, Span, bool, Span, String), UnknownCrateTypes(Span, String, String), UnusedImports(String, Vec<(Span, String)>), @@ -506,9 +497,6 @@ impl BuiltinLintDiagnostics { db.span_label(span, "names from parent modules are not \ accessible without an explicit import"); } - BuiltinLintDiagnostics::MacroExpandedMacroExportsAccessedByAbsolutePaths(span_def) => { - db.span_note(span_def, "the macro is defined here"); - } BuiltinLintDiagnostics::ElidedLifetimesInPaths( n, path_span, incl_angl_brckt, insertion_span, anon_lts ) => { diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 3f1dad9624179..5a8313d10acc6 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -368,11 +368,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { reference: "issue #50504 ", edition: None, }, - FutureIncompatibleInfo { - id: LintId::of(MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS), - reference: "issue #52234 ", - edition: None, - }, FutureIncompatibleInfo { id: LintId::of(ILL_FORMED_ATTRIBUTE_INPUT), reference: "issue #57571 ", @@ -467,6 +462,8 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { "converted into hard error, see https://github.com/rust-lang/rust/issues/42238"); store.register_removed("duplicate_macro_exports", "converted into hard error, see https://github.com/rust-lang/rust/issues/35896"); + store.register_removed("macro_expanded_macro_exports_accessed_by_absolute_paths", + "converted into hard error, see https://github.com/rust-lang/rust/issues/52234"); } pub fn register_internals(store: &mut lint::LintStore, sess: Option<&Session>) { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index c44b554982c9a..822483ae65125 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -4746,14 +4746,13 @@ impl<'a> Resolver<'a> { self.report_with_use_injections(krate); for &(span_use, span_def) in &self.macro_expanded_macro_export_errors { - let msg = "macro-expanded `macro_export` macros from the current crate \ - cannot be referred to by absolute paths"; - self.session.buffer_lint_with_diagnostic( - lint::builtin::MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS, - CRATE_NODE_ID, span_use, msg, - lint::builtin::BuiltinLintDiagnostics:: - MacroExpandedMacroExportsAccessedByAbsolutePaths(span_def), - ); + self.session.struct_span_err( + span_use, + "macro-expanded `macro_export` macros from the current crate \ + cannot be referred to by absolute paths", + ) + .span_note(span_def, "the macro is defined here") + .emit(); } for ambiguity_error in &self.ambiguity_errors { diff --git a/src/test/ui/imports/local-modularized-tricky-fail-3.rs b/src/test/ui/imports/local-modularized-tricky-fail-3.rs index 386de88bc3d62..2a8aa5f9ed1e5 100644 --- a/src/test/ui/imports/local-modularized-tricky-fail-3.rs +++ b/src/test/ui/imports/local-modularized-tricky-fail-3.rs @@ -12,11 +12,9 @@ define_exported!(); mod m { use exported; //~^ ERROR macro-expanded `macro_export` macros from the current crate cannot - //~| WARN this was previously accepted } fn main() { ::exported!(); //~^ ERROR macro-expanded `macro_export` macros from the current crate cannot - //~| WARN this was previously accepted } diff --git a/src/test/ui/imports/local-modularized-tricky-fail-3.stderr b/src/test/ui/imports/local-modularized-tricky-fail-3.stderr index 5272d2a319faa..fdf74cab4acc3 100644 --- a/src/test/ui/imports/local-modularized-tricky-fail-3.stderr +++ b/src/test/ui/imports/local-modularized-tricky-fail-3.stderr @@ -4,9 +4,6 @@ error: macro-expanded `macro_export` macros from the current crate cannot be ref LL | use exported; | ^^^^^^^^ | - = note: `#[deny(macro_expanded_macro_exports_accessed_by_absolute_paths)]` on by default - = 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 #52234 note: the macro is defined here --> $DIR/local-modularized-tricky-fail-3.rs:5:5 | @@ -19,13 +16,11 @@ LL | define_exported!(); | ------------------- in this macro invocation error: macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths - --> $DIR/local-modularized-tricky-fail-3.rs:19:5 + --> $DIR/local-modularized-tricky-fail-3.rs:18:5 | LL | ::exported!(); | ^^^^^^^^^^ | - = 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 #52234 note: the macro is defined here --> $DIR/local-modularized-tricky-fail-3.rs:5:5 | From 962d4ecf09409ae5cc975a738d92c5d7b793de96 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 21:59:22 +0200 Subject: [PATCH 09/12] nested_impl_trait -> deny --- src/librustc/lint/builtin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index d1f9de081fd05..e56cb06fcd342 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -335,7 +335,7 @@ declare_lint! { declare_lint! { pub NESTED_IMPL_TRAIT, - Warn, + Deny, "nested occurrence of `impl Trait` type" } From 13d2d7f63b1e1c99b0cd15dcad46bfeceab0f110 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 22:07:07 +0200 Subject: [PATCH 10/12] ill_formed_attribute_input -> deny --- src/librustc/lint/builtin.rs | 2 +- .../issue-43106-gating-of-inline.rs | 2 +- .../issue-43106-gating-of-inline.stderr | 6 ++--- .../ui/malformed/malformed-regressions.rs | 16 +++++++++----- .../ui/malformed/malformed-regressions.stderr | 22 ++++++++++--------- 5 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index e56cb06fcd342..c5c59b78868f9 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -309,7 +309,7 @@ declare_lint! { pub mod parser { declare_lint! { pub ILL_FORMED_ATTRIBUTE_INPUT, - Warn, + Deny, "ill-formed attribute inputs that were previously accepted and used in practice" } diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-inline.rs b/src/test/ui/feature-gate/issue-43106-gating-of-inline.rs index bb9e6d4ca83b0..80c602eb00afb 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-inline.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-inline.rs @@ -15,7 +15,7 @@ mod inline { //~^ ERROR attribute should be applied to function or closure #[inline = "2100"] fn f() { } - //~^ WARN attribute must be of the form + //~^ ERROR attribute must be of the form //~| WARN this was previously accepted #[inline] struct S; diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-inline.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-inline.stderr index 4310a0c7d588e..0987937192fe2 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-inline.stderr +++ b/src/test/ui/feature-gate/issue-43106-gating-of-inline.stderr @@ -1,10 +1,10 @@ -warning: attribute must be of the form `#[inline]` or `#[inline(always|never)]` +error: attribute must be of the form `#[inline]` or `#[inline(always|never)]` --> $DIR/issue-43106-gating-of-inline.rs:17:5 | LL | #[inline = "2100"] fn f() { } | ^^^^^^^^^^^^^^^^^^ | - = note: `#[warn(ill_formed_attribute_input)]` on by default + = note: `#[deny(ill_formed_attribute_input)]` on by default = 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 #57571 @@ -47,6 +47,6 @@ error[E0518]: attribute should be applied to function or closure LL | #[inline] impl S { } | ^^^^^^^^^ ---------- not a function or closure -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0518`. diff --git a/src/test/ui/malformed/malformed-regressions.rs b/src/test/ui/malformed/malformed-regressions.rs index c1a9d04e6d5cb..ac1444bbaef4e 100644 --- a/src/test/ui/malformed/malformed-regressions.rs +++ b/src/test/ui/malformed/malformed-regressions.rs @@ -1,8 +1,12 @@ -// build-pass (FIXME(62277): could be check-pass?) +#[doc] //~ ERROR attribute must be of the form +//~^ WARN this was previously accepted +#[ignore()] //~ ERROR attribute must be of the form +//~^ WARN this was previously accepted +#[inline = ""] //~ ERROR attribute must be of the form +//~^ WARN this was previously accepted +#[link] //~ ERROR attribute must be of the form +//~^ WARN this was previously accepted +#[link = ""] //~ ERROR attribute must be of the form +//~^ WARN this was previously accepted -#[doc] //~ WARN attribute must be of the form -#[ignore()] //~ WARN attribute must be of the form -#[inline = ""] //~ WARN attribute must be of the form -#[link] //~ WARN attribute must be of the form -#[link = ""] //~ WARN attribute must be of the form fn main() {} diff --git a/src/test/ui/malformed/malformed-regressions.stderr b/src/test/ui/malformed/malformed-regressions.stderr index eebb6f0623fbf..8d1c18ce681cb 100644 --- a/src/test/ui/malformed/malformed-regressions.stderr +++ b/src/test/ui/malformed/malformed-regressions.stderr @@ -1,15 +1,15 @@ -warning: attribute must be of the form `#[doc(hidden|inline|...)]` or `#[doc = "string"]` - --> $DIR/malformed-regressions.rs:3:1 +error: attribute must be of the form `#[doc(hidden|inline|...)]` or `#[doc = "string"]` + --> $DIR/malformed-regressions.rs:1:1 | LL | #[doc] | ^^^^^^ | - = note: `#[warn(ill_formed_attribute_input)]` on by default + = note: `#[deny(ill_formed_attribute_input)]` on by default = 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 #57571 -warning: attribute must be of the form `#[ignore]` or `#[ignore = "reason"]` - --> $DIR/malformed-regressions.rs:4:1 +error: attribute must be of the form `#[ignore]` or `#[ignore = "reason"]` + --> $DIR/malformed-regressions.rs:3:1 | LL | #[ignore()] | ^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | #[ignore()] = 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 #57571 -warning: attribute must be of the form `#[inline]` or `#[inline(always|never)]` +error: attribute must be of the form `#[inline]` or `#[inline(always|never)]` --> $DIR/malformed-regressions.rs:5:1 | LL | #[inline = ""] @@ -26,9 +26,9 @@ LL | #[inline = ""] = 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 #57571 -warning: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", +error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ cfg = "...")]` - --> $DIR/malformed-regressions.rs:6:1 + --> $DIR/malformed-regressions.rs:7:1 | LL | #[link] | ^^^^^^^ @@ -36,9 +36,9 @@ LL | #[link] = 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 #57571 -warning: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", +error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ cfg = "...")]` - --> $DIR/malformed-regressions.rs:7:1 + --> $DIR/malformed-regressions.rs:9:1 | LL | #[link = ""] | ^^^^^^^^^^^^ @@ -46,3 +46,5 @@ LL | #[link = ""] = 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 #57571 +error: aborting due to 5 previous errors + From 32a18ecedd72739c7b70166ceac084d3075ef137 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 22:22:07 +0200 Subject: [PATCH 11/12] tuple indexing macro compat -> error --- src/libsyntax/parse/literal.rs | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/src/libsyntax/parse/literal.rs b/src/libsyntax/parse/literal.rs index 6409acba573ad..c12052b17745f 100644 --- a/src/libsyntax/parse/literal.rs +++ b/src/libsyntax/parse/literal.rs @@ -354,31 +354,19 @@ impl<'a> Parser<'a> { crate fn expect_no_suffix(diag: &Handler, sp: Span, kind: &str, suffix: Option) { if let Some(suf) = suffix { - let mut err = if kind == "a tuple index" && - [sym::i32, sym::u32, sym::isize, sym::usize].contains(&suf) { - // #59553: warn instead of reject out of hand to allow the fix to percolate - // through the ecosystem when people fix their macros - let mut err = diag.struct_span_warn( - sp, - &format!("suffixes on {} are invalid", kind), - ); - err.note(&format!( - "`{}` is *temporarily* accepted on tuple index fields as it was \ - incorrectly accepted on stable for a few releases", - suf, - )); + let mut err = diag.struct_span_err(sp, &format!("suffixes on {} are invalid", kind)); + + if kind == "a tuple index" + && [sym::i32, sym::u32, sym::isize, sym::usize].contains(&suf) + { err.help( "on proc macros, you'll want to use `syn::Index::from` or \ - `proc_macro::Literal::*_unsuffixed` for code that will desugar \ - to tuple field access", - ); - err.note( - "for more context, see https://github.com/rust-lang/rust/issues/60210", + `proc_macro::Literal::*_unsuffixed` for code that will desugar \ + to tuple field access", ); - err - } else { - diag.struct_span_err(sp, &format!("suffixes on {} are invalid", kind)) - }; + err.note("for more context, see https://github.com/rust-lang/rust/issues/60210"); + } + err.span_label(sp, format!("invalid suffix `{}`", suf)); err.emit(); } From f213acf659a8178260989e0f10b623470ba704c3 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 22:33:19 +0200 Subject: [PATCH 12/12] patterns_in_fns_without_body -> deny --- src/librustc/lint/builtin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index c5c59b78868f9..7e179f5d3db87 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -153,7 +153,7 @@ declare_lint! { declare_lint! { pub PATTERNS_IN_FNS_WITHOUT_BODY, - Warn, + Deny, "patterns in functions without body were erroneously allowed" }