Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
JOE1994 authored Dec 27, 2019
2 parents 2ceffd0 + aafb7c9 commit 34d8a71
Show file tree
Hide file tree
Showing 30 changed files with 1,176 additions and 914 deletions.
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: 12 additions & 13 deletions benches/helpers/miri_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,26 @@ 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_interface::{interface, Queries};
use rustc_driver::Compilation;
use crate::test::Bencher;
use rustc_interface::{interface, Queries};

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 @@ -50,13 +53,9 @@ 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 @@
a605441e049f0b6d5f7715b94b8ac4662fd7fcf6
9ae6cedb8d1e37469be1434642a3e403fce50a03
3 changes: 3 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
use_small_heuristics = "Max"
version = "Two"
match_arm_blocks = false
Loading

0 comments on commit 34d8a71

Please sign in to comment.