Fix overcapturing, unsafe extern blocks, and new unsafe ops

This commit is contained in:
Michael Goulet
2025-02-20 18:28:42 +00:00
parent 7f6873f64c
commit e1819a889a
7 changed files with 24 additions and 16 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ fn main() {
// linking, so we need to explicitly depend on the function.
#[cfg(target_os = "macos")]
{
extern "C" {
unsafe extern "C" {
fn _rjem_je_zone_register();
}
@@ -308,7 +308,7 @@ pub(crate) fn region_classification(&self, r: RegionVid) -> Option<RegionClassif
/// Returns an iterator over all the RegionVids corresponding to
/// universally quantified free regions.
pub(crate) fn universal_regions_iter(&self) -> impl Iterator<Item = RegionVid> {
pub(crate) fn universal_regions_iter(&self) -> impl Iterator<Item = RegionVid> + use<> {
(FIRST_GLOBAL_INDEX..self.num_universals).map(RegionVid::from_usize)
}
@@ -7,7 +7,7 @@
use crate::llvm::Bool;
#[link(name = "llvm-wrapper", kind = "static")]
extern "C" {
unsafe extern "C" {
// Enzyme
pub(crate) fn LLVMRustHasMetadata(I: &Value, KindID: c_uint) -> bool;
pub(crate) fn LLVMRustEraseInstUntilInclusive(BB: &BasicBlock, I: &Value);
@@ -18,7 +18,7 @@
pub(crate) fn LLVMRustVerifyFunction(V: &Value, action: LLVMRustVerifierFailureAction) -> Bool;
}
extern "C" {
unsafe extern "C" {
// Enzyme
pub(crate) fn LLVMDumpModule(M: &Module);
pub(crate) fn LLVMDumpValue(V: &Value);
@@ -133,7 +133,7 @@ pub fn num_sccs(&self) -> usize {
/// meaning that if `S1 -> S2`, we will visit `S2` first and `S1` after.
/// This is convenient when the edges represent dependencies: when you visit
/// `S1`, the value for `S2` will already have been computed.
pub fn all_sccs(&self) -> impl Iterator<Item = S> {
pub fn all_sccs(&self) -> impl Iterator<Item = S> + use<N, S, A> {
(0..self.scc_data.len()).map(S::new)
}
+1 -1
View File
@@ -31,7 +31,7 @@ fn recv(&mut self) -> Option<T> {
}
}
fn exec_strategy(ecx: &ExtCtxt<'_>) -> impl pm::bridge::server::ExecutionStrategy {
fn exec_strategy(ecx: &ExtCtxt<'_>) -> impl pm::bridge::server::ExecutionStrategy + use<> {
pm::bridge::server::MaybeCrossThread::<MessagePipe<_>>::new(
ecx.sess.opts.unstable_opts.proc_macro_execution_strategy
== ProcMacroExecutionStrategy::CrossThread,
+12 -8
View File
@@ -171,13 +171,15 @@ fn configure_and_expand(
new_path.push(path);
}
}
env::set_var(
"PATH",
&env::join_paths(
new_path.iter().filter(|p| env::join_paths(iter::once(p)).is_ok()),
)
.unwrap(),
);
unsafe {
env::set_var(
"PATH",
&env::join_paths(
new_path.iter().filter(|p| env::join_paths(iter::once(p)).is_ok()),
)
.unwrap(),
);
}
}
// Create the config for macro expansion
@@ -216,7 +218,9 @@ fn configure_and_expand(
}
if cfg!(windows) {
env::set_var("PATH", &old_path);
unsafe {
env::set_var("PATH", &old_path);
}
}
krate
+6 -2
View File
@@ -51,9 +51,13 @@ fn detect_llvm_link() -> (&'static str, &'static str) {
fn restore_library_path() {
let key = tracked_env_var_os("REAL_LIBRARY_PATH_VAR").expect("REAL_LIBRARY_PATH_VAR");
if let Some(env) = tracked_env_var_os("REAL_LIBRARY_PATH") {
env::set_var(&key, env);
unsafe {
env::set_var(&key, env);
}
} else {
env::remove_var(&key);
unsafe {
env::remove_var(&key);
}
}
}