Closed
Description
The final example does not compile (just clicking the run button), with following messages:
Compiling playground v0.0.1 (file:///playground)
warning: use of deprecated item 'std::heap::Heap': type renamed to `Global`
--> src/main.rs:9:32
|
9 | use std::heap::{Alloc, Layout, Heap};
| ^^^^
|
= note: #[warn(deprecated)] on by default
warning: use of deprecated item 'std::heap::Heap': type renamed to `Global`
--> src/main.rs:34:27
|
34 | let ptr = Heap.alloc(Layout::array::<T>(1).unwrap());
| ^^^^
warning: use of deprecated item 'std::heap::Heap': type renamed to `Global`
--> src/main.rs:38:27
|
38 | let ptr = Heap.realloc(self.ptr.as_ptr() as *mut _,
| ^^^^
warning: use of deprecated item 'std::heap::Heap': type renamed to `Global`
--> src/main.rs:47:29
|
47 | Err(err) => Heap.oom(err),
| ^^^^
warning: use of deprecated item 'std::heap::Heap': type renamed to `Global`
--> src/main.rs:61:17
|
61 | Heap.dealloc(self.ptr.as_ptr() as *mut _,
| ^^^^
error[E0308]: mismatched types
--> src/main.rs:38:40
|
38 | let ptr = Heap.realloc(self.ptr.as_ptr() as *mut _,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::ptr::NonNull`, found *-ptr
|
= note: expected type `std::ptr::NonNull<std::heap::Opaque>`
found type `*mut _`
error[E0308]: mismatched types
--> src/main.rs:40:40
|
40 | Layout::array::<T>(new_cap).unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected usize, found struct `std::heap::Layout`
|
= note: expected type `usize`
found type `std::heap::Layout`
error[E0599]: no method named `oom` found for type `std::heap::Global` in the current scope
--> src/main.rs:47:34
|
47 | Err(err) => Heap.oom(err),
| ^^^
error[E0308]: mismatched types
--> src/main.rs:61:30
|
61 | Heap.dealloc(self.ptr.as_ptr() as *mut _,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::ptr::NonNull`, found *-ptr
|
= note: expected type `std::ptr::NonNull<std::heap::Opaque>`
found type `*mut _`
error: aborting due to 4 previous errors
Some errors occurred: E0308, E0599.
For more information about an error, try `rustc --explain E0308`.
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
Also previous examples during Implementing Vec chapter are using even older allocator API then this final code.
Metadata
Metadata
Assignees
Labels
No labels