Skip to content

Commit 7ab50e4

Browse files
authored
Rollup merge of rust-lang#65785 - Centril:compat-to-error-2, r=oli-obk
Transition future compat lints to {ERROR, DENY} - Take 2 Follow up to rust-lang#63247 implementing rust-lang#63247 (comment). - `legacy_ctor_visibility` (ERROR) -- closes rust-lang#39207 - `legacy_directory_ownership` (ERROR) -- closes rust-lang#37872 - `safe_extern_static` (ERROR) -- closes rust-lang#36247 - `parenthesized_params_in_types_and_modules` (ERROR) -- closes rust-lang#42238 - `duplicate_macro_exports` (ERROR) - `nested_impl_trait` (ERROR) -- closes rust-lang#59014 - `ill_formed_attribute_input` (DENY) -- transitions rust-lang#57571 - `patterns_in_fns_without_body` (DENY) -- transitions rust-lang#35203 r? @varkor cc @petrochenkov
2 parents 76ade3e + 574d2b8 commit 7ab50e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+260
-804
lines changed

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

+27-64
Original file line numberDiff line numberDiff line change
@@ -45,53 +45,6 @@ error: defaults for type parameters are only allowed in `struct`, `enum`, `type`
4545
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
4646
```
4747

48-
## legacy-constructor-visibility
49-
50-
[RFC 1506](https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md) modified some
51-
visibility rules, and changed the visibility of struct constructors. Some
52-
example code that triggers this lint:
53-
54-
```rust,ignore
55-
mod m {
56-
pub struct S(u8);
57-
58-
fn f() {
59-
// this is trying to use S from the 'use' line, but because the `u8` is
60-
// not pub, it is private
61-
::S;
62-
}
63-
}
64-
65-
use m::S;
66-
```
67-
68-
This will produce:
69-
70-
```text
71-
error: private struct constructors are not usable through re-exports in outer modules
72-
--> src/main.rs:5:9
73-
|
74-
5 | ::S;
75-
| ^^^
76-
|
77-
= note: `#[deny(legacy_constructor_visibility)]` on by default
78-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
79-
= note: for more information, see issue #39207 <https://github.com/rust-lang/rust/issues/39207>
80-
```
81-
82-
83-
## legacy-directory-ownership
84-
85-
The legacy_directory_ownership warning is issued when
86-
87-
* There is a non-inline module with a `#[path]` attribute (e.g. `#[path = "foo.rs"] mod bar;`),
88-
* The module's file ("foo.rs" in the above example) is not named "mod.rs", and
89-
* The module's file contains a non-inline child module without a `#[path]` attribute.
90-
91-
The warning can be fixed by renaming the parent module to "mod.rs" and moving
92-
it into its own directory if appropriate.
93-
94-
9548
## missing-fragment-specifier
9649

9750
The missing_fragment_specifier warning is issued when an unused pattern in a
@@ -169,39 +122,49 @@ error: literal out of range for u8
169122
|
170123
```
171124

172-
## parenthesized-params-in-types-and-modules
125+
## patterns-in-fns-without-body
173126

174-
This lint detects incorrect parentheses. Some example code that triggers this
175-
lint:
127+
This lint detects patterns in functions without body were that were
128+
previously erroneously allowed. Some example code that triggers this lint:
176129

177-
```rust,ignore
178-
let x = 5 as usize();
130+
```rust,compile_fail
131+
trait Trait {
132+
fn foo(mut arg: u8);
133+
}
179134
```
180135

181136
This will produce:
182137

183138
```text
184-
error: parenthesized parameters may only be used with a trait
185-
--> src/main.rs:2:21
139+
warning: patterns aren't allowed in methods without bodies
140+
--> src/main.rs:2:12
186141
|
187-
2 | let x = 5 as usize();
188-
| ^^
142+
2 | fn foo(mut arg: u8);
143+
| ^^^^^^^
189144
|
190-
= note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default
145+
= note: `#[warn(patterns_in_fns_without_body)]` on by default
191146
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
192-
= note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238>
147+
= note: for more information, see issue #35203 <https://github.com/rust-lang/rust/issues/35203>
193148
```
194149

195-
To fix it, remove the `()`s.
150+
To fix this, remove the pattern; it can be used in the implementation without
151+
being used in the definition. That is:
196152

197-
## pub-use-of-private-extern-crate
153+
```rust
154+
trait Trait {
155+
fn foo(arg: u8);
156+
}
198157

199-
This lint detects a specific situation of re-exporting a private `extern crate`;
158+
impl Trait for i32 {
159+
fn foo(mut arg: u8) {
160+
161+
}
162+
}
163+
```
200164

201-
## safe-extern-statics
165+
## pub-use-of-private-extern-crate
202166

203-
In older versions of Rust, there was a soundness issue where `extern static`s were allowed
204-
to be accessed in safe code. This lint now catches and denies this kind of code.
167+
This lint detects a specific situation of re-exporting a private `extern crate`;
205168

206169
## unknown-crate-types
207170

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

-40
Original file line numberDiff line numberDiff line change
@@ -307,46 +307,6 @@ warning: path statement with no effect
307307
|
308308
```
309309

310-
## patterns-in-fns-without-body
311-
312-
This lint detects patterns in functions without body were that were
313-
previously erroneously allowed. Some example code that triggers this lint:
314-
315-
```rust
316-
trait Trait {
317-
fn foo(mut arg: u8);
318-
}
319-
```
320-
321-
This will produce:
322-
323-
```text
324-
warning: patterns aren't allowed in methods without bodies
325-
--> src/main.rs:2:12
326-
|
327-
2 | fn foo(mut arg: u8);
328-
| ^^^^^^^
329-
|
330-
= note: `#[warn(patterns_in_fns_without_body)]` on by default
331-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
332-
= note: for more information, see issue #35203 <https://github.com/rust-lang/rust/issues/35203>
333-
```
334-
335-
To fix this, remove the pattern; it can be used in the implementation without
336-
being used in the definition. That is:
337-
338-
```rust
339-
trait Trait {
340-
fn foo(arg: u8);
341-
}
342-
343-
impl Trait for i32 {
344-
fn foo(mut arg: u8) {
345-
346-
}
347-
}
348-
```
349-
350310
## plugin-as-library
351311

352312
This lint detects when compiler plugins are used as ordinary library in

src/librustc/hir/lowering.rs

+9-30
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

@@ -1701,29 +1699,19 @@ impl<'a> LoweringContext<'a> {
17011699
};
17021700
let parenthesized_generic_args = match partial_res.base_res() {
17031701
// `a::b::Trait(Args)`
1704-
Res::Def(DefKind::Trait, _)
1705-
if i + 1 == proj_start => ParenthesizedGenericArgs::Ok,
1702+
Res::Def(DefKind::Trait, _) if i + 1 == proj_start => {
1703+
ParenthesizedGenericArgs::Ok
1704+
}
17061705
// `a::b::Trait(Args)::TraitItem`
1707-
Res::Def(DefKind::Method, _)
1708-
| Res::Def(DefKind::AssocConst, _)
1709-
| Res::Def(DefKind::AssocTy, _)
1710-
if i + 2 == proj_start =>
1711-
{
1706+
Res::Def(DefKind::Method, _) |
1707+
Res::Def(DefKind::AssocConst, _) |
1708+
Res::Def(DefKind::AssocTy, _) if i + 2 == proj_start => {
17121709
ParenthesizedGenericArgs::Ok
17131710
}
17141711
// Avoid duplicated errors.
17151712
Res::Err => ParenthesizedGenericArgs::Ok,
17161713
// An error
1717-
Res::Def(DefKind::Struct, _)
1718-
| Res::Def(DefKind::Enum, _)
1719-
| Res::Def(DefKind::Union, _)
1720-
| Res::Def(DefKind::TyAlias, _)
1721-
| Res::Def(DefKind::Variant, _) if i + 1 == proj_start =>
1722-
{
1723-
ParenthesizedGenericArgs::Err
1724-
}
1725-
// A warning for now, for compatibility reasons.
1726-
_ => ParenthesizedGenericArgs::Warn,
1714+
_ => ParenthesizedGenericArgs::Err,
17271715
};
17281716

17291717
let num_lifetimes = type_def_id.map_or(0, |def_id| {
@@ -1786,7 +1774,7 @@ impl<'a> LoweringContext<'a> {
17861774
segment,
17871775
param_mode,
17881776
0,
1789-
ParenthesizedGenericArgs::Warn,
1777+
ParenthesizedGenericArgs::Err,
17901778
itctx.reborrow(),
17911779
None,
17921780
));
@@ -1862,15 +1850,6 @@ impl<'a> LoweringContext<'a> {
18621850
}
18631851
GenericArgs::Parenthesized(ref data) => match parenthesized_generic_args {
18641852
ParenthesizedGenericArgs::Ok => self.lower_parenthesized_parameter_data(data),
1865-
ParenthesizedGenericArgs::Warn => {
1866-
self.resolver.lint_buffer().buffer_lint(
1867-
PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
1868-
CRATE_NODE_ID,
1869-
data.span,
1870-
msg.into(),
1871-
);
1872-
(hir::GenericArgs::none(), true)
1873-
}
18741853
ParenthesizedGenericArgs::Err => {
18751854
let mut err = struct_span_err!(self.sess, data.span, E0214, "{}", msg);
18761855
err.span_label(data.span, "only `Fn` traits may use parentheses");

0 commit comments

Comments
 (0)