Skip to content

Commit 7186de2

Browse files
authored
Rollup merge of rust-lang#66461 - clemencetbk:master, r=GuillaumeGomez
Add explanation message for E0641 Part of rust-lang#61137
2 parents 6b0c545 + dc137dd commit 7186de2

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

src/librustc_error_codes/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ E0635: include_str!("./error_codes/E0635.md"),
350350
E0636: include_str!("./error_codes/E0636.md"),
351351
E0638: include_str!("./error_codes/E0638.md"),
352352
E0639: include_str!("./error_codes/E0639.md"),
353+
E0641: include_str!("./error_codes/E0641.md"),
353354
E0642: include_str!("./error_codes/E0642.md"),
354355
E0643: include_str!("./error_codes/E0643.md"),
355356
E0644: include_str!("./error_codes/E0644.md"),
@@ -584,7 +585,6 @@ E0744: include_str!("./error_codes/E0744.md"),
584585
E0634, // type has conflicting packed representaton hints
585586
E0637, // "'_" is not a valid lifetime bound
586587
E0640, // infer outlives requirements
587-
E0641, // cannot cast to/from a pointer with an unknown kind
588588
// E0645, // trait aliases not finished
589589
E0657, // `impl Trait` can only capture lifetimes bound at the fn level
590590
E0667, // `impl Trait` in projections
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Attempted to cast to/from a pointer with an unknown kind.
2+
3+
Erroneous code examples:
4+
5+
```compile_fail,E0641
6+
let b = 0 as *const _; // error
7+
```
8+
9+
Must give information for type of pointer that is being cast from/to if the
10+
type cannot be inferred.
11+
12+
```
13+
// Creating a pointer from reference: type can be inferred
14+
let a = &(String::from("Hello world!")) as *const _; // Ok
15+
16+
let b = 0 as *const i32; // Ok
17+
18+
let c: *const i32 = 0 as *const _; // Ok
19+
```

src/test/ui/issues/issue-45730.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ LL | let x = 0 as *const i32 as *const _ as *mut _;
3030

3131
error: aborting due to 3 previous errors
3232

33+
For more information about this error, try `rustc --explain E0641`.

src/test/ui/order-dependent-cast-inference.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ LL | let mut y = 0 as *const _;
1010

1111
error: aborting due to previous error
1212

13+
For more information about this error, try `rustc --explain E0641`.

0 commit comments

Comments
 (0)