Skip to content

Rollup of 9 pull requests - #69796

Merged
bors merged 32 commits into
rust-lang:masterfrom
Centril:rollup-xg85jmx
Mar 7, 2020
Merged

Rollup of 9 pull requests#69796
bors merged 32 commits into
rust-lang:masterfrom
Centril:rollup-xg85jmx

Conversation

@Centril

Copy link
Copy Markdown
Contributor

Successful merges:

Failed merges:

r? @ghost

daborossand others added 30 commits February 15, 2020 19:50
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.
Error::description is deprecated as of version 1.42, as the commit was
not in the release for 1.41.
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`
```
Fixrust-lang#55631, fixrust-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.
Fixesrust-lang#35813.
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.
…-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.
Fixesrust-lang#69751
…ep, r=cramertj
Don't redundantly repeat field names (clippy::redundant_field_names)
@Centril

Copy link
Copy Markdown
ContributorAuthor

@bors r+ p=9 rollup=never

@bors

bors commented Mar 7, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit 709325a has been approved by Centril

@bors

bors commented Mar 7, 2020

Copy link
Copy Markdown
Collaborator

🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened

@borsbors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 7, 2020
@Centril

Copy link
Copy Markdown
ContributorAuthor

@bors p=1001

@CentrilCentril added the rollup A PR which is a rollup label Mar 7, 2020
@bors

bors commented Mar 7, 2020

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 709325a with merge 3ae47448283b46d604f1656269e38e84f05cbc35...

@rust-highfive

Copy link
Copy Markdown
Contributor

Your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

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 @rust-lang/infra. (Feature Requests)

@bors

bors commented Mar 7, 2020

Copy link
Copy Markdown
Collaborator

💔 Test failed - checks-azure

@borsbors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 7, 2020
@Centril

Copy link
Copy Markdown
ContributorAuthor

@bors retry

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 7, 2020
@bors

bors commented Mar 7, 2020

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 709325a with merge a039217...

@bors

bors commented Mar 7, 2020

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-azure
Approved by: Centril
Pushing a039217 to master...

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Mar 7, 2020
@bors
bors merged commit a039217 into rust-lang:masterMar 7, 2020
@Centril
Centril deleted the rollup-xg85jmx branch March 7, 2020 12:02
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-borsThis PR was explicitly merged by bors.rollupA PR which is a rollupS-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

11 participants

@Centril@bors@rust-highfive@daboross@matthiaskrgr@thekuom@cuviper@dylnuge@petrochenkov@JohnTitor@estebank