Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

cranelift-isle: no_std support (#12236)

SSDc1186f2db690
diff --git a/cranelift/isle/isle/isle_examples/link/borrows_main.rs b/cranelift/isle/isle/isle_examples/link/borrows_main.rs
index 9de7d4ddde..eaff4d9f91 100644
--- a/cranelift/isle/isle/isle_examples/link/borrows_main.rs
+++ b/cranelift/isle/isle/isle_examples/link/borrows_main.rs
@@ -1,3 +1,6 @@
+extern crate alloc;
+extern crate core;
+
mod borrows;
#[derive(Clone)]
diff --git a/cranelift/isle/isle/isle_examples/link/iflets_main.rs b/cranelift/isle/isle/isle_examples/link/iflets_main.rs
index 4c5717cbf4..ee974818f9 100644
--- a/cranelift/isle/isle/isle_examples/link/iflets_main.rs
+++ b/cranelift/isle/isle/isle_examples/link/iflets_main.rs
@@ -1,3 +1,6 @@
+extern crate alloc;
+extern crate core;
+
mod iflets;
struct Context;
diff --git a/cranelift/isle/isle/isle_examples/link/multi_constructor_main.rs b/cranelift/isle/isle/isle_examples/link/multi_constructor_main.rs
index 3c05532ce0..c7bd08fd5b 100644
--- a/cranelift/isle/isle/isle_examples/link/multi_constructor_main.rs
+++ b/cranelift/isle/isle/isle_examples/link/multi_constructor_main.rs
@@ -1,3 +1,6 @@
+extern crate alloc;
+extern crate core;
+
mod multi_constructor;
use multi_constructor::{ContextIter, IntoContextIter};
diff --git a/cranelift/isle/isle/isle_examples/link/multi_extractor_main.rs b/cranelift/isle/isle/isle_examples/link/multi_extractor_main.rs
index ebfa38e30f..0554dd5829 100644
--- a/cranelift/isle/isle/isle_examples/link/multi_extractor_main.rs
+++ b/cranelift/isle/isle/isle_examples/link/multi_extractor_main.rs
@@ -1,3 +1,6 @@
+extern crate alloc;
+extern crate core;
+
mod multi_extractor;
use multi_extractor::{ContextIter, IntoContextIter};
diff --git a/cranelift/isle/isle/isle_examples/link/test_main.rs b/cranelift/isle/isle/isle_examples/link/test_main.rs
index 733e2a2019..87f633e2ec 100644
--- a/cranelift/isle/isle/isle_examples/link/test_main.rs
+++ b/cranelift/isle/isle/isle_examples/link/test_main.rs
@@ -1,3 +1,6 @@
+extern crate alloc;
+extern crate core;
+
mod test;
struct Context;
diff --git a/cranelift/isle/isle/isle_examples/run/iconst_main.rs b/cranelift/isle/isle/isle_examples/run/iconst_main.rs
index d53edea438..2750549937 100644
--- a/cranelift/isle/isle/isle_examples/run/iconst_main.rs
+++ b/cranelift/isle/isle/isle_examples/run/iconst_main.rs
@@ -1,3 +1,6 @@
+extern crate alloc;
+extern crate core;
+
mod iconst;
struct Context;
diff --git a/cranelift/isle/isle/isle_examples/run/let_shadowing_main.rs b/cranelift/isle/isle/isle_examples/run/let_shadowing_main.rs
index 37ddb0bcc5..ec57de3383 100644
--- a/cranelift/isle/isle/isle_examples/run/let_shadowing_main.rs
+++ b/cranelift/isle/isle/isle_examples/run/let_shadowing_main.rs
@@ -1,3 +1,6 @@
+extern crate alloc;
+extern crate core;
+
mod let_shadowing;
struct Context;
diff --git a/cranelift/isle/isle/src/codegen.rs b/cranelift/isle/isle/src/codegen.rs
index c215e1db74..78a8fee729 100644
--- a/cranelift/isle/isle/src/codegen.rs
+++ b/cranelift/isle/isle/src/codegen.rs
@@ -166,7 +166,7 @@ impl<'a> Codegen<'a> {
}
writeln!(code, "\nuse super::*; // Pulls in all external types.").unwrap();
- writeln!(code, "use std::marker::PhantomData;").unwrap();
+ writeln!(code, "use core::marker::PhantomData;").unwrap();
}
fn generate_trait_sig(&self, code: &mut String, indent: &str, sig: &ExternalSig) {
@@ -271,38 +271,38 @@ pub trait Length {{
fn len(&self) -> usize;
}}
-impl<T> Length for std::vec::Vec<T> {{
+impl<T> Length for alloc::vec::Vec<T> {{
fn len(&self) -> usize {{
- std::vec::Vec::len(self)
+ alloc::vec::Vec::len(self)
}}
}}
pub struct ContextIterWrapper<I, C> {{
iter: I,
- _ctx: std::marker::PhantomData<C>,
+ _ctx: core::marker::PhantomData<C>,
}}
impl<I: Default, C> Default for ContextIterWrapper<I, C> {{
fn default() -> Self {{
ContextIterWrapper {{
iter: I::default(),
- _ctx: std::marker::PhantomData
+ _ctx: core::marker::PhantomData
}}
}}
}}
-impl<I, C> std::ops::Deref for ContextIterWrapper<I, C> {{
+impl<I, C> core::ops::Deref for ContextIterWrapper<I, C> {{
type Target = I;
fn deref(&self) -> &I {{
&self.iter
}}
}}
-impl<I, C> std::ops::DerefMut for ContextIterWrapper<I, C> {{
+impl<I, C> core::ops::DerefMut for ContextIterWrapper<I, C> {{
fn deref_mut(&mut self) -> &mut I {{
&mut self.iter
}}
}}
impl<I: Iterator, C: Context> From<I> for ContextIterWrapper<I, C> {{
fn from(iter: I) -> Self {{
- Self {{ iter, _ctx: std::marker::PhantomData }}
+ Self {{ iter, _ctx: core::marker::PhantomData }}
}}
}}
impl<I: Iterator, C: Context> ContextIter for ContextIterWrapper<I, C> {{
@@ -322,7 +322,7 @@ impl<I: IntoIterator, C: Context> IntoContextIter for ContextIterWrapper<I, C> {
fn into_context_iter(self) -> Self::IntoIter {{
ContextIterWrapper {{
iter: self.iter.into_iter(),
- _ctx: std::marker::PhantomData
+ _ctx: core::marker::PhantomData
}}
}}
}}