Commit Graph

66597 Commits

Author SHA1 Message Date
bors
d21ec9b4ef Auto merge of #43582 - ivanbakel:unused_mut_ref, r=arielb1
Fixed mutable vars being marked used when they weren't

#### NB : bootstrapping is slow on my machine, even with `keep-stage` - fixes for occurances in the current codebase are <s>in the pipeline</s> done. This PR is being put up for review of the fix of the issue.

Fixes #43526, Fixes #30280, Fixes #25049

### Issue
Whenever the compiler detected a mutable deref being used mutably, it marked an associated value as being used mutably as well. In the case of derefencing local variables which were mutable references, this incorrectly marked the reference itself being used mutably, instead of its contents - with the consequence of making the following code emit no warnings
```
fn do_thing<T>(mut arg : &mut T) {
    ... // don't touch arg - just deref it to access the T
}
```

### Fix
Make dereferences not be counted as a mutable use, but only when they're on borrows on local variables.
#### Why not on things other than local variables?
  * Whenever you capture a variable in a closure, it gets turned into a hidden reference - when you use it in the closure, it gets dereferenced. If the closure uses the variable mutably, that is actually a mutable use of the thing being dereffed to, so it has to be counted.
  * If you deref a mutable `Box` to access the contents mutably, you are using the `Box` mutably - so it has to be counted.
2017-08-10 08:53:22 +00:00
Foucher
27d7e61f1b Fix typo corersponding -> corresponding 2017-08-10 08:49:40 +02:00
bors
2ac5f7d249 Auto merge of #43737 - GuillaumeGomez:duplicate-method, r=eddyb
Improve error message when duplicate names for type and trait method

Fixes #43626.
2017-08-10 06:32:19 +00:00
Nick Cameron
6d736df76b doc tests: use the filename from the source file for doc test programs, rather than a dummy name 2017-08-10 17:59:20 +12:00
Nick Cameron
177cbe01be Some tidying up around include! 2017-08-10 17:59:03 +12:00
kennytm
b4114ebe3a
Exposed all platform-specific documentation. 2017-08-10 13:43:59 +08:00
kennytm
a2b888675a
Implemented #[doc(cfg(...))].
This attribute has two effects:

1. Items with this attribute and their children will have the "This is
   supported on **** only" message attached in the documentation.

2. The items' doc tests will be skipped if the configuration does not
   match.
2017-08-10 13:43:59 +08:00
kennytm
8f935fbb5b
Strip out function implementation when documenting.
This prevents compilation failure we want to document a platform-specific
module. Every function is replaced by `loop {}` using the same construct
as `--unpretty everybody_loops`.

Note also a workaround to #43636 is included: `const fn` will retain their
bodies, since the standard library has quite a number of them.
2017-08-10 13:43:57 +08:00
bors
16268a88fc Auto merge of #43735 - est31:master, r=alexcrichton
Avoid calling the column!() macro in panic

Closes #43057

This "fix" adds a new macro called `__rust_unstable_column` and to use it instead of the `column` macro inside panic. The new macro can be shadowed as well as `column` can, but its very likely that there is no code that does this in practice.

There is no real way to make "unstable" macros that are usable by stable macros, so we do the next best thing and prefix the macro with `__rust_unstable` to make sure people recognize it is unstable.

r? @alexcrichton
2017-08-10 04:01:21 +00:00
bors
57e720d2cd Auto merge of #43730 - nrc:driver-shim, r=eddyb
Make the driver API a little more useful for a tools shim

Example use case: https://github.com/nrc/rls-rustc
2017-08-10 01:22:43 +00:00
Isaac van Bakel
8f78d453de Updated cargo submodule to fix compile error 2017-08-10 02:00:48 +01:00
est31
5cf9f6330a Add a feature gate
@alexcrichton figured out a way how to do it :)
2017-08-10 02:43:31 +02:00
Matt Ickstadt
8c311e56b0 Fix typo in unicode char definition 2017-08-09 19:23:05 -05:00
Vadim Petrochenkov
a965beef8f Better diagnostics and recovery for const in extern blocks 2017-08-10 00:52:50 +01:00
bors
875bcf5c5f Auto merge of #43627 - Aaronepower:master, r=alexcrichton
Updated release notes for 1.20

[Rendered](https://github.com/Aaronepower/rust/blob/master/RELEASES.md)
2017-08-09 22:41:10 +00:00
Nick Cameron
a9a181d4dc driver: factor out continue_parse_after_error so it can be controlled via driver API 2017-08-10 10:14:17 +12:00
nicole mazzuca
445c08d212 fix a typo
(this should not have been merged with this typo)
2017-08-09 13:52:43 -07:00
bors
f142499539 Auto merge of #43484 - estebank:point-to-return, r=arielb1
Point at return type always when type mismatch against it

Before this, the diagnostic errors would only point at the return type
when changing it would be a possible solution to a type error. Add a
label to the return type without a suggestion to change in order to make
the source of the expected type obvious.

Follow up to #42850, fixes #25133, fixes #41897.
2017-08-09 19:50:03 +00:00
Ralf Jung
718a8d1c38 run AddCallGuards for *all* call edges before running AddValidation 2017-08-09 12:16:59 -07:00
Esteban Küber
9bd62a4691 Readd backticks around () 2017-08-09 10:48:33 -07:00
bors
33d71944cd Auto merge of #43732 - kennytm:pass-wrapper-warning, r=arielb1
Fix covered-switch-default warnings in PassWrapper

(See #39063 for explanation)
2017-08-09 17:08:13 +00:00
Steven Fackler
97d046a727 Fix grammar 2017-08-09 09:28:18 -07:00
Michael Woerister
07149e03f4 trans-scheduler: Let main thread take over for other worker. 2017-08-09 18:18:48 +02:00
Alex Crichton
0374e6aab7 rustc: Rearchitect lints to be emitted more eagerly
In preparation for incremental compilation this commit refactors the lint
handling infrastructure in the compiler to be more "eager" and overall more
incremental-friendly. Many passes of the compiler can emit lints at various
points but before this commit all lints were buffered in a table to be emitted
at the very end of compilation. This commit changes these lints to be emitted
immediately during compilation using pre-calculated lint level-related data
structures.

Linting today is split into two phases, one set of "early" lints run on the
`syntax::ast` and a "late" set of lints run on the HIR. This commit moves the
"early" lints to running as late as possible in compilation, just before HIR
lowering. This notably means that we're catching resolve-related lints just
before HIR lowering. The early linting remains a pass very similar to how it was
before, maintaining context of the current lint level as it walks the tree.

Post-HIR, however, linting is structured as a method on the `TyCtxt` which
transitively executes a query to calculate lint levels. Each request to lint on
a `TyCtxt` will query the entire crate's 'lint level data structure' and then go
from there about whether the lint should be emitted or not.

The query depends on the entire HIR crate but should be very quick to calculate
(just a quick walk of the HIR) and the red-green system should notice that the
lint level data structure rarely changes, and should hopefully preserve
incrementality.

Overall this resulted in a pretty big change to the test suite now that lints
are emitted much earlier in compilation (on-demand vs only at the end). This in
turn necessitated the addition of many `#![allow(warnings)]` directives
throughout the compile-fail test suite and a number of updates to the UI test
suite.
2017-08-09 09:13:51 -07:00
Aaron Power
89087183fc Update RELEASES.md 2017-08-09 16:19:54 +01:00
bors
b2bf1639ac Auto merge of #43726 - zackmdavis:extended_information_summer_block_party, r=GuillaumeGomez
E05XX odyssey

chipping away at the surface exposed by #43709

r? @GuillaumeGomez
2017-08-09 13:33:36 +00:00
Oliver Middleton
e5261c0bbf rustdoc: Fix broken CSS in search results
The layout is currently broken for struct/union fields and enum variants
in the search results when searching from a struct, union or enum page.
2017-08-09 13:41:55 +01:00
Michael Woerister
6dbd84640f Erase/anonymize regions while computing TypeId hash. 2017-08-09 14:09:48 +02:00
bors
c2de81f4c9 Auto merge of #43588 - dns2utf8:wrapping_add, r=sfackler
Use explicit wrapping_add …

… to prevent potential unexpected behavior on debug builds.
2017-08-09 11:10:23 +00:00
Ariel Ben-Yehuda
3b0ff0d7e2 Fix errors on Windows 2017-08-09 09:31:10 +00:00
Zack M. Davis
116bf07c32 extended information for E0557 feature has been removed 2017-08-09 01:33:50 -07:00
Zack M. Davis
93bc599d65 extended information for E0552 unrecognized representation hint 2017-08-09 01:33:49 -07:00
Zack M. Davis
6fa140b869 extended information for E0554 feature attributes only work on nightlies
It's more pleasing to use the inner-attribute syntax (`#!` rather than
`#`) in the error message, as that is how `feature` attributes in
particular will be declared (as they apply to the entire crate).
2017-08-09 01:33:49 -07:00
Zack M. Davis
78d1442808 extended information for E0571 break with value in non-loop loop 2017-08-09 01:33:49 -07:00
Esteban Küber
3fcdb8ba72 Only refer to return type when it matches 2017-08-08 22:59:55 -07:00
Steven Fackler
c9814fa485 Instant is monotonically nondecreasing
We don't want to guarantee that `Instant::now() != Instant::now()` is
always true since that depends on the speed of the processor and the
resolution of the clock.
2017-08-08 21:37:37 -07:00
bors
3f977baf34 Auto merge of #43728 - zackmdavis:fnused, r=eddyb
#[must_use] for functions

This implements [RFC 1940](https://github.com/rust-lang/rfcs/pull/1940).

The RFC and discussion thereof seem to suggest that tagging `PartialEq::eq` and friends as `#[must_use]` would automatically lint for unused comparisons, but it doesn't work out that way (at least the way I've implemented it): unused `.eq` method calls get linted, but not `==` expressions. (The lint operates on the HIR, which sees binary operations as their own thing, even if they ultimately just call `.eq` _&c._.)

What do _you_ think??

Resolves #43302.
2017-08-09 04:03:49 +00:00
bors
0f9317d37e Auto merge of #43595 - oyvindln:master, r=aturon
Add an overflow check in the Iter::next() impl for Range<_> to help with vectorization.

This helps with vectorization in some cases, such as (0..u16::MAX).collect::<Vec<u16>>(),
 as LLVM is able to change the loop condition to use equality instead of less than and should help with #43124. (See also my [last comment](https://github.com/rust-lang/rust/issues/43124#issuecomment-319098625) there.) This PR makes collect on ranges of u16, i16, i8, and u8 **significantly** faster (at least on x86-64 and i686), and pretty close, though not quite equivalent to a [manual unsafe implementation](https://is.gd/nkoecB). 32 ( and 64-bit values on x86-64) bit values were already vectorized without this change, and they still are. This PR doesn't seem to help with 64-bit values on i686, as they still don't vectorize well compared to doing a manual loop.

I'm a bit unsure if this was the best way of implementing this, I tried to do it with as little changes as possible and avoided changing the step trait and the behavior in RangeFrom (I'll leave that for others like #43127 to discuss wider changes to the trait). I tried simply changing the comparison to `self.start != self.end` though that made the compiler segfault when compiling stage0, so I went with this method instead for now.

As for `next_back()`, reverse ranges seem to optimise properly already.
2017-08-09 01:30:02 +00:00
Tobias Bucher
5704b07667 mem::unreachable: Add tracking issue 2017-08-09 01:03:50 +02:00
Tobias Bucher
315de9c58f Put intrinsics::unreachable on a possible path to stabilization
Mark it with the `unreachable` feature and put it into the `mem` module.
This is a pretty straight-forward API that can already be simulated in
stable Rust by using `transmute` to create an uninhabited enum that can
be matched.
2017-08-09 00:47:38 +02:00
bors
78efb23586 Auto merge of #43691 - GuillaumeGomez:fix-rustdoc, r=QuietMisdreavus
Fix rustdoc

Fixes #43625.

r? @rust-lang/dev-tools

cc @rust-lang/docs
2017-08-08 22:14:12 +00:00
Ralf Jung
21a707ee97 explain that the example is indeed UB, but that's okay 2017-08-08 14:50:27 -07:00
Stefan Schindler
702750c538 Use explicit wrapping_add to prevent potential unexpected behavior on debug builds 2017-08-08 22:58:09 +02:00
Natalie Boehm
fac6ce79e5 Fix trait name Deref 2017-08-08 16:57:11 -04:00
Guillaume Gomez
8ac4336692 Improve headers linking 2017-08-08 22:16:08 +02:00
bors
215e0b10ea Auto merge of #43711 - lu-zero:master, r=nagisa
More Altivec intrinsics

Beside the usual json + generated files, I added two additional modifiers in the generator.
2017-08-08 19:34:05 +00:00
Guillaume Gomez
ec0ca3a7c6 Remove all usage of hoedown_buffer_puts 2017-08-08 21:25:39 +02:00
Guillaume Gomez
aaa14d1d20 Improve error message when duplicate names for type and trait method 2017-08-08 21:17:33 +02:00
Natalie Boehm
40f5b308bc Update solution to add using &* as well as as_str() 2017-08-08 14:57:34 -04:00
Zack M. Davis
f5ac228b36 mark comparison trait methods as #[must_use]
Note that this doesn't actually give us warnings on `a == b;` and the like, as
some observers may have hoped.

This is in the matter of #43302.
2017-08-08 11:32:10 -07:00