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

Error on private items with stability attributes #83397

Closed
wants to merge 3 commits into from

Conversation

camelid
Copy link
Member

@camelid camelid commented Mar 23, 2021

Fixes #83380.

It doesn't make sense for a private item to have a stability attribute,
and it is likely a mistake. Report an error when we see a case of this.

Inspired by #83372 (comment).

Also tweaked wording of "missing stability attribute" error.

@camelid camelid added A-stability Area: issues related to #[stable] and #[unstable] attributes themselves. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 23, 2021
@rust-highfive
Copy link
Collaborator

r? @matthewjasper

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 23, 2021
@camelid camelid force-pushed the stability-without-publicity branch from ce0f22f to a59f8da Compare March 23, 2021 00:40
@rust-log-analyzer

This comment has been minimized.

@camelid camelid added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Mar 23, 2021
@jyn514 jyn514 added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Mar 24, 2021
@jyn514
Copy link
Member

jyn514 commented Mar 24, 2021

r? @m-ou-se since I think she'll be able to answer "should we do this at all" better

@crlf0710
Copy link
Member

crlf0710 commented Apr 9, 2021

@camelid Ping from triage, what's the current status of this? Seems CI is still red.

@camelid
Copy link
Member Author

camelid commented Apr 12, 2021

@camelid Ping from triage, what's the current status of this? Seems CI is still red.

Yeah, I'm not really sure why the code isn't working, and I haven't gotten around to asking yet.

@m-ou-se
Copy link
Member

m-ou-se commented Apr 12, 2021

should we do this at all

I'm very much in favour of lints like this for the attributes we use in std. It's easy to make mistakes with these attributes, and the more easily an error is caught the better.

I haven't looked in detail through the errors CI is giving, but I wonder how many of these are actual errors with these attributes in std that we only discover now.

Assigning it back for compiler review:

r? @matthewjasper


fn check_private_stability(&self, hir_id: HirId, span: Span) {
let stab = self.tcx.stability().local_stability(hir_id);
let is_error = stab.is_some() && !self.access_levels.is_reachable(hir_id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this is currently buggy: #64762

compiler/rustc_passes/src/stability.rs Outdated Show resolved Hide resolved
@jyn514 jyn514 removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 12, 2021
@crlf0710
Copy link
Member

crlf0710 commented May 1, 2021

@camelid Ping from triage, CI still red, and there's merge conflicts. Would you mind addressing the comments above? Thanks!

If you need help from team members, maybe Zulip is a more effective approach to talk with them. Thanks!

@crlf0710 crlf0710 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 1, 2021
@camelid
Copy link
Member Author

camelid commented May 8, 2021

Thanks for the ping! I'm currently catching up on my pull requests, so I'll try to get to this one soon :)

@camelid camelid force-pushed the stability-without-publicity branch from a59f8da to bd4823e Compare May 18, 2021 00:00
@camelid
Copy link
Member Author

camelid commented May 18, 2021

Starting with a rebase...

@rust-log-analyzer

This comment has been minimized.

@crlf0710
Copy link
Member

crlf0710 commented Jun 5, 2021

@camelid Ping from triage, CI is still red here.

@JohnCSimon
Copy link
Member

JohnCSimon commented Jun 22, 2021

@camelid Ping again from triage, CI is still failing

@camelid camelid marked this pull request as draft July 2, 2021 00:39
@camelid
Copy link
Member Author

camelid commented Jul 3, 2021

I will try to get to this soon.

It doesn't make sense for a private item to have a stability attribute,
and it is likely a mistake. Report an error when we see a case of this.
@camelid camelid force-pushed the stability-without-publicity branch from ba48420 to dad5673 Compare July 22, 2021 23:25
@camelid
Copy link
Member Author

camelid commented Jul 22, 2021

Rebased.

@rust-log-analyzer

This comment has been minimized.

@camelid camelid force-pushed the stability-without-publicity branch from dad5673 to b318344 Compare July 22, 2021 23:55
@camelid
Copy link
Member Author

camelid commented Jul 22, 2021

Hmm, still getting thousands of stability errors when compiling core...

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-10 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   |
22 | use crate::intrinsics;
   | ^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: constant is private but has a stability attribute
  --> library/core/src/num/bignum.rs:94:1
   |
   |
94 | const SMALL_POW5: [(u64, usize); 3] = [(125, 3), (15625, 6), (1_220_703_125, 13)];
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
  --> library/core/src/num/dec2flt/mod.rs:78:1
   |
78 | use crate::fmt;
78 | use crate::fmt;
   | ^^^^^^^^^^^^^^^
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
  --> library/core/src/num/dec2flt/mod.rs:79:1
   |
79 | use crate::str::FromStr;
79 | use crate::str::FromStr;
   | ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
  --> library/core/src/num/dec2flt/mod.rs:81:1
   |
   |
81 | use self::common::{BiasedFp, ByteSlice};
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
  --> library/core/src/num/dec2flt/mod.rs:81:20
   |
   |
81 | use self::common::{BiasedFp, ByteSlice};
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
  --> library/core/src/num/dec2flt/mod.rs:81:30
   |
   |
81 | use self::common::{BiasedFp, ByteSlice};
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
  --> library/core/src/num/dec2flt/mod.rs:82:1
   |
82 | use self::float::RawFloat;
82 | use self::float::RawFloat;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
  --> library/core/src/num/dec2flt/mod.rs:83:1
   |
83 | use self::lemire::compute_float;
83 | use self::lemire::compute_float;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
  --> library/core/src/num/dec2flt/mod.rs:84:1
   |
   |
84 | use self::parse::{parse_inf_nan, parse_number};
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
  --> library/core/src/num/dec2flt/mod.rs:84:19
   |
   |
84 | use self::parse::{parse_inf_nan, parse_number};
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
  --> library/core/src/num/dec2flt/mod.rs:84:34
   |
   |
84 | use self::parse::{parse_inf_nan, parse_number};
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
  --> library/core/src/num/dec2flt/mod.rs:85:1
   |
85 | use self::slow::parse_long_mantissa;
85 | use self::slow::parse_long_mantissa;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: module is private but has a stability attribute
  --> library/core/src/num/dec2flt/mod.rs:87:1
   |
   |
87 | mod common;
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
 --> library/core/src/num/dec2flt/common.rs:3:1
  |
3 | use crate::ptr;
3 | use crate::ptr;
  | ^^^^^^^^^^^^^^^
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public
error: trait is private but has a stability attribute
  --> library/core/src/num/dec2flt/common.rs:6:1
   |
   |
6  | / pub(crate) trait ByteSlice: AsRef<[u8]> {
7  | |     unsafe fn first_unchecked(&self) -> u8 {
8  | |         debug_assert!(!self.is_empty());
9  | |         // SAFETY: safe as long as self is not empty
90 | |     }
91 | | }
   | |_^
   |
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: implementation is private but has a stability attribute
  --> library/core/src/num/dec2flt/common.rs:93:1
   |
   |
93 | impl ByteSlice for [u8] {}
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: trait is private but has a stability attribute
   --> library/core/src/num/dec2flt/common.rs:96:1
    |
    |
96  | / pub(crate) trait ByteSliceMut: AsMut<[u8]> {
97  | |     /// Write a 64-bit integer as 8 bytes in little-endian order.
98  | |     unsafe fn write_u64_unchecked(&mut self, value: u64) {
99  | |         debug_assert!(self.as_mut().len() >= 8);
108 | |     }
109 | | }
    | |_^
    |
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: implementation is private but has a stability attribute
   --> library/core/src/num/dec2flt/common.rs:111:1
    |
    |
111 | impl ByteSliceMut for [u8] {}
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: implementation is private but has a stability attribute
   --> library/core/src/num/dec2flt/common.rs:119:1
    |
    |
119 | / impl<'a> AsciiStr<'a> {
120 | |     pub fn new(slc: &'a [u8]) -> Self {
121 | |         Self { slc }
...   |
151 | |     }
152 | | }
    | |_^
    | |_^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: implementation is private but has a stability attribute
   --> library/core/src/num/dec2flt/common.rs:154:1
    |
    |
154 | / impl<'a> AsRef<[u8]> for AsciiStr<'a> {
155 | |     #[inline]
156 | |     fn as_ref(&self) -> &[u8] {
157 | |         self.slc
159 | | }
    | |_^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: implementation is private but has a stability attribute
   --> library/core/src/num/dec2flt/common.rs:161:1
    |
    |
161 | impl<'a> ByteSlice for AsciiStr<'a> {}
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: function is private but has a stability attribute
   --> library/core/src/num/dec2flt/common.rs:165:1
    |
    |
165 | / pub(crate) fn is_8digits(v: u64) -> bool {
166 | |     let a = v.wrapping_add(0x4646_4646_4646_4646);
167 | |     let b = v.wrapping_sub(0x3030_3030_3030_3030);
168 | |     (a | b) & 0x8080_8080_8080_8080 == 0
    | |_^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: function is private but has a stability attribute
   --> library/core/src/num/dec2flt/common.rs:172:1
    |
    |
172 | / pub(crate) fn parse_digits(s: &mut &[u8], mut f: impl FnMut(u8)) {
173 | |     while let Some(&c) = s.get(0) {
174 | |         let c = c.wrapping_sub(b'0');
175 | |         if c < 10 {
181 | |     }
182 | | }
    | |_^
    |
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: module is private but has a stability attribute
  --> library/core/src/num/dec2flt/mod.rs:88:1
   |
88 | mod decimal;
88 | mod decimal;
   | ^^^^^^^^^^^^
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
  --> library/core/src/num/dec2flt/decimal.rs:12:1
   |
   |
12 | use crate::num::dec2flt::common::{is_8digits, parse_digits, ByteSlice, ByteSliceMut};
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
  --> library/core/src/num/dec2flt/decimal.rs:12:35
   |
   |
12 | use crate::num::dec2flt::common::{is_8digits, parse_digits, ByteSlice, ByteSliceMut};
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
  --> library/core/src/num/dec2flt/decimal.rs:12:47
   |
   |
12 | use crate::num::dec2flt::common::{is_8digits, parse_digits, ByteSlice, ByteSliceMut};
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
  --> library/core/src/num/dec2flt/decimal.rs:12:61
   |
   |
12 | use crate::num::dec2flt::common::{is_8digits, parse_digits, ByteSlice, ByteSliceMut};
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
  --> library/core/src/num/dec2flt/decimal.rs:12:72
   |
   |
12 | use crate::num::dec2flt::common::{is_8digits, parse_digits, ByteSlice, ByteSliceMut};
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: implementation is private but has a stability attribute
  --> library/core/src/num/dec2flt/decimal.rs:26:1
   |
   |
26 | / impl Default for Decimal {
27 | |     fn default() -> Self {
28 | |         Self { num_digits: 0, decimal_point: 0, truncated: false, digits: [0; Self::MAX_DIGITS] }
30 | | }
   | |_^
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: implementation is private but has a stability attribute
   --> library/core/src/num/dec2flt/decimal.rs:32:1
    |
32  | / impl Decimal {
32  | / impl Decimal {
33  | |     /// The maximum number of digits required to unambiguously round a float.
34  | |     ///
35  | |     /// For a double-precision IEEE-754 float, this required 767 digits,
201 | |     }
202 | | }
    | |_^
    |
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: function is private but has a stability attribute
   --> library/core/src/num/dec2flt/decimal.rs:205:1
    |
    |
205 | / pub fn parse_decimal(mut s: &[u8]) -> Decimal {
206 | |     let mut d = Decimal::default();
207 | |     let start = s;
208 | |     s = s.skip_chars(b'0');
271 | |     d
272 | | }
    | |_^
    |
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: function is private but has a stability attribute
   --> library/core/src/num/dec2flt/decimal.rs:274:1
    |
    |
274 | / fn number_of_digits_decimal_left_shift(d: &Decimal, mut shift: usize) -> usize {
275 | |     #[rustfmt::skip]
276 | |     const TABLE: [u16; 65] = [
277 | |         0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817, 0x181D, 0x2024,
350 | |     num_new_digits
351 | | }
    | |_^
    |
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: module is private but has a stability attribute
  --> library/core/src/num/dec2flt/mod.rs:89:1
   |
   |
89 | mod fpu;
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
 --> library/core/src/num/dec2flt/fpu.rs:4:1
  |
4 | pub use fpu_precision::set_precision;
4 | pub use fpu_precision::set_precision;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public
error: module is private but has a stability attribute
  --> library/core/src/num/dec2flt/fpu.rs:87:1
   |
   |
87 | / mod fpu_precision {
88 | |     pub fn set_precision<T>() {}
   | |_^
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: function is private but has a stability attribute
  --> library/core/src/num/dec2flt/fpu.rs:88:5
   |
88 |     pub fn set_precision<T>() {}
88 |     pub fn set_precision<T>() {}
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: module is private but has a stability attribute
  --> library/core/src/num/dec2flt/mod.rs:90:1
   |
   |
90 | mod slow;
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
 --> library/core/src/num/dec2flt/slow.rs:3:1
  |
  |
3 | use crate::num::dec2flt::common::BiasedFp;
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
 --> library/core/src/num/dec2flt/slow.rs:4:1
  |
  |
4 | use crate::num::dec2flt::decimal::{parse_decimal, Decimal};
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
 --> library/core/src/num/dec2flt/slow.rs:4:36
  |
  |
4 | use crate::num::dec2flt::decimal::{parse_decimal, Decimal};
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
 --> library/core/src/num/dec2flt/slow.rs:4:51
  |
  |
4 | use crate::num::dec2flt::decimal::{parse_decimal, Decimal};
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
 --> library/core/src/num/dec2flt/slow.rs:5:1
  |
5 | use crate::num::dec2flt::float::RawFloat;
5 | use crate::num::dec2flt::float::RawFloat;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public
error: function is private but has a stability attribute
   --> library/core/src/num/dec2flt/slow.rs:26:1
    |
    |
26  | / pub(crate) fn parse_long_mantissa<F: RawFloat>(s: &[u8]) -> BiasedFp {
27  | |     const MAX_SHIFT: usize = 60;
28  | |     const NUM_POWERS: usize = 19;
29  | |     const POWERS: [u8; 19] =
...   |
108 | |     BiasedFp { f: mantissa, e: power2 }
    | |_^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: constant is private but has a stability attribute
  --> library/core/src/num/dec2flt/slow.rs:27:5
   |
   |
27 |     const MAX_SHIFT: usize = 60;
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: constant is private but has a stability attribute
  --> library/core/src/num/dec2flt/slow.rs:28:5
   |
28 |     const NUM_POWERS: usize = 19;
28 |     const NUM_POWERS: usize = 19;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: constant is private but has a stability attribute
  --> library/core/src/num/dec2flt/slow.rs:29:5
   |
   |
29 | /     const POWERS: [u8; 19] =
30 | |         [0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59];
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: module is private but has a stability attribute
  --> library/core/src/num/dec2flt/mod.rs:91:1
   |
91 | mod table;
91 | mod table;
   | ^^^^^^^^^^
   |
---
166 | |     }
167 | | }
    | |_^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: module is private but has a stability attribute
   --> library/core/src/stream/mod.rs:125:1
    |
125 | mod stream;
125 | mod stream;
    | ^^^^^^^^^^^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
 --> library/core/src/stream/stream/mod.rs:1:1
  |
1 | use crate::ops::DerefMut;
1 | use crate::ops::DerefMut;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
 --> library/core/src/stream/stream/mod.rs:2:1
  |
2 | use crate::pin::Pin;
2 | use crate::pin::Pin;
  | ^^^^^^^^^^^^^^^^^^^^
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
 --> library/core/src/stream/stream/mod.rs:3:1
  |
  |
3 | use crate::task::{Context, Poll};
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
 --> library/core/src/stream/stream/mod.rs:3:19
  |
  |
3 | use crate::task::{Context, Poll};
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
 --> library/core/src/stream/stream/mod.rs:3:28
  |
  |
3 | use crate::task::{Context, Poll};
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/sync/atomic.rs:135:5
    |
135 |     v: UnsafeCell<u8>,
135 |     v: UnsafeCell<u8>,
    |     ^^^^^^^^^^^^^^^^^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/sync/atomic.rs:165:5
    |
    |
165 |     p: UnsafeCell<*mut T>,
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
   --> library/core/src/sync/atomic.rs:933:9
    |
933 |         use crate::mem::align_of;
933 |         use crate::mem::align_of;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
 --> library/core/src/fmt/builders.rs:6:5
  |
  |
6 |     buf: &'buf mut (dyn fmt::Write + 'buf),
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
 --> library/core/src/fmt/builders.rs:7:5
  |
  |
7 |     state: &'state mut PadAdapterState,
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
  --> library/core/src/fmt/builders.rs:11:5
   |
11 |     on_newline: bool,
11 |     on_newline: bool,
   |     ^^^^^^^^^^^^^^^^
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
  --> library/core/src/fmt/builders.rs:93:5
   |
   |
93 |     fmt: &'a mut fmt::Formatter<'b>,
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
  --> library/core/src/fmt/builders.rs:94:5
   |
94 |     result: fmt::Result,
94 |     result: fmt::Result,
   |     ^^^^^^^^^^^^^^^^^^^
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
  --> library/core/src/fmt/builders.rs:95:5
   |
95 |     has_fields: bool,
95 |     has_fields: bool,
   |     ^^^^^^^^^^^^^^^^
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/builders.rs:282:5
    |
    |
282 |     fmt: &'a mut fmt::Formatter<'b>,
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/builders.rs:283:5
    |
283 |     result: fmt::Result,
283 |     result: fmt::Result,
    |     ^^^^^^^^^^^^^^^^^^^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/builders.rs:284:5
    |
284 |     fields: usize,
284 |     fields: usize,
    |     ^^^^^^^^^^^^^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/builders.rs:285:5
    |
285 |     empty_name: bool,
285 |     empty_name: bool,
    |     ^^^^^^^^^^^^^^^^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/builders.rs:386:5
    |
    |
386 |     fmt: &'a mut fmt::Formatter<'b>,
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/builders.rs:387:5
    |
387 |     result: fmt::Result,
387 |     result: fmt::Result,
    |     ^^^^^^^^^^^^^^^^^^^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/builders.rs:388:5
    |
388 |     has_fields: bool,
388 |     has_fields: bool,
    |     ^^^^^^^^^^^^^^^^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/builders.rs:448:5
    |
    |
448 |     inner: DebugInner<'a, 'b>,
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/builders.rs:578:5
    |
    |
578 |     inner: DebugInner<'a, 'b>,
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/builders.rs:708:5
    |
    |
708 |     fmt: &'a mut fmt::Formatter<'b>,
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/builders.rs:709:5
    |
709 |     result: fmt::Result,
709 |     result: fmt::Result,
    |     ^^^^^^^^^^^^^^^^^^^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/builders.rs:710:5
    |
710 |     has_fields: bool,
710 |     has_fields: bool,
    |     ^^^^^^^^^^^^^^^^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/builders.rs:711:5
    |
711 |     has_key: bool,
711 |     has_key: bool,
    |     ^^^^^^^^^^^^^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/builders.rs:713:5
    |
713 |     state: PadAdapterState,
713 |     state: PadAdapterState,
    |     ^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/mod.rs:218:5
    |
218 |     flags: u32,
218 |     flags: u32,
    |     ^^^^^^^^^^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/mod.rs:219:5
    |
219 |     fill: char,
219 |     fill: char,
    |     ^^^^^^^^^^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/mod.rs:220:5
    |
    |
220 |     align: rt::v1::Alignment,
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/mod.rs:221:5
    |
221 |     width: Option<usize>,
221 |     width: Option<usize>,
    |     ^^^^^^^^^^^^^^^^^^^^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/mod.rs:222:5
    |
222 |     precision: Option<usize>,
222 |     precision: Option<usize>,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/fmt/mod.rs:224:5
    |
    |
224 |     buf: &'a mut (dyn Write + 'a),
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
    --> library/core/src/fmt/mod.rs:1179:5
     |
1179 |     fill: char,
1179 |     fill: char,
     |     ^^^^^^^^^^
     |
     = help: if it is meant to be private, remove the stability attribute
     = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
    --> library/core/src/fmt/mod.rs:1180:5
     |
1180 |     padding: usize,
1180 |     padding: usize,
     |     ^^^^^^^^^^^^^^
     |
     = help: if it is meant to be private, remove the stability attribute
     = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/hash/mod.rs:576:34
    |
    |
576 | pub struct BuildHasherDefault<H>(marker::PhantomData<H>);
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
 --> library/core/src/slice/memchr.rs:4:1
  |
4 | use crate::cmp;
4 | use crate::cmp;
  | ^^^^^^^^^^^^^^^
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public
error: import is private but has a stability attribute
 --> library/core/src/slice/memchr.rs:5:1
  |
5 | use crate::mem;
5 | use crate::mem;
  | ^^^^^^^^^^^^^^^
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public
error: constant is private but has a stability attribute
 --> library/core/src/slice/memchr.rs:7:1
  |
  |
7 | const LO_U64: u64 = 0x0101010101010101;
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public
error: constant is private but has a stability attribute
 --> library/core/src/slice/memchr.rs:8:1
  |
  |
8 | const HI_U64: u64 = 0x8080808080808080;
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public
error: constant is private but has a stability attribute
  --> library/core/src/slice/memchr.rs:11:1
   |
   |
11 | const LO_USIZE: usize = LO_U64 as usize;
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: constant is private but has a stability attribute
  --> library/core/src/slice/memchr.rs:12:1
   |
   |
12 | const HI_USIZE: usize = HI_U64 as usize;
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: constant is private but has a stability attribute
  --> library/core/src/slice/memchr.rs:13:1
   |
   |
13 | const USIZE_BYTES: usize = mem::size_of::<usize>();
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: function is private but has a stability attribute
  --> library/core/src/slice/memchr.rs:23:1
   |
   |
23 | / fn contains_zero_byte(x: usize) -> bool {
24 | |     x.wrapping_sub(LO_USIZE) & !x & HI_USIZE != 0
   | |_^
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: function is private but has a stability attribute
  --> library/core/src/slice/memchr.rs:35:1
   |
   |
35 | / fn repeat_byte(b: u8) -> usize {
36 | |     (b as usize) * (usize::MAX / 255)
   | |_^
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: function is private but has a stability attribute
  --> library/core/src/slice/memchr.rs:50:1
   |
   |
50 | / fn memchr_general_case(x: u8, text: &[u8]) -> Option<usize> {
51 | |     // Scan for a single byte value by reading two `usize` words at a time.
52 | |     //
53 | |     // Split `text` in three parts
...  |
90 | |     text[offset..].iter().position(|elt| *elt == x).map(|i| offset + i)
   | |_^
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: type alias is private but has a stability attribute
   --> library/core/src/slice/memchr.rs:103:5
    |
    |
103 |     type Chunk = usize;
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
  --> library/core/src/slice/iter.rs:67:5
   |
67 |     ptr: NonNull<T>,
67 |     ptr: NonNull<T>,
   |     ^^^^^^^^^^^^^^^
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
  --> library/core/src/slice/iter.rs:68:5
   |
   |
68 |     end: *const T, // If T is a ZST, this is actually ptr+len.  This encoding is picked so that
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
  --> library/core/src/slice/iter.rs:71:5
   |
   |
71 |     _marker: PhantomData<&'a T>,
   |
   = help: if it is meant to be private, remove the stability attribute
   = help: if it is meant to be private, remove the stability attribute
   = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/slice/iter.rs:186:5
    |
186 |     ptr: NonNull<T>,
186 |     ptr: NonNull<T>,
    |     ^^^^^^^^^^^^^^^
    |
    = help: if it is meant to be private, remove the stability attribute
    = help: or, if it is meant to be public, make it public
error: field is private but has a stability attribute
   --> library/core/src/slice/iter.rs:187:5
    |
    |
187 |     end: *mut T, // If T is a ZST, this is actually ptr+len.  This encoding is picked so that
    |
    = help: if it is meant to be private, remove the stability attribute

@camelid
Copy link
Member Author

camelid commented Jul 23, 2021

Ok, it seems like the issue is that definitions are inheriting stability from their parent. E.g., in this code:

#![stable(feature = "rust1", since = "1.0.0")]

#[stable(feature = "rust1", since = "1.0.0")]
pub struct MyStruct {
    my_field: u32,
}

MyStruct.my_field is inheriting MyStruct's stability attribute, which causes this error:

error: field is private but has a stability attribute
 --> foo.rs:8:5
  |
8 |     my_field: u32,
  |     ^^^^^^^^^^^^^
  |
  = help: if it is meant to be private, remove the stability attribute
  = help: or, if it is meant to be public, make it public

Removing both the crate-level stability attribute and the struct-level one causes the field error to disappear (although then it rightly errors because the crate and struct are public but don't have stability attributes). It seems like this might be a pre-existing bug in how stabilities are computed.

@camelid
Copy link
Member Author

camelid commented Jul 23, 2021

Ok, I fixed part of it: it's down from 3608 to 3300 errors 😅

I think some of the bugs might have been introduced in #71481.

@camelid
Copy link
Member Author

camelid commented Jul 23, 2021

It seems that some of the errors were due to bugs in the stability-checking code, but many of them (probably the vast majority) were because some items were private but should still inherit stability from their parent. I'm pretty sure that the stability of a private item is irrelevant because it can't be accessed outside the crate, but I'd rather not mess with the existing stability code too much since it's a bit hard to understand what's going on. So, I think a better approach, at least for now, is to just look at the item's actual stability attributes (not what it's inherited from its parent). This approach seems promising: I'm down to 53 errors in core! Next, I need to see if they are false positives or actually correct.

@camelid
Copy link
Member Author

camelid commented Jul 23, 2021

A lot of the errors seem to be correct! There are a few false positives; so far, I've seen a couple cases where derived impls trigger the error. I'm not sure why it only happens in a few cases.

@camelid
Copy link
Member Author

camelid commented Jul 23, 2021

I'm pretty sure that the stability of a private item is irrelevant because it can't be accessed outside the crate, but I'd rather not mess with the existing stability code too much since it's a bit hard to understand what's going on. So, I think a better approach, at least for now, is to just look at the item's actual stability attributes (not what it's inherited from its parent).

Hmm, I wonder if a better approach would be to not inherit stability for private items...

@camelid
Copy link
Member Author

camelid commented Jul 23, 2021

A lot of the errors seem to be correct! There are a few false positives; so far, I've seen a couple cases where derived impls trigger the error. I'm not sure why it only happens in a few cases.

Actually those weren't false positives: the derives were on a private struct with stability attributes.

@camelid
Copy link
Member Author

camelid commented Jul 23, 2021

Unfortunately, now that I've removed the core stability attributes that were on private items, I'm getting thousands of errors when compiling stage0 core, this time that the items are missing stability attributes. It seems that the stability-checker thinks that private items need attributes?

@jyn514
Copy link
Member

jyn514 commented Jul 23, 2021

@camelid can you post one of the errors?

@camelid
Copy link
Member Author

camelid commented Jul 24, 2021

Sure, here are some samples:

Sample 1 (errors from the start of the output)
error: trait has missing stability attribute
  --> library/core/src/ptr/metadata.rs:51:1
   |
51 | / pub trait Pointee {
52 | |     /// The type for metadata in pointers and references to `Self`.
53 | |     #[lang = "metadata_type"]
54 | |     // NOTE: Keep trait bounds in `static_assert_expected_bounds_for_metadata`
...  |
57 | |     type Metadata: Copy + Send + Sync + Ord + Hash + Unpin;
58 | | }
   | |_^

error: function has missing stability attribute
  --> library/core/src/ptr/metadata.rs:91:1
   |
91 | / pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata {
92 | |     // SAFETY: Accessing the value from the `PtrRepr` union is safe since *const T
93 | |     // and PtrComponents<T> have the same memory layouts. Only std can make this
94 | |     // guarantee.
95 | |     unsafe { PtrRepr { const_ptr: ptr }.components.metadata }
96 | | }
   | |_^

error: struct has missing stability attribute
   --> library/core/src/ptr/metadata.rs:176:1
    |
176 | / pub struct DynMetadata<Dyn: ?Sized> {
177 | |     vtable_ptr: &'static VTable,
178 | |     phantom: crate::marker::PhantomData<Dyn>,
179 | | }
    | |_^

error: implementation has missing stability attribute
   --> library/core/src/ptr/metadata.rs:213:1
    |
213 | unsafe impl<Dyn: ?Sized> Send for DynMetadata<Dyn> {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: implementation has missing stability attribute
   --> library/core/src/ptr/metadata.rs:214:1
    |
214 | unsafe impl<Dyn: ?Sized> Sync for DynMetadata<Dyn> {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: implementation has missing stability attribute
   --> library/core/src/ptr/metadata.rs:216:1
    |
216 | / impl<Dyn: ?Sized> fmt::Debug for DynMetadata<Dyn> {
217 | |     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
218 | |         f.debug_tuple("DynMetadata").field(&(self.vtable_ptr as *const VTable)).finish()
219 | |     }
220 | | }
    | |_^

error: implementation has missing stability attribute
   --> library/core/src/ptr/metadata.rs:224:1
    |
224 | impl<Dyn: ?Sized> Unpin for DynMetadata<Dyn> {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: implementation has missing stability attribute
   --> library/core/src/ptr/metadata.rs:226:1
    |
226 | impl<Dyn: ?Sized> Copy for DynMetadata<Dyn> {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: implementation has missing stability attribute
   --> library/core/src/ptr/metadata.rs:228:1
    |
228 | / impl<Dyn: ?Sized> Clone for DynMetadata<Dyn> {
229 | |     #[inline]
230 | |     fn clone(&self) -> Self {
231 | |         *self
232 | |     }
233 | | }
    | |_^

error: implementation has missing stability attribute
   --> library/core/src/ptr/metadata.rs:235:1
    |
235 | impl<Dyn: ?Sized> Eq for DynMetadata<Dyn> {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: implementation has missing stability attribute
   --> library/core/src/ptr/metadata.rs:237:1
    |
237 | / impl<Dyn: ?Sized> PartialEq for DynMetadata<Dyn> {
238 | |     #[inline]
239 | |     fn eq(&self, other: &Self) -> bool {
240 | |         crate::ptr::eq::<VTable>(self.vtable_ptr, other.vtable_ptr)
241 | |     }
242 | | }
    | |_^

error: implementation has missing stability attribute
   --> library/core/src/ptr/metadata.rs:244:1
    |
244 | / impl<Dyn: ?Sized> Ord for DynMetadata<Dyn> {
245 | |     #[inline]
246 | |     fn cmp(&self, other: &Self) -> crate::cmp::Ordering {
247 | |         (self.vtable_ptr as *const VTable).cmp(&(other.vtable_ptr as *const VTable))
248 | |     }
249 | | }
    | |_^

error: implementation has missing stability attribute
   --> library/core/src/ptr/metadata.rs:251:1
    |
251 | / impl<Dyn: ?Sized> PartialOrd for DynMetadata<Dyn> {
252 | |     #[inline]
253 | |     fn partial_cmp(&self, other: &Self) -> Option<crate::cmp::Ordering> {
254 | |         Some(self.cmp(other))
255 | |     }
256 | | }
    | |_^
Sample 2 (errors from the end of the output)
error: implementation has missing stability attribute
   --> library/core/src/../../stdarch/crates/core_arch/src/macros.rs:88:18
    |
82  | /  macro_rules! types {
83  | |      ($(
84  | |          $(#[$doc:meta])*
85  | |          pub struct $name:ident($($fields:tt)*);
...   |
88  | |          #[derive(Copy, Clone, Debug)]
    | |                   ^^^^ in this macro invocation (#2)
...   |
93  | |      )*)
94  | |  }
    | |__- in this expansion of `types!` (#1)
    | 
   ::: library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs:8:1
    |
8   |  / types! {
9   |  |     /// 128-bit wide integer vector type, x86-specific
10  |  |     ///
11  |  |     /// This type is the same as the `__m128i` type defined by Intel,
...    |
329 |  |     );
330 |  | }
    |  |_- in this macro invocation (#1)
    | 
   ::: library/core/src/marker.rs:393:1
    |
393 | /  pub macro Copy($item:item) {
394 | |      /* compiler built-in */
395 | |  }
    | |__- in this expansion of `#[derive(Copy)]` (#2)

error: implementation has missing stability attribute
   --> library/core/src/../../stdarch/crates/core_arch/src/macros.rs:88:24
    |
82  | /   macro_rules! types {
83  | |       ($(
84  | |           $(#[$doc:meta])*
85  | |           pub struct $name:ident($($fields:tt)*);
...   |
88  | |           #[derive(Copy, Clone, Debug)]
    | |                          ^^^^^ in this macro invocation (#2)
...   |
93  | |       )*)
94  | |   }
    | |___- in this expansion of `types!` (#1)
    | 
   ::: library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs:8:1
    |
8   |   / types! {
9   |   |     /// 128-bit wide integer vector type, x86-specific
10  |   |     ///
11  |   |     /// This type is the same as the `__m128i` type defined by Intel,
...     |
329 |   |     );
330 |   | }
    |   |_- in this macro invocation (#1)
    | 
   ::: library/core/src/clone.rs:139:1
    |
139 | /   pub macro Clone($item:item) {
140 | |       /* compiler built-in */
141 | |   }
    | |___- in this expansion of `#[derive(Clone)]` (#2)

error: implementation has missing stability attribute
   --> library/core/src/../../stdarch/crates/core_arch/src/macros.rs:88:31
    |
82  | /  macro_rules! types {
83  | |      ($(
84  | |          $(#[$doc:meta])*
85  | |          pub struct $name:ident($($fields:tt)*);
...   |
88  | |          #[derive(Copy, Clone, Debug)]
    | |                                ^^^^^ in this macro invocation (#2)
...   |
93  | |      )*)
94  | |  }
    | |__- in this expansion of `types!` (#1)
    | 
   ::: library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs:8:1
    |
8   |  / types! {
9   |  |     /// 128-bit wide integer vector type, x86-specific
10  |  |     ///
11  |  |     /// This type is the same as the `__m128i` type defined by Intel,
...    |
329 |  |     );
330 |  | }
    |  |_- in this macro invocation (#1)
    | 
   ::: library/core/src/fmt/mod.rs:618:5
    |
618 | /      pub macro Debug($item:item) {
619 | |          /* compiler built-in */
620 | |      }
    | |______- in this expansion of `#[derive(Debug)]` (#2)

error: implementation has missing stability attribute
   --> library/core/src/../../stdarch/crates/core_arch/src/macros.rs:88:18
    |
82  | /  macro_rules! types {
83  | |      ($(
84  | |          $(#[$doc:meta])*
85  | |          pub struct $name:ident($($fields:tt)*);
...   |
88  | |          #[derive(Copy, Clone, Debug)]
    | |                   ^^^^ in this macro invocation (#2)
...   |
93  | |      )*)
94  | |  }
    | |__- in this expansion of `types!` (#1)
    | 
   ::: library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs:8:1
    |
8   |  / types! {
9   |  |     /// 128-bit wide integer vector type, x86-specific
10  |  |     ///
11  |  |     /// This type is the same as the `__m128i` type defined by Intel,
...    |
329 |  |     );
330 |  | }
    |  |_- in this macro invocation (#1)
    | 
   ::: library/core/src/marker.rs:393:1
    |
393 | /  pub macro Copy($item:item) {
394 | |      /* compiler built-in */
395 | |  }
    | |__- in this expansion of `#[derive(Copy)]` (#2)

error: implementation has missing stability attribute
   --> library/core/src/../../stdarch/crates/core_arch/src/macros.rs:88:24
    |
82  | /   macro_rules! types {
83  | |       ($(
84  | |           $(#[$doc:meta])*
85  | |           pub struct $name:ident($($fields:tt)*);
...   |
88  | |           #[derive(Copy, Clone, Debug)]
    | |                          ^^^^^ in this macro invocation (#2)
...   |
93  | |       )*)
94  | |   }
    | |___- in this expansion of `types!` (#1)
    | 
   ::: library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs:8:1
    |
8   |   / types! {
9   |   |     /// 128-bit wide integer vector type, x86-specific
10  |   |     ///
11  |   |     /// This type is the same as the `__m128i` type defined by Intel,
...     |
329 |   |     );
330 |   | }
    |   |_- in this macro invocation (#1)
    | 
   ::: library/core/src/clone.rs:139:1
    |
139 | /   pub macro Clone($item:item) {
140 | |       /* compiler built-in */
141 | |   }
    | |___- in this expansion of `#[derive(Clone)]` (#2)

error: implementation has missing stability attribute
   --> library/core/src/../../stdarch/crates/core_arch/src/macros.rs:88:31
    |
82  | /  macro_rules! types {
83  | |      ($(
84  | |          $(#[$doc:meta])*
85  | |          pub struct $name:ident($($fields:tt)*);
...   |
88  | |          #[derive(Copy, Clone, Debug)]
    | |                                ^^^^^ in this macro invocation (#2)
...   |
93  | |      )*)
94  | |  }
    | |__- in this expansion of `types!` (#1)
    | 
   ::: library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs:8:1
    |
8   |  / types! {
9   |  |     /// 128-bit wide integer vector type, x86-specific
10  |  |     ///
11  |  |     /// This type is the same as the `__m128i` type defined by Intel,
...    |
329 |  |     );
330 |  | }
    |  |_- in this macro invocation (#1)
    | 
   ::: library/core/src/fmt/mod.rs:618:5
    |
618 | /      pub macro Debug($item:item) {
619 | |          /* compiler built-in */
620 | |      }
    | |______- in this expansion of `#[derive(Debug)]` (#2)

error: associated type has missing stability attribute
  --> library/core/src/ptr/metadata.rs:57:5
   |
57 |     type Metadata: Copy + Send + Sync + Ord + Hash + Unpin;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: associated function has missing stability attribute
   --> library/core/src/ptr/metadata.rs:194:5
    |
194 | /     pub fn size_of(self) -> usize {
195 | |         self.vtable_ptr.size_of
196 | |     }
    | |_____^

error: associated function has missing stability attribute
   --> library/core/src/ptr/metadata.rs:200:5
    |
200 | /     pub fn align_of(self) -> usize {
201 | |         self.vtable_ptr.align_of
202 | |     }
    | |_____^

error: associated function has missing stability attribute
   --> library/core/src/ptr/metadata.rs:206:5
    |
206 | /     pub fn layout(self) -> crate::alloc::Layout {
207 | |         // SAFETY: the compiler emitted this vtable for a concrete Rust type which
208 | |         // is known to have a valid layout. Same rationale as in `Layout::for_value`.
209 | |         unsafe { crate::alloc::Layout::from_size_align_unchecked(self.size_of(), self.align_of()) }
210 | |     }
    | |_____^

error: aborting due to 3847 previous errors

error: could not compile `core`

And here's a diff showing what stability attributes I deleted:

Diff
diff --git a/library/core/src/future/future.rs b/library/core/src/future/future.rs
index 15952c6806f..bffc5c430f7 100644
--- a/library/core/src/future/future.rs
+++ b/library/core/src/future/future.rs
@@ -1,5 +1,3 @@
-#![stable(feature = "futures_api", since = "1.36.0")]
-
 use crate::marker::Unpin;
 use crate::ops;
 use crate::pin::Pin;
diff --git a/library/core/src/hash/sip.rs b/library/core/src/hash/sip.rs
index 6178b0af137..ac7be9b390a 100644
--- a/library/core/src/hash/sip.rs
+++ b/library/core/src/hash/sip.rs
@@ -27,11 +27,6 @@ pub struct SipHasher13 {
 /// An implementation of SipHash 2-4.
 ///
 /// See: <https://131002.net/siphash/>
-#[unstable(feature = "hashmap_internals", issue = "none")]
-#[rustc_deprecated(
-    since = "1.13.0",
-    reason = "use `std::collections::hash_map::DefaultHasher` instead"
-)]
 #[derive(Debug, Clone, Default)]
 struct SipHasher24 {
     hasher: Hasher<Sip24Rounds>,
diff --git a/library/core/src/iter/adapters/mod.rs b/library/core/src/iter/adapters/mod.rs
index a3fbf4d9c38..8f315472085 100644
--- a/library/core/src/iter/adapters/mod.rs
+++ b/library/core/src/iter/adapters/mod.rs
@@ -196,7 +196,6 @@ fn ok<B, T>(mut f: impl FnMut(B, T) -> B) -> impl FnMut(B, T) -> Result<B, !> {
     }
 }
 
-#[unstable(issue = "none", feature = "inplace_iteration")]
 unsafe impl<S: Iterator, I, E> SourceIter for ResultShunt<'_, I, E>
 where
     I: SourceIter<Source = S>,
@@ -213,7 +212,6 @@ unsafe fn as_inner(&mut self) -> &mut S {
 // SAFETY: ResultShunt::next calls I::find, which has to advance `iter` in order to
 // return `Some(_)`. Since `iter` has type `I: InPlaceIterable` it's guaranteed that
 // at least one item will be moved out from the underlying source.
-#[unstable(issue = "none", feature = "inplace_iteration")]
 unsafe impl<I, T, E> InPlaceIterable for ResultShunt<'_, I, E> where
     I: Iterator<Item = Result<T, E>> + InPlaceIterable
 {
diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
index 540cdf124ee..f283f285e1f 100644
--- a/library/core/src/lib.rs
+++ b/library/core/src/lib.rs
@@ -313,7 +313,6 @@ pub mod assert_matches {
 // FIXME: This annotation should be moved into rust-lang/stdarch after clashing_extern_declarations is
 // merged. It currently cannot because bootstrap fails as the lint hasn't been defined yet.
 #[allow(clashing_extern_declarations)]
-#[unstable(feature = "stdsimd", issue = "48556")]
 mod core_arch;
 
 #[doc = include_str!("../../stdarch/crates/core_arch/src/core_arch_docs.md")]
diff --git a/library/core/src/ops/mod.rs b/library/core/src/ops/mod.rs
index 85e04740d96..f9fe121bbc5 100644
--- a/library/core/src/ops/mod.rs
+++ b/library/core/src/ops/mod.rs
@@ -187,7 +187,6 @@
 #[unstable(feature = "try_trait_v2", issue = "84277")]
 pub use self::try_trait::Try;
 
-#[unstable(feature = "try_trait_transition", reason = "for bootstrap", issue = "none")]
 pub(crate) use self::try_trait::Try as TryV2;
 
 #[unstable(feature = "generator_trait", issue = "43122")]
diff --git a/library/core/src/ptr/metadata.rs b/library/core/src/ptr/metadata.rs
index 287ae69acd1..bb7652a3526 100644
--- a/library/core/src/ptr/metadata.rs
+++ b/library/core/src/ptr/metadata.rs
@@ -1,5 +1,3 @@
-#![unstable(feature = "ptr_metadata", issue = "81513")]
-
 use crate::fmt;
 use crate::hash::{Hash, Hasher};
 
diff --git a/library/core/src/slice/iter.rs b/library/core/src/slice/iter.rs
index 5cbc6343e3a..5dfa1dc3441 100644
--- a/library/core/src/slice/iter.rs
+++ b/library/core/src/slice/iter.rs
@@ -880,7 +880,6 @@ fn next_back(&mut self) -> Option<&'a [T]> {
     }
 }
 
-#[stable(feature = "slice_rsplit", since = "1.27.0")]
 impl<'a, T, P> SplitIter for RSplit<'a, T, P>
 where
     P: FnMut(&T) -> bool,
@@ -936,7 +935,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
     }
 }
 
-#[stable(feature = "slice_rsplit", since = "1.27.0")]
 impl<'a, T, P> SplitIter for RSplitMut<'a, T, P>
 where
     P: FnMut(&T) -> bool,
diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs
index de25c984abf..5087bf8ae89 100644
--- a/library/core/src/slice/mod.rs
+++ b/library/core/src/slice/mod.rs
@@ -1582,7 +1582,6 @@ pub fn split_at_mut(&mut self, mid: usize) -> (&mut [T], &mut [T]) {
     ///     assert_eq!(right, []);
     /// }
     /// ```
-    #[unstable(feature = "slice_split_at_unchecked", reason = "new API", issue = "76014")]
     #[inline]
     unsafe fn split_at_unchecked(&self, mid: usize) -> (&[T], &[T]) {
         // SAFETY: Caller has to check that `0 <= mid <= self.len()`
@@ -1622,7 +1621,6 @@ unsafe fn split_at_unchecked(&self, mid: usize) -> (&[T], &[T]) {
     /// }
     /// assert_eq!(v, [1, 2, 3, 4, 5, 6]);
     /// ```
-    #[unstable(feature = "slice_split_at_unchecked", reason = "new API", issue = "76014")]
     #[inline]
     unsafe fn split_at_mut_unchecked(&mut self, mid: usize) -> (&mut [T], &mut [T]) {
         let len = self.len();
diff --git a/library/core/src/str/validations.rs b/library/core/src/str/validations.rs
index 373a8212425..56d8506d9a4 100644
--- a/library/core/src/str/validations.rs
+++ b/library/core/src/str/validations.rs
@@ -250,9 +250,8 @@ pub(super) fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> {
 ];
 
 /// Given a first byte, determines how many bytes are in this UTF-8 character.
-#[unstable(feature = "str_internals", issue = "none")]
 #[inline]
-pub fn utf8_char_width(b: u8) -> usize {
+pub(crate) fn utf8_char_width(b: u8) -> usize {
     UTF8_CHAR_WIDTH[b as usize] as usize
 }
 
diff --git a/library/core/src/task/poll.rs b/library/core/src/task/poll.rs
index fc0a4e74797..5cc050e97be 100644
--- a/library/core/src/task/poll.rs
+++ b/library/core/src/task/poll.rs
@@ -1,5 +1,3 @@
-#![stable(feature = "futures_api", since = "1.36.0")]
-
 use crate::convert;
 use crate::ops::{self, ControlFlow};
 use crate::result::Result;
diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs
index b775e022a54..f6740ea928c 100644
--- a/library/core/src/task/wake.rs
+++ b/library/core/src/task/wake.rs
@@ -1,5 +1,3 @@
-#![stable(feature = "futures_api", since = "1.36.0")]
-
 use crate::fmt;
 use crate::marker::{PhantomData, Unpin};

@bors
Copy link
Contributor

bors commented Jul 25, 2021

☔ The latest upstream changes (presumably #83723) made this pull request unmergeable. Please resolve the merge conflicts.

@jyn514
Copy link
Member

jyn514 commented Jul 26, 2021

You said:

I'm getting thousands of errors when compiling stage0 core, this time that the items are missing stability attributes. It seems that the stability-checker thinks that private items need attributes?

But all the errors are on public items. Maybe the problem is that some of the items are not actually private, because they're re-exported somewhere? If they're not private, then it seems worth making a cleanup PR to remove pub.

@camelid
Copy link
Member Author

camelid commented Nov 17, 2021

I'm not sure why this change doesn't work correctly, and I probably won't be able to look into it soon, so closing for now. I may try again in the future if someone else doesn't do it by then.

@camelid camelid closed this Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-stability Area: issues related to #[stable] and #[unstable] attributes themselves. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rustc should warn if you have a stability attribute on a non-public item
9 participants