2018-11-27 02:59:49 +00:00
|
|
|
//! # Lints in the Rust compiler
|
2015-02-25 12:03:44 +00:00
|
|
|
//!
|
|
|
|
//! This currently only contains the definitions and implementations
|
|
|
|
//! of most of the lints that `rustc` supports directly, it does not
|
|
|
|
//! contain the infrastructure for defining/registering lints. That is
|
2015-11-22 20:14:09 +00:00
|
|
|
//! available in `rustc::lint` and `rustc_plugin` respectively.
|
2015-02-25 11:44:44 +00:00
|
|
|
//!
|
2018-11-27 02:59:49 +00:00
|
|
|
//! ## Note
|
2015-02-25 11:44:44 +00:00
|
|
|
//!
|
|
|
|
//! This API is completely unstable and subject to change.
|
|
|
|
|
2019-02-05 13:37:15 +00:00
|
|
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
2015-02-25 11:44:44 +00:00
|
|
|
|
2015-06-09 21:39:23 +00:00
|
|
|
#![cfg_attr(test, feature(test))]
|
2015-02-25 11:44:44 +00:00
|
|
|
#![feature(box_patterns)]
|
|
|
|
#![feature(box_syntax)]
|
2018-09-26 21:26:46 +00:00
|
|
|
#![feature(nll)]
|
2015-02-25 11:44:44 +00:00
|
|
|
#![feature(rustc_diagnostic_macros)]
|
2017-05-08 21:36:44 +00:00
|
|
|
|
2018-12-13 15:57:25 +00:00
|
|
|
#![recursion_limit="256"]
|
|
|
|
|
2015-02-25 11:44:44 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate rustc;
|
|
|
|
|
2019-04-16 22:35:54 +00:00
|
|
|
mod error_codes;
|
2018-11-27 02:59:49 +00:00
|
|
|
mod nonstandard_style;
|
|
|
|
pub mod builtin;
|
|
|
|
mod types;
|
|
|
|
mod unused;
|
2019-06-16 03:22:07 +00:00
|
|
|
mod non_ascii_idents;
|
2018-11-27 02:59:49 +00:00
|
|
|
|
2017-08-19 00:09:55 +00:00
|
|
|
use rustc::lint;
|
2019-01-18 06:40:55 +00:00
|
|
|
use rustc::lint::{EarlyContext, LateContext, LateLintPass, EarlyLintPass, LintPass, LintArray};
|
2018-07-13 02:25:02 +00:00
|
|
|
use rustc::lint::builtin::{
|
|
|
|
BARE_TRAIT_OBJECTS,
|
|
|
|
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
|
|
|
|
ELIDED_LIFETIMES_IN_PATHS,
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 19:22:04 +00:00
|
|
|
EXPLICIT_OUTLIVES_REQUIREMENTS,
|
2018-12-10 20:58:57 +00:00
|
|
|
INTRA_DOC_LINK_RESOLUTION_FAILURE,
|
|
|
|
MISSING_DOC_CODE_EXAMPLES,
|
|
|
|
PRIVATE_DOC_TESTS,
|
2019-01-01 23:21:05 +00:00
|
|
|
parser::ILL_FORMED_ATTRIBUTE_INPUT,
|
2018-07-13 02:25:02 +00:00
|
|
|
};
|
2017-08-19 00:09:55 +00:00
|
|
|
use rustc::session;
|
2018-06-21 07:04:50 +00:00
|
|
|
use rustc::hir;
|
2019-01-31 00:36:11 +00:00
|
|
|
use rustc::hir::def_id::DefId;
|
|
|
|
use rustc::ty::query::Providers;
|
|
|
|
use rustc::ty::TyCtxt;
|
2018-06-21 07:04:50 +00:00
|
|
|
|
|
|
|
use syntax::ast;
|
2018-11-27 02:59:49 +00:00
|
|
|
use syntax::edition::Edition;
|
2018-06-21 07:04:50 +00:00
|
|
|
use syntax_pos::Span;
|
2015-02-25 11:44:44 +00:00
|
|
|
|
|
|
|
use session::Session;
|
Add trivial cast lints.
This permits all coercions to be performed in casts, but adds lints to warn in those cases.
Part of this patch moves cast checking to a later stage of type checking. We acquire obligations to check casts as part of type checking where we previously checked them. Once we have type checked a function or module, then we check any cast obligations which have been acquired. That means we have more type information available to check casts (this was crucial to making coercions work properly in place of some casts), but it means that casts cannot feed input into type inference.
[breaking change]
* Adds two new lints for trivial casts and trivial numeric casts, these are warn by default, but can cause errors if you build with warnings as errors. Previously, trivial numeric casts and casts to trait objects were allowed.
* The unused casts lint has gone.
* Interactions between casting and type inference have changed in subtle ways. Two ways this might manifest are:
- You may need to 'direct' casts more with extra type information, for example, in some cases where `foo as _ as T` succeeded, you may now need to specify the type for `_`
- Casts do not influence inference of integer types. E.g., the following used to type check:
```
let x = 42;
let y = &x as *const u32;
```
Because the cast would inform inference that `x` must have type `u32`. This no longer applies and the compiler will fallback to `i32` for `x` and thus there will be a type error in the cast. The solution is to add more type information:
```
let x: u32 = 42;
let y = &x as *const u32;
```
2015-03-20 04:15:27 +00:00
|
|
|
use lint::LintId;
|
2016-01-08 22:53:44 +00:00
|
|
|
use lint::FutureIncompatibleInfo;
|
2015-02-25 11:44:44 +00:00
|
|
|
|
2018-08-29 13:21:01 +00:00
|
|
|
use nonstandard_style::*;
|
2015-09-15 02:36:39 +00:00
|
|
|
use builtin::*;
|
2015-09-22 00:58:57 +00:00
|
|
|
use types::*;
|
2015-09-15 22:58:19 +00:00
|
|
|
use unused::*;
|
2019-06-16 03:22:07 +00:00
|
|
|
use non_ascii_idents::*;
|
2018-12-06 13:03:12 +00:00
|
|
|
use rustc::lint::internal::*;
|
2015-09-15 02:36:39 +00:00
|
|
|
|
2018-06-09 15:20:58 +00:00
|
|
|
/// Useful for other parts of the compiler.
|
|
|
|
pub use builtin::SoftLints;
|
|
|
|
|
2019-01-31 00:36:11 +00:00
|
|
|
pub fn provide(providers: &mut Providers<'_>) {
|
|
|
|
*providers = Providers {
|
|
|
|
lint_mod,
|
|
|
|
..*providers
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-06-21 18:27:44 +00:00
|
|
|
fn lint_mod(tcx: TyCtxt<'_>, module_def_id: DefId) {
|
2019-01-31 00:36:11 +00:00
|
|
|
lint::late_lint_mod(tcx, module_def_id, BuiltinCombinedModuleLateLintPass::new());
|
|
|
|
}
|
|
|
|
|
2019-01-18 06:40:55 +00:00
|
|
|
macro_rules! pre_expansion_lint_passes {
|
|
|
|
($macro:path, $args:tt) => (
|
|
|
|
$macro!($args, [
|
|
|
|
KeywordIdents: KeywordIdents,
|
2019-01-24 20:49:03 +00:00
|
|
|
UnusedDocComment: UnusedDocComment,
|
2019-01-18 06:40:55 +00:00
|
|
|
]);
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! early_lint_passes {
|
|
|
|
($macro:path, $args:tt) => (
|
|
|
|
$macro!($args, [
|
|
|
|
UnusedParens: UnusedParens,
|
|
|
|
UnusedImportBraces: UnusedImportBraces,
|
|
|
|
UnsafeCode: UnsafeCode,
|
|
|
|
AnonymousParameters: AnonymousParameters,
|
2019-04-24 18:38:10 +00:00
|
|
|
EllipsisInclusiveRangePatterns: EllipsisInclusiveRangePatterns::default(),
|
2019-01-18 06:40:55 +00:00
|
|
|
NonCamelCaseTypes: NonCamelCaseTypes,
|
|
|
|
DeprecatedAttr: DeprecatedAttr::new(),
|
2019-06-21 23:30:24 +00:00
|
|
|
WhileTrue: WhileTrue,
|
2019-06-16 03:22:07 +00:00
|
|
|
NonAsciiIdents: NonAsciiIdents,
|
2019-01-18 06:40:55 +00:00
|
|
|
]);
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! declare_combined_early_pass {
|
|
|
|
([$name:ident], $passes:tt) => (
|
|
|
|
early_lint_methods!(declare_combined_early_lint_pass, [pub $name, $passes]);
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
pre_expansion_lint_passes!(declare_combined_early_pass, [BuiltinCombinedPreExpansionLintPass]);
|
|
|
|
early_lint_passes!(declare_combined_early_pass, [BuiltinCombinedEarlyLintPass]);
|
|
|
|
|
2019-01-31 00:36:11 +00:00
|
|
|
macro_rules! late_lint_passes {
|
|
|
|
($macro:path, $args:tt) => (
|
|
|
|
$macro!($args, [
|
|
|
|
// FIXME: Look into regression when this is used as a module lint
|
|
|
|
// May Depend on constants elsewhere
|
|
|
|
UnusedBrokenConst: UnusedBrokenConst,
|
|
|
|
|
|
|
|
// Uses attr::is_used which is untracked, can't be an incremental module pass.
|
2019-04-10 17:47:55 +00:00
|
|
|
UnusedAttributes: UnusedAttributes::new(),
|
2019-01-31 00:36:11 +00:00
|
|
|
|
|
|
|
// Needs to run after UnusedAttributes as it marks all `feature` attributes as used.
|
|
|
|
UnstableFeatures: UnstableFeatures,
|
|
|
|
|
|
|
|
// Tracks state across modules
|
|
|
|
UnnameableTestItems: UnnameableTestItems::new(),
|
|
|
|
|
|
|
|
// Tracks attributes of parents
|
|
|
|
MissingDoc: MissingDoc::new(),
|
|
|
|
|
|
|
|
// Depends on access levels
|
|
|
|
// FIXME: Turn the computation of types which implement Debug into a query
|
|
|
|
// and change this to a module lint pass
|
2019-04-24 12:47:26 +00:00
|
|
|
MissingDebugImplementations: MissingDebugImplementations::default(),
|
2019-01-31 00:36:11 +00:00
|
|
|
]);
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! late_lint_mod_passes {
|
|
|
|
($macro:path, $args:tt) => (
|
|
|
|
$macro!($args, [
|
|
|
|
HardwiredLints: HardwiredLints,
|
|
|
|
ImproperCTypes: ImproperCTypes,
|
|
|
|
VariantSizeDifferences: VariantSizeDifferences,
|
|
|
|
BoxPointers: BoxPointers,
|
|
|
|
PathStatements: PathStatements,
|
|
|
|
|
|
|
|
// Depends on referenced function signatures in expressions
|
|
|
|
UnusedResults: UnusedResults,
|
|
|
|
|
|
|
|
NonUpperCaseGlobals: NonUpperCaseGlobals,
|
|
|
|
NonShorthandFieldPatterns: NonShorthandFieldPatterns,
|
|
|
|
UnusedAllocation: UnusedAllocation,
|
|
|
|
|
|
|
|
// Depends on types used in type definitions
|
|
|
|
MissingCopyImplementations: MissingCopyImplementations,
|
|
|
|
|
|
|
|
PluginAsLibrary: PluginAsLibrary,
|
|
|
|
|
|
|
|
// Depends on referenced function signatures in expressions
|
|
|
|
MutableTransmutes: MutableTransmutes,
|
|
|
|
|
|
|
|
// Depends on types of fields, checks if they implement Drop
|
|
|
|
UnionsWithDropFields: UnionsWithDropFields,
|
|
|
|
|
|
|
|
TypeAliasBounds: TypeAliasBounds,
|
|
|
|
|
|
|
|
TrivialConstraints: TrivialConstraints,
|
|
|
|
TypeLimits: TypeLimits::new(),
|
|
|
|
|
|
|
|
NonSnakeCase: NonSnakeCase,
|
|
|
|
InvalidNoMangleItems: InvalidNoMangleItems,
|
|
|
|
|
|
|
|
// Depends on access levels
|
|
|
|
UnreachablePub: UnreachablePub,
|
|
|
|
|
|
|
|
ExplicitOutlivesRequirements: ExplicitOutlivesRequirements,
|
|
|
|
]);
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! declare_combined_late_pass {
|
|
|
|
([$v:vis $name:ident], $passes:tt) => (
|
|
|
|
late_lint_methods!(declare_combined_late_lint_pass, [$v $name, $passes], ['tcx]);
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: Make a separate lint type which do not require typeck tables
|
|
|
|
late_lint_passes!(declare_combined_late_pass, [pub BuiltinCombinedLateLintPass]);
|
|
|
|
|
|
|
|
late_lint_mod_passes!(declare_combined_late_pass, [BuiltinCombinedModuleLateLintPass]);
|
|
|
|
|
2015-02-25 12:03:44 +00:00
|
|
|
/// Tell the `LintStore` about all the built-in lints (the ones
|
|
|
|
/// defined in this crate and the ones defined in
|
|
|
|
/// `rustc::lint::builtin`).
|
2015-02-25 11:44:44 +00:00
|
|
|
pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
|
2019-01-18 06:40:55 +00:00
|
|
|
macro_rules! add_lint_group {
|
|
|
|
($sess:ident, $name:expr, $($lint:ident),*) => (
|
|
|
|
store.register_group($sess, false, $name, None, vec![$(LintId::of($lint)),*]);
|
2018-09-15 14:26:45 +00:00
|
|
|
)
|
2018-07-14 14:40:17 +00:00
|
|
|
}
|
|
|
|
|
2019-01-31 00:36:11 +00:00
|
|
|
macro_rules! register_pass {
|
|
|
|
($method:ident, $constructor:expr, [$($args:expr),*]) => (
|
|
|
|
store.$method(sess, false, false, $($args,)* box $constructor);
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-01-18 06:40:55 +00:00
|
|
|
macro_rules! register_passes {
|
2019-01-31 00:36:11 +00:00
|
|
|
([$method:ident, $args:tt], [$($passes:ident: $constructor:expr,)*]) => (
|
2019-01-18 06:40:55 +00:00
|
|
|
$(
|
2019-01-31 00:36:11 +00:00
|
|
|
register_pass!($method, $constructor, $args);
|
2019-01-18 06:40:55 +00:00
|
|
|
)*
|
2018-09-15 14:26:45 +00:00
|
|
|
)
|
2016-10-18 05:04:28 +00:00
|
|
|
}
|
|
|
|
|
2019-01-18 06:40:55 +00:00
|
|
|
if sess.map(|sess| sess.opts.debugging_opts.no_interleave_lints).unwrap_or(false) {
|
2019-01-31 00:36:11 +00:00
|
|
|
pre_expansion_lint_passes!(register_passes, [register_pre_expansion_pass, []]);
|
|
|
|
early_lint_passes!(register_passes, [register_early_pass, []]);
|
|
|
|
late_lint_passes!(register_passes, [register_late_pass, [false]]);
|
|
|
|
late_lint_mod_passes!(register_passes, [register_late_pass, [true]]);
|
2019-01-18 06:40:55 +00:00
|
|
|
} else {
|
|
|
|
store.register_pre_expansion_pass(
|
|
|
|
sess,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
box BuiltinCombinedPreExpansionLintPass::new()
|
|
|
|
);
|
|
|
|
store.register_early_pass(sess, false, true, box BuiltinCombinedEarlyLintPass::new());
|
2019-01-31 00:36:11 +00:00
|
|
|
store.register_late_pass(
|
|
|
|
sess, false, true, true, box BuiltinCombinedModuleLateLintPass::new()
|
|
|
|
);
|
|
|
|
store.register_late_pass(
|
|
|
|
sess, false, true, false, box BuiltinCombinedLateLintPass::new()
|
|
|
|
);
|
2015-02-25 11:44:44 +00:00
|
|
|
}
|
|
|
|
|
2018-02-20 21:28:51 +00:00
|
|
|
add_lint_group!(sess,
|
|
|
|
"nonstandard_style",
|
|
|
|
NON_CAMEL_CASE_TYPES,
|
|
|
|
NON_SNAKE_CASE,
|
|
|
|
NON_UPPER_CASE_GLOBALS);
|
|
|
|
|
2016-10-09 04:08:07 +00:00
|
|
|
add_lint_group!(sess,
|
|
|
|
"unused",
|
|
|
|
UNUSED_IMPORTS,
|
|
|
|
UNUSED_VARIABLES,
|
|
|
|
UNUSED_ASSIGNMENTS,
|
|
|
|
DEAD_CODE,
|
|
|
|
UNUSED_MUT,
|
|
|
|
UNREACHABLE_CODE,
|
2016-11-29 07:10:26 +00:00
|
|
|
UNREACHABLE_PATTERNS,
|
2016-10-09 04:08:07 +00:00
|
|
|
UNUSED_MUST_USE,
|
|
|
|
UNUSED_UNSAFE,
|
|
|
|
PATH_STATEMENTS,
|
2017-05-11 08:26:07 +00:00
|
|
|
UNUSED_ATTRIBUTES,
|
2017-10-20 21:00:57 +00:00
|
|
|
UNUSED_MACROS,
|
|
|
|
UNUSED_ALLOCATION,
|
2018-05-18 22:13:53 +00:00
|
|
|
UNUSED_DOC_COMMENTS,
|
2017-10-20 21:00:57 +00:00
|
|
|
UNUSED_EXTERN_CRATES,
|
|
|
|
UNUSED_FEATURES,
|
2018-05-18 23:53:39 +00:00
|
|
|
UNUSED_LABELS,
|
2017-10-20 21:00:57 +00:00
|
|
|
UNUSED_PARENS);
|
2015-02-25 11:44:44 +00:00
|
|
|
|
2018-03-08 21:23:52 +00:00
|
|
|
add_lint_group!(sess,
|
2018-05-10 18:28:11 +00:00
|
|
|
"rust_2018_idioms",
|
2018-05-18 22:13:53 +00:00
|
|
|
BARE_TRAIT_OBJECTS,
|
2018-05-29 02:32:03 +00:00
|
|
|
UNUSED_EXTERN_CRATES,
|
2018-07-31 22:45:11 +00:00
|
|
|
ELLIPSIS_INCLUSIVE_RANGE_PATTERNS,
|
in which inferable outlives-requirements are linted
RFC 2093 (tracking issue #44493) lets us leave off
commonsensically inferable `T: 'a` outlives requirements. (A separate
feature-gate was split off for the case of 'static lifetimes, for
which questions still remain.) Detecting these was requested as an
idioms-2018 lint.
It turns out that issuing a correct, autofixable suggestion here is
somewhat subtle in the presence of other bounds and generic
parameters. Basically, we want to handle these three cases:
• One outlives-bound. We want to drop the bound altogether, including
the colon—
MyStruct<'a, T: 'a>
^^^^ help: remove this bound
• An outlives bound first, followed by a trait bound. We want to
delete the outlives bound and the following plus sign (and
hopefully get the whitespace right, too)—
MyStruct<'a, T: 'a + MyTrait>
^^^^^ help: remove this bound
• An outlives bound after a trait bound. We want to delete the
outlives lifetime and the preceding plus sign—
MyStruct<'a, T: MyTrait + 'a>
^^^^^ help: remove this bound
This gets (slightly) even more complicated in the case of where
clauses, where we want to drop the where clause altogether if there's
just the one bound. Hopefully the comments are enough to explain
what's going on!
A script (in Python, sorry) was used to generate the
hopefully-sufficiently-exhaustive UI test input. Some of these are
split off into a different file because rust-lang-nursery/rustfix#141
(and, causally upstream of that, #53934) prevents them from being
`run-rustfix`-tested.
We also make sure to include a UI test of a case (copied from RFC
2093) where the outlives-bound can't be inferred. Special thanks to
Niko Matsakis for pointing out the `inferred_outlives_of` query,
rather than blindly stripping outlives requirements as if we weren't a
production compiler and didn't care.
This concerns #52042.
2018-08-26 19:22:04 +00:00
|
|
|
ELIDED_LIFETIMES_IN_PATHS,
|
|
|
|
EXPLICIT_OUTLIVES_REQUIREMENTS
|
2018-07-31 22:45:11 +00:00
|
|
|
|
|
|
|
// FIXME(#52665, #47816) not always applicable and not all
|
|
|
|
// macros are ready for this yet.
|
|
|
|
// UNREACHABLE_PUB,
|
|
|
|
|
|
|
|
// FIXME macro crates are not up for this yet, too much
|
|
|
|
// breakage is seen if we try to encourage this lint.
|
|
|
|
// MACRO_USE_EXTERN_CRATE,
|
|
|
|
);
|
2018-03-08 21:23:52 +00:00
|
|
|
|
2018-12-10 20:58:57 +00:00
|
|
|
add_lint_group!(sess,
|
|
|
|
"rustdoc",
|
|
|
|
INTRA_DOC_LINK_RESOLUTION_FAILURE,
|
|
|
|
MISSING_DOC_CODE_EXAMPLES,
|
|
|
|
PRIVATE_DOC_TESTS);
|
|
|
|
|
2016-01-08 22:53:44 +00:00
|
|
|
// Guidelines for creating a future incompatibility lint:
|
|
|
|
//
|
|
|
|
// - Create a lint defaulting to warn as normal, with ideally the same error
|
|
|
|
// message you would normally give
|
|
|
|
// - Add a suitable reference, typically an RFC or tracking issue. Go ahead
|
2017-05-21 11:11:08 +00:00
|
|
|
// and include the full URL, sort items in ascending order of issue numbers.
|
2016-01-08 22:53:44 +00:00
|
|
|
// - Later, change lint to error
|
|
|
|
// - Eventually, remove lint
|
2018-11-27 02:59:49 +00:00
|
|
|
store.register_future_incompatible(sess, vec![
|
2016-01-08 22:53:44 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(PRIVATE_IN_PUBLIC),
|
2016-06-10 20:30:05 +00:00
|
|
|
reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
|
2018-03-15 03:30:06 +00:00
|
|
|
edition: None,
|
2016-01-08 22:53:44 +00:00
|
|
|
},
|
2017-06-25 02:50:51 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(PUB_USE_OF_PRIVATE_EXTERN_CRATE),
|
|
|
|
reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
|
2018-03-15 03:30:06 +00:00
|
|
|
edition: None,
|
2017-06-25 02:50:51 +00:00
|
|
|
},
|
2016-02-12 06:42:44 +00:00
|
|
|
FutureIncompatibleInfo {
|
2017-05-21 11:11:08 +00:00
|
|
|
id: LintId::of(PATTERNS_IN_FNS_WITHOUT_BODY),
|
|
|
|
reference: "issue #35203 <https://github.com/rust-lang/rust/issues/35203>",
|
2018-03-15 03:30:06 +00:00
|
|
|
edition: None,
|
2017-01-21 07:15:23 +00:00
|
|
|
},
|
2018-04-21 14:18:38 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(DUPLICATE_MACRO_EXPORTS),
|
|
|
|
reference: "issue #35896 <https://github.com/rust-lang/rust/issues/35896>",
|
|
|
|
edition: Some(Edition::Edition2018),
|
|
|
|
},
|
2018-07-17 17:56:41 +00:00
|
|
|
FutureIncompatibleInfo {
|
2018-08-24 20:48:20 +00:00
|
|
|
id: LintId::of(KEYWORD_IDENTS),
|
2018-07-17 17:56:41 +00:00
|
|
|
reference: "issue #49716 <https://github.com/rust-lang/rust/issues/49716>",
|
|
|
|
edition: Some(Edition::Edition2018),
|
|
|
|
},
|
2016-08-26 16:23:42 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(SAFE_EXTERN_STATICS),
|
2017-05-21 11:11:08 +00:00
|
|
|
reference: "issue #36247 <https://github.com/rust-lang/rust/issues/36247>",
|
2018-03-15 03:30:06 +00:00
|
|
|
edition: None,
|
2016-10-22 00:33:36 +00:00
|
|
|
},
|
2017-05-26 22:52:25 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(INVALID_TYPE_PARAM_DEFAULT),
|
|
|
|
reference: "issue #36887 <https://github.com/rust-lang/rust/issues/36887>",
|
2018-03-15 03:30:06 +00:00
|
|
|
edition: None,
|
2017-05-26 22:52:25 +00:00
|
|
|
},
|
2016-11-14 09:31:03 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(LEGACY_DIRECTORY_OWNERSHIP),
|
|
|
|
reference: "issue #37872 <https://github.com/rust-lang/rust/issues/37872>",
|
2018-03-15 03:30:06 +00:00
|
|
|
edition: None,
|
2016-11-14 09:31:03 +00:00
|
|
|
},
|
2017-01-20 15:53:49 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(LEGACY_CONSTRUCTOR_VISIBILITY),
|
|
|
|
reference: "issue #39207 <https://github.com/rust-lang/rust/issues/39207>",
|
2018-03-15 03:30:06 +00:00
|
|
|
edition: None,
|
2017-01-20 15:53:49 +00:00
|
|
|
},
|
2017-02-26 03:25:22 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(MISSING_FRAGMENT_SPECIFIER),
|
|
|
|
reference: "issue #40107 <https://github.com/rust-lang/rust/issues/40107>",
|
2018-03-15 03:30:06 +00:00
|
|
|
edition: None,
|
2017-02-26 03:25:22 +00:00
|
|
|
},
|
2017-05-26 13:20:53 +00:00
|
|
|
FutureIncompatibleInfo {
|
2017-05-21 11:11:08 +00:00
|
|
|
id: LintId::of(ILLEGAL_FLOATING_POINT_LITERAL_PATTERN),
|
|
|
|
reference: "issue #41620 <https://github.com/rust-lang/rust/issues/41620>",
|
2018-03-15 03:30:06 +00:00
|
|
|
edition: None,
|
2017-05-26 13:20:53 +00:00
|
|
|
},
|
2017-05-02 02:38:46 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(ANONYMOUS_PARAMETERS),
|
|
|
|
reference: "issue #41686 <https://github.com/rust-lang/rust/issues/41686>",
|
2018-08-27 17:14:31 +00:00
|
|
|
edition: Some(Edition::Edition2018),
|
2017-05-02 02:38:46 +00:00
|
|
|
},
|
2017-05-21 11:11:08 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES),
|
|
|
|
reference: "issue #42238 <https://github.com/rust-lang/rust/issues/42238>",
|
2018-03-15 03:30:06 +00:00
|
|
|
edition: None,
|
2017-06-23 21:56:25 +00:00
|
|
|
},
|
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(LATE_BOUND_LIFETIME_ARGUMENTS),
|
|
|
|
reference: "issue #42868 <https://github.com/rust-lang/rust/issues/42868>",
|
2018-03-15 03:30:06 +00:00
|
|
|
edition: None,
|
2017-06-23 21:56:25 +00:00
|
|
|
},
|
2017-11-16 18:12:23 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(SAFE_PACKED_BORROWS),
|
|
|
|
reference: "issue #46043 <https://github.com/rust-lang/rust/issues/46043>",
|
2018-03-15 03:30:06 +00:00
|
|
|
edition: None,
|
2017-11-16 18:12:23 +00:00
|
|
|
},
|
2018-12-03 21:27:22 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(ORDER_DEPENDENT_TRAIT_OBJECTS),
|
2018-12-03 23:00:21 +00:00
|
|
|
reference: "issue #56484 <https://github.com/rust-lang/rust/issues/56484>",
|
2018-12-03 21:27:22 +00:00
|
|
|
edition: None,
|
|
|
|
},
|
2017-12-21 16:20:53 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(TYVAR_BEHIND_RAW_POINTER),
|
|
|
|
reference: "issue #46906 <https://github.com/rust-lang/rust/issues/46906>",
|
2018-03-15 03:30:06 +00:00
|
|
|
edition: Some(Edition::Edition2018),
|
2018-02-26 13:34:06 +00:00
|
|
|
},
|
|
|
|
FutureIncompatibleInfo {
|
2018-05-18 22:13:53 +00:00
|
|
|
id: LintId::of(UNSTABLE_NAME_COLLISIONS),
|
2018-03-10 17:58:57 +00:00
|
|
|
reference: "issue #48919 <https://github.com/rust-lang/rust/issues/48919>",
|
2018-02-26 13:34:06 +00:00
|
|
|
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.
|
|
|
|
},
|
2018-04-19 23:45:33 +00:00
|
|
|
FutureIncompatibleInfo {
|
2018-05-18 22:13:53 +00:00
|
|
|
id: LintId::of(ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE),
|
2018-10-20 18:17:42 +00:00
|
|
|
reference: "issue #53130 <https://github.com/rust-lang/rust/issues/53130>",
|
2018-04-19 23:45:33 +00:00
|
|
|
edition: Some(Edition::Edition2018),
|
|
|
|
},
|
2018-05-30 12:06:08 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(WHERE_CLAUSES_OBJECT_SAFETY),
|
2018-06-08 21:26:37 +00:00
|
|
|
reference: "issue #51443 <https://github.com/rust-lang/rust/issues/51443>",
|
2018-05-30 12:06:08 +00:00
|
|
|
edition: None,
|
2018-05-19 14:47:34 +00:00
|
|
|
},
|
2018-07-07 20:07:06 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(PROC_MACRO_DERIVE_RESOLUTION_FALLBACK),
|
|
|
|
reference: "issue #50504 <https://github.com/rust-lang/rust/issues/50504>",
|
|
|
|
edition: None,
|
|
|
|
},
|
2018-08-23 23:51:41 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS),
|
|
|
|
reference: "issue #52234 <https://github.com/rust-lang/rust/issues/52234>",
|
|
|
|
edition: None,
|
|
|
|
},
|
2019-01-01 23:21:05 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(ILL_FORMED_ATTRIBUTE_INPUT),
|
2019-01-12 16:00:42 +00:00
|
|
|
reference: "issue #57571 <https://github.com/rust-lang/rust/issues/57571>",
|
2019-01-01 23:21:05 +00:00
|
|
|
edition: None,
|
|
|
|
},
|
2019-01-10 20:23:30 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(AMBIGUOUS_ASSOCIATED_ITEMS),
|
|
|
|
reference: "issue #57644 <https://github.com/rust-lang/rust/issues/57644>",
|
|
|
|
edition: None,
|
|
|
|
},
|
2019-02-20 21:24:32 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(NESTED_IMPL_TRAIT),
|
|
|
|
reference: "issue #59014 <https://github.com/rust-lang/rust/issues/59014>",
|
|
|
|
edition: None,
|
|
|
|
},
|
2019-03-13 19:15:58 +00:00
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(MUTABLE_BORROW_RESERVATION_CONFLICT),
|
|
|
|
reference: "issue #59159 <https://github.com/rust-lang/rust/issues/59159>",
|
|
|
|
edition: None,
|
2019-07-08 09:11:41 +00:00
|
|
|
},
|
|
|
|
FutureIncompatibleInfo {
|
|
|
|
id: LintId::of(INDIRECT_STRUCTURAL_MATCH),
|
|
|
|
reference: "issue #62411 <https://github.com/rust-lang/rust/issues/62411>",
|
|
|
|
edition: None,
|
2019-03-13 19:15:58 +00:00
|
|
|
}
|
2016-01-08 22:53:44 +00:00
|
|
|
]);
|
2015-11-26 17:56:20 +00:00
|
|
|
|
2018-11-27 02:59:49 +00:00
|
|
|
// Register renamed and removed lints.
|
2018-05-18 22:13:53 +00:00
|
|
|
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");
|
2018-08-24 20:48:20 +00:00
|
|
|
store.register_renamed("async_idents", "keyword_idents");
|
2018-07-23 20:05:39 +00:00
|
|
|
store.register_removed("unknown_features", "replaced by an error");
|
2017-10-20 21:00:57 +00:00
|
|
|
store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate");
|
2016-01-11 11:31:46 +00:00
|
|
|
store.register_removed("negate_unsigned", "cast a signed value instead");
|
2016-01-13 18:54:06 +00:00
|
|
|
store.register_removed("raw_pointer_derive", "using derive with raw pointers is ok");
|
2018-11-27 02:59:49 +00:00
|
|
|
// Register lint group aliases.
|
2018-09-15 14:26:45 +00:00
|
|
|
store.register_group_alias("nonstandard_style", "bad_style");
|
2018-11-27 02:59:49 +00:00
|
|
|
// This was renamed to `raw_pointer_derive`, which was then removed,
|
|
|
|
// so it is also considered removed.
|
2017-10-20 21:00:57 +00:00
|
|
|
store.register_removed("raw_pointer_deriving", "using derive with raw pointers is ok");
|
2016-08-23 07:39:30 +00:00
|
|
|
store.register_removed("drop_with_repr_extern", "drop flags have been removed");
|
2017-10-20 21:00:57 +00:00
|
|
|
store.register_removed("fat_ptr_transmutes", "was accidentally removed back in 2014");
|
|
|
|
store.register_removed("deprecated_attr", "use `deprecated` instead");
|
2016-06-10 10:00:21 +00:00
|
|
|
store.register_removed("transmute_from_fn_item_types",
|
|
|
|
"always cast functions before transmuting them");
|
2017-05-21 11:11:08 +00:00
|
|
|
store.register_removed("hr_lifetime_in_assoc_type",
|
|
|
|
"converted into hard error, see https://github.com/rust-lang/rust/issues/33685");
|
|
|
|
store.register_removed("inaccessible_extern_crate",
|
|
|
|
"converted into hard error, see https://github.com/rust-lang/rust/issues/36886");
|
|
|
|
store.register_removed("super_or_self_in_global_path",
|
|
|
|
"converted into hard error, see https://github.com/rust-lang/rust/issues/36888");
|
|
|
|
store.register_removed("overlapping_inherent_impls",
|
|
|
|
"converted into hard error, see https://github.com/rust-lang/rust/issues/36889");
|
|
|
|
store.register_removed("illegal_floating_point_constant_pattern",
|
|
|
|
"converted into hard error, see https://github.com/rust-lang/rust/issues/36890");
|
|
|
|
store.register_removed("illegal_struct_or_enum_constant_pattern",
|
|
|
|
"converted into hard error, see https://github.com/rust-lang/rust/issues/36891");
|
|
|
|
store.register_removed("lifetime_underscore",
|
|
|
|
"converted into hard error, see https://github.com/rust-lang/rust/issues/36892");
|
2017-11-01 18:23:30 +00:00
|
|
|
store.register_removed("extra_requirement_in_impl",
|
|
|
|
"converted into hard error, see https://github.com/rust-lang/rust/issues/37166");
|
2018-05-14 22:24:34 +00:00
|
|
|
store.register_removed("legacy_imports",
|
|
|
|
"converted into hard error, see https://github.com/rust-lang/rust/issues/38260");
|
2018-03-14 04:04:29 +00:00
|
|
|
store.register_removed("coerce_never",
|
|
|
|
"converted into hard error, see https://github.com/rust-lang/rust/issues/48950");
|
|
|
|
store.register_removed("resolve_trait_on_defaulted_unit",
|
|
|
|
"converted into hard error, see https://github.com/rust-lang/rust/issues/48950");
|
2018-09-21 22:58:11 +00:00
|
|
|
store.register_removed("private_no_mangle_fns",
|
2019-07-18 22:05:23 +00:00
|
|
|
"no longer a warning, `#[no_mangle]` functions always exported");
|
2018-09-21 22:58:11 +00:00
|
|
|
store.register_removed("private_no_mangle_statics",
|
2019-07-18 22:05:23 +00:00
|
|
|
"no longer a warning, `#[no_mangle]` statics always exported");
|
2019-01-01 23:21:05 +00:00
|
|
|
store.register_removed("bad_repr",
|
|
|
|
"replaced with a generic attribute input check");
|
2019-03-28 17:36:13 +00:00
|
|
|
store.register_removed("duplicate_matcher_binding_name",
|
|
|
|
"converted into hard error, see https://github.com/rust-lang/rust/issues/57742");
|
2018-05-10 05:42:03 +00:00
|
|
|
store.register_removed("incoherent_fundamental_impls",
|
|
|
|
"converted into hard error, see https://github.com/rust-lang/rust/issues/46205");
|
2015-02-25 11:44:44 +00:00
|
|
|
}
|
2018-12-06 13:03:12 +00:00
|
|
|
|
|
|
|
pub fn register_internals(store: &mut lint::LintStore, sess: Option<&Session>) {
|
|
|
|
store.register_early_pass(sess, false, false, box DefaultHashTypes::new());
|
2019-05-02 14:53:12 +00:00
|
|
|
store.register_early_pass(sess, false, false, box LintPassImpl);
|
2019-04-24 21:22:54 +00:00
|
|
|
store.register_late_pass(sess, false, false, false, box TyTyKind);
|
2018-12-06 13:03:12 +00:00
|
|
|
store.register_group(
|
|
|
|
sess,
|
|
|
|
false,
|
2019-06-17 15:06:11 +00:00
|
|
|
"rustc::internal",
|
2018-12-06 13:03:12 +00:00
|
|
|
None,
|
|
|
|
vec![
|
|
|
|
LintId::of(DEFAULT_HASH_TYPES),
|
|
|
|
LintId::of(USAGE_OF_TY_TYKIND),
|
2019-05-02 14:53:12 +00:00
|
|
|
LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO),
|
2019-04-24 21:22:54 +00:00
|
|
|
LintId::of(TY_PASS_BY_REFERENCE),
|
|
|
|
LintId::of(USAGE_OF_QUALIFIED_TY),
|
2018-12-06 13:03:12 +00:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|