about summary refs log tree commit diff
path: root/src/test/ui/issues
AgeCommit message (Collapse)AuthorLines
2020-05-25Display information about captured variable in `FnMut` errorAaron Hill-1/+14
Fixes #69446 When we encounter a region error involving an `FnMut` closure, we display a specialized error message. However, we currently do not tell the user which upvar was captured. This makes it difficult to determine the cause of the error, especially when the closure is large. This commit records marks constraints involving closure upvars with `ConstraintCategory::ClosureUpvar`. When we decide to 'blame' a `ConstraintCategory::Return`, we additionall store the captured upvar if we found a `ConstraintCategory::ClosureUpvar` in the path. When generating an error message, we point to relevant spans if we have closure upvar information available. We further customize the message if an `async` closure is being returned, to make it clear that the captured variable is being returned indirectly.
2020-05-25Auto merge of #72354 - tamird:remove-copyright, r=Mark-Simulacrumbors-2/+0
Remove dangling COPYRIGHT references Missed in 2a663555ddf36f6b041445894a8c175cd1bc718c. r? @Mark-Simulacrum
2020-05-25remove some unused types from the testsRalf Jung-18/+4
2020-05-25Add test for old compiler ICE when using `Borrow`Ross MacArthur-0/+57
2020-05-23Add test for #72455Yuki Okushi-0/+27
2020-05-21Rollup merge of #72149 - estebank:icemation, r=eddybRalf Jung-0/+20
Don't `type_of` on trait assoc ty without default Fix #72076.
2020-05-20refactor check_for_castBastian Kauschke-0/+10
2020-05-20fix is_const_contextBastian Kauschke-15/+0
2020-05-19Alter wording for `use foo::self` helpmibac138-2/+2
2020-05-19Add error recovery for `use foo::self`mibac138-2/+17
2020-05-19Suggest fixes for `use foo::self`mibac138-2/+11
2020-05-19Remove dangling COPYRIGHT referencesTamir Duberstein-2/+0
Missed in 2a663555ddf36f6b041445894a8c175cd1bc718c.
2020-05-19Rollup merge of #72068 - estebank:mut-deref-hack, r=oli-obkDylan DPC-0/+29
Ignore arguments when looking for `IndexMut` for subsequent `mut` obligation Given code like `v[&field].boo();` where `field: String` and `.boo(&mut self)`, typeck will have decided that `v` is accessed using `Index`, but when `boo` adds a new `mut` obligation, `convert_place_op_to_mutable` is called. When this happens, for *some reason* the arguments' dereference adjustments are completely ignored causing an error saying that `IndexMut` is not satisfied: ``` error[E0596]: cannot borrow data in an index of `Indexable` as mutable --> src/main.rs:30:5 | 30 | v[&field].boo(); | ^^^^^^^^^ cannot borrow as mutable | = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `Indexable` ``` This is not true, but by changing `try_overloaded_place_op` to retry when given `Needs::MutPlace` without passing the argument types, the example successfully compiles. I believe there might be more appropriate ways to deal with this. Fix #72002.
2020-05-18Rollup merge of #71599 - ldm0:fnclo, r=nikomatsakisDylan DPC-18/+7
Support coercion between (FnDef | Closure) and (FnDef | Closure) Fixes #46742, fixes #48109 Inject `Closure` into the `FnDef x FnDef` coercion special case, which makes coercion of `(FnDef | Closure) x (FnDef | Closure)` possible, where closures should be **non-capturing**.
2020-05-16Rollup merge of #72045 - RalfJung:incomplete-unsound, r=petrochenkovRalf Jung-2/+3
Incomplete features can also be unsound Some incomplete features do not just ICE, they are also currently unsound (e.g. https://github.com/rust-lang/rust/pull/72029, and also `specialization` -- which is not yet marked incomplete but [should be](https://github.com/rust-lang/rust/pull/71420)). This makes the message reflect that. While at it I also added a link to the tracking issue, which hopefully should explain what is incomplete/unsound about the feature.
2020-05-14Don't ICE on missing `Unsize` implNathan Corbyn-0/+29
2020-05-12fix test output after rebaseEsteban Küber-1/+1
2020-05-12Increase verbosity of bound restriction suggestionsEsteban Küber-8/+14
- Make the bound restriction suggestion `span_suggestion_verbose`. - Fix whitespace typo.
2020-05-12Don't `type_of` on trait assoc ty without defaultEsteban Küber-0/+20
Fix #72076.
2020-05-11Ignore arguments when looking for `IndexMut` for subsequent `mut` obligationEsteban Küber-0/+29
Given code like `v[&field].boo();` where `field: String` and `.boo(&mut self)`, typeck will have decided that `v` is accessed using `Index`, but when `boo` adds a new `mut` obligation, `convert_place_op_to_mutable` is called. When this happens, for *some reason* the arguments' dereference adjustments are completely ignored causing an error saying that `IndexMut` is not satisfied: ``` error[E0596]: cannot borrow data in an index of `Indexable` as mutable --> src/main.rs:30:5 | 30 | v[&field].boo(); | ^^^^^^^^^ cannot borrow as mutable | = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `Indexable` ``` This is not true, but by changing `try_overloaded_place_op` to retry when given `Needs::MutPlace` without passing the argument types, the example successfully compiles. I believe there might be more appropriate ways to deal with this.
2020-05-09adjust testsRalf Jung-2/+3
2020-05-09Rollup merge of #71185 - JohnTitor:run-fail, r=petrochenkovRalf Jung-0/+305
Move tests from `test/run-fail` to UI Fixes #65440 cc #65865 #65506 r? @nikomatsakis
2020-05-09Test for coercion between (FnDef | Closure) and (FnDef | Closure)Donough Liu-18/+7
2020-05-07Rollup merge of #71960 - estebank:fix-E0284, r=davidtwcoDylan DPC-15/+60
Fix E0284 to not use incorrect wording Fix #71584, fix #69683.
2020-05-07Fix E0284 to not use incorrect wordingEsteban Küber-15/+60
Fix #71584, fix #69683.
2020-05-08Skip tests on emscriptenYuki Okushi-0/+21
2020-05-07reword "possible candidate" import suggestionAndy Russell-11/+11
2020-05-06Rollup merge of #70908 - estebank:suggest-add, r=nikomatsakisDylan DPC-5/+16
Provide suggestions for type parameters missing bounds for associated types When implementing the binary operator traits it is easy to forget to restrict the `Output` associated type. `rustc` now accounts for different cases to lead users in the right direction to add the necessary restrictions. The structured suggestions in the following output are new: ``` error: equality constraints are not yet supported in `where` clauses --> $DIR/missing-bounds.rs:37:33 | LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B { | ^^^^^^^^^^^^^^^^^^^^^^ not supported | = note: see issue #20041 <https://github.com/rust-lang/rust/issues/20041> for more information help: if `Output` is an associated type you're trying to set, use the associated type binding syntax | LL | impl<B: Add> Add for E<B> where B: Add<Output = B> { | ^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/missing-bounds.rs:11:11 | 7 | impl<B> Add for A<B> where B: Add { | - this type parameter ... 11 | A(self.0 + rhs.0) | ^^^^^^^^^^^^^^ expected type parameter `B`, found associated type | = note: expected type parameter `B` found associated type `<B as std::ops::Add>::Output` help: consider further restricting this bound | 7 | impl<B> Add for A<B> where B: Add + std::ops::Add<Output = B> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0369]: cannot add `B` to `B` --> $DIR/missing-bounds.rs:31:21 | 31 | Self(self.0 + rhs.0) | ------ ^ ----- B | | | B | help: consider restricting type parameter `B` | 27 | impl<B: std::ops::Add<Output = B>> Add for D<B> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` That output is given for the following cases: ```rust struct A<B>(B); impl<B> Add for A<B> where B: Add { type Output = Self; fn add(self, rhs: Self) -> Self { A(self.0 + rhs.0) //~ ERROR mismatched types } } struct D<B>(B); impl<B> Add for D<B> { type Output = Self; fn add(self, rhs: Self) -> Self { Self(self.0 + rhs.0) //~ ERROR cannot add `B` to `B` } } struct E<B>(B); impl<B: Add> Add for E<B> where <B as Add>::Output = B { type Output = Self; fn add(self, rhs: Self) -> Self { Self(self.0 + rhs.0) } } ```
2020-05-06Rollup merge of #71937 - mzohreva:mz/ui-tests-ignore-sgx, r=nikomatsakisDylan DPC-4/+7
Ignore SGX on a few ui tests cc @jethrogb
2020-05-06Rollup merge of #71727 - hbina:simplified_usage, r=Mark-SimulacrumDylan DPC-2/+2
SipHasher with keys initialized to 0 should just use new() I believe that is what the `new()` is for, for good reasons.
2020-05-06Move tests from `test/run-fail` to UIYuki Okushi-0/+284
2020-05-05Ignore SGX on a few ui testsMohsen Zohrevandi-4/+7
2020-05-05Rollup merge of #71894 - mibac138:semicolon-not-always-helpful, r=estebankDylan DPC-3/+0
Suggest removing semicolon in last expression only if it's type is known Fixes #67971 Is there a syntax for explicitly checking if a note doesn't exist in test output? Something like `//~ !NOTE ...` I believe r? @estebank deals with diagnostics.
2020-05-05Suggest removing semicolon in last expression only if it's type is knownmibac138-3/+0
2020-05-05Rollup merge of #71902 - mibac138:const-feature-diag, r=varkorDylan DPC-0/+2
Suggest to add missing feature when using gated const features Fixes #71797
2020-05-05Rollup merge of #71711 - Mark-Simulacrum:deignore-tests, r=nikomatsakisDylan DPC-13/+0
Updates to some ignored tests This removes or fixes some ignored test cases. cc #13745
2020-05-04Suggest to add missing feature when using gated const featuresmibac138-0/+2
2020-05-04review comments and rebase fixEsteban Küber-3/+9
2020-05-04Suggest restricting type param when it doesn't satisfy projectionEsteban Küber-1/+3
When encountering a projection that isn't satisfied by a type parameter, suggest constraining the type parameter.
2020-05-04Handle binop on unbound type paramEsteban Küber-1/+4
When encountering a binary operation involving a type parameter that has no bindings, suggest adding the appropriate bound.
2020-05-04Auto merge of #71108 - estebank:suggest-proj-type-mismatch-constraint, r=oli-obkbors-22/+4
On type mismatch involving associated type, suggest constraint When an associated type is found when a specific type was expected, if possible provide a structured suggestion constraining the associated type in a bound. ``` error[E0271]: type mismatch resolving `<T as Foo>::Y == i32` --> $DIR/associated-types-multiple-types-one-trait.rs:13:5 | LL | want_y(t); | ^^^^^^ expected `i32`, found associated type ... LL | fn want_y<T:Foo<Y=i32>>(t: &T) { } | ----- required by this bound in `want_y` | = note: expected type `i32` found associated type `<T as Foo>::Y` help: consider constraining the associated type `<T as Foo>::Y` to `i32` | LL | fn have_x_want_y<T:Foo<X=u32, Y = i32>>(t: &T) | ^^^^^^^^^ ``` ``` error[E0308]: mismatched types --> $DIR/trait-with-missing-associated-type-restriction.rs:12:9 | LL | qux(x.func()) | ^^^^^^^^ expected `usize`, found associated type | = note: expected type `usize` found associated type `<impl Trait as Trait>::A` help: consider constraining the associated type `<impl Trait as Trait>::A` to `usize` | LL | fn foo(x: impl Trait<A = usize>) { | ^^^^^^^^^^ ``` Fix #71035. Related to #70908.
2020-05-02When a projection is expected, suggest constraining or calling methodEsteban Küber-2/+4
2020-05-02On type mismatch involving associated type, suggest constraintEsteban Küber-20/+0
When an associated type is found when a specific type was expected, if possible provide a structured suggestion constraining the associated type in a bound. ``` error[E0271]: type mismatch resolving `<T as Foo>::Y == i32` --> $DIR/associated-types-multiple-types-one-trait.rs:13:5 | LL | want_y(t); | ^^^^^^ expected `i32`, found associated type ... LL | fn want_y<T:Foo<Y=i32>>(t: &T) { } | ----- required by this bound in `want_y` | = note: expected type `i32` found associated type `<T as Foo>::Y` help: consider constraining the associated type `<T as Foo>::Y` to `i32` | LL | fn have_x_want_y<T:Foo<X=u32, Y = i32>>(t: &T) | ^^^^^^^^^ ``` ``` error[E0308]: mismatched types --> $DIR/trait-with-missing-associated-type-restriction.rs:12:9 | LL | qux(x.func()) | ^^^^^^^^ expected `usize`, found associated type | = note: expected type `usize` found associated type `<impl Trait as Trait>::A` help: consider constraining the associated type `<impl Trait as Trait>::A` to `usize` | LL | fn foo(x: impl Trait<A = usize>) { | ^^^^^^^^^^ ```
2020-05-02Replace convenient function `remove_prefix()` with `replace_prefix()`Donough Liu-2/+0
2020-05-02Suggestion for immutable reference -> mutable pointer should be emittedDonough Liu-2/+1
as `Applicability::Unspecified`
2020-05-02Suggest deref when coercing `ty::Ref` to `ty::RawPtr` with arbitraryDonough Liu-2/+224
mutability
2020-05-01SipHasher::new() is literally with SipHasher with both keys being 0Hanif Bin Ariffin-2/+2
2020-04-30Remove unsized enum testMark Rousskov-13/+0
This was already tested (at least) by src/test/ui/unsized/unsized-enum2.rs
2020-04-30Rollup merge of #71540 - ldm0:ref2ptr, r=oli-obkDylan DPC-0/+122
Suggest deref when coercing `ty::Ref` to `ty::RawPtr` Fixes #32122 Currently we do autoderef when casting `ty::Ref` ->`ty::Ref`, but we don't autoderef when casting `ty::Ref` -> `ty::RawPtr`. This PR make the compiler suggests deref when coercing `ty::Ref` to `ty::RawPtr`
2020-04-30Rollup merge of #71205 - NeoRaider:check_attr, r=jonas-schievinkDylan DPC-4/+13
rustc: fix check_attr() for methods, closures and foreign functions This fixes an issue that previously turned up for methods in https://github.com/rust-lang/rust/pull/69274, but also exists for closures and foreign function: `check_attr` does not call `codegen_fn_attrs()` for these types when it should, meaning that incorrectly used function attributes are not diagnosed without codegen. The issue affects our UI tests, as they run with `--emit=metadata` by default, but as it turns out, this is not the only case: Function attributes are not checked on any dead code without this fix! This makes the fix a **breaking change**. The following very silly Rust programs compiles fine on stable Rust when it should not, which is fixed by this PR. ```rust fn main() { #[target_feature(enable = "sse2")] || {}; } ``` I assume any real-world program which may trigger this issue would at least emit a dead code warning, but of course that is no guarantee that such code does not exist... Fixes #70307