Commit Graph

1167 Commits

Author SHA1 Message Date
Oliver Scherer
b2532a8730 Implement destructuring for all aggregates and for references 2020-09-20 13:28:18 +02:00
Oliver Scherer
b54f122a1c Merge tuple and struct pattern generation. 2020-09-20 12:31:37 +02:00
Bastian Kauschke
bfb221b21e array pattern 2020-09-20 08:11:05 +02:00
Bastian Kauschke
3435683fd5 use array_windows instead of windows in the compiler 2020-09-20 08:11:05 +02:00
ishitatsuyuki
7c98f6f584 Add fast path for match checking 2020-09-19 22:00:10 +09:00
Ralf Jung
4831523ac4
Rollup merge of #76757 - matthiaskrgr:clippy_try_into, r=lcnr
don't convert types to the same type with try_into (clippy::useless_conversion)
2020-09-19 11:47:52 +02:00
Matthias Krüger
40dddd3305 use matches!() macro for simple if let conditions 2020-09-18 20:28:35 +02:00
Matthias Krüger
f567287f9f don't convert types to the same type with try_into (clippy::useless_conversion) 2020-09-15 22:49:50 +02:00
Amjad Alsharafi
da700cba08 Stabilize move_ref_pattern 2020-09-15 14:23:05 +08:00
Aaron Hill
d18b4bb7a7
Note when a a move/borrow error is caused by a deref coercion
Fixes #73268

When a deref coercion occurs, we may end up with a move error if the
base value has been partially moved out of. However, we do not indicate
anywhere that a deref coercion is occuring, resulting in an error
message with a confusing span.

This PR adds an explicit note to move errors when a deref coercion is
involved. We mention the name of the type that the deref-coercion
resolved to, as well as the `Deref::Target` associated type being used.
2020-09-10 20:56:20 -04:00
bors
88197214b8 Auto merge of #75573 - Aaron1011:feature/const-mutation-lint, r=oli-obk
Add CONST_ITEM_MUTATION lint

Fixes #74053
Fixes #55721

This PR adds a new lint `CONST_ITEM_MUTATION`.
Given an item `const FOO: SomeType = ..`, this lint fires on:

* Attempting to write directly to a field (`FOO.field = some_val`) or
  array entry (`FOO.array_field[0] = val`)
* Taking a mutable reference to the `const` item (`&mut FOO`), including
  through an autoderef `FOO.some_mut_self_method()`

The lint message explains that since each use of a constant creates a
new temporary, the original `const` item will not be modified.
2020-09-10 05:54:26 +00:00
Aaron Hill
f422ef141a
Add CONST_ITEM_MUTATION lint
Fixes #74053
Fixes #55721

This PR adds a new lint `CONST_ITEM_MUTATION`.
Given an item `const FOO: SomeType = ..`, this lint fires on:

* Attempting to write directly to a field (`FOO.field = some_val`) or
  array entry (`FOO.array_field[0] = val`)
* Taking a mutable reference to the `const` item (`&mut FOO`), including
  through an autoderef `FOO.some_mut_self_method()`

The lint message explains that since each use of a constant creates a
new temporary, the original `const` item will not be modified.
2020-09-07 08:44:35 -04:00
Dylan DPC
acd33e1d14
Rollup merge of #76318 - scottmcm:one-control-flow, r=ecstatic-morse
Use ops::ControlFlow in rustc_data_structures::graph::iterate

Since I only know about this because you mentioned it,
r? @ecstatic-morse

If we're not supposed to use new `core` things in compiler for a while then feel free to close, but it felt reasonable to merge the two types since they're the same, and it might be convenient for people to use `?` in their traversal code.

(This doesn't do the type parameter swap; NoraCodes has signed up to do that one.)
2020-09-07 01:18:05 +02:00
LeSeulArtichaut
3e14b684dd Change ty.kind to a method 2020-09-04 17:47:51 +02:00
Scott McMurray
fac272688e Use ops::ControlFlow in graph::iterate 2020-09-04 01:45:10 -07:00
Dan Aloni
07e7823c01 pretty: trim paths of unique symbols
If a symbol name can only be imported from one place for a type, and
as long as it was not glob-imported anywhere in the current crate, we
can trim its printed path and print only the name.

This has wide implications on error messages with types, for example,
shortening `std::vec::Vec` to just `Vec`, as long as there is no other
`Vec` importable anywhere.

This adds a new '-Z trim-diagnostic-paths=false' option to control this
feature.

On the good path, with no diagnosis printed, we should try to avoid
issuing this query, so we need to prevent trimmed_def_paths query on
several cases.

This change also relies on a previous commit that differentiates
between `Debug` and `Display` on various rustc types, where the latter
is trimmed and presented to the user and the former is not.
2020-09-02 22:26:37 +03:00
mark
9e5f7d5631 mv compiler to compiler/ 2020-08-30 18:45:07 +03:00