Skip to content

Commit

Permalink
Normalize variants of Passes to standard style
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Aug 4, 2018
1 parent 2a93442 commit b3267dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
20 changes: 9 additions & 11 deletions src/librustc/session/config.rs
Expand Up @@ -12,7 +12,6 @@
//! command line options.

pub use self::EntryFnType::*;
pub use self::Passes::*;
pub use self::DebugInfoLevel::*;

use std::str::FromStr;
Expand Down Expand Up @@ -679,15 +678,15 @@ pub enum CrateType {

#[derive(Clone, Hash)]
pub enum Passes {
SomePasses(Vec<String>),
AllPasses,
Some(Vec<String>),
All,
}

impl Passes {
pub fn is_empty(&self) -> bool {
match *self {
SomePasses(ref v) => v.is_empty(),
AllPasses => false,
Passes::Some(ref v) => v.is_empty(),
Passes::All => false,
}
}
}
Expand Down Expand Up @@ -822,8 +821,7 @@ macro_rules! options {

#[allow(dead_code)]
mod $mod_set {
use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer, Lto,
CrossLangLto};
use super::{$struct_name, Passes, Sanitizer, Lto, CrossLangLto};
use rustc_target::spec::{LinkerFlavor, PanicStrategy, RelroLevel};
use std::path::PathBuf;

Expand Down Expand Up @@ -934,13 +932,13 @@ macro_rules! options {
fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
match v {
Some("all") => {
*slot = AllPasses;
*slot = Passes::All;
true
}
v => {
let mut passes = vec![];
if parse_list(&mut passes, v) {
*slot = SomePasses(passes);
*slot = Passes::Some(passes);
true
} else {
false
Expand Down Expand Up @@ -1103,7 +1101,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
"extra data to put in each output filename"),
codegen_units: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
"divide crate into N units to optimize in parallel"),
remark: Passes = (SomePasses(Vec::new()), parse_passes, [UNTRACKED],
remark: Passes = (Passes::Some(Vec::new()), parse_passes, [UNTRACKED],
"print remarks for these optimization passes (space separated, or \"all\")"),
no_stack_check: bool = (false, parse_bool, [UNTRACKED],
"the --no-stack-check flag is deprecated and does nothing"),
Expand Down Expand Up @@ -2946,7 +2944,7 @@ mod tests {
opts.cg.codegen_units = Some(42);
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());

opts.cg.remark = super::SomePasses(vec![String::from("pass1"), String::from("pass2")]);
opts.cg.remark = super::Passes::Some(vec![String::from("pass1"), String::from("pass2")]);
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());

opts.cg.save_temps = true;
Expand Down
7 changes: 3 additions & 4 deletions src/librustc_codegen_llvm/back/write.rs
Expand Up @@ -20,8 +20,7 @@ use consts;
use rustc_incremental::{copy_cgu_workproducts_to_incr_comp_cache_dir, in_incr_comp_dir};
use rustc::dep_graph::{WorkProduct, WorkProductId, WorkProductFileKind};
use rustc::middle::cstore::{LinkMeta, EncodedMetadata};
use rustc::session::config::{self, OutputFilenames, OutputType, Passes, SomePasses,
AllPasses, Sanitizer, Lto};
use rustc::session::config::{self, OutputFilenames, OutputType, Passes, Sanitizer, Lto};
use rustc::session::Session;
use rustc::util::nodemap::FxHashMap;
use time_graph::{self, TimeGraph, Timeline};
Expand Down Expand Up @@ -461,8 +460,8 @@ unsafe extern "C" fn diagnostic_handler(info: &DiagnosticInfo, user: *mut c_void

llvm::diagnostic::Optimization(opt) => {
let enabled = match cgcx.remark {
AllPasses => true,
SomePasses(ref v) => v.iter().any(|s| *s == opt.pass_name),
Passes::All => true,
Passes::Some(ref v) => v.iter().any(|s| *s == opt.pass_name),
};

if enabled {
Expand Down

0 comments on commit b3267dc

Please sign in to comment.