about summary refs log tree commit diff
path: root/src/test/compile-fail
AgeCommit message (Collapse)AuthorLines
2016-11-09Auto merge of #37678 - eddyb:rollup, r=eddybbors-35/+30
Rollup of 5 pull requests - Successful merges: #37402, #37412, #37661, #37664, #37667 - Failed merges:
2016-11-09Show one error for duplicated type definitionsEsteban Küber-12/+1
For the following code: ```rustc struct Bar; struct Bar; fn main () { } ``` show ```nocode error[E0428]: a type named `Bar` has already been defined in this module --> src/test/compile-fail/E0428.rs:12:1 | 11 | struct Bar; | ----------- previous definition of `Bar` here 12 | struct Bar; | ^^^^^^^^^^^ error: aborting due to previous error ``` instead of ```nocode error[E0428]: a type named `Bar` has already been defined in this module --> src/test/compile-fail/E0428.rs:12:1 | 11 | struct Bar; | ----------- previous definition of `Bar` here 12 | struct Bar; | ^^^^^^^^^^^ error[E0428]: a value named `Bar` has already been defined in this module --> src/test/compile-fail/E0428.rs:12:1 | 11 | struct Bar; | ----------- previous definition of `Bar` here 12 | struct Bar; | ^^^^^^^^^^^ error: aborting due to 2 previous errors ```
2016-11-10rustc_typeck: correctly track "always-diverges" and "has-type-errors".Eduard Burtescu-35/+30
2016-11-09Auto merge of #37603 - arielb1:max-slice-length, r=nikomatsakisbors-0/+24
_match: correct max_slice_length logic The logic used to be wildly wrong, but before the HAIR patch its wrongness was in most cases hidden by another bug. Fixes #37598. r? @nikomatsakis
2016-11-09Auto merge of #37670 - eddyb:rollup, r=eddybbors-291/+9
Rollup of 15 pull requests - Successful merges: #36868, #37134, #37229, #37250, #37370, #37428, #37432, #37472, #37524, #37614, #37622, #37627, #37636, #37644, #37654 - Failed merges: #37463, #37542, #37645
2016-11-09Rollup merge of #37428 - estebank:generic-type-error-span, r=sanxiynEduard-Mihai Burtescu-2/+2
Point to type argument span when used as trait Given the following code: ``` rust struct Foo<T: Clone>(T); use std::ops::Add; impl<T: Clone, Add> Add for Foo<T> { type Output = usize; fn add(self, rhs: Self) -> Self::Output { unimplemented!(); } } ``` present the following output: ``` nocode error[E0404]: `Add` is not a trait --> file3.rs:5:21 | 5 | impl<T: Clone, Add> Add for Okok<T> { | --- ^^^ expected trait, found type parameter | | | type parameter defined here ``` Fixes #35987.
2016-11-09Rollup merge of #37370 - estebank:signature-2-empire-strikes-back, ↵Eduard-Mihai Burtescu-203/+0
r=nikomatsakis Include type of missing trait methods in error Provide either a span pointing to the original definition of missing trait items, or a message with the inferred definitions. Fixes #24626. Follow up to PR #36371. If PR #37369 lands, missing trait items that present a multiline span will be able to show the entirety of the item definition on the error itself, instead of just the first line.
2016-11-09Auto merge of #36520 - estebank:dataless-enum, r=brsonbors-2/+6
Reword error when data-less enum variant called as function Given a file like: ``` rust enum Test { Variant, Variant2 {a: u32}, } fn main(){ let x = Test::Variant("Hello"); let y = Test::Variant2("World"); } ``` Both errors now look similar: ``` bash error[E0423]: `Test::Variant2` is the name of a struct or struct variant, but this expression uses it like a function name --> file3.rs:10:13 | 10 | let y = Test::Variant2("Hello"); | ^^^^^^^^^^^^^^ struct called like a function | = help: did you mean to write: `Test::Variant2 { /* fields */ }`? error: `Test::Variant` is the name of a data-less enum, but this expression uses it like a function name --> file3.rs:9:13 | 9 | let x = Test::Variant("World"); | ^^^^^^^^^^^^^^^^^^^^^^ data-less enum called like a function | = help: did you mean to write: `Test::Variant`? note: defined here --> file3.rs:2:5 | 2 | Variant, | ^^^^^^^ error: aborting due to previous error ``` Re: #28533
2016-11-08Group unused import warnings per path listEsteban Küber-2/+3
Given a file ```rust use std::collections::{BinaryHeap, BTreeMap, BTreeSet}; fn main() {} ``` Show a single warning, instead of three for each unused import: ```nocode warning: unused imports, #[warn(unused_imports)] on by default --> foo.rs:1:24 | 1 | use std::collections::{BinaryHeap, BTreeMap, BTreeSet}; | ^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ``` Include support for lints pointing at `MultilineSpan`s, instead of just `Span`s.
2016-11-08Point to type argument span when used as traitEsteban Küber-2/+2
Given the following code: ```rust struct Foo<T: Clone>(T); use std::ops::Add; impl<T: Clone, Add> Add for Foo<T> { type Output = usize; fn add(self, rhs: Self) -> Self::Output { unimplemented!(); } } ``` present the following output: ```nocode error[E0404]: `Add` is not a trait --> file3.rs:5:21 | 5 | impl<T: Clone, Add> Add for Okok<T> { | --- ^^^ expected trait, found type parameter | | | type parameter defined here ```
2016-11-09Improve "Doesn't live long enough" errorMikhail Modin-62/+0
case with temporary variable
2016-11-08Partially stabilize RFC 1506 "Clarify relationships between ADTs"Vadim Petrochenkov-85/+6
2016-11-08Auto merge of #36843 - petrochenkov:dotstab, r=nikomatsakisbors-21/+0
Stabilize `..` in tuple (struct) patterns I'd like to nominate `..` in tuple and tuple struct patterns for stabilization. This feature is a relatively small extension to existing stable functionality and doesn't have known blockers. The feature first appeared in Rust 1.10 6 months ago. An example of use: https://github.com/rust-lang/rust/pull/36203 Closes https://github.com/rust-lang/rust/issues/33627 r? @nikomatsakis
2016-11-06Auto merge of #37506 - jseyfried:improve_shadowing_checks, r=nrcbors-0/+37
macros: improve shadowing checks This PR improves macro-expanded shadowing checks to work with out-of-(pre)order expansion. Out-of-order expansion became possible in #37084, so this technically a [breaking-change] for nightly. The regression test from this PR is an example of code that would break. r? @nrc
2016-11-06Make E0243/0244 message consistent with E0107sinkuu-25/+25
2016-11-05Include type of missing trait methods in errorEsteban Küber-203/+0
Provide either a span pointing to the original definition of missing trait items, or a message with the inferred definitions.
2016-11-05Fix tests from the rollupAlex Crichton-1/+2
2016-11-05Merge branch 'selfgate' of https://github.com/petrochenkov/rust into rollupAlex Crichton-0/+35
2016-11-05Rollup merge of #37564 - Mark-Simulacrum:sized-ice, r=eddybAlex Crichton-0/+16
Fix ICE when querying DefId on Def::Err. Also moves computations into check that `kind_id` is `Ok(_)`, which is in theory an optimization, though I expect it's minor. Fixes #37534. r? @eddyb.
2016-11-05Rollup merge of #37501 - alexcrichton:windows-subsystem, r=brsonAlex Crichton-0/+29
rustc: Add knowledge of Windows subsystems. This commit is an implementation of [RFC 1665] which adds support for the `#![windows_subsystem]` attribute. This attribute allows specifying either the "windows" or "console" subsystems on Windows to the linker. [RFC 1665]: https://github.com/rust-lang/rfcs/blob/master/text/1665-windows-subsystem.md Previously all Rust executables were compiled as the "console" subsystem which meant that if you wanted a graphical application it would erroneously pop up a console whenever opened. When compiling an application, however, this is undesired behavior and the "windows" subsystem is used instead to have control over user interactions. This attribute is validated, but ignored on all non-Windows platforms. cc #37499
2016-11-05_match: correct max_slice_length logicAriel Ben-Yehuda-0/+24
The logic used to be wildly wrong, but before the HAIR patch its wrongness was hidden by another bug. Fixes #37598.
2016-11-04Auto merge of #37167 - nikomatsakis:jroesch-issue-18937, r=pnkfelixbors-194/+55
detect extra region requirements in impls The current "compare method" check fails to check for the "region obligations" that accrue in the fulfillment context. This branch switches that code to create a `FnCtxt` so that it can invoke the regionck code. Previous crater runs (I haven't done one with the latest tip) have found some small number of affected crates, so I went ahead and introduced a warning cycle. I will kick off a crater run with this branch shortly. This is a [breaking-change] because previously unsound code was accepted. The crater runs also revealed some cases where legitimate code was no longer type-checking, so the branch contains one additional (but orthogonal) change. It improves the elaborator so that we elaborate region requirements more thoroughly. In particular, if we know that `&'a T: 'b`, we now deduce that `T: 'b` and `'a: 'b`. I invested a certain amount of effort in getting a good error message. The error message looks like this: ``` error[E0276]: impl has stricter requirements than trait --> traits-elaborate-projection-region.rs:33:5 | 21 | fn foo() where T: 'a; | --------------------- definition of `foo` from trait ... 33 | fn foo() where U: 'a { } | ^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `U: 'a` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #18937 <https://github.com/rust-lang/rust/issues/18937> note: lint level defined here --> traits-elaborate-projection-region.rs:12:9 | 12 | #![deny(extra_requirement_in_impl)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ ``` Obviously the warning only prints if this is a _new_ error (that resulted from the bugfix). But all existing errors that fit this description are updated to follow the general template. In order to get the lint to preserve the span-labels and the error code, I separate out the core `Diagnostic` type (which encapsulates the error code, message, span, and children) from the `DiagnosticBuilder` (which layers on a `Handler` that can be used to report errors). I also extended `add_lint` with an alternative `add_lint_diagnostic` that takes in a full diagnostic (cc @jonathandturner for those changes). This doesn't feel ideal but feels like it's moving in the right direction =). r? @pnkfelix cc @arielb1 Fixes #18937
2016-11-03Fix invalid "ref mut mut" sugestionEsteban Küber-30/+0
2016-11-03Fix ICE when querying DefId on Def::Err.Mark-Simulacrum-0/+16
2016-11-03Add feature gate for Self and associated types in struct expressions and ↵Vadim Petrochenkov-0/+35
patterns
2016-11-03Stabilize `..` in tuple (struct) patternsVadim Petrochenkov-21/+0
2016-11-02Add regression test.Jeffrey Seyfried-0/+37
2016-11-01move compile-fail tests to ui testsNiko Matsakis-192/+0
gets more comprehensive coverage in `ui`
2016-11-01update test error messagesNiko Matsakis-13/+14
We've got a new revised message for E0273; just drop back to the error code, since the ui tests check for the full appearance now.
2016-11-01compare-method lintNiko Matsakis-0/+2
2016-11-01cleanup error reporting and add `ui` testsNiko Matsakis-54/+0
2016-11-01elaborate `T: 'a` dependenciesNiko Matsakis-0/+66
2016-11-01introduce fn-ctxt so we can invoke regionck codeJared Roesch-0/+38
2016-11-01Improve "Doesn't live long enough" errorMikhail Modin-394/+0
case with different lifetime with spans
2016-10-31Changed most vec! invocations to use square bracesiirelu-53/+53
Most of the Rust community agrees that the vec! macro is clearer when called using square brackets [] instead of regular brackets (). Most of these ocurrences are from before macros allowed using different types of brackets. There is one left unchanged in a pretty-print test, as the pretty printer still wants it to have regular brackets.
2016-10-31rustc: Add knowledge of Windows subsystems.Alex Crichton-0/+29
This commit is an implementation of [RFC 1665] which adds support for the `#![windows_subsystem]` attribute. This attribute allows specifying either the "windows" or "console" subsystems on Windows to the linker. [RFC 1665]: https://github.com/rust-lang/rfcs/blob/master/text/1665-windows-subsystem.md Previously all Rust executables were compiled as the "console" subsystem which meant that if you wanted a graphical application it would erroneously pop up a console whenever opened. When compiling an application, however, this is undesired behavior and the "windows" subsystem is used instead to have control over user interactions. This attribute is validated, but ignored on all non-Windows platforms. cc #37499
2016-10-29Auto merge of #37378 - petrochenkov:nopat, r=eddybbors-0/+23
Prohibit patterns in trait methods without bodies They are not properly type checked ```rust trait Tr { fn f(&a: u8); // <- This compiles } ``` , mostly rejected by the parser already and generally don't make much sense. This PR is kind of a missing part of https://github.com/rust-lang/rust/pull/35015. Given the [statistics from crater](https://github.com/rust-lang/rust/pull/37378#issuecomment-256154994), the effect of this PR is mostly equivalent to improving `unused_mut` lint. cc https://github.com/rust-lang/rust/issues/35078#issuecomment-255707355 https://github.com/rust-lang/rust/pull/35015 https://github.com/rust-lang/rfcs/pull/1685 https://github.com/rust-lang/rust/issues/35203 r? @eddyb
2016-10-28Rollup merge of #37430 - robinst:missing-crate-message-add-semicolon, r=eddybGuillaume Gomez-3/+3
Add semicolon to "Maybe a missing `extern crate foo`" message I had it a couple of times that I was missing the "extern crate" line after I introduced a new dependency. So I copied the text from the message and inserted it into the beginning of my code, only to find the compiler complaining that I was missing the semicolon. (I forgot to add it after the text that I had pasted.) There's a similar message which does include the semicolon, namely "help: you can import it into scope: `use foo::Bar;`". I think the two messages should be consistent, so this change adds it for "extern crate".
2016-10-28Rollup merge of #36206 - mcarton:35755, r=pnkfelixGuillaume Gomez-0/+23
Fix bad error message with `::<` in types Fix #36116. Before: ```rust error: expected identifier, found `<` --> src/test/compile-fail/issue-36116.rs:16:52 | 16 | let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>); | ^ error: chained comparison operators require parentheses --> src/test/compile-fail/issue-36116.rs:16:52 | 16 | let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>); | ^^^^^^ | = help: use `::<...>` instead of `<...>` if you meant to specify type arguments error: expected expression, found `)` --> src/test/compile-fail/issue-36116.rs:16:57 | 16 | let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>); | ^ error: expected identifier, found `<` --> src/test/compile-fail/issue-36116.rs:20:17 | 20 | let g: Foo::<i32> = Foo { _a: 42 }; | ^ error: aborting due to 5 previous errors ``` After: ```rust error: unexpected token: `::` --> src/test/compile-fail/issue-36116.rs:16:50 | 16 | let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>); | ^^ | = help: use `<...>` instead of `::<...>` if you meant to specify type arguments error: unexpected token: `::` --> src/test/compile-fail/issue-36116.rs:20:15 | 20 | let g: Foo::<i32> = Foo { _a: 42 }; | ^^ | = help: use `<...>` instead of `::<...>` if you meant to specify type arguments error: aborting due to 2 previous errors ```
2016-10-28Fix bad error message with `::<` in typesmcarton-0/+23
2016-10-27Address comments + Fix rebaseVadim Petrochenkov-6/+44
2016-10-27Support `Self` in struct expressions and patternsVadim Petrochenkov-0/+47
2016-10-27Preparations and cleanupVadim Petrochenkov-61/+76
Diagnostics for struct path resolution errors in resolve and typeck are unified. Self type is treated as a type alias in few places (not reachable yet). Unsafe cell is seen in constants even through type aliases. All checks for struct paths in typeck work on type level.
2016-10-27Auto merge of #36894 - petrochenkov:deny, r=nikomatsakisbors-28/+16
Make sufficiently old or low-impact compatibility lints deny-by-default Tracking issues are updated/created when necessary. Needs crater run before proceeding. r? @nikomatsakis
2016-10-27Make sufficiently old or low-impact compatibility lints deny-by-defaultVadim Petrochenkov-28/+16
2016-10-27Auto merge of #37128 - nrc:depr-attr, r=@alexcrichtonbors-1/+18
Deprecate no_debug and custom_derive r? @nikomatsakis
2016-10-26Auto merge of #11994 - eddyb:struct-literal-field-shorthand, r=nrcbors-0/+72
Implement field shorthands in struct literal expressions. Implements #37340 in a straight-forward way: `Foo { x, y: f() }` parses as `Foo { x: x, y: f() }`. Because of the added `is_shorthand` to `ast::Field`, this is `[syntax-breaking]` (cc @Manishearth). * [x] Mark the fields as being a shorthand (the exact same way we do it in patterns), for pretty-printing. * [x] Gate the shorthand syntax with `#![feature(field_init_shorthand)]`. * [x] Don't parse numeric field as identifiers. * [x] Arbitrary field order tests.
2016-10-27Add semicolon to "Maybe a missing `extern crate foo`" messageRobin Stocker-3/+3
I had it a couple of times that I was missing the "extern crate" line after I introduced a new dependency. So I copied the text from the message and inserted it into the beginning of my code, only to find the compiler complaining that I was missing the semicolon. (I forgot to add it after the text that I had pasted.) There's a similar message which does include the semicolon, namely "help: you can import it into scope: `use foo::Bar;`". I think the two messages should be consistent, so this change adds it for "extern crate".
2016-10-27review changesNick Cameron-1/+1
2016-10-26Auto merge of #36695 - arielb1:literal-match, r=eddybbors-16/+97
Refactor match checking to use HAIR Refactor match checking to use HAIR instead of HIR, fixing quite a few bugs in the process. r? @eddyb