Skip to content

Commit b54c578

Browse files
committed
parenthesized_params_in_types_and_modules -> error
1 parent 98d2c51 commit b54c578

File tree

12 files changed

+59
-158
lines changed

12 files changed

+59
-158
lines changed

src/doc/rustc/src/lints/listing/deny-by-default.md

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -122,31 +122,6 @@ error: literal out of range for u8
122122
|
123123
```
124124

125-
## parenthesized-params-in-types-and-modules
126-
127-
This lint detects incorrect parentheses. Some example code that triggers this
128-
lint:
129-
130-
```rust,ignore
131-
let x = 5 as usize();
132-
```
133-
134-
This will produce:
135-
136-
```text
137-
error: parenthesized parameters may only be used with a trait
138-
--> src/main.rs:2:21
139-
|
140-
2 | let x = 5 as usize();
141-
| ^^
142-
|
143-
= note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default
144-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
145-
= note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>
146-
```
147-
148-
To fix it, remove the `()`s.
149-
150125
## pub-use-of-private-extern-crate
151126

152127
This lint detects a specific situation of re-exporting a private `extern crate`;

src/librustc/hir/lowering.rs

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ use crate::hir::def::{Namespace, Res, DefKind, PartialRes, PerNS};
4444
use crate::hir::{GenericArg, ConstArg};
4545
use crate::hir::ptr::P;
4646
use crate::lint;
47-
use crate::lint::builtin::{self, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
48-
ELIDED_LIFETIMES_IN_PATHS};
47+
use crate::lint::builtin::{self, ELIDED_LIFETIMES_IN_PATHS};
4948
use crate::middle::cstore::CrateStore;
5049
use crate::session::Session;
5150
use crate::session::config::nightly_options;
@@ -298,7 +297,6 @@ enum ParamMode {
298297

299298
enum ParenthesizedGenericArgs {
300299
Ok,
301-
Warn,
302300
Err,
303301
}
304302

@@ -1695,29 +1693,19 @@ impl<'a> LoweringContext<'a> {
16951693
};
16961694
let parenthesized_generic_args = match partial_res.base_res() {
16971695
// `a::b::Trait(Args)`
1698-
Res::Def(DefKind::Trait, _)
1699-
if i + 1 == proj_start => ParenthesizedGenericArgs::Ok,
1696+
Res::Def(DefKind::Trait, _) if i + 1 == proj_start => {
1697+
ParenthesizedGenericArgs::Ok
1698+
}
17001699
// `a::b::Trait(Args)::TraitItem`
1701-
Res::Def(DefKind::Method, _)
1702-
| Res::Def(DefKind::AssocConst, _)
1703-
| Res::Def(DefKind::AssocTy, _)
1704-
if i + 2 == proj_start =>
1705-
{
1700+
Res::Def(DefKind::Method, _) |
1701+
Res::Def(DefKind::AssocConst, _) |
1702+
Res::Def(DefKind::AssocTy, _) if i + 2 == proj_start => {
17061703
ParenthesizedGenericArgs::Ok
17071704
}
17081705
// Avoid duplicated errors.
17091706
Res::Err => ParenthesizedGenericArgs::Ok,
17101707
// An error
1711-
Res::Def(DefKind::Struct, _)
1712-
| Res::Def(DefKind::Enum, _)
1713-
| Res::Def(DefKind::Union, _)
1714-
| Res::Def(DefKind::TyAlias, _)
1715-
| Res::Def(DefKind::Variant, _) if i + 1 == proj_start =>
1716-
{
1717-
ParenthesizedGenericArgs::Err
1718-
}
1719-
// A warning for now, for compatibility reasons.
1720-
_ => ParenthesizedGenericArgs::Warn,
1708+
_ => ParenthesizedGenericArgs::Err,
17211709
};
17221710

17231711
let num_lifetimes = type_def_id.map_or(0, |def_id| {
@@ -1780,7 +1768,7 @@ impl<'a> LoweringContext<'a> {
17801768
segment,
17811769
param_mode,
17821770
0,
1783-
ParenthesizedGenericArgs::Warn,
1771+
ParenthesizedGenericArgs::Err,
17841772
itctx.reborrow(),
17851773
None,
17861774
));
@@ -1856,15 +1844,6 @@ impl<'a> LoweringContext<'a> {
18561844
}
18571845
GenericArgs::Parenthesized(ref data) => match parenthesized_generic_args {
18581846
ParenthesizedGenericArgs::Ok => self.lower_parenthesized_parameter_data(data),
1859-
ParenthesizedGenericArgs::Warn => {
1860-
self.resolver.lint_buffer().buffer_lint(
1861-
PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
1862-
CRATE_NODE_ID,
1863-
data.span,
1864-
msg.into(),
1865-
);
1866-
(hir::GenericArgs::none(), true)
1867-
}
18681847
ParenthesizedGenericArgs::Err => {
18691848
let mut err = struct_span_err!(self.sess, data.span, E0214, "{}", msg);
18701849
err.span_label(data.span, "only `Fn` traits may use parentheses");

src/librustc/lint/builtin.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,6 @@ declare_lint! {
207207
};
208208
}
209209

210-
declare_lint! {
211-
pub PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
212-
Deny,
213-
"detects parenthesized generic parameters in type and module names",
214-
@future_incompatible = FutureIncompatibleInfo {
215-
reference: "issue #42238 <https://github.com/rust-lang/rust/issues/42238>",
216-
edition: None,
217-
};
218-
}
219-
220210
declare_lint! {
221211
pub LATE_BOUND_LIFETIME_ARGUMENTS,
222212
Warn,
@@ -528,7 +518,6 @@ declare_lint_pass! {
528518
SAFE_PACKED_BORROWS,
529519
PATTERNS_IN_FNS_WITHOUT_BODY,
530520
MISSING_FRAGMENT_SPECIFIER,
531-
PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
532521
LATE_BOUND_LIFETIME_ARGUMENTS,
533522
ORDER_DEPENDENT_TRAIT_OBJECTS,
534523
DEPRECATED,

src/librustc_lint/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ fn register_builtins(store: &mut lint::LintStore, no_interleave_lints: bool) {
340340
"converted into hard error, see https://github.com/rust-lang/rust/issues/37872");
341341
store.register_removed("safe_extern_statics",
342342
"converted into hard error, see https://github.com/rust-lang/rust/issues/36247");
343+
store.register_removed("parenthesized_params_in_types_and_modules",
344+
"converted into hard error, see https://github.com/rust-lang/rust/issues/42238");
343345
}
344346

345347
fn register_internals(store: &mut lint::LintStore) {

src/test/ui/issues/issue-32995-2.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
#![allow(unused)]
2-
31
fn main() {
42
{ fn f<X: ::std::marker()::Send>() {} }
53
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
6-
//~| WARN previously accepted
74

85
{ fn f() -> impl ::std::marker()::Send { } }
96
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
10-
//~| WARN previously accepted
117
}
128

139
#[derive(Clone)]
1410
struct X;
1511

1612
impl ::std::marker()::Copy for X {}
1713
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
18-
//~| WARN previously accepted
Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
1-
error: parenthesized type parameters may only be used with a `Fn` trait
2-
--> $DIR/issue-32995-2.rs:4:22
1+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
2+
--> $DIR/issue-32995-2.rs:2:22
33
|
44
LL | { fn f<X: ::std::marker()::Send>() {} }
5-
| ^^^^^^^^
6-
|
7-
= note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default
8-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
9-
= note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>
5+
| ^^^^^^^^ only `Fn` traits may use parentheses
106

11-
error: parenthesized type parameters may only be used with a `Fn` trait
12-
--> $DIR/issue-32995-2.rs:8:29
7+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
8+
--> $DIR/issue-32995-2.rs:5:29
139
|
1410
LL | { fn f() -> impl ::std::marker()::Send { } }
15-
| ^^^^^^^^
16-
|
17-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
18-
= note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>
11+
| ^^^^^^^^ only `Fn` traits may use parentheses
1912

20-
error: parenthesized type parameters may only be used with a `Fn` trait
21-
--> $DIR/issue-32995-2.rs:16:13
13+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
14+
--> $DIR/issue-32995-2.rs:12:13
2215
|
2316
LL | impl ::std::marker()::Copy for X {}
24-
| ^^^^^^^^
25-
|
26-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
27-
= note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>
17+
| ^^^^^^^^ only `Fn` traits may use parentheses
2818

2919
error: aborting due to 3 previous errors
3020

21+
For more information about this error, try `rustc --explain E0214`.

src/test/ui/issues/issue-32995.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,24 @@
1-
#![allow(unused)]
2-
31
fn main() {
42
let x: usize() = 1;
53
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
6-
//~| WARN previously accepted
74

85
let b: ::std::boxed()::Box<_> = Box::new(1);
96
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
10-
//~| WARN previously accepted
117

128
let p = ::std::str::()::from_utf8(b"foo").unwrap();
139
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
14-
//~| WARN previously accepted
1510

1611
let p = ::std::str::from_utf8::()(b"foo").unwrap();
1712
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
18-
//~| WARN previously accepted
1913

2014
let o : Box<dyn (::std::marker()::Send)> = Box::new(1);
2115
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
22-
//~| WARN previously accepted
2316

2417
let o : Box<dyn Send + ::std::marker()::Sync> = Box::new(1);
2518
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
26-
//~| WARN previously accepted
2719
}
2820

2921
fn foo<X:Default>() {
3022
let d : X() = Default::default();
3123
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
32-
//~| WARN previously accepted
3324
}

src/test/ui/issues/issue-32995.stderr

Lines changed: 22 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,45 @@
1-
error: parenthesized type parameters may only be used with a `Fn` trait
2-
--> $DIR/issue-32995.rs:4:12
1+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
2+
--> $DIR/issue-32995.rs:2:12
33
|
44
LL | let x: usize() = 1;
5-
| ^^^^^^^
6-
|
7-
= note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default
8-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
9-
= note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>
5+
| ^^^^^^^ only `Fn` traits may use parentheses
106

11-
error: parenthesized type parameters may only be used with a `Fn` trait
12-
--> $DIR/issue-32995.rs:8:19
7+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
8+
--> $DIR/issue-32995.rs:5:19
139
|
1410
LL | let b: ::std::boxed()::Box<_> = Box::new(1);
15-
| ^^^^^^^
16-
|
17-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
18-
= note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>
11+
| ^^^^^^^ only `Fn` traits may use parentheses
1912

20-
error: parenthesized type parameters may only be used with a `Fn` trait
21-
--> $DIR/issue-32995.rs:12:20
13+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
14+
--> $DIR/issue-32995.rs:8:20
2215
|
2316
LL | let p = ::std::str::()::from_utf8(b"foo").unwrap();
24-
| ^^^^^^^
25-
|
26-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
27-
= note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>
17+
| ^^^^^^^ only `Fn` traits may use parentheses
2818

29-
error: parenthesized type parameters may only be used with a `Fn` trait
30-
--> $DIR/issue-32995.rs:16:25
19+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
20+
--> $DIR/issue-32995.rs:11:25
3121
|
3222
LL | let p = ::std::str::from_utf8::()(b"foo").unwrap();
33-
| ^^^^^^^^^^^^^
34-
|
35-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
36-
= note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>
23+
| ^^^^^^^^^^^^^ only `Fn` traits may use parentheses
3724

38-
error: parenthesized type parameters may only be used with a `Fn` trait
39-
--> $DIR/issue-32995.rs:20:29
25+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
26+
--> $DIR/issue-32995.rs:14:29
4027
|
4128
LL | let o : Box<dyn (::std::marker()::Send)> = Box::new(1);
42-
| ^^^^^^^^
43-
|
44-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
45-
= note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>
29+
| ^^^^^^^^ only `Fn` traits may use parentheses
4630

47-
error: parenthesized type parameters may only be used with a `Fn` trait
48-
--> $DIR/issue-32995.rs:24:35
31+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
32+
--> $DIR/issue-32995.rs:17:35
4933
|
5034
LL | let o : Box<dyn Send + ::std::marker()::Sync> = Box::new(1);
51-
| ^^^^^^^^
52-
|
53-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
54-
= note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>
35+
| ^^^^^^^^ only `Fn` traits may use parentheses
5536

56-
error: parenthesized type parameters may only be used with a `Fn` trait
57-
--> $DIR/issue-32995.rs:30:13
37+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
38+
--> $DIR/issue-32995.rs:22:13
5839
|
5940
LL | let d : X() = Default::default();
60-
| ^^^
61-
|
62-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
63-
= note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>
41+
| ^^^ only `Fn` traits may use parentheses
6442

6543
error: aborting due to 7 previous errors
6644

45+
For more information about this error, try `rustc --explain E0214`.

src/test/ui/suggestions/let-binding-init-expr-as-ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
pub fn foo(num: i32) -> i32 {
22
let foo: i32::from_be(num);
33
//~^ ERROR expected type, found local variable `num`
4+
//~| ERROR type arguments are not allowed for this type
45
//~| ERROR parenthesized type parameters may only be used with a `Fn` trait
56
//~| ERROR ambiguous associated type
6-
//~| WARNING this was previously accepted by the compiler but is being phased out
77
foo
88
}
99

src/test/ui/suggestions/let-binding-init-expr-as-ty.stderr

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,28 @@ LL | let foo: i32::from_be(num);
66
| |
77
| help: use `=` if you meant to assign
88

9-
error: parenthesized type parameters may only be used with a `Fn` trait
9+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
1010
--> $DIR/let-binding-init-expr-as-ty.rs:2:19
1111
|
1212
LL | let foo: i32::from_be(num);
1313
| ^^^^^^^^^^^^
14+
| |
15+
| only `Fn` traits may use parentheses
16+
| help: use angle brackets instead: `from_be<num>`
17+
18+
error[E0109]: type arguments are not allowed for this type
19+
--> $DIR/let-binding-init-expr-as-ty.rs:2:27
1420
|
15-
= note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default
16-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
17-
= note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>
21+
LL | let foo: i32::from_be(num);
22+
| ^^^ type argument not allowed
1823

1924
error[E0223]: ambiguous associated type
2025
--> $DIR/let-binding-init-expr-as-ty.rs:2:14
2126
|
2227
LL | let foo: i32::from_be(num);
2328
| ^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<i32 as Trait>::from_be`
2429

25-
error: aborting due to 3 previous errors
30+
error: aborting due to 4 previous errors
2631

27-
Some errors have detailed explanations: E0223, E0573.
28-
For more information about an error, try `rustc --explain E0223`.
32+
Some errors have detailed explanations: E0109, E0214, E0223, E0573.
33+
For more information about an error, try `rustc --explain E0109`.

src/test/ui/type/ascription/issue-34255-1.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ impl Reactor {
88
//~^ ERROR cannot find value `input_cells` in this scope
99
//~| ERROR parenthesized type parameters may only be used with a `Fn` trait
1010
//~| ERROR wrong number of type arguments: expected 1, found 0
11-
//~| WARNING this was previously accepted by the compiler but is being phased out
1211
}
1312
}
1413

0 commit comments

Comments
 (0)