Skip to content

Commit f3f25b6

Browse files
committed
may_not_refer_to_existing_definition -> allow_invalid
1 parent e98d203 commit f3f25b6

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

clippy.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ lint-commented-code = true
77
[[disallowed-methods]]
88
path = "rustc_lint::context::LintContext::lint"
99
reason = "this function does not add a link to our documentation, please use the `clippy_utils::diagnostics::span_lint*` functions instead"
10-
may-not-refer-to-existing-definition = true
10+
allow-invalid = true
1111

1212
[[disallowed-methods]]
1313
path = "rustc_lint::context::LintContext::span_lint"
1414
reason = "this function does not add a link to our documentation, please use the `clippy_utils::diagnostics::span_lint*` functions instead"
15-
may-not-refer-to-existing-definition = true
15+
allow-invalid = true
1616

1717
[[disallowed-methods]]
1818
path = "rustc_middle::ty::context::TyCtxt::node_span_lint"
1919
reason = "this function does not add a link to our documentation, please use the `clippy_utils::diagnostics::span_lint_hir*` functions instead"
20-
may-not-refer-to-existing-definition = true
20+
allow-invalid = true

clippy_config/src/types.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ pub struct DisallowedPath<const REPLACEMENT_ALLOWED: bool = true> {
2323
path: String,
2424
reason: Option<String>,
2525
replacement: Option<String>,
26-
/// Setting `may_not_refer_to_existing_definition` to true suppresses a warning if `path` does
27-
/// not refer to an existing definition.
26+
/// Setting `allow_invalid` to true suppresses a warning if `path` does not refer to an existing
27+
/// definition.
2828
///
2929
/// This could be useful when conditional compilation is used, or when a clippy.toml file is
3030
/// shared among multiple projects.
31-
may_not_refer_to_existing_definition: bool,
31+
allow_invalid: bool,
3232
/// The span of the `DisallowedPath`.
3333
///
3434
/// Used for diagnostics.
@@ -49,7 +49,7 @@ impl<'de, const REPLACEMENT_ALLOWED: bool> Deserialize<'de> for DisallowedPath<R
4949
path: enum_.path().to_owned(),
5050
reason: enum_.reason().map(ToOwned::to_owned),
5151
replacement: enum_.replacement().map(ToOwned::to_owned),
52-
may_not_refer_to_existing_definition: enum_.may_not_refer_to_existing_definition(),
52+
allow_invalid: enum_.allow_invalid(),
5353
span: Span::default(),
5454
})
5555
}
@@ -65,8 +65,8 @@ enum DisallowedPathEnum {
6565
path: String,
6666
reason: Option<String>,
6767
replacement: Option<String>,
68-
#[serde(rename = "may-not-refer-to-existing-definition")]
69-
may_not_refer_to_existing_definition: Option<bool>,
68+
#[serde(rename = "allow-invalid")]
69+
allow_invalid: Option<bool>,
7070
},
7171
}
7272

@@ -120,12 +120,9 @@ impl DisallowedPathEnum {
120120
}
121121
}
122122

123-
fn may_not_refer_to_existing_definition(&self) -> bool {
123+
fn allow_invalid(&self) -> bool {
124124
match &self {
125-
Self::WithReason {
126-
may_not_refer_to_existing_definition,
127-
..
128-
} => may_not_refer_to_existing_definition.unwrap_or_default(),
125+
Self::WithReason { allow_invalid, .. } => allow_invalid.unwrap_or_default(),
129126
Self::Simple(_) => false,
130127
}
131128
}
@@ -181,7 +178,7 @@ pub fn create_disallowed_map<const REPLACEMENT_ALLOWED: bool>(
181178
span,
182179
format!("expected a {predicate_description}, found a primitive type",),
183180
);
184-
} else if !disallowed_path.may_not_refer_to_existing_definition {
181+
} else if !disallowed_path.allow_invalid {
185182
tcx.sess.dcx().span_warn(
186183
span,
187184
format!("`{path}` does not refer to an existing {predicate_description}"),

tests/ui-toml/toml_invalid_path/clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ path = "std::process::current_exe"
1111

1212
[[disallowed-methods]]
1313
path = "std::current_exe"
14-
may-not-refer-to-existing-definition = true
14+
allow-invalid = true

0 commit comments

Comments
 (0)