Skip to content
This repository was archived by the owner on Mar 25, 2024. It is now read-only.

Commit 8a5542c

Browse files
committed
Resolve non_local_definitions warning in test
warning: non-local `impl` definition, they should be avoided as they go against expectation --> tests/test_error.rs:412:13 | 412 | / impl<'de> Visitor<'de> for X { 413 | | type Value = X; 414 | | 415 | | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ... | 429 | | } 430 | | } | |_____________^ | = help: move this `impl` block outside the of the current associated function `deserialize` and up 2 bodies = 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
1 parent ea57d8c commit 8a5542c

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

tests/test_error.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -404,31 +404,31 @@ fn test_billion_laughs() {
404404
#[derive(Debug)]
405405
struct X;
406406

407+
impl<'de> Visitor<'de> for X {
408+
type Value = X;
409+
410+
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
411+
formatter.write_str("exponential blowup")
412+
}
413+
414+
fn visit_unit<E>(self) -> Result<X, E> {
415+
Ok(X)
416+
}
417+
418+
fn visit_seq<S>(self, mut seq: S) -> Result<X, S::Error>
419+
where
420+
S: SeqAccess<'de>,
421+
{
422+
while let Some(X) = seq.next_element()? {}
423+
Ok(X)
424+
}
425+
}
426+
407427
impl<'de> Deserialize<'de> for X {
408428
fn deserialize<D>(deserializer: D) -> Result<X, D::Error>
409429
where
410430
D: serde::Deserializer<'de>,
411431
{
412-
impl<'de> Visitor<'de> for X {
413-
type Value = X;
414-
415-
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
416-
formatter.write_str("exponential blowup")
417-
}
418-
419-
fn visit_unit<E>(self) -> Result<X, E> {
420-
Ok(X)
421-
}
422-
423-
fn visit_seq<S>(self, mut seq: S) -> Result<X, S::Error>
424-
where
425-
S: SeqAccess<'de>,
426-
{
427-
while let Some(X) = seq.next_element()? {}
428-
Ok(X)
429-
}
430-
}
431-
432432
deserializer.deserialize_any(X)
433433
}
434434
}

0 commit comments

Comments
 (0)