Commit Graph

3164 Commits

Author SHA1 Message Date
bors
088fc7384c Auto merge of #53851 - oli-obk:local_promotion, r=eddyb
Limit the promotion of const fns to the libstd and the `rustc_promotable` attribute

There are so many questions around promoting const fn calls... it seems saner to try to limit automatic promotion to const fns which were explicitly opted in for promotion.

I added the attribute to all public stable const fns that were already promotable (e.g. not Cell::new) in order to not cause any breakage

r? @eddyb

cc @nikomatsakis
2018-10-04 06:48:13 +00:00
bors
d0787284da Auto merge of #54447 - KiChjang:issue-54331, r=nikomatsakis
Lower type ascriptions to HAIR and MIR

Fixes #54331.

r? @nikomatsakis
2018-10-04 00:26:00 +00:00
bors
6ddab3e078 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
2018-10-03 10:49:27 +00:00
Oliver Schneider
9e46c0b689 Only promote calls to #[rustc_promotable] const fns 2018-10-03 10:07:05 +02:00
bors
4cf11765dc 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
2018-10-02 23:29:58 +00:00
Pietro Albini
d9d96637d4
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
2018-10-02 22:54:35 +02:00
Pietro Albini
49d4359f6d
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
2018-10-02 22:54:27 +02:00
bors
2bd5993ca2 Auto merge of #54343 - blitzerr:master, r=nikomatsakis
First shot at #54015

Closes #54015
2018-10-02 20:46:49 +00:00
Pramod Bisht
e536e64702 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
2018-10-02 05:51:02 +00:00
David Wood
2be306939d
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`.
2018-10-02 00:35:15 +02:00
David Wood
43b5d725d0
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.
2018-10-02 00:35:15 +02:00
bors
7cbcdae818 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
2018-10-01 22:32:26 +00:00
Ralf Jung
1397836380 do not promote comparing function pointers 2018-09-30 19:48:54 +02:00
Jorge Aparicio
bd3c7812cb use is_uninhabited in more places 2018-09-30 17:27:06 +02:00
bors
1886d5fe1c Auto merge of #54596 - mjbshaw:drop, r=RalfJung
Make core::mem::needs_drop a const fn

This fixes #51929.
2018-09-30 12:00:45 +00:00
Ralf Jung
d62aa3e085 move ScalarMaybeUndef into the miri engine 2018-09-30 13:09:26 +02:00
Ralf Jung
392ea7ad53 do not normalize non-scalar constants to a ConstValue::ScalarPair 2018-09-30 12:37:00 +02:00
Michael Bradshaw
43cc32fbb2 Merge branch 'master' into drop 2018-09-29 19:51:09 -07:00
bors
6310be458f Auto merge of #54601 - cuviper:prep-1.31, r=Mark-Simulacrum
Bump to 1.31.0 and bootstrap from 1.30 beta

Closes #54594.
2018-09-30 01:45:50 +00:00
Niko Matsakis
4a293a3990 avoid infinite loop in MIR lowering 2018-09-29 10:34:35 -07:00
Keith Yeung
fba9d14779 Lower type ascriptions to HAIR and MIR 2018-09-29 10:34:30 -07:00
bors
eb50e75729 Auto merge of #54599 - nikomatsakis:issue-54593-impl-Trait, r=eddyb
use closure def-id in returns, but base def-id in locals

The refactorings to  handle `let x: impl Trait`  wound up breaking `impl Trait` in closure return types. I think there are some deeper problems with the code in question, but this a least should make @eddyb's example work.

Fixes #54593

r? @eddyb
2018-09-29 15:07:59 +00:00
bors
9653f79033 Auto merge of #54660 - kennytm:rollup, r=kennytm
Rollup of 8 pull requests

Successful merges:

 - #54564 (Add 1.29.1 release notes)
 - #54567 (Include path in stamp hash for debuginfo tests)
 - #54577 (rustdoc: give proc-macros their own pages)
 - #54590 (std: Don't let `rust_panic` get inlined)
 - #54598 (Remove useless lifetimes from `Pin` `impl`s.)
 - #54604 (Added help message for `self_in_typedefs` feature gate)
 - #54635 (Improve docs for std::io::Seek)
 - #54645 (Compute Android gdb version in compiletest)
2018-09-29 12:35:39 +00:00
kennytm
9b56c8700c
Rollup merge of #54604 - alexreg:self_in_typedefs-help, r=estebank
Added help message for `self_in_typedefs` feature gate

Fixes #54563.

CC @Centril @estebank @leonardo-m
2018-09-29 16:43:39 +08:00
Ralf Jung
e37d6d37e7 Revert "Auto merge of #53508 - japaric:maybe-uninit, r=RalfJung"
This reverts commit c6e3d7fa31, reversing
changes made to 4591a245c7.
2018-09-29 09:50:50 +02:00
Eduard-Mihai Burtescu
7020326bea rustc: keep a Span for each predicate in ty::GenericPredicates. 2018-09-28 17:19:35 +03:00
Rusty Blitzerr
d5ae6f7870 [54015] NLL:Improve move error loop detection
Before this patch running the following command would generate the given output:
$ rustc +stage1 src/test/ui/liveness/liveness-move-in-while.rs -Zborrowck=mir -Ztwo-phase-borrows
error[E0382]: borrow of moved value: `y`
 --> src/main.rs:8:24
  |
8 |         println!("{}", y); //~ ERROR use of moved value: `y`
  |                        ^ value borrowed here after move
9 |         while true { while true { while true { x = y; x.clone(); } } }
  |                                                    - value moved here
  |
  = note: move occurs because `y` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait

We want to give the user more hint by telling them that the value was moved in the previous iteration of the
loop. After this patch, the error message adds the phrase "in previous iteration of loop" and in totality
looks like this:

$ rustc +stage1 src/test/ui/liveness/liveness-move-in-while.rs -Zborrowck=mir -Ztwo-phase-borrows
error[E0382]: borrow of moved value: `y`
  --> src/test/ui/liveness/liveness-move-in-while.rs:17:24
   |
17 |         println!("{}", y); //~ ERROR use of moved value: `y`
   |                        ^ value borrowed here after move
18 |         while true { while true { while true { x = y; x.clone(); } } }
   |                                                    - value moved here, in previous iteration of loop
   |
   = note: move occurs because `y` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
2018-09-28 04:43:48 -07:00
Josh Stone
ce034951fb Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
Rusty Blitzerr
2ac6cdf6a1 Ran RustFmt on the file 2018-09-27 19:10:29 -07:00
bors
8876906867 Auto merge of #54468 - matthewjasper:fix-polonius, r=nikomatsakis
[NLL] Get Polonius borrow check to work in simple cases

* Restores the generation of outlives facts from subtyping.
* Restore liveness facts.
* Generate invalidates facts at the start point of each location,
  where we check for errors.
* Add a small test for simple cases (previously these cases have compiled, and more recently ICEd).

Closes #54212
cc #53142 (will need test)

### Known limitations

* Two phase borrows aren't implemented for Polonius yet
* Invalidation facts haven't been updated for some of the recent changes to make `Drop` terminators access fewer things.
* Fact generation is not as optimized as it could be.
* Around 30 tests fail in compare mode, often tests that are ignored in nll compare mode

r? @nikomatsakis
2018-09-27 19:26:59 +00:00
Alexander Regueiro
6bf1aa6ff2 Added help message for feature gate. 2018-09-27 04:19:31 +01:00
bors
441519536c Auto merge of #54526 - nnethercote:shrink-StatementKind, r=nagisa
Shrink `StatementKind`

`StatementKind` occurs in significant amounts in Massif profiles.
2018-09-26 23:22:48 +00:00
Niko Matsakis
bcfdfe4e50 use the closure def-id in returns, but closure-base def-id in locals
Using the `closure_base_def_id` indiscriminantely, as we were doing
before, winds up "going wrong" if the closure type includes the `impl
Trait` from the parent. The problem arises because the return value
for closures is inferred and meant to treat the return
type *opaquely*, so we don't want to be "desugaring" it into the
underlying type.
2018-09-26 17:07:25 -04:00
Matthew Jasper
610903fb11 Get Polonius borrow check to work in simple cases
* Restores the generation of outlives facts from subtyping.
* Restore liveness facts.
* Generate invalidates facts at the start point of each location,
  where we check for errors.
* Add a small test for simple cases.
2018-09-26 22:03:56 +01:00
Michael Bradshaw
c0769545b0 Make core::mem::needs_drop a const fn 2018-09-26 11:04:56 -07:00
Niko Matsakis
0b4791e60b make NLL handle IfEq bounds by using SCC normalization 2018-09-26 09:38:26 -04:00
Niko Matsakis
0f5dae0322 switch to use VerifyBound instead of RegionTest 2018-09-26 09:38:26 -04:00
Niko Matsakis
2392a09397 region_infer: rustfmt 2018-09-26 09:38:26 -04:00
Niko Matsakis
7f8c42d7f0 refactor away AnyRegions and AllRegions
It's a bit cleaner to just have `AnyBound` and `AllBound`, after all.
2018-09-26 09:38:26 -04:00
Niko Matsakis
18b86e9406 introduce VerifyBound::IfEq (presently unused) 2018-09-26 09:38:26 -04:00
Niko Matsakis
582a369bc3 encapsulate infcx too into the delegate 2018-09-26 09:38:26 -04:00
Niko Matsakis
c6f4513804 extract out NLL-specific code from relate-tys into a delegate
No functional change.
2018-09-26 09:38:26 -04:00
Niko Matsakis
a4955d1b2c refactor NLL relate_tys to use Region internally, not RegionVid
No functional change.
2018-09-26 09:38:26 -04:00
Niko Matsakis
9e305a8a23 type_check/mod.rs: rustfmt 2018-09-26 09:38:24 -04:00
Niko Matsakis
2f31698c26 use RegionBoundPairs type alias 2018-09-26 09:37:02 -04:00
bors
0b2eae72af Auto merge of #54164 - mikhail-m1:54131, r=pnkfelix
add "temporary value borrowed for too long" error

Issue #54131

r? @nikomatsakis
2018-09-26 01:16:22 +00:00
bors
4141a4079e Auto merge of #53542 - alexreg:impl-trait-in-bindings, r=cramertj
`impl trait` in bindings (feature: impl-trait-existential-types)

This PR enables `impl Trait` syntax (opaque types) to be used in bindings, e.g.

* `let foo: impl Clone = 1;`
* `static foo: impl Clone = 2;`
* `const foo: impl Clone = 3;`

This is part of [RFC 2071](https://github.com/rust-lang/rfcs/blob/master/text/2071-impl-trait-existential-types.md) ([tracking issue](https://github.com/rust-lang/rust/issues/34511)), but exists behind the separate feature gate `impl_trait_in_bindings`.

CC @cramertj @oli-obk @eddyb @Centril @varkor
2018-09-25 20:02:14 +00:00
Felix S. Klock II
ea4d934c32 Change the diagnostic number from 714 to 716. 2018-09-25 15:23:57 +01:00
Mikhail Modin
5fc0b743d7 add "temporary value dropped while borrowed" error
Issue #54131
2018-09-25 15:23:56 +01:00
Alexander Regueiro
8d5de0b1f8 Handle locals in closures properly. 2018-09-25 03:08:07 +01:00