-
Notifications
You must be signed in to change notification settings - Fork 13k
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 #57792 - Centril:rollup, r=Centril
Rollup of 5 pull requests Successful merges: - #56796 (Change bounds on `TryFrom` blanket impl to use `Into` instead of `From`) - #57768 (Continue parsing after parent type args and suggest using angle brackets) - #57769 (Suggest correct cast for struct fields with shorthand syntax) - #57783 (Add "dereference boxed value" suggestion.) - #57784 (Add span for bad doc comment) Failed merges: r? @ghost
- Loading branch information
Showing
36 changed files
with
484 additions
and
88 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
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,37 @@ | ||
// This test relies on `TryFrom` being blanket impl for all `T: Into` | ||
// and `TryInto` being blanket impl for all `U: TryFrom` | ||
|
||
// This test was added to show the motivation for doing this | ||
// over `TryFrom` being blanket impl for all `T: From` | ||
|
||
#![feature(try_from, never_type)] | ||
|
||
use std::convert::TryInto; | ||
|
||
struct Foo<T> { | ||
t: T, | ||
} | ||
|
||
// This fails to compile due to coherence restrictions | ||
// as of Rust version 1.32.x, therefore it could not be used | ||
// instead of the `Into` version of the impl, and serves as | ||
// motivation for a blanket impl for all `T: Into`, instead | ||
// of a blanket impl for all `T: From` | ||
/* | ||
impl<T> From<Foo<T>> for Box<T> { | ||
fn from(foo: Foo<T>) -> Box<T> { | ||
Box::new(foo.t) | ||
} | ||
} | ||
*/ | ||
|
||
impl<T> Into<Vec<T>> for Foo<T> { | ||
fn into(self) -> Vec<T> { | ||
vec![self.t] | ||
} | ||
} | ||
|
||
pub fn main() { | ||
let _: Result<Vec<i32>, !> = Foo { t: 10 }.try_into(); | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
fn main() { | ||
let v: Vec(&str) = vec!['1', '2']; | ||
//~^ ERROR parenthesized parameters may only be used with a trait | ||
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait | ||
//~| ERROR mismatched types | ||
} |
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,9 +1,22 @@ | ||
error[E0214]: parenthesized parameters may only be used with a trait | ||
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait | ||
--> $DIR/issue-23589.rs:2:15 | ||
| | ||
LL | let v: Vec(&str) = vec!['1', '2']; | ||
| ^^^^^^ only traits may use parentheses | ||
| ^^^^^^ | ||
| | | ||
| only `Fn` traits may use parentheses | ||
| help: use angle brackets instead: `<&str>` | ||
|
||
error: aborting due to previous error | ||
error[E0308]: mismatched types | ||
--> $DIR/issue-23589.rs:2:29 | ||
| | ||
LL | let v: Vec(&str) = vec!['1', '2']; | ||
| ^^^ expected &str, found char | ||
| | ||
= note: expected type `&str` | ||
found type `char` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0214`. | ||
Some errors occurred: E0214, E0308. | ||
For more information about an error, try `rustc --explain E0214`. |
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
Oops, something went wrong.