diff --git a/melior/src/context.rs b/melior/src/context.rs index 8e5407f7f5..7315cd85ce 100644 --- a/melior/src/context.rs +++ b/melior/src/context.rs @@ -4,7 +4,6 @@ use crate::{ logical_result::LogicalResult, string_ref::StringRef, }; -use dashmap::DashMap; use mlir_sys::{ mlirContextAppendDialectRegistry, mlirContextAttachDiagnosticHandler, mlirContextCreate, mlirContextDestroy, mlirContextDetachDiagnosticHandler, mlirContextEnableMultithreading, @@ -13,7 +12,7 @@ use mlir_sys::{ mlirContextIsRegisteredOperation, mlirContextLoadAllAvailableDialects, mlirContextSetAllowUnregisteredDialects, MlirContext, MlirDiagnostic, MlirLogicalResult, }; -use std::{ffi::c_void, marker::PhantomData, pin::Pin}; +use std::{ffi::c_void, marker::PhantomData}; /// A context of IR, dialects, and passes. /// @@ -22,9 +21,6 @@ use std::{ffi::c_void, marker::PhantomData, pin::Pin}; #[derive(Debug)] pub struct Context { raw: MlirContext, - // We need to pass null-terminated strings to functions in the MLIR API although - // Rust's strings are not. - string_cache: DashMap, ()>, } impl Context { @@ -32,7 +28,6 @@ impl Context { pub fn new() -> Self { Self { raw: unsafe { mlirContextCreate() }, - string_cache: Default::default(), } } @@ -124,10 +119,6 @@ impl Context { pub(crate) fn to_ref(&self) -> ContextRef { unsafe { ContextRef::from_raw(self.to_raw()) } } - - pub(crate) fn string_cache(&self) -> &DashMap, ()> { - &self.string_cache - } } impl Drop for Context { diff --git a/melior/src/string_ref.rs b/melior/src/string_ref.rs index 36e0170505..159ca3db7f 100644 --- a/melior/src/string_ref.rs +++ b/melior/src/string_ref.rs @@ -1,9 +1,7 @@ -use crate::Context; use mlir_sys::{mlirStringRefEqual, MlirStringRef}; use std::{ ffi::CStr, marker::PhantomData, - pin::Pin, slice, str::{self, Utf8Error}, }; @@ -40,21 +38,6 @@ impl<'a> StringRef<'a> { unsafe { Self::from_raw(string) } } - /// Converts a string into a null-terminated string reference. - #[deprecated] - pub fn from_str(context: &'a Context, string: &str) -> Self { - let entry = context - .string_cache() - .entry(Pin::new(string.into())) - .or_default(); - let string = MlirStringRef { - data: entry.key().as_bytes().as_ptr() as *const i8, - length: entry.key().len(), - }; - - unsafe { Self::from_raw(string) } - } - /// Converts a string reference into a `str`. pub fn as_str(&self) -> Result<&'a str, Utf8Error> { unsafe {