Fix issue when a foreign `Err` pollutes scope (#758)

This commit is contained in:
Lena Hellström 2025-03-10 18:48:46 +01:00 committed by GitHub
parent 3d1c4c339a
commit bb3e60c94c
2 changed files with 5 additions and 1 deletions

View File

@ -162,7 +162,7 @@ impl DeriveEnum {
// if we have fixed value variants // if we have fixed value variants
result.ident_str("variant"); result.ident_str("variant");
result.puncts("=>"); result.puncts("=>");
result.ident_str("Err"); result.push_parsed("core::result::Result::Err")?;
result.group(Delimiter::Parenthesis, |err_inner| { result.group(Delimiter::Parenthesis, |err_inner| {
err_inner.push_parsed(format!( err_inner.push_parsed(format!(
"{}::error::DecodeError::UnexpectedVariant", "{}::error::DecodeError::UnexpectedVariant",

View File

@ -408,6 +408,10 @@ mod derive_with_polluted_scope {
#[allow(non_snake_case)] #[allow(non_snake_case)]
fn Ok() {} fn Ok() {}
#[allow(dead_code)]
#[allow(non_snake_case)]
fn Err() {}
#[derive(bincode::Encode, bincode::Decode)] #[derive(bincode::Encode, bincode::Decode)]
struct A { struct A {
a: u32, a: u32,