Skip to content

Commit c8e10e3

Browse files
committed
Auto merge of #50879 - petrochenkov:lintconv, r=nikomatsakis
Fix naming conventions for new lints We actually have an RFC from Oct 2014 specifying naming conventions for lints that is still relevant - https://github.com/rust-lang/rfcs/blob/master/text/0344-conventions-galore.md#lints. Unfortunately, human memory doesn't work for such prolonged periods of time, so a number of recently added edition-related lints don't follow the conventions. This PR fixes names for those lints. Unstable lints, simply renamed: - `unused_lifetime` -> `unused_lifetimes` - `absolute_path_not_starting_with_crate` -> `absolute_paths_not_starting_with_crate` - `unnecessary_extern_crate` -> `unnecessary_extern_crates` New lints stabilized in the last couple of releases, registered as renamed (old names still work with a warning): - `single_use_lifetime` -> `single_use_lifetimes` - `elided_lifetime_in_path` -> `elided_lifetimes_in_paths` - `bare_trait_object` -> `bare_trait_objects` - `unstable_name_collision` -> `unstable_name_collisions` - `unused_doc_comment` -> `unused_doc_comments` NOT changed, too old to rename: - `const_err` -> `const_errors` - `unused_allocation` -> `unused_allocations` NOT changed, deprecation lints, no need to rename, they are going to be removed anyway: - `invalid_type_param_default` -> `invalid_type_param_defaults` - `missing_fragment_specifier` -> `missing_fragment_specifiers` - `tyvar_behind_raw_pointer` -> `tyvars_behind_raw_pointer` - `illegal_floating_point_literal_pattern` -> `illegal_floating_point_literal_patterns`
2 parents b86d909 + e60eaf5 commit c8e10e3

File tree

65 files changed

+111
-108
lines changed

Some content is hidden

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

65 files changed

+111
-108
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ To fix it, do as the help message suggests:
6464

6565
```rust
6666
#![feature(dyn_trait)]
67-
#![deny(bare_trait_object)]
67+
#![deny(bare_trait_objects)]
6868

6969
trait Trait { }
7070

src/librustc/hir/lowering.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4125,7 +4125,7 @@ impl<'a> LoweringContext<'a> {
41254125

41264126
fn maybe_lint_bare_trait(&self, span: Span, id: NodeId, is_global: bool) {
41274127
self.sess.buffer_lint_with_diagnostic(
4128-
builtin::BARE_TRAIT_OBJECT,
4128+
builtin::BARE_TRAIT_OBJECTS,
41294129
id,
41304130
span,
41314131
"trait objects without an explicit `dyn` are deprecated",

src/librustc/lint/builtin.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,13 @@ declare_lint! {
225225
}
226226

227227
declare_lint! {
228-
pub SINGLE_USE_LIFETIME,
228+
pub SINGLE_USE_LIFETIMES,
229229
Allow,
230230
"detects lifetime parameters that are only used once"
231231
}
232232

233233
declare_lint! {
234-
pub UNUSED_LIFETIME,
234+
pub UNUSED_LIFETIMES,
235235
Allow,
236236
"detects lifetime parameters that are never used"
237237
}
@@ -243,19 +243,19 @@ declare_lint! {
243243
}
244244

245245
declare_lint! {
246-
pub ELIDED_LIFETIME_IN_PATH,
246+
pub ELIDED_LIFETIMES_IN_PATHS,
247247
Allow,
248248
"hidden lifetime parameters are deprecated, try `Foo<'_>`"
249249
}
250250

251251
declare_lint! {
252-
pub BARE_TRAIT_OBJECT,
252+
pub BARE_TRAIT_OBJECTS,
253253
Allow,
254254
"suggest using `dyn Trait` for trait objects"
255255
}
256256

257257
declare_lint! {
258-
pub ABSOLUTE_PATH_NOT_STARTING_WITH_CRATE,
258+
pub ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
259259
Allow,
260260
"fully qualified paths that start with a module name \
261261
instead of `crate`, `self`, or an extern crate name"
@@ -268,7 +268,7 @@ declare_lint! {
268268
}
269269

270270
declare_lint! {
271-
pub UNSTABLE_NAME_COLLISION,
271+
pub UNSTABLE_NAME_COLLISIONS,
272272
Warn,
273273
"detects name collision with an existing but unstable method"
274274
}
@@ -328,14 +328,14 @@ impl LintPass for HardwiredLints {
328328
DEPRECATED,
329329
UNUSED_UNSAFE,
330330
UNUSED_MUT,
331-
SINGLE_USE_LIFETIME,
332-
UNUSED_LIFETIME,
331+
SINGLE_USE_LIFETIMES,
332+
UNUSED_LIFETIMES,
333333
UNUSED_LABELS,
334334
TYVAR_BEHIND_RAW_POINTER,
335-
ELIDED_LIFETIME_IN_PATH,
336-
BARE_TRAIT_OBJECT,
337-
ABSOLUTE_PATH_NOT_STARTING_WITH_CRATE,
338-
UNSTABLE_NAME_COLLISION,
335+
ELIDED_LIFETIMES_IN_PATHS,
336+
BARE_TRAIT_OBJECTS,
337+
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
338+
UNSTABLE_NAME_COLLISIONS,
339339
DUPLICATE_ASSOCIATED_TYPE_BINDINGS,
340340
)
341341
}

src/librustc/lint/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
505505
"this was previously accepted by the compiler but is being phased out; \
506506
it will become a hard error";
507507

508-
let explanation = if lint_id == LintId::of(::lint::builtin::UNSTABLE_NAME_COLLISION) {
508+
let explanation = if lint_id == LintId::of(::lint::builtin::UNSTABLE_NAME_COLLISIONS) {
509509
"once this method is added to the standard library, \
510510
the ambiguity may cause an error or change in behavior!"
511511
.to_owned()

src/librustc/middle/resolve_lifetime.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
13441344

13451345
self.tcx
13461346
.struct_span_lint_node(
1347-
lint::builtin::SINGLE_USE_LIFETIME,
1347+
lint::builtin::SINGLE_USE_LIFETIMES,
13481348
id,
13491349
span,
13501350
&format!(
@@ -1366,7 +1366,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
13661366

13671367
self.tcx
13681368
.struct_span_lint_node(
1369-
lint::builtin::UNUSED_LIFETIME,
1369+
lint::builtin::UNUSED_LIFETIMES,
13701370
id,
13711371
span,
13721372
&format!(
@@ -1981,7 +1981,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
19811981
if deprecated {
19821982
self.tcx
19831983
.struct_span_lint_node(
1984-
lint::builtin::ELIDED_LIFETIME_IN_PATH,
1984+
lint::builtin::ELIDED_LIFETIMES_IN_PATHS,
19851985
id,
19861986
span,
19871987
&format!("hidden lifetime parameters are deprecated, try `Foo<'_>`"),

src/librustc_lint/builtin.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ impl EarlyLintPass for DeprecatedAttr {
694694
}
695695

696696
declare_lint! {
697-
pub UNUSED_DOC_COMMENT,
697+
pub UNUSED_DOC_COMMENTS,
698698
Warn,
699699
"detects doc comments that aren't used by rustdoc"
700700
}
@@ -704,7 +704,7 @@ pub struct UnusedDocComment;
704704

705705
impl LintPass for UnusedDocComment {
706706
fn get_lints(&self) -> LintArray {
707-
lint_array![UNUSED_DOC_COMMENT]
707+
lint_array![UNUSED_DOC_COMMENTS]
708708
}
709709
}
710710

@@ -713,7 +713,7 @@ impl UnusedDocComment {
713713
I: Iterator<Item=&'a ast::Attribute>,
714714
C: LintContext<'tcx>>(&self, mut attrs: I, cx: &C) {
715715
if let Some(attr) = attrs.find(|a| a.is_value_str() && a.check_name("doc")) {
716-
cx.struct_span_lint(UNUSED_DOC_COMMENT, attr.span, "doc comment not used by rustdoc")
716+
cx.struct_span_lint(UNUSED_DOC_COMMENTS, attr.span, "doc comment not used by rustdoc")
717717
.emit();
718718
}
719719
}
@@ -1527,7 +1527,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedBrokenConst {
15271527
}
15281528

15291529
declare_lint! {
1530-
pub UNNECESSARY_EXTERN_CRATE,
1530+
pub UNNECESSARY_EXTERN_CRATES,
15311531
Allow,
15321532
"suggest removing `extern crate` for the 2018 edition"
15331533
}
@@ -1542,7 +1542,7 @@ impl ExternCrate {
15421542

15431543
impl LintPass for ExternCrate {
15441544
fn get_lints(&self) -> LintArray {
1545-
lint_array!(UNNECESSARY_EXTERN_CRATE)
1545+
lint_array!(UNNECESSARY_EXTERN_CRATES)
15461546
}
15471547
}
15481548

@@ -1555,7 +1555,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExternCrate {
15551555
if it.attrs.iter().any(|a| a.check_name("macro_use")) {
15561556
return
15571557
}
1558-
let mut err = cx.struct_span_lint(UNNECESSARY_EXTERN_CRATE,
1558+
let mut err = cx.struct_span_lint(UNNECESSARY_EXTERN_CRATES,
15591559
it.span, "`extern crate` is unnecessary in the new edition");
15601560
if it.vis == hir::Visibility::Public || self.0 > 1 || orig.is_some() {
15611561
let pub_ = if it.vis == hir::Visibility::Public {

src/librustc_lint/lib.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extern crate rustc_target;
4040
extern crate syntax_pos;
4141

4242
use rustc::lint;
43-
use rustc::lint::builtin::{BARE_TRAIT_OBJECT, ABSOLUTE_PATH_NOT_STARTING_WITH_CRATE};
43+
use rustc::lint::builtin::{BARE_TRAIT_OBJECTS, ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE};
4444
use rustc::session;
4545
use rustc::util;
4646

@@ -174,17 +174,17 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
174174
UNUSED_ATTRIBUTES,
175175
UNUSED_MACROS,
176176
UNUSED_ALLOCATION,
177-
UNUSED_DOC_COMMENT,
177+
UNUSED_DOC_COMMENTS,
178178
UNUSED_EXTERN_CRATES,
179179
UNUSED_FEATURES,
180180
UNUSED_LABELS,
181181
UNUSED_PARENS);
182182

183183
add_lint_group!(sess,
184184
"rust_2018_idioms",
185-
BARE_TRAIT_OBJECT,
185+
BARE_TRAIT_OBJECTS,
186186
UNREACHABLE_PUB,
187-
UNNECESSARY_EXTERN_CRATE);
187+
UNNECESSARY_EXTERN_CRATES);
188188

189189
// Guidelines for creating a future incompatibility lint:
190190
//
@@ -272,14 +272,14 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
272272
edition: Some(Edition::Edition2018),
273273
},
274274
FutureIncompatibleInfo {
275-
id: LintId::of(UNSTABLE_NAME_COLLISION),
275+
id: LintId::of(UNSTABLE_NAME_COLLISIONS),
276276
reference: "issue #48919 <https://github.com/rust-lang/rust/issues/48919>",
277277
edition: None,
278278
// Note: this item represents future incompatibility of all unstable functions in the
279279
// standard library, and thus should never be removed or changed to an error.
280280
},
281281
FutureIncompatibleInfo {
282-
id: LintId::of(ABSOLUTE_PATH_NOT_STARTING_WITH_CRATE),
282+
id: LintId::of(ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE),
283283
reference: "issue TBD",
284284
edition: Some(Edition::Edition2018),
285285
},
@@ -291,6 +291,11 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
291291
]);
292292

293293
// Register renamed and removed lints
294+
store.register_renamed("single_use_lifetime", "single_use_lifetimes");
295+
store.register_renamed("elided_lifetime_in_path", "elided_lifetimes_in_paths");
296+
store.register_renamed("bare_trait_object", "bare_trait_objects");
297+
store.register_renamed("unstable_name_collision", "unstable_name_collisions");
298+
store.register_renamed("unused_doc_comment", "unused_doc_comments");
294299
store.register_renamed("unknown_features", "unused_features");
295300
store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate");
296301
store.register_removed("negate_unsigned", "cast a signed value instead");
@@ -325,6 +330,4 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
325330
"converted into hard error, see https://github.com/rust-lang/rust/issues/48950");
326331
store.register_removed("resolve_trait_on_defaulted_unit",
327332
"converted into hard error, see https://github.com/rust-lang/rust/issues/48950");
328-
store.register_removed("absolute_path_starting_with_module",
329-
"renamed to `absolute_path_not_starting_with_crate`");
330333
}

src/librustc_resolve/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3486,7 +3486,7 @@ impl<'a> Resolver<'a> {
34863486
let diag = lint::builtin::BuiltinLintDiagnostics
34873487
::AbsPathWithModule(span);
34883488
self.session.buffer_lint_with_diagnostic(
3489-
lint::builtin::ABSOLUTE_PATH_NOT_STARTING_WITH_CRATE,
3489+
lint::builtin::ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
34903490
id, span,
34913491
"absolute paths must start with `self`, `super`, \
34923492
`crate`, or an external crate name in the 2018 edition",

src/librustc_typeck/check/method/probe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
10571057
unstable_candidates: &[(&Candidate<'tcx>, Symbol)],
10581058
) {
10591059
let mut diag = self.tcx.struct_span_lint_node(
1060-
lint::builtin::UNSTABLE_NAME_COLLISION,
1060+
lint::builtin::UNSTABLE_NAME_COLLISIONS,
10611061
self.fcx.body_id,
10621062
self.span,
10631063
"a method with this name may be added to the standard library in the future",

src/test/compile-fail/trait-bounds-not-on-struct.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![allow(bare_trait_object)]
11+
#![allow(bare_trait_objects)]
1212

1313
struct Foo;
1414

src/test/compile-fail/useless_comment.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![deny(unused_doc_comment)]
11+
#![deny(unused_doc_comments)]
1212

1313
fn foo() {
1414
/// a //~ ERROR doc comment not used by rustdoc

src/test/ui-fulldeps/unnecessary-extern-crate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// compile-flags: --edition 2018
1212

13-
#![deny(unnecessary_extern_crate)]
13+
#![deny(unnecessary_extern_crates)]
1414
#![feature(alloc, test, libc)]
1515

1616
extern crate alloc;

src/test/ui-fulldeps/unnecessary-extern-crate.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | extern crate alloc;
77
note: lint level defined here
88
--> $DIR/unnecessary-extern-crate.rs:13:9
99
|
10-
LL | #![deny(unnecessary_extern_crate)]
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^
10+
LL | #![deny(unnecessary_extern_crates)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: `extern crate` is unnecessary in the new edition
1414
--> $DIR/unnecessary-extern-crate.rs:19:1

src/test/ui/in-band-lifetimes/ellided-lifetimes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010
#![allow(warnings)]
1111
#![allow(unused_variables, dead_code, unused, bad_style)]
12-
#![deny(elided_lifetime_in_path)]
12+
#![deny(elided_lifetimes_in_paths)]
1313

1414
struct Foo<'a> { x: &'a u32 }
1515
fn foo(x: &Foo) {

src/test/ui/in-band-lifetimes/ellided-lifetimes.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | fn foo(x: &Foo) {
77
note: lint level defined here
88
--> $DIR/ellided-lifetimes.rs:12:9
99
|
10-
LL | #![deny(elided_lifetime_in_path)]
11-
| ^^^^^^^^^^^^^^^^^^^^^^^
10+
LL | #![deny(elided_lifetimes_in_paths)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: aborting due to previous error
1414

src/test/ui/inference_unstable.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: a method with this name may be added to the standard library in the fut
44
LL | assert_eq!('x'.ipu_flatten(), 1);
55
| ^^^^^^^^^^^
66
|
7-
= note: #[warn(unstable_name_collision)] on by default
7+
= note: #[warn(unstable_name_collisions)] on by default
88
= warning: once this method is added to the standard library, the ambiguity may cause an error or change in behavior!
99
= note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
1010
= help: call with fully qualified syntax `inference_unstable_itertools::IpuItertools::ipu_flatten(...)` to keep using the current method

src/test/ui/rust-2018/edition-lint-fully-qualified-paths.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// run-rustfix
1212

1313
#![feature(rust_2018_preview)]
14-
#![deny(absolute_path_not_starting_with_crate)]
14+
#![deny(absolute_paths_not_starting_with_crate)]
1515

1616
mod foo {
1717
crate trait Foo {

src/test/ui/rust-2018/edition-lint-fully-qualified-paths.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// run-rustfix
1212

1313
#![feature(rust_2018_preview)]
14-
#![deny(absolute_path_not_starting_with_crate)]
14+
#![deny(absolute_paths_not_starting_with_crate)]
1515

1616
mod foo {
1717
crate trait Foo {

src/test/ui/rust-2018/edition-lint-fully-qualified-paths.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | let _: <foo::Baz as ::foo::Foo>::Bar = ();
77
note: lint level defined here
88
--> $DIR/edition-lint-fully-qualified-paths.rs:14:9
99
|
10-
LL | #![deny(absolute_path_not_starting_with_crate)]
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
LL | #![deny(absolute_paths_not_starting_with_crate)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
1313
= note: for more information, see issue TBD
1414

src/test/ui/rust-2018/edition-lint-nested-empty-paths.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// run-rustfix
1212

1313
#![feature(rust_2018_preview)]
14-
#![deny(absolute_path_not_starting_with_crate)]
14+
#![deny(absolute_paths_not_starting_with_crate)]
1515
#![allow(unused_imports)]
1616
#![allow(dead_code)]
1717

src/test/ui/rust-2018/edition-lint-nested-empty-paths.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// run-rustfix
1212

1313
#![feature(rust_2018_preview)]
14-
#![deny(absolute_path_not_starting_with_crate)]
14+
#![deny(absolute_paths_not_starting_with_crate)]
1515
#![allow(unused_imports)]
1616
#![allow(dead_code)]
1717

src/test/ui/rust-2018/edition-lint-nested-empty-paths.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | use foo::{bar::{baz::{}}};
77
note: lint level defined here
88
--> $DIR/edition-lint-nested-empty-paths.rs:14:9
99
|
10-
LL | #![deny(absolute_path_not_starting_with_crate)]
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
LL | #![deny(absolute_paths_not_starting_with_crate)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
1313
= note: for more information, see issue TBD
1414

src/test/ui/rust-2018/edition-lint-nested-paths.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// run-rustfix
1212

1313
#![feature(rust_2018_preview)]
14-
#![deny(absolute_path_not_starting_with_crate)]
14+
#![deny(absolute_paths_not_starting_with_crate)]
1515

1616
use crate::foo::{a, b};
1717
//~^ ERROR absolute paths must start with

0 commit comments

Comments
 (0)