Uh oh!
There was an error while loading. Please reload this page.
introduce implied_by in #[unstable] attribute - #99212
Conversation
rust-highfive
commented
Jul 13, 2022
(rust-highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
I would have made these translatable given that's what I'm doing everywhere else but I have a patch coming for rustc_passes in the next few days so it can wait for that. :)
afccf1c to
cf68322CompareCAD97
commented
Jul 13, 2022
What's the behavior of The former is useful for feature subsetting while still unstable, e.g. |
davidtwco
commented
Jul 14, 2022
As for |
This comment was marked as resolved.
This comment was marked as resolved.
cf68322 to
51c89dcCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Change some regular comments into documentation comments. Signed-off-by: David Wood <david.wood@huawei.com>
When an unexpected meta item is provided to `#[stable]`, the diagnostic lists "since" and "note" as expected meta-items, however the surrounding code actually expects "feature" and "since". Signed-off-by: David Wood <david.wood@huawei.com>
51c89dc to
4911697CompareUh oh!
There was an error while loading. Please reload this page.
michaelwoerister
commented
Jul 20, 2022
The implementation looks good to me. Thanks, @davidtwco! Maybe someone from @rust-lang/libs wants to take another look to make sure that this PR actually implements the desired behavior? Otherwise, feel free to r=me. |
michaelwoerister
commented
Jul 20, 2022
Adding a check like this sounds like a good idea. Here maybe?: https://github.com/rust-lang/rust/pull/99212/files#diff-5f57ad10e1bdde3d046b258d390fd2ecc6f1511158aa130cebb72093da16ef29R955-R958 |
m-ou-se
commented
Jul 20, 2022
cc @rust-lang/libs-api |
If part of a feature is stabilized and a new feature is added for the remaining parts, then the `implied_by` attribute can be used to indicate which now-stable feature previously contained a item. If the now-stable feature is still active (if the user has only just updated rustc, for example) then there will not be an stability error for uses of the item from the implied feature. Signed-off-by: David Wood <david.wood@huawei.com>
Adds a simple helper function to the `SourceMap` for extending a `Span` to encompass the entire line it is on - useful for suggestions where removing a line is the suggested action. Signed-off-by: David Wood <david.wood@huawei.com>
Improves the diagnostic when a feature attribute is specified unnecessarily but the feature implies another (i.e. it was partially stabilized) to refer to the implied feature. Signed-off-by: David Wood <david.wood@huawei.com>
4911697 to
675e618Comparedavidtwco
commented
Jul 20, 2022
Added! |
675e618 to
884e453Comparem-ou-se
commented
Jul 20, 2022
I think this is a useful improvement, but there's one thing that concerns me. It's important that I don't think that's a blocker here. Improving ergonomics is good. But something to keep in mind for #[unstable] related changes in general. |
michaelwoerister
commented
Jul 20, 2022
OK, r=me with the test fixed. |
Add a check confirming that features referenced in `implied_by` meta items actually exist. Signed-off-by: David Wood <david.wood@huawei.com>
884e453 to
e587299Comparedavidtwco
commented
Jul 20, 2022
@bors r=michaelwoerister |
bors
commented
Jul 20, 2022
…askrgr Rollup of 9 pull requests Successful merges: - rust-lang#99212 (introduce `implied_by` in `#[unstable]` attribute) - rust-lang#99352 (Use `typeck_results` to avoid duplicate `ast_ty_to_ty` call) - rust-lang#99355 (better error for bad depth parameter on macro metavar expr) - rust-lang#99480 (Diagnostic width span is not added when '0$' is used as width in format strings) - rust-lang#99488 (compiletest: Allow using revisions with debuginfo tests.) - rust-lang#99489 (rustdoc UI fixes) - rust-lang#99508 (Avoid `Symbol` to `String` conversions) - rust-lang#99510 (adapt assembly/static-relocation-model test for LLVM change) - rust-lang#99516 (Use new tracking issue for proc_macro::tracked_*.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
pnkfelix
commented
Jul 27, 2022
Hey @davidtwco , is there any chance that this PR was the cause of the performance regression reported in rollup PR #99520? You can see my line of reasoning about why I thought it might be, over in zulip. |
davidtwco
commented
Jul 28, 2022
It's possible because of some additions to the cross-crate metadata. I've had another look at the changes and can't think of any ways to do less work that it currently does (it should just be writing a |
yaahc
commented
Jul 28, 2022
I don't think we've landed any PRs yet that need this, only #99573 which is still open and has another path to landing that we can use instead, so if there are perf issues with the impl as is and y'all feel like pumping the breaks that should be okay on our side for now at least. |
Original message: Rollup merge of rust-lang#99212 - davidtwco:partial-stability-implies, r=michaelwoerister introduce `implied_by` in `#[unstable]` attribute Requested by the library team [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/better.20support.20for.20partial.20stabilizations/near/285581519). If part of a feature is stabilized and a new feature is added for the remaining parts, then the `implied_by` meta-item can be added to `#[unstable]` to indicate which now-stable feature was used previously. ```diagnostic error: the feature `foo` has been partially stabilized since 1.62.0 and is succeeded by the feature `foobar` --> $DIR/stability-attribute-implies-using-unstable.rs:3:12 | LL | #![feature(foo)] | ^^^ | note: the lint level is defined here --> $DIR/stability-attribute-implies-using-stable.rs:2:9 | LL | #![deny(stable_features)] | ^^^^^^^^^^^^^^^ help: if you are using features which are still unstable, change to using `foobar` | LL | #![feature(foobar)] | ~~~~~~ help: if you are using features which are now stable, remove this line | LL - #![feature(foo)] | ``` When a `#![feature(..)]` attribute still exists for the now-stable attribute, then there this has two effects: - There will not be an stability error for uses of items from the implied feature which are still unstable (until the `#![feature(..)]` is removed or updated to the new feature). - There will be an improved diagnostic for the remaining use of the feature attribute for the now-stable feature. ```rust /// If part of a feature is stabilized and a new feature is added for the remaining parts, /// then the `implied_by` attribute is used to indicate which now-stable feature previously /// contained a item. /// /// ```pseudo-Rust /// #[unstable(feature = "foo", issue = "...")] /// fn foo() {} /// #[unstable(feature = "foo", issue = "...")] /// fn foobar() {} /// ``` /// /// ...becomes... /// /// ```pseudo-Rust /// #[stable(feature = "foo", since = "1.XX.X")] /// fn foo() {} /// #[unstable(feature = "foobar", issue = "...", implied_by = "foo")] /// fn foobar() {} /// ``` ``` In the Zulip discussion, this was envisioned as `implies` on `#[stable]` but I went with `implied_by` on `#[unstable]` because it means that only the unstable attribute needs to be changed in future, not the new stable attribute, which seems less error-prone. It also isn't particularly feasible for me to detect whether items from the implied feature are used and then only suggest updating _or_ removing the `#![feature(..)]` as appropriate, so I always do both. There's some new information in the cross-crate metadata as a result of this change, that's a little unfortunate, but without requiring that the `#[unstable]` and `#[stable]` attributes both contain the implication information, it's necessary: ```rust /// This mapping is necessary unless both the `#[stable]` and `#[unstable]` attributes should /// specify their implications (both `implies` and `implied_by`). If only one of the two /// attributes do (as in the current implementation, `implied_by` in `#[unstable]`), then this /// mapping is necessary for diagnostics. When a "unnecessary feature attribute" error is /// reported, only the `#[stable]` attribute information is available, so the map is necessary /// to know that the feature implies another feature. If it were reversed, and the `#[stable]` /// attribute had an `implies` meta item, then a map would be necessary when avoiding a "use of /// unstable feature" error for a feature that was implied. ``` I also change some comments to documentation comments in the compiler, add a helper for going from a `Span` to a `Span` for the entire line, and fix a incorrect part of the pre-existing stability attribute diagnostics. cc `@yaahc`
…ercote passes: load `defined_lib_features` query less Hopefully addresses the perf regressions from rust-lang#99212 (see rust-lang#99905). Re-structure the stability checks for library features to avoid calling `defined_lib_features` for any more crates than necessary for each of the implications or local feature attributes that need validation. r? `@ghost` (just checking perf at first)
steffahn
commented
Feb 2, 2023
Hi, out of curiosity, since I just found out this had actually been implemented, I wanted to try this on the only occurrence currently in std… and it doesn’t work at all? #![feature(const_btree_new)]use std::collections::BTreeMap;constfnf() -> BTreeMap<(),()>{let x = BTreeMap::new();let l = x.len();
x
}I’m not doing anything wrong, am I? I guess I should open an issue? |
steffahn
commented
Feb 2, 2023
Oh… maybe it’s a problem because it isn’t using |
Requested by the library team on Zulip.
If part of a feature is stabilized and a new feature is added for the remaining parts, then the
implied_bymeta-item can be added to#[unstable]to indicate which now-stable feature was used previously.When a
#![feature(..)]attribute still exists for the now-stable attribute, then there this has two effects:#![feature(..)]is removed or updated to the new feature).In the Zulip discussion, this was envisioned as
implieson#[stable]but I went withimplied_byon#[unstable]because it means that only the unstable attribute needs to be changed in future, not the new stable attribute, which seems less error-prone. It also isn't particularly feasible for me to detect whether items from the implied feature are used and then only suggest updating or removing the#![feature(..)]as appropriate, so I always do both.There's some new information in the cross-crate metadata as a result of this change, that's a little unfortunate, but without requiring that the
#[unstable]and#[stable]attributes both contain the implication information, it's necessary:I also change some comments to documentation comments in the compiler, add a helper for going from a
Spanto aSpanfor the entire line, and fix a incorrect part of the pre-existing stability attribute diagnostics.cc @yaahc