Skip to content

Commit 757daca

Browse files
committed
Auto merge of #63247 - Centril:compat-to-error, r=<try>
Transition some C-future-compatibility lints to {ERROR, DENY} Closes #40107 (ERROR). Closes #39207 (ERROR). Closes #37872 (ERROR). Closes #36887 (ERROR). Closes #36247 (ERROR. Closes #42238 (ERROR). Transitions #59014 (DENY). Transitions #57571 (DENY). Closes #60210 (ERROR). Transitions #35203 (DENY). r? @petrochenkov
2 parents 452087b + f213acf commit 757daca

Some content is hidden

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

56 files changed

+260
-651
lines changed

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

-110
Original file line numberDiff line numberDiff line change
@@ -22,85 +22,6 @@ error: bitshift exceeds the type's number of bits
2222
|
2323
```
2424

25-
## invalid-type-param-default
26-
27-
This lint detects type parameter default erroneously allowed in invalid location. Some
28-
example code that triggers this lint:
29-
30-
```rust,ignore
31-
fn foo<T=i32>(t: T) {}
32-
```
33-
34-
This will produce:
35-
36-
```text
37-
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions.
38-
--> src/main.rs:4:8
39-
|
40-
4 | fn foo<T=i32>(t: T) {}
41-
| ^
42-
|
43-
= note: `#[deny(invalid_type_param_default)]` on by default
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 #36887 <https://github.com/rust-lang/rust/issues/36887>
46-
```
47-
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-
95-
## missing-fragment-specifier
96-
97-
The missing_fragment_specifier warning is issued when an unused pattern in a
98-
`macro_rules!` macro definition has a meta-variable (e.g. `$e`) that is not
99-
followed by a fragment specifier (e.g. `:expr`).
100-
101-
This warning can always be fixed by removing the unused pattern in the
102-
`macro_rules!` macro definition.
103-
10425
## mutable-transmutes
10526

10627
This lint catches transmuting from `&T` to `&mut T` because it is undefined
@@ -123,7 +44,6 @@ error: mutating transmuted &mut T from &T may cause undefined behavior, consider
12344
|
12445
```
12546

126-
12747
## no-mangle-const-items
12848

12949
This lint detects any `const` items with the `#[no_mangle]` attribute.
@@ -169,40 +89,10 @@ error: literal out of range for u8
16989
|
17090
```
17191

172-
## parenthesized-params-in-types-and-modules
173-
174-
This lint detects incorrect parentheses. Some example code that triggers this
175-
lint:
176-
177-
```rust,ignore
178-
let x = 5 as usize();
179-
```
180-
181-
This will produce:
182-
183-
```text
184-
error: parenthesized parameters may only be used with a trait
185-
--> src/main.rs:2:21
186-
|
187-
2 | let x = 5 as usize();
188-
| ^^
189-
|
190-
= note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default
191-
= 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>
193-
```
194-
195-
To fix it, remove the `()`s.
196-
19792
## pub-use-of-private-extern-crate
19893

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

201-
## safe-extern-statics
202-
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.
205-
20696
## unknown-crate-types
20797

20898
This lint detects an unknown crate type found in a `#[crate_type]` directive. Some

Diff for: src/librustc/hir/lowering.rs

+9-30
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");

Diff for: src/librustc/lint/builtin.rs

+3-70
Original file line numberDiff line numberDiff line change
@@ -139,24 +139,12 @@ declare_lint! {
139139
"detect public re-exports of private extern crates"
140140
}
141141

142-
declare_lint! {
143-
pub INVALID_TYPE_PARAM_DEFAULT,
144-
Deny,
145-
"type parameter default erroneously allowed in invalid location"
146-
}
147-
148142
declare_lint! {
149143
pub RENAMED_AND_REMOVED_LINTS,
150144
Warn,
151145
"lints that have been renamed or removed"
152146
}
153147

154-
declare_lint! {
155-
pub SAFE_EXTERN_STATICS,
156-
Deny,
157-
"safe access to extern statics was erroneously allowed"
158-
}
159-
160148
declare_lint! {
161149
pub SAFE_PACKED_BORROWS,
162150
Warn,
@@ -165,33 +153,8 @@ declare_lint! {
165153

166154
declare_lint! {
167155
pub PATTERNS_IN_FNS_WITHOUT_BODY,
168-
Warn,
169-
"patterns in functions without body were erroneously allowed"
170-
}
171-
172-
declare_lint! {
173-
pub LEGACY_DIRECTORY_OWNERSHIP,
174-
Deny,
175-
"non-inline, non-`#[path]` modules (e.g., `mod foo;`) were erroneously allowed in some files \
176-
not named `mod.rs`"
177-
}
178-
179-
declare_lint! {
180-
pub LEGACY_CONSTRUCTOR_VISIBILITY,
181-
Deny,
182-
"detects use of struct constructors that would be invisible with new visibility rules"
183-
}
184-
185-
declare_lint! {
186-
pub MISSING_FRAGMENT_SPECIFIER,
187-
Deny,
188-
"detects missing fragment specifiers in unused `macro_rules!` patterns"
189-
}
190-
191-
declare_lint! {
192-
pub PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
193156
Deny,
194-
"detects parenthesized generic parameters in type and module names"
157+
"patterns in functions without body were erroneously allowed"
195158
}
196159

197160
declare_lint! {
@@ -292,12 +255,6 @@ declare_lint! {
292255
"detects labels that are never used"
293256
}
294257

295-
declare_lint! {
296-
pub DUPLICATE_MACRO_EXPORTS,
297-
Deny,
298-
"detects duplicate macro exports"
299-
}
300-
301258
declare_lint! {
302259
pub INTRA_DOC_LINK_RESOLUTION_FAILURE,
303260
Warn,
@@ -335,13 +292,6 @@ declare_lint! {
335292
via the module system"
336293
}
337294

338-
declare_lint! {
339-
pub MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
340-
Deny,
341-
"macro-expanded `macro_export` macros from the current crate \
342-
cannot be referred to by absolute paths"
343-
}
344-
345295
declare_lint! {
346296
pub EXPLICIT_OUTLIVES_REQUIREMENTS,
347297
Allow,
@@ -359,7 +309,7 @@ declare_lint! {
359309
pub mod parser {
360310
declare_lint! {
361311
pub ILL_FORMED_ATTRIBUTE_INPUT,
362-
Warn,
312+
Deny,
363313
"ill-formed attribute inputs that were previously accepted and used in practice"
364314
}
365315

@@ -385,7 +335,7 @@ declare_lint! {
385335

386336
declare_lint! {
387337
pub NESTED_IMPL_TRAIT,
388-
Warn,
338+
Deny,
389339
"nested occurrence of `impl Trait` type"
390340
}
391341

@@ -420,16 +370,10 @@ declare_lint_pass! {
420370
PRIVATE_IN_PUBLIC,
421371
EXPORTED_PRIVATE_DEPENDENCIES,
422372
PUB_USE_OF_PRIVATE_EXTERN_CRATE,
423-
INVALID_TYPE_PARAM_DEFAULT,
424373
CONST_ERR,
425374
RENAMED_AND_REMOVED_LINTS,
426-
SAFE_EXTERN_STATICS,
427375
SAFE_PACKED_BORROWS,
428376
PATTERNS_IN_FNS_WITHOUT_BODY,
429-
LEGACY_DIRECTORY_OWNERSHIP,
430-
LEGACY_CONSTRUCTOR_VISIBILITY,
431-
MISSING_FRAGMENT_SPECIFIER,
432-
PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
433377
LATE_BOUND_LIFETIME_ARGUMENTS,
434378
ORDER_DEPENDENT_TRAIT_OBJECTS,
435379
DEPRECATED,
@@ -445,14 +389,12 @@ declare_lint_pass! {
445389
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
446390
UNSTABLE_NAME_COLLISIONS,
447391
IRREFUTABLE_LET_PATTERNS,
448-
DUPLICATE_MACRO_EXPORTS,
449392
INTRA_DOC_LINK_RESOLUTION_FAILURE,
450393
MISSING_DOC_CODE_EXAMPLES,
451394
PRIVATE_DOC_TESTS,
452395
WHERE_CLAUSES_OBJECT_SAFETY,
453396
PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
454397
MACRO_USE_EXTERN_CRATE,
455-
MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
456398
parser::ILL_FORMED_ATTRIBUTE_INPUT,
457399
parser::META_VARIABLE_MISUSE,
458400
DEPRECATED_IN_FUTURE,
@@ -470,9 +412,7 @@ pub enum BuiltinLintDiagnostics {
470412
Normal,
471413
BareTraitObject(Span, /* is_global */ bool),
472414
AbsPathWithModule(Span),
473-
DuplicatedMacroExports(ast::Ident, Span, Span),
474415
ProcMacroDeriveResolutionFallback(Span),
475-
MacroExpandedMacroExportsAccessedByAbsolutePaths(Span),
476416
ElidedLifetimesInPaths(usize, Span, bool, Span, String),
477417
UnknownCrateTypes(Span, String, String),
478418
UnusedImports(String, Vec<(Span, String)>),
@@ -553,17 +493,10 @@ impl BuiltinLintDiagnostics {
553493
};
554494
db.span_suggestion(span, "use `crate`", sugg, app);
555495
}
556-
BuiltinLintDiagnostics::DuplicatedMacroExports(ident, earlier_span, later_span) => {
557-
db.span_label(later_span, format!("`{}` already exported", ident));
558-
db.span_note(earlier_span, "previous macro export is now shadowed");
559-
}
560496
BuiltinLintDiagnostics::ProcMacroDeriveResolutionFallback(span) => {
561497
db.span_label(span, "names from parent modules are not \
562498
accessible without an explicit import");
563499
}
564-
BuiltinLintDiagnostics::MacroExpandedMacroExportsAccessedByAbsolutePaths(span_def) => {
565-
db.span_note(span_def, "the macro is defined here");
566-
}
567500
BuiltinLintDiagnostics::ElidedLifetimesInPaths(
568501
n, path_span, incl_angl_brckt, insertion_span, anon_lts
569502
) => {

Diff for: src/librustc/mir/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2803,7 +2803,6 @@ pub enum UnsafetyViolationKind {
28032803
General,
28042804
/// Permitted in const fn and regular fns.
28052805
GeneralAndConstFn,
2806-
ExternStatic(hir::HirId),
28072806
BorrowPacked(hir::HirId),
28082807
}
28092808

0 commit comments

Comments
 (0)