Skip to content

Commit d5cae77

Browse files
Fix overcapturing, unsafe extern blocks, and new unsafe ops
1 parent 2db18b3 commit d5cae77

File tree

6 files changed

+23
-15
lines changed

6 files changed

+23
-15
lines changed

compiler/rustc_borrowck/src/universal_regions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ impl<'tcx> UniversalRegions<'tcx> {
308308

309309
/// Returns an iterator over all the RegionVids corresponding to
310310
/// universally quantified free regions.
311-
pub(crate) fn universal_regions_iter(&self) -> impl Iterator<Item = RegionVid> {
311+
pub(crate) fn universal_regions_iter(&self) -> impl Iterator<Item = RegionVid> + use<> {
312312
(FIRST_GLOBAL_INDEX..self.num_universals).map(RegionVid::from_usize)
313313
}
314314

compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use super::ffi::{BasicBlock, Metadata, Module, Type, Value};
77
use crate::llvm::Bool;
88

99
#[link(name = "llvm-wrapper", kind = "static")]
10-
extern "C" {
10+
unsafe extern "C" {
1111
// Enzyme
1212
pub(crate) fn LLVMRustHasMetadata(I: &Value, KindID: c_uint) -> bool;
1313
pub(crate) fn LLVMRustEraseInstUntilInclusive(BB: &BasicBlock, I: &Value);
@@ -18,7 +18,7 @@ extern "C" {
1818
pub(crate) fn LLVMRustVerifyFunction(V: &Value, action: LLVMRustVerifierFailureAction) -> Bool;
1919
}
2020

21-
extern "C" {
21+
unsafe extern "C" {
2222
// Enzyme
2323
pub(crate) fn LLVMDumpModule(M: &Module);
2424
pub(crate) fn LLVMDumpValue(V: &Value);

compiler/rustc_data_structures/src/graph/scc/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<N: Idx, S: Idx + Ord, A: Annotation> Sccs<N, S, A> {
133133
/// meaning that if `S1 -> S2`, we will visit `S2` first and `S1` after.
134134
/// This is convenient when the edges represent dependencies: when you visit
135135
/// `S1`, the value for `S2` will already have been computed.
136-
pub fn all_sccs(&self) -> impl Iterator<Item = S> {
136+
pub fn all_sccs(&self) -> impl Iterator<Item = S> + use<N, S, A> {
137137
(0..self.scc_data.len()).map(S::new)
138138
}
139139

compiler/rustc_expand/src/proc_macro.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl<T> pm::bridge::server::MessagePipe<T> for MessagePipe<T> {
3131
}
3232
}
3333

34-
fn exec_strategy(ecx: &ExtCtxt<'_>) -> impl pm::bridge::server::ExecutionStrategy {
34+
fn exec_strategy(ecx: &ExtCtxt<'_>) -> impl pm::bridge::server::ExecutionStrategy + use<> {
3535
pm::bridge::server::MaybeCrossThread::<MessagePipe<_>>::new(
3636
ecx.sess.opts.unstable_opts.proc_macro_execution_strategy
3737
== ProcMacroExecutionStrategy::CrossThread,

compiler/rustc_interface/src/passes.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,15 @@ fn configure_and_expand(
171171
new_path.push(path);
172172
}
173173
}
174-
env::set_var(
175-
"PATH",
176-
&env::join_paths(
177-
new_path.iter().filter(|p| env::join_paths(iter::once(p)).is_ok()),
178-
)
179-
.unwrap(),
180-
);
174+
unsafe {
175+
env::set_var(
176+
"PATH",
177+
&env::join_paths(
178+
new_path.iter().filter(|p| env::join_paths(iter::once(p)).is_ok()),
179+
)
180+
.unwrap(),
181+
);
182+
}
181183
}
182184

183185
// Create the config for macro expansion
@@ -216,7 +218,9 @@ fn configure_and_expand(
216218
}
217219

218220
if cfg!(windows) {
219-
env::set_var("PATH", &old_path);
221+
unsafe {
222+
env::set_var("PATH", &old_path);
223+
}
220224
}
221225

222226
krate

compiler/rustc_llvm/build.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,13 @@ fn detect_llvm_link() -> (&'static str, &'static str) {
5151
fn restore_library_path() {
5252
let key = tracked_env_var_os("REAL_LIBRARY_PATH_VAR").expect("REAL_LIBRARY_PATH_VAR");
5353
if let Some(env) = tracked_env_var_os("REAL_LIBRARY_PATH") {
54-
env::set_var(&key, env);
54+
unsafe {
55+
env::set_var(&key, env);
56+
}
5557
} else {
56-
env::remove_var(&key);
58+
unsafe {
59+
env::remove_var(&key);
60+
}
5761
}
5862
}
5963

0 commit comments

Comments
 (0)