Commit Graph

80043 Commits

Author SHA1 Message Date
Zack M. Davis
735d1bd5e6 use HirId in middle::mem_categorization::cmt_, and consequences of that
For the HirIdification initiative #50928.
2018-07-01 22:27:29 -07:00
bors
45935640f0 Auto merge of #51866 - zackmdavis:hir_making_each_day_of_the_year, r=petrochenkov
add modifier keyword spans to hir::Visibility; improve unreachable-pub, private-no-mangle lint suggestions

#50455 pointed out that the unreachable-pub suggestion for brace-grouped `use`s was bogus; #50476 partially ameliorated this by marking the suggestion as `Applicability::MaybeIncorrect`, but this is the actual fix.

Meanwhile, another application of having spans available in `hir::Visibility` is found in the private-no-mangle lints, where we can now issue a suggestion to use `pub` if the item has a more restricted visibility marker (this seems much less likely to come up in practice than not having any visibility keyword at all, but thoroughness is a virtue). While we're there, we can also add a helpful note if the item does have a `pub` (but triggered the lint presumably because enclosing modules were private).

![hir_vis](https://user-images.githubusercontent.com/1076988/42018064-ca830290-7a65-11e8-9c4c-48bc846f861f.png)

r? @nrc
cc @Manishearth
2018-07-02 03:18:49 +00:00
Esteban Küber
e89db3030d Do not suggest changes to str literal if it isn't one 2018-07-01 20:03:35 -07:00
Nicholas Nethercote
f46f05bae8 Make BTreeMap::clone() not allocate when cloning an empty tree. 2018-07-02 13:03:31 +10:00
bors
5df43114bc Auto merge of #51864 - est31:libc_update, r=alexcrichton
Update liblibc

This updates the libc submodule
2018-07-02 01:16:13 +00:00
bors
c697a56d01 Auto merge of #51110 - alexreg:new-static-eval-rules, r=eddyb
Loosened rules involving statics mentioning other statics

Before this PR, trying to mention a static in any way other than taking a reference to it caused a compile-time error. So, while

```rust
static A: u32 = 42;
static B: &u32 = &A;
```

compiles successfully,

```rust
static A: u32 = 42;
static B: u32 = A; // error
```

and

```rust
static A: u32 = 42;
static B: u32 = *&A; // error
```

are not possible to express in Rust. On the other hand, introducing an intermediate `const fn` can presently allow one to do just that:

```rust
static A: u32 = 42;
static B: u32 = foo(&A); // success!

const fn foo(a: &u32) -> u32 {
    *a
}
```

Preventing `const fn` from allowing to work around the ban on reading from statics would cripple `const fn` almost into uselessness.
Additionally, the limitation for reading from statics comes from the old const evaluator(s) and is not shared by `miri`.

This PR loosens the rules around use of statics to allow statics to evaluate other statics by value, allowing all of the above examples to compile and run successfully.
Reads from extern (foreign) statics are however still disallowed by miri, because there is no compile-time value to be read.

```rust
extern static A: u32;

static B: u32 = A; // error
```

This opens up a new avenue of potential issues, as a static can now not just refer to other statics or read from other statics, but even contain references that point into itself.
While it might seem like this could cause subtle bugs like allowing a static to be initialized by its own value, this is inherently impossible in miri.
Reading from a static causes the `const_eval` query for that static to be invoked. Calling the `const_eval` query for a static while already inside the `const_eval` query of said static will cause cycle errors.
It is not possible to accidentally create a bug in miri that would enable initializing a static with itself, because the memory of the static *does not exist* while being initialized.
The memory is not uninitialized, it is not there. Thus any change that would accidentally allow reading from a not yet initialized static would cause ICEs.

Tests have been modified according to the new rules, and new tests have been added for writing to `static mut`s within definitions of statics (which needs to fail), and incremental compilation with complex/interlinking static definitions.
Note that incremental compilation did not need to be adjusted, because all of this was already possible before with workarounds (like intermediate `const fn`s) and the encoding/decoding already supports all the possible cases.

r? @eddyb
2018-07-01 23:00:27 +00:00
bors
a7a60dc7f8 Auto merge of #51969 - pietroalbini:rollup, r=pietroalbini
Rollup of 7 pull requests

Successful merges:

 - #51511 (Stabilize Iterator::flatten in 1.29, fixes #48213.)
 - #51853 (Fix some doc links)
 - #51890 (Fix inconsequential typo in GlobalAlloc doc example)
 - #51920 (use literal span for concrete type suggestion)
 - #51921 (improve the error message when `#[panic_implementation]` is missing)
 - #51922 (rename the llvm-tools component to llvm-tools-preview and tweak its image)
 - #51961 (Fix typo in /src/librustc_resolve/lib.rs)

Failed merges:

r? @ghost
2018-07-01 20:48:57 +00:00
Pietro Albini
3e95491be7
Rollup merge of #51961 - 11Takanori:fix-typo, r=petrochenkov
Fix typo in /src/librustc_resolve/lib.rs

absoluate -> absolute
2018-07-01 21:18:51 +02:00
Pietro Albini
c78bfa33dd
Rollup merge of #51922 - japaric:llvm-tools-preview, r=alexcrichton
rename the llvm-tools component to llvm-tools-preview and tweak its image

as per https://github.com/rust-lang/rust/issues/49584#issuecomment-401217483

r? @alexcrichton or @Mark-Simulacrum
2018-07-01 21:18:50 +02:00
Pietro Albini
87b714b619
Rollup merge of #51921 - japaric:panic-impl-error, r=nagisa
improve the error message when `#[panic_implementation]` is missing

closes #51341

r? @nagisa
cc @phil-opp
2018-07-01 21:18:49 +02:00
Pietro Albini
3f5d2fd850
Rollup merge of #51920 - euclio:concrete-type-suggestion, r=estebank
use literal span for concrete type suggestion

Fixes #51874.

r? @estebank
2018-07-01 21:18:47 +02:00
Pietro Albini
255c26b4f7
Rollup merge of #51890 - Ixrec:patch-3, r=alexcrichton
Fix inconsequential typo in GlobalAlloc doc example
2018-07-01 21:18:46 +02:00
Pietro Albini
1e50629772
Rollup merge of #51853 - MajorBreakfast:fix-doc-links, r=cramertj
Fix some doc links

The futures crate CI always fails because of these intra doc links. I hope that this will fix this issue.

r? @steveklabnik
@cramertj

Edit: I added @steveklabnik as reviewer because this PR also adjusts a link in `src/libstd/error.rs`
2018-07-01 21:18:45 +02:00
Pietro Albini
0f8343830b
Rollup merge of #51511 - Centril:feature/stabilize_iterator_flatten, r=SimonSapin
Stabilize Iterator::flatten in 1.29, fixes #48213.

This PR stabilizes [`Iterator::flatten`](https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#method.flatten) in *version 1.29* (1.28 goes to beta in 10 days, I don't think there's enough time to land it in that time, but let's see...).

Tracking issue is:  #48213.

cc @bluss re. itertools.
r? @SimonSapin
ping @pietroalbini -- let's do a crater run when this passes CI :)
2018-07-01 21:18:43 +02:00
bors
a2be769fd5 Auto merge of #51833 - wesleywiser:faster_large_constant_arrays, r=oli-obk
Speed up compilation of large constant arrays

This is a different approach to #51672 as suggested by @oli-obk. Rather
than write each repeated value one-by-one, we write the first one and
then copy its value directly into the remaining memory.

With this change, the [toy program](c2f4744d2d/src/test/run-pass/mir_heavy_promoted.rs) goes from 63 seconds to 19 seconds on my machine.

Edit: Inlining `Size::bytes()` saves an additional 6 seconds dropping the total time to 13 seconds on my machine.

Edit2: Now down to 2.8 seconds.

r? @oli-obk

cc @nnethercote @eddyb
2018-07-01 18:43:41 +00:00
est31
e8e8bb62d9 Update liblibc 2018-07-01 20:23:41 +02:00
Zack M. Davis
43a0a65fa2 call it hir::VisibilityKind instead of hir::Visibility_:*
It was pointed out in review that the glob-exported
underscore-suffixed convention for `Spanned` HIR nodes is no longer
preferred: see February 2016's #31487 for AST's migration away from
this style towards properly namespaced NodeKind enums.

This concerns #51968.
2018-07-01 11:05:10 -07:00
bors
6af9f91a17 Auto merge of #51536 - davidtwco:nll-dyn-trait-underscore-error-improvements, r=nikomatsakis
NLL: bad error message when converting anonymous lifetime to `'static`

Contributes to #46983. This PR doesn't introduce fantastic errors, but it should hopefully lay some groundwork for diagnostic improvements.
r? @nikomatsakis
2018-07-01 15:49:48 +00:00
David Wood
c0c4741ef7
Updated affected tests after rebase. 2018-07-01 16:14:26 +01:00
David Wood
15aad83560
Fix infinite loops when regions are self-referential. 2018-07-01 16:14:26 +01:00
Niko Matsakis
f334a9e8dd
WIP boring() long line 2018-07-01 16:14:26 +01:00
David Wood
a11245f80e
Ensure that changed errors are lower case. 2018-07-01 16:14:25 +01:00
David Wood
59e64e9085
Updated affected tests. 2018-07-01 16:14:25 +01:00
David Wood
e01e883e4f
Introduce new categories and show a reasonable error message. 2018-07-01 16:14:25 +01:00
David Wood
27ce0cca8e
Moved region inference error reporting into own module. 2018-07-01 16:14:21 +01:00
David Wood
58a723209d
Switched to while let in DFS and deriving Ord on ConstraintCategory. 2018-07-01 15:34:47 +01:00
David Wood
fd0806618c
Constraints are now being categorized, sorted and the error labelled. Categorization needs a bit of work. 2018-07-01 15:33:05 +01:00
Wesley Wiser
46512e09c9 Add two regression tests for const eval 2018-07-01 10:31:15 -04:00
David Wood
56274be4b5
Added bfs for constraint paths from regions. 2018-07-01 15:30:43 +01:00
Niko Matsakis
9e2157fdca
don't consider assignments to temporaries "interesting" 2018-07-01 15:30:43 +01:00
Niko Matsakis
0b620186fd
propagate boring vs interesting causal info for constraints/tests 2018-07-01 15:30:42 +01:00
Niko Matsakis
609bb27514
categorize Locations as interesting or boring 2018-07-01 15:27:15 +01:00
Niko Matsakis
dbeda5ee29
remove the at_location from Locations
We are not currently using it for anything; even polonius just uses
the `from_location`.
2018-07-01 15:27:10 +01:00
Niko Matsakis
73f8333e78 update mir-opt tests 2018-07-01 10:13:05 -04:00
Niko Matsakis
865320f6a4 remove the ins set altogether 2018-07-01 10:13:05 -04:00
Niko Matsakis
5ddda3f195
rename ToLocations to NormalizeLocation 2018-07-01 15:00:34 +01:00
bors
ef9a322843 Auto merge of #51883 - estebank:placement-suggestion, r=varkor
Suggest correct comparison against negative literal

When parsing as emplacement syntax (`x<-1`), suggest the correct syntax
for comparison against a negative value (`x< -1`).

Fix #45651.
2018-07-01 13:37:05 +00:00
Oliver Schneider
0ccebdff6d Update clippy submodule 2018-07-01 13:39:27 +02:00
bors
e100ce4f92 Auto merge of #51855 - Eh2406:i51821, r=nikomatsakis
A fix for 51821

This dedupe the vec of `OutlivesConstraint` using a `FxHashSet<(RegionVid, RegionVid)>` it alsow adds a `struct ConstraintSet` to encapsulate/ensure this behavere.
2018-07-01 10:41:51 +00:00
Niko Matsakis
ac5bd5dd2b remove the FxHashSet since it's not helping us in practice
It turns out that we don't have duplicates, just self-cycles.
2018-07-01 05:53:35 -04:00
Niko Matsakis
be0e77837a use WorkQueue to track dirty bits in liveness 2018-07-01 05:24:16 -04:00
Niko Matsakis
388ff03248 create a new WorkQueue data structure 2018-07-01 05:22:50 -04:00
bors
d94b804863 Auto merge of #51882 - varkor:check-type_dependent_defs, r=estebank
Always check type_dependent_defs

Directly indexing into `type_dependent_defs` has caused multiple ICEs in the past (https://github.com/rust-lang/rust/issues/46771, https://github.com/rust-lang/rust/issues/49241, etc.) and is almost certainly responsible for #51798 too. This PR ensures we always check `type_dependent_defs` first, which should prevent any more of these (or at least make them easier to track down).
2018-07-01 08:41:50 +00:00
Takanori Ishibashi
2e8d9d7a25 absoluate -> absolute 2018-07-01 17:37:42 +09:00
bors
a1703baf52 Auto merge of #51877 - oli-obk:lowering_cleanups3, r=cramertj
Lowering cleanups [3/N]

Needs https://github.com/rust-lang/rust/pull/51806 to be merged first
2018-07-01 06:37:23 +00:00
Zack M. Davis
c2d44b2286 in which the private/restricted-in-public error messaging gets specific
April 2016's Issue #33174 called out the E0446 diagnostics as
confusing. While adding the name of the restricted type to the message
(548e681f) clarified matters somewhat, Esteban Küber pointed out that we
could stand to place a secondary span on the restricted type.

Here, we differentiate between crate-visible, truly private, and
otherwise restricted types, and place a secondary span specifically on
the visibility modifier of the restricted type's declaration (which we
can do now that HIR visibilities have spans!).

At long last, this resolves #33174.
2018-06-30 22:48:05 -07:00
Zack M. Davis
8d1cbb018e private no-mangle lints: help hint note if visibility modifier is pub
If the item is `pub`, one imagines users being confused as to why it's
not reachable/exported; a code suggestion is beyond our local knowledge
here, but we can at least offer a prose hint. (Thanks to Vadim
Petrochenkov for shooting down the present author's original bad idea
for the note text.)

While we're here, use proper HELP expectations instead of ad hoc
comments to communicate (and now, enforce) the expected suggestions in
test/ui/lint/suggestions.rs.
2018-06-30 22:48:05 -07:00
Zack M. Davis
53307473fd private no-mangle lints: issue suggestion for restricted visibility
This is probably quite a lot less likely to come up in practice than the
"inherited" (no visibility keyword) case, but now that we have
visibility spans in the HIR, we can do this, and it presumably doesn't
hurt to be exhaustive. (Who can say but that the attention to detail
just might knock someone's socks off, someday, somewhere?)

This is inspired by #47383.
2018-06-30 22:47:47 -07:00
Zack M. Davis
104985b827 unreachable_pub lint: grab pub span from HIR rather than inferring it
This is a true fix for #50455, superior to the mere bandage offered
in #50476.
2018-06-30 22:41:02 -07:00
Zack M. Davis
4ae89129e1 in which hir::Visibility recalls whence it came (i.e., becomes Spanned)
There are at least a couple (and plausibly even three) diagnostics that
could use the spans of visibility modifiers in order to be reliably
correct (rather than hacking and munging surrounding spans to try to
infer where the visibility keyword must have been).

We follow the naming convention established by the other `Spanned` HIR
nodes: the "outer" type alias gets the "prime" node-type name, the
"inner" enum gets the name suffixed with an underscore, and the variant
names are prefixed with the prime name and `pub use` exported from here
(from HIR).

Thanks to veteran reviewer Vadim Petrochenkov for suggesting this
uniform approach. (A previous draft, based on the reasoning that
`Visibility::Inherited` should not have a span, tried to hack in a named
`span` field on `Visibility::Restricted` and a positional field on
`Public` and `Crate`. This was ... not so uniform.)
2018-06-30 22:41:01 -07:00