Niko Matsakis
c61a0092bc
Fix orphan checking (cc #19470 ). (This is not a complete fix of #19470 because of the backwards compatibility feature gate.)
...
This is a [breaking-change]. The new rules require that, for an impl of a trait defined
in some other crate, two conditions must hold:
1. Some type must be local.
2. Every type parameter must appear "under" some local type.
Here are some examples that are legal:
```rust
struct MyStruct<T> { ... }
// Here `T` appears "under' `MyStruct`.
impl<T> Clone for MyStruct<T> { }
// Here `T` appears "under' `MyStruct` as well. Note that it also appears
// elsewhere.
impl<T> Iterator<T> for MyStruct<T> { }
```
Here is an illegal example:
```rust
// Here `U` does not appear "under" `MyStruct` or any other local type.
// We call `U` "uncovered".
impl<T,U> Iterator<U> for MyStruct<T> { }
```
There are a couple of ways to rewrite this last example so that it is
legal:
1. In some cases, the uncovered type parameter (here, `U`) should be converted
into an associated type. This is however a non-local change that requires access
to the original trait. Also, associated types are not fully baked.
2. Add `U` as a type parameter of `MyStruct`:
```rust
struct MyStruct<T,U> { ... }
impl<T,U> Iterator<U> for MyStruct<T,U> { }
```
3. Create a newtype wrapper for `U`
```rust
impl<T,U> Iterator<Wrapper<U>> for MyStruct<T,U> { }
```
Because associated types are not fully baked, which in the case of the
`Hash` trait makes adhering to this rule impossible, you can
temporarily disable this rule in your crate by using
`#![feature(old_orphan_check)]`. Note that the `old_orphan_check`
feature will be removed before 1.0 is released.
2015-01-02 04:06:09 -05:00
Niko Matsakis
1e3214ba33
Normalize the associated types in closure and closure upvar types.
2015-01-01 18:48:26 -05:00
Niko Matsakis
78f848cde5
Refactor the Typer interface to separate out UnboxedClosureTyper methods, which are
...
the only things that trait selection needs.
2015-01-01 18:48:26 -05:00
Niko Matsakis
7092af7ee3
Normalize predicates found on the impl
2015-01-01 18:48:26 -05:00
Niko Matsakis
6cb425d964
Rework normalization so that it works recursively, since the types extracted from an impl are potentially in need of normalization. This also lays groundwork for further cleanup in other areas by disconnecting normalization from the fulfillment context.
2014-12-31 12:50:30 -05:00
Niko Matsakis
0aa7ba9f5e
Normalize bounds also in the UFCS cases (and get more systematic about it)
2014-12-31 11:16:28 -05:00
Niko Matsakis
4f05ec7d2c
Patch projection to not be so eager to unify type variables. This code
...
is still probably wrong since it fails to incorporate the ambiguity
resolution measures that `select` uses. Also, made more complicated by
the fact that trait object types do not impl their own traits yet.
2014-12-31 11:15:42 -05:00
Niko Matsakis
919975d0a5
Address nits.
2014-12-30 09:36:23 -05:00
Niko Matsakis
de8e0ae22c
Remove the AssocSpace
2014-12-30 09:36:23 -05:00
Niko Matsakis
7ed0e23209
Resolve merge conflicts. This changes should really be integrated back to their respective
...
commits but oh dear what a pain.
2014-12-30 09:36:23 -05:00
Niko Matsakis
05eb2eeb61
Adjust tests for inferenceGet more conservative about inference for now. Seems better to err on the side of being more correct rather than less. Fix a bug in typing index expressions that was exposed as a result, and add one type annotation that is not required. Delete some random tests that were relying on old behavior and don't seem to add anything anymore.
2014-12-30 09:36:23 -05:00
Niko Matsakis
f1c041a54d
Patch long line.
2014-12-30 09:36:23 -05:00
Niko Matsakis
00cf176a5e
Add FIXMEs relating to caching of projection results
2014-12-30 09:36:22 -05:00
Niko Matsakis
3657ae13f5
Don't normalize associated types when in region binders, wait until we instantiate
...
them. Also fix some assertions and handling of builtin bounds.
2014-12-30 09:36:22 -05:00
Niko Matsakis
b7c6e317b0
Make projected types select out of the trait bounds.
2014-12-30 09:36:22 -05:00
Niko Matsakis
de806bc057
Teach project
to project associated types out of object types.
2014-12-30 09:36:22 -05:00
Niko Matsakis
82787c2252
Convert to use Rc<TraitRef>
in object types (finally!).
2014-12-30 09:36:21 -05:00
Niko Matsakis
4404592f36
Implement associated type projection and normalization.
2014-12-30 09:36:21 -05:00
Niko Matsakis
f95bb55a1c
Move the scalar types out of static data so that we can put Rc
into sty.
2014-12-30 09:34:38 -05:00
Niko Matsakis
986f654f3b
Rename trait_ref
field to predicate
, since trait_ref
is really
...
overly general, and the value is always *some* sort of predicate.
2014-12-30 09:32:42 -05:00
Niko Matsakis
4946e1a463
Move the TypeContents-based "Sized" queries into trans, where the full
...
types are always known and hence the ParameterEnvironment is not
necessary. For other `Sized` queries, use the trait infrastructure
just like `Copy`.
2014-12-30 09:32:42 -05:00
Huon Wilson
91db254c81
More rebase fixes.
2014-12-30 00:11:30 +11:00
Huon Wilson
ce3c949115
Intern BareFnTys to make sty slightly smaller.
...
This cuts the ty_bare_fn variant to 48 bytes rather than 56. There
doesn't seem to be a noticable memory usage decrease from this.
2014-12-29 23:55:24 +11:00
Huon Wilson
4f2b0f032a
Store Substs in an arena in the tcx.
...
This current inflates memory use more than 3 times.
2014-12-29 23:55:24 +11:00
bors
4a4c89c7a4
auto merge of #20119 : FlaPer87/rust/oibit-send-and-friends, r=nikomatsakis
...
More work on opt-in built in traits. `Send` and `Sync` are not opt-in, `OwnedPtr` renamed to `UniquePtr` and the `Send` and `Sync` traits are now unsafe.
NOTE: This likely needs to be rebased on top of the yet-to-land snapshot.
r? @nikomatsakis
cc #13231
2014-12-27 13:11:48 +00:00
Flavio Percoco
607f60712c
Keep track of the whole error chain
2014-12-26 17:26:33 +01:00
Flavio Percoco
fb803a8570
Require types to opt-in Sync
2014-12-26 17:26:32 +01:00
Niko Matsakis
a583ba2fa0
Remove McResult
from the mem-categorization interface.
2014-12-25 07:04:07 -05:00
Alex Crichton
de11710d80
rollup merge of #19891 : nikomatsakis/unique-fn-types-3
...
Conflicts:
src/libcore/str.rs
src/librustc_trans/trans/closure.rs
src/librustc_typeck/collect.rs
src/libstd/path/posix.rs
src/libstd/path/windows.rs
2014-12-22 12:51:23 -08:00
Alex Crichton
459f3b2cfa
rollup merge of #20056 : MrFloya/iter_rename
...
Conflicts:
src/libcollections/bit.rs
src/libcore/str.rs
2014-12-22 12:49:57 -08:00
Niko Matsakis
2a43b352f7
Rote changes that don't care to distinguish between a fn pointer and a fn item.
2014-12-22 12:27:07 -05:00
Florian Wilkens
f8cfd2480b
Renaming of the Iter types as in RFC #344
...
libcore: slice::Items -> slice::Iter, slice::MutItems -> slice::IterMut
libcollections: *::Items -> *::Iter, *::MoveItems -> *::IntoIter, *::MutItems -> *::IterMut
This is of course a [breaking-change].
2014-12-22 12:58:55 +01:00
Alex Crichton
082bfde412
Fallout of std::str stabilization
2014-12-21 23:31:42 -08:00
Corey Farwell
98af642f5c
Remove a ton of public reexports
...
Remove most of the public reexports mentioned in #19253
These are all leftovers from the enum namespacing transition
In particular:
* src/libstd/num/strconv.rs
* ExponentFormat
* SignificantDigits
* SignFormat
* src/libstd/path/windows.rs
* PathPrefix
* src/libstd/sys/windows/timer.rs
* Req
* src/libcollections/str.rs
* MaybeOwned
* src/libstd/collections/hash/map.rs
* Entry
* src/libstd/collections/hash/table.rs
* BucketState
* src/libstd/dynamic_lib.rs
* Rtld
* src/libstd/io/net/ip.rs
* IpAddr
* src/libstd/os.rs
* MemoryMapKind
* MapOption
* MapError
* src/libstd/sys/common/net.rs
* SocketStatus
* InAddr
* src/libstd/sys/unix/timer.rs
* Req
[breaking-change]
2014-12-21 09:26:41 -08:00
Jorge Aparicio
e64a0072d6
librustc: use #[deriving(Copy)]
2014-12-19 10:51:00 -05:00
Niko Matsakis
aa20e2ff36
Document new algorithm at a high-level.
2014-12-19 03:29:31 -05:00
Niko Matsakis
0b88c5d392
Remove text on method matching, which is now out of date.
2014-12-19 03:29:31 -05:00
Niko Matsakis
dab6e70e03
Convert gigantic comment away from //!
form. It is annoying to
...
read (`//!` is intrusive) and annoying to edit (must maintain a prefix
on every line). Since the only purpose of a `doc.rs` file is to have a
bunch of text, using `/*!` and `*/` without indentations seems
appropriate.
2014-12-19 03:29:31 -05:00
Niko Matsakis
f45c0ef51e
Implement "perfect forwarding" for HR impls ( #19730 ).
2014-12-19 03:29:31 -05:00
Niko Matsakis
c2ca1a4b62
Make all predicates higher-ranked, not just trait references.
2014-12-19 03:29:30 -05:00
Niko Matsakis
1205fd88df
Centralize on using Binder
to introduce new binding levels, rather than having FnSig carry an implicit binding level. This means that we be more typesafe in general, since things that instantiate bound regions can drop the Binder to reflect that.
2014-12-19 03:29:30 -05:00
Niko Matsakis
416e62924e
Rename the code that replaces unbound variables to "freshen" rather than "skolemize" -- strictly speaking, this is not skolemization, because it is not discharging quantifiers. Also, the trait selection code will still be doing true skolemization, so it would be a confusing overlap of names.
2014-12-19 03:29:30 -05:00
Niko Matsakis
3cf0fbeee9
Create distinct types for a PolyTraitRef (with bindings) and a normal TraitRef.
2014-12-19 03:29:30 -05:00
Flavio Percoco
127dac4990
Don't make unboxed closures implicitly copiable
...
The fix just checks if the bound is `Copy` and returns an `Err` if so.
Closes : #19817
2014-12-16 11:44:10 +01:00
Niko Matsakis
092d04a40a
Rename FnStyle trait to Unsafety.
2014-12-14 11:11:55 -05:00
Niko Matsakis
d258d68db6
Remove proc
types/expressions from the parser, compiler, and
...
language. Recommend `move||` instead.
2014-12-14 04:21:56 -05:00
Jorge Aparicio
1195708f64
librustc: use unboxed closures
2014-12-13 17:03:47 -05:00
Jorge Aparicio
fd06ef24bb
librustc: fix fallout
2014-12-13 17:03:44 -05:00
Niko Matsakis
124e1e18cc
Improve comments and address nits.
2014-12-12 20:25:21 -05:00
Niko Matsakis
97cf91aa30
Fix the opt-out-copy behavior so that values with dtor etc are considered affine
2014-12-12 20:25:21 -05:00