Infer all anonymous lifetimes in assoc consts as 'static#156508
Conversation
|
@bors try |
This comment has been minimized.
This comment has been minimized.
Turn elided_lifetimes_in_associated_constant FCW into a hard error
This comment has been minimized.
This comment has been minimized.
|
@craterbot check |
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
This comment has been minimized.
This comment has been minimized.
|
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🎉 Experiment
Footnotes
|
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
'static
Some cleanups around passing extra lifetime params from the resolver to ast lowering No functional changes, mostly removing information that was never used at any step. Possibly interesting to @petrochenkov and @cjgillot I originally thought this was a necessary cleanup to be able to refactor our `extra_lifetime_params_map` handling, but it turns out that I can also just do rust-lang#156508 which removes all the ugly usage of that side table and makes it possible for that side table to be put into `PerOwnerResolverData`. The changes here still were an improvement on its own, thus this PR.
Some cleanups around passing extra lifetime params from the resolver to ast lowering No functional changes, mostly removing information that was never used at any step. Possibly interesting to @petrochenkov and @cjgillot I originally thought this was a necessary cleanup to be able to refactor our `extra_lifetime_params_map` handling, but it turns out that I can also just do rust-lang#156508 which removes all the ugly usage of that side table and makes it possible for that side table to be put into `PerOwnerResolverData`. The changes here still were an improvement on its own, thus this PR.
Some cleanups around passing extra lifetime params from the resolver to ast lowering No functional changes, mostly removing information that was never used at any step. Possibly interesting to @petrochenkov and @cjgillot I originally thought this was a necessary cleanup to be able to refactor our `extra_lifetime_params_map` handling, but it turns out that I can also just do rust-lang#156508 which removes all the ugly usage of that side table and makes it possible for that side table to be put into `PerOwnerResolverData`. The changes here still were an improvement on its own, thus this PR.
Rollup merge of #156960 - oli-obk:push-rrmqnqvwtmsq, r=tiif Some cleanups around passing extra lifetime params from the resolver to ast lowering No functional changes, mostly removing information that was never used at any step. Possibly interesting to @petrochenkov and @cjgillot I originally thought this was a necessary cleanup to be able to refactor our `extra_lifetime_params_map` handling, but it turns out that I can also just do #156508 which removes all the ugly usage of that side table and makes it possible for that side table to be put into `PerOwnerResolverData`. The changes here still were an improvement on its own, thus this PR.
This comment has been minimized.
This comment has been minimized.
|
The PR description also needs an update after the last commit. |
|
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
| Elided(LifetimeRes), | ||
| Elided { | ||
| res: LifetimeRes, | ||
| /// Always report those lifetimes as an error |
There was a problem hiding this comment.
It's not always an error, it's only an error if it's in a path.
|
r=me after fixing the comment and squashing commits. |
Hard error on hidden elided lifetimes (`S` instead of `S<'_>`) in assoc consts
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@bors r=petrochenkov |
Infer all anonymous lifetimes in assoc consts as `'static` fixes rust-lang#115010 This FCW has been on for almost a year, let's actually do the change that T-lang asked for now that there's no breakage to be expected anymore. I first did a crater run checking if turning it into a hard error breaks anything. There are two cases that would be a hard error (but totally fine by defaulting to `'static`), both based on an old version of `minio`. One is a personal crate on github with no changes in the last year (https://github.com/PapePathe/daaray_kaamil) and the other is https://github.com/gear-tech/gear, which is developed on github actively and does not have this issue anymore (also old `minio` dependency that was since updated). The crates.io version is 2 years outdated. Thus we can pretty much conclude we're not going to cause anyone any confusion or subtle bugs by changing the rules. The rules for associated constants' types are now the same as the rules for free constants' types: We now treat *all* anonymous lifetimes as `'static`, irrespective of whether other lifetimes are in scope or not. This means the following piece of code starts compiling without warnings or errors again. ```rust struct Foo<'a>(&'a ()); impl<'a> Foo<'a> { const STR: &str = "hello, world"; } ``` We keep the hard error on ```rust trait Foo { const B: S = S { s: &() }; } struct S<'a> { s: &'a (), } ``` in contrast to free constant, which are orthogonal to this change and cause more breakage
…uwer Rollup of 21 pull requests Successful merges: - #150946 (intrinsics: Add a fallback for non-const libm float functions) - #158510 (Enable `static_position_independent_executables` on all gnu and musl targets) - #158541 (Move `std::io::Write` to `core::io`) - #158899 (Fix `unaligned_volatile_store` by removing `MemFlags::UNALIGNED`) - #155429 (Support `u128`/`i128` c-variadic arguments) - #156370 (Reject linked dylib EII default overrides) - #156508 (Infer all anonymous lifetimes in assoc consts as `'static`) - #158617 (allow mGCA const arguments to fall back to anon consts) - #158645 (Fix splat ICEs and ban it in closures) - #158859 (Improve `-Zls` diagnostic message on `.rs` files) - #158988 (Redo `TokenStreamIter`) - #158347 (Improve generic parameters handling for #[diagnostic::on_const]) - #158722 (delegation: do not always inherit `ConstArgHasType` predicates) - #158739 (view-types: HIR lowering) - #158883 (tests: fix enum-match.rs to handle LLVM 23) - #158886 (Add documentation for the `no_std` attribute) - #158940 (Implement feature `char_to_u32`) - #158951 (Merge three `MaxUniverse`s into one) - #158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places") - #158996 ([compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes) - #159005 (Use `as_lang_item` instead of repeatedly matching)
Infer all anonymous lifetimes in assoc consts as `'static` fixes rust-lang#115010 This FCW has been on for almost a year, let's actually do the change that T-lang asked for now that there's no breakage to be expected anymore. I first did a crater run checking if turning it into a hard error breaks anything. There are two cases that would be a hard error (but totally fine by defaulting to `'static`), both based on an old version of `minio`. One is a personal crate on github with no changes in the last year (https://github.com/PapePathe/daaray_kaamil) and the other is https://github.com/gear-tech/gear, which is developed on github actively and does not have this issue anymore (also old `minio` dependency that was since updated). The crates.io version is 2 years outdated. Thus we can pretty much conclude we're not going to cause anyone any confusion or subtle bugs by changing the rules. The rules for associated constants' types are now the same as the rules for free constants' types: We now treat *all* anonymous lifetimes as `'static`, irrespective of whether other lifetimes are in scope or not. This means the following piece of code starts compiling without warnings or errors again. ```rust struct Foo<'a>(&'a ()); impl<'a> Foo<'a> { const STR: &str = "hello, world"; } ``` We keep the hard error on ```rust trait Foo { const B: S = S { s: &() }; } struct S<'a> { s: &'a (), } ``` in contrast to free constant, which are orthogonal to this change and cause more breakage
…uwer Rollup of 24 pull requests Successful merges: - #150946 (intrinsics: Add a fallback for non-const libm float functions) - #158510 (Enable `static_position_independent_executables` on all gnu and musl targets) - #158541 (Move `std::io::Write` to `core::io`) - #158899 (Fix `unaligned_volatile_store` by removing `MemFlags::UNALIGNED`) - #156027 (Consider captured regions for opaque type region liveness.) - #156370 (Reject linked dylib EII default overrides) - #156508 (Infer all anonymous lifetimes in assoc consts as `'static`) - #157561 (rustdoc: do not include extra stuff in span) - #158617 (allow mGCA const arguments to fall back to anon consts) - #158645 (Fix splat ICEs and ban it in closures) - #158859 (Improve `-Zls` diagnostic message on `.rs` files) - #158988 (Redo `TokenStreamIter`) - #158347 (Improve generic parameters handling for #[diagnostic::on_const]) - #158384 (Allow BackwardIncompatibleDropHint in polonius legacy) - #158722 (delegation: do not always inherit `ConstArgHasType` predicates) - #158739 (view-types: HIR lowering) - #158877 (borrowck: Keep returned `path` from `best_blame_constraint()` consistent) - #158883 (tests: fix enum-match.rs to handle LLVM 23) - #158886 (Add documentation for the `no_std` attribute) - #158940 (Implement feature `char_to_u32`) - #158951 (Merge three `MaxUniverse`s into one) - #158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places") - #158995 (Use REST API in linkchecker script) - #158996 ([compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes)
Infer all anonymous lifetimes in assoc consts as `'static` fixes rust-lang#115010 This FCW has been on for almost a year, let's actually do the change that T-lang asked for now that there's no breakage to be expected anymore. I first did a crater run checking if turning it into a hard error breaks anything. There are two cases that would be a hard error (but totally fine by defaulting to `'static`), both based on an old version of `minio`. One is a personal crate on github with no changes in the last year (https://github.com/PapePathe/daaray_kaamil) and the other is https://github.com/gear-tech/gear, which is developed on github actively and does not have this issue anymore (also old `minio` dependency that was since updated). The crates.io version is 2 years outdated. Thus we can pretty much conclude we're not going to cause anyone any confusion or subtle bugs by changing the rules. The rules for associated constants' types are now the same as the rules for free constants' types: We now treat *all* anonymous lifetimes as `'static`, irrespective of whether other lifetimes are in scope or not. This means the following piece of code starts compiling without warnings or errors again. ```rust struct Foo<'a>(&'a ()); impl<'a> Foo<'a> { const STR: &str = "hello, world"; } ``` We keep the hard error on ```rust trait Foo { const B: S = S { s: &() }; } struct S<'a> { s: &'a (), } ``` in contrast to free constant, which are orthogonal to this change and cause more breakage
Infer all anonymous lifetimes in assoc consts as `'static` fixes rust-lang#115010 This FCW has been on for almost a year, let's actually do the change that T-lang asked for now that there's no breakage to be expected anymore. I first did a crater run checking if turning it into a hard error breaks anything. There are two cases that would be a hard error (but totally fine by defaulting to `'static`), both based on an old version of `minio`. One is a personal crate on github with no changes in the last year (https://github.com/PapePathe/daaray_kaamil) and the other is https://github.com/gear-tech/gear, which is developed on github actively and does not have this issue anymore (also old `minio` dependency that was since updated). The crates.io version is 2 years outdated. Thus we can pretty much conclude we're not going to cause anyone any confusion or subtle bugs by changing the rules. The rules for associated constants' types are now the same as the rules for free constants' types: We now treat *all* anonymous lifetimes as `'static`, irrespective of whether other lifetimes are in scope or not. This means the following piece of code starts compiling without warnings or errors again. ```rust struct Foo<'a>(&'a ()); impl<'a> Foo<'a> { const STR: &str = "hello, world"; } ``` We keep the hard error on ```rust trait Foo { const B: S = S { s: &() }; } struct S<'a> { s: &'a (), } ``` in contrast to free constant, which are orthogonal to this change and cause more breakage
View all comments
fixes #115010
This FCW has been on for almost a year, let's actually do the change that T-lang asked for now that there's no breakage to be expected anymore. I first did a crater run checking if turning it into a hard error breaks anything.
There are two cases that would be a hard error (but totally fine by defaulting to
'static), both based on an old version ofminio. One is a personal crate on github with no changes in the last year (https://github.com/PapePathe/daaray_kaamil) and the other is https://github.com/gear-tech/gear, which is developed on github actively and does not have this issue anymore (also oldminiodependency that was since updated). The crates.io version is 2 years outdated.Thus we can pretty much conclude we're not going to cause anyone any confusion or subtle bugs by changing the rules. The rules for associated constants' types are now the same as the rules for free constants' types:
We now treat all anonymous lifetimes as
'static, irrespective of whether other lifetimes are in scope or not. This means the following piece of code starts compiling without warnings or errors again.We keep the hard error on
in contrast to free constant, which are orthogonal to this change and cause more breakage