Commit Graph

51866 Commits

Author SHA1 Message Date
bors
97ec69fb95 Auto merge of #32325 - alexcrichton:panic-once, r=aturon
std: Rewrite Once with poisoning

This commit rewrites the `std::sync::Once` primitive with poisoning in mind in
light of #31688. Currently a panic in the initialization closure will cause
future initialization closures to run, but the purpose of a Once is usually to
initialize some global state so it's highly likely that the global state is
corrupt if a panic happened. The same strategy of a mutex is taken where a panic
is propagated by default.

A new API, `call_once_force`, was added to subvert panics like is available on
Mutex as well (for when panicking is handled internally).

Adding this support was a significant enough change to the implementation that
it was just completely rewritten from scratch, primarily to avoid using a
`StaticMutex` which needs to have `destroy()` called on it at some point (a pain
to do).

Closes #31688
2016-03-26 15:14:29 -07:00
NODA, Kai
bf94aefd5a libstd/sys/*/net: very minor clean up of cvt*() utility functions.
Signed-off-by: NODA, Kai <nodakai@gmail.com>
2016-03-27 05:19:10 +08:00
bors
13bfd5c0b7 Auto merge of #32240 - jseyfried:cleanup_resolve, r=nikomatsakis
Cleanup resolve

This is a collection of small refactorings and improvements in `resolve`, most of which could stand alone.
r? @nikomatsakis
2016-03-26 12:40:53 -07:00
Jeffrey Seyfried
e011ae5ea9 Cleanup trait search 2016-03-26 18:23:57 +00:00
Jeffrey Seyfried
60a836fc93 Remove unnecessary pubs 2016-03-26 18:23:56 +00:00
Jeffrey Seyfried
227cc5cd26 Remove an if statement with an condition that is always false 2016-03-26 18:23:56 +00:00
Jeffrey Seyfried
3e7a22e3bc Remove outdated comment 2016-03-26 18:23:55 +00:00
Jeffrey Seyfried
4b6b506ef4 Improve the error message for paths with too many initial supers 2016-03-26 18:23:54 +00:00
Jeffrey Seyfried
8988c4538e Refactor away resolve_import_for_module 2016-03-26 18:23:53 +00:00
Jeffrey Seyfried
43dffc3294 Avoid passing around the current module as an argument in resolve_imports 2016-03-26 18:23:52 +00:00
Jeffrey Seyfried
bb09ae28c0 Refactor away resolve_name_in_lexical_scope and resolve_identifier_in_local_ribs. 2016-03-26 18:23:45 +00:00
Jeffrey Seyfried
73417853e4 Refactor out the common functionality of
`resolve_item_in_lexical_scope` and `resolve_identifier_in_local_ribs` into
a new function `resolve_ident_in_lexical_scope`.
2016-03-26 18:22:42 +00:00
Jeffrey Seyfried
07fecf8098 Replace uses of DefLike with Def (only the DlDef variant of DefLike was being used) 2016-03-26 18:22:41 +00:00
Jeffrey Seyfried
1744f55ad7 Refactor away GraphBuilder 2016-03-26 18:22:40 +00:00
Jeffrey Seyfried
0bed9aea2d Make populate_module_if_necessary a method of resolver 2016-03-26 18:22:37 +00:00
Jeffrey Seyfried
77f0f4a624 Avoid repeating parent 2016-03-26 18:22:34 +00:00
Jeffrey Seyfried
ff014a3a10 Refactor away populate_external_module 2016-03-26 18:22:33 +00:00
Jeffrey Seyfried
7bc6c75d0f Refactor away handle_external_def 2016-03-26 18:22:31 +00:00
Alex Crichton
c966c330c9 std: Rewrite Once with poisoning
This commit rewrites the `std::sync::Once` primitive with poisoning in mind in
light of #31688. Currently a panic in the initialization closure will cause
future initialization closures to run, but the purpose of a Once is usually to
initialize some global state so it's highly likely that the global state is
corrupt if a panic happened. The same strategy of a mutex is taken where a panic
is propagated by default.

A new API, `call_once_force`, was added to subvert panics like is available on
Mutex as well (for when panicking is handled internally).

Adding this support was a significant enough change to the implementation that
it was just completely rewritten from scratch, primarily to avoid using a
`StaticMutex` which needs to have `destroy()` called on it at some point (a pain
to do).

Closes #31688
2016-03-26 10:33:14 -07:00
bors
65bc9d7730 Auto merge of #32503 - dotdash:llvm_attrs, r=eddyb
Fix building on ARM
2016-03-26 10:25:03 -07:00
Jorge Aparicio
064ec35c18 add regression test for try! 2016-03-26 12:10:16 -05:00
Jorge Aparicio
a440c4a10c fix ? expansion in comment 2016-03-26 12:10:05 -05:00
Tang Chenglong
bbba872dde docs: make some text changes on Section Macros
(1) In contrast to `that`, `so that` expresses `result` indicated by the sentence, not `reason`;
(2) `block` is an expression, and may be have an expression, so I add `optional an expression` to make more precise;
(3) When I read here, I was confused with what `the child` referred to. After modification, it would be better.
2016-03-26 23:59:16 +08:00
bors
8f34053f76 Auto merge of #32508 - Manishearth:rollup, r=Manishearth
Rollup of 6 pull requests

- Successful merges: #32383, #32387, #32440, #32470, #32478, #32492
- Failed merges:
2016-03-26 08:07:42 -07:00
Manish Goregaokar
90f2b69cdd Rollup merge of #32492 - xitep:master, r=alexcrichton
Avoid page reload upon hitting "S" when browsing documentation in local mode

The problem seems to have been introduced with commit 2910c00206
2016-03-26 20:35:49 +05:30
Manish Goregaokar
2c4d039b76 Rollup merge of #32478 - xevix:docs/strings-str-unsized-types, r=steveklabnik
Add note on `str` being an unsized type in strings section of book

The book section on Rust strings mentions `&str` and `String` but does not address why `str` is not used directly. This adds a short blurb and a link to the unsized types chapter. The second draft of the book will go more in-depth on this, but this should help a bit for now. Thanks #rust for clarifying this point, and let me know if it needs rewording or different placement 😄.

CC @steveklabnik @Kimundi
2016-03-26 20:35:49 +05:30
Manish Goregaokar
dcfcbaa009 Rollup merge of #32470 - rust-lang:steveklabnik-patch-1, r=alexcrichton
remove broken config

Fixes #32412
2016-03-26 20:35:49 +05:30
Manish Goregaokar
887e927e7b Rollup merge of #32440 - tshepang:compact, r=steveklabnik
doc: remove needless bindings

The extra syntax is more noise than help in simple examples like this
2016-03-26 20:35:49 +05:30
Manish Goregaokar
f8869394bb Rollup merge of #32387 - alexcrichton:ascii-test, r=aturon
std: Add regression test for #32074

Just to make sure we don't accidentally break this in the future.
2016-03-26 20:35:49 +05:30
Manish Goregaokar
4a1e19990f Rollup merge of #32383 - aidanhs:aphs-heap-move-guarantee, r=alexcrichton
Document heap allocation location guarantee

```
14:25 < aidanhs> is there any guarantee that boxes will not move the value on the heap when they are moved?
14:26 <@steveklabnik> aidanhs: ... i'm not sure if it's a guarantee, but it follows, generally
14:26 <@steveklabnik> aidanhs: moves mean memcpy, so you're memcpying the structure of the box itself, which is copying the pointer
14:26 <@steveklabnik> so the pointer won't be updated
14:26 <@steveklabnik> moves cannot do complex things like move the memory around on the heap
14:26 <@kmc> aidanhs: I would say it's guaranteed
14:27 < aidanhs> steveklabnik: yeah, that's what I was thinking, it'd be pretty strange for rust to do something, but I couldn't find any docs one way or the other
14:27 <@steveklabnik> kmc: aidanhs yeah, it's like a borderline thing that we don't explicitly guanratee but i think IS guaranteed by our other guarantees
14:27 <@steveklabnik> mostly that move == memcpy
14:28 < aidanhs> kmc: steveklabnik great thanks! would a PR to the rust reference along these lines be ok?
14:28 < jmesmon> aidanhs: I believe owning_ref has some discussion of that (stable references)
14:29 <@steveklabnik> aidanhs: i would probably take that, yeah
14:29 < aidanhs> jmesmon: thanks, I'll take a look at that
```
https://botbot.me/mozilla/rust/2016-02-22/?msg=60657619&page=18

r? @steveklabnik
2016-03-26 20:35:49 +05:30
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
Tang Chenglong
e469c79de8 Docs: a tiny modification 2016-03-26 21:18:08 +08:00
bors
346d0d5175 Auto merge of #32484 - brson:cargotest, r=alexcrichton
Fix the name of the 'check-cargotest' step
2016-03-26 05:52:39 -07:00
Björn Steinbrink
1eacb4a6c3 Revert "disable llvm assertions on ARM compilers"
This reverts commit afbbb74fec.
2016-03-26 13:02:54 +01:00
Björn Steinbrink
95697a8395 Fix removal of function attributes on ARM
We use a 64bit integer to pass the set of attributes that is to be
removed, but the called C function expects a 32bit integer. On most
platforms this doesn't cause any problems other than being unable to
unset some attributes, but on  ARM even the lower 32bit aren't handled
correctly because the 64bit value is passed in different registers, so
the C function actually sees random garbage.

So we need to fix the relevant functions to use 32bit integers instead.
Additionally we need an implementation that actually accepts 64bit
integers because some attributes can only be unset that way.

Fixes #32360
2016-03-26 13:02:54 +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