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

Stability attributes ignored on use declarations #23937

Open
rprichard opened this Issue Apr 1, 2015 · 3 comments

Comments

Projects
None yet
5 participants
@rprichard
Copy link
Contributor

rprichard commented Apr 1, 2015

std::collections reexports collections::linked_list, which has this alias:

#[deprecated(since = "1.0.0", reason = "renamed to LinkedList")]
#[unstable(feature = "collections")]
pub use LinkedList as DList;

collections::linked_list and collections::linked_list::LinkedList are stable, so presumably the intent of these stability attributes was to stop stable code from using the DList name, but it doesn't work. This compiles fine:

use std::collections::linked_list::DList;
fn main() {
    DList::<i32>::new();
}

AFAICT, stability attributes don't affect pub use declarations.

(Aside: AFAICT, stability attributes also don't affect impls either, but maybe I'm missing something? The standard library has stability attributes on many of its impls.)

@steveklabnik

This comment has been minimized.

Copy link
Member

steveklabnik commented Oct 29, 2015

This appears to be fixed.

#![feature(staged_api)]
#![staged_api]

#[stable]
struct Foo;

#[deprecated(since = "1.0.0", reason = "renamed to LinkedList")]
#[unstable(feature = "collections")]
pub use Foo as Bar;

fn main() {
    Bar::new();
}

gives

hello.rs:9:9: 9:19 error: `Foo` is private, and cannot be reexported [E0364]
hello.rs:9 pub use Foo as Bar;
                   ^~~~~~~~~~
hello.rs:9:9: 9:19 help: run `rustc --explain E0364` to see a detailed explanation
hello.rs:9:9: 9:19 note: Consider marking `Foo` as `pub` in the imported module
hello.rs:9 pub use Foo as Bar;
                   ^~~~~~~~~~
@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Oct 29, 2015

@steveklabnik
This is not fixed.
Correct example is:

#![feature(staged_api)]
#![staged_api]

#[stable(feature = "rust1", since = "1.0.0")]
pub struct Foo;

#[deprecated(since = "1.0.0", reason = "renamed to LinkedList")]
#[unstable(feature = "collections", issue = "0")]
pub use Foo as Bar;

fn main() {
    let bar = Bar;
}

Use of Bar should give a deprecation warning / stability error, but it doesn't - stability/deprecation attributes on reexports are ignored.

@steveklabnik steveklabnik reopened this Oct 29, 2015

@steveklabnik

This comment has been minimized.

Copy link
Member

steveklabnik commented Oct 29, 2015

Ah, my bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.