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

19 lines
266 B
Rust
Raw Normal View History

Make `impl Trait` suggestion in E0746 `MachineApplicable`
2020-01-13 16:13:51 -08:00
// run-rustfix
#![allow(dead_code)]
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: 1854ms 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