FIx ICE while casting a type with error · rust-lang/rust@fb619ec (original) (raw)

``

1

`` +

error[E0261]: use of undeclared lifetime name 'unpinned

``

``

2

`+

--> $DIR/ice-cast-type-with-error-124848.rs:7:32

`

``

3

`+

|

`

``

4

`+

LL | struct MyType<'a>(Cell<Option<&'unpinned mut MyType<'a>>>, Pin);

`

``

5

`+

| - ^^^^^^^^^ undeclared lifetime

`

``

6

`+

| |

`

``

7

`` +

| help: consider introducing lifetime 'unpinned here: 'unpinned,

``

``

8

+

``

9

`` +

error[E0261]: use of undeclared lifetime name 'a

``

``

10

`+

--> $DIR/ice-cast-type-with-error-124848.rs:14:53

`

``

11

`+

|

`

``

12

`+

LL | fn main() {

`

``

13

`` +

| - help: consider introducing lifetime 'a here: <'a>

``

``

14

`+

...

`

``

15

`+

LL | let bad_addr = &unpinned as *const Cell<Option<&'a mut MyType<'a>>> as usize;

`

``

16

`+

| ^^ undeclared lifetime

`

``

17

+

``

18

`` +

error[E0261]: use of undeclared lifetime name 'a

``

``

19

`+

--> $DIR/ice-cast-type-with-error-124848.rs:14:67

`

``

20

`+

|

`

``

21

`+

LL | fn main() {

`

``

22

`` +

| - help: consider introducing lifetime 'a here: <'a>

``

``

23

`+

...

`

``

24

`+

LL | let bad_addr = &unpinned as *const Cell<Option<&'a mut MyType<'a>>> as usize;

`

``

25

`+

| ^^ undeclared lifetime

`

``

26

+

``

27

`` +

error[E0412]: cannot find type Pin in this scope

``

``

28

`+

--> $DIR/ice-cast-type-with-error-124848.rs:7:60

`

``

29

`+

|

`

``

30

`+

LL | struct MyType<'a>(Cell<Option<&'unpinned mut MyType<'a>>>, Pin);

`

``

31

`+

| ^^^ not found in this scope

`

``

32

`+

|

`

``

33

`+

help: consider importing this struct

`

``

34

`+

|

`

``

35

`+

LL + use std::pin::Pin;

`

``

36

`+

|

`

``

37

+

``

38

`+

error[E0061]: this struct takes 2 arguments but 1 argument was supplied

`

``

39

`+

--> $DIR/ice-cast-type-with-error-124848.rs:12:24

`

``

40

`+

|

`

``

41

`+

LL | let mut unpinned = MyType(Cell::new(None));

`

``

42

`+

| ^^^^^^----------------- an argument is missing

`

``

43

`+

|

`

``

44

`+

note: tuple struct defined here

`

``

45

`+

--> $DIR/ice-cast-type-with-error-124848.rs:7:8

`

``

46

`+

|

`

``

47

`+

LL | struct MyType<'a>(Cell<Option<&'unpinned mut MyType<'a>>>, Pin);

`

``

48

`+

| ^^^^^^

`

``

49

`+

help: provide the argument

`

``

50

`+

|

`

``

51

`+

LL | let mut unpinned = MyType(Cell::new(None), /* value */);

`

``

52

`+

| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

`

``

53

+

``

54

`` +

error[E0606]: casting &MyType<'_> as *const Cell<Option<&mut MyType<'_>>> is invalid

``

``

55

`+

--> $DIR/ice-cast-type-with-error-124848.rs:14:20

`

``

56

`+

|

`

``

57

`+

LL | let bad_addr = &unpinned as *const Cell<Option<&'a mut MyType<'a>>> as usize;

`

``

58

`+

| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

`

``

59

+

``

60

`+

error: aborting due to 6 previous errors

`

``

61

+

``

62

`+

Some errors have detailed explanations: E0061, E0261, E0412, E0606.

`

``

63

`` +

For more information about an error, try rustc --explain E0061.

``