diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2024-12-31 14:12:49 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-31 14:12:49 +1100 |
| commit | 2491edab30e58ef37563b9edec50a74fd01bf787 (patch) | |
| tree | 3a22366505e47cc9b81272191e0189c6897024c1 /compiler/rustc_ast/src/ast.rs | |
| parent | 7da22aa6c31a74d491f15dd9d6421fb5334510e7 (diff) | |
| parent | aea2a6f8361c95d60cc8e2757ca473f6915902a9 (diff) | |
| download | rust-2491edab30e58ef37563b9edec50a74fd01bf787.tar.gz rust-2491edab30e58ef37563b9edec50a74fd01bf787.zip | |
Rollup merge of #134949 - compiler-errors:froms, r=jieyouxu
Convert some `Into` impls into `From` impls From the [`From`](https://doc.rust-lang.org/std/convert/trait.From.html) docs: > One should always prefer implementing `From` over [`Into`](https://doc.rust-lang.org/std/convert/trait.Into.html) because implementing `From` automatically provides one with an implementation of [`Into`](https://doc.rust-lang.org/std/convert/trait.Into.html) thanks to the blanket implementation in the standard library. > > Only implement [`Into`](https://doc.rust-lang.org/std/convert/trait.Into.html) when targeting a version prior to Rust 1.41 and converting to a type outside the current crate. `From` was not able to do these types of conversions in earlier versions because of Rust’s orphaning rules. See [Into](https://doc.rust-lang.org/std/convert/trait.Into.html) for more details. Some of these impls are likely from before 1.41, and then some others were probably just mistakes. Building nightly rust is definitely not supported on 1.41, so let's modernize these impls :D
Diffstat (limited to 'compiler/rustc_ast/src/ast.rs')
| -rw-r--r-- | compiler/rustc_ast/src/ast.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 31e6750a678..3a81b93d157 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -241,15 +241,15 @@ impl AngleBracketedArg { } } -impl Into<P<GenericArgs>> for AngleBracketedArgs { - fn into(self) -> P<GenericArgs> { - P(GenericArgs::AngleBracketed(self)) +impl From<AngleBracketedArgs> for P<GenericArgs> { + fn from(val: AngleBracketedArgs) -> Self { + P(GenericArgs::AngleBracketed(val)) } } -impl Into<P<GenericArgs>> for ParenthesizedArgs { - fn into(self) -> P<GenericArgs> { - P(GenericArgs::Parenthesized(self)) +impl From<ParenthesizedArgs> for P<GenericArgs> { + fn from(val: ParenthesizedArgs) -> Self { + P(GenericArgs::Parenthesized(val)) } } |
