]> git.lizzy.rs Git - rust.git/log
rust.git
5 years agoAuto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
bors [Thu, 4 Oct 2018 03:08:22 +0000 (03:08 +0000)]
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis

handle outlives predicates in trait evaluation

This handles higher-ranked outlives predicates in trait evaluation the same way they are handled in projection.

Fixes #54302. I think this is a more correct fix than #54401 because it fixes the root case in evaluation instead of making evaluation used in less cases. However, we might want to go to a direction closer to @nikomatsakis's solution with Chalk.

r? @nikomatsakis

5 years agoAuto merge of #54447 - KiChjang:issue-54331, r=nikomatsakis
bors [Thu, 4 Oct 2018 00:26:00 +0000 (00:26 +0000)]
Auto merge of #54447 - KiChjang:issue-54331, r=nikomatsakis

Lower type ascriptions to HAIR and MIR

Fixes #54331.

r? @nikomatsakis

5 years agoAuto merge of #54391 - davidtwco:issue-54230, r=petrochenkov
bors [Wed, 3 Oct 2018 21:46:21 +0000 (21:46 +0000)]
Auto merge of #54391 - davidtwco:issue-54230, r=petrochenkov

suggest `crate::...` for "local" paths in 2018

Fixes #54230.

This commit adds suggestions for unresolved imports in the cases where
there could be a missing `crate::`, `super::`, `self::` or a missing
external crate name before an import.

r? @nikomatsakis

5 years agoAuto merge of #54605 - petrochenkov:mambig, r=alexcrichton
bors [Wed, 3 Oct 2018 18:12:22 +0000 (18:12 +0000)]
Auto merge of #54605 - petrochenkov:mambig, r=alexcrichton

resolve: Disambiguate a subset of conflicts "macro_rules" vs "macro name in module"

Currently if macro name may refer to both a `macro_rules` macro definition and a macro defined/imported into module we conservatively report an ambiguity error.
Unfortunately, these errors became a source of regressions when macro modularization was enabled - see issue https://github.com/rust-lang/rust/issues/54472.

This PR disambiguates such conflicts in favor of `macro_rules` if both the `macro_rules` item and in-module macro name are defined in the same normal (named) module and `macro_rules` is closer in scope to the point of use (see the tests for examples).
This is a subset of more general approach described in https://github.com/rust-lang/rust/issues/54472#issuecomment-424666659.
The subset is enough to fix all the regressions from https://github.com/rust-lang/rust/issues/54472, but it can be extended to apply to all "macro_rules" vs "macro name in module" conflicts in the future.

To give an analogy, this is equivalent to scoping rules for `let` variables and items defined in blocks (`macro_rules` behaves like "`let` at module level" in general).
```rust
{ // beginning of the block
    use xxx::m; // (1)

    // Starting from the beginning of the block and until here m!() refers to (1)
    macro_rules! m { ... } // (2)
    // Starting from here and until the end of the block m!() refers to (2)
} // end of the block
```
More complex examples with `use` and `macro_rules` from different modules still report ambiguity errors, even if equivalent examples with `let` are legal.

Fixes https://github.com/rust-lang/rust/issues/54472 (stable-to-beta regression)

5 years agoDeterministic external crate suggestion.
David Wood [Wed, 3 Oct 2018 13:20:20 +0000 (15:20 +0200)]
Deterministic external crate suggestion.

This commit ensures that the external crate suggestion is deterministic
by using a `BTreeMap` rather than a `FxHashMap`. This is particularly
useful as `std` and `core` will often contain the same items and
therefore the suggestion would previously suggest either for any given
error - in this case, the suggestion will always prefer `std` now.

5 years agoUpdate tests to demonstrate 2015 behaviour.
David Wood [Fri, 28 Sep 2018 09:32:04 +0000 (11:32 +0200)]
Update tests to demonstrate 2015 behaviour.

Adds a test to demonstrate behaviour of suggestions in the
2015 edition.

5 years agoRemoved hardcoded crate.
David Wood [Fri, 28 Sep 2018 09:30:55 +0000 (11:30 +0200)]
Removed hardcoded crate.

Previously, `meta` crate was hardcoded as attempting to resolve a path
with it would ICE. Now, we attempt to load each extern crate first so
that resolving a path involving that crate doesn't error.

5 years agoAdd suggestions for unresolved imports.
David Wood [Thu, 20 Sep 2018 15:15:52 +0000 (17:15 +0200)]
Add suggestions for unresolved imports.

This commit adds suggestions for unresolved imports in the cases where
there could be a missing `crate::`, `super::`, `self::` or a missing
external crate name before an import.

5 years agoresolve: Prefer `macro_rules` definitions to in-module macro definitions in some...
Vadim Petrochenkov [Thu, 27 Sep 2018 01:49:40 +0000 (04:49 +0300)]
resolve: Prefer `macro_rules` definitions to in-module macro definitions in some cases

5 years agoAuto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
bors [Wed, 3 Oct 2018 10:49:27 +0000 (10:49 +0000)]
Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis

NLL fails to suggest "try removing `&mut` here"

Fixes #51191.

This PR adds ``try removing `&mut` here`` suggestions to functions where a mutable borrow is being taken of a `&mut self` or a `self: &mut Self`. This PR also enables the suggestion for adding a `mut` pattern to by-value implicit self arguments without `mut` patterns already.

r? @nikomatsakis

5 years agoAuto merge of #54767 - pietroalbini:rollup, r=pietroalbini
bors [Tue, 2 Oct 2018 23:29:58 +0000 (23:29 +0000)]
Auto merge of #54767 - pietroalbini:rollup, r=pietroalbini

Rollup of 10 pull requests

Successful merges:

 - #54269 (#53840: Consolidate pattern check errors)
 - #54458 (Allow both explicit and elided lifetimes in the same impl header)
 - #54603 (Add `crate::` to trait suggestions in Rust 2018.)
 - #54648 (Update Cargo's submodule)
 - #54680 (make run-pass tests with empty main just compile-pass tests)
 - #54687 (Use impl_header_lifetime_elision in libcore)
 - #54699 (Re-export `getopts` so custom drivers can reference it.)
 - #54702 (do not promote comparing function pointers)
 - #54728 (Renumber `proc_macro` tracking issues)
 - #54745 (make `CStr::from_bytes_with_nul_unchecked()` a const fn)

Failed merges:

r? @ghost

5 years agoRollup merge of #54745 - abonander:cstr-const, r=oli-obk
Pietro Albini [Tue, 2 Oct 2018 20:54:38 +0000 (22:54 +0200)]
Rollup merge of #54745 - abonander:cstr-const, r=oli-obk

make `CStr::from_bytes_with_nul_unchecked()` a const fn

closes #54678

5 years agoRollup merge of #54728 - alexcrichton:renumber-issues, r=nikomatsakis
Pietro Albini [Tue, 2 Oct 2018 20:54:36 +0000 (22:54 +0200)]
Rollup merge of #54728 - alexcrichton:renumber-issues, r=nikomatsakis

Renumber `proc_macro` tracking issues

Lots of issue links in the compiler still point to https://github.com/rust-lang/rust/issues/38356 which is a bit of a monster issue that isn't serving much purpose any more. I've split the issue into a number of more fine-grained tracking issues to track stabilizations.

5 years agoRollup merge of #54702 - RalfJung:fn-ptr-promotion, r=oli-obk
Pietro Albini [Tue, 2 Oct 2018 20:54:35 +0000 (22:54 +0200)]
Rollup merge of #54702 - RalfJung:fn-ptr-promotion, r=oli-obk

do not promote comparing function pointers

This *could* break existing code that relied on fn ptr comparison getting promoted to `'static` lifetime.

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

5 years agoRollup merge of #54699 - DiamondLovesYou:reexport-getopts, r=pnkfelix
Pietro Albini [Tue, 2 Oct 2018 20:54:34 +0000 (22:54 +0200)]
Rollup merge of #54699 - DiamondLovesYou:reexport-getopts, r=pnkfelix

Re-export `getopts` so custom drivers can reference it.

Otherwise, custom drivers will have to use their own copy of `getopts`, which won't match the types used in `CompilerCalls`.

5 years agoRollup merge of #54687 - scottmcm:more-elision, r=dtolnay
Pietro Albini [Tue, 2 Oct 2018 20:54:33 +0000 (22:54 +0200)]
Rollup merge of #54687 - scottmcm:more-elision, r=dtolnay

Use impl_header_lifetime_elision in libcore

The feature is approved for stabilization, so let's use it to remove about 300 `'a`s.

Tracking issue for the feature: https://github.com/rust-lang/rust/issues/15872

5 years agoRollup merge of #54680 - RalfJung:compile-pass, r=pnkfelix
Pietro Albini [Tue, 2 Oct 2018 20:54:32 +0000 (22:54 +0200)]
Rollup merge of #54680 - RalfJung:compile-pass, r=pnkfelix

make run-pass tests with empty main just compile-pass tests

Many run-pass tests have an empty main, so there is not actually any point in running them. This makes them `compile-pass` tests instead, saving some time (generating the binary and then running it).

For now I did this only for `run-pass/issues`; if there is interest I can also do it for the other directories. I used `^\s*fn\s+main\(\s*\)\s*\{\s*\}` as regexp to identify these files.

5 years agoRollup merge of #54648 - alexcrichton:update-cargo, r=nikomatsakis
Pietro Albini [Tue, 2 Oct 2018 20:54:30 +0000 (22:54 +0200)]
Rollup merge of #54648 - alexcrichton:update-cargo, r=nikomatsakis

Update Cargo's submodule

Bring in a few updates and fixes, mostly a standard update.

5 years agoRollup merge of #54603 - davidtwco:issue-54559, r=nikomatsakis
Pietro Albini [Tue, 2 Oct 2018 20:54:29 +0000 (22:54 +0200)]
Rollup merge of #54603 - davidtwco:issue-54559, r=nikomatsakis

Add `crate::` to trait suggestions in Rust 2018.

Fixes #54559.

In the 2018 edition, when suggesting traits to import that implement a
given method that is being invoked, suggestions will now include the
`crate::` prefix if the suggested trait is local to the current crate.

r? @nikomatsakis

5 years agoRollup merge of #54458 - scottmcm:bug-54456, r=nikomatsakis
Pietro Albini [Tue, 2 Oct 2018 20:54:28 +0000 (22:54 +0200)]
Rollup merge of #54458 - scottmcm:bug-54456, r=nikomatsakis

Allow both explicit and elided lifetimes in the same impl header

While still prohibiting explicit and in-band in the same header.

Fixes #54456

As usual, I don't know the broader context of the code I'm changing, so please let me know whatever I can do better.

Pre-existing test that mixing explicit and in-band remains an error: https://github.com/rust-lang/rust/blob/master/src/test/ui/in-band-lifetimes/E0688.rs

5 years agoRollup merge of #54269 - PramodBisht:issue/53840, r=estebank
Pietro Albini [Tue, 2 Oct 2018 20:54:27 +0000 (22:54 +0200)]
Rollup merge of #54269 - PramodBisht:issue/53840, r=estebank

#53840: Consolidate pattern check errors

#53840  on this PR we are aggregating `cannot bind by-move and by-ref in the same pattern` message present on the different lines into one diagnostic message. Here we are first gathering those `spans` on `vector` then we are throwing them with the help of `MultiSpan`
r? @estebank

Addresses: #53480

5 years agoAuto merge of #54343 - blitzerr:master, r=nikomatsakis
bors [Tue, 2 Oct 2018 20:46:49 +0000 (20:46 +0000)]
Auto merge of #54343 - blitzerr:master, r=nikomatsakis

First shot at #54015

Closes #54015

5 years agomake `CStr::from_bytes_with_nul_unchecked()` a const fn
Austin Bonander [Tue, 2 Oct 2018 11:26:16 +0000 (04:26 -0700)]
make `CStr::from_bytes_with_nul_unchecked()` a const fn

closes #54678

5 years agomake `CStr::from_bytes_with_nul_unchecked()` a const fn
Austin Bonander [Tue, 2 Oct 2018 10:42:01 +0000 (03:42 -0700)]
make `CStr::from_bytes_with_nul_unchecked()` a const fn

closes #54678

5 years agomove some more tests
Ralf Jung [Tue, 2 Oct 2018 11:14:19 +0000 (13:14 +0200)]
move some more tests

5 years agoAuto merge of #54742 - Manishearth:clippyup, r=oli-obk
bors [Tue, 2 Oct 2018 10:36:25 +0000 (10:36 +0000)]
Auto merge of #54742 - Manishearth:clippyup, r=oli-obk

Update clippy

r? @oli-obk @kennytm

5 years agoUpdate clippy
Manish Goregaokar [Tue, 2 Oct 2018 09:11:35 +0000 (11:11 +0200)]
Update clippy

5 years agoConsolidate pattern check errors
Pramod Bisht [Tue, 2 Oct 2018 05:51:02 +0000 (05:51 +0000)]
Consolidate pattern check errors

we are consolidating `cannot bind by-move and by-ref in the same
pattern` message present on the different lines into single diagnostic
message.

To do this, we are first gathering those spans into the vector
after that we are throwing them with the help of MultiSpan in
a separate block.

Addresses: #53840

5 years agoAuto merge of #54701 - arielb1:outlives-later, r=nikomatsakis
bors [Tue, 2 Oct 2018 04:22:55 +0000 (04:22 +0000)]
Auto merge of #54701 - arielb1:outlives-later, r=nikomatsakis

normalize param-env type-outlives predicates last

The normalization of type-outlives predicates can depend on misc.
environment predicates, but not the other way around. Inferred lifetime
bounds can propagate type-outlives bounds far and wide, so their
normalization needs to work well.

Fixes #54467

r? @nikomatsakis
beta-nominating because this is required for inferred_outlives_bounds, which is in beta

5 years agoAuto merge of #54694 - csmoe:self_this, r=estebank
bors [Tue, 2 Oct 2018 01:09:36 +0000 (01:09 +0000)]
Auto merge of #54694 - csmoe:self_this, r=estebank

Suggest to use self for fake-self from other languages

Closes https://github.com/rust-lang/rust/issues/54019
r? @estebank

5 years agoAttempt to resolve linking issues.
David Wood [Thu, 27 Sep 2018 22:56:41 +0000 (00:56 +0200)]
Attempt to resolve linking issues.

This commit takes a different approach to add the `crate::` prefix to
item paths than previous commits. Previously, recursion was stopped
after a prelude crate name was pushed to the path. It is theorized that
this was the cause of the linking issues since the same path logic is
used for symbol names and that not recursing meant that details were
being missed that affect symbol names. As of this commit, instead of
ceasing recursion, a flag is passed through to any subsequent recursive
calls so that the same effect can be achieved by checking that flag.

5 years agoMove prelude crate names into `Session`.
David Wood [Thu, 27 Sep 2018 19:38:11 +0000 (21:38 +0200)]
Move prelude crate names into `Session`.

Avoid hardcoding and special-casing the `std` crate name in the item
path logic by moving the prelude crate name logic into the `Session`
type so it can be reused in the item path logic and resolve module.

5 years agoAdd `crate::` to trait suggestions in Rust 2018.
David Wood [Wed, 26 Sep 2018 23:17:54 +0000 (01:17 +0200)]
Add `crate::` to trait suggestions in Rust 2018.

In the 2018 edition, when suggesting traits to import that implement a
given method that is being invoked, suggestions will now include the
`crate::` prefix if the suggested trait is local to the current crate.

5 years agoImprove mutability error suggestions.
David Wood [Mon, 1 Oct 2018 17:20:57 +0000 (19:20 +0200)]
Improve mutability error suggestions.

This commit improves mutability error suggestions by suggesting the
removal of `&mut` where a mutable borrow is being taken of a `&mut self`
or a `self: &mut Self`.

5 years agoImprove implicit self mutability suggestions.
David Wood [Mon, 1 Oct 2018 15:46:04 +0000 (17:46 +0200)]
Improve implicit self mutability suggestions.

This commit adds an `ImplicitSelfKind` to the HIR and the MIR that keeps
track of whether a implicit self argument is immutable by-value, mutable
by-value, immutable reference or mutable reference so that the addition
of the `mut` keyword can be suggested for the immutable by-value case.

5 years agoAuto merge of #54693 - RalfJung:ctfe-scalar-pair-undef, r=oli-obk
bors [Mon, 1 Oct 2018 22:32:26 +0000 (22:32 +0000)]
Auto merge of #54693 - RalfJung:ctfe-scalar-pair-undef, r=oli-obk

do not normalize all non-scalar constants to a ConstValue::ScalarPair

We still need `ConstValue::ScalarPair` for match handling (matching slices and strings), but that will never see anything `Undef`. For non-fat-ptr `ScalarPair`, just point to the allocation like larger data structures do.

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

r? @eddyb

5 years agoadd a special case for literal `'static: 'a` where-clauses
Ariel Ben-Yehuda [Fri, 28 Sep 2018 21:22:35 +0000 (00:22 +0300)]
add a special case for literal `'static: 'a` where-clauses

This makes evaluation more consistent with fulfillment.

5 years agoenable using the evaluation cache on predicates with LBRs
Ariel Ben-Yehuda [Fri, 28 Sep 2018 20:20:16 +0000 (23:20 +0300)]
enable using the evaluation cache on predicates with LBRs

There is no reason not to do it.

5 years agohandle outlives predicates in trait evaluation
Ariel Ben-Yehuda [Thu, 27 Sep 2018 21:42:19 +0000 (00:42 +0300)]
handle outlives predicates in trait evaluation

Fixes #54302.

5 years agonormalize param-env type-outlives predicates last
Ariel Ben-Yehuda [Sun, 30 Sep 2018 17:09:05 +0000 (20:09 +0300)]
normalize param-env type-outlives predicates last

The normalization of type-outlives predicates can depend on misc.
environment predicates, but not the other way around. Inferred lifetime
bounds can propagate type-outlives bounds far and wide, so their
normalization needs to work well.

Fixes #54467

5 years agoExtra proc macro gates are now at #54727
Alex Crichton [Mon, 1 Oct 2018 17:58:21 +0000 (10:58 -0700)]
Extra proc macro gates are now at #54727

5 years agoAll `proc_macro_span` APIs tracked at #54725 now
Alex Crichton [Mon, 1 Oct 2018 17:53:03 +0000 (10:53 -0700)]
All `proc_macro_span` APIs tracked at #54725 now

5 years agoSpan::def_site() is now at #54724
Alex Crichton [Mon, 1 Oct 2018 17:47:18 +0000 (10:47 -0700)]
Span::def_site() is now at #54724

5 years agoThe `proc_macro_raw_ident` feature is now at #54723
Alex Crichton [Mon, 1 Oct 2018 17:44:19 +0000 (10:44 -0700)]
The `proc_macro_raw_ident` feature is now at #54723

5 years agoThe `proc_macro_quote` feature now lives at #54722
Alex Crichton [Mon, 1 Oct 2018 17:42:16 +0000 (10:42 -0700)]
The `proc_macro_quote` feature now lives at #54722

5 years agoAuto merge of #54667 - RalfJung:maybe-uninit, r=pnkfelix
bors [Mon, 1 Oct 2018 14:58:24 +0000 (14:58 +0000)]
Auto merge of #54667 - RalfJung:maybe-uninit, r=pnkfelix

Panic when using mem::uninitialized or mem::zeroed on an uninhabited type

All code by @japaric. This re-submits one half of https://github.com/rust-lang/rust/pull/53508. This is likely not the one that introduced the perf regression, but just to be sure I'll do a perf run anyway.

5 years agoAuto merge of #54711 - kennytm:rollup, r=kennytm
bors [Mon, 1 Oct 2018 10:16:00 +0000 (10:16 +0000)]
Auto merge of #54711 - kennytm:rollup, r=kennytm

Rollup of 13 pull requests

Successful merges:

 - #53784 (Document that slices cannot be larger than `isize::MAX` bytes)
 - #54308 (Better user experience when attempting to call associated functions with dot notation)
 - #54488 (in which we include attributes in unused `extern crate` suggestion spans)
 - #54544 (Indicate how to move value out of Box in docs.)
 - #54623 (Added help message for `impl_trait_in_bindings` feature gate)
 - #54641 (A few cleanups and minor improvements to rustc/infer)
 - #54656 (Correct doc for WorkQueue<T>::pop().)
 - #54674 (update miri)
 - #54676 (Remove `-Z disable_ast_check_for_mutation_in_guard`)
 - #54679 (Improve bug! message for impossible case in Relate)
 - #54681 (Rename sanitizer runtime libraries on OSX)
 - #54708 (Make ./x.py help <cmd> invoke ./x.py <cmd> -h on its own)
 - #54713 (Add nightly check for tool_lints warning)

5 years agoRollup merge of #54676 - pnkfelix:issue-15287-kill-zflag-disabling-ast-check, r=alexc...
kennytm [Mon, 1 Oct 2018 09:49:33 +0000 (17:49 +0800)]
Rollup merge of #54676 - pnkfelix:issue-15287-kill-zflag-disabling-ast-check, r=alexcrichton

Remove `-Z disable_ast_check_for_mutation_in_guard`

One should use `#![feature(bind_by_move_pattern_guards)]` over `-Z disable_ast_check_for_mutation_in_guard`

cc #15287

5 years agoRollup merge of #54713 - flip1995:tool_lints_nightly, r=Manishearth
kennytm [Mon, 1 Oct 2018 09:49:09 +0000 (17:49 +0800)]
Rollup merge of #54713 - flip1995:tool_lints_nightly, r=Manishearth

Add nightly check for tool_lints warning

cc #54358

Let's add the nightly check, just in case something prevents a stabilization until 1.31.beta.

5 years agoRollup merge of #54674 - RalfJung:miri, r=oli-obk
kennytm [Mon, 1 Oct 2018 09:47:14 +0000 (17:47 +0800)]
Rollup merge of #54674 - RalfJung:miri, r=oli-obk

update miri

5 years agoAdd nightly check for tool_lints warning
flip1995 [Mon, 1 Oct 2018 09:11:58 +0000 (11:11 +0200)]
Add nightly check for tool_lints warning

cc #54358

5 years agoRollup merge of #54708 - collin5:b49475, r=Mark-Simulacrum
kennytm [Mon, 1 Oct 2018 08:13:05 +0000 (16:13 +0800)]
Rollup merge of #54708 - collin5:b49475, r=Mark-Simulacrum

Make ./x.py help <cmd> invoke ./x.py <cmd> -h on its own

Fixes #49475

r? @Mark-Simulacrum

5 years agoRollup merge of #54681 - alexcrichton:san-names, r=kennytm
kennytm [Mon, 1 Oct 2018 08:13:04 +0000 (16:13 +0800)]
Rollup merge of #54681 - alexcrichton:san-names, r=kennytm

Rename sanitizer runtime libraries on OSX

Currently we ship sanitizer libraries as they're built, but these names
unfortunately conflict with the names of the sanitizer libraries
installed on the system. If a crate, for example, links in C code that
wants to use the system sanitizer and the Rust code doesn't use
sanitizers at all, then using `cargo` may accidentally pull in the
Rust-installed sanitizer library due to a conflict in names.

This change is intended to be entirely transparent for Rust users of
sanitizers, it should only hopefully improve our story with other users!

Closes #54134

5 years agoRollup merge of #54679 - phansch:improve_bug_message, r=matthewjasper
kennytm [Mon, 1 Oct 2018 08:13:03 +0000 (16:13 +0800)]
Rollup merge of #54679 - phansch:improve_bug_message, r=matthewjasper

Improve bug! message for impossible case in Relate

Hitting this branch [in Clippy][clippy_issue] and I think it makes sense to print
both values here in case other people hit this branch, too.

(still have to figure out why this branch is hit)

[clippy_issue]: https://github.com/rust-lang-nursery/rust-clippy/issues/2831#issuecomment-424597092

5 years agoRollup merge of #54656 - nieksand:workqueue_doc, r=varkor
kennytm [Mon, 1 Oct 2018 08:13:02 +0000 (16:13 +0800)]
Rollup merge of #54656 - nieksand:workqueue_doc, r=varkor

Correct doc for WorkQueue<T>::pop().

The old function doc looks like copy-pasta from WorkQueue::insert().

WorkQueue::pop() does not enqueue nor does it return a boolean false.  Doc corrected accordingly.

5 years agoRollup merge of #54641 - ljedrz:cleanup_rustc_infer, r=estebank
kennytm [Mon, 1 Oct 2018 08:13:00 +0000 (16:13 +0800)]
Rollup merge of #54641 - ljedrz:cleanup_rustc_infer, r=estebank

A few cleanups and minor improvements to rustc/infer

- use unwrap_or(_else) where applicable
- convert single-branch matches to if-let
- use to_owned instead of to_string with string literals
- improve vector allocations
- readability improvements
- miscellaneous minor code improvements

5 years agoRollup merge of #54623 - alexreg:impl_trait_in_bindings-help, r=estebank
kennytm [Mon, 1 Oct 2018 08:12:59 +0000 (16:12 +0800)]
Rollup merge of #54623 - alexreg:impl_trait_in_bindings-help, r=estebank

Added help message for `impl_trait_in_bindings` feature gate

r? @estebank

CC @Centril

5 years agoRollup merge of #54544 - frewsxcv:frewsxcv-deref, r=GuillaumeGomez
kennytm [Mon, 1 Oct 2018 08:12:58 +0000 (16:12 +0800)]
Rollup merge of #54544 - frewsxcv:frewsxcv-deref, r=GuillaumeGomez

Indicate how to move value out of Box in docs.

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

5 years agoRollup merge of #54488 - zackmdavis:and_the_case_of_the_unused_crate, r=estebank
kennytm [Mon, 1 Oct 2018 08:12:56 +0000 (16:12 +0800)]
Rollup merge of #54488 - zackmdavis:and_the_case_of_the_unused_crate, r=estebank

in which we include attributes in unused `extern crate` suggestion spans

![unused_extern](https://user-images.githubusercontent.com/1076988/45921698-50243e80-be6f-11e8-930a-7b2a33b4935c.png)

Resolves #54400.

r? @estebank

5 years agoRollup merge of #54308 - dsciarra:issue-22692, r=estebank
kennytm [Mon, 1 Oct 2018 08:12:55 +0000 (16:12 +0800)]
Rollup merge of #54308 - dsciarra:issue-22692, r=estebank

Better user experience when attempting to call associated functions with dot notation

Closes #22692

5 years agoRollup merge of #53784 - tbu-:pr_doc_slice_isize_max, r=RalfJung
kennytm [Mon, 1 Oct 2018 08:12:54 +0000 (16:12 +0800)]
Rollup merge of #53784 - tbu-:pr_doc_slice_isize_max, r=RalfJung

Document that slices cannot be larger than `isize::MAX` bytes

Fixes #53676.

5 years agomark fix as MaybeIncorrect
csmoe [Mon, 1 Oct 2018 01:08:26 +0000 (09:08 +0800)]
mark fix as MaybeIncorrect

5 years agoupdate ui test for suggest-self
csmoe [Sun, 30 Sep 2018 12:48:28 +0000 (20:48 +0800)]
update ui test for suggest-self

5 years agolint to use self for this/my
csmoe [Sun, 30 Sep 2018 12:47:15 +0000 (20:47 +0800)]
lint to use self for this/my

5 years agoAuto merge of #54675 - alexcrichton:defaultlibs, r=varkor
bors [Mon, 1 Oct 2018 03:24:02 +0000 (03:24 +0000)]
Auto merge of #54675 - alexcrichton:defaultlibs, r=varkor

rust: Add a `-C default-linker-libraries` option

This commit adds a new codegen option for the compiler which disables
rustc's passing of `-nodefaultlibs` by default on relevant platforms.
Sometimes Rust is linked with C code which fails to link with
`-nodefaultlibs` and is unnecessarily onerous to get linking correctly
with `-nodefaultlibs`.

An example of this is that when you compile C code with sanitizers and
then pass `-fsanitize=address` to the linker, it's incompatible with
`-nodefaultlibs` also being passed to the linker.

In these situations it's easiest to turn off Rust's default passing of
`-nodefaultlibs`, which was more ideological to start with than
anything! Preserving the default is somewhat important but having this
be opt-in shouldn't cause any breakage.

Closes #54237

5 years agoallow use of ./x.py help <cmd> ...
Collins Abitekaniza [Mon, 1 Oct 2018 01:06:58 +0000 (04:06 +0300)]
allow use of ./x.py help <cmd> ...

5 years agoAuto merge of #54662 - matklad:once-perf, r=alexcrichton
bors [Mon, 1 Oct 2018 00:51:19 +0000 (00:51 +0000)]
Auto merge of #54662 - matklad:once-perf, r=alexcrichton

Fix Once perf regression

Because `call_once` is generic, but `is_completed` is not, we need
`#[inline]` annotation to allow LLVM to inline `is_completed` into
`call_once` in downstream crates.

cc https://github.com/rust-lang/rust/pull/53027/files#r221418859

5 years agoAuto merge of #54650 - eddyb:no-extern's-land, r=alexcrichton
bors [Sun, 30 Sep 2018 22:20:16 +0000 (22:20 +0000)]
Auto merge of #54650 - eddyb:no-extern's-land, r=alexcrichton

Don't lint non-extern-prelude extern crate's in Rust 2018.

Fixes #54381 by silencing the lint telling users to remove `extern crate` when `use` doesn't work.

r? @alexcrichton cc @petrochenkov @nikomatsakis @Centril

5 years agoAdded help message for `impl_trait_in_bindings` feature gate.
Alexander Regueiro [Thu, 27 Sep 2018 21:34:19 +0000 (22:34 +0100)]
Added help message for `impl_trait_in_bindings` feature gate.

5 years agoAuto merge of #53255 - orium:fix-bug-overflow-send, r=arielb1
bors [Sun, 30 Sep 2018 19:41:07 +0000 (19:41 +0000)]
Auto merge of #53255 - orium:fix-bug-overflow-send, r=arielb1

Add a per-tree error cache to the obligation forest

This implements part of what @nikomatsakis mentioned in  https://github.com/rust-lang/rust/pull/30533#issuecomment-170705871:

> 1. If you find that a new obligation is a duplicate of one already in the tree, the proper processing is:
>      * if that other location is your parent, you should abort with a cycle error (or accept it, if coinductive)
>      * if that other location is not an ancestor, you can safely ignore the new obligation

In particular it implements the "if that other location is your parent accept it, if coinductive" part.  This fixes #40827.

I have to say that I'm not 100% confident that this is rock solid.  This is my first pull request :tada:, and I didn't know anything about the trait resolver before this.  In particular I'm not totally sure that comparing predicates is enough (for instance, do we need to compare `param_env` as well?).  Also, I'm not sure what @nikomatsakis mentions [here](https://github.com/rust-lang/rust/issues/30977#issue-127091096), but it might be something that affects this PR:

> In particular, I am wary of getting things wrong around inference variables! We can always add things to the set in their current state, and if unifications occur then the obligation is just kind of out-of-date, but I want to be sure we don't accidentally fail to notice that something is our ancestor. I decided this was subtle enough to merit its own PR.

Anyway, go ahead and review :slightly_smiling_face:.

Ref #30977.

# Performance

We are now copying vectors around, so I decided to do some benchmarking.  A simple benchmark shows that this does not seem to affect performance in a measurable way:

I ran `cargo clean && cargo build` 20 times on actix-web (84b27db) and these are the results:

```text
rustc master:

            Mean        Std.Dev.    Min         Median      Max
real        66.637      2.996       57.220      67.714      69.314
user        307.293     14.741      258.093     312.209     320.702
sys         12.524      0.653       10.499      12.726      13.193

rustc fix-bug-overflow-send:

            Mean        Std.Dev.    Min         Median      Max
real        66.297      4.310       53.532      67.516      70.348
user        306.812     22.371      236.917     314.748     326.229
sys         12.757      0.952       9.671       13.125      13.544
```

I will do a more comprehensive benchmark (compiling rustc stage1) and post the results.

r? @nikomatsakis, @nnethercote

PS: It is better to review this commit-by-commit.

5 years agoDeduplicate errors in the obligation forest.
Diogo Sousa [Sun, 30 Sep 2018 01:41:49 +0000 (02:41 +0100)]
Deduplicate errors in the obligation forest.

Fixes #40827.

5 years agoTypos and style fixes.
Diogo Sousa [Fri, 10 Aug 2018 17:13:43 +0000 (18:13 +0100)]
Typos and style fixes.

5 years agoalso compile-fail test fn ptr comparison promotion
Ralf Jung [Sun, 30 Sep 2018 18:25:19 +0000 (20:25 +0200)]
also compile-fail test fn ptr comparison promotion

5 years agodo not promote comparing function pointers
Ralf Jung [Sun, 30 Sep 2018 17:45:31 +0000 (19:45 +0200)]
do not promote comparing function pointers

5 years agoRe-export `getopts` so custom drivers can reference it.
Richard Diamond [Sun, 30 Sep 2018 15:43:47 +0000 (10:43 -0500)]
Re-export `getopts` so custom drivers can reference it.

Otherwise, custom drivers will have to use their own copy of `getopts`, which
won't match the types used in `CompilerCalls`.

5 years agothe test requires unwinding so we don't run it on the wasm32-bare target
Jorge Aparicio [Fri, 21 Sep 2018 21:40:00 +0000 (23:40 +0200)]
the test requires unwinding so we don't run it on the wasm32-bare target

5 years agoadd codegen test
Jorge Aparicio [Thu, 20 Sep 2018 18:57:25 +0000 (20:57 +0200)]
add codegen test

5 years agomake the nil-enum test work again
Jorge Aparicio [Sat, 1 Sep 2018 18:13:13 +0000 (20:13 +0200)]
make the nil-enum test work again

5 years agoadapt to change in Session API
Jorge Aparicio [Thu, 23 Aug 2018 14:18:28 +0000 (16:18 +0200)]
adapt to change in Session API

5 years agoallow dead_code
Jorge Aparicio [Sat, 22 Sep 2018 22:37:08 +0000 (00:37 +0200)]
allow dead_code

5 years agoadd empty enum to the test cases
Jorge Aparicio [Thu, 23 Aug 2018 14:49:35 +0000 (16:49 +0200)]
add empty enum to the test cases

5 years agoimprove the run-pass test
Jorge Aparicio [Thu, 23 Aug 2018 14:49:00 +0000 (16:49 +0200)]
improve the run-pass test

5 years agomove our check to reuse a previous computation
Jorge Aparicio [Thu, 23 Aug 2018 14:39:03 +0000 (16:39 +0200)]
move our check to reuse a previous computation

5 years agoimprove panic message
Jorge Aparicio [Thu, 23 Aug 2018 14:36:51 +0000 (16:36 +0200)]
improve panic message

5 years agouse is_uninhabited in more places
Jorge Aparicio [Thu, 23 Aug 2018 14:34:38 +0000 (16:34 +0200)]
use is_uninhabited in more places

5 years agopanic when instantiating an uninhabited type via mem::{uninitialized,zeroed}
Jorge Aparicio [Sun, 19 Aug 2018 15:36:04 +0000 (17:36 +0200)]
panic when instantiating an uninhabited type via mem::{uninitialized,zeroed}

5 years agoAuto merge of #54622 - matthewjasper:more-nll-mode, r=pnkfelix
bors [Sun, 30 Sep 2018 14:38:47 +0000 (14:38 +0000)]
Auto merge of #54622 - matthewjasper:more-nll-mode, r=pnkfelix

Enable NLL compare mode for more tests

Most of these tests were disabled due to NLL bugs that have since been fixed. A few needed updating for NLL.

r? @nikomatsakis

5 years agoadd test for fake self
csmoe [Sun, 30 Sep 2018 11:09:34 +0000 (19:09 +0800)]
add test for fake self

5 years agomake run-pass tests with empty main just compile-pass tests
Ralf Jung [Sun, 30 Sep 2018 12:27:26 +0000 (14:27 +0200)]
make run-pass tests with empty main just compile-pass tests

5 years agoAuto merge of #54596 - mjbshaw:drop, r=RalfJung
bors [Sun, 30 Sep 2018 12:00:45 +0000 (12:00 +0000)]
Auto merge of #54596 - mjbshaw:drop, r=RalfJung

Make core::mem::needs_drop a const fn

This fixes #51929.

5 years agomove ScalarMaybeUndef into the miri engine
Ralf Jung [Sun, 30 Sep 2018 11:09:26 +0000 (13:09 +0200)]
move ScalarMaybeUndef into the miri engine

5 years agodo not normalize non-scalar constants to a ConstValue::ScalarPair
Ralf Jung [Sun, 30 Sep 2018 10:37:00 +0000 (12:37 +0200)]
do not normalize non-scalar constants to a ConstValue::ScalarPair

5 years agoAuto merge of #53816 - zackmdavis:elided_lifetimes_in_paths_field_day, r=nikomatsakis
bors [Sun, 30 Sep 2018 09:22:31 +0000 (09:22 +0000)]
Auto merge of #53816 - zackmdavis:elided_lifetimes_in_paths_field_day, r=nikomatsakis

don't elide lifetimes in paths in librustc/

In light of the "Apply to rustc" checkbox on #44524 and @nikomatsakis's [recent comment about regularly wanting visual indication of elided lifetimes in types](https://github.com/rust-lang/rust/issues/44524#issuecomment-414663773), I was curious to see what it would look like if we turned the `elided_lifetimes_in_path` lint on in at least one crate in the codebase (I chose librustc). Given that I couldn't figure out how to get `cargo fix` work with the build system, this arguably wasn't a very efficient use of my time, but once I started, the conjunction of moral law and the sunk cost fallacy forced me to continue.

This is mostly applying the `<'_>` suggestions issued by the lint, but there were a few places where I named the lifetimes (_e.g._, `<'a, 'gcx, 'tcx>` on `TyCtxt`) in order to match style with surrounding code.

r? @nikomatsakis

5 years agoAuto merge of #54639 - nagisa:lets-alias-for-now, r=eddyb
bors [Sun, 30 Sep 2018 06:44:13 +0000 (06:44 +0000)]
Auto merge of #54639 - nagisa:lets-alias-for-now, r=eddyb

Do not put noalias annotations by default

This will be re-enabled sooner or later depending on results of further
investigation.

Fixes #54462

Beta backport is: #54640

r? @nikomatsakis

5 years agoActivate the feature in the libcore tests too
Scott McMurray [Sun, 30 Sep 2018 06:29:58 +0000 (23:29 -0700)]
Activate the feature in the libcore tests too

5 years agoUI test updates
Scott McMurray [Sun, 30 Sep 2018 05:05:07 +0000 (22:05 -0700)]
UI test updates

5 years agodon't elide lifetimes in paths in librustc/
Zack M. Davis [Thu, 30 Aug 2018 05:02:42 +0000 (22:02 -0700)]
don't elide lifetimes in paths in librustc/

This seemed like a good way to kick the tires on the
elided-lifetimes-in-paths lint (#52069)—seems to work! This was also
pretty tedious—it sure would be nice if `cargo fix` worked on this
codebase (#53896)!

5 years agoUse impl_header_lifetime_elision in libcore
Scott McMurray [Mon, 3 Sep 2018 11:50:14 +0000 (04:50 -0700)]
Use impl_header_lifetime_elision in libcore

5 years agoMerge branch 'master' into drop
Michael Bradshaw [Sun, 30 Sep 2018 02:51:09 +0000 (19:51 -0700)]
Merge branch 'master' into drop

5 years agoFix ui/run-pass/union/union-nodrop.rs test
Michael Bradshaw [Sun, 30 Sep 2018 02:49:17 +0000 (19:49 -0700)]
Fix ui/run-pass/union/union-nodrop.rs test