Commit Graph

41999 Commits

Author SHA1 Message Date
Felix S. Klock II
b892264ea4 Fix #24895.
[breaking-change]

What does this break?  Basically, code that implements `Drop` and is
using `T:Copy` for one of its type parameters and is relying on the
Drop Check rule not applying to it.

Here is an example:

```rust
#![allow(dead_code,unused_variables,unused_assignments)]
struct D<T:Copy>(T);
impl<T:Copy> Drop for D<T> { fn drop(&mut self) { } }

trait UserT { fn c(&self) { } }
impl<T:Copy> UserT for T { }
struct E<T:UserT>(T);
impl<T:UserT> Drop for E<T> { fn drop(&mut self) { } }

// This one will start breaking.
fn foo() { let (d2, d1); d1 = D(34); d2 = D(&d1); }

#[cfg(this_one_does_and_should_always_break)]
fn bar() { let (e2, e1); e1 = E(34); e2 = E(&e1); }

fn main() {
    foo();
}
```
2015-04-28 17:47:16 +02:00
Steve Klabnik
97199bcb5d remove stability note from std::net
This is served by stability markers.
2015-04-28 11:18:10 -04:00
Felix S. Klock II
0930d383cb rename schedule_drop_{enum,adt}_contents. 2015-04-28 17:01:26 +02:00
bors
d8b64c7fb2 Auto merge of #24891 - tcard:patch-1, r=steveklabnik
`Type` should be `Trait` to match the next example line.

r? @steveklabnik
2015-04-28 14:21:22 +00:00
Robin Stocker
6cdb57d4b6 Add error explanation for E0013 2015-04-28 20:46:24 +10:00
Brendan Graetz
1335be33e4 =BG= change definition to use 'statics' as well as 'constants' 2015-04-28 20:22:26 +10:00
Brendan Graetz
8933253f2b =BG= Add detailed error message for E0265
This error indicates that a constant references itself.
All constants need to resolve to a value in an acyclic manner.

For example, neither of the following can be sensibly compiled:

```
const X: u32 = X;
```

```
const X: u32 = Y;
const Y: u32 = X;
```
2015-04-28 20:09:38 +10:00
Ulrik Sverdrup
b475fc7d6a collections: Implement vec::drain(range) according to RFC 574
Old `.drain()` on vec is performed using `.drain(..)` now.

`.drain(range)` is unstable and under feature(collections_drain)

[breaking-change]
2015-04-28 11:38:33 +02:00
Toni Cárdenas
df1768d8eb TRPL: Tiny incoherence in UFCS example.
`Type` should be `Trait` to match the next example line.

r? @steveklabnik
2015-04-28 11:10:01 +02:00
bors
da2276e293 Auto merge of #24835 - rprichard:rfail-full, r=alexcrichton
This commit gets `make check-stage1` working again after #24718.

cc @tamird

r? @alexcrichton
2015-04-28 05:37:48 +00:00
Chris Morgan
928bd4fe10 Fix #24872, XSS in docs not found page. 2015-04-28 13:31:45 +10:00
Carol (Nichols || Goulding)
d715409736 Make item sections match item EBNF
`enum_item` appeared in the `item` list but did not have an associated section;
`const_item` had a section but did not appear in the list.
2015-04-27 22:02:16 -04:00
bors
2b8c9b12f9 Auto merge of #24478 - alexcrichton:issue-24313, r=aturon
Inspecting the current thread's info may not always work due to the TLS value
having been destroyed (or is actively being destroyed). The code for printing
a panic message assumed, however, that it could acquire the thread's name
through this method.

Instead this commit propagates the `Option` outwards to allow the
`std::panicking` module to handle the case where the current thread isn't
present.

While it solves the immediate issue of #24313, there is still another underlying
issue of panicking destructors in thread locals will abort the process.

Closes #24313
2015-04-28 00:44:56 +00:00
Alex Crichton
9348700007 std: Expand the area of std::fs
This commit is an implementation of [RFC 1044][rfc] which adds additional
surface area to the `std::fs` module. All new APIs are `#[unstable]` behind
assorted feature names for each one.

[rfc]: https://github.com/rust-lang/rfcs/pull/1044

The new APIs added are:

* `fs::canonicalize` - bindings to `realpath` on unix and
  `GetFinalPathNameByHandle` on windows.
* `fs::symlink_metadata` - similar to `lstat` on unix
* `fs::FileType` and accessor methods as `is_{file,dir,symlink}`
* `fs::Metadata::file_type` - accessor for the raw file type
* `fs::DirEntry::metadata` - acquisition of metadata which is free on Windows
  but requires a syscall on unix.
* `fs::DirEntry::file_type` - access the file type which may not require a
  syscall on most platforms.
* `fs::DirEntry::file_name` - access just the file name without leading
  components.
* `fs::PathExt::symlink_metadata` - convenience method for the top-level
  function.
* `fs::PathExt::canonicalize` - convenience method for the top-level
  function.
* `fs::PathExt::read_link` - convenience method for the top-level
  function.
* `fs::PathExt::read_dir` - convenience method for the top-level
  function.
* `std::os::raw` - type definitions for raw OS/C types available on all
  platforms.
* `std::os::$platform` - new modules have been added for all currently supported
  platforms (e.g. those more specific than just `unix`).
* `std::os::$platform::raw` - platform-specific type definitions. These modules
  are populated with the bare essentials necessary for lowing I/O types into
  their raw representations, and currently largely consist of the `stat`
  definition for unix platforms.

This commit also deprecates `Metadata::{modified, accessed}` in favor of
inspecting the raw representations via the lowering methods of `Metadata`.
2015-04-27 17:16:44 -07:00
Alex Crichton
d98ab4faf8 std: Don't assume thread::current() works on panic
Inspecting the current thread's info may not always work due to the TLS value
having been destroyed (or is actively being destroyed). The code for printing
a panic message assumed, however, that it could acquire the thread's name
through this method.

Instead this commit propagates the `Option` outwards to allow the
`std::panicking` module to handle the case where the current thread isn't
present.

While it solves the immediate issue of #24313, there is still another underlying
issue of panicking destructors in thread locals will abort the process.

Closes #24313
2015-04-27 16:15:36 -07:00
bors
97d4e76c20 Auto merge of #24701 - Stebalien:slice, r=alexcrichton
Instead of using the O(n) defaults, define O(1) shortcuts. I also copied (and slightly modified) the relevant tests from the iter tests into the slice tests just in case someone comes along and changes them in the future.

Partially implements  #24214.
2015-04-27 22:46:48 +00:00
Alex Crichton
0e154aaad6 std: Clean up some annotations in thread::local
Don't need so much manual #[doc(hidden)] and #[unstable] as much of it is
inherited!
2015-04-27 15:16:41 -07:00
bors
9c88f3be12 Auto merge of #24765 - pnkfelix:fsk-enum-swapindrop, r=nikomatsakis
Inspect enum discriminant *after* calling its destructor

Includes some drive-by cleanup (e.g. changed some field and method names to reflect fill-on-drop; added comments about zero-variant enums being classified as `_match::Single`).

Probably the most invasive change was the expansion of the maps `available_drop_glues` and `drop_glues` to now hold two different kinds of drop glues; there is the (old) normal drop glue, and there is (new) drop-contents glue that jumps straight to dropping the contents of a struct or enum, skipping its destructor.

 * For all types that do not have user-defined Drop implementations, the normal glue is generated as usual (i.e. recursively dropping the fields of the data structure).

  (And this actually is exactly what the newly-added drop-contents glue does as well.)

 * For types that have user-defined Drop implementations, the "normal" drop glue now schedules a cleanup before invoking the `Drop::drop` method that will call the drop-contents glue after that invocation returns.

Fix #23611.

----

Is this a breaking change?  The prior behavior was totally unsound, and it seems unreasonable that anyone was actually relying on it.

Nonetheless, since there is a user-visible change to the language semantics, I guess I will conservatively mark this as a:

[breaking-change]

(To see an example of what sort of user-visible change this causes, see the comments in the regression test.)
2015-04-27 20:46:48 +00:00
Ulrik Sverdrup
95be21df47 core: Fix size_hint for signed integer Range<T> iterators
There was an overflow bug in .size_hint() for signed iterators, which
produced an hilariously incorrect size or an overflow panic.

Incorrect size is a serious bug since the iterators are marked
ExactSizeIterator. (And leads to abort() on (-1i8..127).collect() when
the collection tries to preallocate too much).

All signed range iterators were affected.

> (-1i8..127).size_hint()
(18446744073709551488, Some(18446744073709551488))

Bug found using quickcheck.

Fixes #24851
2015-04-27 21:14:43 +02:00
Ulrik Sverdrup
9993a43e5c collections: Add trait RangeArgument
RangeArgument is introduced as unstable under the
feature(collections_range)
2015-04-27 19:37:13 +02:00
Alex Crichton
60f8f6bde9 compiletest: Add support for // ignore-musl
Add the ability to ignore a test based on the environment of the triple being
used.
2015-04-27 10:11:15 -07:00
Alex Crichton
7dd62155d8 std: Don't assume dlopen() works on yourself
Statically linked executables do not succeed (aka MUSL-based executables).
2015-04-27 10:11:15 -07:00
Alex Crichton
5f518ad658 compiletest: Don't force dylibs on musl
MUSL support is currently only with static builds, so building a dylib will
always fail.
2015-04-27 10:11:15 -07:00
Alex Crichton
6c048723f8 std: Prepare for linking to musl
This commit modifies the standard library and its dependencies to link correctly
when built against MUSL. This primarily ensures that the right libraries are
linked against and when they're linked against they're linked against
statically.
2015-04-27 10:11:15 -07:00
Alex Crichton
d09851730c rustc: Add support for linking arbitrary objects
MUSL for example provides its own start/end objects in place of the standard
ones shipped by gcc.
2015-04-27 10:11:15 -07:00
Alex Crichton
22da16a4c5 rustc_back: Add x86_64-unknown-linux-musl as a target
This commit adds support for x86_64-unknown-linux-musl as a target of the
compiler. There's some comments in the commit about some of the more flavorful
flags passed to the linker as it's not quite as trivial as the normal specs.
2015-04-27 10:11:15 -07:00
Alex Crichton
cd980b3bee mk: Add support for musl-based builds
This commit adds support to the makefiles, configuration script, and build
system to understand MUSL. This is broken up into a few parts:

* Any target of the form `*-musl` requires the `--musl-root` option to
  `./configure` which will indicate the root of the MUSL installation. It is
  also expected that there is a libunwind build inside of that installation
  built against that MUSL.

* Objects from MUSL are copied into the build tree for Rust to be statically
  linked into the appropriate Rust library.

* Objects for binary startup and shutdown are included in each Rust installation
  by default for MUSL. This requires MUSL to only be installed on the machine
  compiling rust. Only a linker will be necessary for compiling against MUSL on
  a target machine.

Eventually a MUSL and/or libunwind build may be integrated by default into the
build but for now they are just always assumed to exist externally.
2015-04-27 10:11:15 -07:00
bors
857ef6e272 Auto merge of #23606 - quantheory:associated_const, r=nikomatsakis
Closes #17841.

The majority of the work should be done, e.g. trait and inherent impls, different forms of UFCS syntax, defaults, and cross-crate usage. It's probably enough to replace the constants in `f32`, `i8`, and so on, or close to good enough.

There is still some significant functionality missing from this commit:

 - ~~Associated consts can't be used in match patterns at all. This is simply because I haven't updated the relevant bits in the parser or `resolve`, but it's *probably* not hard to get working.~~
 - Since you can't select an impl for trait-associated consts until partway through type-checking, there are some problems with code that assumes that you can check constants earlier. Associated consts that are not in inherent impls cause ICEs if you try to use them in array sizes or match ranges. For similar reasons, `check_static_recursion` doesn't check them properly, so the stack goes ka-blooey if you use an associated constant that's recursively defined. That's a bit trickier to solve; I'm not entirely sure what the best approach is yet.
 - Dealing with consts associated with type parameters will raise some new issues (e.g. if you have a `T: Int` type parameter and want to use `<T>::ZERO`). See rust-lang/rfcs#865.
 - ~~Unused associated consts don't seem to trigger the `dead_code` lint when they should. Probably easy to fix.~~

Also, this is the first time I've been spelunking in rustc to such a large extent, so I've probably done some silly things in a couple of places.
2015-04-27 16:45:21 +00:00
Matt Brubeck
d8797b090f [reference] Fix a typo in 3.4 Whitespace 2015-04-27 09:31:49 -07:00
Alex Crichton
ba2380d7b3 rustc: Add target_env for triples by default
This adds a new `#[cfg]` matcher against the `target_env` property of the
destination target triple. For example all windows triples today end with `-gnu`
but we will also hopefully support non-`gnu` targets for Windows, at which point
we'll need to differentiate between the two. This new `target_env` matches is
provided and filled in with the target's environment name.

Currently the only non-empty value of this name is `gnu`, but `musl` will be
shortly added for the linux triples.
2015-04-27 09:22:05 -07:00
Alex Crichton
681fc82456 mk: Remove a bunch of unused directives 2015-04-27 09:22:05 -07:00
Tshepang Lekhonkhobe
f6c673e9f0 reference: add missing bracket
Also, remove the other brackets, because they make the whole sentence
look awkward.
2015-04-27 16:53:25 +02:00
bors
32f9f42762 Auto merge of #24869 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #24797, #24804, #24848, #24854, #24855, #24860, #24863, #24866, #24867, #24868
- Failed merges:
2015-04-27 14:45:43 +00:00
Steve Klabnik
03f3b45ff0 Rollup merge of #24868 - tshepang:fix-vec-remove-doc, r=steveklabnik 2015-04-27 10:26:20 -04:00
Steve Klabnik
1b18da4a46 Rollup merge of #24867 - tshepang:patch-3, r=steveklabnik 2015-04-27 10:26:20 -04:00
Steve Klabnik
0c3514253c Rollup merge of #24866 - tshepang:vec-intro, r=steveklabnik 2015-04-27 10:26:20 -04:00
Steve Klabnik
188f3eb8f5 Rollup merge of #24863 - dhardy:patch-1, r=steveklabnik
Remove the name "multi-line string literal" since the rule appears to affect each line-break individually rather than the whole string literal. Re-word, and remove the stray reference to raw strings.
2015-04-27 10:26:19 -04:00
Steve Klabnik
be569bcd35 Rollup merge of #24860 - Manishearth:cargo-doc, r=steveklabnik
A user in IRC was having trouble because they used `main.rs` when they were trying
to migrate a library. The `[[lib]]` key is not easily found, and the `main.rs`/`lib.rs`
distinction doesn't seem to exist in trpl


r? @steveklabnik
2015-04-27 10:26:19 -04:00
Steve Klabnik
30f41b1bd6 Rollup merge of #24855 - richo:thread-doc, r=alexcrichton 2015-04-27 10:26:19 -04:00
Steve Klabnik
5a6d9cc159 Rollup merge of #24854 - frewsxcv:patch-19, r=alexcrichton 2015-04-27 10:26:19 -04:00
Steve Klabnik
72ee472146 Rollup merge of #24848 - bluss:deref-string, r=alexcrichton
Improve example for as_string and add example for as_vec

Provide a better example of `as_string` / `DerefString`'s unique capabilities.
Use an example where (for an unspecified reason) you need a &String, and
show how `as_string` solves the problem without needing an allocation.
2015-04-27 10:26:18 -04:00
Steve Klabnik
130240afc6 Rollup merge of #24804 - liigo:new-trait-color, r=steveklabnik
Fixes #24441 

Preview:
![new-trait-color](https://cloud.githubusercontent.com/assets/346530/7331922/d6cbcf72-eb58-11e4-8a1d-4ca5e3683ed2.png)
2015-04-27 10:26:18 -04:00
Steve Klabnik
08c0299a82 Rollup merge of #24797 - roryokane:patch-1, r=nikomatsakis
The minus sign ‘−’ is the same width as the plus sign ‘+’, so the button’s transition between the two symbols will look slightly smoother.

If you don’t want to use literal Unicode characters, I can change ‘−’ to `\u2212`. I’m not starting with that suggestion because ‘−’ is easier to read and understand, and if I used `\u2212`, it would probably be necessary to also comment the usage on each line to explain what character is being used.
2015-04-27 10:26:18 -04:00
Felix S. Klock II
805349a50b Bug fix: Rvalue(ByRef) will issue a lifetime_end as its post_store, which is wrong.
Kudos to dotdash for tracking down this fix.

Presumably the use of `ByRef` was because this value is a reference to
the drop-flag; but an Lvalue will serve just as well for that. dotdash
argues:

> since the drop_flag is in its "final home", Lvalue seems to be the
> correct choice.
2015-04-27 16:21:51 +02:00
Tshepang Lekhonkhobe
36cf51dc3a doc: it is 'index', not 'i' 2015-04-27 16:11:46 +02:00
Felix S. Klock II
24f213d023 drive-by fix: scheduled drops are executed in reverse order.
That is, scheduled drops are executed in reverse order, so for
correctness, we *schedule* the lifetime end before we schedule the
drop, so that when they are executed, the drop will be executed
*before* the lifetime end.
2015-04-27 16:08:30 +02:00
Tshepang Lekhonkhobe
14a6a9f5e2 reference: block-comment -> block comment 2015-04-27 15:42:46 +02:00
Manish Goregaokar
38042d1e18 trpl: clarify lib.rs vs main.rs 2015-04-27 18:42:19 +05:30
bors
b772ce6342 Auto merge of #24834 - shepmaster:default-atomic-ptr, r=alexcrichton
Closes #24613
2015-04-27 12:45:38 +00:00
Tshepang Lekhonkhobe
7335c9f48f book: improve Vec intro 2015-04-27 14:11:27 +02:00