Commit Graph

40485 Commits

Author SHA1 Message Date
Alex Crichton
6968ccfd7a rollup merge of #23651: alexcrichton/unwind-try
This commit provides a safe, but unstable interface for the `try` functionality
of running a closure and determining whether it panicked or not.

There are two primary reasons that this function was previously marked `unsafe`:

1. A vanilla version of this function exposes the problem of exception safety by
   allowing a bare try/catch in the language. It is not clear whether this
   concern should be directly tied to `unsafe` in Rust at the API level. At this
   time, however, the bounds on `ffi::try` require the closure to be both
   `'static` and `Send` (mirroring those of `thread::spawn`). It may be possible
   to relax the bounds in the future, but for now it's the level of safety that
   we're willing to commit to.

2. Panicking while panicking will leak resources by not running destructors.
   Because panicking is still controlled by the standard library, safeguards
   remain in place to prevent this from happening.

The new API is now called `catch_panic` and is marked as `#[unstable]` for now.
2015-03-27 10:07:42 -07:00
Alex Crichton
b79fbe0dae rollup merge of #23625: fhahn/issue-23620-ice-unicode-bytestring
closes #23620

This PR patches the issue mentioned in #23620, but there is also an ICE for invalid escape sequences in byte literals. This is due to the fact that the `scan_byte` function returns ` token::intern("??") ` for invalid bytes, resulting in an ICE later on. Is there a reason for this behavior? Shouldn't `scan_byte` fail when it encounters an invalid byte?

And I noticed a small inconsistency in the documentation. According to the formal byte literal definition in http://doc.rust-lang.org/reference.html#byte-and-byte-string-literals , a byte string literal contains `string_body *`, but according to the text (and the behavior of the lexer) it should not accept unicode escape sequences. Hence it should be replaced by `byte_body *`. If this is valid, I can add this fix to this PR.
2015-03-27 10:07:41 -07:00
Alex Crichton
e42521aa58 rollup merge of #23535: pnkfelix/fsk-filling-drop
Replace zeroing-on-drop with filling-on-drop.

This is meant to set the stage for removing *all* zeroing and filling (on drop) in the future.

Note that the code is meant to be entirely abstract with respect to the particular values used for the drop flags: the final commit demonstrates how to go from zeroing-on-drop to filling-on-drop by changing the value of three constants (in two files).

See further discussion on the internals thread:
  http://internals.rust-lang.org/t/attention-hackers-filling-drop/1715/11

[breaking-change] especially for structs / enums using `#[unsafe_no_drop_flag]`.
2015-03-27 10:07:41 -07:00
Alex Crichton
0e5052c396 rollup merge of #23419: murarth/lookup-addr
Closes #22608
2015-03-27 10:07:40 -07:00
Manish Goregaokar
5b45ede68f Rollup merge of #23712 - nikomatsakis:reflect-trait, r=FlaPer87
This PR introduces a `Reflect` marker trait which is a supertrait of `Any`. The idea is that `Reflect` is defined for all concrete types, but is not defined for type parameters unless there is a `T:Reflect` bound. This is intended to preserve the parametricity property. This allows the `Any` interface to be stabilized without committing us to unbounded reflection that is not easily detectable by the caller.

The implementation of `Reflect` relies on an experimental variant of OIBIT. This variant behaves differently for objects, since it requires that all types exposed as part of the object's *interface* are `Reflect`, but isn't concerned about other types that may be closed over. In other words, you don't have to write `Foo+Reflect` in order for `Foo: Reflect` to hold (where `Foo` is a trait).

Given that `Any` is slated to stabilization and hence that we are committed to some form of reflection, the goal of this PR is to leave our options open with respect to parametricity. I see the options for full stabilization as follows (I think an RFC would be an appropriate way to confirm whichever of these three routes we take):

1. We make `Reflect` a lang-item.
2. We stabilize some version of the OIBIT variation I implemented as a general mechanism that may be appropriate for other use cases.
3. We give up on preserving parametricity here and just have `impl<T> Reflect for T` instead. In that case, `Reflect` is a harmless but not especially useful trait going forward.

cc @aturon
cc @alexcrichton
cc @glaebhoerl (this is more-or-less your proposal, as I understood it)
cc @reem (this is more-or-less what we discussed on IRC at some point)
cc @FlaPer87 (vaguely pertains to OIBIT)
2015-03-27 22:37:36 +05:30
Manish Goregaokar
e65c6e572a Rollup merge of #23625 - fhahn:issue-23620-ice-unicode-bytestring, r=alexcrichton
closes #23620

This PR patches the issue mentioned in #23620, but there is also an ICE for invalid escape sequences in byte literals. This is due to the fact that the `scan_byte` function returns ` token::intern(\"??\") ` for invalid bytes, resulting in an ICE later on. Is there a reason for this behavior? Shouldn't `scan_byte` fail when it encounters an invalid byte?

And I noticed a small inconsistency in the documentation. According to the formal byte literal definition in http://doc.rust-lang.org/reference.html#byte-and-byte-string-literals , a byte string literal contains `string_body *`, but according to the text (and the behavior of the lexer) it should not accept unicode escape sequences. Hence it should be replaced by `byte_body *`. If this is valid, I can add this fix to this PR.
2015-03-27 22:37:28 +05:30
Manish Goregaokar
d77a9510f6 Rollup merge of #23419 - murarth:lookup-addr, r=alexcrichton
Closes #22608
2015-03-27 22:37:20 +05:30
Manish Goregaokar
82b375b44d Rollup merge of #23738 - alexcrichton:snapshots, r=cmr 2015-03-27 22:37:12 +05:30
Alex Crichton
fa3840305c alloc: Don't run some Arc doc tests
Windows gets quite unhappy when a thread fails while the main thread is exiting,
frequently leading to process deadlock. This has been causing quite a few
deadlocks on the windows bots recently. The child threads are presumably failing
because the `println!` is failing due to the main thread being shut down.
2015-03-27 09:59:46 -07:00
Florian Hahn
afaa3b6a20 Prevent ICEs when parsing invalid escapes, closes #23620 2015-03-27 17:47:16 +01:00
bors
242ed0b7c0 Auto merge of #22930 - Gankro:entry_3, r=aturon
RFC pending, but this is the patch that does it.

Totally untested. Likely needs some removed imports. std::collections docs should also be updated to provide better examples.

Closes #23508
2015-03-27 12:55:23 +00:00
Alexis Beingessner
1b98f6da7a default => or_insert per RFC 2015-03-27 07:42:03 -04:00
Ruud van Asseldonk
975ebc194c num: Derive Debug for Wrapping
This allows `Wrapping<T>` to be used in `assert_eq!`, for example.
2015-03-27 10:16:13 +01:00
Nick Cameron
a67faf1b25 Change the trivial cast lints to allow by default 2015-03-27 18:41:18 +13:00
Alexis
93cdf1f278 update everything to use Entry defaults 2015-03-26 21:36:06 -04:00
Alexis
1c35953cf8 entry API v3: replace Entry::get with Entry::default and Entry::default_with 2015-03-26 21:36:06 -04:00
Niko Matsakis
dd8cf92389 Fix doc tests. 2015-03-26 21:12:52 -04:00
Aaron Turon
c9f600bcee Stabilize some stragglers in std::option
Marks as `#[stable}`:

* `ok_or`
* `ok_or_else`
* `iter_mut`
* `cloned`

Similarly to `IteratorExt::cloned`, the `cloned` method is pared down to
work only on `Option<&T>`. Thus, this is a:

[breaking-change]
2015-03-26 17:47:13 -07:00
Murarth
c0dd239753 Add std::net::lookup_addr for reverse DNS lookup
Closes #22608
2015-03-26 17:13:14 -07:00
Felix S. Klock II
b68ca84ef1 workaround pretty-print bugs to placate make check-pretty. 2015-03-27 01:07:27 +01:00
Alex Crichton
e71221f327 std: Stabilize BufRead::split
Now that `<[_]>::split` is an inherent method, it will trump `BufRead::split`
when `BufRead` is in scope, so there is no longer a conflict. As a result,
calling `slice.split()` will probably always give you precisely what you want!
2015-03-26 16:54:15 -07:00
Tshepang Lekhonkhobe
ce668a873e book: fix typo 2015-03-27 01:44:03 +02:00
Alex Crichton
4f419d9668 rustc: Remove support for -l foo:static
This syntax has been renamed to `-l static=foo` some time ago.
2015-03-26 16:42:22 -07:00
Tshepang Lekhonkhobe
4357621ca9 book: there is no guessing game anymore, so remove references to it 2015-03-27 01:35:50 +02:00
Brian Anderson
cbef22e242 Update rust-installer. Fixes --help and interop with NixOS 2015-03-26 16:09:46 -07:00
Alex Crichton
671d896294 rustc: Remove old #[phase] and #[plugin]
This commit removes the extra deprecation warnings and support for the old
`phase` and `plugin` attributes for loading plugins.
2015-03-26 15:43:42 -07:00
Niko Matsakis
710af0498d Refactor object-safety test to use def-ids only 2015-03-26 17:52:39 -04:00
Niko Matsakis
703308db4a Refactor how binders are handled in trait selection 2015-03-26 17:52:38 -04:00
Niko Matsakis
c59fe8bde2 Drive-by fix for incorrect variance rule that I noticed. 2015-03-26 17:52:38 -04:00
Niko Matsakis
9c9bb9ce1d Implement Reflect trait with a variant on the standard OIBIT
semantics that tests the *interface* of trait objects, rather
than what they close over.
2015-03-26 17:52:38 -04:00
Gary M. Josack
5123bf40a1 Update docs to fix various 404s
Found a few 404s that seemed like simple fixes:

The Result docs use old_io Writer as an example. Fix the link to old_io Writer. There's probably an effort to update the example away from a deprecated api but this was a simple fix.

rustc/plugin was pointing at the old guide and it was a broken link anyways (plugin vs plugins). Point at the book instead.

The main page of the API docs referenced c_{str,vec}. Looks like these were deleted in 25d5a3a194. Point at ffi docs instead.
2015-03-26 14:46:06 -07:00
Aaron Turon
e7525cf620 Revise use of conversion traits
This commit revises `path` and `os_str` to use blanket impls for `From`
on reference types. This both cuts down on the number of required impls,
and means that you can pass through e.g. `T: AsRef<OsStr>` to
`PathBuf::from` without an intermediate call to `as_ref`.

It also makes a FIXME note for later generalizing the blanket impls for
`AsRef` and `AsMut` to use `Deref`/`DerefMut`, once it is possible to do
so.
2015-03-26 13:54:48 -07:00
Alex Crichton
3752958e40 syntax: Remove support for #[should_fail]
This attribute has been deprecated in favor of #[should_panic]. This also
updates rustdoc to no longer accept the `should_fail` directive and instead
renames it to `should_panic`.
2015-03-26 13:53:52 -07:00
Tshepang Lekhonkhobe
07afd04d34 book: let grow() accept the growth parameter 2015-03-26 22:38:19 +02:00
Murarth
1c43e53c8f impl FromStr for IpAddr 2015-03-26 13:31:37 -07:00
Alex Crichton
9754b06cd8 rustc: Remove support for old_impl_check
This commit removes compiler support for the `old_impl_check` attribute which
should in theory be entirely removed now. The last remaining use of it in the
standard library has been updated by moving the type parameter on the
`old_io::Acceptor` trait into an associated type. As a result, this is a
breaking change for all current users of the deprecated `old_io::Acceptor`
trait. Code can be migrated by using the `Connection` associated type instead.

[breaking-change]
2015-03-26 13:25:33 -07:00
Tshepang Lekhonkhobe
3e100ff038 book: make it one sentence 2015-03-26 22:10:59 +02:00
Or Neeman
dac552f255 doc: change 0u32..10 to 0..10 2015-03-26 13:24:20 -06:00
Alex Crichton
43bfaa4a33 Mass rename uint/int to usize/isize
Now that support has been removed, all lingering use cases are renamed.
2015-03-26 12:10:22 -07:00
Adenilson Cavalcanti
7d3bf47323 Adding more information about the behavior of Arc/Rc
when you perform a clone() call.
2015-03-26 12:05:21 -07:00
bors
53a183f027 Auto merge of #23359 - erickt:quote, r=pnkfelix
This PR allows the quote macros to unquote trait items, impl items, where clauses, and paths.
2015-03-26 18:43:56 +00:00
Felix S. Klock II
e2cc8b1436 add feature flags required post rebase. 2015-03-26 19:31:53 +01:00
Alex Crichton
77de3ee6e5 syntax: Remove parsing of old slice syntax
This syntax has been deprecated for quite some time, and there were only a few
remaining uses of it in the codebase anyway.
2015-03-26 10:24:44 -07:00
Alex Crichton
36ef29abf7 Register new snapshots 2015-03-26 09:57:05 -07:00
bors
199bdcfeff Auto merge of #23680 - erickt:inline, r=cmr
before:

test bench_read_slice  ... bench:        68 ns/iter (+/- 56)
test bench_read_vec    ... bench:        78 ns/iter (+/- 21)
test bench_write_slice ... bench:       133 ns/iter (+/- 46)
test bench_write_vec   ... bench:       308 ns/iter (+/- 69)

after:

test bench_read_slice  ... bench:        32 ns/iter (+/- 10)
test bench_read_vec    ... bench:        32 ns/iter (+/- 8)
test bench_write_slice ... bench:        53 ns/iter (+/- 12)
test bench_write_vec   ... bench:       247 ns/iter (+/- 172)
2015-03-26 16:10:23 +00:00
Steve Klabnik
c153fc1da1 New section of the book: nightly rust
Now that feature flags are only on nightly, it's good to split this stuff out.
2015-03-26 11:42:45 -04:00
Erick Tryzelaar
c5b8763753 Deprecate as_mut_slice methods
This is technically a breaking change as it deprecates and unstables
some previously stable apis that were missed in the last round of
deprecations.

[breaking change]
2015-03-26 07:29:06 -07:00
bors
557d4346a2 Auto merge of #21237 - erickt:derive-assoc-types, r=erickt
This PR adds support for associated types to the `#[derive(...)]` syntax extension. In order to do this, it switches over to using where predicates to apply the type constraints. So now this:

```rust
type Trait {
    type Type;
}

#[derive(Clone)]
struct Foo<A> where A: Trait {
    a: A,
    b: <A as Trait>::Type,
}
```

Gets expended into this impl:

```rust
impl<A: Clone> Clone for Foo<A> where
    A: Trait,
    <A as Trait>::Type: Clone,
{
    fn clone(&self) -> Foo<T> {
        Foo {
            a: self.a.clone(),
            b: self.b.clone(),
        }
    }
}
```
2015-03-26 13:38:41 +00:00
Felix S. Klock II
aab4bef939 Add tests exercising the dropflag checking functionality. 2015-03-26 14:08:55 +01:00
Felix S. Klock II
4053b00112 Use -Z force-dropflag-checks=on/off for emitting sanity-check.
(That is, added config and debugflag a la check-overflow but for drop
flag sanity-check.)

Remove now-unused import of NoDebugInfo from trans::glue.
2015-03-26 14:08:55 +01:00