Skip to content

Commit

Permalink
Rollup merge of rust-lang#65310 - da-x:issue-56195, r=petrochenkov
Browse files Browse the repository at this point in the history
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 rust-lang#56195, Fixes rust-lang#55417.
  • Loading branch information
tmandry authored Oct 11, 2019
2 parents 811bd38 + e285175 commit c8e3c51
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libsyntax_ext/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/test/ui/deprecation/derive_on_deprecated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

0 comments on commit c8e3c51

Please sign in to comment.