Skip to content

Commit c8e3c51

Browse files
authored
Rollup merge of #65310 - da-x:issue-56195, r=petrochenkov
deriving: avoid dummy Span on an artificial `type_ident` path The dummy Span pointed to the beginning of the source file instead to where the `#[derive]` is located. Later, it tripped the `in_derive_expansion(span)` check at `src/librustc/middle/stability.rs`, causing a span-less deprecation warning to be emitted. Fixes #56195, Fixes #55417.
2 parents 811bd38 + e285175 commit c8e3c51

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/libsyntax_ext/deriving/generic/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ use syntax::util::map_in_place::MapInPlace;
192192
use syntax::ptr::P;
193193
use syntax::symbol::{Symbol, kw, sym};
194194
use syntax::parse::ParseSess;
195-
use syntax_pos::{DUMMY_SP, Span};
195+
use syntax_pos::{Span};
196196

197197
use ty::{LifetimeBounds, Path, Ptr, PtrTy, Self_, Ty};
198198

@@ -1022,7 +1022,7 @@ impl<'a> MethodDef<'a> {
10221022
// [fields of next Self arg], [etc]>
10231023
let mut patterns = Vec::new();
10241024
for i in 0..self_args.len() {
1025-
let struct_path = cx.path(DUMMY_SP, vec![type_ident]);
1025+
let struct_path = cx.path(trait_.span, vec![type_ident]);
10261026
let (pat, ident_expr) = trait_.create_struct_pattern(cx,
10271027
struct_path,
10281028
struct_def,

src/test/ui/deprecation/derive_on_deprecated.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@
66
#[derive(Default)]
77
struct X;
88

9+
#[deprecated(note="Do not use this")]
10+
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default, Hash)]
11+
pub struct Step<I> {
12+
_skip: Option<I>,
13+
}
14+
915
fn main() {}

0 commit comments

Comments
 (0)