Skip to content

Add helper alloc_os_str_as_c_str and use it in env_var emulation #1098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
4 changes: 2 additions & 2 deletions benches/fibonacci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::helpers::*;

#[bench]
fn fib(bencher: &mut Bencher) {
bencher.iter(|| fibonacci_helper::main())
bencher.iter(|| { fibonacci_helper::main(); })
}

#[bench]
Expand All @@ -17,7 +17,7 @@ fn fib_miri(bencher: &mut Bencher) {

#[bench]
fn fib_iter(bencher: &mut Bencher) {
bencher.iter(|| fibonacci_helper_iterative::main())
bencher.iter(|| { fibonacci_helper_iterative::main(); })
}

#[bench]
Expand Down
25 changes: 13 additions & 12 deletions benches/helpers/miri_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,23 @@ extern crate rustc_interface;
extern crate test;

use self::miri::eval_main;
use crate::test::Bencher;
use rustc::hir::def_id::LOCAL_CRATE;
use rustc_driver::Compilation;
use rustc_interface::{interface, Queries};
use rustc_driver::Compilation;
use crate::test::Bencher;

struct MiriCompilerCalls<'a> {
bencher: &'a mut Bencher,
}

impl rustc_driver::Callbacks for MiriCompilerCalls<'_> {
fn after_analysis<'tcx>(
&mut self,
compiler: &interface::Compiler,
queries: &'tcx Queries<'tcx>,
) -> Compilation {
fn after_analysis<'tcx>(&mut self, compiler: &interface::Compiler, queries: &'tcx Queries<'tcx>) -> Compilation {
compiler.session().abort_if_errors();

queries.global_ctxt().unwrap().peek_mut().enter(|tcx| {
let (entry_def_id, _) =
tcx.entry_fn(LOCAL_CRATE).expect("no main or start function found");
let (entry_def_id, _) = tcx.entry_fn(LOCAL_CRATE).expect(
"no main or start function found",
);

self.bencher.iter(|| {
let config = miri::MiriConfig {
Expand Down Expand Up @@ -53,9 +50,13 @@ fn find_sysroot() -> String {
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
match (home, toolchain) {
(Some(home), Some(toolchain)) => format!("{}/toolchains/{}", home, toolchain),
_ => option_env!("RUST_SYSROOT")
.expect("need to specify RUST_SYSROOT env var or use rustup or multirust")
.to_owned(),
_ => {
option_env!("RUST_SYSROOT")
.expect(
"need to specify RUST_SYSROOT env var or use rustup or multirust",
)
.to_owned()
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion benches/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::helpers::*;

#[bench]
fn noop(bencher: &mut Bencher) {
bencher.iter(|| smoke_helper::main())
bencher.iter(|| { smoke_helper::main(); })
}

/*
Expand Down
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9ae6cedb8d1e37469be1434642a3e403fce50a03
a605441e049f0b6d5f7715b94b8ac4662fd7fcf6
3 changes: 0 additions & 3 deletions rustfmt.toml

This file was deleted.

Loading