Niko Matsakis [Mon, 5 Jan 2015 01:35:06 +0000 (20:35 -0500)]
Implement new orphan rule that requires that impls of remote traits meet the following two criteria:
- the self type includes some local type; and,
- type parameters in the self type must be constrained by a local type.
A type parameter is called *constrained* if it appears in some type-parameter of a local type.
Here are some examples that are accepted. In all of these examples, I
assume that `Foo` is a trait defined in another crate. If `Foo` were
defined in the local crate, then all the examples would be legal.
- `impl Foo for LocalType`
- `impl<T> Foo<T> for LocalType` -- T does not appear in Self, so it is OK
- `impl<T> Foo<T> for LocalType<T>` -- T here is constrained by LocalType
- `impl<T> Foo<T> for (LocalType<T>, T)` -- T here is constrained by LocalType
Here are some illegal examples (again, these examples assume that
`Foo` is not local to the current crate):
- `impl Foo for int` -- the Self type is not local
- `impl<T> Foo for T` -- T appears in Self unconstrained by a local type
- `impl<T> Foo for (LocalType, T)` -- T appears in Self unconstrained by a local type
This is a [breaking-change]. For the time being, you can opt out of
the new rules by placing `#[old_orphan_check]` on the trait (and
enabling the feature gate where the trait is defined). Longer term,
you should restructure your traits to avoid the problem. Usually this
means changing the order of parameters so that the "central" type
parameter is in the `Self` position.
As an example of that refactoring, consider the `BorrowFrom` trait:
As defined, this trait is commonly implemented for custom pointer
types, such as `Arc`. Those impls follow the pattern:
```rust
impl<T> BorrowFrom<Arc<T>> for T {...}
```
Unfortunately, this impl is illegal because the self type `T` is not
local to the current crate. Therefore, we are going to change the order of the parameters,
so that `BorrowFrom` becomes `Borrow`:
bors [Sun, 4 Jan 2015 16:36:41 +0000 (16:36 +0000)]
auto merge of #20443 : nikomatsakis/rust/autoderef-overloaded-calls, r=pcwalton
Use autoderef for call notation. This is consistent in that we now autoderef all postfix operators (`.`, `[]`, and `()`). It also means you can call closures without writing `(*f)()`. Note that this is rebased atop the rollup, so only the final commit is relevant.
bors [Sun, 4 Jan 2015 14:21:08 +0000 (14:21 +0000)]
auto merge of #20437 : ranma42/rust/fix-make-install, r=alexcrichton
After 8b3c67690c4747b9fadfef407e6261524fb03f8a the `make install`
command fails if docs are not disabled through CFG_DISABLE_DOCS,
because now the `install` target uses
../../tmp/dist/$(DOC_PKG_NAME)-$(CFG_BUILD)/install.sh
Instead of explicitly depending on
dist/$(PKG_NAME)-$(CFG_BUILD).tar.gz, the `prepare_[un]install`
targets now depend on `dist-tar-bins`, which packages the appropriate
dist archives depending on the configuration.
bors [Sun, 4 Jan 2015 07:51:06 +0000 (07:51 +0000)]
auto merge of #20462 : alexcrichton/rust/remove-deprecated, r=aturon
This removes a large array of deprecated functionality, regardless of how
recently it was deprecated. The purpose of this commit is to clean out the
standard libraries and compiler for the upcoming alpha release.
Some notable compiler changes were to enable warnings for all now-deprecated
command line arguments (previously the deprecated versions were silently
accepted) as well as removing deriving(Zero) entirely (the trait was removed).
The distribution no longer contains the libtime or libregex_macros crates. Both
of these have been deprecated for some time and are available externally.
Alex Crichton [Fri, 2 Jan 2015 07:53:35 +0000 (23:53 -0800)]
Remove deprecated functionality
This removes a large array of deprecated functionality, regardless of how
recently it was deprecated. The purpose of this commit is to clean out the
standard libraries and compiler for the upcoming alpha release.
Some notable compiler changes were to enable warnings for all now-deprecated
command line arguments (previously the deprecated versions were silently
accepted) as well as removing deriving(Zero) entirely (the trait was removed).
The distribution no longer contains the libtime or libregex_macros crates. Both
of these have been deprecated for some time and are available externally.
bors [Sun, 4 Jan 2015 00:50:59 +0000 (00:50 +0000)]
auto merge of #20490 : japaric/rust/assoc-types, r=aturon
closes #20486
closes #20474
closes #20441
[breaking-change]
The `Index[Mut]` traits now have one less input parameter, as the return type of the indexing operation is an associated type. This breaks all existing implementations.
---
binop traits (`Add`, `Sub`, etc) now have an associated type for their return type. Also, the RHS input parameter now defaults to `Self` (except for the `Shl` and `Shr` traits). For example, the `Add` trait now looks like this:
``` rust
trait Add<Rhs=Self> {
type Output;
fn add(self, Rhs) -> Self::Output;
}
```
The `Neg` and `Not` traits now also have an associated type for their return type.
This breaks all existing implementations of these traits.
---
Affected traits:
- `Iterator { type Item }`
- `IteratorExt` no input/output types, uses `<Self as Iterator>::Item` in its methods
- `DoubleEndedIterator` no input/output types, uses `<Self as Iterator>::Item` in its methods
- `DoubleEndedIteratorExt` no input/output types, uses `<Self as Iterator>::Item` in its methods
- `RandomAccessIterator` no input/output types
- `ExactSizeIterator` no input/output types, uses `<Self as Iterator>::Item` in its methods
This breaks all the implementations of these traits.
bors [Sat, 3 Jan 2015 14:20:47 +0000 (14:20 +0000)]
auto merge of #20432 : nikomatsakis/rust/fn-inference-2, r=eddyb
Previously, the borrow mode of each upvar was inferred as part of regionck. This PR moves it into its own separate step. It also employs the `ExprUseVisitor`, further simplifying the code. The eventual goal is to support better inference of `Fn` vs `FnMut` vs `FnOnce` that is not based on the expected type, as well as supporting individual by-move upvars.
Niko Matsakis [Fri, 2 Jan 2015 09:12:25 +0000 (04:12 -0500)]
Move upvar checking into its own pre-pass that occurs before regionck
and which uses EUV. For now, upvar inference is not any smarter than
it ever was, but regionck is simpler because it doesn't have to do as
many things at once.
Niko Matsakis [Fri, 2 Jan 2015 09:09:35 +0000 (04:09 -0500)]
Make `ty::ParameterEnvironment`, not `ty::ctxt`, implement `Typer` and
`UnboxedClosureTyper`. This requires adding a `tcx` field to
`ParameterEnvironment` but generally simplifies everything since we
only need to pass along an `UnboxedClosureTyper` or `Typer`.
Niko Matsakis [Fri, 2 Jan 2015 09:01:30 +0000 (04:01 -0500)]
Modify `type_known_to_meet_builtin_bound` so that it doesn't suppress overflow,
which should always result in an error.
NB. Some of the hunks in this commit rely on a later commit which adds
`tcx` into `param_env` and modifies `ParameterEnvironment` to
implement `Typer`.
Niko Matsakis [Fri, 2 Jan 2015 08:51:49 +0000 (03:51 -0500)]
Re-introduce `McResult<>` as a way of aborting mem-categorization (and
expr-use-visitor) early. Turns out I was wrong to remove this; it
causes a lot of pain trying to run EUV etc during typeck without
ICEing on erroneous programs.
Andrea Canciani [Fri, 2 Jan 2015 19:33:04 +0000 (20:33 +0100)]
Fix `make install` dependencies
After 8b3c67690c4747b9fadfef407e6261524fb03f8a the `make install`
command fails if docs are not disabled through CFG_DISABLE_DOCS,
because now the `install` target uses
../../tmp/dist/$(DOC_PKG_NAME)-$(CFG_BUILD)/install.sh
In 714a2c678c5a5d1fdb9d6de3d515279120305441 the `prepare_install`
target wwas changed to conditionally depend also on the doc archive,
but did not modify `prepare_uninstall`.
Instead of explicitly depending on
dist/$(PKG_NAME)-$(CFG_BUILD).tar.gz, the `prepare_[un]install`
targets now depend on `dist-tar-bins`, which packages the appropriate
dist archives depending on the configuration.
bors [Sat, 3 Jan 2015 03:25:21 +0000 (03:25 +0000)]
auto merge of #20154 : P1start/rust/qualified-assoc-type-generics, r=nikomatsakis
This modifies `Parser::eat_lt` to always split up `<<`s, instead of doing so only when a lifetime name followed or the `force` parameter (now removed) was `true`. This is because `Foo<<TYPE` is now a valid start to a type, whereas previously only `Foo<<LIFETIME` was valid.
This is a [breaking-change]. Change code that looks like this:
bors [Sat, 3 Jan 2015 01:10:40 +0000 (01:10 +0000)]
auto merge of #19835 : pythonesque/rust/add-unordered-intrinsic, r=thestinger
This corresponds to the JMM memory model's non-volatile reads and writes to shared variables. It provides fairly weak guarantees, but prevents UB (specifically, you will never see a value that was not written _at some point_ to the provided location). It is not part of the C++ memory model and is only legal to provide to LLVM for loads and stores (not fences, atomicrmw, etc.).
Valid uses of this ordering are things like racy counters where you don't care about the operation actually being atomic, just want to avoid UB. It cannot be used for synchronization without additional memory barriers since unordered loads and stores may be reordered freely by the optimizer (this is the main way it differs from relaxed).
Because it is new to Rust and it provides so few guarantees, for now only the intrinsic is provided--this patch doesn't add it to any of the higher-level atomic wrappers.
Alex Crichton [Fri, 2 Jan 2015 17:22:44 +0000 (09:22 -0800)]
rollup merge of #20392: daramos/travis
Travis recently launched their new infrastructure on Amazon EC2 with improved resources. The only limitation is that they don't support sudo. http://blog.travis-ci.com/2014-12-17-faster-builds-with-container-based-infrastructure/
I couldn't find anywhere where the build system uses sudo so I don't think that limitation affects rust builds.
This change drops the current `make tidy` times [slightly](https://travis-ci.org/daramos/rust/builds)(travis-test branch).
Alex Crichton [Fri, 2 Jan 2015 17:22:22 +0000 (09:22 -0800)]
rollup merge of #20380: dcrewi/fix-make-install
There seems to be a problem introduced by 8b3c67690c4747b9fadfef407e6261524fb03f8a that causes "make install"
to fail when the build is not configured to skip doc building.
Niko Matsakis [Tue, 16 Dec 2014 02:11:09 +0000 (21:11 -0500)]
Refactor object-safety into its own (cached) module so that we can
check it more easily; also extend object safety to cover sized types
as well as static methods. This makes it sufficient so that we can
always ensure that `Foo : Foo` holds for any trait `Foo`.
Niko Matsakis [Sat, 20 Dec 2014 14:15:52 +0000 (09:15 -0500)]
Move the `upcast` routine into traits and use it for method selection; also
move get_method_index into traits and give it a better name (`get_vtable_index_of_object_method`).