]>
Commit | Line | Data |
---|---|---|
dfeec247 | 1 | //! Lints, aka compiler warnings. |
c34b1796 | 2 | //! |
dfeec247 XL |
3 | //! A 'lint' check is a kind of miscellaneous constraint that a user _might_ |
4 | //! want to enforce, but might reasonably want to permit as well, on a | |
5 | //! module-by-module basis. They contrast with static constraints enforced by | |
6 | //! other phases of the compiler, which are generally required to hold in order | |
7 | //! to compile the program at all. | |
8 | //! | |
f9f354fc | 9 | //! Most lints can be written as [LintPass] instances. These run after |
dfeec247 | 10 | //! all other analyses. The `LintPass`es built into rustc are defined |
f9f354fc | 11 | //! within [rustc_session::lint::builtin], |
dfeec247 | 12 | //! which has further comments on how to add such a lint. |
ed00b5ec | 13 | //! rustc can also load external lint plugins, as is done for Clippy. |
dfeec247 XL |
14 | //! |
15 | //! Some of rustc's lints are defined elsewhere in the compiler and work by | |
16 | //! calling `add_lint()` on the overall `Session` object. This works when | |
17 | //! it happens before the main lint pass, which emits the lints stored by | |
18 | //! `add_lint()`. To emit lints after the main lint pass (from codegen, for | |
19 | //! example) requires more effort. See `emit_lint` and `GatherNodeLevels` | |
20 | //! in `context.rs`. | |
21 | //! | |
f9f354fc | 22 | //! Some code also exists in [rustc_session::lint], [rustc_middle::lint]. |
c34b1796 | 23 | //! |
0731742a | 24 | //! ## Note |
c34b1796 AL |
25 | //! |
26 | //! This API is completely unstable and subject to change. | |
27 | ||
5e7ed085 | 28 | #![allow(rustc::potential_query_instability)] |
1b1a35ee | 29 | #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] |
ed00b5ec FG |
30 | #![cfg_attr(not(bootstrap), doc(rust_logo))] |
31 | #![cfg_attr(not(bootstrap), feature(rustdoc_internals))] | |
1b1a35ee | 32 | #![feature(array_windows)] |
5869c6ff | 33 | #![feature(box_patterns)] |
5e7ed085 | 34 | #![feature(control_flow_enum)] |
5099ac24 | 35 | #![feature(if_let_guard)] |
5e7ed085 | 36 | #![feature(iter_intersperse)] |
f035d41b | 37 | #![feature(iter_order_by)] |
5e7ed085 | 38 | #![feature(let_chains)] |
2b03887a | 39 | #![feature(min_specialization)] |
dfeec247 | 40 | #![feature(never_type)] |
487cf647 | 41 | #![feature(rustc_attrs)] |
dfeec247 | 42 | #![recursion_limit = "256"] |
9c376795 FG |
43 | #![deny(rustc::untranslatable_diagnostic)] |
44 | #![deny(rustc::diagnostic_outside_of_impl)] | |
781aab86 | 45 | #![allow(internal_features)] |
0731742a | 46 | |
c34b1796 | 47 | #[macro_use] |
ba9703b0 | 48 | extern crate rustc_middle; |
60c5eb7d XL |
49 | #[macro_use] |
50 | extern crate rustc_session; | |
f2b60f7d FG |
51 | #[macro_use] |
52 | extern crate tracing; | |
c34b1796 | 53 | |
60c5eb7d | 54 | mod array_into_iter; |
ed00b5ec | 55 | mod async_fn_in_trait; |
dfeec247 XL |
56 | pub mod builtin; |
57 | mod context; | |
487cf647 | 58 | mod deref_into_dyn_supertrait; |
49aad941 | 59 | mod drop_forget_useless; |
dfeec247 | 60 | mod early; |
c295e0f8 | 61 | mod enum_intrinsics_non_enums; |
f2b60f7d | 62 | mod errors; |
5e7ed085 | 63 | mod expect; |
2b03887a | 64 | mod for_loops_over_fallibles; |
add651ee | 65 | mod foreign_modules; |
c295e0f8 | 66 | pub mod hidden_unicode_codepoints; |
dfeec247 | 67 | mod internal; |
fe692bf9 | 68 | mod invalid_from_utf8; |
dfeec247 | 69 | mod late; |
f2b60f7d | 70 | mod let_underscore; |
dfeec247 | 71 | mod levels; |
9c376795 | 72 | mod lints; |
9ffffee4 | 73 | mod map_unit_fn; |
29967ef6 | 74 | mod methods; |
9ffffee4 | 75 | mod multiple_supertrait_upcastable; |
dfeec247 | 76 | mod non_ascii_idents; |
5869c6ff | 77 | mod non_fmt_panic; |
0731742a | 78 | mod nonstandard_style; |
6a06907d | 79 | mod noop_method_call; |
2b03887a | 80 | mod opaque_hidden_inferred_bound; |
5099ac24 | 81 | mod pass_by_value; |
dfeec247 | 82 | mod passes; |
add651ee | 83 | mod ptr_nulls; |
e1599b0c | 84 | mod redundant_semicolon; |
fe692bf9 | 85 | mod reference_casting; |
29967ef6 | 86 | mod traits; |
0731742a XL |
87 | mod types; |
88 | mod unused; | |
89 | ||
94222f64 XL |
90 | pub use array_into_iter::ARRAY_INTO_ITER; |
91 | ||
9ffffee4 | 92 | use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage}; |
49aad941 | 93 | use rustc_fluent_macro::fluent_messages; |
781aab86 | 94 | use rustc_hir::def_id::LocalModDefId; |
49aad941 | 95 | use rustc_middle::query::Providers; |
ba9703b0 | 96 | use rustc_middle::ty::TyCtxt; |
dfeec247 | 97 | use rustc_session::lint::builtin::{ |
6a06907d | 98 | BARE_TRAIT_OBJECTS, ELIDED_LIFETIMES_IN_PATHS, EXPLICIT_OUTLIVES_REQUIREMENTS, |
dfeec247 | 99 | }; |
c34b1796 | 100 | |
dfeec247 | 101 | use array_into_iter::ArrayIntoIter; |
ed00b5ec | 102 | use async_fn_in_trait::AsyncFnInTrait; |
b039eaaf | 103 | use builtin::*; |
487cf647 | 104 | use deref_into_dyn_supertrait::*; |
49aad941 | 105 | use drop_forget_useless::*; |
c295e0f8 | 106 | use enum_intrinsics_non_enums::EnumIntrinsicsNonEnums; |
2b03887a | 107 | use for_loops_over_fallibles::*; |
c295e0f8 | 108 | use hidden_unicode_codepoints::*; |
dfeec247 | 109 | use internal::*; |
fe692bf9 | 110 | use invalid_from_utf8::*; |
f2b60f7d | 111 | use let_underscore::*; |
9ffffee4 | 112 | use map_unit_fn::*; |
29967ef6 | 113 | use methods::*; |
9ffffee4 | 114 | use multiple_supertrait_upcastable::*; |
dfeec247 | 115 | use non_ascii_idents::*; |
5869c6ff | 116 | use non_fmt_panic::NonPanicFmt; |
dfeec247 | 117 | use nonstandard_style::*; |
6a06907d | 118 | use noop_method_call::*; |
2b03887a | 119 | use opaque_hidden_inferred_bound::*; |
5099ac24 | 120 | use pass_by_value::*; |
add651ee | 121 | use ptr_nulls::*; |
dfeec247 | 122 | use redundant_semicolon::*; |
fe692bf9 | 123 | use reference_casting::*; |
29967ef6 | 124 | use traits::*; |
b039eaaf SL |
125 | use types::*; |
126 | use unused::*; | |
c34b1796 | 127 | |
dfeec247 | 128 | /// Useful for other parts of the compiler / Clippy. |
add651ee | 129 | pub use builtin::{MissingDoc, SoftLints}; |
5099ac24 FG |
130 | pub use context::{CheckLintNameResult, FindLintError, LintStore}; |
131 | pub use context::{EarlyContext, LateContext, LintContext}; | |
132 | pub use early::{check_ast_node, EarlyCheckNode}; | |
add651ee | 133 | pub use late::{check_crate, late_lint_mod, unerased_lint_store}; |
dfeec247 XL |
134 | pub use passes::{EarlyLintPass, LateLintPass}; |
135 | pub use rustc_session::lint::Level::{self, *}; | |
136 | pub use rustc_session::lint::{BufferedEarlyLint, FutureIncompatibleInfo, Lint, LintId}; | |
781aab86 | 137 | pub use rustc_session::lint::{LintPass, LintVec}; |
94b46f34 | 138 | |
353b0b11 | 139 | fluent_messages! { "../messages.ftl" } |
9ffffee4 | 140 | |
f035d41b | 141 | pub fn provide(providers: &mut Providers) { |
dfeec247 | 142 | levels::provide(providers); |
04454e1e | 143 | expect::provide(providers); |
add651ee | 144 | foreign_modules::provide(providers); |
dfeec247 | 145 | *providers = Providers { lint_mod, ..*providers }; |
532ac7d7 XL |
146 | } |
147 | ||
add651ee FG |
148 | fn lint_mod(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) { |
149 | late_lint_mod(tcx, module_def_id, BuiltinCombinedModuleLateLintPass::new()); | |
532ac7d7 XL |
150 | } |
151 | ||
487cf647 FG |
152 | early_lint_methods!( |
153 | declare_combined_early_lint_pass, | |
154 | [ | |
155 | pub BuiltinCombinedPreExpansionLintPass, | |
156 | [ | |
157 | KeywordIdents: KeywordIdents, | |
158 | ] | |
159 | ] | |
160 | ); | |
9fa01778 | 161 | |
487cf647 FG |
162 | early_lint_methods!( |
163 | declare_combined_early_lint_pass, | |
164 | [ | |
165 | pub BuiltinCombinedEarlyLintPass, | |
166 | [ | |
9c376795 | 167 | UnusedParens: UnusedParens::new(), |
487cf647 FG |
168 | UnusedBraces: UnusedBraces, |
169 | UnusedImportBraces: UnusedImportBraces, | |
170 | UnsafeCode: UnsafeCode, | |
171 | SpecialModuleName: SpecialModuleName, | |
172 | AnonymousParameters: AnonymousParameters, | |
173 | EllipsisInclusiveRangePatterns: EllipsisInclusiveRangePatterns::default(), | |
174 | NonCamelCaseTypes: NonCamelCaseTypes, | |
175 | DeprecatedAttr: DeprecatedAttr::new(), | |
176 | WhileTrue: WhileTrue, | |
177 | NonAsciiIdents: NonAsciiIdents, | |
178 | HiddenUnicodeCodepoints: HiddenUnicodeCodepoints, | |
add651ee | 179 | IncompleteInternalFeatures: IncompleteInternalFeatures, |
487cf647 FG |
180 | RedundantSemicolons: RedundantSemicolons, |
181 | UnusedDocComment: UnusedDocComment, | |
182 | UnexpectedCfgs: UnexpectedCfgs, | |
183 | ] | |
184 | ] | |
185 | ); | |
532ac7d7 | 186 | |
487cf647 FG |
187 | late_lint_methods!( |
188 | declare_combined_late_lint_pass, | |
189 | [ | |
190 | BuiltinCombinedModuleLateLintPass, | |
191 | [ | |
192 | ForLoopsOverFallibles: ForLoopsOverFallibles, | |
193 | DerefIntoDynSupertrait: DerefIntoDynSupertrait, | |
49aad941 | 194 | DropForgetUseless: DropForgetUseless, |
487cf647 FG |
195 | HardwiredLints: HardwiredLints, |
196 | ImproperCTypesDeclarations: ImproperCTypesDeclarations, | |
197 | ImproperCTypesDefinitions: ImproperCTypesDefinitions, | |
fe692bf9 | 198 | InvalidFromUtf8: InvalidFromUtf8, |
487cf647 FG |
199 | VariantSizeDifferences: VariantSizeDifferences, |
200 | BoxPointers: BoxPointers, | |
201 | PathStatements: PathStatements, | |
202 | LetUnderscore: LetUnderscore, | |
781aab86 | 203 | InvalidReferenceCasting: InvalidReferenceCasting, |
487cf647 FG |
204 | // Depends on referenced function signatures in expressions |
205 | UnusedResults: UnusedResults, | |
206 | NonUpperCaseGlobals: NonUpperCaseGlobals, | |
207 | NonShorthandFieldPatterns: NonShorthandFieldPatterns, | |
208 | UnusedAllocation: UnusedAllocation, | |
209 | // Depends on types used in type definitions | |
210 | MissingCopyImplementations: MissingCopyImplementations, | |
211 | // Depends on referenced function signatures in expressions | |
add651ee | 212 | PtrNullChecks: PtrNullChecks, |
487cf647 FG |
213 | MutableTransmutes: MutableTransmutes, |
214 | TypeAliasBounds: TypeAliasBounds, | |
215 | TrivialConstraints: TrivialConstraints, | |
216 | TypeLimits: TypeLimits::new(), | |
217 | NonSnakeCase: NonSnakeCase, | |
218 | InvalidNoMangleItems: InvalidNoMangleItems, | |
219 | // Depends on effective visibilities | |
220 | UnreachablePub: UnreachablePub, | |
221 | ExplicitOutlivesRequirements: ExplicitOutlivesRequirements, | |
222 | InvalidValue: InvalidValue, | |
223 | DerefNullPtr: DerefNullPtr, | |
224 | // May Depend on constants elsewhere | |
225 | UnusedBrokenConst: UnusedBrokenConst, | |
226 | UnstableFeatures: UnstableFeatures, | |
227 | UngatedAsyncFnTrackCaller: UngatedAsyncFnTrackCaller, | |
228 | ArrayIntoIter: ArrayIntoIter::default(), | |
229 | DropTraitConstraints: DropTraitConstraints, | |
230 | TemporaryCStringAsPtr: TemporaryCStringAsPtr, | |
231 | NonPanicFmt: NonPanicFmt, | |
232 | NoopMethodCall: NoopMethodCall, | |
233 | EnumIntrinsicsNonEnums: EnumIntrinsicsNonEnums, | |
234 | InvalidAtomicOrdering: InvalidAtomicOrdering, | |
235 | NamedAsmLabels: NamedAsmLabels, | |
236 | OpaqueHiddenInferredBound: OpaqueHiddenInferredBound, | |
9ffffee4 FG |
237 | MultipleSupertraitUpcastable: MultipleSupertraitUpcastable, |
238 | MapUnitFn: MapUnitFn, | |
add651ee FG |
239 | MissingDebugImplementations: MissingDebugImplementations, |
240 | MissingDoc: MissingDoc, | |
ed00b5ec | 241 | AsyncFnInTrait: AsyncFnInTrait, |
487cf647 | 242 | ] |
9c376795 | 243 | ] |
487cf647 | 244 | ); |
532ac7d7 | 245 | |
487cf647 | 246 | pub fn new_lint_store(internal_lints: bool) -> LintStore { |
dfeec247 | 247 | let mut lint_store = LintStore::new(); |
e74abb32 | 248 | |
487cf647 | 249 | register_builtins(&mut lint_store); |
e74abb32 XL |
250 | if internal_lints { |
251 | register_internals(&mut lint_store); | |
252 | } | |
253 | ||
254 | lint_store | |
255 | } | |
256 | ||
c34b1796 AL |
257 | /// Tell the `LintStore` about all the built-in lints (the ones |
258 | /// defined in this crate and the ones defined in | |
3dfed10e | 259 | /// `rustc_session::lint::builtin`). |
487cf647 | 260 | fn register_builtins(store: &mut LintStore) { |
c34b1796 | 261 | macro_rules! add_lint_group { |
e74abb32 XL |
262 | ($name:expr, $($lint:ident),*) => ( |
263 | store.register_group(false, $name, None, vec![$(LintId::of($lint)),*]); | |
0bf4aa26 | 264 | ) |
c34b1796 AL |
265 | } |
266 | ||
487cf647 FG |
267 | store.register_lints(&BuiltinCombinedPreExpansionLintPass::get_lints()); |
268 | store.register_lints(&BuiltinCombinedEarlyLintPass::get_lints()); | |
269 | store.register_lints(&BuiltinCombinedModuleLateLintPass::get_lints()); | |
add651ee | 270 | store.register_lints(&foreign_modules::get_lints()); |
c30ab7b3 | 271 | |
dfeec247 XL |
272 | add_lint_group!( |
273 | "nonstandard_style", | |
274 | NON_CAMEL_CASE_TYPES, | |
275 | NON_SNAKE_CASE, | |
276 | NON_UPPER_CASE_GLOBALS | |
277 | ); | |
b7449926 | 278 | |
dfeec247 XL |
279 | add_lint_group!( |
280 | "unused", | |
281 | UNUSED_IMPORTS, | |
282 | UNUSED_VARIABLES, | |
283 | UNUSED_ASSIGNMENTS, | |
284 | DEAD_CODE, | |
285 | UNUSED_MUT, | |
286 | UNREACHABLE_CODE, | |
287 | UNREACHABLE_PATTERNS, | |
dfeec247 XL |
288 | UNUSED_MUST_USE, |
289 | UNUSED_UNSAFE, | |
290 | PATH_STATEMENTS, | |
291 | UNUSED_ATTRIBUTES, | |
292 | UNUSED_MACROS, | |
04454e1e | 293 | UNUSED_MACRO_RULES, |
dfeec247 XL |
294 | UNUSED_ALLOCATION, |
295 | UNUSED_DOC_COMMENTS, | |
296 | UNUSED_EXTERN_CRATES, | |
297 | UNUSED_FEATURES, | |
298 | UNUSED_LABELS, | |
74b04a01 | 299 | UNUSED_PARENS, |
ba9703b0 | 300 | UNUSED_BRACES, |
9ffffee4 FG |
301 | REDUNDANT_SEMICOLONS, |
302 | MAP_UNIT_FN | |
dfeec247 | 303 | ); |
b7449926 | 304 | |
f2b60f7d FG |
305 | add_lint_group!("let_underscore", LET_UNDERSCORE_DROP, LET_UNDERSCORE_LOCK); |
306 | ||
dfeec247 XL |
307 | add_lint_group!( |
308 | "rust_2018_idioms", | |
309 | BARE_TRAIT_OBJECTS, | |
310 | UNUSED_EXTERN_CRATES, | |
311 | ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, | |
312 | ELIDED_LIFETIMES_IN_PATHS, | |
313 | EXPLICIT_OUTLIVES_REQUIREMENTS // FIXME(#52665, #47816) not always applicable and not all | |
314 | // macros are ready for this yet. | |
315 | // UNREACHABLE_PUB, | |
316 | ||
317 | // FIXME macro crates are not up for this yet, too much | |
318 | // breakage is seen if we try to encourage this lint. | |
319 | // MACRO_USE_EXTERN_CRATE | |
320 | ); | |
0531ce1d | 321 | |
0731742a | 322 | // Register renamed and removed lints. |
83c7162d XL |
323 | store.register_renamed("single_use_lifetime", "single_use_lifetimes"); |
324 | store.register_renamed("elided_lifetime_in_path", "elided_lifetimes_in_paths"); | |
325 | store.register_renamed("bare_trait_object", "bare_trait_objects"); | |
326 | store.register_renamed("unstable_name_collision", "unstable_name_collisions"); | |
327 | store.register_renamed("unused_doc_comment", "unused_doc_comments"); | |
b7449926 | 328 | store.register_renamed("async_idents", "keyword_idents"); |
74b04a01 XL |
329 | store.register_renamed("exceeding_bitshifts", "arithmetic_overflow"); |
330 | store.register_renamed("redundant_semicolon", "redundant_semicolons"); | |
fc512014 | 331 | store.register_renamed("overlapping_patterns", "overlapping_range_endpoints"); |
136023e0 XL |
332 | store.register_renamed("disjoint_capture_migration", "rust_2021_incompatible_closure_captures"); |
333 | store.register_renamed("or_patterns_back_compat", "rust_2021_incompatible_or_patterns"); | |
334 | store.register_renamed("non_fmt_panic", "non_fmt_panics"); | |
6a06907d XL |
335 | |
336 | // These were moved to tool lints, but rustc still sees them when compiling normally, before | |
337 | // tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use | |
338 | // `register_removed` explicitly. | |
339 | const RUSTDOC_LINTS: &[&str] = &[ | |
340 | "broken_intra_doc_links", | |
341 | "private_intra_doc_links", | |
342 | "missing_crate_level_docs", | |
343 | "missing_doc_code_examples", | |
344 | "private_doc_tests", | |
345 | "invalid_codeblock_attributes", | |
346 | "invalid_html_tags", | |
347 | "non_autolinks", | |
348 | ]; | |
349 | for rustdoc_lint in RUSTDOC_LINTS { | |
350 | store.register_ignored(rustdoc_lint); | |
351 | } | |
352 | store.register_removed( | |
353 | "intra_doc_link_resolution_failure", | |
354 | "use `rustdoc::broken_intra_doc_links` instead", | |
355 | ); | |
356 | store.register_removed("rustdoc", "use `rustdoc::all` instead"); | |
357 | ||
b7449926 | 358 | store.register_removed("unknown_features", "replaced by an error"); |
abe05a73 | 359 | store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate"); |
9cc50fc6 | 360 | store.register_removed("negate_unsigned", "cast a signed value instead"); |
92a42be0 | 361 | store.register_removed("raw_pointer_derive", "using derive with raw pointers is ok"); |
0731742a | 362 | // Register lint group aliases. |
0bf4aa26 | 363 | store.register_group_alias("nonstandard_style", "bad_style"); |
0731742a XL |
364 | // This was renamed to `raw_pointer_derive`, which was then removed, |
365 | // so it is also considered removed. | |
abe05a73 | 366 | store.register_removed("raw_pointer_deriving", "using derive with raw pointers is ok"); |
9e0c209e | 367 | store.register_removed("drop_with_repr_extern", "drop flags have been removed"); |
abe05a73 XL |
368 | store.register_removed("fat_ptr_transmutes", "was accidentally removed back in 2014"); |
369 | store.register_removed("deprecated_attr", "use `deprecated` instead"); | |
dfeec247 XL |
370 | store.register_removed( |
371 | "transmute_from_fn_item_types", | |
372 | "always cast functions before transmuting them", | |
373 | ); | |
374 | store.register_removed( | |
375 | "hr_lifetime_in_assoc_type", | |
74b04a01 XL |
376 | "converted into hard error, see issue #33685 \ |
377 | <https://github.com/rust-lang/rust/issues/33685> for more information", | |
dfeec247 XL |
378 | ); |
379 | store.register_removed( | |
380 | "inaccessible_extern_crate", | |
74b04a01 XL |
381 | "converted into hard error, see issue #36886 \ |
382 | <https://github.com/rust-lang/rust/issues/36886> for more information", | |
dfeec247 XL |
383 | ); |
384 | store.register_removed( | |
385 | "super_or_self_in_global_path", | |
74b04a01 XL |
386 | "converted into hard error, see issue #36888 \ |
387 | <https://github.com/rust-lang/rust/issues/36888> for more information", | |
dfeec247 XL |
388 | ); |
389 | store.register_removed( | |
390 | "overlapping_inherent_impls", | |
74b04a01 XL |
391 | "converted into hard error, see issue #36889 \ |
392 | <https://github.com/rust-lang/rust/issues/36889> for more information", | |
dfeec247 XL |
393 | ); |
394 | store.register_removed( | |
395 | "illegal_floating_point_constant_pattern", | |
74b04a01 XL |
396 | "converted into hard error, see issue #36890 \ |
397 | <https://github.com/rust-lang/rust/issues/36890> for more information", | |
dfeec247 XL |
398 | ); |
399 | store.register_removed( | |
400 | "illegal_struct_or_enum_constant_pattern", | |
74b04a01 XL |
401 | "converted into hard error, see issue #36891 \ |
402 | <https://github.com/rust-lang/rust/issues/36891> for more information", | |
dfeec247 XL |
403 | ); |
404 | store.register_removed( | |
405 | "lifetime_underscore", | |
74b04a01 XL |
406 | "converted into hard error, see issue #36892 \ |
407 | <https://github.com/rust-lang/rust/issues/36892> for more information", | |
dfeec247 XL |
408 | ); |
409 | store.register_removed( | |
410 | "extra_requirement_in_impl", | |
74b04a01 XL |
411 | "converted into hard error, see issue #37166 \ |
412 | <https://github.com/rust-lang/rust/issues/37166> for more information", | |
dfeec247 XL |
413 | ); |
414 | store.register_removed( | |
415 | "legacy_imports", | |
74b04a01 XL |
416 | "converted into hard error, see issue #38260 \ |
417 | <https://github.com/rust-lang/rust/issues/38260> for more information", | |
dfeec247 XL |
418 | ); |
419 | store.register_removed( | |
420 | "coerce_never", | |
74b04a01 XL |
421 | "converted into hard error, see issue #48950 \ |
422 | <https://github.com/rust-lang/rust/issues/48950> for more information", | |
dfeec247 XL |
423 | ); |
424 | store.register_removed( | |
425 | "resolve_trait_on_defaulted_unit", | |
74b04a01 XL |
426 | "converted into hard error, see issue #48950 \ |
427 | <https://github.com/rust-lang/rust/issues/48950> for more information", | |
dfeec247 XL |
428 | ); |
429 | store.register_removed( | |
430 | "private_no_mangle_fns", | |
431 | "no longer a warning, `#[no_mangle]` functions always exported", | |
432 | ); | |
433 | store.register_removed( | |
434 | "private_no_mangle_statics", | |
435 | "no longer a warning, `#[no_mangle]` statics always exported", | |
436 | ); | |
437 | store.register_removed("bad_repr", "replaced with a generic attribute input check"); | |
438 | store.register_removed( | |
439 | "duplicate_matcher_binding_name", | |
74b04a01 XL |
440 | "converted into hard error, see issue #57742 \ |
441 | <https://github.com/rust-lang/rust/issues/57742> for more information", | |
dfeec247 XL |
442 | ); |
443 | store.register_removed( | |
444 | "incoherent_fundamental_impls", | |
74b04a01 XL |
445 | "converted into hard error, see issue #46205 \ |
446 | <https://github.com/rust-lang/rust/issues/46205> for more information", | |
dfeec247 XL |
447 | ); |
448 | store.register_removed( | |
449 | "legacy_constructor_visibility", | |
74b04a01 XL |
450 | "converted into hard error, see issue #39207 \ |
451 | <https://github.com/rust-lang/rust/issues/39207> for more information", | |
dfeec247 XL |
452 | ); |
453 | store.register_removed( | |
454 | "legacy_directory_ownership", | |
74b04a01 XL |
455 | "converted into hard error, see issue #37872 \ |
456 | <https://github.com/rust-lang/rust/issues/37872> for more information", | |
dfeec247 XL |
457 | ); |
458 | store.register_removed( | |
459 | "safe_extern_statics", | |
74b04a01 XL |
460 | "converted into hard error, see issue #36247 \ |
461 | <https://github.com/rust-lang/rust/issues/36247> for more information", | |
dfeec247 XL |
462 | ); |
463 | store.register_removed( | |
464 | "parenthesized_params_in_types_and_modules", | |
74b04a01 XL |
465 | "converted into hard error, see issue #42238 \ |
466 | <https://github.com/rust-lang/rust/issues/42238> for more information", | |
dfeec247 XL |
467 | ); |
468 | store.register_removed( | |
469 | "duplicate_macro_exports", | |
74b04a01 XL |
470 | "converted into hard error, see issue #35896 \ |
471 | <https://github.com/rust-lang/rust/issues/35896> for more information", | |
dfeec247 XL |
472 | ); |
473 | store.register_removed( | |
474 | "nested_impl_trait", | |
74b04a01 XL |
475 | "converted into hard error, see issue #59014 \ |
476 | <https://github.com/rust-lang/rust/issues/59014> for more information", | |
dfeec247 | 477 | ); |
60c5eb7d | 478 | store.register_removed("plugin_as_library", "plugins have been deprecated and retired"); |
5099ac24 FG |
479 | store.register_removed( |
480 | "unsupported_naked_functions", | |
481 | "converted into hard error, see RFC 2972 \ | |
482 | <https://github.com/rust-lang/rfcs/blob/master/text/2972-constrained-naked.md> for more information", | |
483 | ); | |
04454e1e FG |
484 | store.register_removed( |
485 | "mutable_borrow_reservation_conflict", | |
486 | "now allowed, see issue #59159 \ | |
487 | <https://github.com/rust-lang/rust/issues/59159> for more information", | |
488 | ); | |
2b03887a FG |
489 | store.register_removed( |
490 | "const_err", | |
491 | "converted into hard error, see issue #71800 \ | |
492 | <https://github.com/rust-lang/rust/issues/71800> for more information", | |
493 | ); | |
9ffffee4 FG |
494 | store.register_removed( |
495 | "safe_packed_borrows", | |
496 | "converted into hard error, see issue #82523 \ | |
497 | <https://github.com/rust-lang/rust/issues/82523> for more information", | |
498 | ); | |
499 | store.register_removed( | |
500 | "unaligned_references", | |
501 | "converted into hard error, see issue #82523 \ | |
502 | <https://github.com/rust-lang/rust/issues/82523> for more information", | |
503 | ); | |
781aab86 FG |
504 | store.register_removed( |
505 | "private_in_public", | |
506 | "replaced with another group of lints, see RFC \ | |
507 | <https://rust-lang.github.io/rfcs/2145-type-privacy.html> for more information", | |
508 | ); | |
ed00b5ec FG |
509 | store.register_removed( |
510 | "invalid_alignment", | |
511 | "converted into hard error, see PR #104616 \ | |
512 | <https://github.com/rust-lang/rust/pull/104616> for more information", | |
513 | ); | |
c34b1796 | 514 | } |
532ac7d7 | 515 | |
dfeec247 | 516 | fn register_internals(store: &mut LintStore) { |
e74abb32 | 517 | store.register_lints(&LintPassImpl::get_lints()); |
94222f64 | 518 | store.register_early_pass(|| Box::new(LintPassImpl)); |
136023e0 | 519 | store.register_lints(&DefaultHashTypes::get_lints()); |
add651ee | 520 | store.register_late_mod_pass(|_| Box::new(DefaultHashTypes)); |
5099ac24 | 521 | store.register_lints(&QueryStability::get_lints()); |
add651ee | 522 | store.register_late_mod_pass(|_| Box::new(QueryStability)); |
fc512014 | 523 | store.register_lints(&ExistingDocKeyword::get_lints()); |
add651ee | 524 | store.register_late_mod_pass(|_| Box::new(ExistingDocKeyword)); |
e74abb32 | 525 | store.register_lints(&TyTyKind::get_lints()); |
add651ee | 526 | store.register_late_mod_pass(|_| Box::new(TyTyKind)); |
923072b8 | 527 | store.register_lints(&Diagnostics::get_lints()); |
49aad941 | 528 | store.register_early_pass(|| Box::new(Diagnostics)); |
add651ee | 529 | store.register_late_mod_pass(|_| Box::new(Diagnostics)); |
064997fb | 530 | store.register_lints(&BadOptAccess::get_lints()); |
add651ee | 531 | store.register_late_mod_pass(|_| Box::new(BadOptAccess)); |
5099ac24 | 532 | store.register_lints(&PassByValue::get_lints()); |
add651ee | 533 | store.register_late_mod_pass(|_| Box::new(PassByValue)); |
ed00b5ec FG |
534 | store.register_lints(&SpanUseEqCtxt::get_lints()); |
535 | store.register_late_mod_pass(|_| Box::new(SpanUseEqCtxt)); | |
064997fb FG |
536 | // FIXME(davidtwco): deliberately do not include `UNTRANSLATABLE_DIAGNOSTIC` and |
537 | // `DIAGNOSTIC_OUTSIDE_OF_IMPL` here because `-Wrustc::internal` is provided to every crate and | |
538 | // these lints will trigger all of the time - change this once migration to diagnostic structs | |
539 | // and translation is completed | |
532ac7d7 | 540 | store.register_group( |
532ac7d7 | 541 | false, |
416331ca | 542 | "rustc::internal", |
532ac7d7 XL |
543 | None, |
544 | vec![ | |
545 | LintId::of(DEFAULT_HASH_TYPES), | |
5099ac24 | 546 | LintId::of(POTENTIAL_QUERY_INSTABILITY), |
532ac7d7 | 547 | LintId::of(USAGE_OF_TY_TYKIND), |
5099ac24 | 548 | LintId::of(PASS_BY_VALUE), |
416331ca | 549 | LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO), |
48663c56 | 550 | LintId::of(USAGE_OF_QUALIFIED_TY), |
fc512014 | 551 | LintId::of(EXISTING_DOC_KEYWORD), |
064997fb | 552 | LintId::of(BAD_OPT_ACCESS), |
ed00b5ec | 553 | LintId::of(SPAN_USE_EQ_CTXT), |
532ac7d7 XL |
554 | ], |
555 | ); | |
556 | } | |
136023e0 XL |
557 | |
558 | #[cfg(test)] | |
559 | mod tests; |