Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::num::NonZero;
use std::ops::{Index, IndexMut};
use std::sync::atomic::{AtomicU32, Ordering};

use super::fxhash::FxHashMap;
use crate::backend::fxhash::FxHashMap;

pub(super) type Handle = NonZero<u32>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,13 @@ macro_rules! reverse_decode {
}
}

#[allow(unsafe_code)]
mod arena;
#[allow(unsafe_code)]
mod buffer;
#[deny(unsafe_code)]
pub mod client;
#[allow(unsafe_code)]
mod closure;
#[forbid(unsafe_code)]
mod fxhash;
#[forbid(unsafe_code)]
mod handle;
#[macro_use]
#[forbid(unsafe_code)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ impl<S> DecodeMut<'_, '_, S> for Symbol {

thread_local! {
static INTERNER: RefCell<Interner> = RefCell::new(Interner {
arena: arena::Arena::new(),
names: fxhash::FxHashMap::default(),
arena: crate::backend::arena::Arena::new(),
names: crate::backend::fxhash::FxHashMap::default(),
strings: Vec::new(),
// Start with a base of 1 to make sure that `NonZero<u32>` works.
sym_base: NonZero::new(1).unwrap(),
Expand All @@ -137,11 +137,11 @@ thread_local! {

/// Basic interner for a `Symbol`, inspired by the one in `rustc_span`.
struct Interner {
arena: arena::Arena,
arena: crate::backend::arena::Arena,
// SAFETY: These `'static` lifetimes are actually references to data owned
// by the Arena. This is safe, as we never return them as static references
// from `Interner`.
names: fxhash::FxHashMap<&'static str, Symbol>,
names: crate::backend::fxhash::FxHashMap<&'static str, Symbol>,
strings: Vec<&'static str>,
// The offset to apply to symbol names stored in the interner. This is used
// to ensure that symbol names are not re-used after the interner is
Expand Down Expand Up @@ -194,6 +194,6 @@ impl Interner {

// SAFETY: This is cleared after the names and strings tables are
// cleared out, so no references into the arena should remain.
self.arena = arena::Arena::new();
self.arena = crate::backend::arena::Arena::new();
}
}
5 changes: 5 additions & 0 deletions library/proc_macro/src/backend/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub(crate) mod arena;
pub mod bridge;
pub(crate) mod fxhash;

pub use bridge::*;
8 changes: 5 additions & 3 deletions library/proc_macro/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,17 @@ impl Diagnostic {
/// Emit the diagnostic.
#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
pub fn emit(self) {
fn to_internal(diag: Diagnostic) -> crate::bridge::Diagnostic<crate::bridge::client::Span> {
crate::bridge::Diagnostic {
fn to_internal(
diag: Diagnostic,
) -> crate::backend::Diagnostic<crate::backend::client::Span> {
crate::backend::Diagnostic {
level: diag.level,
message: diag.message,
spans: diag.spans.into_iter().map(|s| s.0).collect(),
children: diag.children.into_iter().map(to_internal).collect(),
}
}

crate::bridge::client::FreeFunctions::emit_diagnostic(to_internal(self));
crate::backend::client::FreeFunctions::emit_diagnostic(to_internal(self));
}
}
Loading
Loading