Skip to content

Commit

Permalink
Ignore non_local_definitions false positive in test
Browse files Browse the repository at this point in the history
rust-lang/rust#121621

    warning: non-local `impl` definition, they should be avoided as they go against expectation
        --> tests/test.rs:2338:5
         |
    2338 | /     impl<'de> Deserialize<'de> for &'de RawMapKey {
    2339 | |         fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    2340 | |         where
    2341 | |             D: serde::Deserializer<'de>,
    ...    |
    2345 | |         }
    2346 | |     }
         | |_____^
         |
         = help: move this `impl` block outside the of the current function `test_raw_value_in_map_key`
         = note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block
         = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type
         = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <rust-lang/rust#120363>
         = note: `#[warn(non_local_definitions)]` on by default
  • Loading branch information
dtolnay committed Feb 26, 2024
1 parent e1b3a6d commit fedf834
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2335,6 +2335,8 @@ fn test_raw_value_in_map_key() {
#[repr(transparent)]
struct RawMapKey(RawValue);

#[allow(unknown_lints)]
#[allow(non_local_definitions)] // false positive: https://github.com/rust-lang/rust/issues/121621
impl<'de> Deserialize<'de> for &'de RawMapKey {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
Expand Down

0 comments on commit fedf834

Please sign in to comment.