diff options
| author | bors <bors@rust-lang.org> | 2022-06-28 18:28:38 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-06-28 18:28:38 +0000 |
| commit | 4995b4e584a2d29c6805460b3002b4cf87bd1e2c (patch) | |
| tree | 6af436ceef2159b4a8779da363614845cd335b6a /clippy_utils | |
| parent | a4130e16124e58ae6c6e6eb201ffced2c1964145 (diff) | |
| parent | d11618e6fa73f7f99d5569349bca800cf2b126bb (diff) | |
| download | rust-4995b4e584a2d29c6805460b3002b4cf87bd1e2c.tar.gz rust-4995b4e584a2d29c6805460b3002b4cf87bd1e2c.zip | |
Auto merge of #9046 - xFrednet:rust-97660-expection-something-something, r=Jarcho
Fix `#[expect]` for most clippy lints This PR fixes most `#[expect]` - lint interactions listed in rust-lang/rust#97660. [My comment in the issue](https://github.com/rust-lang/rust/issues/97660#issuecomment-1147269504) shows the current progress (Once this is merged). I plan to work on `duplicate_mod` and `multiple_inherent_impl` and leave the rest for later. I feel like stabilizing the feature is more important than fixing the last few nits, which currently also don't work with `#[allow]`. --- changelog: none r? `@Jarcho` cc: rust-lang/rust#97660
Diffstat (limited to 'clippy_utils')
| -rw-r--r-- | clippy_utils/src/lib.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index a2772edf738..beb8bbe75d1 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -1539,9 +1539,13 @@ pub fn is_try<'tcx>(cx: &LateContext<'_>, expr: &'tcx Expr<'tcx>) -> Option<&'tc None } -/// Returns `true` if the lint is allowed in the current context +/// Returns `true` if the lint is allowed in the current context. This is useful for +/// skipping long running code when it's unnecessary /// -/// Useful for skipping long running code when it's unnecessary +/// This function should check the lint level for the same node, that the lint will +/// be emitted at. If the information is buffered to be emitted at a later point, please +/// make sure to use `span_lint_hir` functions to emit the lint. This ensures that +/// expectations at the checked nodes will be fulfilled. pub fn is_lint_allowed(cx: &LateContext<'_>, lint: &'static Lint, id: HirId) -> bool { cx.tcx.lint_level_at_node(lint, id).0 == Level::Allow } |
