diff options
| author | Tyler Mandry <tmandry@gmail.com> | 2019-10-11 15:10:00 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-11 15:10:00 -0700 |
| commit | c8e3c517828e2b0c3695140825e6f4ac497c0777 (patch) | |
| tree | 330e62c67797cffbfb908e458941befb8eb22851 | |
| parent | 811bd38ae1f183981e5ec1dc1fe096bd17929825 (diff) | |
| parent | e285175b63626bf930b90b27ba78b35842d0da2f (diff) | |
| download | rust-c8e3c517828e2b0c3695140825e6f4ac497c0777.tar.gz rust-c8e3c517828e2b0c3695140825e6f4ac497c0777.zip | |
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.
| -rw-r--r-- | src/libsyntax_ext/deriving/generic/mod.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/deprecation/derive_on_deprecated.rs | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 9f75f72e820..abdcb6c8e3d 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -192,7 +192,7 @@ use syntax::util::map_in_place::MapInPlace; use syntax::ptr::P; use syntax::symbol::{Symbol, kw, sym}; use syntax::parse::ParseSess; -use syntax_pos::{DUMMY_SP, Span}; +use syntax_pos::{Span}; use ty::{LifetimeBounds, Path, Ptr, PtrTy, Self_, Ty}; @@ -1022,7 +1022,7 @@ impl<'a> MethodDef<'a> { // [fields of next Self arg], [etc]> let mut patterns = Vec::new(); for i in 0..self_args.len() { - let struct_path = cx.path(DUMMY_SP, vec![type_ident]); + let struct_path = cx.path(trait_.span, vec![type_ident]); let (pat, ident_expr) = trait_.create_struct_pattern(cx, struct_path, struct_def, diff --git a/src/test/ui/deprecation/derive_on_deprecated.rs b/src/test/ui/deprecation/derive_on_deprecated.rs index ed4055ecdd3..ac771ac81d1 100644 --- a/src/test/ui/deprecation/derive_on_deprecated.rs +++ b/src/test/ui/deprecation/derive_on_deprecated.rs @@ -6,4 +6,10 @@ #[derive(Default)] struct X; +#[deprecated(note="Do not use this")] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default, Hash)] +pub struct Step<I> { + _skip: Option<I>, +} + fn main() {} |
