]> git.lizzy.rs Git - rust.git/log
rust.git
5 years agorename `type_moves_by_default` to `type_is_copy_modulo_regions`
Niko Matsakis [Tue, 20 Nov 2018 16:59:06 +0000 (11:59 -0500)]
rename `type_moves_by_default` to `type_is_copy_modulo_regions`

5 years agotry to detect affected code and direct people to #56105
Niko Matsakis [Tue, 20 Nov 2018 16:20:05 +0000 (11:20 -0500)]
try to detect affected code and direct people to #56105

5 years agotrack if any region constraints involved placeholders
Niko Matsakis [Tue, 20 Nov 2018 15:24:38 +0000 (10:24 -0500)]
track if any region constraints involved placeholders

5 years agopacify the mercilous eddyb ;)
Niko Matsakis [Mon, 19 Nov 2018 16:57:22 +0000 (11:57 -0500)]
pacify the mercilous eddyb ;)

5 years agoadd some comments about lifetimes etc
Niko Matsakis [Mon, 19 Nov 2018 15:56:24 +0000 (10:56 -0500)]
add some comments about lifetimes etc

5 years agoaddress tmandry nits
Niko Matsakis [Mon, 19 Nov 2018 15:47:34 +0000 (10:47 -0500)]
address tmandry nits

5 years agopacify the mercilous tidy
Niko Matsakis [Mon, 19 Nov 2018 15:29:50 +0000 (10:29 -0500)]
pacify the mercilous tidy

5 years agoimprove handling for subtype
Niko Matsakis [Mon, 19 Nov 2018 15:26:04 +0000 (10:26 -0500)]
improve handling for subtype

Still not great, but good enough to land this PR.

5 years agosay "the lifetime" instead of "some lifetime" when it feels right
Niko Matsakis [Mon, 19 Nov 2018 00:13:37 +0000 (19:13 -0500)]
say "the lifetime" instead of "some lifetime" when it feels right

In particular, when we want to indicate that there is a connection
between the self type and the other types.

5 years agoapply the same logic to ConcreteFailure errors
Niko Matsakis [Mon, 19 Nov 2018 00:07:38 +0000 (19:07 -0500)]
apply the same logic to ConcreteFailure errors

5 years agorefactor highlighting to take any RegionKind, making it more general
Niko Matsakis [Sun, 18 Nov 2018 20:25:57 +0000 (15:25 -0500)]
refactor highlighting to take any RegionKind, making it more general

5 years agoapply the new placeholder errors even with just one placeholder
Niko Matsakis [Sun, 18 Nov 2018 18:25:53 +0000 (13:25 -0500)]
apply the new placeholder errors even with just one placeholder

5 years agointroduce placeholder-placeholder errors for trait matching
Niko Matsakis [Sat, 17 Nov 2018 13:18:37 +0000 (08:18 -0500)]
introduce placeholder-placeholder errors for trait matching

5 years agoadd the ability to highlight placeholders
Niko Matsakis [Sat, 17 Nov 2018 12:03:26 +0000 (07:03 -0500)]
add the ability to highlight placeholders

5 years agogeneralize region highlights into a struct
Niko Matsakis [Sat, 17 Nov 2018 11:27:44 +0000 (06:27 -0500)]
generalize region highlights into a struct

5 years agodump out the exact state in error reporting debugs
Niko Matsakis [Sat, 17 Nov 2018 11:10:30 +0000 (06:10 -0500)]
dump out the exact state in error reporting debugs

5 years agomake `get_highlight_region_for_regionvid` only affect re-vid
Niko Matsakis [Sat, 17 Nov 2018 00:13:55 +0000 (19:13 -0500)]
make `get_highlight_region_for_regionvid` only affect re-vid

In NLL, ReVid is all there is, but I might want to repurpose.

5 years agoremove outdated `rustc_driver` tests
Niko Matsakis [Wed, 31 Oct 2018 17:20:48 +0000 (13:20 -0400)]
remove outdated `rustc_driver` tests

they are subsumed by `hr-subtype/hr-subtype.rs` and other tests

5 years agoWIP other test changes
Niko Matsakis [Mon, 31 Dec 2018 18:45:48 +0000 (13:45 -0500)]
WIP other test changes

5 years agotests: cases where we now do the right thing but did not before
Niko Matsakis [Mon, 31 Dec 2018 18:45:40 +0000 (13:45 -0500)]
tests: cases where we now do the right thing but did not before

Fixes #33684

5 years agotests: worse diagnostics, but basically same errors
Niko Matsakis [Tue, 30 Oct 2018 20:57:52 +0000 (16:57 -0400)]
tests: worse diagnostics, but basically same errors

5 years agotests: move coherence-subtyping from run-pass to compile-fail
Niko Matsakis [Tue, 30 Oct 2018 20:39:29 +0000 (16:39 -0400)]
tests: move coherence-subtyping from run-pass to compile-fail

This is the pattern we no longer accept.

5 years agoadd tests exercising `exists<'a> { forall<'b> { .. } }` pattern
Niko Matsakis [Tue, 30 Oct 2018 20:38:50 +0000 (16:38 -0400)]
add tests exercising `exists<'a> { forall<'b> { .. } }` pattern

Amazingly, this scenario was not tested for trait matching.

5 years agouniverse transition
Niko Matsakis [Sat, 8 Sep 2018 00:11:23 +0000 (20:11 -0400)]
universe transition

Remove the leak-check and its associated machinery. Replace with
making the solver aware of universes.

5 years agoWIP: wfcheck ability to detect
Niko Matsakis [Thu, 27 Dec 2018 15:23:02 +0000 (10:23 -0500)]
WIP: wfcheck ability to detect

5 years agoselect.rs: unsizing coercion should use a subtype
Niko Matsakis [Thu, 27 Dec 2018 15:22:55 +0000 (10:22 -0500)]
select.rs: unsizing coercion should use a subtype

When we coerce `dyn Foo` to `dyn Bar`, that is OK as long as `Foo` is
usable in all contexts where `Bar` is usable (hence using the source
must be a subtype of the target).

This is needed for the universe-based code to handle
`old-lub-glb-object`; that test used to work sort of by accident
before with the old code.

5 years agointroduce ability to detect region constraints from snapshot
Niko Matsakis [Tue, 16 Oct 2018 09:42:18 +0000 (05:42 -0400)]
introduce ability to detect region constraints from snapshot

5 years agomake evaluation track whether outlives relationships mattered
Niko Matsakis [Thu, 20 Sep 2018 17:56:11 +0000 (13:56 -0400)]
make evaluation track whether outlives relationships mattered

Previously, evaluation ignored outlives relationships. Since we using
evaluation to skip the "normal" trait selection (which enforces
outlives relationships) this led to incorrect results in some cases.

5 years agoremove wrapper functions that had no purpose
Niko Matsakis [Mon, 15 Oct 2018 21:28:37 +0000 (17:28 -0400)]
remove wrapper functions that had no purpose

5 years agoremove `commit_if_ok` wrapper
Niko Matsakis [Mon, 15 Oct 2018 21:20:10 +0000 (17:20 -0400)]
remove `commit_if_ok` wrapper

5 years agoAuto merge of #57243 - dingelish:master, r=sfackler
bors [Wed, 2 Jan 2019 15:09:41 +0000 (15:09 +0000)]
Auto merge of #57243 - dingelish:master, r=sfackler

Bound sgx target_env with fortanix as target_vendor

This PR adds `target_vendor` check, as discussed in issue [57231](https://github.com/rust-lang/rust/issues/57231)

Signed-off-by: Yu Ding <dingelish@gmail.com>
5 years agoAuto merge of #57250 - codeworm96:tyerr_msg, r=varkor
bors [Wed, 2 Jan 2019 11:59:15 +0000 (11:59 +0000)]
Auto merge of #57250 - codeworm96:tyerr_msg, r=varkor

Improve type mismatch error messages

Closes #56115.

Replace "integral variable" with "integer" and replace "floating-point variable" with "floating-point number" to make the message less confusing.

TODO the book and clippy needs to be changed accordingly later.

r? @varkor

5 years agoAuto merge of #57251 - petrochenkov:reregr, r=varkor
bors [Wed, 2 Jan 2019 09:24:10 +0000 (09:24 +0000)]
Auto merge of #57251 - petrochenkov:reregr, r=varkor

syntax: Fix regression in diagnostics for patterns in trait method parameters

Fixes https://github.com/rust-lang/rust/issues/55036

5 years agoAuto merge of #56827 - faern:eliminate-recv-timeout-panic, r=KodrAus
bors [Wed, 2 Jan 2019 02:03:15 +0000 (02:03 +0000)]
Auto merge of #56827 - faern:eliminate-recv-timeout-panic, r=KodrAus

Eliminate Receiver::recv_timeout panic

Fixes #54552.

This panic is because `recv_timeout` uses `Instant::now() + timeout` internally. This possible panic is not mentioned in the documentation for this method.

Very recently we merged (still unstable) support for checked addition (#56490) of `Instant + Duration`, so it's now finally possible to add these together without risking a panic.

5 years agoAuto merge of #57209 - estebank:suggest-raw-ident, r=petrochenkov
bors [Tue, 1 Jan 2019 23:30:34 +0000 (23:30 +0000)]
Auto merge of #57209 - estebank:suggest-raw-ident, r=petrochenkov

Suggest using raw identifiers in 2018 edition when using keywords

5 years agoMerge remote-tracking branch 'upstream/master'
Yu Ding [Tue, 1 Jan 2019 22:55:33 +0000 (14:55 -0800)]
Merge remote-tracking branch 'upstream/master'

5 years agosyntax: Fix regression in diagnostics for patterns in trait method parameters
Vadim Petrochenkov [Tue, 1 Jan 2019 16:14:00 +0000 (19:14 +0300)]
syntax: Fix regression in diagnostics for patterns in trait method parameters

5 years agoAuto merge of #57125 - doitian:inconsistent-clone-doc, r=bluss
bors [Tue, 1 Jan 2019 20:50:13 +0000 (20:50 +0000)]
Auto merge of #57125 - doitian:inconsistent-clone-doc, r=bluss

Fix inconsistent Clone documentation.

Now, arrays of any size Clone if the element type is Clone. So remove the
the document that uses this as an example.

refs #57123

5 years agoRemove min_const_unsafe_fn since it is stable
Yu Ding [Tue, 1 Jan 2019 19:49:54 +0000 (11:49 -0800)]
Remove min_const_unsafe_fn since it is stable

Signed-off-by: Yu Ding <dingelish@gmail.com>
5 years agoAuto merge of #55937 - davidtwco:issue-54943, r=pnkfelix
bors [Tue, 1 Jan 2019 15:26:12 +0000 (15:26 +0000)]
Auto merge of #55937 - davidtwco:issue-54943, r=pnkfelix

NLL: User type annotations refactor, associated constant patterns and ref bindings.

Fixes #55511 and Fixes #55401. Contributes to #54943.

This PR performs a large refactoring on user type annotations, checks user type annotations for associated constants in patterns and that user type annotations for `ref` bindings are respected.

r? @nikomatsakis

5 years agoAuto merge of #57203 - nagisa:readme, r=Mark-Simulacrum
bors [Tue, 1 Jan 2019 11:47:58 +0000 (11:47 +0000)]
Auto merge of #57203 - nagisa:readme, r=Mark-Simulacrum

Remove mention of required memory to build

Because it, obviously, changes all the time and 600MiB is way out-of-date now.

5 years agoAuto merge of #57210 - estebank:str-err, r=zackmdavis
bors [Tue, 1 Jan 2019 09:10:23 +0000 (09:10 +0000)]
Auto merge of #57210 - estebank:str-err, r=zackmdavis

Tweak unicode escape diagnostics

5 years agoAuto merge of #57194 - matthiaskrgr:copyright_headers, r=Centril
bors [Tue, 1 Jan 2019 06:34:11 +0000 (06:34 +0000)]
Auto merge of #57194 - matthiaskrgr:copyright_headers, r=Centril

remove more copyright headers

r? @Mark-Simulacrum

5 years agoAuto merge of #57199 - petrochenkov:ambig, r=estebank
bors [Tue, 1 Jan 2019 02:08:39 +0000 (02:08 +0000)]
Auto merge of #57199 - petrochenkov:ambig, r=estebank

resolve: Simplify treatment of ambiguity errors

If we have a glob conflict like this
```rust
mod m1 { struct S; }
mod m2 { struct S; }

use m1::*;
use m2::*;
```
we treat it as a special "ambiguity item" that's not an error by itself, but produces an error when actually used.
```rust
use m1::*; // primary
use m2::*; // secondary

=>

ambiguity S(m1::S, m2::S);
```

Ambiguity items were *sometimes* treated as their primary items for error recovery, but pretty irregularly.

After this PR they are always treated as their primary items, except that
- If an ambiguity item is marked as used, then it still produces an error.
- Ambiguity items are still filtered away when exported to other crates (which is also a use in some sense).

5 years agoImprove type mismatch error messages
Yuning Zhang [Tue, 1 Jan 2019 01:43:08 +0000 (20:43 -0500)]
Improve type mismatch error messages

Replace "integral variable" with "integer" and replace
"floating-point variable" with "floating-point number" to make the
message less confusing.

5 years agoBound sgx target_env with fortanix as target_vendor
Yu Ding [Mon, 31 Dec 2018 23:45:42 +0000 (15:45 -0800)]
Bound sgx target_env with fortanix as target_vendor

Signed-off-by: Yu Ding <dingelish@gmail.com>
5 years agoAuto merge of #56878 - petrochenkov:privdyn, r=arielb1
bors [Mon, 31 Dec 2018 23:30:57 +0000 (23:30 +0000)]
Auto merge of #56878 - petrochenkov:privdyn, r=arielb1

privacy: Use common `DefId` visiting infrastructure for all privacy visitors

One repeating pattern in privacy checking is going through a type, visiting all `DefId`s inside it and doing something with them.
This is the case because visibilities and reachabilities are attached to `DefId`s.

Previously various privacy visitors visited types slightly differently using their own methods, with most recently written `TypePrivacyVisitor` being the "gold standard".
This mostly worked okay, but differences could manifest in overly conservative reachability analysis, some errors being reported twice, some private-in-public lints (not errors) being wrongly reported or not reported.

This PR does something that I wanted to do since https://github.com/rust-lang/rust/pull/32674#discussion_r58291608 - factoring out the common visiting logic!
Now all the common logic is contained in `struct DefIdVisitorSkeleton`, with specific privacy visitors deciding only what to do with visited `DefId`s (via `trait DefIdVisitor`).

A bunch of cleanups is also applied in the process.
This area is somewhat tricky due to lots of easily miss-able details, but thankfully it's was well covered by tests in https://github.com/rust-lang/rust/pull/46083 and previous PRs, so I'm relatively sure in the refactoring correctness.

Fixes https://github.com/rust-lang/rust/pull/56837#discussion_r241962239 in particular.
Also this will help with implementing https://github.com/rust-lang/rust/issues/48054.

5 years agoAddress review comments
Vadim Petrochenkov [Mon, 31 Dec 2018 00:02:40 +0000 (03:02 +0300)]
Address review comments

Say "trait" instead of "type" in diagnostics for `dyn Trait`

5 years agoprivacy: Use common `DefId` visiting infra for all privacy visitors
Vadim Petrochenkov [Sun, 16 Dec 2018 13:18:45 +0000 (16:18 +0300)]
privacy: Use common `DefId` visiting infra for all privacy visitors

5 years agoAuto merge of #57047 - euclio:field-structured-suggestions, r=estebank
bors [Mon, 31 Dec 2018 20:56:19 +0000 (20:56 +0000)]
Auto merge of #57047 - euclio:field-structured-suggestions, r=estebank

use structured suggestions for nonexistent fields

r? @estebank

5 years agoDo not use unicode character in diagnostic help
Esteban Küber [Mon, 31 Dec 2018 17:44:54 +0000 (09:44 -0800)]
Do not use unicode character in diagnostic help

5 years agouse structured suggestions for nonexistent fields
Andy Russell [Thu, 20 Dec 2018 23:10:46 +0000 (18:10 -0500)]
use structured suggestions for nonexistent fields

5 years agoUse structured suggestion for braceless unicode escape squence
Esteban Küber [Thu, 27 Dec 2018 19:21:47 +0000 (11:21 -0800)]
Use structured suggestion for braceless unicode escape squence

5 years agoAccount for `\xFF` and `\u{FF}` sequences in string format errors
Esteban Küber [Thu, 27 Dec 2018 18:40:06 +0000 (10:40 -0800)]
Account for `\xFF` and `\u{FF}` sequences in string format errors

5 years agoUpdate tests after rebase
Esteban Küber [Mon, 31 Dec 2018 16:41:05 +0000 (08:41 -0800)]
Update tests after rebase

5 years agoAddress review comments
Esteban Küber [Sun, 30 Dec 2018 19:52:15 +0000 (11:52 -0800)]
Address review comments

- Suggest raw ident escaping in all editions
- Keep primary label in all cases

5 years agoSuggest using raw identifiers in 2018 edition when using keywords
Esteban Küber [Sun, 30 Dec 2018 01:19:22 +0000 (17:19 -0800)]
Suggest using raw identifiers in 2018 edition when using keywords

5 years agoAuto merge of #57220 - quark-zju:mcount, r=estebank
bors [Mon, 31 Dec 2018 14:30:17 +0000 (14:30 +0000)]
Auto merge of #57220 - quark-zju:mcount, r=estebank

Add `-Z instrument-mcount`

This flag inserts `mcount` function call to the beginning of every function
after inline processing. So tracing tools like uftrace [1] (or ftrace for
Linux kernel modules) have a chance to examine function calls.

It is similar to the `-pg` flag provided by gcc or clang, but without
generating a `__gmon_start__` function for executables. If a program
runs without being traced, no `gmon.out` will be written to disk.

Under the hood, it simply adds `"instrument-function-entry-inlined"="mcount"`
attribute to every function. The `post-inline-ee-instrument` LLVM pass does
the actual job.

[1]: https://github.com/namhyung/uftrace

5 years agoFix inconsistent Clone documentation.
ian [Wed, 26 Dec 2018 05:01:30 +0000 (13:01 +0800)]
Fix inconsistent Clone documentation.

Use function pointer as the example to demonstrate how to implement Clone for
Copy types.

refs #57123

5 years agoAuto merge of #57061 - Zoxc:graph-refactor, r=michaelwoerister
bors [Mon, 31 Dec 2018 10:55:46 +0000 (10:55 +0000)]
Auto merge of #57061 - Zoxc:graph-refactor, r=michaelwoerister

Group dep node data into a single structure

r? @michaelwoerister

5 years agoAddress comments
John Kåre Alsaker [Mon, 31 Dec 2018 08:14:09 +0000 (09:14 +0100)]
Address comments

5 years agoUse `entry` API to avoid double lookup when interning dep nodes
John Kåre Alsaker [Sun, 23 Dec 2018 04:54:10 +0000 (05:54 +0100)]
Use `entry` API to avoid double lookup when interning dep nodes

5 years agoGroup dep node data into a single structure
John Kåre Alsaker [Sat, 22 Dec 2018 11:40:23 +0000 (12:40 +0100)]
Group dep node data into a single structure

5 years agoAuto merge of #57208 - estebank:issue-57198, r=petrochenkov
bors [Mon, 31 Dec 2018 08:06:15 +0000 (08:06 +0000)]
Auto merge of #57208 - estebank:issue-57198, r=petrochenkov

Do not complain about missing crate named as a keyword

Fix #57198.

5 years agoAuto merge of #57044 - varkor:E0512-equal-type, r=matthewjasper
bors [Mon, 31 Dec 2018 04:06:14 +0000 (04:06 +0000)]
Auto merge of #57044 - varkor:E0512-equal-type, r=matthewjasper

Add specific diagnostic when attempting to transmute between equal generic types

Also clarifies the wording of E0512.

Fixes https://github.com/rust-lang/rust/issues/49793.

5 years agoAuto merge of #57035 - Zoxc:query-pref9, r=michaelwoerister
bors [Mon, 31 Dec 2018 01:18:19 +0000 (01:18 +0000)]
Auto merge of #57035 - Zoxc:query-pref9, r=michaelwoerister

Uninline some debugging code and use unlikely! macro

r? @michaelwoerister

5 years agoFix variable string size problem in transmute test
varkor [Sun, 30 Dec 2018 09:56:59 +0000 (09:56 +0000)]
Fix variable string size problem in transmute test

5 years agoAddress review comments: Remove new `PathResult` variant
Esteban Küber [Sun, 30 Dec 2018 20:19:16 +0000 (12:19 -0800)]
Address review comments: Remove new `PathResult` variant

5 years agoAdd `-Z instrument-mcount`
Jun Wu [Sun, 30 Dec 2018 19:59:03 +0000 (11:59 -0800)]
Add `-Z instrument-mcount`

This flag inserts `mcount` function call to the beginning of every function
after inline processing. So tracing tools like uftrace [1] (or ftrace for
Linux kernel modules) have a chance to examine function calls.

It is similar to the `-pg` flag provided by gcc or clang, but without
generating a `__gmon_start__` function for executables. If a program
runs without being traced, no `gmon.out` will be written to disk.

Under the hood, it simply adds `"instrument-function-entry-inlined"="mcount"`
attribute to every function. The `post-inline-ee-instrument` LLVM pass does
the actual job.

[1]: https://github.com/namhyung/uftrace

5 years agoAuto merge of #57213 - matthiaskrgr:clippy_submodule_upd, r=oli-obk
bors [Sun, 30 Dec 2018 18:49:01 +0000 (18:49 +0000)]
Auto merge of #57213 - matthiaskrgr:clippy_submodule_upd, r=oli-obk

submodules: update clippy from f7bdf500 to 39bd8449

Fixes clippy toolstate

Changes:
````
UI test cleanup: Extract iter_skip_next from methods.rs
Update test output after rebase
Remove false negatives from known problems
Implement use_self for tuple structs
Document known problems
rustup https://github.com/rust-lang/rust/pull/56225/
Remove unnecessary `use` statements after `cargo fix`
Apply cargo fix --edition-idioms fixes
Use match ergonomics for booleans lint
Use match ergonomics for block_in_if_condition lint
Use match ergonomics for bit_mask lint
Use match ergonomics for attrs lint
Use match ergonomics for assign_ops lint
Use match ergonomics for artithmetic lint
Use match ergonomics for approx_const lint
Remove crate:: prefixes from crate paths
Support array indexing expressions in unused write to a constant
Mark writes to constants as side-effect-less
Update README local run command to remove syspath
Remove unsafe from consts clippy lints
Fix formatting
Merge new_without_default_derive into new_without_default
Only print out question_mark lint when it actually triggered
Add failing test
Reinserted commata
Recomend `.as_ref()?` in certain situations
Deduplicate some code?
````
r? @oli-obk or anyone else

5 years agosubmodules: update clippy from f7bdf500 to 39bd8449
Matthias Krüger [Sun, 30 Dec 2018 17:16:09 +0000 (18:16 +0100)]
submodules: update clippy from f7bdf500 to 39bd8449

Changes:
````
UI test cleanup: Extract iter_skip_next from methods.rs
Update test output after rebase
Remove false negatives from known problems
Implement use_self for tuple structs
Document known problems
rustup https://github.com/rust-lang/rust/pull/56225/
Remove unnecessary `use` statements after `cargo fix`
Apply cargo fix --edition-idioms fixes
Use match ergonomics for booleans lint
Use match ergonomics for block_in_if_condition lint
Use match ergonomics for bit_mask lint
Use match ergonomics for attrs lint
Use match ergonomics for assign_ops lint
Use match ergonomics for artithmetic lint
Use match ergonomics for approx_const lint
Remove crate:: prefixes from crate paths
Support array indexing expressions in unused write to a constant
Mark writes to constants as side-effect-less
Update README local run command to remove syspath
Remove unsafe from consts clippy lints
Fix formatting
Merge new_without_default_derive into new_without_default
Only print out question_mark lint when it actually triggered
Add failing test
Reinserted commata
Recomend `.as_ref()?` in certain situations
Deduplicate some code?
````

5 years agoAuto merge of #57205 - petrochenkov:extrecov, r=estebank
bors [Sun, 30 Dec 2018 16:06:30 +0000 (16:06 +0000)]
Auto merge of #57205 - petrochenkov:extrecov, r=estebank

Improve error recovery for some built-in macros

Fixes https://github.com/rust-lang/rust/issues/55897

5 years agoGuarantee `rustc_dump_user_substs` error order.
David Wood [Sat, 22 Dec 2018 14:32:44 +0000 (15:32 +0100)]
Guarantee `rustc_dump_user_substs` error order.

This commit buffers the errors output by the `rustc_dump_user_substs`
attribute so that they can be output in order of span and would
therefore be consistent.

5 years agoStop duplicating projections of type annotation.
David Wood [Wed, 19 Dec 2018 15:47:06 +0000 (16:47 +0100)]
Stop duplicating projections of type annotation.

This commit changes how type annotations are handled in bindings during
MIR building.

Instead of building up a `PatternTypeProjections` with the
`CanonicalUserTypeAnnotation` and projections, the
`CanonicalUserTypeAnnotation` is stored in the
`canonical_user_type_annotations` map at the start and the (equivalent)
`UserTypeProjections` is built up with the new index and same projections.

This has the effect of deduplicating type annotations as instead of type
annotations being added to the `canonical_user_type_annotations` map
multiple times at the end after being duplicated (which happens in building
up `PatternTypeProjections`), it is instead added once.

5 years agoStop well-formedness checking unreachable code.
David Wood [Tue, 18 Dec 2018 20:27:22 +0000 (21:27 +0100)]
Stop well-formedness checking unreachable code.

This commit stops well-formedness checking applying to unreachable code
and therefore stops some of the ICEs that the intended solution taken by
this PR causes.

By disabling these checks, we can land the other fixes and larger
refactors that this PR includes.

5 years agoFix unresolved inference variable ICE.
David Wood [Sun, 9 Dec 2018 02:07:31 +0000 (03:07 +0100)]
Fix unresolved inference variable ICE.

This commit moves well-formedness check for the
`UserTypeAnnotation::Ty(..)` case from always running to only when the
code is reachable. This solves the ICE that resulted from
`src/test/ui/issue-54943-1.rs` (a minimal repro of `dropck-eyepatch`
run-pass tests that failed).

The main well-formedness check that was intended to be run despite
unreachable code still is, that being the
`UserTypeAnnotation::TypeOf(..)` case. Before this PR, the other case
wasn't being checked at all.

It is possible to fix this ICE while still always checking
well-formedness for the `UserTypeAnnotation::Ty(..)` case but that
solution will ICE in unreachable code for that case, the diff for
that change [can be found here](0).

[0]: https://gist.github.com/davidtwco/f9751ffd9c0508f7251c0f17adc3af53

5 years agoAdd explicit error annotations to test.
David Wood [Fri, 7 Dec 2018 23:50:35 +0000 (00:50 +0100)]
Add explicit error annotations to test.

This commit adds explicit error annotations to tests after rebasing
which is now required.

5 years agoSupport user type annotations in `ref` bindings.
David Wood [Sun, 25 Nov 2018 14:14:39 +0000 (15:14 +0100)]
Support user type annotations in `ref` bindings.

This commit adds support for user type annotations in variables declared
using `ref` bindings. When a variable declared using a `ref` binding,
then the `LocalDecl` has the type `&T` where the `&` was introduced by
the `ref` binding but the canonicalized type annotation has only a
`T` since the reference is implicit with the `ref` binding.

Therefore, to support type annotations, the canonicalized type
annotation either needs wrapped in a reference, or the `LocalDecl` type
must have a wrapped reference removed for comparison. It is easier to
remove the outer reference from the `LocalDecl` for the purpose of
comparison, so that is the approach this commit takes.

5 years agoAdd user type annotations to MIR dump.
David Wood [Sun, 25 Nov 2018 12:31:34 +0000 (13:31 +0100)]
Add user type annotations to MIR dump.

This commit writes the user type annotations to the MIR dump so that
they are visible again.

5 years agoType annotations in associated constant patterns.
David Wood [Sat, 24 Nov 2018 11:56:24 +0000 (12:56 +0100)]
Type annotations in associated constant patterns.

This commit adds support for respecting user type annotations with
associated constants in patterns.

5 years agoAdd test for unreachable well-formedness.
David Wood [Fri, 23 Nov 2018 10:55:09 +0000 (11:55 +0100)]
Add test for unreachable well-formedness.

This commit adds a test for checking that types are well-formed when
unreachable.

5 years agoAlways check well-formedness.
David Wood [Thu, 22 Nov 2018 19:35:24 +0000 (20:35 +0100)]
Always check well-formedness.

This commit uses the map introduced by the previous commit to ensure
that types are always checked for well-formedness by the NLL type check.
Previously, without the map introduced by the previous commit, types
would not be checked for well-formedness if the `AscribeUserType`
statement that would trigger that check was removed as unreachable code.

5 years agoRefactor `UserTypeAnnotation`.
David Wood [Fri, 16 Nov 2018 21:56:18 +0000 (22:56 +0100)]
Refactor `UserTypeAnnotation`.

This commit refactors the `UserTypeAnnotation` type to be referred to by
an index within `UserTypeProjection`. `UserTypeAnnotation` is instead
kept in an `IndexVec` within the `Mir` struct.

Further, instead of `UserTypeAnnotation` containing canonicalized types,
it now contains normal types and the entire `UserTypeAnnotation` is
canonicalized. To support this, the type was moved from the `rustc::mir`
module to `rustc::ty` module.

5 years agoAuto merge of #57204 - czipperz:ord_docs_must_agree, r=sfackler
bors [Sun, 30 Dec 2018 13:24:11 +0000 (13:24 +0000)]
Auto merge of #57204 - czipperz:ord_docs_must_agree, r=sfackler

Make std::cmp::Ord documentation specify what it means to agree with ParitalEq

Resolves #57157

5 years agoAuto merge of #57158 - estebank:as-ref, r=zackmdavis
bors [Sun, 30 Dec 2018 09:51:44 +0000 (09:51 +0000)]
Auto merge of #57158 - estebank:as-ref, r=zackmdavis

Suggest `.as_ref()` when appropriate for `Option` and `Result`

Fix #55198.

5 years agoAuto merge of #57195 - czipperz:mention_ToString_in_std_fmt_docs, r=SimonSapin
bors [Sun, 30 Dec 2018 07:12:13 +0000 (07:12 +0000)]
Auto merge of #57195 - czipperz:mention_ToString_in_std_fmt_docs, r=SimonSapin

Mention ToString in std::fmt docs

I believe this should be added because `x.to_string()` is preferred over `format!("{}", x)` as the recommended way to convert a value to a string.  `std::fmt` and the `format` macro is where people look for documentation about this, and thus we should include references to this preferred functions there.

Resolves #55065

5 years agoAuto merge of #57185 - petrochenkov:impice4, r=estebank
bors [Sun, 30 Dec 2018 03:12:16 +0000 (03:12 +0000)]
Auto merge of #57185 - petrochenkov:impice4, r=estebank

resolve: Fix one more ICE in import validation

So if you have an unresolved import
```rust
mod m {
    use foo::bar;
}
```
error recovery will insert a special item with `Def::Err` definition into module `m`, so other things depending on `bar` won't produce extra errors.

The issue was that erroneous `bar` was overwriting legitimate `bar`s coming from globs, e.g.
```rust
mod m {
    use baz::*; // imports real existing `bar`
    use foo::bar;
}
```
causing some unwanted diagnostics talking about "unresolved items", and producing inconsistent resolutions like https://github.com/rust-lang/rust/issues/57015.
This PR stops overwriting real successful resolutions with `Def::Err`s.

Fixes https://github.com/rust-lang/rust/issues/57015

5 years agoDo not complain about missing crate named as a keyword
Esteban Küber [Sun, 30 Dec 2018 00:35:57 +0000 (16:35 -0800)]
Do not complain about missing crate named as a keyword

5 years agoMention ToString in std::fmt docs
Czipperz [Sat, 29 Dec 2018 07:54:05 +0000 (02:54 -0500)]
Mention ToString in std::fmt docs

5 years agoSpecify criterion for PartialOrd
Czipperz [Sun, 30 Dec 2018 00:14:06 +0000 (19:14 -0500)]
Specify criterion for PartialOrd

5 years agoAuto merge of #56843 - csmoe:non-copy, r=davidtwco
bors [Sat, 29 Dec 2018 23:45:45 +0000 (23:45 +0000)]
Auto merge of #56843 - csmoe:non-copy, r=davidtwco

Add a note describing the type of the non-Copy moved variable

Closes #56654
r?@davidtwco

5 years agoMake std::cmp::Ord documentation specify what it means to agree with PartialEq
Czipperz [Sat, 29 Dec 2018 22:48:43 +0000 (17:48 -0500)]
Make std::cmp::Ord documentation specify what it means to agree with PartialEq

5 years agoImprove error recovery for some built-in macros
Vadim Petrochenkov [Sat, 29 Dec 2018 21:56:55 +0000 (00:56 +0300)]
Improve error recovery for some built-in macros

5 years agoRemove mention of required memory to build
Simonas Kazlauskas [Sat, 29 Dec 2018 22:15:42 +0000 (00:15 +0200)]
Remove mention of required memory to build

Because it, obviously, changes all the time and 600MiB is way
out-of-date now.

5 years agoAuto merge of #56225 - alexreg:type_alias_enum_variants, r=petrochenkov
bors [Sat, 29 Dec 2018 21:03:11 +0000 (21:03 +0000)]
Auto merge of #56225 - alexreg:type_alias_enum_variants, r=petrochenkov

Implement RFC 2338, "Type alias enum variants"

This PR implements [RFC 2338](https://github.com/rust-lang/rfcs/pull/2338), allowing one to write code like the following.

```rust
#![feature(type_alias_enum_variants)]

enum Foo {
    Bar(i32),
    Baz { i: i32 },
}

type Alias = Foo;

fn main() {
    let t = Alias::Bar(0);
    let t = Alias::Baz { i: 0 };
    match t {
        Alias::Bar(_i) => {}
        Alias::Baz { i: _i } => {}
    }
}
```

Since `Self` can be considered a type alias in this context, it also enables using `Self::Variant` as both a constructor and pattern.

Fixes issues #56199 and #56611.

N.B., after discussing the syntax for type arguments on enum variants with @petrochenkov and @eddyb (there are also a few comments on the [tracking issue](https://github.com/rust-lang/rust/issues/49683)), the consensus seems to be treat the syntax as follows, which ought to be backwards-compatible.

```rust
Option::<u8>::None; // OK
Option::None::<u8>; // OK, but lint in near future (hard error next edition?)
Alias::<u8>::None; // OK
Alias::None::<u8>; // Error
```

I do not know if this will need an FCP, but let's start one if so.

5 years agoUse `same_type` instead of duplicating logic
Esteban Küber [Sat, 29 Dec 2018 18:54:32 +0000 (10:54 -0800)]
Use `same_type` instead of duplicating logic

5 years agoAuto merge of #57197 - kennytm:rollup, r=kennytm
bors [Sat, 29 Dec 2018 18:12:57 +0000 (18:12 +0000)]
Auto merge of #57197 - kennytm:rollup, r=kennytm

Rollup of 7 pull requests

Successful merges:

 - #57149 (Fix typo in pin documentation)
 - #57153 (Small: Fix span in char documentation)
 - #57159 (Update references to closed issue)
 - #57163 (Give the crate select chevron room to breathe.)
 - #57168 (Removed aligned ZST requirement from docs of read_/write_unaligned.)
 - #57174 (Update link to rustc guide)
 - #57177 (Fix warning when compiling rustc)

Failed merges:

r? @ghost

5 years agoresolve: Simplify treatment of ambiguity errors
Vadim Petrochenkov [Sat, 29 Dec 2018 15:15:29 +0000 (18:15 +0300)]
resolve: Simplify treatment of ambiguity errors

5 years agoAuto merge of #56924 - ehuss:update-cargo-rls-miri, r=alexcrichton
bors [Sat, 29 Dec 2018 15:35:59 +0000 (15:35 +0000)]
Auto merge of #56924 - ehuss:update-cargo-rls-miri, r=alexcrichton

Update cargo, rls, miri

Update cargo, rls, miri

Added `rustc-workspace-hack` to miri so that it shares the same features for serde as other tools.

cc @alexcrichton

## cargo

25 commits in 2cf1f5dda2f7ed84e94c4d32f643e0f1f15352f0..0d1f1bbeabd5b43a7f3ecfa16540af8e76d5efb4
2018-12-11 03:44:04 +0000 to 2018-12-19 14:45:14 +0000
- Remove Stale bot's configuration (rust-lang/cargo#6463)
- Add labels to issue templates (rust-lang/cargo#6464)
- Fix new man page links. (rust-lang/cargo#6459)
- Fix metabuild compile errors with --message-format=json. (rust-lang/cargo#6432)
- Support alt-registry names in [patch] table. (rust-lang/cargo#6456)
- Update the rustup URL (rust-lang/cargo#6455)
- New man pages. (rust-lang/cargo#6405)
- Reify the DepFingerprint type (rust-lang/cargo#6451)
- Extract Fingerprint::new (rust-lang/cargo#6449)
- Upgrade the metabuild to Rust 2018 (rust-lang/cargo#6448)
- Make edition comparing code consistent (rust-lang/cargo#6450)
- Document `name` and `authors` in [package] (rust-lang/cargo#6447)
- Travis: only use mdbook 0.1.7. (rust-lang/cargo#6443)
- Update git2-curl requirement from 0.8.1 to 0.9.0 (rust-lang/cargo#6439)
- Update git2 requirement from 0.7.5 to 0.8.0 (rust-lang/cargo#6438)
- Display errors when `cargo fix` fails. (rust-lang/cargo#6419)
- cargo fix: fix targets with shared sources. (rust-lang/cargo#6434)
- Fix panic-in-panic in tests. (rust-lang/cargo#6431)
- More Rust 2018 edition cleanups (rust-lang/cargo#6422)
- Cleanup some trait impls for SourceId (rust-lang/cargo#6429)
- Remove a nightly check from doc tests (rust-lang/cargo#6427)
- Replace CargoError with failure::Error (rust-lang/cargo#6425)
- Allow testsuite warnings in dev (rust-lang/cargo#6426)
- add `--dry-run` option to cargo update (rust-lang/cargo#6371)
- Migrate to some Rust 2018 idioms (rust-lang/cargo#6416)

## rls

16 commits in bd5b899afb05e14d33e210ede3da241ca1ca088f..6f5e4bba7b1586fca6e0ea7724cadb5683b2f308
2018-12-10 08:53:00 +0100 to 2018-12-21 17:11:08 +0100
- Update jsonrpc-core (rust-lang-nursery/rls#1206)
- Use `home_dir` from `home` crate (rust-lang-nursery/rls#1207)
- Update cargo. (rust-lang-nursery/rls#1204)
- Fix deprecated `trim_{left,right}` warnings (rust-lang-nursery/rls#1203)
- Respect ${CARGO,RUSTUP}_HOME for tooltip relative dirs (rust-lang-nursery/rls#1201)
- Separate tooltip tests that require Racer fallback (rust-lang-nursery/rls#1200)
- tests: Don't generate tooltip results in tests/fixtures (rust-lang-nursery/rls#1199)
- Overhaul fixture handling in tests (rust-lang-nursery/rls#1190)
- Don't return symbols with empty names (rust-lang-nursery/rls#1193)
- Don't check AppVeyor CI status for bors
- Properly infer full_docs (rust-lang-nursery/rls#1192)
- Update cargo (rust-lang-nursery/rls#1191)
- Improve hover test_tooltip tests (rust-lang-nursery/rls#1175)
- Fix unused warnings (rust-lang-nursery/rls#1185)
- Workaround rust-lang-nursery/rls#703 to prevent obscure failures due to sccache. (rust-lang-nursery/rls#1177)
- Disable travis cache (rust-lang-nursery/rls#1182)

## miri

14 commits in bccadeb4f7cbeeb14097a365653148afe8bbd159..6c2fc6daf1ac6849d1243b213f5a3fb07feeef29
2018-12-08 11:07:22 +0100 to 2018-12-26 14:28:25 +0100
- use memory::check_bounds_ptr for offset check (solson/miri#589)
- Fix comparing function pointers (solson/miri#587)
- fix for infallible allocation (solson/miri#586)
- fix test for latest nightly (solson/miri#585)
- Treat ref-to-raw cast like a reborrow: do a special kind of retag (solson/miri#572)
- Test cargo-miri on Windows (solson/miri#578)
- Cargo miri tweaks and test that we can exclude tests (solson/miri#580)
- Fix cargo miri test (solson/miri#550)
- fix for latest nightly (solson/miri#574)
- Add rustc-workspace-hack. (solson/miri#575)
- use RUSTC_WRAPPER for the cargo hook (solson/miri#573)
- do not auto-detect the targets in the sysroot, instead specify target manually through env var (solson/miri#570)
- Cleanup: Avoid repeating signatures, get rid of to_bytes hack (solson/miri#568)
- Support building and running with full MIR on foreign architectures, drop support for missing MIR (solson/miri#566)

5 years agoAuto merge of #57181 - petrochenkov:impice3, r=estebank
bors [Sat, 29 Dec 2018 12:55:48 +0000 (12:55 +0000)]
Auto merge of #57181 - petrochenkov:impice3, r=estebank

resolve: Fix another ICE in import validation

Imports are allowed to have ambiguous resolutions as long as all of them have same `Def`.
As it turned out, it's possible for different `Module`s to have same `Def` when `extern crate` items are involved.

Fixes https://github.com/rust-lang/rust/issues/56596