Commit Graph

107762 Commits

Author SHA1 Message Date
Mazdak Farrokhzad
ca90c3d0a7
Rollup merge of #69754 - Dylnuge:dylnuge/dep-version, r=Mark-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 #69751
2020-03-07 08:15:32 +01:00
Mazdak Farrokhzad
93a57cf3a8
Rollup merge of #69727 - JohnTitor:sugg-unwrap, r=estebank
Avoid using `unwrap()` in suggestions

Fixes #69725

r? @estebank
2020-03-07 08:15:30 +01:00
Mazdak Farrokhzad
b25fb9e79b
Rollup merge of #69706 - cuviper:subslice-methods, 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.
2020-03-07 08:15:29 +01:00
Mazdak Farrokhzad
ba1f6cbb00
Rollup merge of #69690 - thekuom:test/67311-extend-bindings-after-at-tests, r=Centril
test(pattern): add tests for combinations of pattern features

Reference issue #67311

Tests combinations of the following pattern features:
- bindings_after_at
- or_patterns
- slice_patterns
- box_patterns

r? @Centril
2020-03-07 08:15:28 +01:00
Mazdak Farrokhzad
e9c3ddc8df
Rollup merge of #69680 - petrochenkov:nont4, r=Centril
rustc_expand: Factor out `Annotatable::into_tokens` to a separate method

Minor refactoring salvaged from https://github.com/rust-lang/rust/pull/69594.
r? @Centril
2020-03-07 08:15:26 +01:00
Mazdak Farrokhzad
5d1433b1f4
Rollup merge of #69656 - matthiaskrgr:iter_nth_zero, r=oli-obk
Use .next() instead of .nth(0) on iterators.
2020-03-07 08:15:24 +01:00
Mazdak Farrokhzad
111724f5e2
Rollup merge of #68985 - daboross:fix-35813, r=Centril
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 #35813.
2020-03-07 08:15:21 +01:00
Mazdak Farrokhzad
e8bb6c05ab
Rollup merge of #67741 - estebank:point-at-pat-def, r=Centril
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 #55631, fix #48062, cc #42876.
2020-03-07 08:15:19 +01:00
Esteban Küber
125159f30a When encountering an Item in a pat context, point at the item def 2020-03-06 15:29:26 -08:00
Yuki Okushi
3d67649287
Add a regression test 2020-03-07 04:38:50 +09:00
Yuki Okushi
1631b4de1c
Avoid using unwrap() in suggestions 2020-03-07 04:24:13 +09:00
bors
2890b37b86 Auto merge of #69753 - pnkfelix:issue-69191-ice-on-uninhabited-enum-field, r=oli
Do not ICE when matching an uninhabited enum's field

Fix #69191
2020-03-06 17:52:52 +00:00
Vadim Petrochenkov
2d0c5b4337 rustc_expand: Factor out Annotatable::into_tokens to a separate method 2020-03-06 20:34:01 +03:00
Felix S. Klock II
b4422fb14b Added oli's multivariant test case (alpha renaming the enum name itself).
(And added Ralf's suggested test.)

Added my own three-variant multi-variant as well.
2020-03-06 06:46:37 -05:00
bors
865b44a3e3 Auto merge of #69614 - estebank:ice-age, r=davidtwco
`delay_span_bug` when codegen cannot select obligation

Fix #69602, introduced in #60126 by letting the compiler continue past
type checking after encountering errors.
2020-03-06 08:24:48 +00:00
Oliver Scherer
40809b0585
Add FIXME 2020-03-06 08:48:58 +01:00
Dylan Nugent
9afbf28ef6 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.
2020-03-05 21:55:36 -05:00
Felix S. Klock II
9712fa4059 Fix #69191 2020-03-05 21:53:26 -05:00
bors
4a1b69d53a Auto merge of #69586 - petrochenkov:unmerge, r=Centril
ast: Unmerge structures for associated items and foreign items

Follow-up to https://github.com/rust-lang/rust/pull/69194.
r? @Centril
2020-03-06 02:22:49 +00:00
bors
b818ccc74c Auto merge of #69746 - Dylan-DPC:rollup-wr6dvdk, r=Dylan-DPC
Rollup of 8 pull requests

Successful merges:

 - #69697 (Add explanation for E0380)
 - #69698 (Use associated constants of integer types)
 - #69711 (Update macros.rs: fix documentation typo.)
 - #69713 (more clippy cleanups)
 - #69728 (Make link to `std::str` active)
 - #69732 (Clean E0382 and E0384 explanations)
 - #69736 (even more clippy cleanups)
 - #69742 (Fixed a typo)

Failed merges:

r? @ghost
2020-03-05 21:39:00 +00:00
Dylan DPC
80c843431d
Rollup merge of #69742 - TrolledWoods:patch-1, r=jonas-schievink
Fixed a typo

"vector" was used instead of "string". I think this is a typo?
2020-03-05 22:04:12 +01:00
Dylan DPC
67d735c4bf
Rollup merge of #69736 - matthiaskrgr:even_more_clippy, r=Dylan-DPC
even more clippy cleanups

* Don't pass &mut where immutable reference (&) is sufficient (clippy::unnecessary_mut_passed)
* Use more efficient &&str to String conversion (clippy::inefficient_to_string)
* Don't always eval arguments inside .expect(), use unwrap_or_else and closure. (clippy::expect_fun_call)
* Use righthand '&' instead of lefthand "ref". (clippy::toplevel_ref_arg)
* Use simple 'for i in x' loops instead of 'while let Some(i) = x.next()' loops on iterators. (clippy::while_let_on_iterator)
* Const items have by default a static lifetime, there's no need to annotate it. (clippy::redundant_static_lifetimes)
* Remove redundant patterns when matching ( x @ _  to  x) (clippy::redundant_pattern)
2020-03-05 22:04:10 +01:00
Dylan DPC
558115b86c
Rollup merge of #69732 - GuillaumeGomez:cleanup-e0382-e0384, r=Dylan-DPC
Clean E0382 and E0384 explanations

r? @Dylan-DPC
2020-03-05 22:04:09 +01:00
Dylan DPC
7aac135dd7
Rollup merge of #69728 - LeSeulArtichaut:patch-1, r=steveklabnik
Make link to `std::str` active

Closes #69726.

r? @dtolnay
2020-03-05 22:04:07 +01:00
Dylan DPC
22a743bc1c
Rollup merge of #69713 - matthiaskrgr:more_cleanup, r=cramertj
more clippy cleanups

* Don't use .ok() before unwrapping via .expect() on a Result.
* Use .map() to modify data inside Options instead of using .and_then(|x| Some(y))
* Use .as_deref() instead of .as_ref().map(Deref::deref)
* Don't use "if let" bindings to only check a value and not actually bind anything.
* Use single-char patter on {ends,starts}_with and remove clone on copy type.
2020-03-05 22:04:05 +01:00
Dylan DPC
189626672d
Rollup merge of #69711 - penelopezone:patch-1, r=steveklabnik
Update macros.rs: fix documentation typo.
2020-03-05 22:04:04 +01:00
Dylan DPC
44f184acc0
Rollup merge of #69698 - RalfJung:int_assoc, r=davidtwco
Use associated constants of integer types

Take advantage of https://github.com/rust-lang/rust/pull/68952 in the interpreter and some nearby modules :)
2020-03-05 22:04:02 +01:00
Dylan DPC
e01dc83aa8
Rollup merge of #69697 - GuillaumeGomez:explanation-e0380, r=Dylan-DPC
Add explanation for E0380

r? @Dylan-DPC
2020-03-05 22:03:58 +01:00
TrolledWoods
79bc934ff3
Fixed a typo
"vector" was used instead of "string"
2020-03-05 20:20:02 +01:00
bors
96bb8b31c8 Auto merge of #67260 - TheSamsa:const-limit, r=oli-obk
const limit for CTFE

I tried to tackle the first steps for this issue.
The active feature flag does link to the issue below, I think this has to change, because there should be a tracking issue?
1679a7647d/src/librustc_feature/active.rs (L530)

Also, I only put up the storage of the limit like "recursion_limit" but created a seperate file in the same place. Since I guess the invocation happens seperately.
https://github.com/TheSamsa/rust/blob/const-limit/src/librustc/middle/const_limit.rs

If this does not hold up for the issue and since there is a time pressure, just reject it.

hopefully this does not put more load on you than I expected...
2020-03-05 17:46:58 +00:00
Matthias Krüger
84577c86bf Don't pass &mut where immutable reference (&) is sufficient (clippy::unnecessary_mut_passed) 2020-03-05 16:39:20 +01:00
Matthias Krüger
8ba92d9ce4 Use more efficient &&str to String conversion (clippy::inefficient_to_string) 2020-03-05 16:39:20 +01:00
Matthias Krüger
a1c3eb6043 Don't always eval arguments inside .expect(), use unwrap_or_else and closure. (clippy::expect_fun_call) 2020-03-05 16:39:20 +01:00
Matthias Krüger
3fc5c118dd Use righthand '&' instead of lefthand "ref". (clippy::toplevel_ref_arg) 2020-03-05 16:39:12 +01:00
Matthias Krüger
3e70c8ec2f Use simple 'for i in x' loops instead of 'while let Some(x) = x.next()' loops on iterators. (clippy::while_let_on_iterator) 2020-03-05 16:38:48 +01:00
Matthias Krüger
c2bbe3349f Const items have by default a static lifetime, there's no need to annotate it. (clippy::redundant_static_lifetimes) 2020-03-05 16:38:24 +01:00
Matthias Krüger
edd3e175d6 Remove redundant patterns when matching ( x @ _ to x) (clippy::redundant_pattern) 2020-03-05 16:30:43 +01:00
bors
c79f5f0647 Auto merge of #69692 - matthiaskrgr:submodule_upd, r=oli-obk
submodules: update clippy from 8b7f7e66 to 74eae9dc

Changes:
````
Rustup to rust-lang/rust#69506
Revive rls integration test
use question mark operator
Add regression test
Use `try_eval_usize` over `eval_usize`
Add path for display trait
Use lang items instead of get_trait_def_id where possible
Update stderr
Don't lint debug formatting in debug impl
Whitelist unused attribute for use items.
add test for #5238
````

Makes clippy tests pass again.

r? @oli-obk
2020-03-05 13:40:57 +00:00
Guillaume Gomez
6b28a8c46f Clean E0382 and E0384 explanations 2020-03-05 13:05:08 +01:00
LeSeulArtichaut
6ed4829c17
Make link to std::str active 2020-03-05 08:52:46 +01:00
Christoph Schmidler
527456e219 Bumped version number for const_eval_limit in active.rs
and renamed 'recursion_limit' in limits.rs to simple 'limit' because it does handle other limits too.
2020-03-05 08:10:39 +01:00
Christoph Schmidler
c94c74e2d9 Opt out of CTFE if the 'const_eval_limit' is set to 0 2020-03-05 08:09:52 +01:00
Christoph Schmidler
288e142737 Add a new test to reach const_limit setting, although with wrong WARNINGs yet
rename feature to const_eval_limit
2020-03-05 08:09:52 +01:00
Christoph Schmidler
ff38babc31 Disable CTFE if const_limit was set to 0, otherwise use the value set, which defaults to 1_000_000 2020-03-05 08:09:52 +01:00
Christoph Schmidler
337af5ef7a Prepare const_limit feature gate and attribute 2020-03-05 08:09:52 +01:00
bors
1e179690f8 Auto merge of #69717 - estebank:correctly-probe, r=varkor
Correctly reject `TraitCandidate` in all cases

Follow up to #69255, addresses #69629.

When `self.select_trait_candidate(trait_ref)` returned `Err(_)`, `result` wasn't being set to `NoMatch`, causing invalid methods to be selected.
2020-03-05 03:44:53 +00:00
Esteban Küber
8a3272985b Correctly reject TraitCandidate in all cases
Follow up to #69255, fix #69629.
2020-03-04 13:59:51 -08:00
Matthias Krüger
80ed505c41 Use single-char patter on {ends,starts}_with and remove clone on copy type.
These were introduced since I last fixed most of these occurences. (clippy::clone_on_copy, clippy::single_char_pattern)
2020-03-04 20:47:05 +01:00
Matthias Krüger
d8d2004c6f Don't use "if let" bindings to only check a value and not actually bind anything.
For example:  `if let Some(_) = foo() {}`	can be reduced to	`if foo().is_some() {}`   (clippy::redundant_pattern_matching)
2020-03-04 20:41:03 +01:00
Matthias Krüger
38f5db7268 Use .as_deref() instead of .as_ref().map(Deref::deref) (clippy::option_as_ref_deref) 2020-03-04 20:39:22 +01:00