Stability checker doesn't recurse down reexports properly

44547d0
Opened by Manish Goregaokar at 2024-12-14 23:21:52

stability.rs:

#![crate_type="lib"]
#![feature(staged_api)]

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

mod foo {
   #[derive(Copy)]
   pub struct Bar;
}

#[unstable(feature="foobar")]
pub mod foobar {
    pub use super::foo::*;
}

test.rs:

extern crate stability;
use stability::foobar::Bar;

fn main(){
   let x = Bar; //~ ERROR use of unmarked library feature
}

#[unstable] is inherited through mods (only #[stable] isn't inherited). However, in this particular case, the inheritance doesn't cross the reexport.

A more concrete example is the hash_state module. Chris fixed the stability of its items in this PR, however the module itself was private and reexported as an #[unstable] module before the PR. Yet, usage of items within the hash_state module were broken before the PR.

This seems wrong, #[unstable] (and the others, except #[stable]) should be inherited down pub uses.

cc @brson

  1. stability.rs:

    #![crate_type="lib"]
    #![feature(staged_api)]
    
    #![staged_api]
    #![stable(feature = "stability", since = "1.0.0")]
    
    mod foo {
       #[derive(Copy)]
       pub struct Bar;
    }
    
    #[unstable(feature="foobar")]
    pub mod foobar {
        pub use super::foo::*;
    }
    

    test.rs:

    extern crate stability;
    use stability::foobar::Bar;
    
    fn main(){
       let x = Bar; //~ ERROR use of unmarked library feature
    }
    

    #[unstable] is inherited through mods (only #[stable] isn't inherited). However, in this particular case, the inheritance doesn't cross the reexport.

    A more concrete example is the hash_state module. Chris fixed the stability of its items in this PR, however the module itself was private and reexported as an #[unstable] module before the PR. Yet, usage of items within the hash_state module were broken before the PR.

    This seems wrong, #[unstable] (and the others, except #[stable]) should be inherited down pub uses.

    cc @brson

    Martin Nordholts at 2023-11-21 07:11:03

  2. Traige: staged_api is now only available to the compiler, so I was unable to come up with a quick test case.

    Steve Klabnik at 2016-03-04 16:44:50

  3. Still an issue. (Also, staged_api is still available to everyone on unstable, it just uses misleading error message to hide the truth.)

    Vadim Petrochenkov at 2016-03-04 17:03:16

  4. Ahhh I thought I was using unstable, I guess I wasn't.

    On Mar 4, 2016, 12:03 -0500, Vadim Petrochenkovnotifications@github.com, wrote:

    Still an issue. (Also,staged_apiis still available to everyone on unstable, it just uses misleading error message to hide the truth.)

    — Reply to this email directly orview it on GitHub(https://github.com/rust-lang/rust/issues/21905#issuecomment-192358629).

    Steve Klabnik at 2016-03-04 18:15:57

  5. Triage: not aware of any changes at all here. There's not a ton of pressure to fix this.

    Steve Klabnik at 2019-03-11 17:28:29