summary refs log tree commit diff
path: root/src/test/ui
AgeCommit message (Collapse)AuthorLines
2016-12-30Disable field reorderingAustin Hicks-29/+32
2016-12-18Auto merge of #37429 - camlorn:univariant_layout_optimization, r=eddybbors-32/+29
struct field reordering and optimization This is work in progress. The goal is to divorce the order of fields in source code from the order of fields in the LLVM IR, then optimize structs (and tuples/enum variants)by always ordering fields from least to most aligned. It does not work yet. I intend to check compiler memory usage as a benchmark, and a crater run will probably be required. I don't know enough of the compiler to complete this work unaided. If you see places that still need updating, please mention them. The only one I know of currently is debuginfo, which I'm putting off intentionally until a bit later. r? @eddyb
2016-12-16Allow path fragments to be parsed as type parameter bounds in macro expansionKalita Alexey-0/+30
2016-12-14Fix -Z print-type-sizes and tests.Austin Hicks-32/+29
This was done by sorting the fields by increasing offset; as a consequence, the order of -Z print-type-sizes matches memory order not source order.
2016-12-12Auto merge of #38057 - KiChjang:display-formal-type-param, r=nikomatsakisbors-2/+27
Display better error messages for E0282 Fixes #36554.
2016-12-09Add UI test for missing type parameterKeith Yeung-0/+25
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-03Update error expectationsKeith Yeung-2/+2
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-12-02limit the length of types in monomorphizationAriel Ben-Yehuda-0/+43
This adds the new insta-stable `#![type_size_limit]` crate attribute to control the limit, and is obviously a [breaking-change] fixable by that.
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-36/+152
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-24Tests of `-Z print-type-sizes` functionality.Felix S. Klock II-0/+442
Note that the tests have been updated to initialize the local variables; originally it was enough just to declare them. Back when I started this, the `layout_cache` contained entries even just for types that had been declared but not initialized. Apparently things have changed in the interim so that if I want one of those layouts to be computed, I need to actually initialize the value. (Incidentally, this shows a weakness in the strategy of just walking the `layout_cache`; the original strategy of using a MIR visitor would probably have exhibited more robustness in terms of consistent output, but it had other weaknesses so I chose not to reimplement it. At least, not yet.) ---- Also, I have updated tests to avoid target-specific alignments.
2016-11-23review commentsEsteban Küber-8/+7
2016-11-22Show multiline spans in full if short enoughEsteban Küber-36/+153
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-14Auto merge of #37771 - alexcrichton:fix-nightlies, r=brsonbors-0/+52
test: Move missing-items to a ui test This test is failing on nightly for unknown reasons, and my best guess is a difference in grep versions which is interpreting symbols differently. For now let's just move this to a ui test and hope it fixes nightlies.
2016-11-14test: Move missing-items to a ui testAlex Crichton-0/+52
This test is failing on nightly for unknown reasons, and my best guess is a difference in grep versions which is interpreting symbols differently. For now let's just move this to a ui test and hope it fixes nightlies.
2016-11-12Auto merge of #37531 - estebank:fix-ref-mut-mut, r=jonathandturnerbors-0/+142
Fix invalid "ref mut mut" sugestion Change output from: ```nocode error: cannot borrow immutable local variable `x` as mutable --> <anon>:12:23 | 11 | TestEnum::Item(ref mut x) => { | --------- use `ref mut mut x` here to make mutable 12 | test(&mut x); | ^ cannot borrow mutably ``` to ```nocode error: cannot borrow immutable local variable `x` as mutable --> <anon>:12:23 | 12 | test(&mut x); | ^ | | | cannot reborrow mutably | try removing `&mut` here ``` Fixes #37139, #34337, #34126
2016-11-12Auto merge of #37554 - mikhail-m1:dnlle, r=jonathandturnerbors-8/+110
Improve "Doesn't live long enough" error case with temporary variable issue #36279 part of #35233 r? @jonathandturner
2016-11-12Rollup merge of #37695 - estebank:unescaped-curly, r=alexcrichtonEduard-Mihai Burtescu-0/+36
On fmt string with unescaped `{` note how to escape On cases of malformed format strings where a `{` hasn't been properly escaped, like `println!("{");`, present a NOTE explaining how to escape the `{` char. Fix #34300.
2016-11-12Rollup merge of #37613 - DanielKeep:eww-you-got-printf-in-your-format, ↵Eduard-Mihai Burtescu-0/+72
r=alexcrichton Add foreign formatting directive detection. This teaches `format_args!` how to interpret format printf- and shell-style format directives. This is used in cases where there are unused formatting arguments, and the reason for that *might* be because the programmer is trying to use the wrong kind of formatting string. This was prompted by an issue encountered by simulacrum on the #rust IRC channel. In short: although `println!` told them that they weren't using all of the conversion arguments, the problem was in using printf-syle directives rather than ones `println!` would undertand. Where possible, `format_args!` will tell the programmer what they should use instead. For example, it will suggest replacing `%05d` with `{:0>5}`, or `%2$.*3$s` with `{1:.3$}`. Even if it cannot suggest a replacement, it will explicitly note that Rust does not support that style of directive, and direct the user to the `std::fmt` documentation. ----- **Example**: given: ```rust fn main() { println!("%.*3$s %s!\n", "Hello,", "World", 4); println!("%1$*2$.*3$f", 123.456); } ``` The compiler outputs the following: ```text error: multiple unused formatting arguments --> local/fmt.rs:2:5 | 2 | println!("%.*3$s %s!\n", "Hello,", "World", 4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: argument never used --> local/fmt.rs:2:30 | 2 | println!("%.*3$s %s!\n", "Hello,", "World", 4); | ^^^^^^^^ note: argument never used --> local/fmt.rs:2:40 | 2 | println!("%.*3$s %s!\n", "Hello,", "World", 4); | ^^^^^^^ note: argument never used --> local/fmt.rs:2:49 | 2 | println!("%.*3$s %s!\n", "Hello,", "World", 4); | ^ = help: `%.*3$s` should be written as `{:.2$}` = help: `%s` should be written as `{}` = note: printf formatting not supported; see the documentation for `std::fmt` = note: this error originates in a macro outside of the current crate error: argument never used --> local/fmt.rs:6:29 | 6 | println!("%1$*2$.*3$f", 123.456); | ^^^^^^^ | = help: `%1$*2$.*3$f` should be written as `{0:1$.2$}` = note: printf formatting not supported; see the documentation for `std::fmt` ```
2016-11-12Rollup merge of #37481 - estebank:lifetime-help-removal-for-impl, r=eddybEduard-Mihai Burtescu-0/+50
Don't provide hint to add lifetime on impl items ``` rust use std::str::FromStr; pub struct Foo<'a> { field: &'a str, } impl<'a> FromStr for Foo<'a> { type Err = (); fn from_str(path: &str) -> Result<Self, ()> { Ok(Foo { field: path }) } } ``` would give the following hint: ``` nocode help: consider using an explicit lifetime parameter as shown: fn from_str(path: &'a str) -> Result<Self, ()> --> <anon>:9:5 | 9 | fn from_str(path: &str) -> Result<Self, ()> { | ^ ``` which is never correct, since then there will be a lifetime mismatch between the `impl` and the trait. Remove this hint for all `impl` items. Re: #37363.
2016-11-11On fmt string with unescaped `{` note how to escapeEsteban Küber-0/+36
On cases of malformed format strings where a `{` hasn't been properly escaped, like `println!("{");`, present a note explaining how to escape the `{` char.
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-11Add foreign formatting directive detection.Daniel Keep-0/+72
This teaches `format_args!` how to interpret format printf- and shell-style format directives. This is used in cases where there are unused formatting arguments, and the reason for that *might* be because the programmer is trying to use the wrong kind of formatting string. This was prompted by an issue encountered by simulacrum on the #rust IRC channel. In short: although `println!` told them that they weren't using all of the conversion arguments, the problem was in using printf-syle directives rather than ones `println!` would undertand. Where possible, `format_args!` will tell the programmer what they should use instead. For example, it will suggest replacing `%05d` with `{:0>5}`, or `%2$.*3$s` with `{1:.3$}`. Even if it cannot suggest a replacement, it will explicitly note that Rust does not support that style of directive, and direct the user to the `std::fmt` documentation.
2016-11-10Don't hint to add lifetime on trait implEsteban Küber-0/+50
Don't provide hint to add lifetime on impl items that implement a trait. ```rust use std::str::FromStr; pub struct Foo<'a> { field: &'a str, } impl<'a> FromStr for Foo<'a> { type Err = (); fn from_str(path: &str) -> Result<Self, ()> { Ok(Foo { field: path }) } } ``` would give the following hint: ```nocode help: consider using an explicit lifetime parameter as shown: fn from_str(path: &'a str) -> Result<Self, ()> --> <anon>:9:5 | 9 | fn from_str(path: &str) -> Result<Self, ()> { | ^ ``` which is never correct, since then there will be a lifetime mismatch between the impl and the trait. Remove this hint for impl items that implement a trait.
2016-11-09Rollup merge of #37428 - estebank:generic-type-error-span, r=sanxiynEduard-Mihai Burtescu-1/+34
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-1/+34
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-8/+110
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-04Auto merge of #37167 - nikomatsakis:jroesch-issue-18937, r=pnkfelixbors-2/+440
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-0/+142
2016-11-01move compile-fail tests to ui testsNiko Matsakis-7/+313
gets more comprehensive coverage in `ui`
2016-11-01update ref fileNiko Matsakis-8/+0
2016-11-01compare-method lintNiko Matsakis-9/+36
2016-11-01cleanup error reporting and add `ui` testsNiko Matsakis-2/+115
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-26un-break the `construct_witness` logicAriel Ben-Yehuda-0/+103
Fixes #35609.
2016-10-20improve "Doesn't live long enough" errorMikhail Modin-36/+1818
2016-10-17Moved new dropck-eyepatch compile-fail tests to the `ui/` subtree.Felix S. Klock II-0/+470
2016-10-06Better underline for E0057,E0060,E0061Andrea Corradi-0/+34
2016-10-04Rollup merge of #36798 - gavinb:fix/36164, r=GuillaumeGomezManish Goregaokar-6/+58
Improve error message and snippet for "did you mean `x`" - Fixes #36164 - Part of #35233 Based on the standalone example https://is.gd/8STXMd posted by @nikomatsakis and using the third formatting option mentioned in #36164 and agreed by @jonathandturner. Note however this does not address the question of [how to handle an empty or unknown suggestion](https://github.com/rust-lang/rust/issues/36164#issuecomment-244460024). @nikomatsakis any suggestions on how best to address that part?