提交 aabb6e72 编写于 作者: A Aaron Turon

rustc: Rename lints per RFC 344

RFC 344 proposes a set of naming conventions for lints. This commit
renames existing lints to follow the conventions.

Use the following sed script to bring your code up to date:

```
s/unnecessary_typecast/unused_typecasts/g
s/unsigned_negate/unsigned_negation/g
s/type_limits/unused_comparisons/g
s/type_overflow/overflowing_literals/g
s/ctypes/improper_ctypes/g
s/owned_heap_memory/box_pointers/g
s/unused_attribute/unused_attributes/g
s/path_statement/path_statements/g
s/unused_must_use/unused_must_use/g
s/unused_result/unused_results/g
s/non_uppercase_statics/non_upper_case_globals/g
s/unnecessary_parens/unused_parens/g
s/unnecessary_import_braces/unused_import_braces/g
s/unused_unsafe/unused_unsafe/g
s/unsafe_block/unsafe_blocks/g
s/unused_mut/unused_mut/g
s/unnecessary_allocation/unused_allocation/g
s/missing_doc/missing_docs/g
s/unused_imports/unused_imports/g
s/unused_extern_crate/unused_extern_crates/g
s/unnecessary_qualification/unused_qualifications/g
s/unrecognized_lint/unknown_lints/g
s/unused_variable/unused_variables/g
s/dead_assignment/unused_assignments/g
s/unknown_crate_type/unknown_crate_types/g
s/variant_size_difference/variant_size_differences/g
s/transmute_fat_ptr/fat_ptr_transmutes/g
```

Closes #16545
Closes #17932

Due to deprecation, this is a:

[breaking-change]
上级 5e1e2456
......@@ -704,7 +704,7 @@ pub fn collect_crate_types(session: &Session,
}
Some(ref n) if n.equiv(&("bin")) => Some(config::CrateTypeExecutable),
Some(_) => {
session.add_lint(lint::builtin::UNKNOWN_CRATE_TYPE,
session.add_lint(lint::builtin::UNKNOWN_CRATE_TYPES,
ast::CRATE_NODE_ID,
a.span,
"invalid `crate_type` \
......@@ -712,7 +712,7 @@ pub fn collect_crate_types(session: &Session,
None
}
_ => {
session.add_lint(lint::builtin::UNKNOWN_CRATE_TYPE,
session.add_lint(lint::builtin::UNKNOWN_CRATE_TYPES,
ast::CRATE_NODE_ID,
a.span,
"`crate_type` requires a \
......
此差异已折叠。
......@@ -175,20 +175,20 @@ pub fn register_builtin(&mut self, sess: Option<&Session>) {
HardwiredLints,
WhileTrue,
UnusedCasts,
CTypes,
HeapMemory,
UnusedAttribute,
PathStatement,
UnusedResult,
ImproperCTypes,
BoxPointers,
UnusedAttributes,
PathStatements,
UnusedResults,
NonCamelCaseTypes,
NonSnakeCase,
NonUppercaseStatics,
UnnecessaryParens,
UnnecessaryImportBraces,
NonUpperCaseGlobals,
UnusedParens,
UnusedImportBraces,
UnusedUnsafe,
UnsafeBlock,
UnsafeBlocks,
UnusedMut,
UnnecessaryAllocation,
UnusedAllocation,
Stability,
)
......@@ -199,12 +199,12 @@ pub fn register_builtin(&mut self, sess: Option<&Session>) {
)
add_lint_group!(sess, "bad_style",
NON_CAMEL_CASE_TYPES, NON_SNAKE_CASE, NON_UPPERCASE_STATICS)
NON_CAMEL_CASE_TYPES, NON_SNAKE_CASE, NON_UPPER_CASE_GLOBALS)
add_lint_group!(sess, "unused",
UNUSED_IMPORTS, UNUSED_VARIABLE, DEAD_ASSIGNMENT, DEAD_CODE,
UNUSED_MUT, UNREACHABLE_CODE, UNUSED_EXTERN_CRATE, UNUSED_MUST_USE,
UNUSED_UNSAFE, UNUSED_RESULT, PATH_STATEMENT)
UNUSED_IMPORTS, UNUSED_VARIABLES, UNUSED_ASSIGNMENTS, DEAD_CODE,
UNUSED_MUT, UNREACHABLE_CODE, UNUSED_EXTERN_CRATES, UNUSED_MUST_USE,
UNUSED_UNSAFE, UNUSED_RESULTS, PATH_STATEMENTS)
// We have one lint pass defined in this module.
self.register_pass(sess, false, box GatherNodeLevels as LintPassObject);
......@@ -430,7 +430,7 @@ fn with_lint_attrs(&mut self,
(*lint_id, level, span))
.collect(),
None => {
self.span_lint(builtin::UNRECOGNIZED_LINT, span,
self.span_lint(builtin::UNKNOWN_LINTS, span,
format!("unknown `{}` attribute: `{}`",
level.as_str(), lint_name).as_slice());
continue;
......@@ -713,7 +713,7 @@ fn get_lints(&self) -> LintArray {
fn check_item(&mut self, cx: &Context, it: &ast::Item) {
match it.node {
ast::ItemEnum(..) => {
let lint_id = LintId::of(builtin::VARIANT_SIZE_DIFFERENCE);
let lint_id = LintId::of(builtin::VARIANT_SIZE_DIFFERENCES);
let lvlsrc = cx.lints.get_level_source(lint_id);
match lvlsrc {
(lvl, _) if lvl != Allow => {
......
......@@ -1629,11 +1629,11 @@ fn warn_about_unused(&self,
};
if is_assigned {
self.ir.tcx.sess.add_lint(lint::builtin::UNUSED_VARIABLE, id, sp,
self.ir.tcx.sess.add_lint(lint::builtin::UNUSED_VARIABLES, id, sp,
format!("variable `{}` is assigned to, but never used",
*name));
} else {
self.ir.tcx.sess.add_lint(lint::builtin::UNUSED_VARIABLE, id, sp,
self.ir.tcx.sess.add_lint(lint::builtin::UNUSED_VARIABLES, id, sp,
format!("unused variable: `{}`", *name));
}
}
......@@ -1651,7 +1651,7 @@ fn warn_about_dead_assign(&self,
if self.live_on_exit(ln, var).is_none() {
let r = self.should_warn(var);
for name in r.iter() {
self.ir.tcx.sess.add_lint(lint::builtin::DEAD_ASSIGNMENT, id, sp,
self.ir.tcx.sess.add_lint(lint::builtin::UNUSED_ASSIGNMENTS, id, sp,
format!("value assigned to `{}` is never read", *name));
}
}
......
......@@ -5232,7 +5232,7 @@ fn resolve_path(&mut self,
match (def, unqualified_def) {
(Some((ref d, _)), Some((ref ud, _))) if *d == *ud => {
self.session
.add_lint(lint::builtin::UNNECESSARY_QUALIFICATION,
.add_lint(lint::builtin::UNUSED_QUALIFICATIONS,
id,
path.span,
"unnecessary qualification".to_string());
......@@ -6125,7 +6125,7 @@ fn check_for_item_unused_imports(&mut self, vi: &ViewItem) {
match self.session.cstore.find_extern_mod_stmt_cnum(id)
{
Some(crate_num) => if !self.used_crates.contains(&crate_num) {
self.session.add_lint(lint::builtin::UNUSED_EXTERN_CRATE,
self.session.add_lint(lint::builtin::UNUSED_EXTERN_CRATES,
id,
vi.span,
"unused extern crate".to_string());
......
......@@ -2078,7 +2078,7 @@ fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &ast::EnumDef, sp: Span,
let mut sizes = Vec::new(); // does no allocation if no pushes, thankfully
let levels = ccx.tcx().node_lint_levels.borrow();
let lint_id = lint::LintId::of(lint::builtin::VARIANT_SIZE_DIFFERENCE);
let lint_id = lint::LintId::of(lint::builtin::VARIANT_SIZE_DIFFERENCES);
let lvlsrc = match levels.find(&(id, lint_id)) {
None | Some(&(lint::Allow, _)) => return,
Some(&lvlsrc) => lvlsrc,
......@@ -2115,7 +2115,7 @@ fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &ast::EnumDef, sp: Span,
if largest > slargest * 3 && slargest > 0 {
// Use lint::raw_emit_lint rather than sess.add_lint because the lint-printing
// pass for the latter already ran.
lint::raw_emit_lint(&ccx.tcx().sess, lint::builtin::VARIANT_SIZE_DIFFERENCE,
lint::raw_emit_lint(&ccx.tcx().sess, lint::builtin::VARIANT_SIZE_DIFFERENCES,
lvlsrc, Some(sp),
format!("enum variant is more than three times larger \
({} bytes) than the next largest (ignoring padding)",
......
......@@ -122,7 +122,7 @@ pub fn check_intrinsics(ccx: &CrateContext) {
if ty::type_is_fat_ptr(ccx.tcx(), transmute_restriction.to) ||
ty::type_is_fat_ptr(ccx.tcx(), transmute_restriction.from) {
ccx.sess()
.add_lint(::lint::builtin::TRANSMUTE_FAT_PTR,
.add_lint(::lint::builtin::FAT_PTR_TRANSMUTES,
transmute_restriction.id,
transmute_restriction.span,
format!("Transmuting fat pointer types; {} to {}.\
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册