-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rollup of 12 pull requests #69795
Rollup of 12 pull requests #69795
Conversation
This adds parsing for expressions like 'x as Ty[0]' which will immediately error out, but still give the rest of the parser a valid parse tree to continue.
This is almost entirely refactoring and message changing, with the single behavioral change of panicking for unexpected output.
Previously this just errored out on all usages of type ascription, which isn't helpful.
This is a modified version of estebank's suggestion, with a bit of extra cleanup now that we don't need the different cases for if we can turn a span into a string or not.
Implementes suggeseted changes by Centril. This checks whether the memory location of the cast remains the same after atttempting to parse a postfix operator after a cast has been parsed. If the address is not the same, an illegal postfix operator was parsed. Previously the code generated a hash of the pointer, which was overly complex and inefficent. Casting the pointers and comparing them is simpler and more effcient.
Reference issue rust-lang#67311 Tests combinations of the following pattern features: - bindings_after_at - or_patterns - slice_patterns - box_patterns
Some of the nested OR paths were being missed
For all of the methods that pick off the first or last element, we can use subslice patterns to implement them directly, rather than relying on deeper indexing function calls. At a minimum, this means the generated code will rely less on inlining for performance, but in some cases it also optimizes better.
When encountering an Item in a pat context, point at the item def ``` error[E0308]: mismatched types --> $DIR/const-in-struct-pat.rs:8:17 | LL | struct foo; | ----------- `foo` defined here ... LL | let Thing { foo } = t; | ^^^ expected struct `std::string::String`, found struct `foo` | = note: `foo` is interpreted as a unit struct, not a new binding help: you can bind the struct field to a different name | LL | let Thing { foo: other_foo } = t; | ^^^^^^^^^^^^^^ ``` ``` error[E0308]: mismatched types --> $DIR/const.rs:14:9 | LL | const FOO: Foo = Foo{bar: 5}; | ----------------------------- constant defined here ... LL | FOO => {}, | ^^^ | | | expected `&Foo`, found struct `Foo` | `FOO` is interpreted as a constant, not a new binding | help: use different name to introduce a new binding: `other_foo` ``` Fix rust-lang#55631, fix rust-lang#48062, cc rust-lang#42876.
Parse & reject postfix operators after casts This adds an explicit error messages for when parsing `x as Type[0]` or similar expressions. Our add an extra parse case for parsing any postfix operator (dot, indexing, method calls, await) that triggers directly after parsing `as` expressions. My friend and I worked on this together, but they're still deciding on a github username and thus I'm submitting this for both of us. It will immediately error out, but will also provide the rest of the parser with a useful parse tree to deal with. There's one decision we made in how this produces the parse tree. In the situation `&x as T[0]`, one could imagine this parsing as either `&((x as T)[0])` or `((&x) as T)[0]`. We chose the latter for ease of implementation, and as it seemed the most intuitive. Feedback welcome! This is our first change to the parser section, and it might be completely horrible. Fixes rust-lang#35813.
ast: `Mac`/`Macro` -> `MacCall` It's now obvious that these refer to macro calls rather than to macro definitions. It's also a single name instead of two different names in different places. `rustc_expand` usually calls macro calls in a wide sense (including attributes and derives) "macro invocations", but structures and variants renamed in this PR are only relevant to fn-like macros, so it's simpler and clearer to just call them calls. cc rust-lang#63586 (comment) r? @eddyb
Use .next() instead of .nth(0) on iterators.
Rename DefKind::Method and TraitItemKind::Method r? @eddyb, @Centril, or @matthewjasper cc rust-lang#69498 rust-lang#60163
rustc_expand: Factor out `Annotatable::into_tokens` to a separate method Minor refactoring salvaged from rust-lang#69594. r? @Centril
…after-at-tests, r=Centril test(pattern): add tests for combinations of pattern features Reference issue rust-lang#67311 Tests combinations of the following pattern features: - bindings_after_at - or_patterns - slice_patterns - box_patterns r? @Centril
Use subslice patterns in slice methods For all of the methods that pick off the first or last element, we can use subslice patterns to implement them directly, rather than relying on deeper indexing function calls. At a minimum, this means the generated code will rely less on inlining for performance, but in some cases it also optimizes better.
…i-obk Make PlaceRef take just one lifetime r? @eddyb
Avoid using `unwrap()` in suggestions Fixes rust-lang#69725 r? @estebank
…-Simulacrum Update deprecation version to 1.42 for Error::description Error::description is deprecated as of version 1.42, as the commit was not in the release for 1.41. Fixes rust-lang#69751
…ep, r=cramertj Don't redundantly repeat field names (clippy::redundant_field_names)
@bors r+ p=12 rollup=never |
📌 Commit 46266c1 has been approved by |
🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened |
@bors p=1001 |
⌛ Testing commit 46266c1 with merge fc140a3381cec8bc4b3670348101d2c3ea51cc54... |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
💔 Test failed - checks-azure |
Successful merges:
Mac
/Macro
->MacCall
#69589 (ast:Mac
/Macro
->MacCall
)Annotatable::into_tokens
to a separate method #69680 (rustc_expand: Factor outAnnotatable::into_tokens
to a separate method)unwrap()
in suggestions #69727 (Avoid usingunwrap()
in suggestions)Failed merges:
r? @ghost