about summary refs log tree commit diff
path: root/src/test/compile-fail
AgeCommit message (Collapse)AuthorLines
2017-02-04Add a new ui test and update existing onesCengiz Can-39/+29
2017-02-04Improve error message for uninferrable types #38812Cengiz Can-26/+28
2017-02-04Auto merge of #38426 - vadimcn:nobundle, r=alexcrichtonbors-0/+13
Implement kind="static-nobundle" (RFC 1717) This implements the "static-nobundle" library kind (last item from #37403). Rustc handles "static-nobundle" libs very similarly to dylibs, except that on Windows, uses of their symbols do not get marked with "dllimport". Which is the whole point of this feature.
2017-02-04note wording: lint implied by lint group, not lint group implies lintZack M. Davis-1/+1
2017-02-04make lint-group-style test a UI rather than a compile-fail testZack M. Davis-51/+0
As suggested by Niko Matsakis in review (https://github.com/rust-lang/rust/pull/38103#discussion_r94460982) regarding the endeavor prompted by #36846.
2017-02-04note lint group set on command line triggering individual lintZack M. Davis-1/+1
Previously, the note/message for the source of a lint being the command line unconditionally named the individual lint, even if the actual command specified a lint group (e.g., `-D warnings`); here, we take note of the actual command options so we can be more specific. This remains in the matter of #36846.
2017-02-04note individual lint name set via lint group attribute in notesZack M. Davis-9/+27
Warning or error messages set via a lint group attribute (e.g. `#[deny(warnings)]`) should still make it clear which individual lint (by name) was triggered, similarly to how we include "on by default" language for default lints. This—and, while we're here, the existing "on by default" language—can be tucked into a note rather than cluttering the main error message. This occasions the slightest of refactorings (we now have to get the diagnostic-builder with the main message first, before matching on the lint source). This is in the matter of #36846.
2017-02-04Uninhabited while-let pattern fixAndrew Cann-0/+8
2017-02-04Expand defaulted unit testAndrew Cann-0/+15
2017-02-03lint/ctypes: Don't warn on non-unsized structs with PhantomData.Emilio Cobos Álvarez-0/+6
Fixes #34798
2017-02-03Fix testAndrew Cann-3/+6
2017-02-03Fix testAndrew Cann-4/+11
2017-02-03Use a proper future-compatibility lintAndrew Cann-0/+26
2017-02-02Rollup merge of #39420 - oli-obk:sugg, r=pnkfelixGuillaume Gomez-1/+2
parser: use suggestions instead of helps with code in them
2017-02-02Auto merge of #39384 - wesleywiser:fix_fixmes, r=alexcrichtonbors-31/+0
Resolve a bunch of fixmes Resolves 56 fixmes in test code related to `box` syntax.
2017-02-02Auto merge of #38932 - petrochenkov:privctor, r=jseyfriedbors-71/+71
Privatize constructors of tuple structs with private fields This PR implements the strictest version of such "privatization" - it just sets visibilities for struct constructors, this affects everything including imports. ``` visibility(struct_ctor) = min(visibility(struct), visibility(field_1), ..., visibility(field_N)) ``` Needs crater run before proceeding. Resolves https://github.com/rust-lang/rfcs/issues/902 r? @nikomatsakis
2017-01-31Removes FIXMEs related to #22405Wesley Wiser-31/+0
2017-01-31use suggestions instead of helps with code in themOliver Schneider-1/+2
2017-01-30Merge ty::TyBox into ty::TyAdtVadim Petrochenkov-40/+35
2017-01-29Improve diagnostics for inaccessible constructorsVadim Petrochenkov-63/+1
2017-01-29Implement compatibility lint for legacy constructor visibilitiesVadim Petrochenkov-0/+28
2017-01-29Fix the falloutVadim Petrochenkov-82/+53
2017-01-29Privatize constructors of tuple structs with private fieldsVadim Petrochenkov-0/+63
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