Skip to content

Commit 7c043e2

Browse files
authored
Rollup merge of rust-lang#65193 - Mark-Simulacrum:lockless-lintstore, r=nikomatsakis
Lockless LintStore This removes mutability from the lint store after registration. Each commit stands alone, for the most part, though they don't make sense out of sequence. The intent here is to move LintStore to a more parallel-friendly architecture, although also just a cleaner one from an implementation perspective. Specifically, this has the following changes: * We no longer implicitly register lints when registering lint passes * For the most part this means that registration calls now likely want to call something like: `lint_store.register_lints(&Pass::get_lints())` as well as `register_*_pass`. * In theory this is a simplification as it's much easier for folks to just register lints and then have passes that implement whichever lint however they want, rather than necessarily tying passes to lints. * Lint passes still have a list of associated lints, but a followup PR could plausibly change that * This list must be known for a given pass type, not instance, i.e., `fn get_lints()` is the signature instead of `fn get_lints(&self)` as before. * We do not store pass objects, instead storing constructor functions. This means we always get new passes when running lints (this happens approximately once though for a given compiler session, so no behavior change is expected). * Registration API is _much_ simpler: generally all functions are just taking `Fn() -> PassObject` rather than several different `bool`s.
2 parents 4b9fbfb + 4e8d1b2 commit 7c043e2

28 files changed

+477
-557
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -3483,6 +3483,7 @@ dependencies = [
34833483
"rustc_data_structures",
34843484
"rustc_errors",
34853485
"rustc_interface",
3486+
"rustc_lint",
34863487
"rustc_metadata",
34873488
"rustc_mir",
34883489
"rustc_plugin",

src/librustc/lint/builtin.rs

+138-31
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
//! compiler code, rather than using their own custom pass. Those
55
//! lints are all available in `rustc_lint::builtin`.
66
7-
use crate::lint::{LintPass, LateLintPass, LintArray};
7+
use crate::lint::{LintPass, LateLintPass, LintArray, FutureIncompatibleInfo};
88
use crate::middle::stability;
99
use crate::session::Session;
1010
use errors::{Applicability, DiagnosticBuilder, pluralise};
1111
use syntax::ast;
12+
use syntax::edition::Edition;
1213
use syntax::source_map::Span;
1314
use syntax::symbol::Symbol;
1415

@@ -22,7 +23,7 @@ declare_lint! {
2223
pub CONST_ERR,
2324
Deny,
2425
"constant evaluation detected erroneous expression",
25-
report_in_external_macro: true
26+
report_in_external_macro
2627
}
2728

2829
declare_lint! {
@@ -71,7 +72,7 @@ declare_lint! {
7172
pub UNREACHABLE_CODE,
7273
Warn,
7374
"detects unreachable code paths",
74-
report_in_external_macro: true
75+
report_in_external_macro
7576
}
7677

7778
declare_lint! {
@@ -131,7 +132,11 @@ declare_lint! {
131132
declare_lint! {
132133
pub PRIVATE_IN_PUBLIC,
133134
Warn,
134-
"detect private items in public interfaces not caught by the old implementation"
135+
"detect private items in public interfaces not caught by the old implementation",
136+
@future_incompatible = FutureIncompatibleInfo {
137+
reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
138+
edition: None,
139+
};
135140
}
136141

137142
declare_lint! {
@@ -143,13 +148,21 @@ declare_lint! {
143148
declare_lint! {
144149
pub PUB_USE_OF_PRIVATE_EXTERN_CRATE,
145150
Deny,
146-
"detect public re-exports of private extern crates"
151+
"detect public re-exports of private extern crates",
152+
@future_incompatible = FutureIncompatibleInfo {
153+
reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
154+
edition: None,
155+
};
147156
}
148157

149158
declare_lint! {
150159
pub INVALID_TYPE_PARAM_DEFAULT,
151160
Deny,
152-
"type parameter default erroneously allowed in invalid location"
161+
"type parameter default erroneously allowed in invalid location",
162+
@future_incompatible = FutureIncompatibleInfo {
163+
reference: "issue #36887 <https://github.com/rust-lang/rust/issues/36887>",
164+
edition: None,
165+
};
153166
}
154167

155168
declare_lint! {
@@ -161,63 +174,99 @@ declare_lint! {
161174
declare_lint! {
162175
pub SAFE_EXTERN_STATICS,
163176
Deny,
164-
"safe access to extern statics was erroneously allowed"
177+
"safe access to extern statics was erroneously allowed",
178+
@future_incompatible = FutureIncompatibleInfo {
179+
reference: "issue #36247 <https://github.com/rust-lang/rust/issues/36247>",
180+
edition: None,
181+
};
165182
}
166183

167184
declare_lint! {
168185
pub SAFE_PACKED_BORROWS,
169186
Warn,
170-
"safe borrows of fields of packed structs were was erroneously allowed"
187+
"safe borrows of fields of packed structs were was erroneously allowed",
188+
@future_incompatible = FutureIncompatibleInfo {
189+
reference: "issue #46043 <https://github.com/rust-lang/rust/issues/46043>",
190+
edition: None,
191+
};
171192
}
172193

173194
declare_lint! {
174195
pub PATTERNS_IN_FNS_WITHOUT_BODY,
175196
Warn,
176-
"patterns in functions without body were erroneously allowed"
197+
"patterns in functions without body were erroneously allowed",
198+
@future_incompatible = FutureIncompatibleInfo {
199+
reference: "issue #35203 <https://github.com/rust-lang/rust/issues/35203>",
200+
edition: None,
201+
};
177202
}
178203

179204
declare_lint! {
180205
pub LEGACY_DIRECTORY_OWNERSHIP,
181206
Deny,
182207
"non-inline, non-`#[path]` modules (e.g., `mod foo;`) were erroneously allowed in some files \
183-
not named `mod.rs`"
208+
not named `mod.rs`",
209+
@future_incompatible = FutureIncompatibleInfo {
210+
reference: "issue #37872 <https://github.com/rust-lang/rust/issues/37872>",
211+
edition: None,
212+
};
184213
}
185214

186215
declare_lint! {
187216
pub LEGACY_CONSTRUCTOR_VISIBILITY,
188217
Deny,
189-
"detects use of struct constructors that would be invisible with new visibility rules"
218+
"detects use of struct constructors that would be invisible with new visibility rules",
219+
@future_incompatible = FutureIncompatibleInfo {
220+
reference: "issue #39207 <https://github.com/rust-lang/rust/issues/39207>",
221+
edition: None,
222+
};
190223
}
191224

192225
declare_lint! {
193226
pub MISSING_FRAGMENT_SPECIFIER,
194227
Deny,
195-
"detects missing fragment specifiers in unused `macro_rules!` patterns"
228+
"detects missing fragment specifiers in unused `macro_rules!` patterns",
229+
@future_incompatible = FutureIncompatibleInfo {
230+
reference: "issue #40107 <https://github.com/rust-lang/rust/issues/40107>",
231+
edition: None,
232+
};
196233
}
197234

198235
declare_lint! {
199236
pub PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
200237
Deny,
201-
"detects parenthesized generic parameters in type and module names"
238+
"detects parenthesized generic parameters in type and module names",
239+
@future_incompatible = FutureIncompatibleInfo {
240+
reference: "issue #42238 <https://github.com/rust-lang/rust/issues/42238>",
241+
edition: None,
242+
};
202243
}
203244

204245
declare_lint! {
205246
pub LATE_BOUND_LIFETIME_ARGUMENTS,
206247
Warn,
207-
"detects generic lifetime arguments in path segments with late bound lifetime parameters"
248+
"detects generic lifetime arguments in path segments with late bound lifetime parameters",
249+
@future_incompatible = FutureIncompatibleInfo {
250+
reference: "issue #42868 <https://github.com/rust-lang/rust/issues/42868>",
251+
edition: None,
252+
};
208253
}
209254

210255
declare_lint! {
211256
pub ORDER_DEPENDENT_TRAIT_OBJECTS,
212257
Deny,
213-
"trait-object types were treated as different depending on marker-trait order"
258+
"trait-object types were treated as different depending on marker-trait order",
259+
@future_incompatible = FutureIncompatibleInfo {
260+
reference: "issue #56484 <https://github.com/rust-lang/rust/issues/56484>",
261+
edition: None,
262+
};
214263
}
215264

216265
declare_lint! {
217266
pub DEPRECATED,
218267
Warn,
219268
"detects use of deprecated items",
220-
report_in_external_macro: true
269+
report_in_external_macro
221270
}
222271

223272
declare_lint! {
@@ -253,7 +302,11 @@ declare_lint! {
253302
declare_lint! {
254303
pub TYVAR_BEHIND_RAW_POINTER,
255304
Warn,
256-
"raw pointer to an inference variable"
305+
"raw pointer to an inference variable",
306+
@future_incompatible = FutureIncompatibleInfo {
307+
reference: "issue #46906 <https://github.com/rust-lang/rust/issues/46906>",
308+
edition: Some(Edition::Edition2018),
309+
};
257310
}
258311

259312
declare_lint! {
@@ -272,19 +325,33 @@ declare_lint! {
272325
pub ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
273326
Allow,
274327
"fully qualified paths that start with a module name \
275-
instead of `crate`, `self`, or an extern crate name"
328+
instead of `crate`, `self`, or an extern crate name",
329+
@future_incompatible = FutureIncompatibleInfo {
330+
reference: "issue #53130 <https://github.com/rust-lang/rust/issues/53130>",
331+
edition: Some(Edition::Edition2018),
332+
};
276333
}
277334

278335
declare_lint! {
279336
pub ILLEGAL_FLOATING_POINT_LITERAL_PATTERN,
280337
Warn,
281-
"floating-point literals cannot be used in patterns"
338+
"floating-point literals cannot be used in patterns",
339+
@future_incompatible = FutureIncompatibleInfo {
340+
reference: "issue #41620 <https://github.com/rust-lang/rust/issues/41620>",
341+
edition: None,
342+
};
282343
}
283344

284345
declare_lint! {
285346
pub UNSTABLE_NAME_COLLISIONS,
286347
Warn,
287-
"detects name collision with an existing but unstable method"
348+
"detects name collision with an existing but unstable method",
349+
@future_incompatible = FutureIncompatibleInfo {
350+
reference: "issue #48919 <https://github.com/rust-lang/rust/issues/48919>",
351+
edition: None,
352+
// Note: this item represents future incompatibility of all unstable functions in the
353+
// standard library, and thus should never be removed or changed to an error.
354+
};
288355
}
289356

290357
declare_lint! {
@@ -302,7 +369,11 @@ declare_lint! {
302369
declare_lint! {
303370
pub DUPLICATE_MACRO_EXPORTS,
304371
Deny,
305-
"detects duplicate macro exports"
372+
"detects duplicate macro exports",
373+
@future_incompatible = FutureIncompatibleInfo {
374+
reference: "issue #35896 <https://github.com/rust-lang/rust/issues/35896>",
375+
edition: Some(Edition::Edition2018),
376+
};
306377
}
307378

308379
declare_lint! {
@@ -326,13 +397,21 @@ declare_lint! {
326397
declare_lint! {
327398
pub WHERE_CLAUSES_OBJECT_SAFETY,
328399
Warn,
329-
"checks the object safety of where clauses"
400+
"checks the object safety of where clauses",
401+
@future_incompatible = FutureIncompatibleInfo {
402+
reference: "issue #51443 <https://github.com/rust-lang/rust/issues/51443>",
403+
edition: None,
404+
};
330405
}
331406

332407
declare_lint! {
333408
pub PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
334409
Warn,
335-
"detects proc macro derives using inaccessible names from parent modules"
410+
"detects proc macro derives using inaccessible names from parent modules",
411+
@future_incompatible = FutureIncompatibleInfo {
412+
reference: "issue #50504 <https://github.com/rust-lang/rust/issues/50504>",
413+
edition: None,
414+
};
336415
}
337416

338417
declare_lint! {
@@ -346,7 +425,11 @@ declare_lint! {
346425
pub MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
347426
Deny,
348427
"macro-expanded `macro_export` macros from the current crate \
349-
cannot be referred to by absolute paths"
428+
cannot be referred to by absolute paths",
429+
@future_incompatible = FutureIncompatibleInfo {
430+
reference: "issue #52234 <https://github.com/rust-lang/rust/issues/52234>",
431+
edition: None,
432+
};
350433
}
351434

352435
declare_lint! {
@@ -359,15 +442,23 @@ declare_lint! {
359442
pub INDIRECT_STRUCTURAL_MATCH,
360443
// defaulting to allow until rust-lang/rust#62614 is fixed.
361444
Allow,
362-
"pattern with const indirectly referencing non-`#[structural_match]` type"
445+
"pattern with const indirectly referencing non-`#[structural_match]` type",
446+
@future_incompatible = FutureIncompatibleInfo {
447+
reference: "issue #62411 <https://github.com/rust-lang/rust/issues/62411>",
448+
edition: None,
449+
};
363450
}
364451

365452
/// Some lints that are buffered from `libsyntax`. See `syntax::early_buffered_lints`.
366453
pub mod parser {
367454
declare_lint! {
368455
pub ILL_FORMED_ATTRIBUTE_INPUT,
369456
Warn,
370-
"ill-formed attribute inputs that were previously accepted and used in practice"
457+
"ill-formed attribute inputs that were previously accepted and used in practice",
458+
@future_incompatible = super::FutureIncompatibleInfo {
459+
reference: "issue #57571 <https://github.com/rust-lang/rust/issues/57571>",
460+
edition: None,
461+
};
371462
}
372463

373464
declare_lint! {
@@ -387,31 +478,47 @@ declare_lint! {
387478
pub DEPRECATED_IN_FUTURE,
388479
Allow,
389480
"detects use of items that will be deprecated in a future version",
390-
report_in_external_macro: true
481+
report_in_external_macro
391482
}
392483

393484
declare_lint! {
394485
pub AMBIGUOUS_ASSOCIATED_ITEMS,
395486
Deny,
396-
"ambiguous associated items"
487+
"ambiguous associated items",
488+
@future_incompatible = FutureIncompatibleInfo {
489+
reference: "issue #57644 <https://github.com/rust-lang/rust/issues/57644>",
490+
edition: None,
491+
};
397492
}
398493

399494
declare_lint! {
400495
pub NESTED_IMPL_TRAIT,
401496
Warn,
402-
"nested occurrence of `impl Trait` type"
497+
"nested occurrence of `impl Trait` type",
498+
@future_incompatible = FutureIncompatibleInfo {
499+
reference: "issue #59014 <https://github.com/rust-lang/rust/issues/59014>",
500+
edition: None,
501+
};
403502
}
404503

405504
declare_lint! {
406505
pub MUTABLE_BORROW_RESERVATION_CONFLICT,
407506
Warn,
408-
"reservation of a two-phased borrow conflicts with other shared borrows"
507+
"reservation of a two-phased borrow conflicts with other shared borrows",
508+
@future_incompatible = FutureIncompatibleInfo {
509+
reference: "issue #59159 <https://github.com/rust-lang/rust/issues/59159>",
510+
edition: None,
511+
};
409512
}
410513

411514
declare_lint! {
412515
pub SOFT_UNSTABLE,
413516
Deny,
414-
"a feature gate that doesn't break dependent crates"
517+
"a feature gate that doesn't break dependent crates",
518+
@future_incompatible = FutureIncompatibleInfo {
519+
reference: "issue #64266 <https://github.com/rust-lang/rust/issues/64266>",
520+
edition: None,
521+
};
415522
}
416523

417524
declare_lint_pass! {

0 commit comments

Comments
 (0)