diff options
| author | Jason Newcomb <jsnewcomb@pm.me> | 2025-05-14 05:49:50 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-14 05:49:50 +0000 |
| commit | 373df5265e4b75a1594ae8b47d71451f10ea5a64 (patch) | |
| tree | 22f9e8634689aeeea9e2dcabae659e6719b61bac /tests | |
| parent | 17f2a87c0cdade23b20ea5b3004235d8c1db8eb5 (diff) | |
| parent | cc5d1a5ab5c551ec763e2e32d1737ef7cddf9669 (diff) | |
| download | rust-373df5265e4b75a1594ae8b47d71451f10ea5a64.tar.gz rust-373df5265e4b75a1594ae8b47d71451f10ea5a64.zip | |
Post `non_std_lazy_statics` type warnings onto the right node (#14740)
When a `non_std_lazy_statics` warning is generated about an item type which can be replaced by a standard library one, ensure that the lint happens on the item HIR node so that it can be expected. changelog: [`non_std_lazy_statics`]: generate the warning onto the right node Fixes rust-lang/rust-clippy#14729 Note that this doesn't change anything on lints generated for the `lazy_static::lazy_static` macro because the `expect` attribute cannot be applied to a macro.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/non_std_lazy_static/non_std_lazy_static_fixable.fixed | 7 | ||||
| -rw-r--r-- | tests/ui/non_std_lazy_static/non_std_lazy_static_fixable.rs | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/tests/ui/non_std_lazy_static/non_std_lazy_static_fixable.fixed b/tests/ui/non_std_lazy_static/non_std_lazy_static_fixable.fixed index 2b30c8f984e..d6c35d8097c 100644 --- a/tests/ui/non_std_lazy_static/non_std_lazy_static_fixable.fixed +++ b/tests/ui/non_std_lazy_static/non_std_lazy_static_fixable.fixed @@ -70,3 +70,10 @@ mod external_macros { once_cell::external!(); lazy_static::external!(); } + +mod issue14729 { + use once_cell::sync::Lazy; + + #[expect(clippy::non_std_lazy_statics)] + static LAZY_FOO: Lazy<String> = Lazy::new(|| "foo".to_uppercase()); +} diff --git a/tests/ui/non_std_lazy_static/non_std_lazy_static_fixable.rs b/tests/ui/non_std_lazy_static/non_std_lazy_static_fixable.rs index c52338eee83..996ef050d69 100644 --- a/tests/ui/non_std_lazy_static/non_std_lazy_static_fixable.rs +++ b/tests/ui/non_std_lazy_static/non_std_lazy_static_fixable.rs @@ -70,3 +70,10 @@ mod external_macros { once_cell::external!(); lazy_static::external!(); } + +mod issue14729 { + use once_cell::sync::Lazy; + + #[expect(clippy::non_std_lazy_statics)] + static LAZY_FOO: Lazy<String> = Lazy::new(|| "foo".to_uppercase()); +} |
