Commit Graph

51767 Commits

Author SHA1 Message Date
Andreas Linz
2eb84299ca Fix missing console output in Barrier example
The `println!` calls in the previous version were never shown (at least
not in the playpen) because the main thread is finished before all the
spawned child threads were synchronized. This commit adds a join for
each thread handle to wait in the main thread until all child threads
are finished.
2016-03-26 14:53:27 +01:00
bors
c9b6ba800a Auto merge of #32468 - cardoe:llvm-check, r=alexcrichton
configure: update required LLVM version

Rust 1.7.0 and newer appears to require LLVM 3.6.0 or newer when
building against a version that's out of the tree with the --llvm-root
flag.

Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
2016-03-26 03:31:56 -07:00
bors
d322f990b0 Auto merge of #32496 - Manishearth:rollup, r=Manishearth
Rollup of 11 pull requests

- Successful merges: #32131, #32199, #32257, #32325, #32435, #32447, #32448, #32456, #32469, #32476, #32482
- Failed merges: #32240
2016-03-26 01:13:31 -07:00
Manish Goregaokar
6c10866b02 Fixup #32476 2016-03-26 13:42:05 +05:30
Manish Goregaokar
317acb7d13 Rollup merge of #32482 - nikomatsakis:erase-via-visitor, r=nagisa
use new visitor to erase regions

r? @nagisa
2016-03-26 13:42:05 +05:30
Manish Goregaokar
d36cb2209f Rollup merge of #32476 - diwic:63-null-thread-name, r=alexcrichton
Fix unsound behaviour with null characters in thread names (issue #32475)

Previously, the thread name (&str) was converted to a CString in the
new thread, but outside unwind::try, causing a panic to continue into FFI.

This patch changes that behaviour, so that the panic instead happens
in the parent thread (where panic infrastructure is properly set up),
not the new thread.

This could potentially be a breaking change for architectures who don't
support thread names.
2016-03-26 13:42:04 +05:30
Manish Goregaokar
e3e58247a3 Rollup merge of #32469 - nikomatsakis:shared-cgu, r=eddyb
make available monomorphizations shared by CGU

The current setup means that all generics are local to a codegen-unit,
which means massive duplication.
2016-03-26 13:42:04 +05:30
Manish Goregaokar
671027817c Rollup merge of #32456 - bluss:str-zero, r=alexcrichton
Hardcode accepting 0 as a valid str char boundary

If we check explicitly for index == 0, that removes the need to read the
byte at index 0, so it avoids a trip to the string's memory, and it
optimizes out the slicing index' bounds check whenever it is (a constant) zero.
2016-03-26 13:42:04 +05:30
Manish Goregaokar
023fae6175 Rollup merge of #32448 - sfackler:time-augmented-assignment, r=alexcrichton
Add augmented assignment operator impls for time types

r? @alexcrichton
2016-03-26 13:42:03 +05:30
Manish Goregaokar
515e87dde2 Rollup merge of #32447 - nodakai:dots-in-err-idx, r=Manishearth
Remove ungrammatical dots from the error index.

They were probably meant as a shorthand for omitted code.

Part of #32446 but there should be a separate fix for the issue.
2016-03-26 13:42:03 +05:30
Manish Goregaokar
b55d7729c2 Rollup merge of #32435 - nrc:fix-err-recover, r=nikomatsakis
Some fixes for error recovery in the compiler
2016-03-26 13:42:03 +05:30
Manish Goregaokar
a8d59e0ca6 Rollup merge of #32257 - alexcrichton:fix-status-stdin, r=aturon
std: Fix inheriting stdin on status()

This regression was accidentally introduced in #31618, and it's just flipping a
boolean!

Closes #32254
2016-03-26 09:07:21 +05:30
Manish Goregaokar
128b2ad829 Rollup merge of #32199 - nikomatsakis:limiting-constants-in-patterns-2, r=pnkfelix
Restrict constants in patterns

This implements [RFC 1445](https://github.com/rust-lang/rfcs/blob/master/text/1445-restrict-constants-in-patterns.md). The primary change is to limit the types of constants used in patterns to those that *derive* `Eq` (note that implementing `Eq` is not sufficient). This has two main effects:

1. Floating point constants are linted, and will eventually be disallowed. This is because floating point constants do not implement `Eq` but only `PartialEq`. This check replaces the existing special case code that aimed to detect the use of `NaN`.
2. Structs and enums must derive `Eq` to be usable within a match.

This is a [breaking-change]: if you encounter a problem, you are most likely using a constant in an expression where the type of the constant is some struct that does not currently implement
`Eq`. Something like the following:

```rust
struct SomeType { ... }
const SOME_CONST: SomeType = ...;

match foo {
    SOME_CONST => ...
}
```

The easiest and most future compatible fix is to annotate the type in question with `#[derive(Eq)]` (note that merely *implementing* `Eq` is not enough, it must be *derived*):

```rust
struct SomeType { ... }
const SOME_CONST: SomeType = ...;

match foo {
    SOME_CONST => ...
}
```

Another good option is to rewrite the match arm to use an `if` condition (this is also particularly good for floating point types, which implement `PartialEq` but not `Eq`):

```rust
match foo {
    c if c == SOME_CONST => ...
}
```

Finally, a third alternative is to tag the type with `#[structural_match]`; but this is not recommended, as the attribute is never expected to be stabilized. Please see RFC #1445 for more details.

cc https://github.com/rust-lang/rust/issues/31434

r? @pnkfelix
2016-03-26 09:07:21 +05:30
Manish Goregaokar
b8b17a54cf Rollup merge of #32131 - petrochenkov:prim, r=eddyb
resolve: Minimize hacks in name resolution of primitive types

When resolving the first unqualified segment in a path with `n` segments and `n - 1` associated item segments, e.g. (`a` or `a::assoc` or `a::assoc::assoc` etc) try to resolve `a` without considering primitive types first. If the "normal" lookup fails or results in a module, then try to resolve `a` as a primitive type as a fallback.

This way backward compatibility is respected, but the restriction from E0317 can be lifted, i.e. primitive names mostly can be shadowed like any other names.

Furthermore, if names of primitive types are [put into prelude](https://github.com/petrochenkov/rust/tree/prim2) (now it's possible to do), then most of names will be resolved in conventional way and amount of code relying on this fallback will be greatly reduced. Although, it's not entirely convenient to put them into prelude right now due to temporary conflicts like `use prelude::v1::*; use usize;` in libcore/libstd, I'd better wait for proper glob shadowing before doing it.
I wish the `no_prelude` attribute were unstable as intended :(

cc @jseyfried @arielb1
r? @eddyb
2016-03-26 09:07:20 +05:30
bors
8d2d2be6c6 Auto merge of #32293 - nikomatsakis:incr-comp-def-path-munging, r=alexcrichton
Revamp symbol names for impls (and make them deterministic, etc)

This builds on @michaelwoerister's epic PR #31539 (note that his PR never landed, so I just incorporated it into this one). The main change here is that we remove the "name" from `DefPathData` for impls, since that name is synthetic and not sufficiently predictable for incr comp. However, just doing that would cause bad symbol names since those are based on the `DefPath`. Therefore, I introduce a new mechanism for getting symbol names (and also paths for user display) called `item_path`. This is kind of simplistic for now (based on strings) but I expect to expand it later to support richer types, hopefully generating C++-mangled names that gdb etc can understand. Along the way I cleaned up how we track the path that leads to an extern crate.

There is still some cleanup left undone here. Notably, I didn't remove the impl names altogether -- that would probably make sense. I also didn't try to remove the `item_symbols` vector. Mostly I want to unblock my other incr. comp. work. =)

r? @eddyb
cc @eddyb @alexcrichton @michaelwoerister
2016-03-25 18:09:28 -07:00
Niko Matsakis
1ea93c2a63 remove link-guard test 2016-03-25 19:33:13 -04:00
bors
a1e29daf1a Auto merge of #32167 - jseyfried:refactor_prelude, r=nikomatsakis
resolve: Refactor how the prelude is handled

This PR refactors how the prelude is handled in `resolve`.

Instead of importing names from the prelude into each module's `resolutions`, this PR adds a new field `prelude: RefCell<Option<Module>>` to `ModuleS` that is set during import resolution but used only when resolving in a lexical scope (i.e. the scope of an initial segment of a relative path).

r? @nikomatsakis
2016-03-25 15:53:16 -07:00
Jeffrey Seyfried
54cd4d1472 Add and use resolve_name_in_lexical_scope and
exclude the prelude from `resolve_name(.., allow_private_imports = true)`.
2016-03-25 22:22:15 +00:00
Jeffrey Seyfried
de970b1dff Refactor away NameResolution::result 2016-03-25 22:22:15 +00:00
Jeffrey Seyfried
5a8845e40b Refactor away DefModifiers::PRELUDE 2016-03-25 22:22:15 +00:00
Jeffrey Seyfried
febef471e3 Refactor how the prelude is handled 2016-03-25 22:22:12 +00:00
Jeffrey Seyfried
21064d097e Refactor away resolve_imports::Shadowable and rename shadowable -> is_prelude 2016-03-25 22:18:30 +00:00
Niko Matsakis
874574d548 change test to be specific for msvc 2016-03-25 17:33:17 -04:00
Niko Matsakis
2536ae55a4 fix error message 2016-03-25 15:14:45 -04:00
Niko Matsakis
944dc4aa65 fix cargo.toml for new dependency 2016-03-25 14:39:24 -04:00
Niko Matsakis
726ba6630d Rebase over my PR 2016-03-25 14:36:49 -04:00
Niko Matsakis
8a7b1bca04 Update backtrace test for FIXME on windows 2016-03-25 14:07:21 -04:00
Niko Matsakis
24059f74d7 Drive-by fix for unnecessary &mut 2016-03-25 14:07:21 -04:00
Niko Matsakis
fd25a63ba9 document test, don't use grep 2016-03-25 14:07:20 -04:00
Niko Matsakis
ab0a87243e test for immediate symbol name hashing 2016-03-25 14:07:20 -04:00
Niko Matsakis
87debd9328 include the immediate type in the symbol name hash
the intention is to give some simple protection like link-guards
but not impede ability to upgrade dylib in place
2016-03-25 14:07:20 -04:00
Niko Matsakis
814477a893 Revert "workarounds to make link guards work on windows"
This reverts commit b52004d202ddfffa100d4963216e1673a0be0b95.
2016-03-25 14:07:20 -04:00
Niko Matsakis
4c527457f1 rip out link guards
As discussed in
https://github.com/rust-lang/rust/pull/32293#issuecomment-200597130,
adding link guards are a heuristic that is causing undue complications:

- the link guards inject extra public symbols, which is not always OK.
- link guards as implemented could be a non-trivial performance hit,
  because no attempt is made to "de-duplicate" the dependency graph,
  so at worst you have O(N!) calls to the link guard functions.

Nonetheless, link guards are very helpful in detecting errors, so it may
be worth adding them back in some modified form in the future.
2016-03-25 14:07:20 -04:00
Niko Matsakis
b385ce1223 workarounds to make link guards work on windows
Link guards cause problems in some specific scenarios on windows because
they force libcore to be instantiated, since we do not GC functions
effectively on windows.

The changes here are two:

1. disable core for rsbegin/rsend
2. make panic_fmt an extern fn for smallest-hello-world so that it
   is not marked as "internal" for LLVM
2016-03-25 14:07:20 -04:00
Niko Matsakis
751c24d345 renumber error from E0522 to E0523
another name was added in the meantime
2016-03-25 14:07:20 -04:00
Niko Matsakis
b184d2712f check only that symbol names are deterministic
Full binary reproducible builds are not possible on all platforms
because linker injects a certain amount of randomness, apparently. Or,
at minimum, they don't work reliably yet.
2016-03-25 14:07:20 -04:00
Niko Matsakis
7e8e6712b5 Remove static linking hack since we are now passing absolute paths 2016-03-25 14:07:20 -04:00
Niko Matsakis
bca94230f3 Fix accursed issue-4264.pp 2016-03-25 14:07:20 -04:00
Niko Matsakis
e8dfaa71e6 Correections due to refactoring . 2016-03-25 14:07:20 -04:00
Niko Matsakis
5a68116240 pacify the merciless tidy: s/E0521/E0522
Gah. I always find it confusing that make tidy gives me the highest error
code, but not the **next** error code.
2016-03-25 14:07:20 -04:00
Niko Matsakis
af057bdb1c renumber diagnostic to avoid conflict
specialization nabbed E0520
2016-03-25 14:07:20 -04:00
Niko Matsakis
86fa58d6c8 remove unused variable in compiletest 2016-03-25 14:07:19 -04:00
Niko Matsakis
977636156a unit-test symbol-names and item-paths 2016-03-25 14:07:19 -04:00
Niko Matsakis
2291abf313 refactor item-paths in diagnostics, symbol names
This change has a few parts. We introduce a new `item_path` module for
constructing item paths. The job of this module is basically to make
nice, user-readable paths -- but these paths are not necessarily 100%
unique. They meant to help a *human* find code, but not necessarily a
compute. These paths are used to drive `item_path_str` but also symbol
names.

Because the paths are not unique, we also modify the symbol name hash to
include the full `DefPath`, whereas before it included only those
aspects of the def-path that were not included in the "informative"
symbol name.

Eventually, I'd like to make the item-path infrastructure a bit more
declarative.  Right now it's based purely on strings. In particular, for
impls, we should supply the raw types to the `ItemPathBuffer`, so that
symbol names can be encoded using the C++ encoding scheme for better
integration with tooling.
2016-03-25 14:07:19 -04:00
Niko Matsakis
cd5cf09635 add krate_attrs accessor
makes better edges in dep graph
2016-03-25 14:07:19 -04:00
Niko Matsakis
ab9b844146 track the extern-crate def-id rather than path
We used to track, for each crate, a path that led to the extern-crate
that imported it. Instead of that, track the def-id of the extern crate,
along with a bit more information, and derive the path on the fly.
2016-03-25 14:07:19 -04:00
Niko Matsakis
6056c5fbed fallout: update codegen-units tests 2016-03-25 14:07:19 -04:00
Niko Matsakis
5e26508744 refactor DefPathData variants
In particular, remove the name from the Impl, since that name is
synthesized and is not predictable (it tends to break incr. comp.).

Also rename the variants to be a bit more uniform and remove some
distinctions that we were not really taking advantage of anywhere.
2016-03-25 14:07:19 -04:00
Niko Matsakis
7b6270b537 store krate information more uniformly
make DefPath store krate and enable uniform access to crate_name/crate_disambiguator
2016-03-25 14:07:19 -04:00
Niko Matsakis
65c0b7c292 track def-id for inlined items 2016-03-25 14:07:19 -04:00