]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #66461 - clemencetbk:master, r=GuillaumeGomez
authorMazdak Farrokhzad <twingoow@gmail.com>
Tue, 19 Nov 2019 12:10:19 +0000 (13:10 +0100)
committerGitHub <noreply@github.com>
Tue, 19 Nov 2019 12:10:19 +0000 (13:10 +0100)
Add explanation message for E0641

Part of #61137

src/librustc_error_codes/error_codes.rs
src/librustc_error_codes/error_codes/E0641.md [new file with mode: 0644]
src/test/ui/issues/issue-45730.stderr
src/test/ui/order-dependent-cast-inference.stderr

index 9fc375cc7b044a37f8efd4f5e2a96feb7bb898a4..e575528a4633cd3d68c0a7a09cf56a081c90b760 100644 (file)
 E0636: include_str!("./error_codes/E0636.md"),
 E0638: include_str!("./error_codes/E0638.md"),
 E0639: include_str!("./error_codes/E0639.md"),
+E0641: include_str!("./error_codes/E0641.md"),
 E0642: include_str!("./error_codes/E0642.md"),
 E0643: include_str!("./error_codes/E0643.md"),
 E0644: include_str!("./error_codes/E0644.md"),
     E0634, // type has conflicting packed representaton hints
     E0637, // "'_" is not a valid lifetime bound
     E0640, // infer outlives requirements
-    E0641, // cannot cast to/from a pointer with an unknown kind
 //  E0645, // trait aliases not finished
     E0657, // `impl Trait` can only capture lifetimes bound at the fn level
     E0667, // `impl Trait` in projections
diff --git a/src/librustc_error_codes/error_codes/E0641.md b/src/librustc_error_codes/error_codes/E0641.md
new file mode 100644 (file)
index 0000000..e39bebc
--- /dev/null
@@ -0,0 +1,19 @@
+Attempted to cast to/from a pointer with an unknown kind.
+
+Erroneous code examples:
+
+```compile_fail,E0641
+let b = 0 as *const _; // error
+```
+
+Must give information for type of pointer that is being cast from/to if the
+type cannot be inferred.
+
+```
+// Creating a pointer from reference: type can be inferred
+let a = &(String::from("Hello world!")) as *const _; // Ok
+
+let b = 0 as *const i32; // Ok
+
+let c: *const i32 = 0 as *const _; // Ok
+```
\ No newline at end of file
index 4fc1e3835f7ad82730e487a403d7ffe826956cac..3c400d6eefaa8de6aefa13d08132c171df820de6 100644 (file)
@@ -30,3 +30,4 @@ LL |     let x = 0 as *const i32 as *const _ as *mut _;
 
 error: aborting due to 3 previous errors
 
+For more information about this error, try `rustc --explain E0641`.
index 01e59f8f022fdc5d185134bc5f79fe0f7c558f7f..081038c573acfdcb82cb7e8666830c9cdde2c4d4 100644 (file)
@@ -10,3 +10,4 @@ LL |     let mut y = 0 as *const _;
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0641`.