about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-08-03 19:58:26 +0200
committerMazdak Farrokhzad <twingoow@gmail.com>2019-11-06 11:10:37 +0100
commitb54c5781b8252189f04a58247f644bcf2bd9dd68 (patch)
treea36b4ff5dfb4d607114e8ef33b96d6c6fddbf361
parent98d2c510dd121d31061ae95b41a5afb3386d17e3 (diff)
downloadrust-b54c5781b8252189f04a58247f644bcf2bd9dd68.tar.gz
rust-b54c5781b8252189f04a58247f644bcf2bd9dd68.zip
parenthesized_params_in_types_and_modules -> error
-rw-r--r--src/doc/rustc/src/lints/listing/deny-by-default.md25
-rw-r--r--src/librustc/hir/lowering.rs39
-rw-r--r--src/librustc/lint/builtin.rs11
-rw-r--r--src/librustc_lint/lib.rs2
-rw-r--r--src/test/ui/issues/issue-32995-2.rs5
-rw-r--r--src/test/ui/issues/issue-32995-2.stderr29
-rw-r--r--src/test/ui/issues/issue-32995.rs9
-rw-r--r--src/test/ui/issues/issue-32995.stderr65
-rw-r--r--src/test/ui/suggestions/let-binding-init-expr-as-ty.rs2
-rw-r--r--src/test/ui/suggestions/let-binding-init-expr-as-ty.stderr19
-rw-r--r--src/test/ui/type/ascription/issue-34255-1.rs1
-rw-r--r--src/test/ui/type/ascription/issue-34255-1.stderr10
12 files changed, 59 insertions, 158 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 b349c68359c..466a748bcee 100644
--- a/src/doc/rustc/src/lints/listing/deny-by-default.md
+++ b/src/doc/rustc/src/lints/listing/deny-by-default.md
@@ -122,31 +122,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 <https://github.com/rust-lang/rust/issues/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 c8bb35202f5..9f5e5fae07f 100644
--- a/src/librustc/hir/lowering.rs
+++ b/src/librustc/hir/lowering.rs
@@ -44,8 +44,7 @@ use crate::hir::def::{Namespace, Res, DefKind, PartialRes, PerNS};
 use crate::hir::{GenericArg, ConstArg};
 use crate::hir::ptr::P;
 use crate::lint;
-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;
@@ -298,7 +297,6 @@ enum ParamMode {
 
 enum ParenthesizedGenericArgs {
     Ok,
-    Warn,
     Err,
 }
 
@@ -1695,29 +1693,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| {
@@ -1780,7 +1768,7 @@ impl<'a> LoweringContext<'a> {
                 segment,
                 param_mode,
                 0,
-                ParenthesizedGenericArgs::Warn,
+                ParenthesizedGenericArgs::Err,
                 itctx.reborrow(),
                 None,
             ));
@@ -1856,15 +1844,6 @@ impl<'a> LoweringContext<'a> {
                 }
                 GenericArgs::Parenthesized(ref data) => match parenthesized_generic_args {
                     ParenthesizedGenericArgs::Ok => self.lower_parenthesized_parameter_data(data),
-                    ParenthesizedGenericArgs::Warn => {
-                        self.resolver.lint_buffer().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 c1957df2e62..c9dd60827ff 100644
--- a/src/librustc/lint/builtin.rs
+++ b/src/librustc/lint/builtin.rs
@@ -208,16 +208,6 @@ declare_lint! {
 }
 
 declare_lint! {
-    pub PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
-    Deny,
-    "detects parenthesized generic parameters in type and module names",
-    @future_incompatible = FutureIncompatibleInfo {
-        reference: "issue #42238 <https://github.com/rust-lang/rust/issues/42238>",
-        edition: None,
-    };
-}
-
-declare_lint! {
     pub LATE_BOUND_LIFETIME_ARGUMENTS,
     Warn,
     "detects generic lifetime arguments in path segments with late bound lifetime parameters",
@@ -528,7 +518,6 @@ declare_lint_pass! {
         SAFE_PACKED_BORROWS,
         PATTERNS_IN_FNS_WITHOUT_BODY,
         MISSING_FRAGMENT_SPECIFIER,
-        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 5c10399d7db..c3c5589b9d0 100644
--- a/src/librustc_lint/lib.rs
+++ b/src/librustc_lint/lib.rs
@@ -340,6 +340,8 @@ fn register_builtins(store: &mut lint::LintStore, no_interleave_lints: bool) {
         "converted into hard error, see https://github.com/rust-lang/rust/issues/37872");
     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");
 }
 
 fn register_internals(store: &mut lint::LintStore) {
diff --git a/src/test/ui/issues/issue-32995-2.rs b/src/test/ui/issues/issue-32995-2.rs
index 2234f68f246..e713a64d3f5 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<X: ::std::marker()::Send>() {} }
     //~^ 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 976e3064db6..6c2d772a233 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:22
+error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
+  --> $DIR/issue-32995-2.rs:2:22
    |
 LL |     { fn f<X: ::std::marker()::Send>() {} }
-   |                      ^^^^^^^^
-   |
-   = 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 <https://github.com/rust-lang/rust/issues/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:29
+error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
+  --> $DIR/issue-32995-2.rs:5:29
    |
 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 <https://github.com/rust-lang/rust/issues/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:13
+error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
+  --> $DIR/issue-32995-2.rs:12:13
    |
 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 <https://github.com/rust-lang/rust/issues/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 3526deffc79..0d07a76939f 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<dyn (::std::marker()::Send)> = Box::new(1);
     //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
-    //~| WARN previously accepted
 
     let o : Box<dyn Send + ::std::marker()::Sync> = Box::new(1);
     //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
-    //~| WARN previously accepted
 }
 
 fn foo<X:Default>() {
     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 724e82a59dc..b868011b99b 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:12
+error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
+  --> $DIR/issue-32995.rs:2:12
    |
 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 <https://github.com/rust-lang/rust/issues/42238>
+   |            ^^^^^^^ only `Fn` traits may use parentheses
 
-error: parenthesized type parameters may only be used with a `Fn` trait
-  --> $DIR/issue-32995.rs:8:19
+error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
+  --> $DIR/issue-32995.rs:5:19
    |
 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 <https://github.com/rust-lang/rust/issues/42238>
+   |                   ^^^^^^^ only `Fn` traits may use parentheses
 
-error: parenthesized type parameters may only be used with a `Fn` trait
-  --> $DIR/issue-32995.rs:12:20
+error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
+  --> $DIR/issue-32995.rs:8:20
    |
 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 <https://github.com/rust-lang/rust/issues/42238>
+   |                    ^^^^^^^ only `Fn` traits may use parentheses
 
-error: parenthesized type parameters may only be used with a `Fn` trait
-  --> $DIR/issue-32995.rs:16:25
+error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
+  --> $DIR/issue-32995.rs:11: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 <https://github.com/rust-lang/rust/issues/42238>
+   |                         ^^^^^^^^^^^^^ only `Fn` traits may use parentheses
 
-error: parenthesized type parameters may only be used with a `Fn` trait
-  --> $DIR/issue-32995.rs:20:29
+error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
+  --> $DIR/issue-32995.rs:14:29
    |
 LL |     let o : Box<dyn (::std::marker()::Send)> = 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 <https://github.com/rust-lang/rust/issues/42238>
+   |                             ^^^^^^^^ only `Fn` traits may use parentheses
 
-error: parenthesized type parameters may only be used with a `Fn` trait
-  --> $DIR/issue-32995.rs:24:35
+error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
+  --> $DIR/issue-32995.rs:17:35
    |
 LL |     let o : Box<dyn Send + ::std::marker()::Sync> = 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 <https://github.com/rust-lang/rust/issues/42238>
+   |                                   ^^^^^^^^ only `Fn` traits may use parentheses
 
-error: parenthesized type parameters may only be used with a `Fn` trait
-  --> $DIR/issue-32995.rs:30:13
+error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
+  --> $DIR/issue-32995.rs:22:13
    |
 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 <https://github.com/rust-lang/rust/issues/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/suggestions/let-binding-init-expr-as-ty.rs b/src/test/ui/suggestions/let-binding-init-expr-as-ty.rs
index beea951a18a..94c72a31e5e 100644
--- a/src/test/ui/suggestions/let-binding-init-expr-as-ty.rs
+++ b/src/test/ui/suggestions/let-binding-init-expr-as-ty.rs
@@ -1,9 +1,9 @@
 pub fn foo(num: i32) -> i32 {
     let foo: i32::from_be(num);
     //~^ ERROR expected type, found local variable `num`
+    //~| ERROR type arguments are not allowed for this type
     //~| ERROR parenthesized type parameters may only be used with a `Fn` trait
     //~| ERROR ambiguous associated type
-    //~| WARNING this was previously accepted by the compiler but is being phased out
     foo
 }
 
diff --git a/src/test/ui/suggestions/let-binding-init-expr-as-ty.stderr b/src/test/ui/suggestions/let-binding-init-expr-as-ty.stderr
index a7c784fe827..5353b3a75b2 100644
--- a/src/test/ui/suggestions/let-binding-init-expr-as-ty.stderr
+++ b/src/test/ui/suggestions/let-binding-init-expr-as-ty.stderr
@@ -6,15 +6,20 @@ LL |     let foo: i32::from_be(num);
    |            |
    |            help: use `=` if you meant to assign
 
-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/let-binding-init-expr-as-ty.rs:2:19
    |
 LL |     let foo: i32::from_be(num);
    |                   ^^^^^^^^^^^^
+   |                   |
+   |                   only `Fn` traits may use parentheses
+   |                   help: use angle brackets instead: `from_be<num>`
+
+error[E0109]: type arguments are not allowed for this type
+  --> $DIR/let-binding-init-expr-as-ty.rs:2:27
    |
-   = 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 <https://github.com/rust-lang/rust/issues/42238>
+LL |     let foo: i32::from_be(num);
+   |                           ^^^ type argument not allowed
 
 error[E0223]: ambiguous associated type
   --> $DIR/let-binding-init-expr-as-ty.rs:2:14
@@ -22,7 +27,7 @@ error[E0223]: ambiguous associated type
 LL |     let foo: i32::from_be(num);
    |              ^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<i32 as Trait>::from_be`
 
-error: aborting due to 3 previous errors
+error: aborting due to 4 previous errors
 
-Some errors have detailed explanations: E0223, E0573.
-For more information about an error, try `rustc --explain E0223`.
+Some errors have detailed explanations: E0109, E0214, E0223, E0573.
+For more information about an error, try `rustc --explain E0109`.
diff --git a/src/test/ui/type/ascription/issue-34255-1.rs b/src/test/ui/type/ascription/issue-34255-1.rs
index c21d9f3d97c..c0d39c59014 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 0d0acfde886..7895cf77fc0 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:27
    |
 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 <https://github.com/rust-lang/rust/issues/42238>
+   |                           ^^^^^ only `Fn` traits may use parentheses
 
 error[E0107]: wrong number of type arguments: expected 1, found 0
   --> $DIR/issue-34255-1.rs:7:22
@@ -22,5 +18,5 @@ LL |         input_cells: Vec::new()
 
 error: aborting due to 3 previous errors
 
-Some errors have detailed explanations: E0107, E0425.
+Some errors have detailed explanations: E0107, E0214, E0425.
 For more information about an error, try `rustc --explain E0107`.