[beta] Fix naming conventions for new lints

This commit is contained in:
Vadim Petrochenkov 2018-05-19 01:13:53 +03:00 committed by Pietro Albini
parent 24815d3a68
commit 068f4e00d4
No known key found for this signature in database
GPG key ID: E8C1042DD1624519
26 changed files with 54 additions and 49 deletions

View file

@ -64,7 +64,7 @@ To fix it, do as the help message suggests:
```rust
#![feature(dyn_trait)]
#![deny(bare_trait_object)]
#![deny(bare_trait_objects)]
trait Trait { }

View file

@ -4122,7 +4122,7 @@ impl<'a> LoweringContext<'a> {
fn maybe_lint_bare_trait(&self, span: Span, id: NodeId, is_global: bool) {
self.sess.buffer_lint_with_diagnostic(
builtin::BARE_TRAIT_OBJECT,
builtin::BARE_TRAIT_OBJECTS,
id,
span,
"trait objects without an explicit `dyn` are deprecated",

View file

@ -231,7 +231,7 @@ declare_lint! {
}
declare_lint! {
pub SINGLE_USE_LIFETIME,
pub SINGLE_USE_LIFETIMES,
Allow,
"detects single use lifetimes"
}
@ -243,19 +243,19 @@ declare_lint! {
}
declare_lint! {
pub ELIDED_LIFETIME_IN_PATH,
pub ELIDED_LIFETIMES_IN_PATHS,
Allow,
"hidden lifetime parameters are deprecated, try `Foo<'_>`"
}
declare_lint! {
pub BARE_TRAIT_OBJECT,
pub BARE_TRAIT_OBJECTS,
Allow,
"suggest using `dyn Trait` for trait objects"
}
declare_lint! {
pub ABSOLUTE_PATH_STARTING_WITH_MODULE,
pub ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
Allow,
"fully qualified paths that start with a module name \
instead of `crate`, `self`, or an extern crate name"
@ -268,7 +268,7 @@ declare_lint! {
}
declare_lint! {
pub UNSTABLE_NAME_COLLISION,
pub UNSTABLE_NAME_COLLISIONS,
Warn,
"detects name collision with an existing but unstable method"
}
@ -317,12 +317,12 @@ impl LintPass for HardwiredLints {
DEPRECATED,
UNUSED_UNSAFE,
UNUSED_MUT,
SINGLE_USE_LIFETIME,
SINGLE_USE_LIFETIMES,
TYVAR_BEHIND_RAW_POINTER,
ELIDED_LIFETIME_IN_PATH,
BARE_TRAIT_OBJECT,
ABSOLUTE_PATH_STARTING_WITH_MODULE,
UNSTABLE_NAME_COLLISION,
ELIDED_LIFETIMES_IN_PATHS,
BARE_TRAIT_OBJECTS,
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
UNSTABLE_NAME_COLLISIONS,
)
}
}

View file

@ -505,7 +505,7 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
"this was previously accepted by the compiler but is being phased out; \
it will become a hard error";
let explanation = if lint_id == LintId::of(::lint::builtin::UNSTABLE_NAME_COLLISION) {
let explanation = if lint_id == LintId::of(::lint::builtin::UNSTABLE_NAME_COLLISIONS) {
"once this method is added to the standard library, \
the ambiguity may cause an error or change in behavior!"
.to_owned()

View file

@ -1290,7 +1290,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
this.tcx
.struct_span_lint_node(
lint::builtin::SINGLE_USE_LIFETIME,
lint::builtin::SINGLE_USE_LIFETIMES,
id,
span,
&format!(
@ -1901,7 +1901,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
if deprecated {
self.tcx
.struct_span_lint_node(
lint::builtin::ELIDED_LIFETIME_IN_PATH,
lint::builtin::ELIDED_LIFETIMES_IN_PATHS,
id,
span,
&format!("hidden lifetime parameters are deprecated, try `Foo<'_>`"),

View file

@ -694,7 +694,7 @@ impl EarlyLintPass for DeprecatedAttr {
}
declare_lint! {
pub UNUSED_DOC_COMMENT,
pub UNUSED_DOC_COMMENTS,
Warn,
"detects doc comments that aren't used by rustdoc"
}
@ -704,7 +704,7 @@ pub struct UnusedDocComment;
impl LintPass for UnusedDocComment {
fn get_lints(&self) -> LintArray {
lint_array![UNUSED_DOC_COMMENT]
lint_array![UNUSED_DOC_COMMENTS]
}
}
@ -713,7 +713,7 @@ impl UnusedDocComment {
I: Iterator<Item=&'a ast::Attribute>,
C: LintContext<'tcx>>(&self, mut attrs: I, cx: &C) {
if let Some(attr) = attrs.find(|a| a.is_value_str() && a.check_name("doc")) {
cx.struct_span_lint(UNUSED_DOC_COMMENT, attr.span, "doc comment not used by rustdoc")
cx.struct_span_lint(UNUSED_DOC_COMMENTS, attr.span, "doc comment not used by rustdoc")
.emit();
}
}

View file

@ -40,7 +40,7 @@ extern crate rustc_target;
extern crate syntax_pos;
use rustc::lint;
use rustc::lint::builtin::{BARE_TRAIT_OBJECT, ABSOLUTE_PATH_STARTING_WITH_MODULE};
use rustc::lint::builtin::{BARE_TRAIT_OBJECTS, ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE};
use rustc::session;
use rustc::util;
@ -172,14 +172,14 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
UNUSED_ATTRIBUTES,
UNUSED_MACROS,
UNUSED_ALLOCATION,
UNUSED_DOC_COMMENT,
UNUSED_DOC_COMMENTS,
UNUSED_EXTERN_CRATES,
UNUSED_FEATURES,
UNUSED_PARENS);
add_lint_group!(sess,
"rust_2018_migration",
BARE_TRAIT_OBJECT,
BARE_TRAIT_OBJECTS,
UNREACHABLE_PUB);
// Guidelines for creating a future incompatibility lint:
@ -273,20 +273,25 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
edition: Some(Edition::Edition2018),
},
FutureIncompatibleInfo {
id: LintId::of(UNSTABLE_NAME_COLLISION),
id: LintId::of(UNSTABLE_NAME_COLLISIONS),
reference: "issue #48919 <https://github.com/rust-lang/rust/issues/48919>",
edition: None,
// Note: this item represents future incompatibility of all unstable functions in the
// standard library, and thus should never be removed or changed to an error.
},
FutureIncompatibleInfo {
id: LintId::of(ABSOLUTE_PATH_STARTING_WITH_MODULE),
id: LintId::of(ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE),
reference: "issue TBD",
edition: Some(Edition::Edition2018),
},
]);
// Register renamed and removed lints
store.register_renamed("single_use_lifetime", "single_use_lifetimes");
store.register_renamed("elided_lifetime_in_path", "elided_lifetimes_in_paths");
store.register_renamed("bare_trait_object", "bare_trait_objects");
store.register_renamed("unstable_name_collision", "unstable_name_collisions");
store.register_renamed("unused_doc_comment", "unused_doc_comments");
store.register_renamed("unknown_features", "unused_features");
store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate");
store.register_removed("negate_unsigned", "cast a signed value instead");

View file

@ -3367,7 +3367,7 @@ impl<'a> Resolver<'a> {
let diag = lint::builtin::BuiltinLintDiagnostics
::AbsPathWithModule(path_span);
self.session.buffer_lint_with_diagnostic(
lint::builtin::ABSOLUTE_PATH_STARTING_WITH_MODULE,
lint::builtin::ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
id, path_span,
"Absolute paths must start with `self`, `super`, \
`crate`, or an external crate name in the 2018 edition",

View file

@ -1056,7 +1056,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
unstable_candidates: &[(&Candidate<'tcx>, Symbol)],
) {
let mut diag = self.tcx.struct_span_lint_node(
lint::builtin::UNSTABLE_NAME_COLLISION,
lint::builtin::UNSTABLE_NAME_COLLISIONS,
self.fcx.body_id,
self.span,
"a method with this name may be added to the standard library in the future",

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(bare_trait_object)]
#![allow(bare_trait_objects)]
struct Foo;

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(unused_doc_comment)]
#![deny(unused_doc_comments)]
fn foo() {
/// a //~ ERROR doc comment not used by rustdoc

View file

@ -9,7 +9,7 @@
// except according to those terms.
#![feature(crate_in_paths)]
#![deny(absolute_path_starting_with_module)]
#![deny(absolute_paths_not_starting_with_crate)]
#![allow(unused)]
pub mod foo {

View file

@ -7,8 +7,8 @@ LL | use ::bar::Bar;
note: lint level defined here
--> $DIR/edition-lint-paths.rs:12:9
|
LL | #![deny(absolute_path_starting_with_module)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #![deny(absolute_paths_not_starting_with_crate)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
= note: for more information, see issue TBD

View file

@ -9,7 +9,7 @@
// except according to those terms.
#![allow(warnings)]
#![allow(unused_variables, dead_code, unused, bad_style)]
#![deny(elided_lifetime_in_path)]
#![deny(elided_lifetimes_in_paths)]
struct Foo<'a> { x: &'a u32 }
fn foo(x: &Foo) {

View file

@ -7,8 +7,8 @@ LL | fn foo(x: &Foo) {
note: lint level defined here
--> $DIR/ellided-lifetimes.rs:12:9
|
LL | #![deny(elided_lifetime_in_path)]
| ^^^^^^^^^^^^^^^^^^^^^^^
LL | #![deny(elided_lifetimes_in_paths)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View file

@ -7,7 +7,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(single_use_lifetime)]
#![deny(single_use_lifetimes)]
// FIXME(#44752) -- this scenario should not be warned
fn deref<'x>() -> &'x u32 { //~ ERROR lifetime name `'x` only used once
22

View file

@ -7,8 +7,8 @@ LL | fn deref<'x>() -> &'x u32 { //~ ERROR lifetime name `'x` only used once
note: lint level defined here
--> $DIR/single_use_lifetimes-2.rs:10:9
|
LL | #![deny(single_use_lifetime)]
| ^^^^^^^^^^^^^^^^^^^
LL | #![deny(single_use_lifetimes)]
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View file

@ -7,7 +7,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(single_use_lifetime)]
#![deny(single_use_lifetimes)]
struct Foo<'x> { //~ ERROR lifetime name `'x` only used once
x: &'x u32 // no warning!
}

View file

@ -7,8 +7,8 @@ LL | struct Foo<'x> { //~ ERROR lifetime name `'x` only used once
note: lint level defined here
--> $DIR/single_use_lifetimes-3.rs:10:9
|
LL | #![deny(single_use_lifetime)]
| ^^^^^^^^^^^^^^^^^^^
LL | #![deny(single_use_lifetimes)]
| ^^^^^^^^^^^^^^^^^^^^
error: lifetime name `'y` only used once
--> $DIR/single_use_lifetimes-3.rs:16:6

View file

@ -7,7 +7,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(single_use_lifetime)]
#![deny(single_use_lifetimes)]
// Neither should issue a warning, as explicit lifetimes are mandatory in this case
struct Foo<'x> { //~ ERROR lifetime name `'x` only used once
x: &'x u32

View file

@ -7,8 +7,8 @@ LL | struct Foo<'x> { //~ ERROR lifetime name `'x` only used once
note: lint level defined here
--> $DIR/single_use_lifetimes-4.rs:10:9
|
LL | #![deny(single_use_lifetime)]
| ^^^^^^^^^^^^^^^^^^^
LL | #![deny(single_use_lifetimes)]
| ^^^^^^^^^^^^^^^^^^^^
error: lifetime name `'x` only used once
--> $DIR/single_use_lifetimes-4.rs:16:10

View file

@ -7,7 +7,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(single_use_lifetime)]
#![deny(single_use_lifetimes)]
// Should not issue a warning, as explicit lifetimes are mandatory in this case:
trait Foo<'x> { //~ ERROR lifetime name `'x` only used once
fn foo(&self, arg: &'x u32);

View file

@ -7,8 +7,8 @@ LL | trait Foo<'x> { //~ ERROR lifetime name `'x` only used once
note: lint level defined here
--> $DIR/single_use_lifetimes-5.rs:10:9
|
LL | #![deny(single_use_lifetime)]
| ^^^^^^^^^^^^^^^^^^^
LL | #![deny(single_use_lifetimes)]
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View file

@ -7,7 +7,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(single_use_lifetime)]
#![deny(single_use_lifetimes)]
fn deref<'x>(v: &'x u32) -> u32 { //~ ERROR lifetime name `'x` only used once
*v

View file

@ -7,8 +7,8 @@ LL | fn deref<'x>(v: &'x u32) -> u32 { //~ ERROR lifetime name `'x` only used on
note: lint level defined here
--> $DIR/single_use_lifetimes.rs:10:9
|
LL | #![deny(single_use_lifetime)]
| ^^^^^^^^^^^^^^^^^^^
LL | #![deny(single_use_lifetimes)]
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View file

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