about summary refs log tree commit diff
path: root/compiler/rustc_error_codes
diff options
context:
space:
mode:
authoraticu <15schnic@gmail.com>2022-06-13 09:32:54 +0200
committeraticu <15schnic@gmail.com>2022-07-19 10:23:34 +0200
commit38ea23558eca629d668208e368dfa711b8229192 (patch)
tree90a1903fd4d360fe50c4feffc9eaabf44cbc84c8 /compiler/rustc_error_codes
parent1cbacc0c8aa3c4d99a073108d4ec7a535ff79102 (diff)
downloadrust-38ea23558eca629d668208e368dfa711b8229192.tar.gz
rust-38ea23558eca629d668208e368dfa711b8229192.zip
Don't use main; improve example
Diffstat (limited to 'compiler/rustc_error_codes')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0283.md14
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0790.md16
2 files changed, 11 insertions, 19 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0283.md b/compiler/rustc_error_codes/src/error_codes/E0283.md
index e5a3179aabf..79d2c8204f9 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0283.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0283.md
@@ -9,15 +9,13 @@ impl Into<u32> for Foo {
     fn into(self) -> u32 { 1 }
 }
 
-fn main() {
-    let foo = Foo;
-    let bar: u32 = foo.into() * 1u32;
-}
+let foo = Foo;
+let bar: u32 = foo.into() * 1u32;
 ```
 
 This error can be solved by adding type annotations that provide the missing
 information to the compiler. In this case, the solution is to specify the
-fully-qualified method:
+trait's type parameter:
 
 ```
 struct Foo;
@@ -26,8 +24,6 @@ impl Into<u32> for Foo {
     fn into(self) -> u32 { 1 }
 }
 
-fn main() {
-    let foo = Foo;
-    let bar: u32 = <Foo as Into<u32>>::into(foo) * 1u32;
-}
+let foo = Foo;
+let bar: u32 = Into::<u32>::into(foo) * 1u32;
 ```
diff --git a/compiler/rustc_error_codes/src/error_codes/E0790.md b/compiler/rustc_error_codes/src/error_codes/E0790.md
index 93d9636626d..2aee9dfbdbd 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0790.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0790.md
@@ -20,11 +20,9 @@ impl Generator for AnotherImpl {
     fn create() -> u32 { 2 }
 }
 
-fn main() {
-    let cont: u32 = Generator::create();
-    // error, impossible to choose one of Generator trait implementation
-    // Should it be Impl or AnotherImpl, maybe something else?
-}
+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
@@ -42,10 +40,8 @@ impl Generator for AnotherImpl {
     fn create() -> u32 { 2 }
 }
 
-fn main() {
-    let gen1 = AnotherImpl::create();
+let gen1 = AnotherImpl::create();
 
-    // if there are multiple methods with same name (different traits)
-    let gen2 = <AnotherImpl as Generator>::create();
-}
+// if there are multiple methods with same name (different traits)
+let gen2 = <AnotherImpl as Generator>::create();
 ```