summary refs log tree commit diff
path: root/src/test/compile-fail
AgeCommit message (Collapse)AuthorLines
2017-03-10Fix #39390 on beta.Jeffrey Seyfried-15/+0
2017-02-25use a more conservative inhabitableness ruleAriel Ben-Yehuda-3/+3
This is a [breaking-change] from 1.15, because this used to compile: ```Rust enum Void {} fn foo(x: &Void) { match x {} } ```
2017-02-25check_match: don't treat privately uninhabited types as uninhabitedAriel Ben-Yehuda-7/+33
Fixes #38972.
2017-02-23Fix ICE when parsing token trees after an error.Jeffrey Seyfried-0/+32
2017-02-23Fix ICE on certain sequence repetitions.Jeffrey Seyfried-0/+15
2017-02-23remove vestiges of the old suggestion machineryNiko Matsakis-4/+1
2017-02-10Uninhabited while-let pattern fixAndrew Cann-0/+8
2017-02-01Fixup tests for new unknown derive errorJosh Driver-2/+2
2017-01-30Merge ty::TyBox into ty::TyAdtVadim Petrochenkov-40/+35
2017-01-28Auto merge of #39305 - eddyb:synelide, r=nikomatsakisbors-14/+52
Perform lifetime elision (more) syntactically, before type-checking. The *initial* goal of this patch was to remove the (contextual) `&RegionScope` argument passed around `rustc_typeck::astconv` and allow converting arbitrary (syntactic) `hir::Ty` to (semantic) `Ty`. I've tried to closely match the existing behavior while moving the logic to the earlier `resolve_lifetime` pass, and [the crater report](https://gist.github.com/eddyb/4ac5b8516f87c1bfa2de528ed2b7779a) suggests none of the changes broke real code, but I will try to list everything: There are few cases in lifetime elision that could trip users up due to "hidden knowledge": ```rust type StaticStr = &'static str; // hides 'static trait WithLifetime<'a> { type Output; // can hide 'a } // This worked because the type of the first argument contains // 'static, although StaticStr doesn't even have parameters. fn foo(x: StaticStr) -> &str { x } // This worked because the compiler resolved the argument type // to <T as WithLifetime<'a>>::Output which has the hidden 'a. fn bar<'a, T: WithLifetime<'a>>(_: T::Output) -> &str { "baz" } ``` In the two examples above, elision wasn't using lifetimes that were in the source, not even *needed* by paths in the source, but rather *happened* to be part of the semantic representation of the types. To me, this suggests they should have never worked through elision (and they don't with this PR). Next we have an actual rule with a strange result, that is, the return type here elides to `&'x str`: ```rust impl<'a, 'b> Trait for Foo<'a, 'b> { fn method<'x, 'y>(self: &'x Foo<'a, 'b>, _: Bar<'y>) -> &str { &self.name } } ``` All 3 of `'a`, `'b` and `'y` are being ignored, because the `&self` elision rule only cares that the first argument is "`self` by reference". Due implementation considerations (elision running before typeck), I've limited it in this PR to a reference to a primitive/`struct`/`enum`/`union`, but not other types, but I am doing another crater run to assess the impact of limiting it to literally `&self` and `self: &Self` (they're identical in HIR). It's probably ideal to keep an "implicit `Self` for `self`" type around and *only* apply the rule to `&self` itself, but that would result in more bikeshed, and #21400 suggests some people expect otherwise. Another decent option is treating `self: X, ... -> Y` like `X -> Y` (one unique lifetime in `X` used for `Y`). The remaining changes have to do with "object lifetime defaults" (see RFCs [599](https://github.com/rust-lang/rfcs/blob/master/text/0599-default-object-bound.md) and [1156](https://github.com/rust-lang/rfcs/blob/master/text/1156-adjust-default-object-bounds.md)): ```rust trait Trait {} struct Ref2<'a, 'b, T: 'a+'b>(&'a T, &'b T); // These apply specifically within a (fn) body, // which allows type and lifetime inference: fn main() { // Used to be &'a mut (Trait+'a) - where 'a is one // inference variable - &'a mut (Trait+'b) in this PR. let _: &mut Trait; // Used to be an ambiguity error, but in this PR it's // Ref2<'a, 'b, Trait+'c> (3 inference variables). let _: Ref2<Trait>; } ``` What's happening here is that inference variables are created on the fly by typeck whenever a lifetime has no resolution attached to it - while it would be possible to alter the implementation to reuse inference variables based on decisions made early by `resolve_lifetime`, not doing that is more flexible and works better - it can compile all testcases from #38624 by not ending up with `&'static mut (Trait+'static)`. The ambiguity specifically cannot be an early error, because this is only the "default" (typeck can still pick something better based on the definition of `Trait` and whether it has any lifetime bounds), and having an error at all doesn't help anyone, as we can perfectly infer an appropriate lifetime inside the `fn` body. **TODO**: write tests for the user-visible changes. cc @nikomatsakis @arielb1
2017-01-28test: add missing lifetime in recently added test.Eduard-Mihai Burtescu-1/+1
2017-01-28rustc: always keep an explicit lifetime in trait objects.Eduard-Mihai Burtescu-2/+4
2017-01-28rustc_typeck: move impl Trait checks out of RegionScope.Eduard-Mihai Burtescu-1/+1
2017-01-28rustc: move most of lifetime elision to resolve_lifetimes.Eduard-Mihai Burtescu-8/+44
2017-01-28rustc: always include elidable lifetimes in HIR types.Eduard-Mihai Burtescu-2/+2
2017-01-27Rollup merge of #39335 - cramertj:cramertj/can_begin_expr_fix, r=petrochenkovAlex Crichton-0/+30
Fix can_begin_expr keyword behavior Partial fix for #28784.
2017-01-27Rollup merge of #39306 - GuillaumeGomez:newtype_help, r=eddybAlex Crichton-1/+6
Add note for E0117 Fixes #39249. I just applied the suggestion of @durka since I don't see anything else to add.
2017-01-27Rollup merge of #39290 - canndrew:hide-uninhabitedness, r=nikomatsakisAlex Crichton-19/+50
Hide uninhabitedness checks behind feature gate This reverts the fix to match exhaustiveness checking so that it can be discussed. The new code is now hidden behind the `never_type` feature gate.
2017-01-27Rollup merge of #38617 - pnkfelix:double-reference, r=pnkfelixAlex Crichton-0/+38
Detect double reference when applying binary op ``` rust let vr = v.iter().filter(|x| { x % 2 == 0 }); ``` will now yield the following compiler output: ``` bash ERROR binary operation `%` cannot be applied to type `&&_` NOTE this is a reference of a reference to a type that `%` can be applied to, you need to dereference this variable once for this operation to work NOTE an implementation of `std::ops::Rem` might be missing for `&&_` ``` The first NOTE is new. Fix #33877 ---- Thanks to @estebank for providing the original PR #34420 (of which this is a tweaked rebase).
2017-01-27Auto merge of #37057 - brson:nosuggest, r=nikomatsakisbors-126/+0
rustc: Remove all "consider using an explicit lifetime parameter" suggestions These give so many incorrect suggestions that having them is detrimental to the user experience. The compiler should not be suggesting changes to the code that are wrong - it is infuriating: not only is the compiler telling you that _you don't understand_ borrowing, _the compiler itself_ appears to not understand borrowing. It does not inspire confidence. r? @nikomatsakis
2017-01-27Auto merge of #39282 - petrochenkov:selfstab, r=nikomatsakisbors-37/+0
Stabilize Self and associated types in struct expressions and patterns Rebase of https://github.com/rust-lang/rust/pull/37734 Closes https://github.com/rust-lang/rust/issues/37544 r? @nikomatsakis
2017-01-26Fix can_begin_expr keyword behaviorTaylor Cramer-0/+30
2017-01-27Auto merge of #39158 - petrochenkov:bounds, r=nikomatsakisbors-15/+89
Bounds parsing refactoring 2 See https://github.com/rust-lang/rust/pull/37511 for previous discussion. cc @matklad Relaxed parsing rules: - zero bounds after `:` are allowed in all contexts. - zero predicates are allowed after `where`. - trailing separator `,` is allowed after predicates in `where` clauses not followed by `{`. Other parsing rules: - trailing separator `+` is still allowed in all bound lists. Code is also cleaned up and tests added. I haven't touched parsing of trait object types yet, I'll do it later.
2017-01-26rustc: Remove all "consider using an explicit lifetime parameter" suggestionsBrian Anderson-126/+0
These give so many incorrect suggestions that having them is detrimental to the user experience. The compiler should not be suggesting changes to the code that are wrong - it is infuriating: not only is the compiler telling you that _you don't understand_ borrowing, _the compiler itself_ appears to not understand borrowing. It does not inspire confidence.
2017-01-26Auto merge of #39066 - arielb1:lifetime-extension-test, r=nikomatsakisbors-0/+27
End temporary lifetimes being extended by `let X: &_` hints cc #39283 r? @nikomatsakis
2017-01-26Auto merge of #38819 - GuillaumeGomez:main_func_wrong_type, r=GuillaumeGomezbors-5/+5
Add a distinct error code and description for "main function has wron… …g type"
2017-01-26Add note for E0117Guillaume Gomez-1/+6
2017-01-26Update error code numberGuillaume Gomez-5/+5
2017-01-26Add a distinct error code and description for "main function has wrong type"Guillaume Gomez-5/+5
2017-01-26Auto merge of #39075 - est31:remove_reflect, r=nikomatsakisbors-127/+0
Remove Reflect PR for removing the `Reflect` trait. Opened so that a crater run can be done for testing the impact: https://github.com/rust-lang/rust/issues/27749#issuecomment-272665163 Fixes #27749
2017-01-26Auto merge of #39000 - nikomatsakis:incr_comp_crosscontaminate_impl_item, ↵bors-12/+52
r=michaelwoerister process trait/impl items directly from the visitor callback The current setup processes impl/trait items while visiting the impl/trait. This means we basically have this setup: <Lots> -> TypeckItemBody(Impl) -> Tables(ImplItem{0,1,2,3}) But this was largely an artifact of the older code. By moving the processing of items into method dedicated for their use, we produce this setup: <Little> -> TypeckItemBody(ImplItem0) -> Tables(ImplItem0) ... <Little> -> TypeckItemBody(ImplItem3) -> Tables(ImplItem3) r? @michaelwoerister Also, we might consider removing the `TypeckItemBody` node altogether and just using `Tables` as the task. `Tables` is its primary output, I imagine? That would reduce size of dep-graph somewhat. cc @eddyb -- perhaps this pattern applies elsewhere?
2017-01-25Auto merge of #38920 - petrochenkov:selfimpl, r=eddybbors-0/+43
Partially implement RFC 1647 (`Self` in impl headers) The name resolution part is easy, but the typeck part contains an unexpected problem. It turns out that `Self` type *depends* on bounds and `where` clauses, so we need to convert them first to determine what the `Self` type is! If bounds/`where` clauses can refer to `Self` then we have a cyclic dependency. This is required to support impls like this: ``` // Found in libcollections impl<I: IntoIterator> SpecExtend<I> for LinkedList<I::Item> { .... } ^^^^^ associated type `Item` is found using information from bounds ``` I'm not yet sure how to resolve this issue. One possible solution (that feels hacky) is to make two passes over generics - first collect predicates ignoring everything involving `Self`, then determine `Self`, then collect predicates again without ignoring anything. (Some kind of lazy on-demand checking or something looks like a proper solution.) This patch in its current state doesn't solve the problem with `Self` in bounds, so the only observable things it does is improving error messages and supporting `impl Trait<Self> for Type {}`. There's also a question about feature gating. It's non-trivial to *detect* "newly resolved" `Self`s to feature gate them, but it's simple to *enable* the new resolution behavior when the feature gate is already specified. Alternatively this can be considered a bug fix and merged without a feature gate. cc https://github.com/rust-lang/rust/issues/38864 r? @nikomatsakis cc @eddyb Whitespace ignoring diff https://github.com/rust-lang/rust/pull/38920/files?w=1
2017-01-25rename `Tables` to `TypeckTables`Niko Matsakis-14/+14
2017-01-25merge TypeckItemBody and Tables depnodesNiko Matsakis-12/+12
2017-01-25fix the test case by supplying proper optionsNiko Matsakis-0/+5
2017-01-25pacify the mercilous tidyNiko Matsakis-0/+10
2017-01-25process trait/impl items directly from the visitor callbackNiko Matsakis-0/+25
The current setup processes impl/trait items while visiting the impl/trait. This means we basically have this setup: <Lots> -> TypeckItemBody(Impl) -> Tables(ImplItem{0,1,2,3}) But this was largely an artifact of the older code. By moving the processing of items into method dedicated for their use, we produce this setup: <Little> -> TypeckItemBody(ImplItem0) -> Tables(ImplItem0) ... <Little> -> TypeckItemBody(ImplItem3) -> Tables(ImplItem3)
2017-01-25Hide uninhabitedness checks behind feature gateAndrew Cann-19/+50
2017-01-25Auto merge of #35712 - oli-obk:exclusive_range_patterns, r=nikomatsakisbors-0/+78
exclusive range patterns adds `..` patterns to the language under a feature gate (`exclusive_range_pattern`). This allows turning ``` rust match i { 0...9 => {}, 10...19 => {}, 20...29 => {}, _ => {} } ``` into ``` rust match i { 0..10 => {}, 10..20 => {}, 20..30 => {}, _ => {} } ```
2017-01-25end temporary lifetimes being extended by `let X: &_` hintsAriel Ben-Yehuda-0/+27
Fixes #36082.
2017-01-25Stabilize Self and associated types in struct expressions and patternsVadim Petrochenkov-37/+0
2017-01-24Remove Reflectest31-127/+0
* Remove the Reflect trait * Remove the "reflect" lang feature
2017-01-24Improve some expected/found error messages from parserVadim Petrochenkov-7/+10
2017-01-24Add testsVadim Petrochenkov-0/+54
2017-01-24Refactor parsing of generic arguments/parameters and where clausesVadim Petrochenkov-15/+32
2017-01-22[Gate Tests] - marking feature testsColm Seale-0/+11
Removal of the lang feature gate tests whitelist #39059 r? @est31
2017-01-22Auto merge of #39127 - canndrew:unreachable-pattern-errors-into-warnings, ↵bors-0/+96
r=arielb1 Change unreachable pattern ICEs to warnings Allow code with unreachable `?` and `for` patterns to compile. Add some tests.
2017-01-22Warn on unused `#[macro_use]` imports.Jeffrey Seyfried-2/+21
2017-01-21Resolve `Self` in impl headersVadim Petrochenkov-0/+43
2017-01-21Improve `unused_extern_crate` warnings.Jeffrey Seyfried-0/+5