summary refs log tree commit diff
path: root/src/test/ui
AgeCommit message (Collapse)AuthorLines
2017-04-22Auto merge of #39999 - bitshifter:struct_align, r=eddybbors-0/+59
Implementation of repr struct alignment RFC 1358. The main changes around rustc::ty::Layout::struct: * Added abi_align field which stores abi alignment before repr align is applied * align field contains transitive repr alignment * Added padding vec which stores padding required after fields The main user of this information is rustc_trans::adt::struct_llfields which determines the LLVM fields to be used by LLVM, including padding fields. A possible future optimisation would be to put the padding Vec in an Option, since it will be unused unless you are using repr align.
2017-04-21Rollup merge of #41435 - estebank:issue-33884, r=nikomatsakisCorey Farwell-0/+39
Add test for issue 33884 Fix #33884. r=nikomatsakis
2017-04-21Rollup merge of #37658 - GuillaumeGomez:ref_suggestion, r=nikomatsakis,eddybCorey Farwell-10/+5
Ref suggestion
2017-04-21Update ui testGuillaume Gomez-10/+5
2017-04-20Reduce visual clutter of multiline start when possibleEsteban Küber-111/+86
When a span starts on a line with nothing but whitespace to the left, and there are no other annotations in that line, simplify the visual representation of the span. Go from: ```rust error[E0072]: recursive type `A` has infinite size --> file2.rs:1:1 | 1 | struct A { | _^ starting here... 2 | | a: A, 3 | | } | |_^ ...ending here: recursive type has infinite size | ``` To: ```rust error[E0072]: recursive type `A` has infinite size --> file2.rs:1:1 | 1 | / struct A { 2 | | a: A, 3 | | } | |_^ recursive type has infinite size ``` Remove `starting here...`/`...ending here` labels from all multiline diagnostics.
2017-04-20Add test for issue 33884Esteban Küber-0/+39
Fix #33884
2017-04-21Added feature gate, updated error messages and tests.Cameron Hart-0/+1
2017-04-21Implementation of repr struct alignment RFC 1358.Cameron Hart-0/+58
The main changes around rustc::ty::Layout::struct and rustc_trans:adt: * Added primitive_align field which stores alignment before repr align * Always emit field padding when generating the LLVM struct fields * Added methods for adjusting field indexes from the layout index to the LLVM struct field index The main user of this information is rustc_trans::adt::struct_llfields which determines the LLVM fields to be used by LLVM, including padding fields.
2017-04-20Rollup merge of #41214 - estebank:less-multiline, r=petrochenkovCorey Farwell-1/+64
Add a way to get shorter spans until `char` for pointing at defs ```rust error[E0072]: recursive type `X` has infinite size --> file.rs:10:1 | 10 | struct X { | ^^^^^^^^ recursive type has infinite size | = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `X` representable ``` vs ```rust error[E0072]: recursive type `X` has infinite size --> file.rs:10:1 | 10 | struct X { | _^ starting here... 11 | | x: X, 12 | | } | |_^ ...ending here: recursive type has infinite size | = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `X` representable ``` Re: #35965, #38246. Follow up to #38328. r? @jonathandturner
2017-04-18change note for patternsCengiz Can-1/+1
2017-04-18fixes #40013Cengiz Can-5/+72
2017-04-17Auto merge of #41282 - arielb1:missing-impl-item, r=petrochenkovbors-5/+85
libsyntax/parse: fix missing kind error reporting Fixes #41161. Fixes #41239.
2017-04-17libsyntax/parse: improve associated item error reportingAriel Ben-Yehuda-5/+85
Fixes #41161. Fixes #41239.
2017-04-12Rollup merge of #41205 - estebank:shorter-mismatched-types-2, r=nikomatsakisTim Neumann-5/+136
Highlight and simplify mismatched types Shorten mismatched types errors by replacing subtypes that are not different with `_`, and highlighting only the subtypes that are different. Given a file ```rust struct X<T1, T2> { x: T1, y: T2, } fn foo() -> X<X<String, String>, String> { X { x: X {x: "".to_string(), y: 2}, y: "".to_string()} } fn bar() -> Option<String> { "".to_string() } ``` provide the following output ```rust error[E0308]: mismatched types --> file.rs:6:5 | 6 | X { x: X {x: "".to_string(), y: 2}, y: "".to_string()} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::string::String`, found {integer} | = note: expected type `X<X<_, std::string::String>, _>` ^^^^^^^^^^^^^^^^^^^ // < highlighted found type `X<X<_, {integer}>, _>` ^^^^^^^^^ // < highlighted error[E0308]: mismatched types --> file.rs:6:5 | 10 | "".to_string() | ^^^^^^^^^^^^^^ expected struct `std::option::Option`, found `std::string::String` | = note: expected type `Option<std::string::String>` ^^^^^^^ ^ // < highlighted found type `std::string::String` ``` Fix #21025. Re: #40186. Follow up to #39906. I'm looking to change how this output is accomplished so that it doesn't create list of strings to pass around, but rather add an elided `Ty` placeholder, and use the same string formatting for normal types. I'll be doing that soonish. r? @nikomatsakis
2017-04-12Rollup merge of #41087 - estebank:tuple-float-index, r=arielb1Tim Neumann-0/+26
Use proper span for tuple index parsed as float Fix diagnostic suggestion from: ```rust help: try parenthesizing the first index | (1, (2, 3)).((1, (2, 3)).1).1; ``` to the correct: ```rust help: try parenthesizing the first index | ((1, (2, 3)).1).1; ``` Fix #41081.
2017-04-12Add a way to get shorter spans until `char` for pointing at defsEsteban Küber-1/+64
```rust error[E0072]: recursive type `X` has infinite size --> file.rs:10:1 | 10 | struct X { | ^^^^^^^^ recursive type has infinite size | = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `X` representable ``` vs ```rust error[E0072]: recursive type `X` has infinite size --> file.rs:10:1 | 10 | struct X { | _^ starting here... 11 | | x: X, 12 | | } | |_^ ...ending here: recursive type has infinite size | = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `X` representable ```
2017-04-11Highlight and simplify mismatched typesEsteban Küber-5/+136
Shorten mismatched types errors by replacing subtypes that are not different with `_`, and highlighting only the subtypes that are different. Given a file ```rust struct X<T1, T2> { x: T1, y: T2, } fn foo() -> X<X<String, String>, String> { X { x: X {x: "".to_string(), y: 2}, y: "".to_string()} } fn bar() -> Option<String> { "".to_string() } ``` provide the following output ```rust error[E0308]: mismatched types --> file.rs:6:5 | 6 | X { x: X {x: "".to_string(), y: 2}, y: "".to_string()} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::string::String`, found {integer} | = note: expected type `X<X<_, std::string::String>, _>` ^^^^^^^^^^^^^^^^^^^ // < highlighted found type `X<X<_, {integer}>, _>` ^^^^^^^^^ // < highlighted error[E0308]: mismatched types --> file.rs:6:5 | 10 | "".to_string() | ^^^^^^^^^^^^^^ expected struct `std::option::Option`, found `std::string::String` | = note: expected type `Option<std::string::String>` ^^^^^^^ ^ // < highlighted found type `std::string::String` ```
2017-04-11UI test for -Z print-fuel=fooAustin Hicks-0/+22
2017-04-11Initial attempt at implementing optimization fuel and re-enabling struct ↵Austin Hicks-32/+29
field reordering.
2017-04-11Auto merge of #41174 - estebank:issue-41155, r=nikomatsakisbors-0/+23
Point at only one char on `Span::next_point` Avoid pointing at two chars so the diagnostic output doesn't display a multiline span when starting beyond a line end. Fix #41155. Instead of ```rust error: expected one of `(`, `const`, `default`, `extern`, `fn`, `type`, or `unsafe`, found `}` --> <anon>:3:1 | 1 | impl S { pub | _____________- starting here... 2 | | | | ...ending here: expected one of 7 possible tokens here 3 | } | ^ unexpected token ``` show ```rust error: expected one of `(`, `const`, `default`, `extern`, `fn`, `type`, or `unsafe`, found `}` --> <anon>:13:1 | 12 | pub | - expected one of 7 possible tokens here 13 | } | ^ unexpected token ```
2017-04-10Auto merge of #40565 - estebank:binops-help, r=arielb1bors-5/+204
Explicit help message for binop type mismatch When trying to do `1 + Some(2)`, or some other binary operation on two types different types without an appropriate trait implementation, provide an explicit help message: ```rust help: `{integer} + std::option::Option<{integer}>` has no implementation ``` Re: #39579, #38564, #37626, #39942, #34698.
2017-04-10Explicit help message for binop type missmatchEsteban Küber-5/+204
When trying to do a binary operation with missing implementation, for example `1 + Some(2)`, provide an explicit help message: ``` note: no implementation for `{integer} + std::option::Option<{integer}>` ``` Use `rustc_on_unimplemented` for the suggestions. Move cfail test to ui.
2017-04-10Point at only one char on `Span::next_point`Esteban Küber-0/+23
Avoid pointing at two chars so the diagnostic output doesn't display a multiline span when starting beyond a line end.
2017-04-09Auto merge of #41136 - estebank:multiline, r=jonathandturnerbors-10/+13
Always show end line of multiline annotations ```rust error[E0046]: not all trait items implemented, missing: `Item` --> $DIR/issue-23729.rs:20:9 | 20 | impl Iterator for Recurrence { | _________^ starting here... 21 | | //~^ ERROR E0046 22 | | //~| NOTE missing `Item` in implementation 23 | | //~| NOTE `Item` from trait: `type Item;` ... | 36 | | } 37 | | } | |_________^ ...ending here: missing `Item` in implementation | = note: `Item` from trait: `type Item;` ``` instead of ```rust error[E0046]: not all trait items implemented, missing: `Item` --> $DIR/issue-23729.rs:20:9 | 20 | impl Iterator for Recurrence { | ^ missing `Item` in implementation | = note: `Item` from trait: `type Item;` ```
2017-04-09Always show end line of multiline annotationsEsteban Küber-10/+13
```rust error[E0046]: not all trait items implemented, missing: `Item` --> $DIR/issue-23729.rs:20:9 | 20 | impl Iterator for Recurrence { | _________^ starting here... 21 | | //~^ ERROR E0046 22 | | //~| NOTE missing `Item` in implementation 23 | | //~| NOTE `Item` from trait: `type Item;` ... | 36 | | } 37 | | } | |_________^ ...ending here: missing `Item` in implementation | = note: `Item` from trait: `type Item;` ``` instead of ```rust error[E0046]: not all trait items implemented, missing: `Item` --> $DIR/issue-23729.rs:20:9 | 20 | impl Iterator for Recurrence { | ^ missing `Item` in implementation | = note: `Item` from trait: `type Item;` ```
2017-04-07Merge branch 'master' into ty-placeholderEsteban Küber-7/+363
2017-04-06Rollup merge of #41108 - arielb1:tuple-blame, r=estebankCorey Farwell-1/+13
don't try to blame tuple fields for immutability Tuple fields don't have an `&T` in their declaration that can be changed to `&mut T` - skip them.. Fixes #41104. r? @nikomatsakis
2017-04-06don't try to blame tuple fields for immutabilityAriel Ben-Yehuda-1/+13
Tuple fields don't have an `&T` in their declaration that can be changed to `&mut T` - skip them.. Fixes #41104.
2017-04-05Rollup merge of #41052 - topecongiro:overlapping_inherent_impls, r=estebankAriel Ben-Yehuda-0/+101
Make 'overlapping_inherent_impls' lint a hard error This is ought to be implemented in PR #40728. Unfortunately, when I rebased the PR to resolve merge conflict, the "hard error" code disappeared. This PR complements the initial PR. Now the following rust code gives the following error: ```rust struct Foo; impl Foo { fn id() {} } impl Foo { fn id() {} } fn main() {} ``` ``` error[E0592]: duplicate definitions with name `id` --> /home/topecongiro/test.rs:4:5 | 4 | fn id() {} | ^^^^^^^^^^ duplicate definitions for `id` ... 8 | fn id() {} | ---------- other definition for `id` error: aborting due to previous error ```
2017-04-05Rollup merge of #40815 - estebank:issue-40006, r=GuillaumeGomezAriel Ben-Yehuda-0/+29
Identify missing item category in `impl`s ```rust struct S; impl S { pub hello_method(&self) { println!("Hello"); } } fn main() { S.hello_method(); } ``` ```rust error: missing `fn` for method declaration --> file.rs:3:4 | 3 | pub hello_method(&self) { | ^ missing `fn` ``` Fix #40006. r? @pnkfelix CC @jonathandturner @GuillaumeGomez
2017-04-05Use proper span for tuple index parsed as floatEsteban Küber-0/+26
Fix diagnostic suggestion from: ```rust help: try parenthesizing the first index | (1, (2, 3)).((1, (2, 3)).1).1; ``` to the correct: ```rust help: try parenthesizing the first index | ((1, (2, 3)).1).1; ```
2017-04-05Rollup merge of #41062 - estebank:private-field, r=arielb1Corey Farwell-0/+37
Do not recommend private fields called as method ```rust error: no method named `dog_age` found for type `animal::Dog` in the current scope --> $DIR/private-field.rs:26:23 | 26 | let dog_age = dog.dog_age(); | ^^^^^^^ private field, not a method ``` Fix #27654.
2017-04-04Do not recommend private fields called as methodEsteban Küber-0/+37
2017-04-04Merge branch 'master' into issue-32540Esteban Küber-22/+1761
2017-04-04Move 'coherence-overlapping-inherent-impl-trait' test to uitopecongiro-0/+26
2017-04-04Move 'overlapping_inherent_impls' test to uitopecongiro-0/+75
2017-04-03Merge branch 'master' into issue-40006Esteban Küber-22/+1761
2017-04-02Introduce `TyErr` independent from `TyInfer`Esteban Küber-0/+69
Add a `TyErr` type to represent unknown types in places where parse errors have happened, while still able to build the AST. Initially only used to represent incorrectly written fn arguments and avoid "expected X parameters, found Y" errors when called with the appropriate amount of parameters. We cannot use `TyInfer` for this as `_` is not allowed as a valid argument type. Example output: ```rust error: expected one of `:` or `@`, found `,` --> file.rs:12:9 | 12 | fn bar(x, y: usize) {} | ^ error[E0061]: this function takes 2 parameters but 3 parameters were supplied --> file.rs:19:9 | 12 | fn bar(x, y) {} | --------------- defined here ... 19 | bar(1, 2, 3); | ^^^^^^^ expected 2 parameters ```
2017-03-30update UI testNiko Matsakis-4/+0
We no longer give suggestions; this is presumably related to the changes I made in coercion. However, those suggestions appear to be wrong anyhow!
2017-03-30cherry-pick over the tests I wrote for the reachability codeNiko Matsakis-0/+1023
For the most part, the current code performs similarly, although it differs in some particulars. I'll be nice to have these tests for judging future changes, as well.
2017-03-30rework how we handle the type of loopsNiko Matsakis-0/+33
First, we keep a `CoerceMany` now to find the LUB of all the break expressions. Second, this `CoerceMany` is actually an `Option<CoerceMany>`, and we store `None` for loops where "break with an expression" is disallowed. This avoids silly duplicate errors about a type mismatch, since the loops pass already reports an error that the break cannot have an expression. Finally, since we now detect an invalid break target during HIR lowering, refactor `find_loop` to be infallible. Adjust tests as needed: - some spans from breaks are slightly different - break up a single loop into multiple since `CoerceMany` silences redundant and derived errors - add a ui test that we only give on error for loop-break-value
2017-03-30Auto merge of #40597 - jseyfried:improve_span_expn_info, r=jseyfriedbors-4/+1
macros: improve `Span`'s expansion information This PR improves `Span`'s expansion information. More specifically: - It refactors AST node span construction to preserve expansion information. - Today, we only use the underlying tokens' `BytePos`s, throwing away the `ExpnId`s. - This improves the accuracy of AST nodes' expansion information, fixing #30506. - It refactors `span.expn_id: ExpnId` to `span.ctxt: SyntaxContext` and removes `ExpnId`. - This gives all tokens as much hygiene information as `Ident`s. - This is groundwork for procedural macros 2.0 `TokenStream` API. - This is also groundwork for declarative macros 2.0, which will need this hygiene information for some non-`Ident` tokens. - It simplifies processing of spans' expansion information throughout the compiler. - It fixes #40649. - It fixes #39450 and fixes part of #23480. r? @nrc
2017-03-29Rollup merge of #40816 - estebank:issue-38321, r=nikomatsakisCorey Farwell-0/+338
Clarify suggetion for field used as method Instead of ```rust error: no method named `src_addr` found for type `&wire::ipv4::Repr` in the current scope --> src/wire/ipv4.rs:409:34 | 409 | packet.set_src_addr(self.src_addr()); | ^^^^^^^^ | note: did you mean to write `self.src_addr`? --> src/wire/ipv4.rs:409:34 | 409 | packet.set_src_addr(self.src_addr()); | ^^^^^^^^ ``` present ```rust error: no method named `src_addr` found for type `&wire::ipv4::Repr` in the current scope --> src/wire/ipv4.rs:409:34 | 409 | packet.set_src_addr(self.src_addr()); | ^^^^^^^^ field, not a method | = help: did you mean to write `self.src_addr` instead of `self.src_addr(...)`? ``` Fix #38321.
2017-03-29Refactor how spans are combined in the parser.Jeffrey Seyfried-4/+1
2017-03-28Simplify labels and move tests to uiEsteban Küber-0/+338
2017-03-27Fix unittestsEsteban Küber-1/+5
2017-03-27Simplify error outputEsteban Küber-7/+3
2017-03-27fix handling of `self`Ariel Ben-Yehuda-9/+102
2017-03-27borrowck: consolidate `mut` suggestionsAriel Ben-Yehuda-15/+119
This converts all of borrowck's `mut` suggestions to a new `mc::ImmutabilityBlame` API instead of the current mix of various hacks. Fixes #35937. Fixes #40823.
2017-03-25Improve wording and spans for unexpected tokenEsteban Küber-7/+173
* Point at where the token was expected instead of the last token successfuly parsed. * Only show `unexpected token` if the next char and the unexpected token don't have the same span. * Change some cfail and pfail tests to ui test. * Don't show all possible tokens in span label if they are more than 6.