Commit Graph

4640 Commits

Author SHA1 Message Date
Esteban Küber
7451cd8dc0 Deduplicate mismatched delimiter errors
Delay unmatched delimiter errors until after the parser has run to
deduplicate them when parsing and attempt recovering intelligently.
2019-02-07 01:41:30 -08:00
bors
825f355c74 Auto merge of #57998 - niklasf:align-enum, r=nagisa
Allow #[repr(align(x))] on enums (#57996)

Tracking issue: #57996

Implements an extension of [RFC 1358](https://github.com/rust-lang/rfcs/blob/master/text/1358-repr-align.md) behind a feature flag (`repr_align_enum`). Originally introduced here for structs: #39999.

It seems like only HIR-level changes are required, since enums are already aware of their alignment (due to alignment of their limbs).

cc @bitshifter
2019-02-07 04:26:08 +00:00
David Wood
6717727fcb
Lower constant patterns with ascribed types.
This commit fixes a bug introduced by #55937 which started checking user
type annotations for associated type patterns. Where lowering a
associated constant expression would previously return a
`PatternKind::Constant`, it now returns a `PatternKind::AscribeUserType`
with a `PatternKind::Constant` inside, this commit unwraps that to
access the constant pattern inside and behaves as before.
2019-02-06 21:10:43 +01:00
Clint Frederickson
d4c52bfb17 error output updated by ./x.py test --stage 1 src/test/ui --incremental --bless 2019-02-06 08:42:21 -07:00
bors
b139669f37 Auto merge of #56123 - oli-obk:import_miri_from_future, r=eddyb
Add a forever unstable opt-out of const qualification checks

r? @eddyb

cc @RalfJung @Centril

basically a forever unstable way to screw with const things in horribly unsafe, unsound and incoherent ways.

Note that this does *not* affect miri except by maybe violating assumptions that miri makes. But there's no change in how miri evaluates things.
2019-02-06 08:42:46 +00:00
bors
2596bc1368 Auto merge of #58061 - nnethercote:overhaul-syntax-Folder, r=petrochenkov
Overhaul `syntax::fold::Folder`.

This PR changes `syntax::fold::Folder` from a functional style
(where most methods take a `T` and produce a new `T`) to a more
imperative style (where most methods take and modify a `&mut T`), and
renames it `syntax::mut_visit::MutVisitor`.

This makes the code faster and more concise.
2019-02-06 06:01:37 +00:00
Nicholas Nethercote
9fcb1658ab Overhaul syntax::fold::Folder.
This commit changes `syntax::fold::Folder` from a functional style
(where most methods take a `T` and produce a new `T`) to a more
imperative style (where most methods take and modify a `&mut T`), and
renames it `syntax::mut_visit::MutVisitor`.

The first benefit is speed. The functional style does not require any
reallocations, due to the use of `P::map` and
`MoveMap::move_{,flat_}map`. However, every field in the AST must be
overwritten; even those fields that are unchanged are overwritten with
the same value. This causes a lot of unnecessary memory writes. The
imperative style reduces instruction counts by 1--3% across a wide range
of workloads, particularly incremental workloads.

The second benefit is conciseness; the imperative style is usually more
concise. E.g. compare the old functional style:
```
fn fold_abc(&mut self, abc: ABC) {
    ABC {
        a: fold_a(abc.a),
        b: fold_b(abc.b),
        c: abc.c,
    }
}
```
with the imperative style:
```
fn visit_abc(&mut self, ABC { a, b, c: _ }: &mut ABC) {
    visit_a(a);
    visit_b(b);
}
```
(The reductions get larger in more complex examples.)

Overall, the patch removes over 200 lines of code -- even though the new
code has more comments -- and a lot of the remaining lines have fewer
characters.

Some notes:

- The old style used methods called `fold_*`. The new style mostly uses
  methods called `visit_*`, but there are a few methods that map a `T`
  to something other than a `T`, which are called `flat_map_*` (`T` maps
  to multiple `T`s) or `filter_map_*` (`T` maps to 0 or 1 `T`s).

- `move_map.rs`/`MoveMap`/`move_map`/`move_flat_map` are renamed
  `map_in_place.rs`/`MapInPlace`/`map_in_place`/`flat_map_in_place` to
  reflect their slightly changed signatures.

- Although this commit renames the `fold` module as `mut_visit`, it
  keeps it in the `fold.rs` file, so as not to confuse git. The next
  commit will rename the file.
2019-02-06 09:06:27 +11:00
Clint Frederickson
a15916b245 [WIP] add better error message for partial move 2019-02-05 13:56:29 -07:00
Andy Russell
113b7f7be1
allow shorthand syntax for deprecation reason 2019-02-05 15:26:26 -05:00
kennytm
3abb03fdb3
Rollup merge of #58138 - ishitatsuyuki:stability-delay, r=estebank
Fix #58101
2019-02-06 00:29:08 +09:00
Oliver Scherer
c93bce85e5 Add more tests 2019-02-05 14:18:09 +01:00
David Wood
b377d0b14c
Fix span for closure return type when annotated.
This commit adjusts the span used to label closure return types so that
if the user specifies the return type, i.e. `|_| -> X {}` instead of
`|_| {}`, we correctly highlight all of it and not just the last
character.
2019-02-05 11:10:04 +01:00
bors
b2c6b8c29f Auto merge of #57973 - davidtwco:issue-52891, r=estebank
Add suggestion for duplicated import.

Fixes #52891.

This PR adds a suggestion when a import is duplicated (ie. the same name
is used twice trying to import the same thing) to remove the second
import.
2019-02-05 05:14:15 +00:00
ishitatsuyuki
652f2c753a Add test 2019-02-04 19:26:46 +09:00
David Wood
7102339477
Update visibility of intermediate use items.
Currently, the target of a use statement will be updated with
the visibility of the use statement itself (if the use statement was
visible).

This commit ensures that if the path to the target item is via another
use statement then that intermediate use statement will also have the
visibility updated like the target. This silences incorrect
`unreachable_pub` lints with inactionable suggestions.
2019-02-02 15:29:13 +01:00
bors
852701ad6d Auto merge of #57978 - varkor:fix-irrefutable-integer-range-match, r=oli-obk
Fix bug in integer range matching

Fixes #57894.
2019-02-01 20:57:36 +00:00
varkor
cd1047e0d4 Fix bug in integer range matching 2019-02-01 20:02:21 +00:00
Niko Matsakis
9d2a0b9e82 add regression test for #57979 2019-02-01 12:28:10 -05:00
Oliver Scherer
f2241f640b Make the existential type errors a little bit more helpful 2019-02-01 16:39:50 +01:00
Oliver Scherer
984688ace3 Test more related cases 2019-02-01 16:39:50 +01:00
Oliver Scherer
6f83dcc192 Restrict concrete types to equivalent types 2019-02-01 16:39:50 +01:00
Oliver Scherer
cf01b514c8 Generic type parameters are flexible even for existential types 2019-02-01 16:38:46 +01:00
Oliver Scherer
0d25ff8842 Test aller things 2019-02-01 16:38:46 +01:00
Oliver Scherer
ed10a5ba01 Test all the things 2019-02-01 16:38:46 +01:00
Oliver Scherer
6982fd21d1 Be more permissive with required bounds on existential types 2019-02-01 16:38:46 +01:00
bors
742fcc7167 Auto merge of #57586 - Aaron1011:feature/pub-priv-dep, r=petrochenkov
Implement public/private dependency feature

Implements https://github.com/rust-lang/rust/issues/44663

The core implementation is done - however, there are a few issues that still need to be resolved:

- [x] The `EXTERNAL_PRIVATE_DEPENDENCY` lint currently does notthing when the `public_private_dependencies` is not enabled. Should mentioning the lint (in an `allow` or `deny` attribute) be an error if the feature is not enabled? (Resolved- the feature was removed)
- [x] Crates with the name `core` and `std` are always marked public, without the need to explcitily specify them on the command line. Is this what we want to do? Do we want to allow`no_std`/`no_core` crates to explicitly control this in some way? (Resolved - private crates are now explicitly specified)
- [x] Should I add additional UI tests? (Resolved - added more tests)
- [x] Does it make sense to be able to allow/deny the `EXTERNAL_PRIVATE_DEPENDENCY` on an individual item? (Resolved - this is implemented)
2019-02-01 15:24:26 +00:00
Aaron Hill
541d315313
Update tests for future-compat warning removal 2019-02-01 09:43:57 -05:00
Aaron Hill
a05bfc6aeb
Test allowing individual struct field 2019-02-01 09:43:57 -05:00
Aaron Hill
48ec29d38e
Replace --extern-public with --extern-private 2019-02-01 09:43:57 -05:00
Aaron Hill
b29a21fbae
Remove feature from test 2019-02-01 09:43:57 -05:00
Aaron Hill
3fa36471e8
Rename external_private_dependency to exported_private_dependencies 2019-02-01 09:43:56 -05:00
Aaron Hill
bc2221f7b6
Add test for 'std' crate being public 2019-02-01 09:43:56 -05:00
Aaron Hill
d60214cdf7
Clippy fixes, rename stuff to match RFC 2019-02-01 09:43:56 -05:00
Aaron Hill
12f9b796ff
Improve UI tests 2019-02-01 09:43:56 -05:00
Aaron Hill
93d872dbc8
Add UI test 2019-02-01 09:43:56 -05:00
bors
c9a8687951 Auto merge of #57916 - Zoxc:incr-passes4, r=michaelwoerister
Misc performance tweaks

r? @michaelwoerister
2019-02-01 12:52:54 +00:00
bors
741a3d42cb Auto merge of #58002 - oli-obk:deprecated_sugg, r=zackmdavis
Add suggestions to deprecation lints

Clippy used to do this suggestion, but the clippy lints happen after the deprecation lints so we ended up never seeing the structured suggestions.
2019-02-01 01:06:15 +00:00
Niklas Fiekas
73bf0703a7 Add more tests for #[repr(align(x))] on enums 2019-01-31 14:18:51 +01:00
Oliver Scherer
d0129a613c Add a forever unstable opt-out of const qualification checks 2019-01-31 14:03:01 +01:00
David Wood
1595163356
Add suggestion for duplicated import.
This commit adds a suggestion when a import is duplicated (ie. the same name
is used twice trying to import the same thing) to remove the second
import.
2019-01-31 12:01:28 +01:00
Mazdak Farrokhzad
877dee7c67
Rollup merge of #58008 - matthewjasper:places-conflict-args, r=oli-obk
Pass correct arguments to places_conflict

The borrow place *must* be a place that we track borrows for, otherwise
we will likely ICE.

Closes #57989
2019-01-31 02:10:53 +01:00
Mazdak Farrokhzad
bc7be96cb9
Rollup merge of #58007 - estebank:issue-58006, r=petrochenkov
Don't panic when accessing enum variant ctor using `Self` in match

Fix #58006.

r? @petrochenkov
2019-01-31 02:10:52 +01:00
Mazdak Farrokhzad
bb91a192c0
Rollup merge of #57999 - jethrogb:jb/movbe-feature, r=alexcrichton
Add MOVBE x86 CPU feature

I have no idea if this is correct. I basically copied the ADX feature. I verified the feature is also called `movbe` in LLVM.

I marked this to become stable immediately, as part of the RFC 2045.

r? @alexcrichton
2019-01-31 02:10:49 +01:00
Mazdak Farrokhzad
ab844daadb
Rollup merge of #57008 - Knium:misleading-try-adding-parentheses-in-match-with-comma, r=oli-obk
suggest `|` when `,` founds in invalid match value

Issue #54807
I get stuck on (what | how) I should implement...
2019-01-31 02:10:40 +01:00
John Kåre Alsaker
38bcd4b42a Move privacy checking later in the pipeline and make some passes run in parallel 2019-01-30 21:19:02 +01:00
Matthew Jasper
6fe370c7ce Pass correct arguments to places_conflict
The borrow place *must* be a place that we track borrows for, otherwise
we will likely ICE.
2019-01-30 19:49:31 +00:00
Esteban Küber
74675fed68 Don't panic when accessing enum variant ctor using Self in match 2019-01-30 11:39:56 -08:00
Oliver Scherer
4056b575e2 Add suggestions to deprecation lints 2019-01-30 17:49:04 +01:00
Jethro Beekman
a3f0af2e67 Add MOVBE feature 2019-01-30 21:07:48 +05:30
Niklas Fiekas
c6f6101180 Allow #[repr(align(x))] on enums (#57996) 2019-01-30 14:15:38 +01:00
Knium_
62867b4992 Suggest to add each of | and () when unexpected , is found in pattern 2019-01-30 13:50:44 +09:00
John Kåre Alsaker
0e2ad51e36 Fix tests 2019-01-29 21:10:36 +01:00
bors
7425663011 Auto merge of #57901 - lqd:issue_57362, r=nikomatsakis
Add information to higher-ranked lifetimes conflicts error messages

Make these errors go through the new "placeholder error" code path, to have self tys displayed and make them hopefully less confusing.

Should fix #57362.

r? @nikomatsakis — so we can iterate on the specific wording you wanted.
2019-01-29 16:58:15 +00:00
Ariel Ben-Yehuda
0ceb30de6d add tests to a few edge cases in method lookup
These aren't fixed by this PR, but were broken in a few older attempts
at it. Make sure they don't regress.
2019-01-29 01:00:25 +02:00
Rémy Rakic
c97d135452 Refer to synthetically named lifetimes as "some specific lifetime" rather than "the specific lifetime" 2019-01-28 23:12:13 +01:00
Mazdak Farrokhzad
d3bb907eff
Rollup merge of #57904 - euclio:attribute-typos, r=davidtwco
add typo suggestion to unknown attribute error

Provides a suggestion using Levenshtein distance to suggest built-in attributes and attribute macros.

Fixes #49270.
2019-01-28 22:25:47 +01:00
bors
d8a0dd7ae8 Auto merge of #55704 - Nemo157:pinned-generators, r=Zoxc
Use pinning for generators to make trait safe

I'm unsure whether there needs to be any changes to the actual generator transform. Tests are passing so the fact that `Pin<&mut T>` is fundamentally the same as `&mut T` seems to allow it to still work, but maybe there's something subtle here that could go wrong.

This is specified in [RFC 2349 § Immovable generators](https://github.com/rust-lang/rfcs/blob/master/text/2349-pin.md#immovable-generators) (although, since that RFC it has become safe to create an immovable generator, and instead it's unsafe to resume any generator; with these changes both are now safe and instead the unsafety is moved to creating a `Pin<&mut [static generator]>` which there are safe APIs for).

CC #43122
2019-01-28 14:12:15 +00:00
David Wood
5f021e0023
Unused variable suggestions on all patterns.
This commit extends existing suggestions to prefix unused variable
bindings in match arms with an underscore so that it applies to all
patterns in a match arm.
2019-01-28 10:46:31 +01:00
bors
c32515566f Auto merge of #57910 - Mark-Simulacrum:delete-test, r=petrochenkov
Delete long-ignored and useless test

cc @pnkfelix (https://github.com/rust-lang/rust/issues/13745#issuecomment-457599109)

r? @petrochenkov as you re-enabled this test in 21d67c45a3, https://github.com/rust-lang/rust/pull/55236
2019-01-28 03:46:25 +00:00
Andy Russell
5e67021172
add typo suggestion to unknown attribute error 2019-01-27 21:56:50 -05:00
Wim Looman
c4bf5f9d63 Temporary workaround for travis diagnostic difference 2019-01-27 22:59:00 +01:00
Wim Looman
730b18b6e5 Mark static generators as !Unpin 2019-01-27 22:58:59 +01:00
Wim Looman
a3fdee9a75 Change generator trait to use pinning 2019-01-27 22:58:53 +01:00
bors
8611577360 Auto merge of #57765 - Mark-Simulacrum:bootstrap-bump, r=alexcrichton
Bump bootstrap compiler to 1.33 beta

r? @alexcrichton or @pietroalbini

cc @rust-lang/release
2019-01-27 18:18:17 +00:00
Mark Rousskov
e0bc0ba281 Update comment in test which has changed its purpose 2019-01-27 08:59:58 -07:00
Rémy Rakic
489bc4a2c6 When mentioning lifetimes, put either the trait ref or the self type closer to the lifetimes
When mentioning lifetimes, only invert wording between the expected trait and the self type when the self type has the vid.
This way, the lifetimes always stay close to the self type or trait ref that actually contains them.
2019-01-27 10:52:45 +01:00
Rémy Rakic
1730ad4d1c Fix issue-57362-1.rs attributes 2019-01-27 10:52:45 +01:00
Niko Matsakis
ec6405bccd identify when implemented for "some specific lifetime" 2019-01-27 10:52:44 +01:00
Niko Matsakis
c5dea5753f break apart tests 2019-01-27 10:52:43 +01:00
Remy Rakic
f5a74d40d9 Test new placeholder error messages in previously untested combinations 2019-01-27 10:52:43 +01:00
Remy Rakic
a79f135be6 Update test expectations for new placeholder error messages 2019-01-27 10:52:43 +01:00
lqd
ce61b1b9fa Update two E308 tests to the new placeholder error 2019-01-27 10:52:42 +01:00
Mark Rousskov
7a58c6d1de Replace deprecated ATOMIC_INIT consts 2019-01-26 15:27:38 -07:00
bors
20c2cba61d Auto merge of #57918 - Centril:rollup, r=Centril
Rollup of 7 pull requests

Successful merges:

 - #57407 (Stabilize extern_crate_self)
 - #57703 (Make MutexGuard's Debug implementation more useful.)
 - #57764 (Fix some minor warnings)
 - #57825 (un-deprecate mem::zeroed)
 - #57827 (Ignore aarch64 in simd-intrinsic-generic-reduction)
 - #57908 (resolve: Fix span arithmetics in the import conflict error)
 - #57913 (Change crate-visibility-modifier issue number in The Unstable Book)

Failed merges:

r? @ghost
2019-01-26 18:14:46 +00:00
Mazdak Farrokhzad
bbe8dd9ca3
Rollup merge of #57908 - petrochenkov:errepice, r=estebank
resolve: Fix span arithmetics in the import conflict error

https://github.com/rust-lang/rust/pull/56937 rebased and fixed

Fixes https://github.com/rust-lang/rust/issues/56411
Fixes https://github.com/rust-lang/rust/issues/57071
Fixes https://github.com/rust-lang/rust/issues/57787

r? @estebank
2019-01-26 18:21:47 +01:00
Mazdak Farrokhzad
5e6c2f40d0
Rollup merge of #57407 - mehcode:stabilize-extern-crate-self, r=Centril
Stabilize extern_crate_self

Fixes #56409
2019-01-26 18:21:41 +01:00
bors
46a43dc1e9 Auto merge of #57852 - davidtwco:issue-57819, r=estebank
Suggest removing leading left angle brackets.

Fixes #57819.

This PR adds errors and accompanying suggestions as below:

```
bar::<<<<<T as Foo>::Output>();
     ^^^ help: remove extra angle brackets
```

r? @estebank
2019-01-26 15:33:43 +00:00
bors
42eb5ff404 Auto merge of #55641 - nagisa:optimize-attr, r=pnkfelix
Implement optimize(size) and optimize(speed) attributes

This PR implements both `optimize(size)` and `optimize(speed)` attributes.

While the functionality itself works fine now, this PR is not yet complete: the code might be messy in places and, most importantly, the compiletest must be improved with functionality to run tests with custom optimization levels. Otherwise the new attribute cannot be tested properly. Oh, and not all of the RFC is implemented – attribute propagation is not implemented for example.

# TODO

* [x] Improve compiletest so that tests can be written;
* [x] Assign a proper error number (E9999 currently, no idea how to allocate a number properly);
* [ ] Perhaps reduce the duplication in LLVM attribute assignment code…
2019-01-26 07:08:18 +00:00
bors
37d51aa8f3 Auto merge of #57898 - Centril:rollup, r=Centril
Rollup of 5 pull requests

Successful merges:

 - #56233 (Miri and miri-related code contains repetitions of `(n << amt) >> amt`)
 - #57645 (distinguish "no data" from "heterogeneous" in ABI)
 - #57734 (Fix evaluating trivial drop glue in constants)
 - #57886 (Add suggestion for moving type declaration before associated type bindings in generic arguments.)
 - #57890 (Fix wording in diagnostics page)

Failed merges:

r? @ghost
2019-01-25 23:27:20 +00:00
Vadim Petrochenkov
1b659d69bc Address review comments and cleanup code 2019-01-26 01:49:55 +03:00
François Mockers
ac4b685650 #56411 do not suggest a fix for a import conflict in a macro 2019-01-25 22:39:14 +03:00
Simonas Kazlauskas
ce289c6c99 Resolve breakage 2019-01-25 19:20:38 +02:00
Mazdak Farrokhzad
7768358e72
Rollup merge of #57886 - davidtwco:issue-57385, r=estebank
Add suggestion for moving type declaration before associated type bindings in generic arguments.

Fixes #57385.

r? @estebank
2019-01-25 16:59:29 +01:00
Mazdak Farrokhzad
141fa859b8
Rollup merge of #57734 - oli-obk:fixes_and_cleanups, r=pnkfelix
Fix evaluating trivial drop glue in constants

```rust
struct A;
impl Drop for A {
    fn drop(&mut self) {}
}

const FOO: Option<A> = None;

const BAR: () = (FOO, ()).1;
```

was erroring with

```
error: any use of this value will cause an error
 --> src/lib.rs:9:1
  |
9 | const BAR: () = (FOO, ()).1;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^-^
  |                           |
  |                           calling non-const function `std::ptr::real_drop_in_place::<(std::option::Option<A>, ())> - shim(Some((std::option::Option<A>, ())))`
  |
  = note: #[deny(const_err)] on by default

error: aborting due to previous error
```

before this PR. According to godbolt this last compiled successfully in 1.27
2019-01-25 16:59:27 +01:00
Mazdak Farrokhzad
7779bb9907
Rollup merge of #57645 - nikomatsakis:issue-56877-abi-aggregates, r=eddyb
distinguish "no data" from "heterogeneous" in ABI

Ignore zero-sized types when computing whether something is a homogeneous aggregate, except be careful of VLA.

cc #56877

r? @arielb1
cc @eddyb
2019-01-25 16:59:26 +01:00
Niko Matsakis
8e4c57fca2 distinguish "no data" from "heterogeneous" for ABI purposes
Also, add a testing infrastructure and tests that lets us dump layout.
2019-01-25 10:03:47 -05:00
bors
0b1669d96c Auto merge of #57714 - matthewjasper:wellformed-unreachable, r=pnkfelix
[NLL] Clean up handling of type annotations

* Renames (Canonical)?UserTypeAnnotation -> (Canonical)?UserType so that the name CanonicalUserTypeAnnotation is free.
* Keep the inferred type associated to user type annotations in the MIR, so that it can be compared against the annotated type, even when the annotated expression gets removed from the MIR. (#54943)
* Use the inferred type to allow infallible handling of user type projections (#57531)
* Uses revisions for the tests in #56993
* Check the types of `Unevaluated` constants with no annotations (#46702)
* Some drive-by cleanup

Closes #46702
Closes #54943
Closes #57531
Closes #57731
cc #56993 leaving this open to track the underlying issue: we are not running tests with full NLL enabled on CI at the moment

r? @nikomatsakis
2019-01-25 14:25:37 +00:00
Felix S. Klock II
620a03f5aa Unit test from #57866. 2019-01-25 15:19:37 +01:00
David Wood
7a0abbff8b
Combining move lifetime and type suggestions.
This commit combines the move lifetime and move type suggestions so that
when rustfix applies them they don't conflict with each other.
2019-01-25 11:54:21 +01:00
David Wood
463e623ca9
Suggestion moving types before associated types.
This commit extends existing suggestions to move lifetimes before types
in generic arguments to also suggest moving types behind associated type
bindings.
2019-01-25 11:15:16 +01:00
Oliver Scherer
506393eaaf Add a compile-fail test for Drop in constants in the presence of Options 2019-01-25 09:54:25 +01:00
Mazdak Farrokhzad
a9950f6a45
Rollup merge of #57802 - davidtwco:issue-56943, r=estebank
Print visible name for types as well as modules.

Fixes #56943 and fixes #57713.

This commit extends previous work in #55007 where the name from the
visible parent was used for modules. Now, we also print the name from
the visible parent for types.

r? @estebank
2019-01-25 01:37:02 +01:00
Mazdak Farrokhzad
f20c6c8581
Rollup merge of #57294 - estebank:point-copy-less, r=nikomatsakis
When using value after move, point at span of local

When trying to use a value after move, instead of using a note, point
at the local declaration that has a type that doesn't implement `Copy`
trait.

```
error[E0382]: use of moved value: `x`
  --> $DIR/issue-34721.rs:27:9
   |
LL |     pub fn baz<T: Foo>(x: T) -> T {
   |                -       - move occurs because `x` has type `T`, which does not implement the `Copy` trait
   |                |
   |                consider adding a `Copy` constraint to this type argument
LL |         if 0 == 1 {
LL |             bar::bar(x.zero())
   |                      - value moved here
LL |         } else {
LL |             x.zero()
   |             - value moved here
LL |         };
LL |         x.zero()
   |         ^ value used here after move
```

Fix #34721.
2019-01-25 01:36:59 +01:00
bors
278067d34d Auto merge of #57879 - Centril:rollup, r=Centril
Rollup of 9 pull requests

Successful merges:

 - #57380 (Fix Instant/Duration math precision & associativity on Windows)
 - #57606 (Get rid of the fake stack frame for reading from constants)
 - #57803 (Several changes to libunwind for SGX target)
 - #57846 (rustdoc: fix ICE from loading proc-macro stubs)
 - #57860 (Add os::fortanix_sgx::ffi module)
 - #57861 (Don't export table by default in wasm)
 - #57863 (Add suggestion for incorrect field syntax.)
 - #57867 (Fix std::future::from_generator documentation)
 - #57873 (Stabilize no_panic_pow)

Failed merges:

r? @ghost
2019-01-24 21:23:11 +00:00
Esteban Küber
baa0828ee3 Fix --compare-mode=nll tests 2019-01-24 10:53:43 -08:00
Esteban Küber
29e8e63c84 review comments 2019-01-24 10:36:50 -08:00
Esteban Küber
0e2d6e0175 Point at type argument suggesting adding Copy constraint 2019-01-24 10:36:50 -08:00
Esteban Küber
e0a606c6a9 Add test for #34721 2019-01-24 10:36:50 -08:00
Esteban Küber
5e9c8d7369 When using value after move, point at span of local
When trying to use a value after move, instead of using a note, point
at the local declaration that has a type that doesn't implement `Copy`
trait.
2019-01-24 10:36:50 -08:00
Simonas Kazlauskas
89e34d3e32 Add a feature gate test for #[optimize] 2019-01-24 20:13:51 +02:00
Mazdak Farrokhzad
1a3b3d4298
Rollup merge of #57863 - davidtwco:issue-57684, r=estebank
Add suggestion for incorrect field syntax.

Fixes #57684.

This commit adds a suggestion when a `=` character is used when
specifying the value of a field in a struct constructor incorrectly
instead of a `:` character.

r? @estebank
2019-01-24 18:25:49 +01:00
Mazdak Farrokhzad
8348f83388
Rollup merge of #57606 - oli-obk:shrink, r=RalfJung
Get rid of the fake stack frame for reading from constants

r? @RalfJung

fixes the ice in https://github.com/rust-lang/rust/issues/53708 but still keeps around the wrong "non-exhaustive match" error

cc @varkor
2019-01-24 18:25:43 +01:00
bors
01f8e25b15 Auto merge of #51285 - Mark-Simulacrum:remove-quote_apis, r=Manishearth
Remove quote_*! macros

This deletes a considerable amount of test cases, some of which we may want to keep. I'm not entirely certain what the primary intent of many of them was; if we should keep them I can attempt to edit each case to continue compiling without the quote_*! macros involved.

Fixes #46849.
Fixes #12265.
Fixes #12266.
Fixes #26994.

r? @Manishearth
2019-01-24 15:48:46 +00:00
Mark Simulacrum
db97c48ad6 Remove quote_*! macros and associated APIs 2019-01-24 07:37:34 -07:00
bors
095b44c83b Auto merge of #57269 - gnzlbg:simd_bitmask, r=rkruppe
Add intrinsic to create an integer bitmask from a vector mask

This PR adds a new simd intrinsic: `simd_bitmask(vector) -> unsigned integer` that creates an integer bitmask from a vector mask by extracting one bit of each vector lane.

This is required to implement: https://github.com/rust-lang-nursery/packed_simd/issues/166 .

EDIT: the reason we need an intrinsics for this is that we have to truncate the vector lanes to an `<i1 x N>` vector, and then bitcast that to an `iN` integer (while making sure that we only materialize `i8`, ... , `i64` - that is, no `i1`, `i2`, `i4`, types), and we can't do any of that in a Rust library.

r? @rkruppe
2019-01-24 13:11:06 +00:00
Mazdak Farrokhzad
d17f62d857
Rollup merge of #57836 - oli-obk:existential_crisis, r=estebank
Fix some cross crate existential type ICEs

fixes #53443
2019-01-24 00:19:59 +01:00
Mazdak Farrokhzad
5749bac989
Rollup merge of #57834 - SimonSapin:type_id, r=Centril
Stabilize Any::get_type_id and rename to type_id

FCP: https://github.com/rust-lang/rust/issues/27745#issuecomment-373906749

Closes https://github.com/rust-lang/rust/issues/27745.
2019-01-24 00:19:58 +01:00
Mazdak Farrokhzad
b5447b50b0
Rollup merge of #57817 - davidtwco:issue-54521, r=estebank
Add error for trailing angle brackets.

Fixes #54521.

This PR adds a error (and accompanying machine applicable
suggestion) for trailing angle brackets on function calls with a
turbofish.

r? @estebank
2019-01-24 00:19:57 +01:00
Mazdak Farrokhzad
da182a0fe7
Rollup merge of #57795 - estebank:did-you-mean, r=zackmdavis
Use structured suggestion in stead of notes
2019-01-24 00:19:55 +01:00
Mazdak Farrokhzad
8ef8d57029
Rollup merge of #57793 - estebank:impl-trait-resolve, r=oli-obk
Explain type mismatch cause pointing to return type when it is `impl Trait`

Fix #57743.
2019-01-24 00:19:54 +01:00
Mazdak Farrokhzad
2dd63a2e10
Rollup merge of #57779 - estebank:recover-struct-fields, r=davidtwco
Recover from parse errors in literal struct fields and incorrect float literals

Fix #52496.
2019-01-24 00:19:53 +01:00
David Wood
f14d007ee4
Add suggestion for incorrect field syntax.
This commit adds a suggestion when a `=` character is used when
specifying the value of a field in a struct constructor incorrectly
instead of a `:` character.
2019-01-23 23:40:58 +01:00
Oliver Scherer
5d6faf7b4a Remove unused feature gates 2019-01-23 11:34:58 +01:00
David Wood
22f794b00f
Suggest removing leading left angle brackets.
This commit adds errors and accompanying suggestions as below:

```
bar::<<<<<T as Foo>::Output>();
     ^^^ help: remove extra angle brackets
```
2019-01-23 11:25:45 +01:00
bors
6bba352cad Auto merge of #57835 - pnkfelix:issue-57673-remove-leaky-nested-probe, r=arielb1
typeck: remove leaky nested probe during trait object method resolution

addresses #57673  (but not marking with f-x because thats now afflicting beta channel).

Fix #57216
2019-01-22 23:02:38 +00:00
Oliver Scherer
2c57d1d256 Add regression test 2019-01-22 17:22:30 +01:00
Oliver Scherer
a59eabbc36 Get rid of the fake stack frame 2019-01-22 17:22:29 +01:00
Oliver Scherer
26edb28d31 Fix some cross crate existential type ICEs 2019-01-22 16:08:00 +01:00
Felix S. Klock II
33c2ceb3a2 unit test for issue 57673. 2019-01-22 14:49:18 +01:00
bors
ad30e9a681 Auto merge of #57830 - Centril:rollup, r=Centril
Rollup of 9 pull requests

Successful merges:

 - #57537 (Small perf improvement for fmt)
 - #57552 (Default images)
 - #57604 (Make `str` indexing generic on `SliceIndex`.)
 - #57667 (Fix memory leak in P::filter_map)
 - #57677 (const_eval: Predetermine the layout of all locals when pushing a stack frame)
 - #57791 (Add regression test for #54582)
 - #57798 (Corrected spelling inconsistency)
 - #57809 (Add powerpc64-unknown-freebsd)
 - #57813 (fix validation range printing when encountering undef)

Failed merges:

r? @ghost
2019-01-22 13:40:01 +00:00
Simon Sapin
fb5d3c1f37 Stabilize Any::get_type_id and rename to type_id
FCP: https://github.com/rust-lang/rust/issues/27745#issuecomment-373906749
2019-01-22 14:25:27 +01:00
Mazdak Farrokhzad
dec7b7b131
Rollup merge of #57813 - RalfJung:validation-range-printing, r=oli-obk
fix validation range printing when encountering undef
2019-01-22 12:20:36 +01:00
Mazdak Farrokhzad
8c551155d9
Rollup merge of #57798 - hellow554:master, r=davidtwco
Corrected spelling inconsistency

resolves #57773
2019-01-22 12:20:33 +01:00
Mazdak Farrokhzad
892e6930ce
Rollup merge of #57791 - estebank:issue-54582, r=zackmdavis
Add regression test for #54582

Fix #54582.
2019-01-22 12:20:32 +01:00
Mazdak Farrokhzad
ad55b73da1
Rollup merge of #57604 - alercah:str-index, r=sfackler
Make `str` indexing generic on `SliceIndex`.

Fixes #55603
2019-01-22 12:20:28 +01:00
bors
76c87a166f Auto merge of #56221 - estebank:remove-dummy-checks, r=varkor
Remove unnecessary dummy span checks

The emitter already verifies wether a given span note or span label
can be emitted to the output. If it can't, because it is a dummy
span, it will be either elided for labels or emitted as an unspanned
note/help when applicable.
2019-01-22 10:59:09 +00:00
gnzlbg
785f529d6e Add intrinsic to create an integer bitmask from the MSB of integer vectors 2019-01-22 09:39:09 +01:00
Marcel Hellwig
051835b903 Corrected spelling inconsistency
resolves #57773
2019-01-22 09:08:52 +01:00
bors
8e9774ffcf Auto merge of #57475 - SimonSapin:signed, r=estebank
Add signed num::NonZeroI* types

Multiple people have asked for them in https://github.com/rust-lang/rust/issues/49137. Given that the unsigned ones already exist, they are very easy to add and not an additional maintenance burden.
2019-01-22 05:42:11 +00:00
Esteban Küber
4745b86202 Accept more invalid code that is close to correct fields 2019-01-21 15:47:23 -08:00
David Wood
914d142c02
Extend trailing > detection for paths.
This commit extends the trailing `>` detection to also work for paths
such as `Foo::<Bar>>:Baz`.

This involves making the existing check take the token that is expected
to follow the path being checked as a parameter.

Care is taken to ensure that this only happens on the construction of a
whole path segment and not a partial path segment (during recursion).

Through this enhancement, it was also observed that the ordering of
right shift token and greater than tokens was overfitted to the examples
being tested.

In practice, given a sequence of `>` characters: `>>>>>>>>>`
..then they will be split into `>>` eagerly: `>> >> >> >> >`.
..but when a `<` is prepended, then the first `>>` is split:
`<T> > >> >> >> >`
..and then when another `<` is prepended, a right shift is first again:
`Vec<<T>> >> >> >> >`

In the previous commits, a example that had two `<<` characters was
always used and therefore it was incorrectly assumed that `>>` would
always be first - but when there is a single `<`, this is not the case.
2019-01-22 00:35:31 +01:00
bors
51cc3cdcf0 Auto merge of #55009 - oli-obk:const_safety, r=RalfJung
Make raw ptr ops unsafe in const contexts

r? @RalfJung

cc @Centril
2019-01-21 23:10:11 +00:00
David Wood
3f0fc9b035
Pluralize error messages.
This commit pluralizes error messages when more than a single trailing
`>` character is present.
2019-01-21 22:42:54 +01:00
David Wood
6c399d155c
Add error for trailing angle brackets.
This commit adds a error (and accompanying machine applicable
suggestion) for trailing angle brackets on function calls with a
turbofish.
2019-01-21 22:42:54 +01:00
Ralf Jung
400e28d27a fix validation range printing when encountering undef 2019-01-21 19:08:47 +01:00
Simon Sapin
e195ce654a Fix some non-determinism in help messages for E0277 errors.
The diagnostic for this error prints `the following implementations
were found` followed by the first N relevant impls, sorted.

This commit makes the sort happen before slicing,
so that the set of impls being printed is deterministic
when the input is not.
2019-01-21 18:41:53 +01:00
Oliver Scherer
aedc3a51df Declare some unconst operations as unsafe in const fn 2019-01-21 16:01:57 +01:00
bors
7164a9f151 Auto merge of #55045 - kleimkuhler:add-std-is_sorted, r=KodrAus
Add `is_sorted` to `Iterator` and `[T]`

This is an initial implementation for the first step of [RFC 2351](https://github.com/rust-lang/rfcs/blob/master/text/2351-is-sorted.md)

Tracking issue: https://github.com/rust-lang/rust/issues/53485
2019-01-21 13:55:45 +00:00
David Wood
1db42756f7
Print visible name for types as well as modules.
This commit extends previous work in #55007 where the name from the
visible parent was used for modules. Now, we also print the name from
the visible parent for types.
2019-01-21 13:25:15 +01:00
Esteban Küber
45a95b512c Use structured suggestion in stead of notes 2019-01-20 21:41:25 -08:00
Esteban Küber
e33f7f7de1 Explain type mismatch cause pointing to return type when it is impl Trait 2019-01-20 18:42:10 -08:00
Mazdak Farrokhzad
00c60d115c
Rollup merge of #57784 - JohnTitor:improve-error-message, r=estebank
Add span for bad doc comment

Fixes #57382

r? @estebank
2019-01-21 02:21:58 +01:00
Mazdak Farrokhzad
74b8cd4957
Rollup merge of #57783 - davidtwco:issue-57741, r=estebank
Add "dereference boxed value" suggestion.

Contributes to #57741.

This PR adds a `help: consider dereferencing the boxed value` suggestion to discriminants of match statements when the match arms have type `T` and the discriminant has type `Box<T>`.

r? @estebank
2019-01-21 02:21:57 +01:00
Mazdak Farrokhzad
3bb9fc4007
Rollup merge of #57769 - estebank:cast-suggestion-struct-field, r=matthewjasper
Suggest correct cast for struct fields with shorthand syntax

```
error[E0308]: mismatched types
  --> $DIR/type-mismatch-struct-field-shorthand.rs:8:19
   |
LL |     let _ = RGB { r, g, b };
   |                   ^ expected f64, found f32
help: you can cast an `f32` to `f64` in a lossless way
   |
LL |     let _ = RGB { r: r.into(), g, b };
   |                   ^^^^^^^^^^^
```

Fix #52497.
2019-01-21 02:21:56 +01:00
Mazdak Farrokhzad
627e001a72
Rollup merge of #57768 - estebank:type-args-sugg, r=zackmdavis
Continue parsing after parent type args and suggest using angle brackets

```
error[E0214]: parenthesized parameters may only be used with a trait
--> $DIR/E0214.rs:2:15
   |
LL |     let v: Vec(&str) = vec!["foo"];
   |               ^^^^^^
   |               |
   |               only traits may use parentheses
   |               help: use angle brackets instead: `<&str>`
```

r? @zackmdavis
2019-01-21 02:21:55 +01:00
Mazdak Farrokhzad
ebc70e2e9e
Rollup merge of #56796 - KrishnaSannasi:try_from_impl_change, r=shepmaster
Change bounds on `TryFrom` blanket impl to use `Into` instead of `From`

This is from this [comment](https://github.com/rust-lang/rust/issues/33417#issuecomment-447111156) I made.

This will expand the impls available for `TryFrom` and `TryInto`, without losing anything in the process.
2019-01-21 02:21:53 +01:00
Esteban Küber
3ecbe1efa0 Add regression test for #54582 2019-01-20 17:14:15 -08:00
Esteban Küber
defa61f3fb Tweak field parse error recovery 2019-01-20 15:16:36 -08:00
Esteban Küber
15bad8bbfd Extend incorrect float literal recovery to account for suffixes 2019-01-20 14:25:53 -08:00
Esteban Küber
e387597a8f Reword message for incorrect float literal 2019-01-20 13:59:35 -08:00
Esteban Küber
c4b8df5df2 Remove unnecessary dummy span checks
The emitter already verifies wether a given span note or span label
can be emitted to the output. If it can't, because it is a dummy
span, it will be either elided for labels or emitted as an unspanned
note/help when applicable.
2019-01-20 13:29:03 -08:00
David Wood
f13fe5f3f7
Add "dereference boxed value" suggestion.
This commit adds a `help: consider dereferencing the boxed value`
suggestion to discriminants of match statements when the match arms have
type `T` and the discriminant has type `Box<T>`.
2019-01-20 22:26:37 +01:00
Yuki Okushi
b97c9641f5 Fix tests 2019-01-21 04:52:30 +09:00
Esteban Küber
2ab6cefccf Do not suggest angle brackets when there are no type arguments 2019-01-20 02:47:51 -08:00
Esteban Küber
acbda76f23 Recover with suggestion from writing .42 instead of 0.42 2019-01-20 01:49:04 -08:00
Esteban Küber
b1f169fe7a Recover from parse errors in struct literal fields
Attempt to recover from parse errors while parsing a struct's literal fields
by skipping tokens until a comma or the closing brace is found. This allows
errors in other fields to be reported.
2019-01-20 00:37:06 -08:00
bors
2ab5d8ac44 Auto merge of #57651 - JohnTitor:give-char-type, r=estebank
Implement new literal type `Err`

Fixes #57384

I removed `return Ok`, otherwise, two errors occur. Any solutions?

r? @estebank
2019-01-20 08:26:12 +00:00
Yuki Okushi
4005d3a8cb Remove whitespace 2019-01-20 14:59:10 +09:00
Yuki Okushi
7ce2514419 Fix tests 2019-01-20 14:53:28 +09:00
Esteban Küber
b36bf76dec Suggest correct cast for struct fields with shorthand syntax 2019-01-19 20:18:56 -08:00
Esteban Küber
d37a6d83e1 Suggest usage of angle brackets 2019-01-19 19:39:58 -08:00
Esteban Küber
3235446b39 Accept parenthesized type args for error recovery 2019-01-19 19:27:49 -08:00
Esteban Küber
d38e70036e Continune parsing after encountering Trait with paren args 2019-01-19 18:44:26 -08:00
Yuki Okushi
e9af312932 [WIP] Fix tests 2019-01-20 04:37:58 +09:00
Matthew Jasper
1593ac9b9f Don't ignore _ in type casts and ascriptions 2019-01-19 19:33:41 +00:00
Mazdak Farrokhzad
5b9e02a39c
Rollup merge of #57723 - estebank:fix, r=davidtwco
Point at cause for expectation in return type type error

Various improvements and fixes for type errors in return expressions.

Fix #57664.
2019-01-19 19:41:22 +01:00
Matthew Jasper
c76e55747b Type check unnanotated constant items with NLL 2019-01-19 16:30:45 +00:00
Matthew Jasper
65fe251634 Handle lifetime annotations in unreachable code
We  equate the type in the annotation with the inferred type first so
that we have a fully inferred type to perform the well-formedness check
on.
2019-01-19 16:30:45 +00:00
Mazdak Farrokhzad
4eeb095437
Rollup merge of #57649 - petrochenkov:privexist, r=arielb1
privacy: Account for associated existential types

Turns out they *can* be associated (but only in impls, not traits).
Fixes https://github.com/rust-lang/rust/issues/53546#issuecomment-454372879

r? @arielb1
2019-01-19 14:21:21 +01:00
Mazdak Farrokhzad
5272be5b5e
Rollup merge of #57502 - nikomatsakis:fix-trait-alias-1b, r=nikomatsakis
make trait-aliases work across crates

This is rebase of a small part of @alexreg's PR #55994. It focuses just on the changes that integrate trait aliases properly into crate metadata, excluding the stylistic edits and the trait objects.

The stylistic edits I also rebased and can open a separate PR.

The trait object stuff I found challenging and decided it basically needed to be reimplemented. For now I've excluded it.

Since this is really @alexreg's work (I really just rebased) I am going to make it r=me once it is working.

Fixes #56488.
Fixes #57023.
2019-01-19 14:21:18 +01:00
Alexis Hunt
c7d25a2a40 Make str indexing generic on SliceIndex. 2019-01-19 04:16:05 -05:00
Mazdak Farrokhzad
83921c31b8
Rollup merge of #57666 - pnkfelix:generalize-huge-enum-test-to-work-cross-platform, r=nikomatsakis
Generalize `huge-enum.rs` test and expected stderr for more cross platform cases

With this change, I am able to build and test cross-platform `rustc`

In particular, I can use the following in my `config.toml`:

```
[build]
host = ["i686-unknown-linux-gnu", "x86_64-unknown-linux-gnu"]
target = ["i686-unknown-linux-gnu", "x86_64-unknown-linux-gnu"]
```

Before this change, my attempt to run the test suite would fail
because the error output differs depending on what your host and
targets are.

----

To be concrete, here are the actual messages one can observe:

```
% ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc ../src/test/ui/huge-enum.rs -Aunused  --target=x86_64-unknown-linux-gnu
error: the type `std::option::Option<[u32; 35184372088831]>` is too big for the current architecture

error: aborting due to previous error

% ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc ../src/test/ui/huge-enum.rs -Aunused  --target=i686-unknown-linux-gnu
error: the type `std::option::Option<[u32; 536870911]>` is too big for the current architecture

error: aborting due to previous error

% ./build/i686-unknown-linux-gnu/stage1/bin/rustc ../src/test/ui/huge-enum.rs -Aunused  --target=i686-unknown-linux-gnu
error: the type `std::option::Option<[u32; 536870911]>` is too big for the current architecture

error: aborting due to previous error

% ./build/i686-unknown-linux-gnu/stage1/bin/rustc ../src/test/ui/huge-enum.rs -Aunused  --target=x86_64-unknown-linux-gnu
error: the type `[u32; 35184372088831]` is too big for the current architecture

error: aborting due to previous error
```

To address these variations, I changed the test to be more aggressive
in its normalization strategy. We cannot (and IMO should not)
guarantee that `Option` will appear in the error output here. So I
normalized both types `Option<[u32; N]>` and `[u32; N]` to just `TYPE`
2019-01-19 09:03:32 +01:00
Mazdak Farrokhzad
fd779d3f76
Rollup merge of #57610 - mark-i-m:nested-matchers, r=petrochenkov
Fix nested `?` matchers

fix #57597

I'm not 100% if this works yet...

cc @alercah

When  this is ready (but perhaps not yet):
2019-01-19 09:03:28 +01:00
Mazdak Farrokhzad
b941f290ac
Rollup merge of #57501 - petrochenkov:highvar, r=alexreg
High priority resolutions for associated variants

In https://github.com/rust-lang/rust/pull/56225 variants were assigned lowest priority during name resolution to avoid crater run and potential breakage.

This PR changes the rules to give variants highest priority instead.
Some motivation:
- If variants (and their constructors) are treated as associated items, then they are obviously *inherent* associated items since they don't come from traits.
- Inherent associated items have higher priority during resolution than associated items from traits.
- The reason is that there is a way to disambiguate in favor of trait items (`<Type as Trait>::Ambiguous`), but there's no way to disambiguate in favor of inherent items, so they became unusable in case of ambiguities if they have low priority.
- It's technically problematic to fallback from associated types to anything until lazy normalization (?) is implemented.

Crater found some regressions from this change, but they are all in type positions, e.g.
```rust
fn f() -> Self::Ambiguos { ... } // Variant `Ambiguous` or associated type `Ambiguous`?
```
, so variants are not usable there right now, but they may become usable in the future if https://github.com/rust-lang/rfcs/pull/2593 is accepted.
This PR keeps code like this successfully resolving, but introduces a future-compatibility lint `ambiguous_associated_items` that recommends rewriting it as `<Self as Trait>::Ambiguous`.
2019-01-19 09:03:26 +01:00
bors
af73e64423 Auto merge of #56722 - Aaron1011:fix/blanket-eval-overflow, r=nikomatsakis
Fix stack overflow when finding blanket impls

Currently, SelectionContext tries to prevent stack overflow by keeping
track of the current recursion depth. However, this depth tracking is
only used when performing normal section (which includes confirmation).
No such tracking is performed for evaluate_obligation_recursively, which
can allow a stack overflow to occur.

To fix this, this commit tracks the current predicate evaluation depth.
This is done separately from the existing obligation depth tracking:
an obligation overflow can occur across multiple calls to 'select' (e.g.
when fulfilling a trait), while a predicate evaluation overflow can only
happen as a result of a deep recursive call stack.

Fixes #56701

I've re-used `tcx.sess.recursion_limit` when checking for predication evaluation overflows. This is such a weird corner case that I don't believe it's necessary to have a separate setting controlling the maximum depth.
2019-01-19 05:05:48 +00:00
bors
53b622a48a Auto merge of #56479 - mark-i-m:unsat, r=nikomatsakis
Better lifetime error message

I propose the following error message as more user-friendly

r? @nikomatsakis
2019-01-19 02:25:38 +00:00
Mazdak Farrokhzad
2a830e47e1
Rollup merge of #57725 - estebank:parens, r=michaelwoerister
Use structured suggestion to surround struct literal with parenthesis
2019-01-18 22:56:48 +01:00
Mazdak Farrokhzad
42accf06dc
Rollup merge of #57720 - dlrobertson:fix_57521, r=estebank
Fix suggestions given mulitple bad lifetimes

When given multiple lifetimes prior to type parameters in generic
parameters, do not ICE and print the correct suggestion.

r? @estebank

CC @pnkfelix

Fixes: #57521
2019-01-18 22:56:47 +01:00
Mazdak Farrokhzad
0eb4bdc5f1
Rollup merge of #57657 - AB1908:regression-test-case, r=nikomatsakis
Add regression test to close #53787

Fixes #53787
2019-01-18 22:56:44 +01:00
Mazdak Farrokhzad
d2300afd66
Rollup merge of #57650 - AB1908:master, r=petrochenkov
librustc_metadata: Pass a default value when unwrapping a span

Fixes #57323.

When compiling with `static-nobundle` a-la

`rustc -l static-nobundle=nonexistent main.rs`

we now get a neat output in the form of:

```
error[E0658]: kind="static-nobundle" is feature gated (see issue #37403)
  |
  = help: add #![feature(static_nobundle)] to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
```
The build and tests completed successfully on my machine. Should I be adding a new test?
2019-01-18 22:56:43 +01:00
Mazdak Farrokhzad
f63e3d2ef4
Rollup merge of #57635 - euclio:path-separators, r=michaelwoerister
use structured macro and path resolve suggestions
2019-01-18 22:56:42 +01:00
Mazdak Farrokhzad
49c74e4c85
Rollup merge of #57350 - folex:master, r=estebank
Better error note on unimplemented Index trait for string

fixes #56740

I've tried to compile suggestion from comments in the issue #56740, but unsure of it. So I'm open to advice :)

Current output will be like this:
```rust
error[E0277]: the type `str` cannot be indexed by `{integer}`
  --> $DIR/str-idx.rs:3:17
   |
LL |     let c: u8 = s[4]; //~ ERROR the type `str` cannot be indexed by `{integer}`
   |                 ^^^^ `str` cannot be indexed by `{integer}`
   |
   = help: the trait `std::ops::Index<{integer}>` is not implemented for `str`
   = note: you can use `.chars().nth()` or `.bytes().nth()`
           see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
```

`x.py test src/test/ui` succeeded and I've also tested output manually by compiling the following code:
```rust
fn _f() {
    let s = std::string::String::from("hello");
    let _c = s[0];

    let s = std::string::String::from("hello");
    let mut _c = s[0];

    let s = "hello";
    let _c = s[0];

    let s = "hello";
    let mut _c = &s[0];
}
```

Not sure if some docs should be changed too. I will also fix error message in the [Book :: Indexing into Strings](db53e2e3cd/src/ch08-02-strings.md (indexing-into-strings)) if that PR will get approved :)
2019-01-18 22:56:40 +01:00
Mazdak Farrokhzad
0dd4bfa356
Rollup merge of #57302 - sinkuu:unused_assignments_fp, r=estebank
Fix unused_assignments false positive

Fixes #22630.

In liveness analysis, make `continue` jump to the loop condition's `LiveNode` (`cond` as in comment) instead of the loop's one (`expr`).

069b0c4108/src/librustc/middle/liveness.rs (L1358-L1370)
2019-01-18 22:56:39 +01:00
Mazdak Farrokhzad
b9cb5db5e8
Rollup merge of #57107 - mjbshaw:thread_local_test, r=nikomatsakis
Add a regression test for mutating a non-mut #[thread_local]

This should close #54901 since the regression has since been fixed.
2019-01-18 22:56:34 +01:00
Mazdak Farrokhzad
4091ca0183
Rollup merge of #57551 - petrochenkov:regrtest, r=nikomatsakis
resolve: Add a test for issue #57539

Add a test for the bugfix regression reported in https://github.com/rust-lang/rust/issues/57539

Closes https://github.com/rust-lang/rust/issues/57539
2019-01-18 18:06:32 +01:00
Oliver Scherer
efda6816bd Allow evaluating trivial drop glue in constants 2019-01-18 13:31:05 +01:00
Esteban Küber
2e06d9c91b Point at return type when appropriate 2019-01-18 00:12:09 -08:00
Esteban Küber
954769e2ed Fix test after rebase 2019-01-17 22:51:01 -08:00
Kevin Leimkuhler
b4766f8077 Correct error location indicated by comments 2019-01-17 22:37:12 -08:00
Lukas Kalbertodt
54f11240b7 Override Iterator::is_sorted_by in slice::Iter impl
Additionally, the root implementation was changed a bit: it now uses
`all` instead of coding that logic manually.

To avoid duplicate code, the inherent `[T]::is_sorted_by` method now
calls `self.iter().is_sorted_by(...)`. This should always be inlined
and not result in overhead.
2019-01-17 22:34:43 -08:00
Kevin Leimkuhler
ce47dde59f Add is_sorted unstable documentation 2019-01-17 22:34:43 -08:00
Kevin Leimkuhler
02477f6f99 Add is_sorted impl for [T] 2019-01-17 22:34:43 -08:00
Kevin Leimkuhler
8dea0d0172 Add initial impl of is_sorted to Iterator 2019-01-17 22:34:42 -08:00
Esteban Küber
9b8243ac24 Point at more cases involving return types 2019-01-17 22:33:20 -08:00
Esteban Küber
c4318502bc Avoid pointing at multiple places on return type error 2019-01-17 22:33:20 -08:00
Esteban Küber
19255dc2e6 Point more places where expectation comes from 2019-01-17 22:33:20 -08:00
Esteban Küber
90507295db Do not give incorrect label for return type mismatch 2019-01-17 22:33:20 -08:00
Esteban Küber
ec3c5b0199 Use structured suggestion to surround struct literal with parenthesis 2019-01-17 21:19:30 -08:00
Mark Mansi
db2d243e9e fix compat-mode ui test 2019-01-17 22:04:27 -06:00
Mark Mansi
274d293cab Update tests 2019-01-17 20:39:06 -06:00