rust/library/std/src
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
..
backtrace std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
collections Tests for HashMap/HashSet::drain_filter 2020-09-08 17:24:28 -07:00
env std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
error std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
f32 std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
f64 std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
ffi Capitalize safety comments 2020-09-08 22:26:44 -04:00
fs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
io Auto merge of #74366 - t-rapp:tr-bufreader-pos, r=LukasKalbertodt 2020-09-07 11:09:41 +00:00
lazy std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
memchr std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
net Make Ipv4Addr and Ipv6Addr const tests unit tests under library 2020-09-03 23:17:21 +02:00
num std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
os Update std::os module documentation. 2020-09-11 04:05:19 +02:00
path std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
prelude Fix incorrect link in prelude 2020-09-02 17:38:21 -04:00
process std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
sync Auto merge of #76128 - poliorcetics:doc-use-arc-clone, r=KodrAus 2020-09-06 12:34:31 +00:00
sys Auto merge of #76561 - Thomasdezeeuw:iov-constant-limits, r=Amanieu 2020-09-12 12:06:12 +00:00
sys_common Capitalize safety comments 2020-09-08 22:26:44 -04:00
thread std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
time std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
alloc.rs Capitalize safety comments 2020-09-08 22:26:44 -04:00
ascii.rs Convert many files to intra-doc links 2020-09-02 17:37:40 -04:00
backtrace.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
env.rs Improve docs for std::env::args() 2020-09-04 14:00:09 -07:00
error.rs Mark Error impl for LayoutErr as stable. 2020-09-11 13:36:15 +02:00
f32.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
f64.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
fs.rs Convert many files to intra-doc links 2020-09-02 17:37:40 -04:00
future.rs Stabilize future readiness fns 2020-08-25 19:08:43 +02:00
keyword_docs.rs Improve wording for const pointers 2020-09-01 19:44:20 -07:00
lazy.rs Capitalize safety comments 2020-09-08 22:26:44 -04:00
lib.rs Auto merge of #74328 - yoshuawuyts:stabilize-future-readiness-fns, r=sfackler 2020-09-12 02:13:28 +00:00
macros.rs Add missing links 2020-08-22 20:23:50 -07:00
memchr.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
num.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
panic.rs Mark RefUnwindSafe impls for stable atomic types as stable. 2020-09-11 13:36:15 +02:00
panicking.rs Abort when catch_unwind catches a foreign exception 2020-08-27 21:08:30 +01:00
path.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
primitive_docs.rs Rollup merge of #76164 - lzutao:slice-array, r=ehuss 2020-09-03 02:22:04 +02:00
process.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
rt.rs Prevent __rust_begin_short_backtrace frames from being tail-call optimised away 2020-08-07 19:31:25 +01:00
time.rs Rollup merge of #76162 - abrausch:documentation-fix-duration_since, r=jyn514 2020-09-09 01:35:10 +02:00