Logo
Explore Help
Register Sign In
rust-lang/rust
1
0
Fork 0
You've already forked rust
Code Issues Pull Requests Actions 2 Packages Projects Releases Wiki Activity
Files
b3827e4f3728b77bd3e60587487ebfc3cc8d901b
rust/tests/ui/error-codes/E0746.rs

19 lines
252 B
Rust
Raw Normal View History

Make `impl Trait` suggestion in E0746 `MachineApplicable`
2020-01-13 16:13:51 -08:00
#![allow(dead_code)]
Simplify suggestion when returning bare dyn trait
2023-05-18 01:47:55 +00:00
Specific error for unsized `dyn Trait` return type Suggest `impl Trait` when possible, and `Box<dyn Trait>` otherwise.
2020-01-13 13:13:12 -08:00
struct Struct;
trait Trait {}
impl Trait for Struct {}
impl Trait for u32 {}
fn foo() -> dyn Trait { Struct }
//~^ ERROR E0746
fn bar() -> dyn Trait { //~ ERROR E0746
if true {
Elide E0308 errors in favor of E0746 When a type error involves a `dyn Trait` as the return type, do not emit the type error, as the "return type is not `Sized`" error will provide enough information to the user.
2020-01-13 16:12:44 -08:00
return 0;
Specific error for unsized `dyn Trait` return type Suggest `impl Trait` when possible, and `Box<dyn Trait>` otherwise.
2020-01-13 13:13:12 -08:00
}
Elide E0308 errors in favor of E0746 When a type error involves a `dyn Trait` as the return type, do not emit the type error, as the "return type is not `Sized`" error will provide enough information to the user.
2020-01-13 16:12:44 -08:00
42
Specific error for unsized `dyn Trait` return type Suggest `impl Trait` when possible, and `Box<dyn Trait>` otherwise.
2020-01-13 13:13:12 -08:00
}
fn main() {}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 1977ms Template: 2ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API