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

Make #[rustc_deprecated] (and #[deprecated]) on re-exports either work properly or cause a compiler error #82123

Closed
bstrie opened this issue Feb 15, 2021 · 2 comments
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@bstrie
Copy link
Contributor

bstrie commented Feb 15, 2021

#82080 laid undetected for years due to the silent inability of #[rustc_deprecated] to apply properly to re-exports. For now people simply have to remember not to use it with re-exports, but it would be nice if it either 1) worked as expected, or at least 2) caused a compiler error so that it couldn't pass silently.

Open question: should the chosen behavior extend to the stable #[deprecated] attribute as well? If made to work on re-exports this will be a slight increase to the API surface area, but if made into an error it could potentially be a breaking change (although easily understood and justified as a bugfix).

Test case for #[deprecated]:

mod foo {
    #[deprecated]
    pub use crate::bar::Bar;
}

mod bar {
    pub struct Bar;
}

fn main() {
    let _ = foo::Bar; // should warn
    let _ = bar::Bar; // should not warn
}

Once (if) this is fixed, then we should go through the stdlib and use this to replace all of the wrapper functions/type aliases that are currently used to trigger deprecated lints (e.g. the items in #82122 ). Better to have a deprecated path than a full-fledged item and symbol.

@bstrie bstrie added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Feb 15, 2021
@bstrie bstrie changed the title Make #[rustc_deprecated] on re-exports either work properly or cause a compiler error Make #[rustc_deprecated] (and #[deprecated]) on re-exports either work properly or cause a compiler error Feb 15, 2021
@jyn514 jyn514 added T-libs Relevant to the library team, which will review and decide on the PR/issue. and removed T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Feb 15, 2021
@Pratyush
Copy link
Contributor

Relevant: #30827

@bstrie
Copy link
Contributor Author

bstrie commented Feb 22, 2021

Good catch, I'll close this as a duplicate.

@bstrie bstrie closed this as completed Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants