Skip to content
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

Closed
wants to merge 58 commits into from
Closed

Conversation

Centril
Copy link
Contributor

@Centril Centril commented Mar 7, 2020

Successful merges:

Failed merges:

r? @ghost

daboross and 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.
JohnTitor and others added 14 commits March 7, 2020 04:38
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.
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
…-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)
@Centril
Copy link
Contributor Author

Centril commented Mar 7, 2020

@bors r+ p=12 rollup=never

@bors
Copy link
Contributor

bors commented Mar 7, 2020

📌 Commit 46266c1 has been approved by Centril

@bors
Copy link
Contributor

bors commented Mar 7, 2020

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

@bors bors 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
Contributor Author

Centril commented Mar 7, 2020

@bors p=1001

@bors
Copy link
Contributor

bors commented Mar 7, 2020

⌛ Testing commit 46266c1 with merge fc140a3381cec8bc4b3670348101d2c3ea51cc54...

@Centril Centril added the rollup A PR which is a rollup label Mar 7, 2020
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-tools of 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.
2020-03-07T06:22:49.6263984Z [TIMING] BookTest { compiler: Compiler { stage: 2, host: "x86_64-unknown-linux-gnu" }, path: "src/doc/book", name: "book", is_ext_doc: true } -- 61.935
2020-03-07T06:22:49.6268501Z Testing rustbook src/doc/nomicon
2020-03-07T06:22:56.3445310Z Error: Rustdoc returned an error: 
2020-03-07T06:22:56.3445590Z running 6 tests
2020-03-07T06:22:56.3446452Z test /tmp/mdbook-y11Qm8/destructors.md - Destructors (line 128) ... FAILED
2020-03-07T06:22:56.3447003Z test /tmp/mdbook-y11Qm8/destructors.md - Destructors (line 28) ... FAILED
2020-03-07T06:22:56.3447826Z test /tmp/mdbook-y11Qm8/destructors.md - Destructors (line 110) ... ok
2020-03-07T06:22:56.3448733Z test /tmp/mdbook-y11Qm8/destructors.md - Destructors (line 6) ... ignored
2020-03-07T06:22:56.3449316Z test /tmp/mdbook-y11Qm8/destructors.md - Destructors (line 55) ... FAILED
2020-03-07T06:22:56.3449873Z test /tmp/mdbook-y11Qm8/destructors.md - Destructors (line 96) ... ok
2020-03-07T06:22:56.3450257Z failures:
2020-03-07T06:22:56.3450374Z 
2020-03-07T06:22:56.3450374Z 
2020-03-07T06:22:56.3450866Z ---- /tmp/mdbook-y11Qm8/destructors.md - Destructors (line 128) stdout ----
2020-03-07T06:22:56.3451238Z error[E0432]: unresolved import `std::alloc::Alloc`
2020-03-07T06:22:56.3452212Z  --> /tmp/mdbook-y11Qm8/destructors.md:131:18
2020-03-07T06:22:56.3452614Z 4 | use std::alloc::{Alloc, GlobalAlloc, Global, Layout};
2020-03-07T06:22:56.3452860Z   |                  ^^^^^
2020-03-07T06:22:56.3453033Z   |                  |
2020-03-07T06:22:56.3453243Z   |                  no `Alloc` in `alloc`
2020-03-07T06:22:56.3453243Z   |                  no `Alloc` in `alloc`
2020-03-07T06:22:56.3453528Z   |                  help: a similar name exists in the module: `alloc`
2020-03-07T06:22:56.3453933Z 
2020-03-07T06:22:56.3454212Z error[E0599]: no method named `dealloc` found for struct `std::alloc::Global` in the current scope
2020-03-07T06:22:56.3454763Z   --> /tmp/mdbook-y11Qm8/destructors.md:142:20
2020-03-07T06:22:56.3455390Z 15 |             Global.dealloc(c.cast(), Layout::new::<T>());
2020-03-07T06:22:56.3455763Z    |                    ^^^^^^^ method not found in `std::alloc::Global`
2020-03-07T06:22:56.3456035Z    |
2020-03-07T06:22:56.3456282Z    = help: items from traits can only be used if the trait is in scope
2020-03-07T06:22:56.3456282Z    = help: items from traits can only be used if the trait is in scope
2020-03-07T06:22:56.3456644Z help: the following trait is implemented but not in scope; perhaps add a `use` for it:
2020-03-07T06:22:56.3456913Z    |
2020-03-07T06:22:56.3457085Z 4  | use std::alloc::AllocRef;
2020-03-07T06:22:56.3457278Z    |
2020-03-07T06:22:56.3457375Z 
2020-03-07T06:22:56.3457862Z error[E0599]: no method named `dealloc` found for struct `std::alloc::Global` in the current scope
2020-03-07T06:22:56.3459129Z   --> /tmp/mdbook-y11Qm8/destructors.md:157:20
2020-03-07T06:22:56.3459828Z 30 |             Global.dealloc(c.cast(), Layout::new::<T>());
2020-03-07T06:22:56.3460444Z    |                    ^^^^^^^ method not found in `std::alloc::Global`
2020-03-07T06:22:56.3460745Z    |
2020-03-07T06:22:56.3461033Z    = help: items from traits can only be used if the trait is in scope
---
2020-03-07T06:22:56.3463404Z 
2020-03-07T06:22:56.3463625Z Some errors have detailed explanations: E0432, E0599.
2020-03-07T06:22:56.3464140Z For more information about an error, try `rustc --explain E0432`.
2020-03-07T06:22:56.3464544Z Couldn't compile the test.
2020-03-07T06:22:56.3464994Z ---- /tmp/mdbook-y11Qm8/destructors.md - Destructors (line 28) stdout ----
2020-03-07T06:22:56.3465318Z error[E0432]: unresolved import `std::alloc::Alloc`
2020-03-07T06:22:56.3465767Z  --> /tmp/mdbook-y11Qm8/destructors.md:31:18
2020-03-07T06:22:56.3467202Z 4 | use std::alloc::{Alloc, Global, GlobalAlloc, Layout};
2020-03-07T06:22:56.3467466Z   |                  ^^^^^
2020-03-07T06:22:56.3467848Z   |                  |
2020-03-07T06:22:56.3468059Z   |                  no `Alloc` in `alloc`
2020-03-07T06:22:56.3468059Z   |                  no `Alloc` in `alloc`
2020-03-07T06:22:56.3468786Z   |                  help: a similar name exists in the module: `alloc`
2020-03-07T06:22:56.3469033Z 
2020-03-07T06:22:56.3469368Z error[E0599]: no method named `dealloc` found for struct `std::alloc::Global` in the current scope
2020-03-07T06:22:56.3470036Z   --> /tmp/mdbook-y11Qm8/destructors.md:42:20
2020-03-07T06:22:56.3470538Z 15 |             Global.dealloc(c.cast(), Layout::new::<T>())
2020-03-07T06:22:56.3471101Z    |                    ^^^^^^^ method not found in `std::alloc::Global`
2020-03-07T06:22:56.3471388Z    |
2020-03-07T06:22:56.3471998Z    = help: items from traits can only be used if the trait is in scope
---
2020-03-07T06:22:56.3473581Z 
2020-03-07T06:22:56.3473780Z Some errors have detailed explanations: E0432, E0599.
2020-03-07T06:22:56.3474283Z For more information about an error, try `rustc --explain E0432`.
2020-03-07T06:22:56.3474660Z Couldn't compile the test.
2020-03-07T06:22:56.3475100Z ---- /tmp/mdbook-y11Qm8/destructors.md - Destructors (line 55) stdout ----
2020-03-07T06:22:56.3475412Z error[E0432]: unresolved import `std::alloc::Alloc`
2020-03-07T06:22:56.3476201Z  --> /tmp/mdbook-y11Qm8/destructors.md:58:18
2020-03-07T06:22:56.3476615Z 4 | use std::alloc::{Alloc, Global, GlobalAlloc, Layout};
2020-03-07T06:22:56.3476867Z   |                  ^^^^^
2020-03-07T06:22:56.3477043Z   |                  |
2020-03-07T06:22:56.3477262Z   |                  no `Alloc` in `alloc`
2020-03-07T06:22:56.3477262Z   |                  no `Alloc` in `alloc`
2020-03-07T06:22:56.3477561Z   |                  help: a similar name exists in the module: `alloc`
2020-03-07T06:22:56.3477974Z 
2020-03-07T06:22:56.3478445Z error[E0599]: no method named `dealloc` found for struct `std::alloc::Global` in the current scope
2020-03-07T06:22:56.3479043Z   --> /tmp/mdbook-y11Qm8/destructors.md:69:20
2020-03-07T06:22:56.3479529Z 15 |             Global.dealloc(c.cast(), Layout::new::<T>());
2020-03-07T06:22:56.3479918Z    |                    ^^^^^^^ method not found in `std::alloc::Global`
2020-03-07T06:22:56.3480208Z    |
2020-03-07T06:22:56.3480468Z    = help: items from traits can only be used if the trait is in scope
2020-03-07T06:22:56.3480468Z    = help: items from traits can only be used if the trait is in scope
2020-03-07T06:22:56.3480849Z help: the following trait is implemented but not in scope; perhaps add a `use` for it:
2020-03-07T06:22:56.3481135Z    |
2020-03-07T06:22:56.3481643Z 4  | use std::alloc::AllocRef;
2020-03-07T06:22:56.3481827Z    |
2020-03-07T06:22:56.3481917Z 
2020-03-07T06:22:56.3482303Z error[E0599]: no method named `dealloc` found for struct `std::alloc::Global` in the current scope
2020-03-07T06:22:56.3482840Z   --> /tmp/mdbook-y11Qm8/destructors.md:82:20
2020-03-07T06:22:56.3483345Z 28 |             Global.dealloc(c.cast::<u8>(), Layout::new::<T>());
2020-03-07T06:22:56.3483707Z    |                    ^^^^^^^ method not found in `std::alloc::Global`
2020-03-07T06:22:56.3483941Z    |
2020-03-07T06:22:56.3484170Z    = help: items from traits can only be used if the trait is in scope
---
2020-03-07T06:22:56.3486372Z For more information about an error, try `rustc --explain E0432`.
2020-03-07T06:22:56.3486782Z Couldn't compile the test.
2020-03-07T06:22:56.3486916Z 
2020-03-07T06:22:56.3487057Z failures:
2020-03-07T06:22:56.3487448Z     /tmp/mdbook-y11Qm8/destructors.md - Destructors (line 128)
2020-03-07T06:22:56.3488114Z     /tmp/mdbook-y11Qm8/destructors.md - Destructors (line 28)
2020-03-07T06:22:56.3488826Z     /tmp/mdbook-y11Qm8/destructors.md - Destructors (line 55)
2020-03-07T06:22:56.3489464Z test result: FAILED. 2 passed; 3 failed; 1 ignored; 0 measured; 0 filtered out
2020-03-07T06:22:56.3489714Z 
2020-03-07T06:22:56.3489811Z 
2020-03-07T06:22:56.3489966Z 
---
2020-03-07T06:22:56.3492801Z [TIMING] BookTest { compiler: Compiler { stage: 2, host: "x86_64-unknown-linux-gnu" }, path: "src/doc/nomicon", name: "nomicon", is_ext_doc: true } -- 6.718
2020-03-07T06:22:56.3493254Z Testing rustbook src/doc/reference
2020-03-07T06:23:12.3486892Z Error: Rustdoc returned an error: 
2020-03-07T06:23:12.3487208Z running 2 tests
2020-03-07T06:23:12.3488416Z test /tmp/mdbook-nsUu3Y/expressions/array-expr.md - Array_and_array_index_expressions::Array_and_slice_indexing_expressions (line 63) ... FAILED
2020-03-07T06:23:12.3489688Z test /tmp/mdbook-nsUu3Y/expressions/array-expr.md - Array_and_array_index_expressions::Array_expressions (line 27) ... ok
2020-03-07T06:23:12.3490356Z failures:
2020-03-07T06:23:12.3490470Z 
2020-03-07T06:23:12.3490470Z 
2020-03-07T06:23:12.3491095Z ---- /tmp/mdbook-nsUu3Y/expressions/array-expr.md - Array_and_array_index_expressions::Array_and_slice_indexing_expressions (line 63) stdout ----
2020-03-07T06:23:12.3491567Z error: this operation will panic at runtime
2020-03-07T06:23:12.3492272Z   --> /tmp/mdbook-nsUu3Y/expressions/array-expr.md:72:9
2020-03-07T06:23:12.3492959Z 11 | let x = (["a", "b"])[10]; // warning: index out of bounds
2020-03-07T06:23:12.3493352Z    |         ^^^^^^^^^^^^^^^^ index out of bounds: the len is 2 but the index is 10
2020-03-07T06:23:12.3493656Z    |
2020-03-07T06:23:12.3493878Z    = note: `#[deny(unconditional_panic)]` on by default
2020-03-07T06:23:12.3493878Z    = note: `#[deny(unconditional_panic)]` on by default
2020-03-07T06:23:12.3494088Z 
2020-03-07T06:23:12.3494281Z error: this operation will panic at runtime
2020-03-07T06:23:12.3494778Z   --> /tmp/mdbook-nsUu3Y/expressions/array-expr.md:78:1
2020-03-07T06:23:12.3495763Z 17 | arr[10];                  // warning: index out of bounds
2020-03-07T06:23:12.3496642Z    | ^^^^^^^ index out of bounds: the len is 2 but the index is 10
2020-03-07T06:23:12.3496914Z 
2020-03-07T06:23:12.3497133Z error: aborting due to 2 previous errors
2020-03-07T06:23:12.3497133Z error: aborting due to 2 previous errors
2020-03-07T06:23:12.3497341Z 
2020-03-07T06:23:12.3497704Z Couldn't compile the test.
2020-03-07T06:23:12.3498052Z 
2020-03-07T06:23:12.3498243Z failures:
2020-03-07T06:23:12.3499001Z     /tmp/mdbook-nsUu3Y/expressions/array-expr.md - Array_and_array_index_expressions::Array_and_slice_indexing_expressions (line 63)
2020-03-07T06:23:12.3500252Z test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
2020-03-07T06:23:12.3500488Z 
2020-03-07T06:23:12.3500579Z 
2020-03-07T06:23:12.3500732Z 
---
2020-03-07T06:25:48.4902574Z error: Unable to retrieve "http://www.ps.uni-sb.de/courses/typen-ws99/class.ps.gz": http://www.ps.uni-sb.de/courses/typen-ws99/class.ps.gz: timed out
2020-03-07T06:25:48.4903964Z 
2020-03-07T06:25:48.4904564Z     ┌── appendix/bibliography.md:11:3 ───
2020-03-07T06:25:48.4904941Z     │
2020-03-07T06:25:48.4905528Z  11 │ * [Typeclasses: making ad-hoc polymorphism less ad hoc](http://www.ps.uni-sb.de/courses/typen-ws99/class.ps.gz)
2020-03-07T06:25:48.4906547Z     │   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ http://www.ps.uni-sb.de/courses/typen-ws99/class.ps.gz: timed out
2020-03-07T06:25:48.4907700Z 
2020-03-07T06:25:48.5017159Z Building stage2 tool clippy-driver (x86_64-unknown-linux-gnu)
2020-03-07T06:25:48.7860902Z    Compiling proc-macro2 v0.4.30
2020-03-07T06:25:48.7861481Z    Compiling unicode-xid v0.1.0
---
2020-03-07T07:09:34.7548788Z Verifying status of rustc-guide...
2020-03-07T07:09:34.7601649Z Cloning into 'rust-toolstate'...
2020-03-07T07:09:35.3813440Z warning: Tool `nomicon` is not test-pass (is `test-fail`), this should be fixed before beta is branched.
2020-03-07T07:09:35.3814713Z warning: Tool `reference` is not test-pass (is `test-fail`), this should be fixed before beta is branched.
2020-03-07T07:09:35.3815622Z error: Tool `clippy-driver` has regressed from test-pass to build-fail during beta week.
2020-03-07T07:09:35.3823986Z Build completed unsuccessfully in 0:00:02
2020-03-07T07:09:35.3872848Z == clock drift check ==
2020-03-07T07:09:35.3883304Z   local time: Sat Mar  7 07:09:35 UTC 2020
2020-03-07T07:09:35.4596288Z   network time: Sat, 07 Mar 2020 07:09:35 GMT
2020-03-07T07:09:35.4596288Z   network time: Sat, 07 Mar 2020 07:09:35 GMT
2020-03-07T07:09:35.4598741Z == end clock drift check ==
2020-03-07T07:09:35.8007804Z 
2020-03-07T07:09:35.8089924Z ##[error]Bash exited with code '1'.
2020-03-07T07:09:35.8175192Z ##[section]Starting: Checkout rust-lang/rust@auto to s
2020-03-07T07:09:35.8180390Z ==============================================================================
2020-03-07T07:09:35.8180794Z Task         : Get sources
2020-03-07T07:09:35.8181219Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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
Copy link
Contributor

bors commented Mar 7, 2020

💔 Test failed - checks-azure

@bors bors 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 Centril closed this Mar 7, 2020
@Centril Centril deleted the rollup-pnopqvc branch March 7, 2020 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet