forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#114802 - chenyukang:yukang-fix-114979-bad-par…
…ens-dyn, r=estebank Fix bad suggestion when wrong parentheses around a dyn trait Fixes rust-lang#114797
- Loading branch information
Showing
8 changed files
with
105 additions
and
28 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
17 changes: 17 additions & 0 deletions
17
tests/ui/suggestions/issue-114797-bad-parentheses-dyn-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,17 @@ | ||
//run-rustfix | ||
#![allow(dead_code)] | ||
|
||
trait Trait {} | ||
|
||
fn assert_send(ptr: *mut dyn Trait) -> *mut (dyn Trait + Send) { | ||
//~^ ERROR incorrect parentheses around trait bounds | ||
ptr as _ | ||
} | ||
|
||
fn foo2(_: &(dyn Trait + Send)) {} | ||
//~^ ERROR incorrect parentheses around trait bounds | ||
|
||
fn foo3(_: &(dyn Trait + Send)) {} | ||
//~^ ERROR incorrect parentheses around trait bounds | ||
|
||
fn main() {} |
17 changes: 17 additions & 0 deletions
17
tests/ui/suggestions/issue-114797-bad-parentheses-dyn-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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//run-rustfix | ||
#![allow(dead_code)] | ||
|
||
trait Trait {} | ||
|
||
fn assert_send(ptr: *mut dyn Trait) -> *mut dyn (Trait + Send) { | ||
//~^ ERROR incorrect parentheses around trait bounds | ||
ptr as _ | ||
} | ||
|
||
fn foo2(_: &dyn (Trait + Send)) {} | ||
//~^ ERROR incorrect parentheses around trait bounds | ||
|
||
fn foo3(_: &dyn(Trait + Send)) {} | ||
//~^ ERROR incorrect parentheses around trait bounds | ||
|
||
fn main() {} |
38 changes: 38 additions & 0 deletions
38
tests/ui/suggestions/issue-114797-bad-parentheses-dyn-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
error: incorrect parentheses around trait bounds | ||
--> $DIR/issue-114797-bad-parentheses-dyn-trait.rs:6:49 | ||
| | ||
LL | fn assert_send(ptr: *mut dyn Trait) -> *mut dyn (Trait + Send) { | ||
| ^ ^ | ||
| | ||
help: fix the parentheses | ||
| | ||
LL - fn assert_send(ptr: *mut dyn Trait) -> *mut dyn (Trait + Send) { | ||
LL + fn assert_send(ptr: *mut dyn Trait) -> *mut (dyn Trait + Send) { | ||
| | ||
|
||
error: incorrect parentheses around trait bounds | ||
--> $DIR/issue-114797-bad-parentheses-dyn-trait.rs:11:17 | ||
| | ||
LL | fn foo2(_: &dyn (Trait + Send)) {} | ||
| ^ ^ | ||
| | ||
help: fix the parentheses | ||
| | ||
LL - fn foo2(_: &dyn (Trait + Send)) {} | ||
LL + fn foo2(_: &(dyn Trait + Send)) {} | ||
| | ||
|
||
error: incorrect parentheses around trait bounds | ||
--> $DIR/issue-114797-bad-parentheses-dyn-trait.rs:14:16 | ||
| | ||
LL | fn foo3(_: &dyn(Trait + Send)) {} | ||
| ^ ^ | ||
| | ||
help: fix the parentheses | ||
| | ||
LL - fn foo3(_: &dyn(Trait + Send)) {} | ||
LL + fn foo3(_: &(dyn Trait + Send)) {} | ||
| | ||
|
||
error: aborting due to 3 previous errors | ||
|