about summary refs log tree commit diff
path: root/src/test/ui/span
AgeCommit message (Collapse)AuthorLines
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
2016-11-11Auto merge of #37456 - estebank:unused-imports-verbosity, r=jonathandturnerbors-0/+21
Group unused import warnings per import list 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 --> file2.rs:1:24 | 1 | use std::collections::{BinaryHeap, BTreeMap, BTreeSet}; | ^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ``` Include support for lints pointing at `MultilineSpan`s, instead of just `Span`s. Fixes #16132.
2016-11-09Rollup merge of #37428 - estebank:generic-type-error-span, r=sanxiynEduard-Mihai Burtescu-0/+33
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-0/+315
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-08Group unused import warnings per path listEsteban Küber-0/+21
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-0/+33
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-6/+108
case with temporary variable
2016-11-05Include type of missing trait methods in errorEsteban Küber-0/+315
Provide either a span pointing to the original definition of missing trait items, or a message with the inferred definitions.
2016-11-01Improve "Doesn't live long enough" errorMikhail Modin-6/+690
case with different lifetime with spans
2016-10-31Auto merge of #37191 - zackmdavis:we_heard_you_the_first_time_really, ↵bors-0/+54
r=nikomatsakis introing one-time diagnostics: only emit "lint level defined here" once This is a revised resubmission of PR #34084 (which was closed due to inactivity on account of time constraints on the author's part). --- We introduce a new `one_time_diagnostics` field on `rustc::session::Session` to hold a hashset of diagnostic messages we've set once but don't want to see again (as uniquified by span and message text), "lint level defined here" being the motivating example dealt with here. This is in the matter of #24690. --- r? @nikomatsakis
2016-10-26deduplicate one-time diagnostics on lint ID as well as span and messageZack M. Davis-0/+54
Some lint-level attributes (like `bad-style`, or, more dramatically, `warnings`) can affect more than one lint; it seems fairer to point out the attribute once for each distinct lint affected. Also, a UI test is added. This remains in the matter of #24690.
2016-10-20improve "Doesn't live long enough" errorMikhail Modin-0/+1782
2016-10-06Better underline for E0057,E0060,E0061Andrea Corradi-0/+34
2016-09-30Update E0220 error formatJesus Garlea-1/+1
squash! Update E0220 error format Update Error E0220 to new format
2016-09-26Update E0425, E0446, E0449Jonathan Turner-0/+33
2016-09-16fix top level attr spansMikhail Modin-0/+32
2016-09-12Auto merge of #36354 - mikhail-m1:master, r=jonathandturnerbors-0/+66
fix span for errors E0537, E0535 & E0536 fix #36182 as part of #35233
2016-09-10fix span for errors E0537, E0535 & E0536Mikhail Modin-0/+66
2016-09-04Rollup merge of #36212 - razielgn:updated-e0493-to-new-format, r=jonathandturnerManish Goregaokar-0/+41
Updated e0493 to new format (+ bonus). Part of #35233. Fixes #35999. r? @jonathandturner I'm not satisfied with the bonus part, there has to be an easier way to reach into the `Drop`'s span implementation. I'm all ears. :)
2016-09-02Moved test on E0493 from compile-fail to ui.Federico Ravasio-0/+41
2016-08-31Update error message for lifetime of borrowed valuesJonathan Turner-2/+2
2016-08-18Auto merge of #35732 - jonathandturner:region_error_labels, r=nikomatsakisbors-0/+37
Move 'doesn't live long enough' errors to labels This patch moves the "doesn't live long enough" region-style errors to instead use labels. An example follows. Before: ``` error: `x` does not live long enough --> src/test/compile-fail/send-is-not-static-ensures-scoping.rs:26:18 | 26 | let y = &x; | ^ | note: reference must be valid for the block at 23:10... --> src/test/compile-fail/send-is-not-static-ensures-scoping.rs:23:11 | 23 | fn main() { | ^ note: ...but borrowed value is only valid for the block suffix following statement 0 at 25:18 --> src/test/compile-fail/send-is-not-static-ensures-scoping.rs:25:19 | 25 | let x = 1; | ^ ``` After: ``` error: `x` does not live long enough --> src/test/compile-fail/send-is-not-static-ensures-scoping.rs:26:18 | 26 | let y = &x; | ^ does not live long enough ... 32 | }; | - borrowed value only valid until here ... 35 | } | - borrowed value must be valid until here ``` r? @nikomatsakis
2016-08-17Move 'doesn't live long enough' errors to labelsJonathan Turner-0/+37