Repository: rust
Issue: `#[deprecated]` on re-exported items does not work
Labels: A-lints,T-compiler,C-bug,L-deprecated

### Problem

Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=ac1e0d070ba838247ac3587ca23bbaed

```rust
#[derive(PartialEq, Eq)]
struct New;

#[deprecated(note = "bang")]
use New as DeprecatedAlias;

#[deprecated(note = "bang")]
type ConstAndTy = New; // 

#[deprecated(note = "bang")]
#[allow(nonstandard_style)]
const ConstAndTy: New = New;

fn main ()
{
    // 😭 (does not warn)
    let self::DeprecatedAlias: DeprecatedAlias = DeprecatedAlias;
    let _ = DeprecatedAlias {};
    
    // OK (does warn)
    let self::ConstAndTy: ConstAndTy = ConstAndTy;
    let _ = ConstAndTy {};
}
```

The current output is:

  - deprecated warnings for all four usages of `ConstAndTy` (constant value, type, constant pattern, literal struct constructor).

  - **No warnings whatsoever for any of the four usages of `DeprecatedAlias`.**

<details>

```text
warning: use of deprecated constant `ConstAndTy`: bang
  --> src/main.rs:21:40
   |
21 |     let self::ConstAndTy: ConstAndTy = ConstAndTy;
   |                                        ^^^^^^^^^^
   |
   = note: `#[warn(deprecated)]` on by default

warning: use of deprecated constant `ConstAndTy`: bang
  --> src/main.rs:21:9
   |
21 |     let self::ConstAndTy: ConstAndTy = ConstAndTy;
   |         ^^^^^^^^^^^^^^^^

warning: use of deprecated type alias `ConstAndTy`: bang
  --> src/main.rs:21:27
   |
21 |     let self::ConstAndTy: ConstAndTy = ConstAndTy;
   |                           ^^^^^^^^^^

warning: use of deprecated type alias `ConstAndTy`: bang
  --> src/main.rs:22:13
   |
22 |     let _ = ConstAndTy {};
   |             ^^^^^^^^^^
```

</details>

Moreover, even if it were to lint about the `use`-reexported deprecated item, I suspect there would be no mention of the item at the origin of the re-export, even when visible and not deprecated itself.

### Suggested improvement

Ideally:

  - the output should warn about `DeprecatedAlias` too:

    ```
    warning: use of deprecated constant `DeprecatedAlias`: bang
      --> src/main.rs:17:50
       |
    17 |     let self::DeprecatedAlias: DeprecatedAlias = DeprecatedAlias;
       |                                                  ^^^^^^^^^^^^^^^
       |
       = note: `#[warn(deprecated)]` on by default
    
    warning: use of deprecated constant `DeprecatedAlias`: bang
      --> src/main.rs:17:9
       |
    17 |     let self::DeprecatedAlias: DeprecatedAlias = DeprecatedAlias;
       |         ^^^^^^^^^^^^^^^^^^^^^
    
    warning: use of deprecated type alias `DeprecatedAlias`: bang
      --> src/main.rs:17:32
       |
    17 |     let self::DeprecatedAlias: DeprecatedAlias = DeprecatedAlias;
       |                                ^^^^^^^^^^^^^^^
    
    warning: use of deprecated type alias `DeprecatedAlias`: bang
      --> src/main.rs:18:13
       |
    18 |     let _ = DeprecatedAlias {};
       |             ^^^^^^^^^^^^^^^
    ```

  - And when the source of the re-export is visible to the scope where the deprecated alias is used, it should also suggest using that path instead:

    ```diff
      warning: use of deprecated constant `DeprecatedAlias`: bang
        --> src/main.rs:17:50
         |
      17 |     let self::DeprecatedAlias: DeprecatedAlias = DeprecatedAlias;
         |                                                  ^^^^^^^^^^^^^^^
    +    |                                                  help: use the non-deprecated path: `New`
         |
         = note: `#[warn(deprecated)]` on by default
      
      warning: use of deprecated constant `DeprecatedAlias`: bang
        --> src/main.rs:17:9
         |
      17 |     let self::DeprecatedAlias: DeprecatedAlias = DeprecatedAlias;
         |         ^^^^^^^^^^^^^^^^^^^^^
    +    |         help: use the non-deprecated path: `self::New`
      
      warning: use of deprecated type alias `DeprecatedAlias`: bang
        --> src/main.rs:17:32
         |
      17 |     let self::DeprecatedAlias: DeprecatedAlias = DeprecatedAlias;
         |                                ^^^^^^^^^^^^^^^
    +    |                                help: use the non-deprecated path: `New`
      
      warning: use of deprecated type alias `DeprecatedAlias`: bang
        --> src/main.rs:18:13
         |
      18 |     let _ = DeprecatedAlias {};
         |             ^^^^^^^^^^^^^^^
    +    |             help: use the non-deprecated path: `New`
    ```

### Rationale and further discussion

_c.f._ https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification

  - cc @shepmaster @jyn514 @thomcc