Skip to content

Commit 29b777b

Browse files
committed
parenthesized_params_in_types_and_modules -> error
1 parent 3b9128d commit 29b777b

File tree

10 files changed

+46
-151
lines changed

10 files changed

+46
-151
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
@@ -89,31 +89,6 @@ error: literal out of range for u8
8989
|
9090
```
9191

92-
## parenthesized-params-in-types-and-modules
93-
94-
This lint detects incorrect parentheses. Some example code that triggers this
95-
lint:
96-
97-
```rust,ignore
98-
let x = 5 as usize();
99-
```
100-
101-
This will produce:
102-
103-
```text
104-
error: parenthesized parameters may only be used with a trait
105-
--> src/main.rs:2:21
106-
|
107-
2 | let x = 5 as usize();
108-
| ^^
109-
|
110-
= note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default
111-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
112-
= note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>
113-
```
114-
115-
To fix it, remove the `()`s.
116-
11792
## pub-use-of-private-extern-crate
11893

11994
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
@@ -40,8 +40,7 @@ use crate::hir::def_id::{DefId, DefIndex, CRATE_DEF_INDEX};
4040
use crate::hir::def::{Res, DefKind, PartialRes, PerNS};
4141
use crate::hir::{GenericArg, ConstArg};
4242
use crate::hir::ptr::P;
43-
use crate::lint::builtin::{self, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
44-
ELIDED_LIFETIMES_IN_PATHS};
43+
use crate::lint::builtin::{self, ELIDED_LIFETIMES_IN_PATHS};
4544
use crate::middle::cstore::CrateStore;
4645
use crate::session::Session;
4746
use crate::session::config::nightly_options;
@@ -286,7 +285,6 @@ enum ParamMode {
286285

287286
enum ParenthesizedGenericArgs {
288287
Ok,
289-
Warn,
290288
Err,
291289
}
292290

@@ -2057,29 +2055,19 @@ impl<'a> LoweringContext<'a> {
20572055
};
20582056
let parenthesized_generic_args = match partial_res.base_res() {
20592057
// `a::b::Trait(Args)`
2060-
Res::Def(DefKind::Trait, _)
2061-
if i + 1 == proj_start => ParenthesizedGenericArgs::Ok,
2058+
Res::Def(DefKind::Trait, _) if i + 1 == proj_start => {
2059+
ParenthesizedGenericArgs::Ok
2060+
}
20622061
// `a::b::Trait(Args)::TraitItem`
2063-
Res::Def(DefKind::Method, _)
2064-
| Res::Def(DefKind::AssocConst, _)
2065-
| Res::Def(DefKind::AssocTy, _)
2066-
if i + 2 == proj_start =>
2067-
{
2062+
Res::Def(DefKind::Method, _) |
2063+
Res::Def(DefKind::AssocConst, _) |
2064+
Res::Def(DefKind::AssocTy, _) if i + 2 == proj_start => {
20682065
ParenthesizedGenericArgs::Ok
20692066
}
20702067
// Avoid duplicated errors.
20712068
Res::Err => ParenthesizedGenericArgs::Ok,
20722069
// An error
2073-
Res::Def(DefKind::Struct, _)
2074-
| Res::Def(DefKind::Enum, _)
2075-
| Res::Def(DefKind::Union, _)
2076-
| Res::Def(DefKind::TyAlias, _)
2077-
| Res::Def(DefKind::Variant, _) if i + 1 == proj_start =>
2078-
{
2079-
ParenthesizedGenericArgs::Err
2080-
}
2081-
// A warning for now, for compatibility reasons.
2082-
_ => ParenthesizedGenericArgs::Warn,
2070+
_ => ParenthesizedGenericArgs::Err,
20832071
};
20842072

20852073
let num_lifetimes = type_def_id.map_or(0, |def_id| {
@@ -2142,7 +2130,7 @@ impl<'a> LoweringContext<'a> {
21422130
segment,
21432131
param_mode,
21442132
0,
2145-
ParenthesizedGenericArgs::Warn,
2133+
ParenthesizedGenericArgs::Err,
21462134
itctx.reborrow(),
21472135
None,
21482136
));
@@ -2218,15 +2206,6 @@ impl<'a> LoweringContext<'a> {
22182206
}
22192207
GenericArgs::Parenthesized(ref data) => match parenthesized_generic_args {
22202208
ParenthesizedGenericArgs::Ok => self.lower_parenthesized_parameter_data(data),
2221-
ParenthesizedGenericArgs::Warn => {
2222-
self.sess.buffer_lint(
2223-
PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
2224-
CRATE_NODE_ID,
2225-
data.span,
2226-
msg.into(),
2227-
);
2228-
(hir::GenericArgs::none(), true)
2229-
}
22302209
ParenthesizedGenericArgs::Err => {
22312210
let mut err = struct_span_err!(self.sess, data.span, E0214, "{}", msg);
22322211
err.span_label(data.span, "only `Fn` traits may use parentheses");

src/librustc/lint/builtin.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,6 @@ declare_lint! {
157157
"patterns in functions without body were erroneously allowed"
158158
}
159159

160-
declare_lint! {
161-
pub PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
162-
Deny,
163-
"detects parenthesized generic parameters in type and module names"
164-
}
165-
166160
declare_lint! {
167161
pub LATE_BOUND_LIFETIME_ARGUMENTS,
168162
Warn,
@@ -393,7 +387,6 @@ declare_lint_pass! {
393387
RENAMED_AND_REMOVED_LINTS,
394388
SAFE_PACKED_BORROWS,
395389
PATTERNS_IN_FNS_WITHOUT_BODY,
396-
PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
397390
LATE_BOUND_LIFETIME_ARGUMENTS,
398391
ORDER_DEPENDENT_TRAIT_OBJECTS,
399392
DEPRECATED,

src/librustc_lint/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
331331
reference: "issue #41686 <https://github.com/rust-lang/rust/issues/41686>",
332332
edition: Some(Edition::Edition2018),
333333
},
334-
FutureIncompatibleInfo {
335-
id: LintId::of(PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES),
336-
reference: "issue #42238 <https://github.com/rust-lang/rust/issues/42238>",
337-
edition: None,
338-
},
339334
FutureIncompatibleInfo {
340335
id: LintId::of(LATE_BOUND_LIFETIME_ARGUMENTS),
341336
reference: "issue #42868 <https://github.com/rust-lang/rust/issues/42868>",
@@ -473,6 +468,8 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
473468
"converted into hard error, see https://github.com/rust-lang/rust/issues/36887");
474469
store.register_removed("safe_extern_statics",
475470
"converted into hard error, see https://github.com/rust-lang/rust/issues/36247");
471+
store.register_removed("parenthesized_params_in_types_and_modules",
472+
"converted into hard error, see https://github.com/rust-lang/rust/issues/42238");
476473
}
477474

478475
pub fn register_internals(store: &mut lint::LintStore, sess: Option<&Session>) {

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:28
1+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
2+
--> $DIR/issue-32995-2.rs:2:28
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:35
7+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
8+
--> $DIR/issue-32995-2.rs:5:35
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:19
13+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
14+
--> $DIR/issue-32995-2.rs:12:19
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:17
1+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
2+
--> $DIR/issue-32995.rs:2:17
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:24
7+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
8+
--> $DIR/issue-32995.rs:5:24
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:25
13+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
14+
--> $DIR/issue-32995.rs:8:25
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:36
19+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
20+
--> $DIR/issue-32995.rs:11:36
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:35
25+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
26+
--> $DIR/issue-32995.rs:14:35
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:41
31+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
32+
--> $DIR/issue-32995.rs:17:41
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:14
37+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
38+
--> $DIR/issue-32995.rs:22:14
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/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

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ error[E0425]: cannot find value `input_cells` in this scope
44
LL | input_cells: Vec::new()
55
| ^^^^^^^^^^^ a field by this name exists in `Self`
66

7-
error: parenthesized type parameters may only be used with a `Fn` trait
7+
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
88
--> $DIR/issue-34255-1.rs:7:30
99
|
1010
LL | input_cells: Vec::new()
11-
| ^^
12-
|
13-
= note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default
14-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
15-
= note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>
11+
| ^^ only `Fn` traits may use parentheses
1612

1713
error[E0601]: `main` function not found in crate `issue_34255_1`
1814
|
@@ -26,5 +22,5 @@ LL | input_cells: Vec::new()
2622

2723
error: aborting due to 4 previous errors
2824

29-
Some errors have detailed explanations: E0107, E0425, E0601.
25+
Some errors have detailed explanations: E0107, E0214, E0425, E0601.
3026
For more information about an error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)