rust/compiler
bors 989190874f Auto merge of #76538 - fusion-engineering-forks:check-useless-unstable-trait-impl, r=lcnr
Warn for #[unstable] on trait impls when it has no effect.

Earlier today I sent a PR with an `#[unstable]` attribute on a trait `impl`, but was informed that this attribute has no effect there. (comment: https://github.com/rust-lang/rust/pull/76525#issuecomment-689678895, issue: https://github.com/rust-lang/rust/issues/55436)

This PR adds a warning for this situation. Trait `impl` blocks with `#[unstable]` where both the type and the trait are stable will result in a warning:

```
warning: An `#[unstable]` annotation here has no effect. See issue #55436 <https://github.com/rust-lang/rust/issues/55436> for more information.
   --> library/std/src/panic.rs:235:1
    |
235 | #[unstable(feature = "integer_atomics", issue = "32976")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

---

It detects three problems in the existing code:

1. A few `RefUnwindSafe` implementations for the atomic integer types in `library/std/src/panic.rs`. Example:
d92155bf6a/library/std/src/panic.rs (L235-L236)
2. An implementation of `Error` for `LayoutErr` in `library/std/srd/error.rs`:
d92155bf6a/library/std/src/error.rs (L392-L397)
3. `From` implementations for `Waker` and `RawWaker` in `library/alloc/src/task.rs`. Example:
d92155bf6a/library/alloc/src/task.rs (L36-L37)

Case 3 interesting: It has a bound with an `#[unstable]` trait (`W: Wake`), so appears to have much effect on stable code. It does however break similar blanket implementations. It would also have immediate effect if `Wake` was implemented for any stable type. (Which is not the case right now, but there are no warnings in place to prevent it.) Whether this case is a problem or not is not clear to me. If it isn't, adding a simple `c.visit_generics(..);` to this PR will stop the warning for this case.
2020-09-12 18:01:33 +00:00
..
rustc
rustc_apfloat
rustc_arena
rustc_ast Fully integrate token collection for additional AST structs 2020-09-10 17:58:14 -04:00
rustc_ast_lowering Attach TokenStream to ast::Visibility 2020-09-10 17:33:06 -04:00
rustc_ast_passes update the version of itertools and parking_lot 2020-09-12 08:26:53 +02:00
rustc_ast_pretty Fully integrate token collection for additional AST structs 2020-09-10 17:58:14 -04:00
rustc_attr
rustc_builtin_macros Attach tokens to ast::Stmt 2020-09-10 17:33:06 -04:00
rustc_codegen_llvm Rollup merge of #74787 - petrochenkov:rustllvm, r=cuviper 2020-09-09 21:02:24 -07:00
rustc_codegen_ssa use push(char) instead of push_str(&str) to add single chars to strings 2020-09-10 13:58:41 +02:00
rustc_data_structures update the version of itertools and parking_lot 2020-09-12 08:26:53 +02:00
rustc_driver Auto merge of #73996 - da-x:short-unique-paths, r=petrochenkov 2020-09-03 23:27:45 +00:00
rustc_error_codes Rollup merge of #75984 - kornelski:typeormodule, r=matthewjasper 2020-09-09 15:05:45 -07:00
rustc_errors rustc_{errors,session}: add delay_good_path_bug 2020-09-02 10:43:17 +03:00
rustc_expand Attach tokens to ast::Stmt 2020-09-10 17:33:06 -04:00
rustc_feature fix tidy, small cleanup 2020-09-10 09:48:02 +02:00
rustc_fs_util
rustc_graphviz Also fixed monospace font for d3-graphviz engine 2020-09-09 14:49:32 -07:00
rustc_hir [WIP] give better errors for broken intra doc links 2020-09-05 13:48:19 -04:00
rustc_hir_pretty
rustc_incremental
rustc_index
rustc_infer use push(char) instead of push_str(&str) to add single chars to strings 2020-09-10 13:58:41 +02:00
rustc_interface Attach tokens to ast::Stmt 2020-09-10 17:33:06 -04:00
rustc_lexer lexer: Tiny improvement to shebang detection 2020-09-02 00:40:19 +03:00
rustc_lint Change ty.kind to a method 2020-09-04 17:47:51 +02:00
rustc_llvm Move rustllvm into rustc_llvm 2020-09-09 23:05:43 +03:00
rustc_macros Fix non-determinism in generated format string. 2020-09-09 21:23:25 +10:00
rustc_metadata Attach TokenStream to ast::Visibility 2020-09-10 17:33:06 -04:00
rustc_middle Auto merge of #75573 - Aaron1011:feature/const-mutation-lint, r=oli-obk 2020-09-10 05:54:26 +00:00
rustc_mir update the version of itertools and parking_lot 2020-09-12 08:26:53 +02:00
rustc_mir_build Auto merge of #75573 - Aaron1011:feature/const-mutation-lint, r=oli-obk 2020-09-10 05:54:26 +00:00
rustc_parse Attach tokens to ast::Stmt 2020-09-10 17:33:06 -04:00
rustc_parse_format
rustc_passes Improve ineffective_unstable_trait_impl error message. 2020-09-11 21:42:28 +02:00
rustc_plugin_impl
rustc_privacy Change ty.kind to a method 2020-09-04 17:47:51 +02:00
rustc_query_system update the version of itertools and parking_lot 2020-09-12 08:26:53 +02:00
rustc_resolve Auto merge of #76499 - guswynn:priv_des, r=petrochenkov 2020-09-11 20:01:31 +00:00
rustc_save_analysis use push(char) instead of push_str(&str) to add single chars to strings 2020-09-10 13:58:41 +02:00
rustc_serialize
rustc_session Auto merge of #76538 - fusion-engineering-forks:check-useless-unstable-trait-impl, r=lcnr 2020-09-12 18:01:33 +00:00
rustc_span implement const_evaluatable_checked feature MVP 2020-09-10 08:52:02 +02:00
rustc_symbol_mangling Change ty.kind to a method 2020-09-04 17:47:51 +02:00
rustc_target remove redundant clones 2020-09-09 16:32:55 +02:00
rustc_trait_selection fix tidy, small cleanup 2020-09-10 09:48:02 +02:00
rustc_traits kind -> kind() 2020-09-04 19:17:57 -04:00
rustc_ty Change ty.kind to a method 2020-09-04 17:47:51 +02:00
rustc_typeck better diag when const ranges are used in patterns 2020-09-11 15:02:15 -07:00