summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2017-03-10Fix #39390 on beta.Jeffrey Seyfried-2/+5
2017-03-09Propagate expected type hints through struct literals.Eduard-Mihai Burtescu-0/+20
2017-03-09trans: don't ICE when trying to create ADT trans-itemsAriel Ben-Yehuda-0/+51
ADTs are translated in-place from rustc_trans::callee, so no trans-items are needed. This fix will be superseded by the shimmir branch, but I prefer not to backport that to beta. Fixes #39823.
2017-03-09Fix const expression macro invocations.Jeffrey Seyfried-0/+24
2017-03-09Fix ICE: don't use `struct_variant` on enumsEsteban Küber-0/+34
Fix #40221 and add unittest.
2017-02-25std: Relax UnwindSafe impl for UniqueAlex Crichton-1/+4
Add the `?Sized` bound as we don't require the type to be sized. Closes #40011
2017-02-25use a more conservative inhabitableness ruleAriel Ben-Yehuda-8/+4
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/+62
Fixes #38972.
2017-02-23emit "align 1" metadata on loads/stores of packed structsAriel Ben-Yehuda-0/+29
According to the LLVM reference: > A value of 0 or an omitted align argument means that the operation has the ABI alignment for the target. So loads/stores of fields of packed structs need to have their align set to 1. Implement that by tracking the alignment of `LvalueRef`s. Fixes #39376.
2017-02-23Fix ICE when accessing mutably an immutable enumEsteban Küber-0/+30
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-23fix run-pass test that required `Copy` implNiko Matsakis-0/+2
2017-02-23remove vestiges of the old suggestion machineryNiko Matsakis-4/+92
2017-02-23add some sample UI error test casesNiko Matsakis-0/+243
These are some samples that I have been focusing on improving over time. In this PR, I mainly want to stem the bleeding where we in some cases we show an error that gives you no possible way to divine the problem.
2017-02-10Uninhabited while-let pattern fixAndrew Cann-0/+8
2017-02-06Delete failing testJosh Driver-51/+0
2017-02-01Fixup tests for new unknown derive errorJosh Driver-2/+2
2017-01-31Auto merge of #39379 - segevfiner:fix-backtraces-on-i686-pc-windows-gnu, ↵bors-5/+0
r=alexcrichton Fix backtraces on i686-pc-windows-gnu by disabling FPO This might have performance implications. But do note that MSVC disables FPO by default nowadays and it's use is limited in exception heavy languages like C++. See discussion in: #39234 Closes: #28218
2017-01-31Auto merge of #39250 - cseale:issue_30924, r=est31bors-0/+3
[Gate Tests] - marking feature tests Removal of the lang feature gate tests whitelist #39059 r? @est31
2017-01-31[Gate Tests] - marking feature testsColm Seale-0/+3
Removal of the lang feature gate tests whitelist #39059 r? @est31
2017-01-30Merge ty::TyBox into ty::TyAdtVadim Petrochenkov-50/+45
2017-01-29Fix backtraces on i686-pc-windows-gnu by disabling FPOSegev Finer-5/+0
This might have performance implications. But do note that MSVC disables FPO by default nowadays and it's use is limited in exception heavy languages like C++. Closes: #28218
2017-01-28Auto merge of #39234 - segevfiner:fix-backtraces-on-windows-gnu, r=petrochenkovbors-3/+2
Make backtraces work on Windows GNU targets again. This is done by adding a function that can return a filename to pass to backtrace_create_state. The filename is obtained in a safe way by first getting the filename, locking the file so it can't be moved, and then getting the filename again and making sure it's the same. See: https://github.com/rust-lang/rust/pull/37359#issuecomment-260123399 Issue: #33985 Note though that this isn't that pretty... I had to implement a `WideCharToMultiByte` wrapper function to convert to the ANSI code page. This will work better than only allowing ASCII provided that the ANSI code page is set to the user's local language, which is often the case. Also, please make sure that I didn't break the Unix build.
2017-01-28Disable backtrace tests on i686-pc-windows-gnu since it's broken by FPOSegev Finer-0/+5
2017-01-28Auto merge of #39305 - eddyb:synelide, r=nikomatsakisbors-14/+76
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: move object default lifetimes to resolve_lifetimes.Eduard-Mihai Burtescu-0/+24
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 #39313 - est31:drop_in_place_is_stable, r=GuillaumeGomezAlex Crichton-2/+0
drop_in_place is stable now, don't #![feature] it in the nomicon and a test. It was stable since Rust 1.8. r? @GuillaumeGomez
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-179/+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-41/+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-27Auto merge of #39281 - michaelwoerister:make-cc-incr-comp-opt-in, r=nikomatsakisbors-0/+15
incr.comp.: Make cross-crate tracking for incr. comp. opt-in. The current implementation of cross-crate dependency tracking can cause quite long compile times and high memory usage for some crates (see #39208 for example). This PR therefore makes that part of dependency tracking optional. Incremental compilation still works, it will only have very coarse dep-tracking for upstream crates. r? @nikomatsakis
2017-01-26Fix can_begin_expr keyword behaviorTaylor Cramer-0/+30
2017-01-27Auto merge of #39139 - estebank:issue-38147, r=nikomatsakisbors-15/+153
Point to immutable arg/fields when trying to use as &mut Present the following output when trying to access an immutable borrow's field as mutable: ``` error[E0389]: cannot borrow data mutably in a `&` reference --> $DIR/issue-38147-1.rs:27:9 | 26 | fn f(&self) { | ----- use `&mut self` here to make mutable 27 | f.s.push('x'); | ^^^ assignment into an immutable reference ``` And the following when trying to access an immutable struct field as mutable: ``` error: cannot borrow immutable borrowed content `*self.s` as mutable --> $DIR/issue-38147-3.rs:17:9 | 12 | s: &'a String | ------------- use `&'a mut String` here to make mutable ...| 16 | fn f(&self) { | ----- use `&mut self` here to make mutable 17 | self.s.push('x'); | ^^^^^^ cannot borrow as mutable ``` Fixes #38147.
2017-01-27Auto merge of #39158 - petrochenkov:bounds, r=nikomatsakisbors-30/+233
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-179/+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-26Point to immutable arg/fields when trying to use as &mutEsteban Küber-15/+153
Point to immutable borrow arguments and fields when trying to use them as mutable borrows. Add label to primary span on "cannot borrow as mutable" errors. Present the following output when trying to access an immutable borrow's field as mutable: ``` error[E0389]: cannot borrow data mutably in a `&` reference --> $DIR/issue-38147-1.rs:27:9 | 26 | fn f(&self) { | ----- use `&mut self` here to make mutable 27 | f.s.push('x'); | ^^^ assignment into an immutable reference ``` And the following when trying to access an immutable struct field as mutable: ``` error: cannot borrow immutable borrowed content `*self.s` as mutable --> $DIR/issue-38147-3.rs:17:9 | 12 | s: &'a String | ------------- use `&'a mut String` here to make mutable ...| 16 | fn f(&self) { | ----- use `&mut self` here to make mutable 17 | self.s.push('x'); | ^^^^^^ cannot borrow as mutable ```
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 #39309 - eddyb:map-shmap, r=nikomatsakisbors-2/+2
Rename tcx.map to the far more descriptive tcx.hir. Also a bit more renaming because `ast_map` and `'ast` were still used with HIR. Main motivation is to "free up" `tcx.map`, or rather, `tcx.maps`, to consolidate `ty::maps` there. 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-26rustc: rename TyCtxt's `map` field to `hir`.Eduard-Mihai Burtescu-2/+2
2017-01-26Add note for E0117Guillaume Gomez-1/+6