Skip to content

Commit 7ab960b

Browse files
authored
Unrolled build for rust-lang#124522
Rollup merge of rust-lang#124522 - blyxyas:refactor-is-loaded, r=jieyouxu [Refactor] Rename `Lint` and `LintGroup`'s `is_loaded` to `is_externally_loaded` The field being named `is_loaded` was very confusing. Turns out it's true for lints that are registered by external tools like Clippy (I had to look at rust-lang#116412 to know what the variable meant). So I renamed `is_loaded` to `is_externally_loaded` and added some docs.
2 parents e27af29 + d31b7db commit 7ab960b

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

Diff for: compiler/rustc_driver_impl/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ Available lint options:
971971

972972
let lint_store = unerased_lint_store(sess);
973973
let (loaded, builtin): (Vec<_>, _) =
974-
lint_store.get_lints().iter().cloned().partition(|&lint| lint.is_loaded);
974+
lint_store.get_lints().iter().cloned().partition(|&lint| lint.is_externally_loaded);
975975
let loaded = sort_lints(sess, loaded);
976976
let builtin = sort_lints(sess, builtin);
977977

Diff for: compiler/rustc_lint/src/context.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct LintAlias {
110110

111111
struct LintGroup {
112112
lint_ids: Vec<LintId>,
113-
is_loaded: bool,
113+
is_externally_loaded: bool,
114114
depr: Option<LintAlias>,
115115
}
116116

@@ -159,7 +159,9 @@ impl LintStore {
159159
// Don't display deprecated lint groups.
160160
depr.is_none()
161161
})
162-
.map(|(k, LintGroup { lint_ids, is_loaded, .. })| (*k, lint_ids.clone(), *is_loaded))
162+
.map(|(k, LintGroup { lint_ids, is_externally_loaded, .. })| {
163+
(*k, lint_ids.clone(), *is_externally_loaded)
164+
})
163165
}
164166

165167
pub fn register_early_pass(
@@ -218,7 +220,7 @@ impl LintStore {
218220
.entry(edition.lint_name())
219221
.or_insert(LintGroup {
220222
lint_ids: vec![],
221-
is_loaded: lint.is_loaded,
223+
is_externally_loaded: lint.is_externally_loaded,
222224
depr: None,
223225
})
224226
.lint_ids
@@ -231,7 +233,7 @@ impl LintStore {
231233
.entry("future_incompatible")
232234
.or_insert(LintGroup {
233235
lint_ids: vec![],
234-
is_loaded: lint.is_loaded,
236+
is_externally_loaded: lint.is_externally_loaded,
235237
depr: None,
236238
})
237239
.lint_ids
@@ -246,29 +248,29 @@ impl LintStore {
246248
alias,
247249
LintGroup {
248250
lint_ids: vec![],
249-
is_loaded: false,
251+
is_externally_loaded: false,
250252
depr: Some(LintAlias { name: lint_name, silent: true }),
251253
},
252254
);
253255
}
254256

255257
pub fn register_group(
256258
&mut self,
257-
is_loaded: bool,
259+
is_externally_loaded: bool,
258260
name: &'static str,
259261
deprecated_name: Option<&'static str>,
260262
to: Vec<LintId>,
261263
) {
262264
let new = self
263265
.lint_groups
264-
.insert(name, LintGroup { lint_ids: to, is_loaded, depr: None })
266+
.insert(name, LintGroup { lint_ids: to, is_externally_loaded, depr: None })
265267
.is_none();
266268
if let Some(deprecated) = deprecated_name {
267269
self.lint_groups.insert(
268270
deprecated,
269271
LintGroup {
270272
lint_ids: vec![],
271-
is_loaded,
273+
is_externally_loaded,
272274
depr: Some(LintAlias { name, silent: false }),
273275
},
274276
);

Diff for: compiler/rustc_lint_defs/src/lib.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ pub struct Lint {
323323

324324
pub future_incompatible: Option<FutureIncompatibleInfo>,
325325

326-
pub is_loaded: bool,
326+
/// `true` if this lint is being loaded by another tool (e.g. Clippy).
327+
pub is_externally_loaded: bool,
327328

328329
/// `Some` if this lint is feature gated, otherwise `None`.
329330
pub feature_gate: Option<Symbol>,
@@ -468,7 +469,7 @@ impl Lint {
468469
default_level: Level::Forbid,
469470
desc: "",
470471
edition_lint_opts: None,
471-
is_loaded: false,
472+
is_externally_loaded: false,
472473
report_in_external_macro: false,
473474
future_incompatible: None,
474475
feature_gate: None,
@@ -817,7 +818,7 @@ macro_rules! declare_lint {
817818
name: stringify!($NAME),
818819
default_level: $crate::$Level,
819820
desc: $desc,
820-
is_loaded: false,
821+
is_externally_loaded: false,
821822
$($v: true,)*
822823
$(feature_gate: Some($gate),)?
823824
$(future_incompatible: Some($crate::FutureIncompatibleInfo {
@@ -859,7 +860,7 @@ macro_rules! declare_tool_lint {
859860
edition_lint_opts: None,
860861
report_in_external_macro: $external,
861862
future_incompatible: None,
862-
is_loaded: true,
863+
is_externally_loaded: true,
863864
$(feature_gate: Some($gate),)?
864865
crate_level_only: false,
865866
..$crate::Lint::default_fields_for_macro()

Diff for: tests/ui/statics/nested_struct.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ pub struct Lint {
99
pub name: &'static str,
1010
pub desc: &'static str,
1111
pub report_in_external_macro: bool,
12-
pub is_loaded: bool,
12+
pub is_externally_loaded: bool,
1313
pub crate_level_only: bool,
1414
}
1515

1616
static FOO: &Lint = &Lint {
1717
name: &"foo",
1818
desc: "desc",
1919
report_in_external_macro: false,
20-
is_loaded: true,
20+
is_externally_loaded: true,
2121
crate_level_only: false,
2222
};
2323

0 commit comments

Comments
 (0)