From 5394268ca379538f0f96d8083be7ec9c7558dace Mon Sep 17 00:00:00 2001 From: Jason Newcomb Date: Sun, 5 Apr 2026 14:26:40 -0400 Subject: [PATCH] Mark method receivers in builtin derives as being from the derive. --- compiler/rustc_builtin_macros/src/deriving/generic/mod.rs | 2 +- compiler/rustc_expand/src/build.rs | 2 +- tests/ui/associated-types/issue-38821.stderr | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index b392a9623d05..63c06e672727 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -1052,7 +1052,7 @@ fn create_method( let args = { let self_arg = explicit_self.map(|explicit_self| { - let ident = Ident::with_dummy_span(kw::SelfLower).with_span_pos(span); + let ident = Ident::new(kw::SelfLower, span); ast::Param::from_self(ast::AttrVec::default(), explicit_self, ident) }); let nonself_args = diff --git a/compiler/rustc_expand/src/build.rs b/compiler/rustc_expand/src/build.rs index 3680f24707df..05e6b78132ae 100644 --- a/compiler/rustc_expand/src/build.rs +++ b/compiler/rustc_expand/src/build.rs @@ -315,7 +315,7 @@ pub fn expr_ident(&self, span: Span, id: Ident) -> Box { self.expr_path(self.path_ident(span, id)) } pub fn expr_self(&self, span: Span) -> Box { - self.expr_ident(span, Ident::with_dummy_span(kw::SelfLower)) + self.expr_ident(span, Ident::new(kw::SelfLower, span)) } pub fn expr_macro_call(&self, span: Span, call: Box) -> Box { diff --git a/tests/ui/associated-types/issue-38821.stderr b/tests/ui/associated-types/issue-38821.stderr index 07b146f8bfca..e3398f0e2390 100644 --- a/tests/ui/associated-types/issue-38821.stderr +++ b/tests/ui/associated-types/issue-38821.stderr @@ -272,6 +272,7 @@ LL | impl IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `::SqlType: NotNull` is not satisfied --> $DIR/issue-38821.rs:23:23 @@ -301,6 +302,7 @@ LL | impl IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `::SqlType: NotNull` is not satisfied --> $DIR/issue-38821.rs:23:10