-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Correctly check never_type
feature gating
#120552
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check if this also works for RPIT? Or dyn Fn() -> !
?
Also, instead of keeping this "in generics" state as part of the visitor, please just modify this line to check for |
This will also likely require a beta backport depending on the timing of when this lands. I'll nominate it pre-emptively so we don't forget. This should be backported to 1.77, so if this lands on 1.77 then we're good. |
Except this is the "default" implementation. It should call the |
Yes, I understand clearly what the problem is. There's a discrepancy between what I don't understand what point you're trying to make here though -- there's still no reason to introduce For the record, the approach that you've taken also breaks this code which compiles on stable: trait X<const N: i32> {}
fn hello<T: X<{ fn hello() -> ! { loop {} } 1 }>>() {}
fn main() {} |
Then I misunderstood what you meant. I understood that you said to revert the change on this line and to add a code comment. However, this would not only impact |
Actually, that's not the right line that I suggested anyways. Just modify the The manual tracking of a boolean in a walker imo is an anti-pattern, because it's very easy to get wrong with nested items and other AST nodes. |
No I'm fine with doing it. Just didn't understand what you meant. |
e450f16
to
aee9d60
Compare
Applied your suggestions. Added more ui tests and also the case which should work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me after applying changes
@@ -362,6 +362,16 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { | |||
} | |||
} | |||
|
|||
fn visit_generic_args(&mut self, args: &'a ast::GenericArgs) { | |||
if let ast::GenericArgs::Parenthesized(generic_args) = args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls leave a comment explaining why this is being checked here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
tests/ui/never_type/const-context.rs
Outdated
|
||
trait X<const N: i32> {} | ||
|
||
fn hello<T: X<{ fn hello() -> ! { loop {} } 1 }>>() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you rename this? it's not really that it's in a "const context", it's more about it being in a nested item.
Maybe never-type-in-nested-fn-decl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
aee9d60
to
0f21e45
Compare
@bors r=compiler-errors |
🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened. |
…gate, r=compiler-errors Correctly check `never_type` feature gating Fixes rust-lang#120542. The feature wasn't tested on return type of a generic function type, so it got under the radar in rust-lang#120316. r? `@compiler-errors`
…gate, r=compiler-errors Correctly check `never_type` feature gating Fixes rust-lang#120542. The feature wasn't tested on return type of a generic function type, so it got under the radar in rust-lang#120316. r? ``@compiler-errors``
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#119759 (Add FileCheck annotations to dataflow-const-prop tests) - rust-lang#120323 (On E0277 be clearer about implicit `Sized` bounds on type params and assoc types) - rust-lang#120473 (Only suggest removal of `as_*` and `to_` conversion methods on E0308) - rust-lang#120520 (Some cleanups around diagnostic levels.) - rust-lang#120540 (add test for try-block-in-match-arm) - rust-lang#120547 (`#![feature(inline_const_pat)]` is no longer incomplete) - rust-lang#120552 (Correctly check `never_type` feature gating) - rust-lang#120555 (put pnkfelix (me) back on the review queue.) - rust-lang#120556 (Improve the diagnostics for unused generic parameters) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#119759 (Add FileCheck annotations to dataflow-const-prop tests) - rust-lang#120323 (On E0277 be clearer about implicit `Sized` bounds on type params and assoc types) - rust-lang#120473 (Only suggest removal of `as_*` and `to_` conversion methods on E0308) - rust-lang#120520 (Some cleanups around diagnostic levels.) - rust-lang#120540 (add test for try-block-in-match-arm) - rust-lang#120547 (`#![feature(inline_const_pat)]` is no longer incomplete) - rust-lang#120552 (Correctly check `never_type` feature gating) - rust-lang#120555 (put pnkfelix (me) back on the review queue.) - rust-lang#120556 (Improve the diagnostics for unused generic parameters) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#119759 (Add FileCheck annotations to dataflow-const-prop tests) - rust-lang#120323 (On E0277 be clearer about implicit `Sized` bounds on type params and assoc types) - rust-lang#120473 (Only suggest removal of `as_*` and `to_` conversion methods on E0308) - rust-lang#120540 (add test for try-block-in-match-arm) - rust-lang#120547 (`#![feature(inline_const_pat)]` is no longer incomplete) - rust-lang#120552 (Correctly check `never_type` feature gating) - rust-lang#120555 (put pnkfelix (me) back on the review queue.) - rust-lang#120556 (Improve the diagnostics for unused generic parameters) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#120552 - GuillaumeGomez:never-type-feature-gate, r=compiler-errors Correctly check `never_type` feature gating Fixes rust-lang#120542. The feature wasn't tested on return type of a generic function type, so it got under the radar in rust-lang#120316. r? ```@compiler-errors```
[beta] backports - Correct paths for hexagon-unknown-none-elf platform doc rust-lang#120533 - CI: Use ninja on apple builders rust-lang#120543 - Correctly check `never_type` feature gating rust-lang#120552 - Revert unsound libcore changes of 119911 rust-lang#120562 r? cuviper
[beta] backports - Correct paths for hexagon-unknown-none-elf platform doc rust-lang#120533 - CI: Use ninja on apple builders rust-lang#120543 - Correctly check `never_type` feature gating rust-lang#120552 - Revert unsound libcore changes of 119911 rust-lang#120562 r? cuviper
[beta] backports - Correct paths for hexagon-unknown-none-elf platform doc rust-lang#120533 - CI: Use ninja on apple builders rust-lang#120543 - Correctly check `never_type` feature gating rust-lang#120552 - Revert unsound libcore changes of 119911 rust-lang#120562 - Downgrade xcode rust-lang#120914 r? cuviper
[beta] backports - Correct paths for hexagon-unknown-none-elf platform doc rust-lang#120533 - CI: Use ninja on apple builders rust-lang#120543 - Correctly check `never_type` feature gating rust-lang#120552 - Revert unsound libcore changes of 119911 rust-lang#120562 - Downgrade xcode rust-lang#120914 - Update jobserver-rs to 0.1.28 rust-lang#120846 - [beta] Update LLVM submodule rust-lang#121132 r? cuviper
Fixes #120542.
The feature wasn't tested on return type of a generic function type, so it got under the radar in #120316.
r? @compiler-errors