Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation warning emitted from derive without a span #56195

Closed
bluss opened this issue Nov 24, 2018 · 2 comments · Fixed by #65310
Closed

Deprecation warning emitted from derive without a span #56195

bluss opened this issue Nov 24, 2018 · 2 comments · Fixed by #65310
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@bluss
Copy link
Member

bluss commented Nov 24, 2018

Reproducing code:

#[derive(Clone)]
#[deprecated(note="This is no longer useful")]
pub struct MyType { }

fn main() { }

Emits (without line numbers)

warning: use of deprecated item 'MyType': This is no longer useful
  |
  = note: #[warn(deprecated)] on by default

(Old report)

In this branch / commit of itertools, running cargo build shows a deprecation error without location in the code.

Running `rustc --crate-name itertools src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="use_std"' -C metadata=ba59252761bab077 -C extra-filename=-ba59252761bab077 --out-dir /home/travis/build/bluss/rust-itertools/target/debug/deps -L dependency=/home/travis/build/bluss/rust-itertools/target/debug/deps --extern either=/home/travis/build/bluss/rust-itertools/target/debug/deps/libeither-298d84de5004c8fc.rlib`
warning: use of deprecated item: Use std .step_by() instead
  |
  = note: #[warn(deprecated)] on by default
warning: use of deprecated item: Use std .step_by() instead

Version: rustc 1.32.0-nightly (1f57e48 2018-11-23)

@bluss
Copy link
Member Author

bluss commented Nov 24, 2018

Culprit found: the derives on top of the deprecated type.

#[deprecated(note="Use std .step_by() instead", since="0.8")]
#[derive(Clone, Debug)]
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
pub struct Step<I> {
    iter: Fuse<I>,
    skip: usize,
}

Inserting an#[allow(deprecated)] on the deprecated struct silences the mystery warning.

@bluss bluss changed the title Deprecation warning emitted by rustc without a span Deprecation warning emitted from derive without a span Nov 24, 2018
@estebank estebank added the A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. label Nov 24, 2018
@joshlf
Copy link
Contributor

joshlf commented Oct 5, 2019

Same as #38832?

tmandry added a commit to tmandry/rust that referenced this issue Oct 11, 2019
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.
@bors bors closed this as completed in a32aec0 Oct 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants