Repository navigation
Lex lifetimes as identifiers, recover from emoji and emit appropriate error - #153893
Conversation
|
The parser was modified, potentially altering the grammar of (stable) Rust cc @fmease |
|
rustbot has assigned @jdonszelmann. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
8679628 to
cf3c735
Compare
This comment has been minimized.
This comment has been minimized.
| self.bump(); | ||
| self.eat_while(is_id_continue); | ||
| self.eat_while(|c| { | ||
| let is_emoji = !c.is_ascii() && c.is_emoji_char(); |
There was a problem hiding this comment.
can we possibly create a function or a method for this, i see this logic is using in two places, maybe something like self.is_emoji() would be better approach?
| if has_emoji { | ||
| self.dcx().struct_span_err(span, "lifetimes cannot contain emoji").emit(); | ||
| } |
There was a problem hiding this comment.
Why not make use of the preexisting ParseSess.bad_unicode_identifiers & rustc_interface::passes infrastructure?
There was a problem hiding this comment.
There was a problem hiding this comment.
The main reason to not do that is to still leverage the 'blah' recovery machinery. Here we are in a situation where we have to either choose one case to have nicer output than the other, or find a good way to unify both checks.
cf3c735 to
a45ca0d
Compare
This comment has been minimized.
This comment has been minimized.
a45ca0d to
dfdc525
Compare
This comment has been minimized.
This comment has been minimized.
|
rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead. cc @rust-lang/rust-analyzer |
This comment has been minimized.
This comment has been minimized.
|
I agree with esteban for the nicer suggestions here, that's probably worth it. Sorry it took me a while, but lgtm. @bors r=me,veykril rollup |
|
@bors r=jdonszelmann,Veykril |
…lmann,Veykril Lex lifetimes as identifiers, recover from emoji and emit appropriate error Lex and parse emoji in lifetimes by using the identifier logic, and disallow them in the parser with a hard error. Allow emoji to start a lifetime name even if they are not XID_Start. ``` error: identifiers cannot contain emoji: `'🐛🐛🐛family👨👩👧👦` --> $DIR/emoji-in-lifetime.rs:1:22 | LL | fn bad_lifetime_name<'🐛🐛🐛family👨👩👧👦>( | ^^^^^^^^^^^^^^^^^^^^^ ``` Address rust-lang#141081 (but we could provide more information in the diagnostic, pointing at the specific chars, providing a link to the reference on identifiers and/or some other extra information).
Rollup of 7 pull requests Successful merges: - #142659 (compiler-builtins: Clean up features) - #153574 (Avoid ICE when param-env normalization leaves unresolved inference variables) - #153648 (Fix EII function aliases eliminated by LTO) - #153790 (Fix regression when dealing with generics/values with unresolved inference) - #153893 (Lex lifetimes as identifiers, recover from emoji and emit appropriate error) - #153980 (refactor: move doc(rust_logo) check to parser) - #154551 (Skip suggestions pointing to macro def for assert_eq)
Rollup of 7 pull requests Successful merges: - #142659 (compiler-builtins: Clean up features) - #153574 (Avoid ICE when param-env normalization leaves unresolved inference variables) - #153648 (Fix EII function aliases eliminated by LTO) - #153790 (Fix regression when dealing with generics/values with unresolved inference) - #153893 (Lex lifetimes as identifiers, recover from emoji and emit appropriate error) - #153980 (refactor: move doc(rust_logo) check to parser) - #154551 (Skip suggestions pointing to macro def for assert_eq)
|
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. |
8bdd8a4 to
fc29b70
Compare
|
I've only made one change: reverted the field name change from |
This comment has been minimized.
This comment has been minimized.
a1c55e3 to
793200a
Compare
Lex and parse emoji in lifetimes, and disallow them in the parser with a hard error. Allow emoji to start a lifetime name even if they are not XID_Start. ``` error: lifetimes cannot contain emoji --> $DIR/emoji-in-lifetime.rs:1:22 | LL | fn bad_lifetime_name<'🐛🐛🐛family👨👩👧👦>( | ^^^^^^^^^^^^^^^^^^^^^ ``` Unify lifetime and identifier parsing. Use `bad_unicode_identifiers` for lifetimes.
fc29b70 to
a1c55e3
Compare
|
Approving as per #153893 (comment) @bors r=jdonszelmann,Veykril |
…lmann,Veykril Lex lifetimes as identifiers, recover from emoji and emit appropriate error Lex and parse emoji in lifetimes by using the identifier logic, and disallow them in the parser with a hard error. Allow emoji to start a lifetime name even if they are not XID_Start. ``` error: identifiers cannot contain emoji: `'🐛🐛🐛family👨👩👧👦` --> $DIR/emoji-in-lifetime.rs:1:22 | LL | fn bad_lifetime_name<'🐛🐛🐛family👨👩👧👦>( | ^^^^^^^^^^^^^^^^^^^^^ ``` Address rust-lang#141081 (but we could provide more information in the diagnostic, pointing at the specific chars, providing a link to the reference on identifiers and/or some other extra information).
Rollup of 8 pull requests Successful merges: - #159540 (Enable statx on all Linux targets and short-circuit it for musl) - #164168 (Add tests for unsoundness involving alias liveness) - #164608 (core: Constify `resumable_breakpoint` and re-export it in `std`) - #164787 (cg_llvm: Use an invariant lifetime brand for LLVM contexts ) - #164966 (x86-64-linux-gnu seems to have working f128 now) - #153893 (Lex lifetimes as identifiers, recover from emoji and emit appropriate error) - #164895 (Disable recovery when attribute parser shouldn't emit) - #165004 (docs: Nitpick change in `HashMap`'s `.insert_entry()` doc example)
…lmann,Veykril Lex lifetimes as identifiers, recover from emoji and emit appropriate error Lex and parse emoji in lifetimes by using the identifier logic, and disallow them in the parser with a hard error. Allow emoji to start a lifetime name even if they are not XID_Start. ``` error: identifiers cannot contain emoji: `'🐛🐛🐛family👨👩👧👦` --> $DIR/emoji-in-lifetime.rs:1:22 | LL | fn bad_lifetime_name<'🐛🐛🐛family👨👩👧👦>( | ^^^^^^^^^^^^^^^^^^^^^ ``` Address rust-lang#141081 (but we could provide more information in the diagnostic, pointing at the specific chars, providing a link to the reference on identifiers and/or some other extra information).
Rollup of 8 pull requests Successful merges: - #164168 (Add tests for unsoundness involving alias liveness) - #164608 (core: Constify `resumable_breakpoint` and re-export it in `std`) - #164787 (cg_llvm: Use an invariant lifetime brand for LLVM contexts ) - #164851 (Add behavior tests for `Arc` and `Rc`) - #164966 (x86-64-linux-gnu seems to have working f128 now) - #153893 (Lex lifetimes as identifiers, recover from emoji and emit appropriate error) - #164895 (Disable recovery when attribute parser shouldn't emit) - #165004 (docs: Nitpick change in `HashMap`'s `.insert_entry()` doc example)
Rollup of 9 pull requests Successful merges: - #164168 (Add tests for unsoundness involving alias liveness) - #164608 (core: Constify `resumable_breakpoint` and re-export it in `std`) - #164787 (cg_llvm: Use an invariant lifetime brand for LLVM contexts ) - #164966 (x86-64-linux-gnu seems to have working f128 now) - #153893 (Lex lifetimes as identifiers, recover from emoji and emit appropriate error) - #164848 (Add `strict_` methods to `NonZero`) - #164895 (Disable recovery when attribute parser shouldn't emit) - #164963 (fd-views: enable test on Miri) - #165004 (docs: Nitpick change in `HashMap`'s `.insert_entry()` doc example)
Rollup of 9 pull requests Successful merges: - #164168 (Add tests for unsoundness involving alias liveness) - #164608 (core: Constify `resumable_breakpoint` and re-export it in `std`) - #164787 (cg_llvm: Use an invariant lifetime brand for LLVM contexts ) - #164966 (x86-64-linux-gnu seems to have working f128 now) - #153893 (Lex lifetimes as identifiers, recover from emoji and emit appropriate error) - #164848 (Add `strict_` methods to `NonZero`) - #164895 (Disable recovery when attribute parser shouldn't emit) - #164963 (fd-views: enable test on Miri) - #165004 (docs: Nitpick change in `HashMap`'s `.insert_entry()` doc example)
…lmann,Veykril Lex lifetimes as identifiers, recover from emoji and emit appropriate error Lex and parse emoji in lifetimes by using the identifier logic, and disallow them in the parser with a hard error. Allow emoji to start a lifetime name even if they are not XID_Start. ``` error: identifiers cannot contain emoji: `'🐛🐛🐛family👨👩👧👦` --> $DIR/emoji-in-lifetime.rs:1:22 | LL | fn bad_lifetime_name<'🐛🐛🐛family👨👩👧👦>( | ^^^^^^^^^^^^^^^^^^^^^ ``` Address rust-lang#141081 (but we could provide more information in the diagnostic, pointing at the specific chars, providing a link to the reference on identifiers and/or some other extra information).
Rollup of 9 pull requests Successful merges: - #164168 (Add tests for unsoundness involving alias liveness) - #164608 (core: Constify `resumable_breakpoint` and re-export it in `std`) - #164787 (cg_llvm: Use an invariant lifetime brand for LLVM contexts ) - #164966 (x86-64-linux-gnu seems to have working f128 now) - #153893 (Lex lifetimes as identifiers, recover from emoji and emit appropriate error) - #164848 (Add `strict_` methods to `NonZero`) - #164895 (Disable recovery when attribute parser shouldn't emit) - #164963 (fd-views: enable test on Miri) - #165004 (docs: Nitpick change in `HashMap`'s `.insert_entry()` doc example)
Rollup merge of #153893 - estebank:emoji-lifetime, r=jdonszelmann,Veykril Lex lifetimes as identifiers, recover from emoji and emit appropriate error Lex and parse emoji in lifetimes by using the identifier logic, and disallow them in the parser with a hard error. Allow emoji to start a lifetime name even if they are not XID_Start. ``` error: identifiers cannot contain emoji: `'🐛🐛🐛family👨👩👧👦` --> $DIR/emoji-in-lifetime.rs:1:22 | LL | fn bad_lifetime_name<'🐛🐛🐛family👨👩👧👦>( | ^^^^^^^^^^^^^^^^^^^^^ ``` Address #141081 (but we could provide more information in the diagnostic, pointing at the specific chars, providing a link to the reference on identifiers and/or some other extra information).
View all comments
Lex and parse emoji in lifetimes by using the identifier logic, and disallow them in the parser with a hard error. Allow emoji to start a lifetime name even if they are not XID_Start.
Address #141081 (but we could provide more information in the diagnostic, pointing at the specific chars, providing a link to the reference on identifiers and/or some other extra information).