Commit Graph

74190 Commits

Author SHA1 Message Date
Felix S. Klock II
c8041dd8ac Add AutoBorrowMutability; its like hir::Mutability but w/ two-phase borrow info too.
Namely, the mutable borrows also carries a flag indicating whether
they should support two-phase borrows.

This allows us to thread down, from the point of the borrow's
introduction, whether the particular adjustment that created it is one
that yields two-phase mutable borrows.
2018-02-08 12:16:30 +01:00
Felix S. Klock II
1855ab7424 Restrict two-phase borrows to solely borrows introduced via autoref.
Added `-Z two-phase-beyond-autoref` to bring back old behavior (mainly
to allow demonstration of desugared examples).

Updated tests to use aforementioned flag when necessary. (But in each
case where I added the flag, I made sure to also include a revision
without the flag so that one can readily see what the actual behavior
we expect is for the initial deployment of NLL.)
2018-02-08 12:16:30 +01:00
Felix S. Klock II
c00266b7ac Encode (in MIR) whether borrows are explicit in source or arise due to autoref.
This is foundation for issue 46747 (limit two-phase borrows to method-call autorefs).
2018-02-08 12:16:25 +01:00
bors
4f93357d3b Auto merge of #47607 - davidtwco:issue-45697, r=nikomatsakis
MIR-borrowck: augmented assignment causes duplicate errors

Fixes #45697. This PR resolves the error duplication. I attempted to replace the existing sets since there were quite a few but only managed to replace two of them.

r? @nikomatsakis
2018-02-07 02:20:23 +00:00
bors
bd98fe0c05 Auto merge of #48040 - kennytm:rollup, r=kennytm
Rollup of 7 pull requests

- Successful merges: #46962, #47986, #48012, #48013, #48026, #48031, #48036
- Failed merges:
2018-02-06 19:28:54 +00:00
kennytm
7f0e87a781
Rollup merge of #48036 - durka:proc-macro-doteq, r=alexcrichton
proc_macro: don't panic parsing ..= (fix #47950)
2018-02-07 03:23:30 +08:00
kennytm
d0e7da48fa
Rollup merge of #48031 - matthiaskrgr:exampleconfigtoml_typos, r=kennytm
config.toml.example: fix typos.

Most of them were found by codespell: https://github.com/lucasdemarchi/codespell
2018-02-07 03:23:29 +08:00
kennytm
ccdb320c68
Rollup merge of #48026 - Badel2:doc-assoc-const-object-safe, r=nikomatsakis
Document that associated constants prevent a trait from being made into an object

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

Add a short mention of associated constants to E0038
2018-02-07 03:23:28 +08:00
kennytm
3373f65682
Rollup merge of #48013 - onur:use-time-in-bootstrap-dist, r=alexcrichton
Use time crate in bootstrap dist instead of date

`bootstrap dist` command is trying to run *NIX specific `date` command to get current month and year. This command keep failing when it's called on a Windows command prompt. This patch is making it use time crate.

Closes: #47908
2018-02-07 03:23:26 +08:00
kennytm
4f184eb6a3
Rollup merge of #48012 - scottmcm:faster-rangeinclusive-fold, r=alexcrichton
Override try_[r]fold for RangeInclusive

Because the last item needs special handling, it seems that LLVM has trouble canonicalizing the loops in external iteration.  With the override, it becomes obvious that the start==end case exits the loop (as opposed to the one *after* that exiting the loop in external iteration).

Demo adapted from https://github.com/rust-lang/rust/issues/45222
```rust
#[no_mangle]
pub fn foo3r(n: u64) -> u64 {
    let mut count = 0;
    (0..n).for_each(|_| {
        (0 ..= n).rev().for_each(|j| {
            count += j;
        })
    });
    count
}
```

<details>
 <summary>Current nightly ASM, 100 lines (https://play.rust-lang.org/?gist=f5674c702c6e2045c3aab5d03763e5f6&version=nightly&mode=release)</summary>

```asm
foo3r:
	pushq	%rbx
.Lcfi0:
.Lcfi1:
	testq	%rdi, %rdi
	je	.LBB0_1
	testb	$1, %dil
	jne	.LBB0_4
	xorl	%eax, %eax
	xorl	%r8d, %r8d
	cmpq	$1, %rdi
	jne	.LBB0_11
	jmp	.LBB0_23
.LBB0_1:
	xorl	%eax, %eax
	popq	%rbx
	retq
.LBB0_4:
	xorl	%r8d, %r8d
	movq	$-1, %r9
	xorl	%eax, %eax
	movq	%rdi, %r11
	xorl	%r10d, %r10d
	jmp	.LBB0_5
.LBB0_8:
	addq	%r11, %rax
	movq	%rsi, %r11
	movq	%rdx, %r10
.LBB0_5:
	cmpq	%r11, %r10
	movl	$1, %ecx
	cmovbq	%r9, %rcx
	cmoveq	%r8, %rcx
	testq	%rcx, %rcx
	movl	$0, %esi
	movl	$1, %edx
	je	.LBB0_8
	cmpq	$-1, %rcx
	jne	.LBB0_9
	leaq	-1(%r11), %rsi
	movq	%r10, %rdx
	jmp	.LBB0_8
.LBB0_9:
	movl	$1, %r8d
	cmpq	$1, %rdi
	je	.LBB0_23
.LBB0_11:
	xorl	%r9d, %r9d
	movq	$-1, %r10
.LBB0_12:
	movq	%rdi, %rsi
	xorl	%r11d, %r11d
	jmp	.LBB0_13
.LBB0_16:
	addq	%rsi, %rax
	movq	%rcx, %rsi
	movq	%rbx, %r11
.LBB0_13:
	cmpq	%rsi, %r11
	movl	$1, %edx
	cmovbq	%r10, %rdx
	cmoveq	%r9, %rdx
	testq	%rdx, %rdx
	movl	$0, %ecx
	movl	$1, %ebx
	je	.LBB0_16
	cmpq	$-1, %rdx
	jne	.LBB0_17
	leaq	-1(%rsi), %rcx
	movq	%r11, %rbx
	jmp	.LBB0_16
.LBB0_17:
	movq	%rdi, %rcx
	xorl	%r11d, %r11d
	jmp	.LBB0_18
.LBB0_21:
	addq	%rcx, %rax
	movq	%rsi, %rcx
	movq	%rbx, %r11
.LBB0_18:
	cmpq	%rcx, %r11
	movl	$1, %edx
	cmovbq	%r10, %rdx
	cmoveq	%r9, %rdx
	testq	%rdx, %rdx
	movl	$0, %esi
	movl	$1, %ebx
	je	.LBB0_21
	cmpq	$-1, %rdx
	jne	.LBB0_22
	leaq	-1(%rcx), %rsi
	movq	%r11, %rbx
	jmp	.LBB0_21
.LBB0_22:
	addq	$2, %r8
	cmpq	%rdi, %r8
	jne	.LBB0_12
.LBB0_23:
	popq	%rbx
	retq
.Lfunc_end0:
```
</details><br>

With this PR:
```asm
foo3r:
	test	rcx, rcx
	je	.LBB3_1
	lea	r8, [rcx - 1]
	lea	rdx, [rcx - 2]
	mov	rax, r8
	mul	rdx
	shld	rdx, rax, 63
	imul	r8, r8
	add	r8, rcx
	sub	r8, rdx
	imul	r8, rcx
	mov	rax, r8
	ret
.LBB3_1:
	xor	r8d, r8d
	mov	rax, r8
	ret
```
2018-02-07 03:23:25 +08:00
kennytm
a026e8a972
Rollup merge of #47986 - Gilnaa:libtest_relaxed, r=Mark-Simulacrum
libtest: Replace panics with error messages

This replaces explicit panics on failures in libtest with prints to stderr.
Where "failures" == CLI argument parsing and such

Before:
```
$ ./foo-stable --not-an-option
thread 'main' panicked at '"Unrecognized option: \'not-an-option\'"', libtest/lib.rs:251:27
note: Run with `RUST_BACKTRACE=1` for a backtrace.
```

After:
```
$ ./foo-nightly --not-an-option
error: Unrecognized option: 'not-an-option'
```
2018-02-07 03:23:24 +08:00
kennytm
0a3e07dd72
Rollup merge of #46962 - clarcharr:os_raw_docs, r=QuietMisdreavus
Document std::os::raw.

This adds a brief explanation to each type and its definition according to C. This also helps clarify that the definitions of the types, as described by rustdoc, are not necessarily the same from platform to platform.
2018-02-07 03:23:23 +08:00
Badel2
498ef20a2a Trait objects cannot contain associated constants 2018-02-06 18:44:38 +01:00
David Wood
bb6e54d4bc
Added and updated tests to enable/disable overflow checks. 2018-02-06 17:37:49 +00:00
QuietMisdreavus
fefd5e9bbc fix docs link 2018-02-06 09:26:15 -06:00
Alex Burka
3cf73f40fb proc_macro: don't panic parsing ..= (fix #47950) 2018-02-06 14:43:01 +00:00
Matthias Krüger
8d8ba812d0 config.toml.example: fix typos.
Most of them were found by codespell: https://github.com/lucasdemarchi/codespell
2018-02-06 13:01:10 +01:00
bors
ca7d839088 Auto merge of #47203 - varkor:output-filename-conflicts-with-directory, r=estebank
Warn when rustc output conflicts with existing directories

When the compiled executable would conflict with a directory, display a
rustc error instead of a verbose and potentially-confusing linker
error. This is a usability improvement, and doesn’t actually change
behaviour with regards to compilation success. This addresses the
concern in #35887. Fixes #13098.
2018-02-06 09:51:03 +00:00
bors
b224fc84e3 Auto merge of #48017 - kennytm:rollup, r=kennytm
Rollup of 10 pull requests

- Successful merges: #46030, #47496, #47543, #47704, #47753, #47807, #47948, #47959, #48003, #48007
- Failed merges:
2018-02-06 07:02:25 +00:00
David Wood
5cd4b4fd95
Swapped order of left/right visits to ensure consistency in read/write pass ordering when -O is passed. 2018-02-05 22:31:56 +00:00
kennytm
0553dc81d3
Rollup merge of #48007 - nrc:rls-field-init, r=eddyb
save-analysis: avoid implicit unwrap

When looking up a field defintion, since the name might be incorrect in the field init shorthand case.

cc https://github.com/rust-lang-nursery/rls/issues/699

r? @eddyb
2018-02-06 02:13:55 +08:00
kennytm
e2f6e134c1
Rollup merge of #48003 - mbrubeck:docs, r=steveklabnik
Fix info about generic impls in AsMut docs

This text was copy-pasted from the `AsRef` docs to `AsMut`, but needed some additional adjustments for correctness.
2018-02-06 02:13:54 +08:00
kennytm
daecd15271
Rollup merge of #47959 - Manishearth:rustdoc-ice, r=Mark-Simulacrum
Fix rustdoc ICE on macros defined within functions

fixes #47639
2018-02-06 02:13:52 +08:00
kennytm
55aef3c9c7
Rollup merge of #47948 - pietroalbini:use-nested-groups-stabilize, r=petrochenkov
Stabilize use_nested_groups

As requested in #44494. Documentation PRs already sent.
2018-02-06 02:13:51 +08:00
kennytm
e8688b4a24
Rollup merge of #47807 - tbu-:pr_doc_constanttime_cstr, r=steveklabnik
Make wording around 0-cost casts more precise
2018-02-06 02:13:50 +08:00
kennytm
ddc4284b71
Rollup merge of #47753 - steveklabnik:update-book, r=alexcrichton
Update book

This PR does two things:

1. update the book to include https://github.com/rust-lang/book/pull/1088
2. update to mdbook 0.1

Both of these things are big changes, so I want to land them now, well before the next branch, so we can kick the tires.

------------------------------

Locally, I'm seeing some weirdness around the reference and this:

![image](https://user-images.githubusercontent.com/27786/35411917-8dcbb31a-01e8-11e8-8c30-0bd280d93b9d.png)

Putting this PR up so others can try and build and see if it reproduces for them.
2018-02-06 02:13:49 +08:00
kennytm
a405a08d72
Rollup merge of #47704 - dsprenkels:issue-44415, r=alexcrichton
Add a regression test for #44415

This PR adds a regression test for issue #44415.

Fixes #44415.
2018-02-06 02:13:48 +08:00
kennytm
9dab73773a
Rollup merge of #47543 - topecongiro:issue-42344, r=nikomatsakis
Disallow mutable borrow to non-mut statics

Closes #42344.
2018-02-06 02:13:46 +08:00
kennytm
cde119db8e
Rollup merge of #47496 - QuietMisdreavus:rls-doc-include, r=estebank
add documentation from doc(include) to analysis data

cc #44732

Currently save-analysis only loads docs from plain doc comments and doc attributes. Since `#[doc(include="filename.md")]` doesn't create a plain doc attribute when it loads the file, we need to be sure to pick up this info for the analysis data.
2018-02-06 02:13:45 +08:00
kennytm
eb5a4617a5
Rollup merge of #46030 - Zoxc:asm-volatile, r=nikomatsakis
Make inline assembly volatile if it has no outputs. Fixes #46026
2018-02-06 02:13:44 +08:00
bors
6c04c41034 Auto merge of #47881 - oli-obk:miri_clippy, r=Manishearth
Update clippy and miri submodule

r? @Manishearth

cc @kennytm I needed to touch the miri submodule's Cargo.toml to make sure that clippy gets the newest compiletest_rs. This will not fix miri, but since I touched the miri submodule, will this PR fail?

miri is unfixable until #46882 is merged
2018-02-05 15:05:43 +00:00
John Kåre Alsaker
a29d8545b5 Make inline assembly volatile if it has no outputs. Fixes #46026 2018-02-05 15:56:44 +01:00
Oliver Schneider
70717f20f5
Update clippy and miri submodule 2018-02-05 11:36:51 +01:00
Pietro Albini
01f0814a2a
Stabilize use_nested_groups 2018-02-05 10:23:40 +01:00
bors
b0a396bb0a Auto merge of #47920 - Aaron1011:nll-overflow, r=pnkfelix
Fix overflow when performing drop check calculations in NLL

Clearing out the infcx's region constraints after processing each type
ends up interacting badly with normalizing associated types. This commit
keeps all region constraints intact until the end of
TypeLivenessGenerator.add_drop_live_constraint, ensuring that normalized
types are able to re-use existing inference variables.

Fixes #47589
2018-02-05 09:17:00 +00:00
Onur Aslan
1461d12b3c Use time crate in bootstrap dist instead of date 2018-02-05 11:39:54 +03:00
Scott McMurray
1b1e887f4d Override try_[r]fold for RangeInclusive
Because the last item needs special handling, it seems that LLVM has trouble canonicalizing the loops in external iteration.  With the override, it becomes obvious that the start==end case exits the loop (as opposed to the one *after* that exiting the loop in external iteration).
2018-02-04 23:48:40 -08:00
bors
07ea260407 Auto merge of #47873 - Aaron1011:final-ref-coerce, r=nikomatsakis
Fix ref-to-ptr coercions not working with NLL in certain cases

Implicit coercions from references to pointers were lowered to slightly
different Mir than explicit casts (e.g. 'foo as *mut T'). This resulted
in certain uses of self-referential structs compiling correctly when an
explicit cast was used, but not when the implicit coercion was used.

To fix this, this commit adds an outer 'Use' expr when applying a
raw-ptr-borrow adjustment. This makes the lowered Mir for coercions
identical to that of explicit coercions, allowing the original code to
compile regardless of how the raw ptr cast occurs.

Fixes #47722
2018-02-05 04:32:06 +00:00
bors
dd29d3dd76 Auto merge of #47865 - Manishearth:cleanup-shim, r=nikomatsakis
Cleanup the shim code

 - We now write directly to `RETURN_PLACE` instead of creating intermediates
 - `tuple_like_shim` takes an iterator (used by #47867)
 - `tuple_like_shim` no longer relies on it being the first thing to create blocks, and uses relative block indexing in a cleaner way (necessary for #47867)
 - All the shim builders take `dest, src` arguments instead of hardcoding RETURN_PLACE

r? @eddyb
2018-02-05 01:45:46 +00:00
bors
e7e982ac03 Auto merge of #47998 - kennytm:rollup, r=kennytm
Rollup of 10 pull requests

- Successful merges: #47862, #47877, #47896, #47912, #47947, #47958, #47978, #47996, #47999, #47892
- Failed merges:
2018-02-04 22:58:10 +00:00
Nick Cameron
3c72a848e9 save-analysis: avoid implicit unwrap
When looking up a field defintion, since the name might be incorrect in the field init shorthand case.

cc https://github.com/rust-lang-nursery/rls/issues/699
2018-02-05 11:00:56 +13:00
steveklabnik
983cc00b80 add exceptions for new deps 2018-02-04 15:47:36 -05:00
steveklabnik
5437188e10 update mdbook to 0.1.2
and improve printing of errors
2018-02-04 15:47:35 -05:00
steveklabnik
b320829da4 update reference 2018-02-04 15:44:48 -05:00
steveklabnik
dcb3e21b06 update trpl
Includes https://github.com/rust-lang/book/pull/1088 and
62210e326c
2018-02-04 15:44:48 -05:00
Matt Brubeck
f243f9239d Fix info about generic impls in AsMut docs
This text was copy-pasted from the `AsRef` docs to `AsMut`, but needed
some additional adjustments for correctness.
2018-02-04 11:57:36 -08:00
kennytm
e17ebdf344
Rollup merge of #47892 - Badel2:const_type_id_of, r=oli-obk
Turn `type_id` into a constant intrinsic

https://github.com/rust-lang/rust/issues/27745

The method `get_type_id` in `Any` is intended to support reflection. It's currently unstable in favor of using an associated constant instead. This PR makes the `type_id` intrinsic a constant intrinsic, the same as `size_of` and `align_of`, allowing `TypeId::of` to be a `const fn`, which will allow using an associated constant in `Any`.
2018-02-05 01:27:36 +08:00
kennytm
66d6c855bd
Rollup merge of #47999 - jaystrictor:master, r=Mark-Simulacrum
Remove 'the this' in doc comments.
2018-02-05 01:20:56 +08:00
kennytm
adb5849b79
Rollup merge of #47996 - Zoxc:run-make-last, r=Mark-Simulacrum
Run the `run-make` tests last, so more tests run on Windows when `make` is unavailable
2018-02-05 01:19:41 +08:00
kennytm
393cd89267
Rollup merge of #47978 - eddyb:iu, r=kennytm
ui tests: diff from old (expected) to new (actual) instead of backwards.

Previously `actual` was "old" and `expected` was "new" which resulted in `+` before `-`.
AFAIK all diff tools put `-` before `+`, which made the previous behavior *very confusing*.

r? @nikomatsakis
2018-02-04 23:29:01 +08:00