Commit Graph

80965 Commits

Author SHA1 Message Date
mark
2a7ae04a68 Extend ParseSess to support buffering lints 2018-07-23 21:54:43 -05:00
bors
6a1c0637ce Auto merge of #52175 - fpoli:testsuite-callsite-span, r=petrochenkov
Match errors using the callsite of macro expansions

Fix for issue #51848
2018-07-23 21:44:37 +00:00
bors
00204c2f52 Auto merge of #50494 - F001:as_cell, r=alexcrichton
Implement rfc 1789: Conversions from `&mut T` to `&Cell<T>`

I'm surprised that RFC 1789 has not been implemented for several months. Tracking issue: https://github.com/rust-lang/rust/issues/43038

Please note: when I was writing tests for `&Cell<[i32]>`, I found it is not easy to get the length of the contained slice. So I designed a `get_with` method which might be useful for similar cases. This method is not designed in the RFC, and it certainly needs to be reviewed by core team. I think it has some connections with `Cell::update` https://github.com/rust-lang/rust/issues/50186 , which is also in design phase.
2018-07-23 19:43:36 +00:00
bors
8dbbd81f7e Auto merge of #52566 - pnkfelix:buffer-nll-errors-for-z-borrowck-migrate, r=nikomatsakis
Buffer NLL errors

Buffer the errors generated during MIR-borrowck (aka NLL).

This is the first big step towards resolving issue #46908.
2018-07-23 17:45:34 +00:00
bors
6bb50f569d Auto merge of #52639 - oli-obk:clippyup, r=kennytm
Update the clippy submodule

r? @kennytm

cc @nrc @Manishearth
2018-07-23 15:38:46 +00:00
bors
5665a2d367 Auto merge of #52506 - alexcrichton:dont-duplicate-wasm-sections, r=michaelwoerister
rustc: Work around an upstream wasm ThinLTO bug

This commit implements a workaround for an [upstream LLVM bug][1] where custom
sections were accidentally duplicated amongst codegen units when ThinLTO passes
were performed. This is due to the fact that custom sections for wasm are stored
as metadata nodes which are automatically imported into modules when ThinLTO
happens. The fix here is to forcibly delete the metadata node from imported
modules before LLVM has a chance to try to copy it over.

[1]: https://bugs.llvm.org/show_bug.cgi?id=38184
2018-07-23 13:42:23 +00:00
F001
489101cc45 use inherent method instead 2018-07-23 20:58:40 +08:00
Federico Poli
8ec9d7242c Match errors using the callsite of macro expansions 2018-07-23 14:31:06 +02:00
Felix S. Klock II
1a0294bb84 Thread the errors_buffer down through the NLL region_infer code. 2018-07-23 14:20:20 +02:00
Felix S. Klock II
ec005ccf84 Separate the construction of a generic bound failure from its emission. 2018-07-23 14:20:20 +02:00
Felix S. Klock II
87e729f58a thread the errors_buffer down into nll::type_check.
Right now its solely used for `check_local`, which ... I guess is not surprising?
2018-07-23 14:20:20 +02:00
Santiago Pastorino
3d3e0aa571 Buffer errors in MIR borrow check
(pnkfelix updated to address tidy, and to change the buffer from
`Vec<DiagnosticBuilder<'errs>>` to a `Vec<Diagnostic>` in order to
avoid painful lifetime maintenance.)
2018-07-23 14:20:12 +02:00
bors
970102f24c Auto merge of #52589 - petrochenkov:derlint, r=alexcrichton
Attach deprecation lint `proc_macro_derive_resolution_fallback` to a specific node id

So it can be `allow`-ed from inside the derive.

cc https://github.com/rust-lang/rust/pull/51952
2018-07-23 11:39:50 +00:00
Santiago Pastorino
da935e96a1 Remove redundant outlives declarations 2018-07-23 13:28:54 +02:00
Santiago Pastorino
82e853e2e2 Remove wrong allow(dead_code) directive 2018-07-23 13:28:54 +02:00
Santiago Pastorino
bc1eec3fa8 Remove unneded lifetimes relations declaration 2018-07-23 13:28:54 +02:00
Santiago Pastorino
e4e84fd8ff Let mir reference lifetime be inferred 2018-07-23 13:28:54 +02:00
Santiago Pastorino
30313c0ec9 Let lifetimes on find be inferred 2018-07-23 13:28:54 +02:00
Santiago Pastorino
caa11dee50 Remove unused lifetime annotation 2018-07-23 13:28:54 +02:00
Santiago Pastorino
5dc5c02581 gcx outlives tcx which outlives a, no need to explicitly do gcx: a 2018-07-23 13:27:32 +02:00
Santiago Pastorino
e0ea756b9f Remove duplicated report word in docs 2018-07-23 13:27:32 +02:00
Oliver Schneider
4e93436325 Update the clippy submodule 2018-07-23 13:01:44 +02:00
bors
2e6fc3e2c0 Auto merge of #52211 - bjorn3:misc_rustdoc_changes, r=QuietMisdreavus
Misc rustdoc changes
2018-07-23 09:37:03 +00:00
bors
3900bf8ae3 Auto merge of #52612 - matthewjasper:remove-unnecessary-flow, r=nikomatsakis
Don't keep the possibly initialized flow around longer than needed

The possibly initialized flow isn't used after liveness is computed, so don't keep it around. Locally this is about a 10% time win for tuple-stress (which is spending a lot of time calculating flows now that it's not spending so much on liveness).

r? @nikomatsakis
2018-07-23 06:44:15 +00:00
bors
210d61f05c Auto merge of #52571 - oli-obk:promotion_abort, r=nagisa
Abort if a promoted fails to be const evaluable and its runtime checks didn't trigger

r? @eddyb

cc @RalfJung @nagisa

cc https://github.com/rust-lang/rust/issues/49760
2018-07-23 03:06:08 +00:00
bors
02b0479c26 Auto merge of #52568 - oli-obk:span_bug_error, r=varkor
Fix loop label resolution around constants

And make `delay_span_bug` a little more helpful

r? @varkor

fixes #52442
fixes #52443
2018-07-23 01:02:32 +00:00
bors
67f9c71e45 Auto merge of #52564 - pnkfelix:issue-52126-lhs-of-assign-op-is-invariant, r=eddyb
LHS of assign op is invariant

This addresses a bug injected by #45435. That PR changed the way we type-check `LHS <op> RHS` to coerce the LHS to the expected supertype in much the same way that we coerce the RHS.

The problem is that when we have a case of `LHS <op>= RHS`, we do not want to coerce to a supertype; we need the type to remain invariant. Otherwise we risk leaking a value with short-lifetimes into a expression context that needs to satisfy a long lifetime.

Fix #52126
2018-07-22 23:05:11 +00:00
bors
ffaf3d2567 Auto merge of #52069 - zackmdavis:elided_states_of_america—and_to_the_re-pub-lic, r=nikomatsakis
add structured suggestions and fix false-positive for elided-lifetimes-in-paths lint

This adds structured suggestions to the elided-lifetimes-in-paths lint (introduced in Nov. 2017's #46254), prevents it from emitting a false-positive on anonymous (underscore) lifetimes (!), and adds it to the idioms-2018 group (#52041).

~~As an aside, "elided-lifetimes-in-paths" seems like an unfortunate name, because it's not clear exactly what "elided" means. The motivation for this lint (see original issue #45992, and [RFC 2115](e978a8d301/text/2115-argument-lifetimes.md (motivation))) seems to be specifically about not supplying angle-bracketed lifetime arguments to non-`&` types, but (1) the phrase "lifetime elision" has historically also referred to the ability to not supply a lifetime name to `&` references, and (2) an `is_elided` method in the HIR returns true for anoymous/underscore lifetimes, which is _not_ what we're trying to lint here. (That naming confusion is almost certainly what led to the false positive addressed here.) Given that the lint is relatively new and is allow-by-default, is it too late to rename it ... um, _again_ (#50879)?~~

~~This does _not_ address a couple of other false positives discovered in https://github.com/rust-lang/rust/issues/52041#issuecomment-402547901.~~

![elided_states](https://user-images.githubusercontent.com/1076988/42302137-2bf9479c-7fce-11e8-8bd0-f29aefc802b6.png)

r? @nikomatsakis
cc @nrc @petrochenkov
2018-07-22 20:54:05 +00:00
bors
3b7720399a Auto merge of #52616 - kennytm:rollup, r=kennytm
Rollup of 11 pull requests

Successful merges:

 - #51807 (Deprecation of str::slice_unchecked(_mut))
 - #52051 (mem::swap the obvious way for types smaller than the SIMD optimization's block size)
 - #52465 (Add CI test harness for `thumb*` targets. [IRR-2018-embedded])
 - #52507 (Reword when `_` couldn't be inferred)
 - #52508 (Document that Unique::empty() and NonNull::dangling() aren't sentinel values)
 - #52521 (Fix links in rustdoc book.)
 - #52581 (Avoid using `#[macro_export]` for documenting builtin macros)
 - #52582 (Typo)
 - #52587 (Add missing backtick in UniversalRegions doc comment)
 - #52594 (Run the error index tool against the sysroot libdir)
 - #52615 (Added new lines to .gitignore.)
2018-07-22 18:51:46 +00:00
kennytm
b954d4d1b5
Rollup merge of #52051 - scottmcm:swap-directly, r=alexcrichton
mem::swap the obvious way for types smaller than the SIMD optimization's block size

LLVM isn't able to remove the alloca for the unaligned block in the post-SIMD tail in some cases, so doing this helps SRoA work in cases where it currently doesn't.  Found in the `replace_with` RFC discussion.

Examples of the improvements:
<details>
 <summary>swapping `[u16; 3]` takes 1/3 fewer instructions and no stackalloc</summary>

```rust
type Demo = [u16; 3];
pub fn swap_demo(x: &mut Demo, y: &mut Demo) {
    std::mem::swap(x, y);
}
```

nightly:
```asm
_ZN4blah9swap_demo17ha1732a9b71393a7eE:
.seh_proc _ZN4blah9swap_demo17ha1732a9b71393a7eE
	sub	rsp, 32
	.seh_stackalloc 32
	.seh_endprologue
	movzx	eax, word ptr [rcx + 4]
	mov	word ptr [rsp + 4], ax
	mov	eax, dword ptr [rcx]
	mov	dword ptr [rsp], eax
	movzx	eax, word ptr [rdx + 4]
	mov	word ptr [rcx + 4], ax
	mov	eax, dword ptr [rdx]
	mov	dword ptr [rcx], eax
	movzx	eax, word ptr [rsp + 4]
	mov	word ptr [rdx + 4], ax
	mov	eax, dword ptr [rsp]
	mov	dword ptr [rdx], eax
	add	rsp, 32
	ret
	.seh_handlerdata
	.section	.text,"xr",one_only,_ZN4blah9swap_demo17ha1732a9b71393a7eE
	.seh_endproc
```

this PR:
```asm
_ZN4blah9swap_demo17ha1732a9b71393a7eE:
	mov	r8d, dword ptr [rcx]
	movzx	r9d, word ptr [rcx + 4]
	movzx	eax, word ptr [rdx + 4]
	mov	word ptr [rcx + 4], ax
	mov	eax, dword ptr [rdx]
	mov	dword ptr [rcx], eax
	mov	word ptr [rdx + 4], r9w
	mov	dword ptr [rdx], r8d
	ret
```
</details>

<details>
 <summary>`replace_with` optimizes down much better</summary>

Inspired by https://github.com/rust-lang/rfcs/pull/2490,

```rust
fn replace_with<T, F>(x: &mut Option<T>, f: F)
    where F: FnOnce(Option<T>) -> Option<T>
{
    *x = f(x.take());
}

pub fn inc_opt(mut x: &mut Option<i32>) {
    replace_with(&mut x, |i| i.map(|j| j + 1));
}
```

Rust 1.26.0:
```asm
_ZN4blah7inc_opt17heb0acb64c51777cfE:
	mov	rax, qword ptr [rcx]
	movabs	r8, 4294967296
	add	r8, rax
	shl	rax, 32
	movabs	rdx, -4294967296
	and	rdx, r8
	xor	r8d, r8d
	test	rax, rax
	cmove	rdx, rax
	setne	r8b
	or	rdx, r8
	mov	qword ptr [rcx], rdx
	ret
```

Nightly (better thanks to ScalarPair, maybe?):
```asm
_ZN4blah7inc_opt17h66df690be0b5899dE:
	mov	r8, qword ptr [rcx]
	mov	rdx, r8
	shr	rdx, 32
	xor	eax, eax
	test	r8d, r8d
	setne	al
	add	edx, 1
	mov	dword ptr [rcx], eax
	mov	dword ptr [rcx + 4], edx
	ret
```

This PR:
```asm
_ZN4blah7inc_opt17h1426dc215ecbdb19E:
	xor	eax, eax
	cmp	dword ptr [rcx], 0
	setne	al
	mov	dword ptr [rcx], eax
	add	dword ptr [rcx + 4], 1
	ret
```

Where that add is beautiful -- using an addressing mode to not even need to explicitly go through a register -- and the remaining imperfection is well-known (https://github.com/rust-lang/rust/pull/49420#issuecomment-376805721).
</details>
2018-07-23 01:02:41 +08:00
kennytm
7019ccee93
Rollup merge of #52615 - davidtwco:add-to-gitignore, r=nikomatsakis,Mark-Simulacrum
Added new lines to .gitignore.

There are a handful of files that I often find in my local working directories that I never want to commit that aren't covered in the `.gitignore` file:

`/mir_dump`:
Default output location from `-Z mir-dump=all` for a specific test, I can't think of a reason why this should ever be commited.

`tags*`/`TAGS*`:
I use `vim-gutentags` which outputs `tags` and `tags.temp` which I don't want commited. I also collapsed the `TAGS`, `TAGS.vi`, `TAGS.emacs` into `TAGS*`.

`Session.vim`:
I use `vim-obsession` to save my current session in Vim, it outputs a `Session.vim` file, this also shouldn't be commited.
2018-07-23 01:00:10 +08:00
kennytm
de3cf0c433
Rollup merge of #52594 - Mark-Simulacrum:error-index-stage0, r=alexcrichton
Run the error index tool against the sysroot libdir

Previously when building the error index tool in stage 0 we would
attempt to use stage 0 libraries, but because it depends on rustdoc,
those don't exist: rustdoc is built against stage 1 libraries.

This patch aligns those two and passes the stage 1 libdir to the error
index.

@GuillaumeGomez discovered that this hasn't worked (presumably for a long time now, but not sure).

r? @alexcrichton
2018-07-23 01:00:09 +08:00
kennytm
aea141e72c
Rollup merge of #52587 - csmoe:doc, r=kennytm
Add missing backtick in UniversalRegions doc comment

r? @QuietMisdreavus
2018-07-23 01:00:07 +08:00
kennytm
1208944ccb
Rollup merge of #52582 - felixrabe:patch-2, r=pietroalbini
Typo
2018-07-23 01:00:05 +08:00
kennytm
8e6971dd2d
Rollup merge of #52581 - petrochenkov:bmacrodoc, r=alexcrichton
Avoid using `#[macro_export]` for documenting builtin macros

Use a special `rustc_*` attribute instead.

cc https://github.com/rust-lang/rust/pull/52234
2018-07-23 01:00:03 +08:00
bors
32772fddd5 Auto merge of #52572 - davidtwco:issue-51027, r=nikomatsakis
NLL diagnostics replaced nice closure errors w/ indecipherable free region errors

Fixes #51027.

r? @nikomatsakis
2018-07-22 16:48:09 +00:00
Zack M. Davis
41d5c0ce1f in which the elided-lifetimes-in-paths lint undergoes a revolution
The existing elided-lifetimes-in-paths lint (introduced in Nov. 2017's
accd997b5 / #46254) lacked stuctured suggestions and—much more
alarmingly—produced false positives on associated functions (like
`Ref::clone`) and on anonymous '_ lifetimes (!!—yes, the very
anonymous lifetimes that we meant to suggest "instead"). That this
went apparently unnoticed for so long maybe tells you something about
how many people actually bother to flip on allow-by-default lints.

After many hours of good old-fashioned American elbow grease—and a
little help from expert reviewers—it turns out that getting the right
answer is a lot easier if we fire the lint while lowering the Higher
Intermediate Representation.

The lint is promoted to the idioms-2018 group.

Also, in the matter of test filenames, "elided" only has one 'l' (see,
e.g., https://en.wiktionary.org/wiki/elide).

Resolves #52041.
2018-07-22 08:27:10 -07:00
kennytm
02357079a6
Rollup merge of #52521 - ehuss:rustdoc-passes-doc, r=kennytm
Fix links in rustdoc book.

Due to a change in how mdbook generates section anchors, headers
with non-alphabetic characters now start with "a".
2018-07-22 22:10:14 +08:00
kennytm
519651acca
Rollup merge of #52508 - joshtriplett:dangling-not-sentinel, r=Mark-Simulacrum
Document that Unique::empty() and NonNull::dangling() aren't sentinel values

The documentation of Unique::empty() and NonNull::dangling() could
potentially suggest that they work as sentinel values indicating a
not-yet-initialized pointer. However, they both declare a non-null
pointer equal to the alignment of the type, which could potentially
reference a valid value of that type (specifically, the first such valid
value in memory). Explicitly document that the return value of these
functions does not work as a sentinel value.
2018-07-22 22:10:13 +08:00
kennytm
82cdbf1d3a
Rollup merge of #52507 - estebank:infer-type, r=nikomatsakis
Reword when `_` couldn't be inferred

r? @nikomatsakis
2018-07-22 22:10:11 +08:00
kennytm
180ad53576
Rollup merge of #52465 - sekineh:add-ci-thumb, r=alexcrichton
Add CI test harness for `thumb*` targets. [IRR-2018-embedded]

This pull request will do the following (rather trivial) changes:
- Fix #52163. In other words, we enabled `./x.py test src/test/run-make` for `no_std` targets.
- Modify `dist-various-1` Dockerfile.
  - CI now performs `run-make` test run on the targets below:
    - `thumbv6m-none-eabi`
    - `thumbv7m-none-eabi`
    - `thumbv7em-none-eabi`
    - `thumbv7em-none-eabihf`.
- ~~Add `thumb-none` Dockerfile.~~
  - ~~Initially, `thumbv7m-none-eabi`, `thumbv7em-none-eabi` and `thumbv7em-none-eabihf` are included as the tested target. `thumbv6m-none-eabi` is disabled for now because LLVM support is not certain.~~
- ~~Add `thumb-none` to .travis.yml~~

Note:
- `run-make` tests are not implemented yet. This PR is test harness only.

The amount of change is very small, but I'd like to open the pull request while the change is trivial.
Because I'm not very used to pull request process, I want to make a small progress first.  This PR will be a foundation for later additions.

CC @kennytm @jamesmunns @nerdyvaishali
2018-07-22 22:10:10 +08:00
kennytm
67cf3ba528
Rollup merge of #51807 - newpavlov:deprecate_str_slice, r=alexcrichton
Deprecation of str::slice_unchecked(_mut)

Closes #51715

I am not sure if 1.28.0 or 1.29.0 should be used for deprecation version, for now it's 1.28.0.

Additionally I've replaced `slice_unchecked` uses with `get_unchecked`. The only places where this method is still used are `src/liballoc/tests/str.rs` and `src/liballoc/tests/str.rs`.
2018-07-22 22:10:09 +08:00
David Wood
c645ecd0a6
Added new lines to .gitignore. 2018-07-22 14:14:39 +01:00
Oliver Schneider
233a6e13ca
Use correct exclusion comment 2018-07-22 14:44:17 +02:00
David Wood
c64db0078a
Fallback to general error handling in ICE cases. 2018-07-22 12:53:55 +01:00
David Wood
b6dfa8cba3
Modified how constraint classification happens to upvars, can now handle function call case. 2018-07-22 12:53:53 +01:00
David Wood
ce4f446aa8
Improved is_upvar_field_projection - no longer need recurse parameter. 2018-07-22 12:53:51 +01:00
David Wood
f71dbbb44f
Improved documentation of functions in new module. 2018-07-22 12:49:42 +01:00
David Wood
571eec627c
Improved closure errors. 2018-07-22 12:49:35 +01:00
David Wood
24c5751197
Classify aggregate rvalues as assignments. 2018-07-22 12:23:53 +01:00