Commit Graph

67508 Commits

Author SHA1 Message Date
bors
a7b7dce02d Auto merge of #44413 - est31:move_man, r=nikomatsakis
Move the man directory to a subdirectory

There is no reason it should be in the top directory.
2017-09-12 12:41:23 +00:00
bors
817e1b81e2 Auto merge of #44344 - jonhoo:entry_or_default, r=BurntSushi
Add or_default to Entry APIs

As argued for in #44324, this PR adds a new `or_default` method to the various `Entry` APIs (currently just for `BTreeMap` and `HashMap`) when `V: Default`. This method is effectively a shorthand for `or_insert_with(Default::default)`.
2017-09-12 09:54:59 +00:00
bors
8fc0fc8c2d Auto merge of #44310 - ldr709:master, r=BurntSushi
Additional traits for std::mem::ManuallyDrop

The first commit adds `Clone` and `Copy` trait implementations for `ManuallyDrop`. Although `Drop` and `Copy` cannot be used together, this may be useful for generics.

The second commit adds implementations common traits. I do not think this is necessary, as they could be implemented in a wrapper type outside the standard library, but it would make `ManuallyDrop` more convenient to use.
2017-09-12 07:13:40 +00:00
bors
3cb24bd37b Auto merge of #44275 - eddyb:deferred-ctfe, r=nikomatsakis
Evaluate fixed-length array length expressions lazily.

This is in preparation for polymorphic array lengths (aka `[T; T::A]`) and const generics.
We need deferred const-evaluation to break cycles when array types show up in positions which require knowing the array type to typeck the array length, e.g. the array type is in a `where` clause.

The final step - actually passing bounds in scope to array length expressions from the parent - is not done because it still produces cycles when *normalizing* `ParamEnv`s, and @nikomatsakis' in-progress lazy normalization work is needed to deal with that uniformly.

However, the changes here are still useful to unlock work on const generics, which @EpicatSupercell manifested interest in, and I might be mentoring them for that, but we need this baseline first.

r? @nikomatsakis cc @oli-obk
2017-09-12 04:14:07 +00:00
bors
11f64d8f88 Auto merge of #43716 - MaloJaffre:_-in-literals, r=petrochenkov
Accept underscores in unicode escapes

Fixes #43692.

I don't know if this need an RFC, but at least the impl is here!
2017-09-12 01:25:23 +00:00
bors
07d950f38f Auto merge of #44498 - alexcrichton:fix-nightlies, r=alexcrichton
rustbuild: Fix a distribution bug with rustdoc

Apparently `File::create` was called when there was an existing hard link or the
like, causing an existing file to get accidentally truncated!

Closes #44487
2017-09-11 22:49:20 +00:00
bors
eba374fb21 Auto merge of #44442 - Aaron1011:promote-static-ref, r=eddyb
Fix regression in promotion of rvalues referencing a static

This commit makes librustc_passes::consts::CheckCrateVisitor properly
mark expressions as promotable if they reference a static, as it's
perfectly fine for one static to reference another. It fixes a
regression that prevented a temporary rvalue from referencing a static
if it was itself declared within a static.

Prior to commit https://github.com/rust-lang/rust/commit/b8c05fe90bc,
`region::ScopeTree` would only register a 'terminating scope' for function
bodies. Thus, while rvalues in a static that referenced a static would be marked
unpromotable, the lack of enclosing scope would cause
mem_categorization::MemCategorizationContext::cat_rvalue_node
to compute a 'temporary scope' of `ReStatic`. Since this had the same
effect as explicitly selecting a scope of `ReStatic`
due to the rvalue being marked by CheckCrateVisitor as promotable,
no issue occurred.

However, commit https://github.com/rust-lang/rust/commit/b8c05fe90bc
made ScopeTree unconditionally register a 'terminating scope'
Since mem_categorization would now compute a non-static 'temporary scope', the
aforementioned rvalues would be erroneously marked as living for too
short a time.

By fixing the behavior of CheckCrateVisitor, this commit avoids changing
mem_categorization's behavior, while ensuring that temporary values in
statics are still allowed to reference other statics.

Fixes issue #44373
2017-09-11 20:02:19 +00:00
Alex Crichton
eb26d5b7c9 rustbuild: Fix a distribution bug with rustdoc
Apparently `File::create` was called when there was an existing hard link or the
like, causing an existing file to get accidentally truncated!

Closes #44487
2017-09-11 11:01:48 -07:00
bors
efa3ec67e2 Auto merge of #44435 - alexcrichton:in-scope, r=michaelwoerister
rustc: Remove HirId from queries

This'll allow us to reconstruct query parameters purely from the `DepNode`
they're associated with.

Closes #44414
2017-09-11 15:35:35 +00:00
Alex Crichton
caaf365a9d rustc: Remove HirId from queries
This'll allow us to reconstruct query parameters purely from the `DepNode`
they're associated with. Some queries could move straight to `HirId` but others
that don't always have a correspondance between `HirId` and `DefId` moved to
two-level maps where the query operates over a `DefIndex`, returning a map,
which is then keyed off `ItemLocalId`.

Closes #44414
2017-09-11 07:53:48 -07:00
Aaron Hill
fb540e3de4 Update comment to properly describe static promotion restrictions 2017-09-11 10:51:28 -04:00
bors
19d30fcdb2 Auto merge of #44440 - cuviper:min_global_align, r=japaric
Add `TargetOptions::min_global_align`, with s390x at 16-bit

The SystemZ `LALR` instruction provides PC-relative addressing for globals,
but only to *even* addresses, so other compilers make sure that such
globals are always 2-byte aligned.  In Clang, this is modeled with
`TargetInfo::MinGlobalAlign`, and `TargetOptions::min_global_align` now
serves the same purpose for rustc.

In Clang, the only targets that set this are SystemZ, Lanai, and NVPTX, and
the latter two don't have targets in rust master.

Fixes #44411.
r? @eddyb
2017-09-11 12:53:21 +00:00
bors
5d744e94c2 Auto merge of #44410 - alexcrichton:fix-travis, r=Mark-Simulacrum
Fix sanitizer tests on buggy kernels

Travis recently pushed an update to the Linux environments, namely the kernels
that we're running on. This in turn caused some of the sanitizer tests we run to
fail. We also apparently weren't the first to hit these failures! Detailed in
google/sanitizers#837 these tests were failing due to a specific commit in the
kernel which has since been backed out, but for now work around the buggy kernel
that's deployed on Travis and eventually we should be able to remove these
flags.
2017-09-11 09:47:06 +00:00
bors
a0b34199ba Auto merge of #44385 - alexcrichton:new-sccache-keys, r=alexcrichton
Rotate Travis/AppVeyor S3 keys

Haven't done this in awhile so seems like a good idea!
2017-09-11 07:18:27 +00:00
Eduard-Mihai Burtescu
57ebd28fdb rustc: use ConstVal::Unevaluated instead of mir::Literal::Item. 2017-09-11 08:41:16 +03:00
Eduard-Mihai Burtescu
74349fa288 rustc: evaluate fixed-length array length expressions lazily. 2017-09-11 08:41:16 +03:00
Eduard-Mihai Burtescu
88217618ec rustc: remove obsolete const_val::ErrKind::{Negate,Not}On. 2017-09-11 08:41:15 +03:00
Eduard-Mihai Burtescu
8a9b78f5cc rustc: use ty::Const for the length of TyArray. 2017-09-11 08:41:15 +03:00
Eduard-Mihai Burtescu
3ce31eb990 rustc: replace usize with u64 and ConstUsize. 2017-09-11 08:41:15 +03:00
Eduard-Mihai Burtescu
932289c12d rustc: introduce ty::Const { ConstVal, Ty }. 2017-09-11 08:41:15 +03:00
Eduard-Mihai Burtescu
50076b00c2 rustc: intern ConstVal's in TyCtxt. 2017-09-11 08:41:03 +03:00
bors
909733286f Auto merge of #44383 - qmx:gh/40473/no-inline-trait-method, r=nikomatsakis
MIR: should not inline trait method

Fixes #40473.

The idea here is bailing out of inlining if we're talking about a trait method.
2017-09-11 04:59:28 +00:00
bors
e6bce95094 Auto merge of #44375 - topecongiro:macrodef-span, r=petrochenkov
Add visibility to span for macros 2.0

cc https://github.com/rust-lang-nursery/rustfmt/issues/1949.
r? @nrc
2017-09-11 02:23:24 +00:00
bors
3d29f0e8fd Auto merge of #44316 - eddyb:no-local-var-def-id, r=michaelwoerister
Use NodeId/HirId instead of DefId for local variables.

r? @michaelwoerister
2017-09-10 21:55:43 +00:00
bors
ca94c75c52 Auto merge of #44220 - kennytm:fix-44216-instance-plus-max-duration-should-panic, r=alexcrichton
Properly detect overflow in Instance ± Duration.

Fix #44216.
Fix #42622

The computation `Instant::now() + Duration::from_secs(u64::max_value())` now panics. The call `receiver.recv_timeout(Duration::from_secs(u64::max_value()))`, which involves such time addition, will also panic.

The reason #44216 arises is because of an unchecked cast from `u64` to `i64`, making the duration equivalent to -1 second.

Note that the current implementation is over-conservative, since e.g. (-2⁶²) + (2⁶³) is perfectly fine for an `i64`, yet this is rejected because (2⁶³) overflows the `i64`.
2017-09-10 18:37:27 +00:00
bors
b413f34087 Auto merge of #44079 - gaurikholkar:named_conf, r=nikomatsakis
Extend E0623 for LateBound and EarlyBound Regions

This is a fix for #43882
```
fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) {
    x.push(y);
}
```
now gives

```
error[E0623]: lifetime mismatch
  --> $DIR/ex3-both-anon-regions-latebound-regions.rs:12:12
   |
11 | fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) {
   |                           ------      ------ these two types are declared with different lifetimes...
12 |     x.push(y);
   |            ^ ...but data from `y` flows into `x` here
```
cc @nikomatsakis @arielb1

Please ignore the second commit. It will be merged in a separate PR.
2017-09-10 15:32:20 +00:00
bors
d290dec97f Auto merge of #44474 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 13 pull requests

- Successful merges: #44262, #44329, #44332, #44347, #44372, #44384, #44387, #44396, #44449, #44451, #44457, #44464, #44467
- Failed merges:
2017-09-10 12:48:55 +00:00
Guillaume Gomez
8a7d93bf6f Rollup merge of #44467 - toidiu:ak-44382, r=frewsxcv
documentation update to demonstrate mutability

#44467

- demonstrate correct implementation returns `Some`
- demonstrate out of bounds returns `None`
- demonstrate mutability
2017-09-10 14:03:32 +02:00
Guillaume Gomez
dcc1d1463a Rollup merge of #44464 - Dushistov:master, r=alexcrichton
add test for #41229

Closes #41229
2017-09-10 14:03:31 +02:00
Guillaume Gomez
329ed4affe Rollup merge of #44457 - napen123:master, r=frewsxcv
Add doc examples for str::as_bytes_mut

Fixes #44427
2017-09-10 14:03:30 +02:00
Guillaume Gomez
485847dd70 Rollup merge of #44451 - Zoxc:gen-panic, r=eddyb
Fix bitrotted generator panic emission

r? @eddyb
2017-09-10 14:03:29 +02:00
Guillaume Gomez
d3ef39f2af Rollup merge of #44449 - tommyip:doc_string_as_str, r=frewsxcv
Add doc example to String::as_str

Fixes #44428.
2017-09-10 14:03:28 +02:00
Guillaume Gomez
f76f2c76dc Rollup merge of #44396 - joshlf:tls-comment, r=alexcrichton
std:🧵:LocalKey: Document limitation with initializers

Document that if a `LocalKey`'s initializer recursively depends on itself, initialization will result in infinite recursion.
2017-09-10 14:03:27 +02:00
Guillaume Gomez
06f39fa10e Rollup merge of #44387 - est31:update_compiler_builtins, r=Mark-Simulacrum
Update the libcompiler_builins submodule

Pulls in https://github.com/rust-lang-nursery/compiler-builtins/pull/187 for nicer build output :)
2017-09-10 14:03:26 +02:00
Guillaume Gomez
0e2dac7eba Rollup merge of #44384 - alexcrichton:osx-segfault, r=estebank
std: Fix a segfault on OSX with backtraces

Apparently `dladdr` can succeed but still give you NULL pointers!

Closes #44379
2017-09-10 14:03:25 +02:00
Guillaume Gomez
1e4ab871f5 Rollup merge of #44372 - bgermann:master, r=alexcrichton
Use memalign instead of posix_memalign for Solaris

As pointed out in https://github.com/rust-lang/libc/commit/deb61c8,
Solaris 10 does not support posix_memalign.
Use memalign for all Solaris versions instead.
With this change applied I am able to cross-build rustc for Solaris 10.
2017-09-10 14:03:24 +02:00
Guillaume Gomez
65fd1a20b0 Rollup merge of #44347 - GuillaumeGomez:rustdoc-false-positive, r=QuietMisdreavus
Reduce false positives number in rustdoc html diff

cc @rust-lang/dev-tools
r? @nrc

Very simple trick but should lighten html diff a bit
2017-09-10 14:03:23 +02:00
Guillaume Gomez
62659ebf66 Rollup merge of #44332 - tirr-c:issue-44021, r=petrochenkov
Expect pipe symbol after closure parameter list

Fixes #44021.

---

Originally, the parser just called `bump` to discard following token after parsing closure parameter list, because it assumes `|` is following. However, the following code breaks the assumption:

```rust
struct MyStruct;
impl MyStruct {
   fn f() {|x, y}
}
```

Here, the parameter list is `x, y` and the following token is `}`. The parser discards `}`, and then we have a curly bracket mismatch.

Indeed, this code has a syntax error. On current nightly, the compiler emits an syntax error, but with incorrect message and span, followed by an ICE.

```
error: expected expression, found `}`
 --> 44021.rs:4:1
  |
4 | }
  | ^

error: internal compiler error: unexpected panic
```

Even worse, on current stable(1.20.0), the compiler falls into an infinite loop.

This pull request fixes this problem. Now the compiler emits correct error message and span, and does not ICE.

```
error: expected one of `:`, `@`, or `|`, found `}`
 --> 44021.rs:3:20
  |
3 |     fn foo() {|x, y}
  |                    ^ expected one of `:`, `@`, or `|` here
```
2017-09-10 14:03:22 +02:00
Guillaume Gomez
078e1c546c Rollup merge of #44329 - nrc:pulldown-warn-fix, r=ollie27
Fixup some nits from #44238

r? @ollie27
2017-09-10 14:03:21 +02:00
Guillaume Gomez
9af7de1cb8 Rollup merge of #44262 - alexcrichton:repr-128-gate, r=nikomatsakis
rustc: Separately feature gate repr(i128)

Brought up during the discussion of #35118, the support for this is still
somewhat buggy and so stabilization likely wants to be considered independently
of the type itself.
2017-09-10 14:03:20 +02:00
bors
23aaeb573b Auto merge of #44312 - eddyb:static-by-any-other-name, r=alexcrichton
Use rvalue promotion to 'static instead of static items.

Fixes #44240. Among other things, in crates that do a lot of formatting, this could reduce the number of items, although I haven't measured the performance benefits. If there's a codegen slowdown, that should IMO be solved by caching the output of miri, *not* by using `static`.

r? @alexcrichton
2017-09-10 10:09:47 +00:00
Niko Matsakis
88e4bf6827 fix "correct" case in diagnostic error message 2017-09-10 06:08:29 -04:00
Eduard-Mihai Burtescu
10f66bd6e4 Use rvalue promotion to 'static instead of static items. 2017-09-10 11:20:27 +03:00
bors
34035d23ff Auto merge of #44418 - alexcrichton:remove-dep-graph, r=michaelwoerister
rustc: Remove `DepGraph` handling from rustc_metadata

This should now be entirely tracked through queries, so no need to have a
`DepGraph` in the `CStore` object any more!

cc #44390
2017-09-10 07:33:46 +00:00
bors
6d445e16b5 Auto merge of #44260 - alexcrichton:hardlink-no-copy, r=Mark-Simulacrum
rustbuild: Switch back to using hard links

The `copy` function historically in rustbuild used hard links to speed up the
copy operations that it does. This logic was backed out, however, in #39518 due
to a bug that only showed up on Windows, described in #39504. The cause
described in #39504 happened because Cargo, on a fresh build, would overwrite
the previous artifacts with new hard links that Cargo itself manages.

This behavior in Cargo was fixed in rust-lang/cargo#4390 where it no longer
should overwrite files on fresh builds, opportunistically leaving the filesystem
intact and not touching it.

Hopefully this can help speed up local builds by doing fewer copies all over the
place!
2017-09-10 04:36:15 +00:00
kennytm
4962f9d725
Relaxed error pattern, and add test for SystemTime as well. 2017-09-10 12:35:47 +08:00
Alex Crichton
38bedfabb9 rustbuild: Switch back to using hard links
The `copy` function historically in rustbuild used hard links to speed up the
copy operations that it does. This logic was backed out, however, in #39518 due
to a bug that only showed up on Windows, described in #39504. The cause
described in #39504 happened because Cargo, on a fresh build, would overwrite
the previous artifacts with new hard links that Cargo itself manages.

This behavior in Cargo was fixed in rust-lang/cargo#4390 where it no longer
should overwrite files on fresh builds, opportunistically leaving the filesystem
intact and not touching it.

Hopefully this can help speed up local builds by doing fewer copies all over the
place!
2017-09-09 21:14:44 -07:00
Alex Crichton
d724d03389 rustc: Remove DepGraph handling from rustc_metadata
This should now be entirely tracked through queries, so no need to have a
`DepGraph` in the `CStore` object any more!
2017-09-09 21:11:25 -07:00
bors
f982ff05db Auto merge of #44274 - Mark-Simulacrum:rustdoc-tests, r=alexcrichton
Test rustdoc.

Also fixes the broken tests.

r? @alexcrichton
2017-09-10 01:24:14 +00:00
toidiu
c430fa8084 documentation update to demonstrate mutability 2017-09-09 16:56:12 -04:00