Commit Graph

40196 Commits

Author SHA1 Message Date
Felix S. Klock II
5b2e8693e4 Reject specialized Drop impls.
See Issue 8142 for discussion.

This makes it illegal for a Drop impl to be more specialized than the
original item.

So for example, all of the following are now rejected (when they would
have been blindly accepted before):

```rust
struct S<A> { ... };
impl Drop for S<i8> { ... } // error: specialized to concrete type

struct T<'a> { ... };
impl Drop for T<'static> { ... } // error: specialized to concrete region

struct U<A> { ... };
impl<A:Clone> Drop for U<A> { ... } // error: added extra type requirement

struct V<'a,'b>;
impl<'a,'b:a> Drop for V<'a,'b> { ... } // error: added extra region requirement
```

Due to examples like the above, this is a [breaking-change].

(The fix is to either remove the specialization from the `Drop` impl,
or to transcribe the requirements into the struct/enum definition;
examples of both are shown in the PR's fixed to `libstd`.)

----

This is likely to be the last thing blocking the removal of the
`#[unsafe_destructor]` attribute.

Includes two new error codes for the new dropck check.

Update run-pass tests to accommodate new dropck pass.

Update tests and docs to reflect new destructor restriction.

----

Implementation notes:

We identify Drop impl specialization by not being as parametric as the
struct/enum definition via unification.

More specifically:

 1. Attempt unification of a skolemized instance of the struct/enum
    with an instance of the Drop impl's type expression where all of
    the impl's generics (i.e. the free variables of the type
    expression) have been replaced with unification variables.

 2. If unification fails, then reject Drop impl as specialized.

 3. If unification succeeds, check if any of the skolemized
    variables "leaked" into the constraint set for the inference
    context; if so, then reject Drop impl as specialized.

 4. Otherwise, unification succeeded without leaking skolemized
    variables: accept the Drop impl.

We identify whether a Drop impl is injecting new predicates by simply
looking whether the predicate, after an appropriate substitution,
appears on the struct/enum definition.
2015-03-24 22:27:23 +01:00
Felix S. Klock II
290c8de0a6 Added T:Send bound to JoinGuard<T> to avoid specialized Drop impl. 2015-03-24 22:27:23 +01:00
Felix S. Klock II
5f57fd591d Added T:Send bound to Queue<T> to avoid specialized Drop impl. 2015-03-24 22:27:23 +01:00
Felix S. Klock II
123b5c124e Added T:Send bound to Packet<T> to avoid specialized Drop impl. 2015-03-24 22:27:23 +01:00
Felix S. Klock II
018eeb76f0 added T:Send bound to Mutex<T> to avoid specialized Drop impl. 2015-03-24 22:27:23 +01:00
Felix S. Klock II
1e71d2e71c Added W: Writer bound to BufferedWriter<W> to avoid specialized Drop impl. 2015-03-24 22:27:23 +01:00
Felix S. Klock II
1249e60891 Added T:Send bound to Queue<T> to avoid specialized Drop impl. 2015-03-24 22:27:23 +01:00
Felix S. Klock II
26a79e3c20 Added Write bounds to avoid a specialized Drop impl for BufWriter. 2015-03-24 22:27:22 +01:00
Felix S. Klock II
0adab507bb Added T:Send bound to sync::mpsc::Receiver and sync::mpsc::Sender.
This was necessary to avoid specialized `Drop` impls for the two structs.
2015-03-24 22:27:22 +01:00
Felix S. Klock II
5fa4b4c4af Remove unnecessary bounds from Drop impl for Arc and arc::Weak and
one of the helper method impls.
2015-03-24 22:27:22 +01:00
bors
ed81038504 Auto merge of #23654 - alexcrichton:rollup, r=alexcrichton 2015-03-24 17:38:09 +00:00
Alex Crichton
d252d0ad54 Test fixes and rebase conflicts, round 4 2015-03-24 10:23:47 -07:00
Alex Crichton
a7e204909b Merge remote-tracking branch 'origin/master' into rollup 2015-03-24 08:03:25 -07:00
Alex Crichton
c5c3de0cf4 Test fixes and rebase conflicts, round 3 2015-03-23 22:52:21 -07:00
Alex Crichton
253992eb38 rollup merge of #23653: dhuseby/bitrig-stage0-c64d671
@alexcrichton this adds the latest Bitrig snapshot.  Please upload the corresponding snapshot: https://github.com/dhuseby/rust-cross-bitrig/blob/master/snapshots/rust-stage0-2015-03-17-c64d671-bitrig-x86_64-41de2c7a69a1ac648d3fa3b65e96a29bdc122163.tar.bz2
2015-03-23 17:13:39 -07:00
Alex Crichton
1588caca61 rollup merge of #23652: alexcrichton/stabilize-hasher-finish
This commit enables writing a stable implementation of the `Hasher` trait as
well as actually calculating the hash of a vlaue in a stable fashion. The
signature is stabilized as-is.
2015-03-23 17:13:38 -07:00
Alex Crichton
7380b6ffc8 rollup merge of #23645: steveklabnik/gh23642
Fixes #23642
2015-03-23 17:13:38 -07:00
Alex Crichton
6a44f24b9e rollup merge of #23644: mbrubeck/doc-edit
PR #23104 moved `is_null` and `offset` to an inherent impl on the raw pointer type.

I'm not sure whether or how it's possible to link to docs for that impl.

r? @steveklabnik
2015-03-23 17:13:37 -07:00
Alex Crichton
690ee161c6 rollup merge of #23509: aturon/stab-entry
This commit marks as `#[stable]` the `Entry` types for the maps provided
by `std`. The main reason these had been left unstable previously was
uncertainty about an eventual trait design, but several plausible
designs have been proposed that all work fine with the current type definitions.

r? @Gankro
2015-03-23 17:13:27 -07:00
Alex Crichton
29b54387b8 Test fixes and rebase conflicts, round 2 2015-03-23 17:10:19 -07:00
Dave Huseby
3a0c15f3cf adding lastest Bitrig snapshot by hand 2015-03-23 15:58:44 -07:00
Matt Brubeck
3f52d719dc Update docs for ptr module.
PR #23104 moved `is_null` and `offset` to an inherent impl on the raw pointer
type.
2015-03-23 15:57:20 -07:00
Aaron Turon
248b2ecd18 Stabilize Entry types
This commit marks as `#[stable]` the `Entry` types for the maps provided
by `std`. The main reason these had been left unstable previously was
uncertainty about an eventual trait design, but several plausible
designs have been proposed that all work fine with the current type definitions.
2015-03-23 15:49:15 -07:00
bors
28a0b25f42 Auto merge of #23536 - pnkfelix:arith-oflo-shifts, r=nikomatsakis
overflow-checking for rhs of shift operators

Subtask of #22020 ([RFC 560](https://github.com/rust-lang/rfcs/blob/master/text/0560-integer-overflow.md))
2015-03-23 22:43:39 +00:00
Alex Crichton
3112716f12 rollup merge of #23506: alexcrichton/remove-some-deprecated-things
Conflicts:
	src/test/run-pass/deprecated-no-split-stack.rs
2015-03-23 15:27:06 -07:00
Alex Crichton
aea822626f rollup merge of #23503: alexcrichton/fix-ptr-docs
The method with which backwards compatibility was retained ended up leading to
documentation that rustdoc didn't handle well and largely ended up confusing.
2015-03-23 15:26:24 -07:00
Alex Crichton
6e0f1d3984 rollup merge of #23484: alexcrichton/marker-trait-stable
This trait has proven quite useful when defining marker traits to avoid the
semi-confusing `PhantomFn` trait and it looks like it will continue to be a
useful tool for defining these traits.
2015-03-23 15:26:24 -07:00
Alex Crichton
04e667a6b1 Test fixes and rebase conflicts, round 1 2015-03-23 15:18:40 -07:00
Alex Crichton
7d07f70ccb rollup merge of #23383: alexcrichton/fs-create-dir-all
Conflicts:
	src/libstd/fs/mod.rs
2015-03-23 15:18:24 -07:00
Alex Crichton
c608084ff5 rollup merge of #23598: brson/gate
Conflicts:
	src/compiletest/compiletest.rs
	src/libcollections/lib.rs
	src/librustc_back/lib.rs
	src/libserialize/lib.rs
	src/libstd/lib.rs
	src/libtest/lib.rs
	src/test/run-make/rustdoc-default-impl/foo.rs
	src/test/run-pass/env-home-dir.rs
2015-03-23 15:13:15 -07:00
Alex Crichton
d8b06284ea rollup merge of #23650: brson/32-bit-userspace
The variable '$SHELL' is not actually defined by 'sh'.

This makes Rust build correctly in popular Docker images.
2015-03-23 15:11:18 -07:00
Alex Crichton
7101ff4513 rollup merge of #23648: steveklabnik/rollup
- Successful merges: #22954, #23119, #23509, #23561, #23590, #23607, #23608, #23618, #23622, #23639, #23641
- Failed merges: #23401
2015-03-23 15:11:15 -07:00
Alex Crichton
fcf2ba794e rollup merge of #23641: steveklabnik/gh23632
Fixes #23632
2015-03-23 15:11:13 -07:00
Alex Crichton
8a15868206 rollup merge of #23640: nagisa/thread-less-weak
This is more portable as far as linux is concerned.
2015-03-23 15:11:12 -07:00
Alex Crichton
5e06ebbfc0 rollup merge of #23639: steveklabnik/gh21305
Fixes #21305

Not sure if we should include more than this here, but it should be good to have at least this.
2015-03-23 15:11:10 -07:00
Alex Crichton
ca7f7cf3d3 rollup merge of #23637: apasel422/iter 2015-03-23 15:11:09 -07:00
Alex Crichton
c7509bb8d8 rollup merge of #23634: WiSaGaN/bugfix/fix_dead_link 2015-03-23 15:11:07 -07:00
Alex Crichton
19510ac70b rollup merge of #23633: tomjakubowski/rustdoc-array-prim
Previously, impls for `[T; n]` were collected in the same place as impls for `[T]` and `&[T]`. This splits them out into their own primitive page in both core and std.
2015-03-23 15:11:06 -07:00
Alex Crichton
28fcdc0df7 rollup merge of #23631: andersk/minstack-dlsym
Linking `__pthread_get_minstack`, even weakly, was causing Debian’s `dpkg-shlibdeps` to detect an unnecessarily strict versioned dependency on libc6.

Closes #23628.
2015-03-23 15:11:05 -07:00
Alex Crichton
ef07e0797f rollup merge of #23622: steveklabnik/gh23196
Fixes #23196
2015-03-23 15:11:03 -07:00
Alex Crichton
b03939bfab rollup merge of #23619: steveklabnik/gh23220
Fixes #23571

I _think_ this is better, but other suggestions welcome too.
2015-03-23 15:11:02 -07:00
Alex Crichton
a78eb53074 rollup merge of #23618: steveklabnik/gh23571
Fixes #23571
2015-03-23 15:11:00 -07:00
Alex Crichton
5a6a90508d rollup merge of #23615: steveklabnik/gh23540
Closes #23540
2015-03-23 15:10:58 -07:00
Alex Crichton
010895e4f2 rollup merge of #23612: dotdash/closure_bloat
For the rust-call ABI, the last function argument is a tuple that gets
untupled for the actual call. For bare functions using this ABI, the
code has access to the tuple, so we need to tuple the arguments again.
But closures can't actually access the tuple. Their arguments map to the
elements in the tuple. So what we currently do is to tuple the arguments
and then immediately untuple them again, which is pretty useless and we
can just omit it.
2015-03-23 15:10:57 -07:00
Alex Crichton
c99970783a rollup merge of #23608: nagisa/refine-cursor-docstring
r? @steveklabnik
2015-03-23 15:10:55 -07:00
Alex Crichton
71c705db02 rollup merge of #23607: mahkoh/cursor
Closes #23599

r? @alexcrichton
2015-03-23 15:10:53 -07:00
Alex Crichton
68fb3acd85 rollup merge of #23604: apasel422/btree
`btree_map::IntoIter` (and `btree_set::IntoIter`) remains, but it is a bit trickier.
2015-03-23 15:10:51 -07:00
Alex Crichton
753efb5042 rollup merge of #23601: nikomatsakis/by-value-index
This is a [breaking-change]. When indexing a generic map (hashmap, etc) using the `[]` operator, it is now necessary to borrow explicitly, so change `map[key]` to `map[&key]` (consistent with the `get` routine). However, indexing of string-valued maps with constant strings can now be written `map["abc"]`.

r? @japaric
cc @aturon @Gankro
2015-03-23 15:10:50 -07:00
Alex Crichton
388e5aee1e rollup merge of #23590: FuGangqiang/attr 2015-03-23 15:10:36 -07:00
Alex Crichton
bed77408df rollup merge of #23580: nikomatsakis/pattern-and-overflow 2015-03-23 15:10:30 -07:00