Repository navigation
fix ICE when a forced keyword follows a parameter pattern - #165906
rust-bors[bot] merged 1 commit into
Conversation
|
@fmease I apply your suggestion in #165700, the below 4 tests has failed. It looks like that
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
I've looked at the test failures and almost all of the diagnostic changes look fine or even like an improvement to me.
To put things into context, recover_missing_kw_before_item is meant to trigger in cases where the user wanted to write a struct, enum, fn, etc. but forgot to prefix the item with keyword struct, enum, fn, etc. respectively.
Well, you generally wouldn't call your struct/enum/fn a keyword since that's not allowed without an r#, right? Note that we do recover from that which is absolutely desired in cases like fn if() {} (here suggest adding r#). However, how likely is it that somebody forgot struct/enum/fn and tried to name the item a keyword (e.g., pub if {})? Incredibly unlikely. So I'm happy about us stopping to trigger in cases like const Self(); and item!(Self {});. You can't call a struct Self and you can't rewrite it to r#Self either.
PR #150590 actually made us stop recovering there but for some reason it was brought back in PR #151249.
Regarding parameter_without_type basically the thing applies: You wouldn't try to write a C-style parameter and name it a keyword ... except self (as found in one failing test), that I do consider legitimate.
So, simply remove the relevant //..~ ERROR annotations from the tests (most if not all tests are just regression tests for former ICEs btw) and re--bless the test expectations.
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
k#self'sident.nameis also self, so it hits theident.name == kw::SelfLowerbranch too, which gives two extra outputs: the "declare the type" suggestion, and a "self parameter is only allowed in associated functions" error. @fmease We accept this or narrow theselfexception toIdentKind::Normal?
Apologies for the delayed response. Since both self and k#self denote keyword self, it's correct to trigger the "declare the type" suggestion. After all, you can define a method like fn f(k#self); or fn f(k#self: Type);.
Regarding the extra "self parameter is only allowed in associated functions", that would be evidence for the fact that we've successfully recovered from fn f(Type k#self); interpreting it as fn f(k#self: Type);. If you don't want it in the test, consider wrapping the function in question in a trait def or impl block (unless it alters the original test intention).
305ac22 to
4dfdc40
Compare
|
The parser was modified, potentially altering the grammar of (stable) Rust cc @fmease |
This comment has been minimized.
This comment has been minimized.
|
@bors squash |
This comment has been minimized.
This comment has been minimized.
|
🔨 4 commits were squashed into cbaa0d2. |
d6fe4aa to
cbaa0d2
Compare
This comment has been minimized.
This comment has been minimized.
cbaa0d2 to
070afe1
Compare
|
@bors squash |
This comment has been minimized.
This comment has been minimized.
* fix ICE when a forced keyword follows a parameter pattern * Update compiler/rustc_parse/src/parser/diagnostics.rs * fix the errors * fix format error * update stderr Co-authored-by: Joseph Zhao <65984904+programskillforverification@users.noreply.github.com> Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
|
🔨 5 commits were squashed into 421b1b2. |
070afe1 to
421b1b2
Compare
…-kw-param-without-type, r=fmease fix ICE when a forced keyword follows a parameter pattern This is a resubmission of rust-lang#165700 by lazerg. Fixes rust-lang#165690 r? fmease
Rollup of 21 pull requests Successful merges: - #165707 (bootstrap: Make low priority the default) - #165716 (Refactor split_block in check_pointers to avoid Terminator: None) - #165934 (Avoid using Terminator:None in simplify_cfg) - #166050 (Use attribute parser for lang attributes in `LateResolutionVisitor`) - #166069 (bootstrap: fix keep-stage-std) - #166117 (Remove ebadf handling from stdio) - #166119 (Avoid an ICE on re-exports of private imports without a DefId) - #165094 (reflection: doc attributes from adts, fields, and variants) - #165216 (Clearer diagnostics when `&FnOnce` was provided when `FnOnce` was expected) - #165694 (view-types: make sure view types are !Sized) - #165802 (Add CI workflow to publish backtrace after a push to main) - #165883 (Report a recursion limit error instead of delaying a bug in RPITIT collector) - #165906 (fix ICE when a forced keyword follows a parameter pattern) - #166064 (Add const generic transmute min support) - #166136 (Move ub_checks() inside the const_eval_select branch.) - #166158 (bump some tools' `toml` dependency) - #166166 (Don't recover if not allowed in `parse_seq_to_before_tokens`) - #166176 (compiletest: Move all code out of the crate root) - #166185 (simd-test: Fix cfg syntax in the test macro) - #166194 (std: Unstably constify `std::process::abort`) - #166210 (Avoid terminator: None in insert_direct_enum_check) Failed merges: - #166150 (Reflection: refactor Type and TypeKind) - #166160 (refactor CTFE-specific intrinsics to different file)
Rollup of 20 pull requests Successful merges: - #165716 (Refactor split_block in check_pointers to avoid Terminator: None) - #165934 (Avoid using Terminator:None in simplify_cfg) - #166050 (Use attribute parser for lang attributes in `LateResolutionVisitor`) - #166069 (bootstrap: fix keep-stage-std) - #166117 (Remove ebadf handling from stdio) - #166119 (Avoid an ICE on re-exports of private imports without a DefId) - #165094 (reflection: doc attributes from adts, fields, and variants) - #165216 (Clearer diagnostics when `&FnOnce` was provided when `FnOnce` was expected) - #165694 (view-types: make sure view types are !Sized) - #165802 (Add CI workflow to publish backtrace after a push to main) - #165883 (Report a recursion limit error instead of delaying a bug in RPITIT collector) - #165906 (fix ICE when a forced keyword follows a parameter pattern) - #166064 (Add const generic transmute min support) - #166136 (Move ub_checks() inside the const_eval_select branch.) - #166158 (bump some tools' `toml` dependency) - #166166 (Don't recover if not allowed in `parse_seq_to_before_tokens`) - #166176 (compiletest: Move all code out of the crate root) - #166185 (simd-test: Fix cfg syntax in the test macro) - #166194 (std: Unstably constify `std::process::abort`) - #166210 (Avoid terminator: None in insert_direct_enum_check) Failed merges: - #166150 (Reflection: refactor Type and TypeKind) - #166160 (refactor CTFE-specific intrinsics to different file)
Rollup of 20 pull requests Successful merges: - rust-lang/rust#165716 (Refactor split_block in check_pointers to avoid Terminator: None) - rust-lang/rust#165934 (Avoid using Terminator:None in simplify_cfg) - rust-lang/rust#166050 (Use attribute parser for lang attributes in `LateResolutionVisitor`) - rust-lang/rust#166069 (bootstrap: fix keep-stage-std) - rust-lang/rust#166117 (Remove ebadf handling from stdio) - rust-lang/rust#166119 (Avoid an ICE on re-exports of private imports without a DefId) - rust-lang/rust#165094 (reflection: doc attributes from adts, fields, and variants) - rust-lang/rust#165216 (Clearer diagnostics when `&FnOnce` was provided when `FnOnce` was expected) - rust-lang/rust#165694 (view-types: make sure view types are !Sized) - rust-lang/rust#165802 (Add CI workflow to publish backtrace after a push to main) - rust-lang/rust#165883 (Report a recursion limit error instead of delaying a bug in RPITIT collector) - rust-lang/rust#165906 (fix ICE when a forced keyword follows a parameter pattern) - rust-lang/rust#166064 (Add const generic transmute min support) - rust-lang/rust#166136 (Move ub_checks() inside the const_eval_select branch.) - rust-lang/rust#166158 (bump some tools' `toml` dependency) - rust-lang/rust#166166 (Don't recover if not allowed in `parse_seq_to_before_tokens`) - rust-lang/rust#166176 (compiletest: Move all code out of the crate root) - rust-lang/rust#166185 (simd-test: Fix cfg syntax in the test macro) - rust-lang/rust#166194 (std: Unstably constify `std::process::abort`) - rust-lang/rust#166210 (Avoid terminator: None in insert_direct_enum_check) Failed merges: - rust-lang/rust#166150 (Reflection: refactor Type and TypeKind) - rust-lang/rust#166160 (refactor CTFE-specific intrinsics to different file)
This is a resubmission of #165700 by lazerg.
Fixes #165690
r? fmease