Skip to content

Commit

Permalink
[Refactor] Rename Lint and LintGroup\'s is_loaded to is_externally_lo…
Browse files Browse the repository at this point in the history
…aded
  • Loading branch information
blyxyas committed Apr 29, 2024
1 parent 9084601 commit f67a0da
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ Available lint options:

let lint_store = unerased_lint_store(sess);
let (loaded, builtin): (Vec<_>, _) =
lint_store.get_lints().iter().cloned().partition(|&lint| lint.is_loaded);
lint_store.get_lints().iter().cloned().partition(|&lint| lint.is_externally_loaded);
let loaded = sort_lints(sess, loaded);
let builtin = sort_lints(sess, builtin);

Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct LintAlias {

struct LintGroup {
lint_ids: Vec<LintId>,
is_loaded: bool,
is_externally_loaded: bool,
depr: Option<LintAlias>,
}

Expand Down Expand Up @@ -159,7 +159,7 @@ impl LintStore {
// Don't display deprecated lint groups.
depr.is_none()
})
.map(|(k, LintGroup { lint_ids, is_loaded, .. })| (*k, lint_ids.clone(), *is_loaded))
.map(|(k, LintGroup { lint_ids, is_externally_loaded, .. })| (*k, lint_ids.clone(), *is_externally_loaded))
}

pub fn register_early_pass(
Expand Down Expand Up @@ -218,7 +218,7 @@ impl LintStore {
.entry(edition.lint_name())
.or_insert(LintGroup {
lint_ids: vec![],
is_loaded: lint.is_loaded,
is_externally_loaded: lint.is_externally_loaded,
depr: None,
})
.lint_ids
Expand All @@ -231,7 +231,7 @@ impl LintStore {
.entry("future_incompatible")
.or_insert(LintGroup {
lint_ids: vec![],
is_loaded: lint.is_loaded,
is_externally_loaded: lint.is_externally_loaded,
depr: None,
})
.lint_ids
Expand All @@ -246,29 +246,29 @@ impl LintStore {
alias,
LintGroup {
lint_ids: vec![],
is_loaded: false,
is_externally_loaded: false,
depr: Some(LintAlias { name: lint_name, silent: true }),
},
);
}

pub fn register_group(
&mut self,
is_loaded: bool,
is_externally_loaded: bool,
name: &'static str,
deprecated_name: Option<&'static str>,
to: Vec<LintId>,
) {
let new = self
.lint_groups
.insert(name, LintGroup { lint_ids: to, is_loaded, depr: None })
.insert(name, LintGroup { lint_ids: to, is_externally_loaded, depr: None })
.is_none();
if let Some(deprecated) = deprecated_name {
self.lint_groups.insert(
deprecated,
LintGroup {
lint_ids: vec![],
is_loaded,
is_externally_loaded,
depr: Some(LintAlias { name, silent: false }),
},
);
Expand Down
9 changes: 5 additions & 4 deletions compiler/rustc_lint_defs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ pub struct Lint {

pub future_incompatible: Option<FutureIncompatibleInfo>,

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

/// `Some` if this lint is feature gated, otherwise `None`.
pub feature_gate: Option<Symbol>,
Expand Down Expand Up @@ -468,7 +469,7 @@ impl Lint {
default_level: Level::Forbid,
desc: "",
edition_lint_opts: None,
is_loaded: false,
is_externally_loaded: false,
report_in_external_macro: false,
future_incompatible: None,
feature_gate: None,
Expand Down Expand Up @@ -817,7 +818,7 @@ macro_rules! declare_lint {
name: stringify!($NAME),
default_level: $crate::$Level,
desc: $desc,
is_loaded: false,
is_externally_loaded: false,
$($v: true,)*
$(feature_gate: Some($gate),)?
$(future_incompatible: Some($crate::FutureIncompatibleInfo {
Expand Down Expand Up @@ -859,7 +860,7 @@ macro_rules! declare_tool_lint {
edition_lint_opts: None,
report_in_external_macro: $external,
future_incompatible: None,
is_loaded: true,
is_externally_loaded: true,
$(feature_gate: Some($gate),)?
crate_level_only: false,
..$crate::Lint::default_fields_for_macro()
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/statics/nested_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ pub struct Lint {
pub name: &'static str,
pub desc: &'static str,
pub report_in_external_macro: bool,
pub is_loaded: bool,
pub is_externally_loaded: bool,
pub crate_level_only: bool,
}

static FOO: &Lint = &Lint {
name: &"foo",
desc: "desc",
report_in_external_macro: false,
is_loaded: true,
is_externally_loaded: true,
crate_level_only: false,
};

Expand Down

0 comments on commit f67a0da

Please sign in to comment.