Rollup merge of #98507 - xFrednet:rfc-2383-manual-expectation-magic, r=wesleywiser
Finishing touches for `#[expect]` (RFC 2383) This PR adds documentation and some functionality to rustc's lint passes, to manually fulfill expectations. This is needed for some lints in Clippy. Hopefully, it should be one of the last things before we can move forward with stabilizing this feature. As part of this PR, I've also updated `clippy::duplicate_mod` to showcase how this new functionality can be used and to ensure that it works correctly. --- changelog: [`duplicate_mod`]: Fixed lint attribute interaction r? `@wesleywiser` cc: https://github.com/rust-lang/rust/issues/97660, https://github.com/rust-lang/rust/issues/85549 And I guess that's it. Here have a magical unicorn 🦄
This commit is contained in:
commit
c815fef795
7 changed files with 92 additions and 7 deletions
|
@ -520,6 +520,11 @@ declare_lint! {
|
|||
/// The `expect` attribute can be removed if this is intended behavior otherwise
|
||||
/// it should be investigated why the expected lint is no longer issued.
|
||||
///
|
||||
/// In rare cases, the expectation might be emitted at a different location than
|
||||
/// shown in the shown code snippet. In most cases, the `#[expect]` attribute
|
||||
/// works when added to the outer scope. A few lints can only be expected
|
||||
/// on a crate level.
|
||||
///
|
||||
/// Part of RFC 2383. The progress is being tracked in [#54503]
|
||||
///
|
||||
/// [#54503]: https://github.com/rust-lang/rust/issues/54503
|
||||
|
|
|
@ -232,6 +232,13 @@ impl Level {
|
|||
Level::Deny | Level::Forbid => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_expectation_id(&self) -> Option<LintExpectationId> {
|
||||
match self {
|
||||
Level::Expect(id) | Level::ForceWarn(Some(id)) => Some(*id),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Specification of a single lint.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue