forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#65192 - estebank:restrict-bound, r=matthewj…
…asper Use structured suggestion for restricting bounds When a trait bound is not met and restricting a type parameter would make the restriction hold, use a structured suggestion pointing at an appropriate place (type param in param list or `where` clause). Account for opaque parameters where instead of suggesting extending the `where` clause, we suggest appending the new restriction: `fn foo(impl Trait + UnmetTrait)`. Fix rust-lang#64565, fix rust-lang#41817, fix rust-lang#24354, cc rust-lang#26026, cc rust-lang#37808, cc rust-lang#24159, fix rust-lang#37138, fix rust-lang#24354, cc rust-lang#20671.
- Loading branch information
Showing
102 changed files
with
847 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/test/ui/associated-types/associated-types-bound-failure.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// run-rustfix | ||
// Test equality constraints on associated types in a where clause. | ||
#![allow(dead_code)] | ||
|
||
pub trait ToInt { | ||
fn to_int(&self) -> isize; | ||
} | ||
|
||
pub trait GetToInt | ||
{ | ||
type R; | ||
|
||
fn get(&self) -> <Self as GetToInt>::R; | ||
} | ||
|
||
fn foo<G>(g: G) -> isize | ||
where G : GetToInt, <G as GetToInt>::R: ToInt | ||
{ | ||
ToInt::to_int(&g.get()) //~ ERROR E0277 | ||
} | ||
|
||
fn bar<G : GetToInt>(g: G) -> isize | ||
where G::R : ToInt | ||
{ | ||
ToInt::to_int(&g.get()) // OK | ||
} | ||
|
||
pub fn main() { | ||
} |
2 changes: 2 additions & 0 deletions
2
src/test/ui/associated-types/associated-types-bound-failure.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
src/test/ui/associated-types/associated-types-bound-failure.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/test/ui/associated-types/associated-types-for-unimpl-trait.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// run-rustfix | ||
#![allow(unused_variables)] | ||
|
||
trait Get { | ||
type Value; | ||
fn get(&self) -> <Self as Get>::Value; | ||
} | ||
|
||
trait Other { | ||
fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get {} | ||
//~^ ERROR the trait bound `Self: Get` is not satisfied | ||
} | ||
|
||
fn main() { | ||
} |
3 changes: 3 additions & 0 deletions
3
src/test/ui/associated-types/associated-types-for-unimpl-trait.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// run-rustfix | ||
#![allow(unused_variables)] | ||
|
||
trait Get { | ||
type Value; | ||
fn get(&self) -> <Self as Get>::Value; | ||
|
9 changes: 5 additions & 4 deletions
9
src/test/ui/associated-types/associated-types-for-unimpl-trait.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.