Commit graph

39101 commits

Author SHA1 Message Date
Flavio Percoco 9d0d72345d register snapshot 880fb89 2015-02-27 01:48:49 +01:00
bors 880fb89bde Auto merge of #22512 - nikomatsakis:issue-20300-where-clause-not-bounds, r=nikomatsakis
This is a fix for #20300 though as a side-sweep it fixes a number of stack overflows because it integrates cycle detection into the conversion process. I didn't go through and retest everything.

The tricky part here is that in some cases we have to go find the information we need from the AST -- we can't use the converted form of the where-clauses because we often have to handle something like `T::Item` *while converting the where-clauses themselves*. Since this is also not a fixed-point process we can't just try and keep trying to find the best order. So instead I modified the `AstConv` interface to allow you to request the bounds for a type parameter; we'll then do a secondary scan of the where-clauses to figure out what we need. This may create a cycle in some cases, but we have code to catch that.

Another approach that is NOT taken by this PR would be to "convert" `T::Item` into a form that does not specify what trait it's using. This then kind of defers the problem of picking the trait till later. That might be a good idea, but it would make normalization and everything else much harder, so I'm holding off on that (and hoping to find a better way for handling things like `i32::T`).

This PR also removes "most of" the `bounds` struct from `TypeParameterDef`. Still a little ways to go before `ParamBounds` can be removed entirely -- it's used for supertraits, for example (though those really ought to be converted, I think, to a call to `get_type_parameter_bounds` on `Self` from within the trait definition).

cc @jroesch 

Fixes #20300
2015-02-25 04:28:23 +00:00
Niko Matsakis 1ef3598ed9 Merge conflicts due to eddyb's UFCS branch 2015-02-24 16:27:23 -05:00
Niko Matsakis abdb42ba64 Remove two uses of old [] notation 2015-02-24 16:27:23 -05:00
Niko Matsakis eb77fe9e06 Merge conflict: port default impls code 2015-02-24 16:27:23 -05:00
Niko Matsakis 31e09f740a Add handy switch -Z treat-err-as-bug -- it often happens that I am
compiling something I expect to succeed, and this lets me get
stacktraces and also abort compilation faster.
2015-02-24 16:27:23 -05:00
Niko Matsakis cf73e36ab0 Rework trait-bound-conversion so be based on the AST and rework collect
to pass in the appropriate ast::generics etc
2015-02-24 16:27:23 -05:00
Niko Matsakis 36d04711b7 Remove bounds struct from TypeParameterDef. Bounds information is now
exclusively stored in the where clauses.
2015-02-24 16:27:22 -05:00
Niko Matsakis 3c782b742b Rework the get_type_parameter_bounds impl to use a trait object
and act more generically.
2015-02-24 16:27:22 -05:00
Niko Matsakis 0d9e473be9 Comprehence cycle detection in collect. In some cases, the cycles we
report are not *necessary* cycles, but we'll work on refactoring them
over time. This overlaps with the cycle detection that astconv already
does: I left that code in because it gives a more targeted error
message, though perhaps less helpful in that it doesn't give the full
details of the cycle.
2015-02-24 16:27:22 -05:00
Niko Matsakis 15ef2c2e6b Convert astconv to request bounds through the AstConv interface
rather than poking through the `TypeParameterDef` directly.
2015-02-24 16:27:22 -05:00
Niko Matsakis e033a231ab Change collect to implement AstConv on a ItemCtxt rather than a
global context. Have this `ItemCtxt` carry a (currently unused) pointer
to the in-scope generics.
2015-02-24 16:27:22 -05:00
bors ad04cce61c Auto merge of #22530 - rprichard:master, r=dotdash
Fixes #22525

I wasn't sure if I should reuse `write::get_llvm_opt_level` or not.  It returns an `llvm::CodeGenOptLevel`, which is the Rust binding for `CodeGenOpt::Level`. `lto.rs` is passing an optlevel to LLVM's `PassManagerBuilder`, which takes an unsigned int.  `PassManagerBuilder`'s optlevel uses essentially the same enumeration (i.e. 0-3 with 2 as default), but it's implicit.
2015-02-24 20:57:31 +00:00
bors 0bd15657d9 Auto merge of #22172 - eddyb:almost-there, r=nikomatsakis
Adds `<module::Type>::method` support and makes `module::Type::method` a shorthand for it.
This is most of #16293, except that chaining multiple associated types is not yet supported.
It also fixes #22563 as `impl`s are no longer treated as modules in resolve.

Unfortunately, this is still a *[breaking-change]*:
* If you used a global path to a primitive type, i.e. `::bool`, `::i32` etc. - that was a bug I had to fix.
Solution: remove the leading `::`.
* If you passed explicit `impl`-side type parameters to an inherent method, e.g.:
```rust
struct Foo<T>(T);
impl<A, B> Foo<(A, B)> {
    fn pair(a: A, b: B) -> Foo<(A, B)> { Foo((a, b)) }
}
Foo::<A, B>::pair(a, b)
// Now that is sugar for:
<Foo<A, B>>::pair(a, b)
// Which isn't valid because `Foo` has only one type parameter.
// Solution: replace with:
Foo::<(A, B)>::pair(a, b)
// And, if possible, remove the explicit type param entirely:
Foo::pair(a, b)
```
* If you used the `QPath`-related `AstBuilder` methods @hugwijst added in #21943.
The methods still exist, but `QPath` was replaced by `QSelf`, with the actual path stored separately.
Solution: unpack the pair returned by `cx.qpath` to get the two arguments for `cx.expr_qpath`.
2015-02-24 17:56:09 +00:00
bors c9ace059e7 Auto merge of #22749 - kballard:process-stdio-constructors, r=alexcrichton
There are no tests for this because testing inherit/null is tricky.
Probably why there weren't tests for it to begin with.
2015-02-24 15:01:28 +00:00
Eduard Burtescu 0c6d1f3b3d syntax: update pretty-printer for the <T>::method shorthand. 2015-02-24 14:16:03 +02:00
Eduard Burtescu 72d5f39be7 Fix fallout from rebasing. 2015-02-24 14:16:02 +02:00
Eduard Burtescu 8501c9dee5 rustc_typeck: unify the impl type with the UFCS path prefix type. 2015-02-24 14:16:02 +02:00
Eduard Burtescu f0efa2d843 Update trans/save's span hacks for fully qualified UFCS paths. 2015-02-24 14:16:02 +02:00
Eduard Burtescu 9ac073604c Fix fallout from allowing impls outside of the type's definition module. 2015-02-24 14:16:02 +02:00
Eduard Burtescu 866a5ee299 Fix fallout from correct stability handling in UFCS. 2015-02-24 14:16:02 +02:00
Eduard Burtescu 923616e188 Fix @nikomatsakis' nits in typeck. 2015-02-24 14:16:02 +02:00
Eduard Burtescu 09ad993a25 tests: add two new run-pass tests for method behavior after UFCS. 2015-02-24 14:16:02 +02:00
Eduard Burtescu d31b9ebef5 Implement <T>::method UFCS expression syntax. 2015-02-24 14:16:02 +02:00
Eduard Burtescu fdfb532d78 tests: remove warnings from and rename const-polymorphic-paths to ufcs-polymorphic-paths. 2015-02-24 14:16:02 +02:00
Eduard Burtescu 5a6a9ed792 rustc: combine partial_def_map and last_private_map into def_map. 2015-02-24 14:16:02 +02:00
Eduard Burtescu 06f362aeb3 rustc_resolve: don't handle impl items as if they were modules. 2015-02-24 14:16:01 +02:00
Eduard Burtescu 6700166442 core: fix typo that wasn't caught by the hacky previous implementation. 2015-02-24 14:16:01 +02:00
Eduard Burtescu fe4f9b8e3a Use partial path resolutions in expressions for UFCS desugaring. 2015-02-24 14:16:01 +02:00
Eduard Burtescu 7a3054f55c rustc_resolve: remove the distinction between DefStaticMethod and DefMethod. 2015-02-24 14:14:17 +02:00
Eduard Burtescu 0f49254b31 rustc: use partially resolved definitions to replace the T::A hack. 2015-02-24 14:14:17 +02:00
Eduard Burtescu 5809f8ae74 rustc_resolve: use the visitor model more, remove redundant repeated lookups. 2015-02-24 14:14:16 +02:00
Eduard Burtescu ffb8092ccf syntax: use a single Path for Trait::Item in QPath. 2015-02-24 14:14:16 +02:00
Eduard Burtescu 326711e9bd rustc_resolve: use DefAssociatedTy for TyQPath. 2015-02-24 14:14:16 +02:00
Eduard Burtescu 9a69378e8b rustc: load DefAssociatedTy from cross-crate metadata. Fixes #20542. 2015-02-24 14:14:16 +02:00
Eduard Burtescu 9739ae4d09 rustc: remove unused ForeignType item family. 2015-02-24 14:14:16 +02:00
Eduard Burtescu 004df413aa syntax: don't use TraitRef in QPath. 2015-02-24 14:14:16 +02:00
Eduard Burtescu a817c69297 syntax: don't store a secondary NodeId for TyPath. 2015-02-24 14:14:16 +02:00
Eduard Burtescu 27747ac1a7 Revert bogus rename from DefTrait to DefaultImpl. 2015-02-24 14:14:16 +02:00
bors dccdde4007 Auto merge of #22755 - Manishearth:rollup, r=Manishearth 2015-02-24 09:33:17 +00:00
Manish Goregaokar b182cd7245 Fix integers in tests (fixup #22700) 2015-02-24 13:49:01 +05:30
Ryan Prichard 9167c62c1a Disable run-pass/sepcomp-lib-lto.rs on Android until #18800 is fixed 2015-02-23 23:42:42 -08:00
Manish Goregaokar 2d74b53a03 Rollup merge of #22720 - edwardw:enum-struct-ident-walk-into-a-bar, r=nick29581
Closes #22589
Closes #22647
Closes #22665
Closes #22712
2015-02-24 12:33:40 +05:30
Edward Wang a1396d250a Add tests for expect ident but find enum or struct panic
Closes #22589
Closes #22647
Closes #22665
Closes #22712
2015-02-24 14:59:24 +08:00
Manish Goregaokar 13efa52946 Remove another instance of ty_open (fixup #22213) 2015-02-24 12:25:56 +05:30
Manish Goregaokar 89d5d2448d Rollup merge of #22213 - eddyb:ty_open-case-closed, r=nikomatsakis
This type wasn't necessary, as there was no place using it and unsized types not wrapped in it, at the same time.
r? @nikomatsakis
2015-02-24 12:26:01 +05:30
Eduard Burtescu 8659de0334 rustc_trans: use an Lvalue Datum for an unsized lvalue to avoid bogus drops. 2015-02-24 08:40:15 +02:00
Eduard Burtescu 3b0cafbcd7 tests: update expected recursion limit errors for the temporary lack of spans. 2015-02-24 08:40:15 +02:00
Eduard Burtescu 7a8a5172a5 Remove ty_open and treat Unsized lvalues as *Unsized. 2015-02-24 08:40:14 +02:00
Manish Goregaokar e711ac7e75 Remove double expr_u32 (fixup #22700) 2015-02-24 12:08:36 +05:30