summary refs log tree commit diff
path: root/src/test/ui/span
AgeCommit message (Collapse)AuthorLines
2017-03-10Rollup merge of #40287 - estebank:label-overlap, r=nrcAlex Crichton-0/+27
Fix incorrect span label formatting Fix #40157.
2017-03-10Rollup merge of #40092 - sinkuu:fix_suggestion_index, r=pnkfelixAlex Crichton-0/+27
Fix suggestion span error with a line containing multibyte characters This PR fixes broken suggestions caused by multibyte characters. e.g. for this code, rustc provides a broken suggestion ([playground](https://is.gd/DWGLu7)): ```rust fn main() { let tup = (1,); println!("☃{}", tup[0]); } ``` ``` error: cannot index a value of type `({integer},)` --> <anon>:3:21 | 3 | println!("☃{}", tup[0]); | ^^^^^^ | help: to access tuple elements, use tuple indexing syntax as shown | println!("☃{}"tup.00]); error: aborting due to previous error ``` `CodeSuggestion::splice_lines` is misusing `Loc.col` (`CharPos`) as a byte offset when slicing source.
2017-03-10Fix incorrect span label formattingEsteban Küber-0/+27
2017-03-10Point to enclosing block/fn on nested unsafeEsteban Küber-0/+182
When declaring nested unsafe blocks (`unsafe {unsafe {}}`) that trigger the "unnecessary `unsafe` block" error, point out the enclosing `unsafe block` or `unsafe fn` that makes it unnecessary.
2017-03-06Clean up "pattern doesn't bind x" messagesEsteban Küber-0/+64
Group "missing variable bind" spans in `or` matches and clarify wording for the two possible cases: when a variable from the first pattern is not in any of the subsequent patterns, and when a variable in any of the other patterns is not in the first one. Before: ``` error[E0408]: variable `a` from pattern #1 is not bound in pattern #2 --> file.rs:10:23 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^^^^ pattern doesn't bind `a` error[E0408]: variable `b` from pattern #2 is not bound in pattern #1 --> file.rs:10:32 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^ pattern doesn't bind `b` error[E0408]: variable `a` from pattern #1 is not bound in pattern #3 --> file.rs:10:37 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^ pattern doesn't bind `a` error[E0408]: variable `d` from pattern #1 is not bound in pattern #3 --> file.rs:10:37 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^ pattern doesn't bind `d` error[E0408]: variable `c` from pattern #3 is not bound in pattern #1 --> file.rs:10:43 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^ pattern doesn't bind `c` error[E0408]: variable `d` from pattern #1 is not bound in pattern #4 --> file.rs:10:48 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^ pattern doesn't bind `d` error: aborting due to 6 previous errors ``` After: ``` error[E0408]: variable `a` is not bound in all patterns --> file.rs:20:37 | 20 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { intln!("{:?}", a); } | - ^^^^^^^^^^^ ^^^^^^^^ - variable t in all patterns | | | | | | | pattern doesn't bind `a` | | pattern doesn't bind `a` | variable not in all patterns error[E0408]: variable `d` is not bound in all patterns --> file.rs:20:37 | 20 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { intln!("{:?}", a); } | - - ^^^^^^^^ ^^^^^^^^ pattern esn't bind `d` | | | | | | | pattern doesn't bind `d` | | variable not in all patterns | variable not in all patterns error[E0408]: variable `b` is not bound in all patterns --> file.rs:20:37 | 20 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { intln!("{:?}", a); } | ^^^^^^^^^^^ - ^^^^^^^^ ^^^^^^^^ pattern esn't bind `b` | | | | | | | pattern doesn't bind `b` | | variable not in all patterns | pattern doesn't bind `b` error[E0408]: variable `c` is not bound in all patterns --> file.rs:20:48 | 20 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { intln!("{:?}", a); } | ^^^^^^^^^^^ ^^^^^^^^^^^ - ^^^^^^^^ pattern esn't bind `c` | | | | | | | variable not in all tterns | | pattern doesn't bind `c` | pattern doesn't bind `c` error: aborting due to 4 previous errors ``` * Have only one presentation for binding consistency errors * Point to same binding in multiple patterns when possible * Check inconsistent bindings in all arms * Simplify wording of diagnostic message * Sort emition and spans of binding errors for deterministic output
2017-02-28walk the bodies "in order" by traversing the crateNiko Matsakis-8/+8
Otherwise the errors from borrowck come out in an unpredictable order.
2017-02-25rustc_typeck: rework coherence to be almost completely on-demand.Eduard-Mihai Burtescu-9/+9
2017-02-25Fix suggestion span error with a line containing non-ASCIIssinkuu-0/+27
2017-02-09change span_notes to notes in E0368/E0369Alex Burka-10/+2
2017-02-04note wording: lint implied by lint group, not lint group implies lintZack M. Davis-3/+3
2017-02-04note individual lint name set via lint group attribute in notesZack M. Davis-1/+7
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-02Auto merge of #39384 - wesleywiser:fix_fixmes, r=alexcrichtonbors-18/+16
Resolve a bunch of fixmes Resolves 56 fixmes in test code related to `box` syntax.
2017-02-02Auto merge of #39116 - mgattozzi:better-string-message, r=nrcbors-0/+51
Add clearer error message using `&str + &str` This is the first part of #39018. One of the common things for new users coming from more dynamic languages like JavaScript, Python or Ruby is to use `+` to concatenate strings. However, this doesn't work that way in Rust unless the first type is a `String`. This commit adds a check for this use case and outputs a new error as well as a suggestion to guide the user towards the desired behavior. It also adds a new test case to test the output of the error.
2017-01-31Removes FIXMEs related to #22405Wesley Wiser-18/+16
2017-01-30Merge ty::TyBox into ty::TyAdtVadim Petrochenkov-1/+1
2017-01-28Add clearer error message using `&str + &str`Michael Gattozzi-0/+51
This is the first part of #39018. One of the common things for new users coming from more dynamic languages like JavaScript, Python or Ruby is to use `+` to concatenate strings. However, this doesn't work that way in Rust unless the first type is a `String`. This commit adds a check for this use case and outputs a new error as well as a suggestion to guide the user towards the desired behavior. It also adds a new test case to test the output of the error.
2017-01-26Point to immutable arg/fields when trying to use as &mutEsteban Küber-15/+17
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-20Rollup merge of #39168 - estebank:multiline-candidate, r=petrochenkovAlex Crichton-1/+1
Use multiline Diagnostic for candidate in other module ``` error[E0574]: expected struct, variant or union type, found enum `Result` --> $DIR/issue-16058.rs:19:9 | 19 | Result { | ^^^^^^ not a struct, variant or union type | = help: possible better candidates are found in other modules, you can import them into scope: `use std::fmt::Result;` `use std::io::Result;` `use std::thread::Result;` error: aborting due to previous error ```
2017-01-20Auto merge of #38955 - estebank:highlighted-diags, r=nikomatsakisbors-7/+7
Teach Diagnostics to highlight text Support styled `Diagnostic` output: <img width="469" alt="mismatched types error with colorized types in the note" src="https://cloud.githubusercontent.com/assets/1606434/21871227/93a84198-d815-11e6-88b1-0ede3c7e28ef.png"> Closes #37532 and #38901. r? @nikomatsakis CC @jonathandturner @nagisa @nrc
2017-01-18Use multiline Diagnostic for candidate in other moduleEsteban Küber-1/+1
2017-01-18Auto merge of #38168 - estebank:help-E0034, r=nrcbors-0/+269
E0034: provide disambiguated syntax for candidates For a given file ```rust trait A { fn foo(&self) {} } trait B : A { fn foo(&self) {} } fn bar<T: B>(a: &T) { a.foo() } ``` provide the following output ``` error[E0034]: multiple applicable items in scope --> file.rs:6:5 | 6 | a.foo(1) | ^^^ multiple `foo` found | note: candidate #1 is defined in the trait `A` --> file.rs:2:11 | 2 | trait A { fn foo(&self, a: usize) {} } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to use it here write `A::foo(&a, 1)` instead --> file.rs:6:5 | 6 | a.foo(1) | ^^^ note: candidate #2 is defined in the trait `B` --> file.rs:3:15 | 3 | trait B : A { fn foo(&self, a: usize) {} } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to use it here write `B::foo(&a, 1)` instead --> file.rs:6:5 | 6 | a.foo(1) | ^^^ ``` Fix #37767.
2017-01-17Teach Diagnostics to highlight textEsteban Küber-7/+7
2017-01-16Auto merge of #38806 - comex:lint-attr-fix, r=nrcbors-12/+12
Fix lint attributes on non-item nodes. Currently, late lint checking uses two HIR visitors: LateContext and IdVisitor. IdVisitor only overrides visit_id, and for each node searches for builtin lints previously added to the session; LateContext overrides a number of methods, and runs late lints. When LateContext encounters an item, it first has IdVisitor walk everything in it except nested items (OnlyBodies), then recurses into it itself - i.e. there are two separate walks. Aside from apparently being unnecessary, this separation prevents lint attributes (allow/deny/warn) on non-item HIR nodes from working properly. Test case: ```rust // generates warning without this change fn main() { #[allow(unreachable_code)] loop { break; break; } } ``` LateContext contains logic to merge attributes seen into the current lint settings while walking (with_lint_attrs), but IdVisitor does not. So such attributes will affect late lints (because they are called from LateContext), and if the node contains any items within it, they will affect builtin lints within those items (because that IdVisitor is run while LateContext is within the attributed node), but otherwise the attributes will be ignored for builtin lints. This change simply removes IdVisitor and moves its visit_id into LateContext itself. Hopefully this doesn't break anything... Also added walk calls to visit_lifetime and visit_lifetime_def respectively, so visit_lifetime_def will recurse into the lifetime and visit_lifetime will recurse into the name. In principle this could confuse lint plugins. This is "necessary" because walk_lifetime calls visit_id on the lifetime; of course, an alternative would be directly calling visit_id (which would require manually iterating over the lifetimes in visit_lifetime_def), but that seems less clean.
2017-01-15Auto merge of #39040 - estebank:relevant-impl-multiline, r=nikomatsakisbors-4/+4
Use multiline Diagnostic for "relevant impl" list Provide the following output: ``` error[E0277]: the trait bound `Bar: Foo<usize>` is not satisfied --> $DIR/issue-21659-show-relevant-trait-impls-2.rs:38:8 | 38 | f1.foo(1usize); | ^^^ the trait `Foo<usize>` is not implemented for `Bar` | = help: the following implementations were found: <Bar as Foo<i8>> <Bar as Foo<i16>> <Bar as Foo<i32>> <Bar as Foo<u8>> and 2 others error: aborting due to previous error ``` instead of ``` error[E0277]: the trait bound `Bar: Foo<usize>` is not satisfied --> $DIR/issue-21659-show-relevant-trait-impls-2.rs:38:8 | 38 | f1.foo(1usize); | ^^^ the trait `Foo<usize>` is not implemented for `Bar` | = help: the following implementations were found: = help: <Bar as Foo<i8>> = help: <Bar as Foo<i16>> = help: <Bar as Foo<i32>> = help: <Bar as Foo<u8>> = help: and 2 others error: aborting due to previous error ```
2017-01-14Merge branch 'master' into lint-attr-fixcomex-9/+113
2017-01-13Use multiline Diagnostic for "relevant impl" listEsteban Küber-4/+4
Provide the following output: ``` error[E0277]: the trait bound `Bar: Foo<usize>` is not satisfied --> $DIR/issue-21659-show-relevant-trait-impls-2.rs:38:8 | 38 | f1.foo(1usize); | ^^^ the trait `Foo<usize>` is not implemented for `Bar` | = help: the following implementations were found: <Bar as Foo<i8>> <Bar as Foo<i16>> <Bar as Foo<i32>> <Bar as Foo<u8>> and 2 others error: aborting due to previous error ``` instead of ``` error[E0277]: the trait bound `Bar: Foo<usize>` is not satisfied --> $DIR/issue-21659-show-relevant-trait-impls-2.rs:38:8 | 38 | f1.foo(1usize); | ^^^ the trait `Foo<usize>` is not implemented for `Bar` | = help: the following implementations were found: = help: <Bar as Foo<i8>> = help: <Bar as Foo<i16>> = help: <Bar as Foo<i32>> = help: <Bar as Foo<u8>> = help: and 2 others error: aborting due to previous error ```
2017-01-12E0034: provide disambiguated syntax for candidatesEsteban Küber-0/+269
For a given file ```rust trait A { fn foo(&self) {} } trait B : A { fn foo(&self) {} } fn bar<T: B>(a: &T) { a.foo() } ``` provide the following output ``` error[E0034]: multiple applicable items in scope --> file.rs:6:5 | 6 | a.foo(1) | ^^^ multiple `foo` found | note: candidate #1 is defined in the trait `A` --> file.rs:2:11 | 2 | trait A { fn foo(&self, a: usize) {} } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to use it here write `A::foo(&a, 1)` instead --> file.rs:6:5 | 6 | a.foo(1) | ^^^ note: candidate #2 is defined in the trait `B` --> file.rs:3:15 | 3 | trait B : A { fn foo(&self, a: usize) {} } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to use it here write `B::foo(&a, 1)` instead --> file.rs:6:5 | 6 | a.foo(1) | ^^^ ```
2017-01-12resolve: Do not use "resolve"/"resolution" in error messagesVadim Petrochenkov-3/+3
2017-01-11Auto merge of #38916 - estebank:pad-suggestion-list, r=nikomatsakisbors-6/+6
Teach diagnostics to correct margin of multiline messages Make the suggestion list have a correct padding: ``` error[E0308]: mismatched types --> file.rs:3:20 | 3 | let x: usize = ""; | ^^ expected usize, found reference | = note: expected type `usize` = note: found type `&'static str` = help: here are some functions which might fulfill your needs: - .len() - .foo() - .bar() ```
2017-01-10Rollup merge of #38606 - estebank:test-for-27522, r=petrochenkovSeo Sanghyeon-0/+30
Add test for correct span for type Adds test for and closes #27522.
2017-01-07Teach diagnostics to have correctly padded listsEsteban Küber-6/+6
Make the suggestion list have a correct padding: ``` error[E0308]: mismatched types --> file.rs:3:20 | 3 | let x: usize = ""; | ^^ expected usize, found reference | = note: expected type `usize` = note: found type `&'static str` = help: here are some functions which might fulfill your needs: - .len() - .foo() - .bar() ```
2017-01-06Fix test/ui/span/issue-24690.stderrcomex-12/+12
The errors are now emitted in a different order (in order of source location rather than going back and forth) but otherwise everything's the same.
2017-01-04Add test for correct span for typeEsteban Küber-0/+30
Test for #27522.
2017-01-04typeck::coherence::builtin - sort impls in the DefId orderAriel Ben-Yehuda-21/+21
this makes error messages consistent across architectures
2017-01-04simplify Copy implementation error reportingAriel Ben-Yehuda-0/+74
Span the affected fields instead of reporting the field/variant name.
2016-12-28rustc: separate TraitItem from their parent Item, just like ImplItem.Eduard-Mihai Burtescu-8/+8
2016-12-26More systematic error reporting in path resolutionVadim Petrochenkov-7/+14
2016-12-20Update ui test stderrGuillaume Gomez-2/+5
2016-12-20improve suggestions output and add ui testGuillaume Gomez-0/+99
2016-12-06Auto merge of #38121 - jonathandturner:better_e0061, r=nikomatsakisbors-6/+2
Point arg num mismatch errors back to their definition This PR updates the arg num errors (like E0061) to point back at the function definition where they were defined. Before: ``` error[E0061]: this function takes 2 parameters but 1 parameter was supplied --> E0061.rs:18:7 | 18 | f(0); | ^ | = note: the following parameter types were expected: = note: u16, &str ``` Now: ``` error[E0061]: this function takes 2 parameters but 1 parameter was supplied --> E0061.rs:18:7 | 11 | fn f(a: u16, b: &str) {} | ------------------------ defined here ... 18 | f(0); | ^ expected 2 parameters ``` This is an incremental improvement. We probably want to underline only the function name and also have support for functions defined in crates outside of the current crate. r? @nikomatsakis
2016-12-03Rollup merge of #38065 - estebank:fix-37618, r=jonathandturnerCorey Farwell-3/+3
Show `Trait` instead of `<Struct as Trait>` in E0323 For a given file ``` trait Foo { fn bar(&self); } pub struct FooConstForMethod; impl Foo for FooConstForMethod { const bar: u64 = 1; } ``` show ``` error[E0323]: item `bar` is an associated const, which doesn't match its trait `Foo` ``` instead of ``` error[E0323]: item `bar` is an associated const, which doesn't match its trait `<FooConstForMethod as Foo>` ``` Fix #37618
2016-12-01Point arg num mismatch errors back to their definitionJonathan Turner-6/+2
2016-11-29Auto merge of #37863 - mikhail-m1:mut_error, r=nikomatsakisbors-0/+640
add hint to fix error for immutable ref in arg fix #36412 part of #35233 r? @jonathandturner
2016-11-29Auto merge of #37369 - estebank:multiline-span, r=nikomatsakisbors-18/+107
Show multiline spans in full if short enough When dealing with multiline spans that span few lines, show the complete span instead of restricting to the first character of the first line. For example, instead of: ``` % ./rustc file2.rs error[E0277]: the trait bound `{integer}: std::ops::Add<()>` is not satisfied --> file2.rs:13:9 | 13 | foo(1 + bar(x, | ^ trait `{integer}: std::ops::Add<()>` not satisfied | ``` show ``` % ./rustc file2.rs error[E0277]: the trait bound `{integer}: std::ops::Add<()>` is not satisfied --> file2.rs:13:9 | 13 | foo(1 + bar(x, | ________^ starting here... 14 | | y), | |_____________^ ...ending here: trait `{integer}: std::ops::Add<()>` not satisfied | ``` The [proposal in internals](https://internals.rust-lang.org/t/proposal-for-multiline-span-comments/4242/6) outlines the reasoning behind this.
2016-11-28Show `Trait` instead of `<Struct as Trait>` in E0323Esteban Küber-3/+3
For a given file ``` trait Foo { fn bar(&self); } pub struct FooConstForMethod; impl Foo for FooConstForMethod { const bar: u64 = 1; } ``` show ``` error[E0323]: item `bar` is an associated const, which doesn't match its trait `Foo` ``` instead of ``` error[E0323]: item `bar` is an associated const, which doesn't match its trait `<FooConstForMethod as Foo>` ```
2016-11-29add hint to fix error for immutable ref in argMikhail Modin-0/+640
2016-11-28rustc: rework stability to be on-demand for type-directed lookup.Eduard Burtescu-1/+1
2016-11-23review commentsEsteban Küber-5/+4
2016-11-22Show multiline spans in full if short enoughEsteban Küber-18/+108
When dealing with multiline spans that span few lines, show the complete span instead of restricting to the first character of the first line. For example, instead of: ``` % ./rustc foo.rs error[E0277]: the trait bound `{integer}: std::ops::Add<()>` is not satisfied --> foo.rs:13:9 | 13 | foo(1 + bar(x, | ^ trait `{integer}: std::ops::Add<()>` not satisfied | ``` show ``` % ./rustc foo.rs error[E0277]: the trait bound `{integer}: std::ops::Add<()>` is not satisfied --> foo.rs:13:9 | 13 | foo(1 + bar(x, | ________^ starting here... 14 | | y), | |_____________^ ...ending here: trait `{integer}: std::ops::Add<()>` not satisfied | ```
2016-11-12Auto merge of #37554 - mikhail-m1:dnlle, r=jonathandturnerbors-6/+108
Improve "Doesn't live long enough" error case with temporary variable issue #36279 part of #35233 r? @jonathandturner