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#99462 - matthiaskrgr:rollup-ihhwaru, r=matthi…
…askrgr Rollup of 9 pull requests Successful merges: - rust-lang#98028 (Add E0790 as more specific variant of E0283) - rust-lang#99384 (use body's param-env when checking if type needs drop) - rust-lang#99401 (Avoid `Symbol` to `&str` conversions) - rust-lang#99419 (Stabilize `core::task::ready!`) - rust-lang#99435 (Revert "Stabilize $$ in Rust 1.63.0") - rust-lang#99438 (Improve suggestions for `NonZeroT` <- `T` coercion error) - rust-lang#99441 (Update mdbook) - rust-lang#99453 (:arrow_up: rust-analyzer) - rust-lang#99457 (use `par_for_each_in` in `par_body_owners` and `collect_crate_mono_items`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
55 changed files
with
705 additions
and
204 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
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,47 @@ | ||
You need to specify a specific implementation of the trait in order to call the | ||
method. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0790 | ||
trait Generator { | ||
fn create() -> u32; | ||
} | ||
struct Impl; | ||
impl Generator for Impl { | ||
fn create() -> u32 { 1 } | ||
} | ||
struct AnotherImpl; | ||
impl Generator for AnotherImpl { | ||
fn create() -> u32 { 2 } | ||
} | ||
let cont: u32 = Generator::create(); | ||
// error, impossible to choose one of Generator trait implementation | ||
// Should it be Impl or AnotherImpl, maybe something else? | ||
``` | ||
|
||
This error can be solved by adding type annotations that provide the missing | ||
information to the compiler. In this case, the solution is to use a concrete | ||
type: | ||
|
||
``` | ||
trait Generator { | ||
fn create() -> u32; | ||
} | ||
struct AnotherImpl; | ||
impl Generator for AnotherImpl { | ||
fn create() -> u32 { 2 } | ||
} | ||
let gen1 = AnotherImpl::create(); | ||
// if there are multiple methods with same name (different traits) | ||
let gen2 = <AnotherImpl as Generator>::create(); | ||
``` |
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
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.