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

Closed
rprichard opened this issue Apr 1, 2015 · 4 comments
Closed

Stability attributes ignored on use declarations #23937

rprichard opened this issue Apr 1, 2015 · 4 comments
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-stability Area: `#[stable]`, `#[unstable]` etc. C-bug Category: This is a bug. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@rprichard
Copy link
Contributor

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 steveklabnik added the A-attributes Area: Attributes (`#[…]`, `#![…]`) label Apr 3, 2015
@steveklabnik
Copy link
Member

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
Copy link
Contributor

@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
Copy link
Member

Ah, my bad.

@brson brson added P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. I-wrong labels Apr 4, 2017
@Mark-Simulacrum Mark-Simulacrum added A-stability Area: `#[stable]`, `#[unstable]` etc. C-bug Category: This is a bug. and removed C-enhancement Category: An issue proposing an enhancement or a PR with one. I-wrong labels Jul 22, 2017
@bstrie
Copy link
Contributor

bstrie commented Feb 22, 2021

Closing in favor of #30827.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-stability Area: `#[stable]`, `#[unstable]` etc. C-bug Category: This is a bug. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants