Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explanation message for E0641 #66461

Merged
merged 2 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc_error_codes/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ E0635: include_str!("./error_codes/E0635.md"),
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"),
Expand Down Expand Up @@ -585,7 +586,6 @@ E0744: include_str!("./error_codes/E0744.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
Expand Down
19 changes: 19 additions & 0 deletions src/librustc_error_codes/error_codes/E0641.md
Original file line number Diff line number Diff line change
@@ -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
```
1 change: 1 addition & 0 deletions src/test/ui/issues/issue-45730.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
1 change: 1 addition & 0 deletions src/test/ui/order-dependent-cast-inference.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.