From 177f9f91708180d70b9b92a76a6bdbb84999d2c4 Mon Sep 17 00:00:00 2001 From: Matthew Hammer Date: Tue, 23 May 2017 14:49:08 -0600 Subject: [PATCH 001/123] add '-Z profile-queries' debug flag --- src/librustc/session/config.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 4212fa1f8b12e..ad2b2eb342c0f 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -973,6 +973,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv)"), query_dep_graph: bool = (false, parse_bool, [UNTRACKED], "enable queries of the dependency graph for regression testing"), + profile_queries: bool = (false, parse_bool, [UNTRACKED], + "trace and profile the queries of the incremental compilation framework"), no_analysis: bool = (false, parse_bool, [UNTRACKED], "parse and expand the source, but run no analysis"), extra_plugins: Vec = (Vec::new(), parse_list, [TRACKED], @@ -2499,6 +2501,8 @@ mod tests { assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); opts.debugging_opts.query_dep_graph = true; assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); + opts.profile_queries = true; + assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); opts.debugging_opts.no_analysis = true; assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); opts.debugging_opts.unstable_options = true; From 46e04f1055e1c96d99b729012cd8a0223d5596fc Mon Sep 17 00:00:00 2001 From: Matthew Hammer Date: Tue, 23 May 2017 16:20:12 -0600 Subject: [PATCH 002/123] send QueryBegin message on channel; TODO-Send: actually create the channel in driver, and a thread to listen on other end --- src/librustc/session/mod.rs | 1 + src/librustc/ty/context.rs | 23 +++++++++++++++++++++++ src/librustc/ty/maps.rs | 9 +++++++++ 3 files changed, 33 insertions(+) diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 814246330a4c2..b6c7a5e9f4d27 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -352,6 +352,7 @@ impl Session { } pub fn verbose(&self) -> bool { self.opts.debugging_opts.verbose } pub fn time_passes(&self) -> bool { self.opts.debugging_opts.time_passes } + pub fn profile_queries(&self) -> bool { self.opts.debugging_opts.profile_queries } pub fn count_llvm_insns(&self) -> bool { self.opts.debugging_opts.count_llvm_insns } diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index b9355c264b3ef..67b6b47c9d117 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -40,6 +40,8 @@ use ty::layout::{Layout, TargetDataLayout}; use ty::inhabitedness::DefIdForest; use ty::maps; use ty::steal::Steal; +use ty::maps::{Query}; + use util::nodemap::{NodeMap, NodeSet, DefIdMap, DefIdSet}; use util::nodemap::{FxHashMap, FxHashSet}; use rustc_data_structures::accumulate_vec::AccumulateVec; @@ -54,10 +56,13 @@ use std::mem; use std::ops::Deref; use std::iter; use std::rc::Rc; +use std::sync::mpsc::{Sender}; + use syntax::abi; use syntax::ast::{self, Name, NodeId}; use syntax::attr; use syntax::symbol::{Symbol, keywords}; +use syntax_pos::{Span}; use hir; @@ -422,6 +427,20 @@ impl<'a, 'gcx, 'tcx> Deref for TyCtxt<'a, 'gcx, 'tcx> { } } +/// A sequence of these messages induce a trace of query-based incremental compilation. +/// TODO(matthewhammer): Determine whether we should include cycle detection here or not. +#[derive(Clone)] +pub enum ProfileQueriesMsg<'a> { + /// begin a new query + QueryBegin(Span,Query<'a>), + /// query is satisfied by using an already-known value for the given key + CacheHit, + /// query requires running a provider; providers may nest, permitting queries to nest. + ProviderBegin, + /// query is satisfied by a provider terminating with a value + ProviderEnd, +} + pub struct GlobalCtxt<'tcx> { global_arenas: &'tcx GlobalArenas<'tcx>, global_interners: CtxtInterners<'tcx>, @@ -434,6 +453,9 @@ pub struct GlobalCtxt<'tcx> { pub dep_graph: DepGraph, + /// Initialized for -Z profile-queries + pub profile_queries_sender: RefCell>>>, + /// Common types, pre-interned for your convenience. pub types: CommonTypes<'tcx>, @@ -710,6 +732,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { global_arenas: arenas, global_interners: interners, dep_graph: dep_graph.clone(), + profile_queries_sender:RefCell::new(None), types: common_types, named_region_map: named_region_map, trait_map: resolutions.trait_map, diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index f448ca8934732..21552cb3bb6fb 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -459,6 +459,15 @@ macro_rules! define_maps { key, span); + // XXX + if tcx.sess.profile_queries() { + use ty::context::ProfileQueriesMsg; + let s = span.clone(); + let q = Query::$name(key.clone()); + tcx.profile_queries_sender.borrow().as_ref().unwrap() + .send(ProfileQueriesMsg::QueryBegin(s, q)).unwrap() + } + if let Some(result) = tcx.maps.$name.borrow().get(&key) { return Ok(f(result)); } From dfa863c2ddce33fb6d187006a2deb968e9c75e0e Mon Sep 17 00:00:00 2001 From: Matthew Hammer Date: Tue, 23 May 2017 19:57:05 -0600 Subject: [PATCH 003/123] profile_queries_msg macro; all messages in place --- src/librustc/ty/maps.rs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index 21552cb3bb6fb..35b4623b9c035 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -22,6 +22,7 @@ use ty::{self, CrateInherentImpls, Ty, TyCtxt}; use ty::item_path; use ty::steal::Steal; use ty::subst::Substs; +use ty::context::ProfileQueriesMsg; use util::nodemap::{DefIdSet, NodeSet}; use rustc_data_structures::indexed_vec::IndexVec; @@ -391,6 +392,15 @@ impl<'tcx> QueryDescription for queries::is_mir_available<'tcx> { } } +macro_rules! profile_queries_msg { + ($tcx:expr, $msg:expr) => { + if $tcx.sess.profile_queries() { + $tcx.profile_queries_sender.borrow().as_ref().unwrap() + .send($msg).unwrap() + } + } +} + macro_rules! define_maps { (<$tcx:tt> $($(#[$attr:meta])* @@ -459,16 +469,13 @@ macro_rules! define_maps { key, span); - // XXX - if tcx.sess.profile_queries() { - use ty::context::ProfileQueriesMsg; - let s = span.clone(); - let q = Query::$name(key.clone()); - tcx.profile_queries_sender.borrow().as_ref().unwrap() - .send(ProfileQueriesMsg::QueryBegin(s, q)).unwrap() - } + profile_queries_msg! + (tcx, + ProfileQueriesMsg::QueryBegin(span.clone(), + Query::$name(key.clone()))); if let Some(result) = tcx.maps.$name.borrow().get(&key) { + profile_queries_msg!(tcx, ProfileQueriesMsg::CacheHit); return Ok(f(result)); } @@ -481,10 +488,12 @@ macro_rules! define_maps { let _task = tcx.dep_graph.in_task(Self::to_dep_node(&key)); + profile_queries_msg!(tcx, ProfileQueriesMsg::ProviderBegin); let result = tcx.cycle_check(span, Query::$name(key), || { let provider = tcx.maps.providers[key.map_crate()].$name; provider(tcx.global_tcx(), key) })?; + profile_queries_msg!(tcx, ProfileQueriesMsg::ProviderEnd); Ok(f(tcx.maps.$name.borrow_mut().entry(key).or_insert(result))) } From aa5becd2bfdf7c64783e5d61ba98151ec9add384 Mon Sep 17 00:00:00 2001 From: Matthew Hammer Date: Wed, 24 May 2017 11:13:48 -0600 Subject: [PATCH 004/123] spawning thread, but getting the compiler to overflow in some checks: https://gist.github.com/matthewhammer/209bb7ebaf3f9d4470cb96d406056576 --- src/librustc/ty/maps.rs | 1 + src/librustc/ty/mod.rs | 2 +- src/librustc_driver/driver.rs | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index 35b4623b9c035..e33d8869d7cca 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -392,6 +392,7 @@ impl<'tcx> QueryDescription for queries::is_mir_available<'tcx> { } } +// If enabled, send a message to the profile-queries thread macro_rules! profile_queries_msg { ($tcx:expr, $msg:expr) => { if $tcx.sess.profile_queries() { diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 6ca401d27ac72..31afc76824da6 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -75,7 +75,7 @@ pub use self::sty::InferTy::*; pub use self::sty::RegionKind::*; pub use self::sty::TypeVariants::*; -pub use self::context::{TyCtxt, GlobalArenas, tls}; +pub use self::context::{TyCtxt, GlobalArenas, tls, ProfileQueriesMsg}; pub use self::context::{Lift, TypeckTables}; pub use self::instance::{Instance, InstanceDef}; diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index eff5d2b2f37f1..7258653bba088 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -21,7 +21,7 @@ use rustc::lint; use rustc::middle::{self, dependency_format, stability, reachable}; use rustc::middle::privacy::AccessLevels; use rustc::mir::transform::{MIR_CONST, MIR_VALIDATED, MIR_OPTIMIZED, Passes}; -use rustc::ty::{self, TyCtxt, Resolutions, GlobalArenas}; +use rustc::ty::{self, TyCtxt, Resolutions, GlobalArenas, ProfileQueriesMsg}; use rustc::util::common::time; use rustc::util::nodemap::NodeSet; use rustc::util::fs::rename_or_copy_remove; @@ -49,6 +49,8 @@ use std::io::{self, Write}; use std::iter; use std::path::{Path, PathBuf}; use std::rc::Rc; +use std::sync::mpsc::{channel,Receiver}; + use syntax::{ast, diagnostics, visit}; use syntax::attr; use syntax::ext::base::ExtCtxt; @@ -826,6 +828,11 @@ pub fn phase_2_configure_and_expand(sess: &Session, }) } +pub fn profile_queries_thread<'tcx>(r:Receiver>) { + // XXX + panic!("TODO") +} + /// Run the resolution, typechecking, region checking and other /// miscellaneous analysis passes on the crate. Return various /// structures carrying the results of the analysis. @@ -952,6 +959,15 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session, index, name, |tcx| { + + if tcx.sess.profile_queries() { + use std::thread; + use std::sync::mpsc::{channel,Receiver}; + let (tx, rx) = channel(); + *tcx.profile_queries_sender.borrow_mut() = Some(tx); + thread::spawn(move||profile_queries_thread(rx)); + } + let incremental_hashes_map = time(time_passes, "compute_incremental_hashes_map", From 86fb705bca2e4ffb86c9e738143438942ad442f4 Mon Sep 17 00:00:00 2001 From: Matthew Hammer Date: Wed, 24 May 2017 13:14:18 -0600 Subject: [PATCH 005/123] avoid tcx lifetime in the inter-thread profile-queries messages --- src/librustc/ty/context.rs | 8 ++++---- src/librustc/ty/maps.rs | 8 +++++++- src/librustc_driver/driver.rs | 6 +++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 67b6b47c9d117..d8a5ca778c3f9 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -40,7 +40,7 @@ use ty::layout::{Layout, TargetDataLayout}; use ty::inhabitedness::DefIdForest; use ty::maps; use ty::steal::Steal; -use ty::maps::{Query}; +use ty::maps::{QueryMsg}; use util::nodemap::{NodeMap, NodeSet, DefIdMap, DefIdSet}; use util::nodemap::{FxHashMap, FxHashSet}; @@ -430,9 +430,9 @@ impl<'a, 'gcx, 'tcx> Deref for TyCtxt<'a, 'gcx, 'tcx> { /// A sequence of these messages induce a trace of query-based incremental compilation. /// TODO(matthewhammer): Determine whether we should include cycle detection here or not. #[derive(Clone)] -pub enum ProfileQueriesMsg<'a> { +pub enum ProfileQueriesMsg { /// begin a new query - QueryBegin(Span,Query<'a>), + QueryBegin(Span,QueryMsg), /// query is satisfied by using an already-known value for the given key CacheHit, /// query requires running a provider; providers may nest, permitting queries to nest. @@ -454,7 +454,7 @@ pub struct GlobalCtxt<'tcx> { pub dep_graph: DepGraph, /// Initialized for -Z profile-queries - pub profile_queries_sender: RefCell>>>, + pub profile_queries_sender: RefCell>>, /// Common types, pre-interned for your convenience. pub types: CommonTypes<'tcx>, diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index e33d8869d7cca..940d9e4e96ac8 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -429,6 +429,12 @@ macro_rules! define_maps { $($(#[$attr])* $name($K)),* } + #[allow(bad_style)] + #[derive(Clone, Debug, PartialEq, Eq)] + pub enum QueryMsg { + $($name(String)),* + } + impl<$tcx> Query<$tcx> { pub fn describe(&self, tcx: TyCtxt) -> String { match *self { @@ -473,7 +479,7 @@ macro_rules! define_maps { profile_queries_msg! (tcx, ProfileQueriesMsg::QueryBegin(span.clone(), - Query::$name(key.clone()))); + QueryMsg::$name(format!("{:?}", key)))); if let Some(result) = tcx.maps.$name.borrow().get(&key) { profile_queries_msg!(tcx, ProfileQueriesMsg::CacheHit); diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 7258653bba088..0fb2c461543f9 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -49,7 +49,7 @@ use std::io::{self, Write}; use std::iter; use std::path::{Path, PathBuf}; use std::rc::Rc; -use std::sync::mpsc::{channel,Receiver}; +use std::sync::mpsc::{Receiver}; use syntax::{ast, diagnostics, visit}; use syntax::attr; @@ -828,7 +828,7 @@ pub fn phase_2_configure_and_expand(sess: &Session, }) } -pub fn profile_queries_thread<'tcx>(r:Receiver>) { +pub fn profile_queries_thread(_r:Receiver) { // XXX panic!("TODO") } @@ -962,7 +962,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session, if tcx.sess.profile_queries() { use std::thread; - use std::sync::mpsc::{channel,Receiver}; + use std::sync::mpsc::{channel}; let (tx, rx) = channel(); *tcx.profile_queries_sender.borrow_mut() = Some(tx); thread::spawn(move||profile_queries_thread(rx)); From 9d71b2129c2c257ab932131ef44e4360bd682458 Mon Sep 17 00:00:00 2001 From: Matthew Hammer Date: Tue, 6 Jun 2017 14:35:02 -0600 Subject: [PATCH 006/123] add control messages (halt and dump); parse traces to dump --- src/librustc/ty/context.rs | 4 ++ src/librustc_driver/driver.rs | 124 +++++++++++++++++++++++++++++++++- 2 files changed, 125 insertions(+), 3 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index d8a5ca778c3f9..6daec6fdc7d28 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -439,6 +439,10 @@ pub enum ProfileQueriesMsg { ProviderBegin, /// query is satisfied by a provider terminating with a value ProviderEnd, + /// dump a record of the queries to the given path + Dump(String), + /// stop the profilequeriesmsg service + Halt } pub struct GlobalCtxt<'tcx> { diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 0fb2c461543f9..3f4717a6e02b4 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -828,9 +828,127 @@ pub fn phase_2_configure_and_expand(sess: &Session, }) } -pub fn profile_queries_thread(_r:Receiver) { - // XXX - panic!("TODO") +mod trace { + use super::*; + use syntax_pos::Span; + use self::ty::maps::QueryMsg; + + #[derive(Debug,Clone)] + pub struct Query { + pub span: Span, + pub msg: QueryMsg, + } + pub enum Effect { + QueryBegin(Query,CacheCase), + } + pub enum CacheCase { + Hit, Miss + } + /// Recursive trace structure + pub struct Rec { + pub effect: Effect, + pub extent: Box> + } + /// State for parsing recursive trace structure + #[derive(Clone)] + pub enum ParseState { + NoQuery, + HaveQuery(Query), + RunningProvider(Query), + } + pub struct StackFrame { + pub parse_st: ParseState, + pub traces: Vec, + } +} + +pub fn profile_queries_thread(r:Receiver) { + use self::trace::*; + //use std::sync::mpsc::*; // for Receiver + + let mut queries : Vec = vec![]; + let mut frame : StackFrame = StackFrame{ parse_st:ParseState::NoQuery, traces:vec![] }; + let mut stack : Vec = vec![]; + loop { + let msg = r.recv().unwrap(); + // Meta-level versus _actual_ queries messages + match msg { + ProfileQueriesMsg::Halt => return, + ProfileQueriesMsg::Dump(path) => { + panic!("XXX:TODO: Dump: {:?}", path) + } + // Actual query message: + msg => { + queries.push(msg.clone()); + match (frame.parse_st.clone(), msg) { + (_,ProfileQueriesMsg::Halt) => unreachable!(), + (_,ProfileQueriesMsg::Dump(_)) => unreachable!(), + + // QueryBegin + (ParseState::HaveQuery(q1), + ProfileQueriesMsg::QueryBegin(span2,querymsg2)) => { + panic!("parse error: first query is unfinished: {:?} and now {:?}", + q1, Query{span:span2, msg:querymsg2}) + }, + (ParseState::NoQuery, + ProfileQueriesMsg::QueryBegin(span,querymsg)) => { + frame.parse_st = ParseState::HaveQuery(Query{span:span, msg:querymsg}) + } + // CacheHit + (ParseState::NoQuery, + ProfileQueriesMsg::CacheHit) => { + panic!("parse error: CacheHit before QueryBegin") + } + (ParseState::HaveQuery(q), + ProfileQueriesMsg::CacheHit) => { + let trace : Rec = Rec{ + effect: Effect::QueryBegin(q, CacheCase::Hit), + extent: Box::new(vec![]) + }; + frame.traces.push( trace ); + } + // ProviderBegin + (ParseState::NoQuery, + ProfileQueriesMsg::ProviderBegin) => { + panic!("parse error: expected a query before beginning a provider") + }, + (ParseState::HaveQuery(q), + ProfileQueriesMsg::ProviderBegin) => { + frame.parse_st = ParseState::RunningProvider(q); + let old_frame = frame; + stack.push(old_frame); + frame = StackFrame{parse_st:ParseState::NoQuery, traces:vec![]}; + } + // ProviderEnd + (ParseState::HaveQuery(q), + ProfileQueriesMsg::ProviderEnd) => { + panic!("parse error: expected something to following BeginQuery for {:?}", q) + }, + (ParseState::NoQuery, + ProfileQueriesMsg::ProviderEnd) => { + panic!("parse error") + }, + (ParseState::RunningProvider(q), + ProfileQueriesMsg::ProviderEnd) => { + match stack.pop() { + None => panic!("parse error: expected a stack frame"), + Some(old_frame) => { + let top_frame = frame; + frame = old_frame; + let trace : Rec = Rec { + effect: Effect::QueryBegin(q, CacheCase::Miss), + extent: Box::new(top_frame.traces) }; + frame.traces.push( trace ) + } + } + } + (ParseState::RunningProvider(q), _) => { + panic!("parse error: {:?}", q) + } + } + } + } + } } /// Run the resolution, typechecking, region checking and other From 741376be96e85cb7a21d299250c5c4087a3622fb Mon Sep 17 00:00:00 2001 From: Matthew Hammer Date: Wed, 14 Jun 2017 14:44:28 -0400 Subject: [PATCH 007/123] basic HTML output --- src/librustc_driver/driver.rs | 43 ++++++++++++++++++-- src/librustc_incremental/assert_dep_graph.rs | 7 ++++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 3f4717a6e02b4..5a3c2379d52ef 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -832,8 +832,9 @@ mod trace { use super::*; use syntax_pos::Span; use self::ty::maps::QueryMsg; + use std::fs::File; - #[derive(Debug,Clone)] + #[derive(Debug,Clone,Eq,PartialEq)] pub struct Query { pub span: Span, pub msg: QueryMsg, @@ -850,7 +851,7 @@ mod trace { pub extent: Box> } /// State for parsing recursive trace structure - #[derive(Clone)] + #[derive(Clone,Eq,PartialEq)] pub enum ParseState { NoQuery, HaveQuery(Query), @@ -860,10 +861,40 @@ mod trace { pub parse_st: ParseState, pub traces: Vec, } -} + + pub fn css_class_of_query_msg(qmsg:&trace::Query) -> String { + let debugstr = format!("{:?}", qmsg); + let cons : Vec<&str> = debugstr.trim().split("(").collect(); + assert!(cons.len() > 0 && cons[0] != ""); + cons[0].to_string() + } + + pub fn css_class_of_effect(eff:&Effect) -> String { + match *eff { + Effect::QueryBegin(ref qmsg, ref cc) => { + format!("{} {}", + css_class_of_query_msg(qmsg), + match *cc { + CacheCase::Hit => "hit", + CacheCase::Miss => "miss", + }) + } + } + } + + pub fn write_traces(file:&mut File, traces:&Vec) { + for t in traces { + write!(file, "
", css_class_of_effect(&t.effect)).unwrap(); + write_traces(file, &t.extent); + write!(file, "
").unwrap(); + } + } +} + pub fn profile_queries_thread(r:Receiver) { use self::trace::*; + use std::fs::File; //use std::sync::mpsc::*; // for Receiver let mut queries : Vec = vec![]; @@ -875,7 +906,11 @@ pub fn profile_queries_thread(r:Receiver) { match msg { ProfileQueriesMsg::Halt => return, ProfileQueriesMsg::Dump(path) => { - panic!("XXX:TODO: Dump: {:?}", path) + assert!(stack.len() == 0); + assert!(frame.parse_st == trace::ParseState::NoQuery); + let html_path = format!("{}.html", path); + let mut file = File::create(&html_path).unwrap(); + trace::write_traces(&mut file, &frame.traces); } // Actual query message: msg => { diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index 39fe2188f68d1..4c5d8c2be9798 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -63,6 +63,13 @@ use syntax_pos::Span; pub fn assert_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let _ignore = tcx.dep_graph.in_ignore(); + if tcx.sess.profile_queries() { + tcx.profile_queries_sender.borrow().as_ref().unwrap() + .send( + ProfileQueriesMsg::Dump("dep-graph") + ).unwrap() + } + if tcx.sess.opts.debugging_opts.dump_dep_graph { dump_graph(tcx); } From d8569ebc665605fe267d95d871db2173cfdc1eb8 Mon Sep 17 00:00:00 2001 From: Matthew Hammer Date: Wed, 14 Jun 2017 17:37:22 -0400 Subject: [PATCH 008/123] profile-queries: test runs; debugging; now crashes with 'cannot access stdout during shutdown' --- src/librustc/ty/context.rs | 2 +- src/librustc/ty/maps.rs | 5 +- src/librustc_driver/driver.rs | 90 ++++++++++---------- src/librustc_incremental/assert_dep_graph.rs | 3 +- 4 files changed, 52 insertions(+), 48 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 6daec6fdc7d28..be4c8baf78804 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -429,7 +429,7 @@ impl<'a, 'gcx, 'tcx> Deref for TyCtxt<'a, 'gcx, 'tcx> { /// A sequence of these messages induce a trace of query-based incremental compilation. /// TODO(matthewhammer): Determine whether we should include cycle detection here or not. -#[derive(Clone)] +#[derive(Clone,Debug)] pub enum ProfileQueriesMsg { /// begin a new query QueryBegin(Span,QueryMsg), diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index 940d9e4e96ac8..4393645d202dd 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -22,7 +22,7 @@ use ty::{self, CrateInherentImpls, Ty, TyCtxt}; use ty::item_path; use ty::steal::Steal; use ty::subst::Substs; -use ty::context::ProfileQueriesMsg; +use ty::ProfileQueriesMsg; use util::nodemap::{DefIdSet, NodeSet}; use rustc_data_structures::indexed_vec::IndexVec; @@ -485,6 +485,8 @@ macro_rules! define_maps { profile_queries_msg!(tcx, ProfileQueriesMsg::CacheHit); return Ok(f(result)); } + // else, we are going to run the provider: + profile_queries_msg!(tcx, ProfileQueriesMsg::ProviderBegin); // FIXME(eddyb) Get more valid Span's on queries. // def_span guard is necesary to prevent a recursive loop, @@ -495,7 +497,6 @@ macro_rules! define_maps { let _task = tcx.dep_graph.in_task(Self::to_dep_node(&key)); - profile_queries_msg!(tcx, ProfileQueriesMsg::ProviderBegin); let result = tcx.cycle_check(span, Query::$name(key), || { let provider = tcx.maps.providers[key.map_crate()].$name; provider(tcx.global_tcx(), key) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 5a3c2379d52ef..65c400f868b64 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -837,13 +837,13 @@ mod trace { #[derive(Debug,Clone,Eq,PartialEq)] pub struct Query { pub span: Span, - pub msg: QueryMsg, + pub msg: QueryMsg, } pub enum Effect { QueryBegin(Query,CacheCase), } pub enum CacheCase { - Hit, Miss + Hit, Miss } /// Recursive trace structure pub struct Rec { @@ -855,7 +855,7 @@ mod trace { pub enum ParseState { NoQuery, HaveQuery(Query), - RunningProvider(Query), + //RunningProvider(Query), } pub struct StackFrame { pub parse_st: ParseState, @@ -902,6 +902,7 @@ pub fn profile_queries_thread(r:Receiver) { let mut stack : Vec = vec![]; loop { let msg = r.recv().unwrap(); + println!("profile_queries_thread: {:?}", msg); // Meta-level versus _actual_ queries messages match msg { ProfileQueriesMsg::Halt => return, @@ -911,6 +912,7 @@ pub fn profile_queries_thread(r:Receiver) { let html_path = format!("{}.html", path); let mut file = File::create(&html_path).unwrap(); trace::write_traces(&mut file, &frame.traces); + continue } // Actual query message: msg => { @@ -919,21 +921,44 @@ pub fn profile_queries_thread(r:Receiver) { (_,ProfileQueriesMsg::Halt) => unreachable!(), (_,ProfileQueriesMsg::Dump(_)) => unreachable!(), - // QueryBegin - (ParseState::HaveQuery(q1), - ProfileQueriesMsg::QueryBegin(span2,querymsg2)) => { - panic!("parse error: first query is unfinished: {:?} and now {:?}", - q1, Query{span:span2, msg:querymsg2}) - }, + // Parse State: NoQuery (ParseState::NoQuery, ProfileQueriesMsg::QueryBegin(span,querymsg)) => { frame.parse_st = ParseState::HaveQuery(Query{span:span, msg:querymsg}) - } - // CacheHit + }, (ParseState::NoQuery, ProfileQueriesMsg::CacheHit) => { - panic!("parse error: CacheHit before QueryBegin") + panic!("parse error: unexpected CacheHit; expected QueryBegin") + }, + (ParseState::NoQuery, + ProfileQueriesMsg::ProviderBegin) => { + panic!("parse error: expected QueryBegin before beginning a provider") + }, + (ParseState::NoQuery, + ProfileQueriesMsg::ProviderEnd) => { + let provider_extent = frame.traces; + match stack.pop() { + None => panic!("parse error: expected a stack frame; found an empty stack"), + Some(old_frame) => { + match old_frame.parse_st { + ParseState::NoQuery => panic!("parse error: expected a stack frame for a query"), + ParseState::HaveQuery(q) => { + frame = StackFrame{ + parse_st:ParseState::NoQuery, + traces:old_frame.traces + }; + let trace = Rec { + effect: Effect::QueryBegin(q, CacheCase::Miss), + extent: Box::new(provider_extent) + }; + frame.traces.push( trace ); + } + } + } + } } + + // Parse State: HaveQuery (ParseState::HaveQuery(q), ProfileQueriesMsg::CacheHit) => { let trace : Rec = Rec{ @@ -941,45 +966,22 @@ pub fn profile_queries_thread(r:Receiver) { extent: Box::new(vec![]) }; frame.traces.push( trace ); - } - // ProviderBegin - (ParseState::NoQuery, - ProfileQueriesMsg::ProviderBegin) => { - panic!("parse error: expected a query before beginning a provider") + frame.parse_st = ParseState::NoQuery; }, - (ParseState::HaveQuery(q), + (ParseState::HaveQuery(_q), ProfileQueriesMsg::ProviderBegin) => { - frame.parse_st = ParseState::RunningProvider(q); - let old_frame = frame; - stack.push(old_frame); + stack.push(frame); frame = StackFrame{parse_st:ParseState::NoQuery, traces:vec![]}; - } - // ProviderEnd + }, (ParseState::HaveQuery(q), ProfileQueriesMsg::ProviderEnd) => { - panic!("parse error: expected something to following BeginQuery for {:?}", q) + panic!("parse error: unexpected ProviderEnd; expected something else to follow BeginQuery for {:?}", q) }, - (ParseState::NoQuery, - ProfileQueriesMsg::ProviderEnd) => { - panic!("parse error") + (ParseState::HaveQuery(q1), + ProfileQueriesMsg::QueryBegin(span2,querymsg2)) => { + panic!("parse error: unexpected QueryBegin; earlier query is unfinished: {:?} and now {:?}", + q1, Query{span:span2, msg:querymsg2}) }, - (ParseState::RunningProvider(q), - ProfileQueriesMsg::ProviderEnd) => { - match stack.pop() { - None => panic!("parse error: expected a stack frame"), - Some(old_frame) => { - let top_frame = frame; - frame = old_frame; - let trace : Rec = Rec { - effect: Effect::QueryBegin(q, CacheCase::Miss), - extent: Box::new(top_frame.traces) }; - frame.traces.push( trace ) - } - } - } - (ParseState::RunningProvider(q), _) => { - panic!("parse error: {:?}", q) - } } } } diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index 4c5d8c2be9798..dd49d13cc52ce 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -59,6 +59,7 @@ use std::fs::File; use std::io::Write; use syntax::ast; use syntax_pos::Span; +use rustc::ty::ProfileQueriesMsg; pub fn assert_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let _ignore = tcx.dep_graph.in_ignore(); @@ -66,7 +67,7 @@ pub fn assert_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { if tcx.sess.profile_queries() { tcx.profile_queries_sender.borrow().as_ref().unwrap() .send( - ProfileQueriesMsg::Dump("dep-graph") + ProfileQueriesMsg::Dump("dep-graph".to_string()) ).unwrap() } From 947c1a7d337e13a1f6b3b407a2cb4b889f26d398 Mon Sep 17 00:00:00 2001 From: Matthew Hammer Date: Wed, 14 Jun 2017 19:08:33 -0400 Subject: [PATCH 009/123] detect closed channel; text with query constructor string in final HTML --- src/librustc_driver/driver.rs | 71 ++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 17 deletions(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 65c400f868b64..33375502217cd 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -862,33 +862,53 @@ mod trace { pub traces: Vec, } - pub fn css_class_of_query_msg(qmsg:&trace::Query) -> String { - let debugstr = format!("{:?}", qmsg); - let cons : Vec<&str> = debugstr.trim().split("(").collect(); + pub fn cons_of_query_msg(q:&trace::Query) -> String { + let s = format!("{:?}", q.msg); + let cons: Vec<&str> = s.split(|d| d == '(' || d == '{').collect(); assert!(cons.len() > 0 && cons[0] != ""); cons[0].to_string() } - - pub fn css_class_of_effect(eff:&Effect) -> String { + + // First return value is text; second return value is a CSS class + pub fn html_of_effect(eff:&Effect) -> (String, String) { match *eff { Effect::QueryBegin(ref qmsg, ref cc) => { - format!("{} {}", - css_class_of_query_msg(qmsg), + let cons = cons_of_query_msg(qmsg); + (cons.clone(), + format!("{} {}", + cons, match *cc { CacheCase::Hit => "hit", CacheCase::Miss => "miss", - }) + })) } } } - pub fn write_traces(file:&mut File, traces:&Vec) { + fn write_traces_rec(file:&mut File, traces:&Vec, depth:usize) { for t in traces { - write!(file, "
", css_class_of_effect(&t.effect)).unwrap(); - write_traces(file, &t.extent); - write!(file, "
").unwrap(); + let (eff_text, eff_css_classes) = html_of_effect(&t.effect); + write!(file, "
\n", + depth, + t.extent.len(), + if t.extent.len() > 5 { + // query symbol_name has extent 5, and is very common + // query def_symbol_name has extent 6, and is somewhat common + " extent-big" + } else { "" }, + eff_css_classes, + ).unwrap(); + write!(file, "{}\n", eff_text).unwrap(); + write_traces_rec(file, &t.extent, depth + 1); + write!(file, "
\n").unwrap(); } } + + pub fn write_traces(html_file:&mut File, _counts_file:&mut File, traces:&Vec) { + // XXX/TODO: Populate counts_file with counts for each constructor (a histogram of constructor occurrences) + write_traces_rec(html_file, traces, 0) + } + } @@ -901,17 +921,34 @@ pub fn profile_queries_thread(r:Receiver) { let mut frame : StackFrame = StackFrame{ parse_st:ParseState::NoQuery, traces:vec![] }; let mut stack : Vec = vec![]; loop { - let msg = r.recv().unwrap(); - println!("profile_queries_thread: {:?}", msg); + let msg = r.recv(); + if let Err(_recv_err) = msg { + // TODO: Perhaps do something smarter than simply quitting? + break + }; + let msg = msg.unwrap(); + debug!("profile_queries_thread: {:?}", msg); + // Meta-level versus _actual_ queries messages match msg { ProfileQueriesMsg::Halt => return, ProfileQueriesMsg::Dump(path) => { assert!(stack.len() == 0); assert!(frame.parse_st == trace::ParseState::NoQuery); - let html_path = format!("{}.html", path); - let mut file = File::create(&html_path).unwrap(); - trace::write_traces(&mut file, &frame.traces); + { // write HTML file + let html_path = format!("{}.html", path); + let mut html_file = File::create(&html_path).unwrap(); + + let counts_path = format!("{}.counts.txt", path); + let mut counts_file = File::create(&counts_path).unwrap(); + + write!(html_file, "\n").unwrap(); + write!(html_file, "\n\n", + "dep-graph.css").unwrap(); + write!(html_file, "\n").unwrap(); + trace::write_traces(&mut html_file, &mut counts_file, &frame.traces); + write!(html_file, "\n\n").unwrap(); + } continue } // Actual query message: From 84b880d55e5b154d9649107ac583de7591a81823 Mon Sep 17 00:00:00 2001 From: Stefan Schindler Date: Thu, 15 Jun 2017 11:36:32 +0200 Subject: [PATCH 010/123] Add hint about the return code of panic! --- src/libcore/macros.rs | 2 +- src/libstd/macros.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index d68fad4972c68..537d925c8fa7c 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -456,7 +456,7 @@ macro_rules! writeln { /// /// # Panics /// -/// This will always panic. +/// This will always [panic!](macro.panic.html). /// /// # Examples /// diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index df3fce0da765d..547e840ffb7f3 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -24,6 +24,8 @@ /// The multi-argument form of this macro panics with a string and has the /// `format!` syntax for building a string. /// +/// If the main thread panics it will return with code `101`. +/// /// # Examples /// /// ```should_panic From b4ceece9c4506a73e56ace84ebcfaef448045561 Mon Sep 17 00:00:00 2001 From: Matthew Hammer Date: Thu, 15 Jun 2017 10:52:10 -0400 Subject: [PATCH 011/123] add CSS style to rust code; change filename to 'profile_queries.html' --- src/librustc_driver/driver.rs | 44 +++++++++++++++++++- src/librustc_incremental/assert_dep_graph.rs | 2 +- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 33375502217cd..d0410351fd832 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -909,6 +909,42 @@ mod trace { write_traces_rec(html_file, traces, 0) } + pub fn write_style(html_file:&mut File) { + write!(html_file,"{}", " +body { + font-family: sans-serif; + background: black; +} +div { + color: black; + display: inline-block; + border-style: solid; + border-color: red; + border-width: 1px; + border-radius: 5px; + padding: 0px; + margin: 1px; + font-size: 0px; +} +.miss { + border-color: red; + border-width: 1px; +} +.extent-0 { + padding: 2px; +} +.extent-big { + border-width: 3px; + font-size: 12px; + color: white; +} +.hit { + padding: 0px; + border-color: blue; + border-width: 3px; +} +").unwrap(); + } } @@ -943,8 +979,12 @@ pub fn profile_queries_thread(r:Receiver) { let mut counts_file = File::create(&counts_path).unwrap(); write!(html_file, "\n").unwrap(); - write!(html_file, "\n\n", - "dep-graph.css").unwrap(); + write!(html_file, "\n\n", + "profile_queries.css").unwrap(); + write!(html_file, "\n").unwrap(); + write!(html_file, "\n").unwrap(); write!(html_file, "\n").unwrap(); trace::write_traces(&mut html_file, &mut counts_file, &frame.traces); write!(html_file, "\n\n").unwrap(); diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index dd49d13cc52ce..001660e423205 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -67,7 +67,7 @@ pub fn assert_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { if tcx.sess.profile_queries() { tcx.profile_queries_sender.borrow().as_ref().unwrap() .send( - ProfileQueriesMsg::Dump("dep-graph".to_string()) + ProfileQueriesMsg::Dump("profile_queries".to_string()) ).unwrap() } From 88610845fe6747489a8e42cb4bcf95f0ee003ce4 Mon Sep 17 00:00:00 2001 From: Matthew Hammer Date: Thu, 15 Jun 2017 11:37:09 -0400 Subject: [PATCH 012/123] tidiness checks pass --- src/librustc/ty/context.rs | 4 +-- src/librustc_driver/driver.rs | 52 +++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index be4c8baf78804..6d0dd525eb4aa 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -428,7 +428,7 @@ impl<'a, 'gcx, 'tcx> Deref for TyCtxt<'a, 'gcx, 'tcx> { } /// A sequence of these messages induce a trace of query-based incremental compilation. -/// TODO(matthewhammer): Determine whether we should include cycle detection here or not. +/// FIXME(matthewhammer): Determine whether we should include cycle detection here or not. #[derive(Clone,Debug)] pub enum ProfileQueriesMsg { /// begin a new query @@ -440,7 +440,7 @@ pub enum ProfileQueriesMsg { /// query is satisfied by a provider terminating with a value ProviderEnd, /// dump a record of the queries to the given path - Dump(String), + Dump(String), /// stop the profilequeriesmsg service Halt } diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index d0410351fd832..9c433adfeee59 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -833,7 +833,7 @@ mod trace { use syntax_pos::Span; use self::ty::maps::QueryMsg; use std::fs::File; - + #[derive(Debug,Clone,Eq,PartialEq)] pub struct Query { pub span: Span, @@ -842,7 +842,7 @@ mod trace { pub enum Effect { QueryBegin(Query,CacheCase), } - pub enum CacheCase { + pub enum CacheCase { Hit, Miss } /// Recursive trace structure @@ -868,9 +868,9 @@ mod trace { assert!(cons.len() > 0 && cons[0] != ""); cons[0].to_string() } - + // First return value is text; second return value is a CSS class - pub fn html_of_effect(eff:&Effect) -> (String, String) { + pub fn html_of_effect(eff:&Effect) -> (String, String) { match *eff { Effect::QueryBegin(ref qmsg, ref cc) => { let cons = cons_of_query_msg(qmsg); @@ -889,9 +889,9 @@ mod trace { for t in traces { let (eff_text, eff_css_classes) = html_of_effect(&t.effect); write!(file, "
\n", - depth, + depth, t.extent.len(), - if t.extent.len() > 5 { + if t.extent.len() > 5 { // query symbol_name has extent 5, and is very common // query def_symbol_name has extent 6, and is somewhat common " extent-big" @@ -905,7 +905,8 @@ mod trace { } pub fn write_traces(html_file:&mut File, _counts_file:&mut File, traces:&Vec) { - // XXX/TODO: Populate counts_file with counts for each constructor (a histogram of constructor occurrences) + // FIXME(matthewhammer): Populate counts_file with counts for + // each constructor (a histogram of constructor occurrences) write_traces_rec(html_file, traces, 0) } @@ -959,12 +960,12 @@ pub fn profile_queries_thread(r:Receiver) { loop { let msg = r.recv(); if let Err(_recv_err) = msg { - // TODO: Perhaps do something smarter than simply quitting? - break + // FIXME: Perhaps do something smarter than simply quitting? + break }; let msg = msg.unwrap(); debug!("profile_queries_thread: {:?}", msg); - + // Meta-level versus _actual_ queries messages match msg { ProfileQueriesMsg::Halt => return, @@ -974,12 +975,13 @@ pub fn profile_queries_thread(r:Receiver) { { // write HTML file let html_path = format!("{}.html", path); let mut html_file = File::create(&html_path).unwrap(); - + let counts_path = format!("{}.counts.txt", path); let mut counts_file = File::create(&counts_path).unwrap(); write!(html_file, "\n").unwrap(); - write!(html_file, "\n\n", + write!(html_file, + "\n\n", "profile_queries.css").unwrap(); write!(html_file, "\n").unwrap(); - write!(html_file, "\n").unwrap(); - write!(html_file, "\n").unwrap(); - trace::write_traces(&mut html_file, &mut counts_file, &frame.traces); - write!(html_file, "\n\n").unwrap(); - } - continue - } - // Actual query message: - msg => { - queries.push(msg.clone()); - match (frame.parse_st.clone(), msg) { - (_,ProfileQueriesMsg::Halt) => unreachable!(), - (_,ProfileQueriesMsg::Dump(_)) => unreachable!(), - - // Parse State: NoQuery - (ParseState::NoQuery, - ProfileQueriesMsg::QueryBegin(span,querymsg)) => { - let start = Instant::now(); - frame.parse_st = ParseState::HaveQuery - (Query{span:span, msg:querymsg}, start) - }, - (ParseState::NoQuery, - ProfileQueriesMsg::CacheHit) => { - panic!("parse error: unexpected CacheHit; expected QueryBegin") - }, - (ParseState::NoQuery, - ProfileQueriesMsg::ProviderBegin) => { - panic!("parse error: expected QueryBegin before beginning a provider") - }, - (ParseState::NoQuery, - ProfileQueriesMsg::ProviderEnd) => { - let provider_extent = frame.traces; - match stack.pop() { - None => - panic!("parse error: expected a stack frame; found an empty stack"), - Some(old_frame) => { - match old_frame.parse_st { - ParseState::NoQuery => - panic!("parse error: expected a stack frame for a query"), - ParseState::HaveQuery(q,start) => { - let duration = start.elapsed(); - frame = StackFrame{ - parse_st:ParseState::NoQuery, - traces:old_frame.traces - }; - let trace = Rec { - effect: Effect::QueryBegin(q, CacheCase::Miss), - extent: Box::new(provider_extent), - start: start, - duration: duration, - }; - frame.traces.push( trace ); - } - } - } - } - } - - // Parse State: HaveQuery - (ParseState::HaveQuery(q,start), - ProfileQueriesMsg::CacheHit) => { - let duration = start.elapsed(); - let trace : Rec = Rec{ - effect: Effect::QueryBegin(q, CacheCase::Hit), - extent: Box::new(vec![]), - start: start, - duration: duration, - }; - frame.traces.push( trace ); - frame.parse_st = ParseState::NoQuery; - }, - (ParseState::HaveQuery(_,_), - ProfileQueriesMsg::ProviderBegin) => { - stack.push(frame); - frame = StackFrame{parse_st:ParseState::NoQuery, traces:vec![]}; - }, - (ParseState::HaveQuery(q,_), - ProfileQueriesMsg::ProviderEnd) => { - panic!("parse error: unexpected ProviderEnd; -expected something else to follow BeginQuery for {:?}", q) - }, - (ParseState::HaveQuery(q1,_), - ProfileQueriesMsg::QueryBegin(span2,querymsg2)) => { - panic!("parse error: unexpected QueryBegin; -earlier query is unfinished: {:?} and now {:?}", - q1, Query{span:span2, msg:querymsg2}) - }, - } - } - } - } -} - /// Run the resolution, typechecking, region checking and other /// miscellaneous analysis passes on the crate. Return various /// structures carrying the results of the analysis. @@ -1340,14 +964,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session, name, |tcx| { - if tcx.sess.profile_queries() { - use std::thread; - use std::sync::mpsc::{channel}; - let (tx, rx) = channel(); - *tcx.profile_queries_sender.borrow_mut() = Some(tx); - thread::spawn(move||profile_queries_thread(rx)); - } - let incremental_hashes_map = time(time_passes, "compute_incremental_hashes_map", @@ -1458,6 +1074,11 @@ pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, &incremental_hashes_map, &translation.metadata.hashes, translation.link.crate_hash)); + + if tcx.sess.opts.debugging_opts.profile_queries { + profq_msg(ProfileQueriesMsg::Dump("profile_queries".to_string())) + } + translation } diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 34f636d0b9a12..e244a5fc53ab7 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -107,6 +107,7 @@ use syntax_pos::{DUMMY_SP, MultiSpan}; pub mod test; pub mod driver; +pub mod profile; pub mod pretty; pub mod target_features; mod derive_registrar; diff --git a/src/librustc_driver/profile/mod.rs b/src/librustc_driver/profile/mod.rs new file mode 100644 index 0000000000000..965919169a2db --- /dev/null +++ b/src/librustc_driver/profile/mod.rs @@ -0,0 +1,144 @@ +use rustc::util::common::{ProfileQueriesMsg,profq_set_chan}; +use std::sync::mpsc::{Receiver}; +use std::io::{Write}; + +pub mod trace; + +pub fn begin() { + use std::thread; + use std::sync::mpsc::{channel}; + let (tx, rx) = channel(); + if profq_set_chan(tx) { + thread::spawn(move||profile_queries_thread(rx)); + } +} + +fn profile_queries_thread(r:Receiver) { + use self::trace::*; + use std::fs::File; + use std::time::{Instant}; + + let mut queries : Vec = vec![]; + let mut frame : StackFrame = StackFrame{ parse_st:ParseState::NoQuery, traces:vec![] }; + let mut stack : Vec = vec![]; + loop { + let msg = r.recv(); + if let Err(_recv_err) = msg { + // FIXME: Perhaps do something smarter than simply quitting? + break + }; + let msg = msg.unwrap(); + debug!("profile_queries_thread: {:?}", msg); + + // Meta-level versus _actual_ queries messages + match msg { + ProfileQueriesMsg::Halt => return, + ProfileQueriesMsg::Dump(path) => { + assert!(stack.len() == 0); + assert!(frame.parse_st == trace::ParseState::NoQuery); + { // write HTML file + let html_path = format!("{}.html", path); + let mut html_file = File::create(&html_path).unwrap(); + + let counts_path = format!("{}.counts.txt", path); + let mut counts_file = File::create(&counts_path).unwrap(); + + write!(html_file, "\n").unwrap(); + write!(html_file, + "\n\n", + "profile_queries.css").unwrap(); + write!(html_file, "\n").unwrap(); + write!(html_file, "\n").unwrap(); + write!(html_file, "\n").unwrap(); + trace::write_traces(&mut html_file, &mut counts_file, &frame.traces); + write!(html_file, "\n\n").unwrap(); + } + continue + } + // Actual query message: + msg => { + queries.push(msg.clone()); + match (frame.parse_st.clone(), msg) { + (_,ProfileQueriesMsg::Halt) => unreachable!(), + (_,ProfileQueriesMsg::Dump(_)) => unreachable!(), + + // Parse State: NoQuery + (ParseState::NoQuery, + ProfileQueriesMsg::QueryBegin(span,querymsg)) => { + let start = Instant::now(); + frame.parse_st = ParseState::HaveQuery + (Query{span:span, msg:querymsg}, start) + }, + (ParseState::NoQuery, + ProfileQueriesMsg::CacheHit) => { + panic!("parse error: unexpected CacheHit; expected QueryBegin") + }, + (ParseState::NoQuery, + ProfileQueriesMsg::ProviderBegin) => { + panic!("parse error: expected QueryBegin before beginning a provider") + }, + (ParseState::NoQuery, + ProfileQueriesMsg::ProviderEnd) => { + let provider_extent = frame.traces; + match stack.pop() { + None => + panic!("parse error: expected a stack frame; found an empty stack"), + Some(old_frame) => { + match old_frame.parse_st { + ParseState::NoQuery => + panic!("parse error: expected a stack frame for a query"), + ParseState::HaveQuery(q,start) => { + let duration = start.elapsed(); + frame = StackFrame{ + parse_st:ParseState::NoQuery, + traces:old_frame.traces + }; + let trace = Rec { + effect: Effect::QueryBegin(q, CacheCase::Miss), + extent: Box::new(provider_extent), + start: start, + duration: duration, + }; + frame.traces.push( trace ); + } + } + } + } + } + + // Parse State: HaveQuery + (ParseState::HaveQuery(q,start), + ProfileQueriesMsg::CacheHit) => { + let duration = start.elapsed(); + let trace : Rec = Rec{ + effect: Effect::QueryBegin(q, CacheCase::Hit), + extent: Box::new(vec![]), + start: start, + duration: duration, + }; + frame.traces.push( trace ); + frame.parse_st = ParseState::NoQuery; + }, + (ParseState::HaveQuery(_,_), + ProfileQueriesMsg::ProviderBegin) => { + stack.push(frame); + frame = StackFrame{parse_st:ParseState::NoQuery, traces:vec![]}; + }, + (ParseState::HaveQuery(q,_), + ProfileQueriesMsg::ProviderEnd) => { + panic!("parse error: unexpected ProviderEnd; +expected something else to follow BeginQuery for {:?}", q) + }, + (ParseState::HaveQuery(q1,_), + ProfileQueriesMsg::QueryBegin(span2,querymsg2)) => { + panic!("parse error: unexpected QueryBegin; +earlier query is unfinished: {:?} and now {:?}", + q1, Query{span:span2, msg:querymsg2}) + }, + } + } + } + } +} diff --git a/src/librustc_driver/profile/trace.rs b/src/librustc_driver/profile/trace.rs new file mode 100644 index 0000000000000..b8b43a51f6322 --- /dev/null +++ b/src/librustc_driver/profile/trace.rs @@ -0,0 +1,236 @@ +use super::*; +use syntax_pos::Span; +use rustc::ty::maps::QueryMsg; +use std::fs::File; +use std::time::{Duration, Instant}; +use std::collections::hash_map::HashMap; + +#[derive(Debug, Clone, Eq, PartialEq)] +pub struct Query { + pub span: Span, + pub msg: QueryMsg, +} +pub enum Effect { + QueryBegin(Query, CacheCase), +} +pub enum CacheCase { + Hit, Miss +} +/// Recursive trace structure +pub struct Rec { + pub effect: Effect, + pub start: Instant, + pub duration: Duration, + pub extent: Box>, +} +/// State for parsing recursive trace structure +#[derive(Clone, Eq, PartialEq)] +pub enum ParseState { + NoQuery, + HaveQuery(Query, Instant), +} +pub struct StackFrame { + pub parse_st: ParseState, + pub traces: Vec, +} +pub struct QueryMetric { + pub count: usize, + pub duration: Duration, +} + +pub fn cons_of_query_msg(q: &trace::Query) -> String { + let s = format!("{:?}", q.msg); + let cons: Vec<&str> = s.split(|d| d == '(' || d == '{').collect(); + assert!(cons.len() > 0 && cons[0] != ""); + cons[0].to_string() +} + +// First return value is text; second return value is a CSS class +pub fn html_of_effect(eff: &Effect) -> (String, String) { + match *eff { + Effect::QueryBegin(ref qmsg, ref cc) => { + let cons = cons_of_query_msg(qmsg); + (cons.clone(), + format!("{} {}", + cons, + match *cc { + CacheCase::Hit => "hit", + CacheCase::Miss => "miss", + })) + } + } +} + +// First return value is text; second return value is a CSS class +fn html_of_duration(_start: &Instant, dur: &Duration) -> (String, String) { + use rustc::util::common::duration_to_secs_str; + (duration_to_secs_str(dur.clone()), + "".to_string() + ) +} + +fn html_of_fraction(frac: f64) -> (String, String) { + let css = { + if frac > 0.50 { format!("frac-50") } + else if frac > 0.40 { format!("frac-40") } + else if frac > 0.30 { format!("frac-30") } + else if frac > 0.20 { format!("frac-20") } + else if frac > 0.10 { format!("frac-10") } + else if frac > 0.05 { format!("frac-05") } + else if frac > 0.02 { format!("frac-02") } + else if frac > 0.01 { format!("frac-01") } + else if frac > 0.001 { format!("frac-001") } + else { format!("frac-0") } + }; + let percent = frac * 100 as f64; + if percent > 0.1 as f64 { (format!("{:.1}%", percent), css) } + else { (format!("< 0.1%", ), css) } +} + +fn total_duration(traces: &Vec) -> Duration { + let mut sum : Duration = Duration::new(0,0); + for t in traces.iter() { + sum += t.duration; + } + return sum +} + +fn duration_div(nom: Duration, den: Duration) -> f64 { + let nom_sec = nom.as_secs(); + let den_sec = den.as_secs(); + let nom_nanos = nom.subsec_nanos(); + let den_nanos = den.subsec_nanos(); + if nom_sec == den_sec { + if nom_sec == 0 { + nom_nanos as f64 / den_nanos as f64 + } else { + panic!("FIXME(matthewhammer)") + } + } else { + panic!("FIXME(matthewhammer)") + } +} + +fn write_traces_rec(file: &mut File, traces: &Vec, total: Duration, depth: usize) { + for t in traces { + let (eff_text, eff_css_classes) = html_of_effect(&t.effect); + let (dur_text, dur_css_classes) = html_of_duration(&t.start, &t.duration); + let fraction = duration_div(t.duration, total); + let percent = fraction * 100 as f64; + let (frc_text, frc_css_classes) = html_of_fraction(fraction); + write!(file, "
\n", + depth, + t.extent.len(), + /* Heuristic for 'important' CSS class: */ + if t.extent.len() > 5 || percent >= 1.0 as f64 { + " important" } + else { "" }, + eff_css_classes, + dur_css_classes, + frc_css_classes, + ).unwrap(); + write!(file, "
{}
\n", eff_text).unwrap(); + write!(file, "
{}
\n", dur_text).unwrap(); + write!(file, "
{}
\n", frc_text).unwrap(); + write_traces_rec(file, &t.extent, total, depth + 1); + write!(file, "
\n").unwrap(); + } +} + +fn compute_counts_rec(counts: &mut HashMap, traces: &Vec) { + for t in traces.iter() { + match t.effect { + Effect::QueryBegin(ref qmsg, ref _cc) => { + let qcons = cons_of_query_msg(qmsg); + let qm = match counts.get(&qcons) { + Some(qm) => + QueryMetric{ + count: qm.count + 1, + duration: qm.duration + t.duration + }, + None => QueryMetric{ + count: 1, + duration: t.duration + } + }; + counts.insert(qcons, qm); + } + } + compute_counts_rec(counts, &t.extent) + } +} + +pub fn write_counts(count_file: &mut File, counts: &mut HashMap) { + use rustc::util::common::duration_to_secs_str; + use std::cmp::Ordering; + + let mut data = vec![]; + for (ref cons, ref qm) in counts.iter() { + data.push((cons.clone(), qm.count.clone(), qm.duration.clone())); + }; + data.sort_by(|&(_,_,d1),&(_,_,d2)| + if d1 > d2 { Ordering::Less } else { Ordering::Greater } ); + for (cons, count, duration) in data { + write!(count_file, "{},{},{}\n", + cons, count, duration_to_secs_str(duration) + ).unwrap(); + } +} + +pub fn write_traces(html_file: &mut File, counts_file: &mut File, traces: &Vec) { + let mut counts : HashMap = HashMap::new(); + compute_counts_rec(&mut counts, traces); + write_counts(counts_file, &mut counts); + + let total : Duration = total_duration(traces); + write_traces_rec(html_file, traces, total, 0) +} + +pub fn write_style(html_file: &mut File) { + write!(html_file,"{}", " +body { + font-family: sans-serif; + background: black; +} +.trace { + color: black; + display: inline-block; + border-style: solid; + border-color: red; + border-width: 1px; + border-radius: 5px; + padding: 0px; + margin: 1px; + font-size: 0px; +} +.miss { + border-color: red; + border-width: 1px; +} +.extent-0 { + padding: 2px; +} +.important { + border-width: 3px; + font-size: 12px; + color: white; + border-color: #f77; +} +.hit { + padding: 0px; + border-color: blue; + border-width: 3px; +} +.eff { + color: #fff; + display: inline-block; +} +.frc { + color: #7f7; + display: inline-block; +} +.dur { + display: none +} +").unwrap(); +} diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index 001660e423205..39fe2188f68d1 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -59,18 +59,10 @@ use std::fs::File; use std::io::Write; use syntax::ast; use syntax_pos::Span; -use rustc::ty::ProfileQueriesMsg; pub fn assert_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let _ignore = tcx.dep_graph.in_ignore(); - if tcx.sess.profile_queries() { - tcx.profile_queries_sender.borrow().as_ref().unwrap() - .send( - ProfileQueriesMsg::Dump("profile_queries".to_string()) - ).unwrap() - } - if tcx.sess.opts.debugging_opts.dump_dep_graph { dump_graph(tcx); } From a01c91c8bc251f46b94c5124f31df6bc094fb0a1 Mon Sep 17 00:00:00 2001 From: Havvy Date: Tue, 27 Jun 2017 03:59:07 -0700 Subject: [PATCH 078/123] Document error coercion to false in path-ext methods + see also sections --- src/libstd/path.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 42a54ed6d754c..f0feb82cd01b1 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -2215,12 +2215,22 @@ impl Path { /// This function will traverse symbolic links to query information about the /// destination file. In case of broken symbolic links this will return `false`. /// + /// If you cannot access the directory containing the file, e.g. because of a + /// permission error, this will return `false`. + /// /// # Examples /// /// ```no_run /// use std::path::Path; /// assert_eq!(Path::new("does_not_exist.txt").exists(), false); /// ``` + /// + /// # See Also + /// + /// This is a convenience function that coerces errors to false. If you want to + /// check errors, call [fs::metadata]. + /// + /// [fs::metadata]: ../../std/fs/fn.metadata.html #[stable(feature = "path_ext", since = "1.5.0")] pub fn exists(&self) -> bool { fs::metadata(self).is_ok() @@ -2231,6 +2241,9 @@ impl Path { /// This function will traverse symbolic links to query information about the /// destination file. In case of broken symbolic links this will return `false`. /// + /// If you cannot access the directory containing the file, e.g. because of a + /// permission error, this will return `false`. + /// /// # Examples /// /// ```no_run @@ -2238,6 +2251,15 @@ impl Path { /// assert_eq!(Path::new("./is_a_directory/").is_file(), false); /// assert_eq!(Path::new("a_file.txt").is_file(), true); /// ``` + /// + /// # See Also + /// + /// This is a convenience function that coerces errors to false. If you want to + /// check errors, call [fs::metadata] and handle its Result. Then call + /// [fs::Metadata::is_file] if it was Ok. + /// + /// [fs::metadata]: ../../std/fs/fn.metadata.html + /// [fs::Metadata::is_file]: ../../std/fs/struct.Metadata.html#method.is_file #[stable(feature = "path_ext", since = "1.5.0")] pub fn is_file(&self) -> bool { fs::metadata(self).map(|m| m.is_file()).unwrap_or(false) @@ -2248,6 +2270,9 @@ impl Path { /// This function will traverse symbolic links to query information about the /// destination file. In case of broken symbolic links this will return `false`. /// + /// If you cannot access the directory containing the file, e.g. because of a + /// permission error, this will return `false`. + /// /// # Examples /// /// ```no_run @@ -2255,6 +2280,15 @@ impl Path { /// assert_eq!(Path::new("./is_a_directory/").is_dir(), true); /// assert_eq!(Path::new("a_file.txt").is_dir(), false); /// ``` + /// + /// # See Also + /// + /// This is a convenience function that coerces errors to false. If you want to + /// check errors, call [fs::metadata] and handle its Result. Then call + /// [fs::Metadata::is_dir] if it was Ok. + /// + /// [fs::metadata]: ../../std/fs/fn.metadata.html + /// [fs::Metadata::is_dir]: ../../std/fs/struct.Metadata.html#method.is_dir #[stable(feature = "path_ext", since = "1.5.0")] pub fn is_dir(&self) -> bool { fs::metadata(self).map(|m| m.is_dir()).unwrap_or(false) From 66fce33ecb56c8aae8d77ffd4fc0562aadf66a0b Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 12 Jul 2017 12:59:05 -0700 Subject: [PATCH 079/123] overload the mir ty methods to make them more ergonomic to use --- src/librustc/mir/mod.rs | 16 ++++++++++ src/librustc/mir/tcx.rs | 8 ++--- .../dataflow/drop_flag_effects.rs | 6 ++-- src/librustc_mir/dataflow/move_paths/mod.rs | 4 +-- src/librustc_mir/transform/inline.rs | 10 +++---- src/librustc_mir/transform/instcombine.rs | 2 +- src/librustc_mir/transform/promote_consts.rs | 4 +-- src/librustc_mir/transform/qualify_consts.rs | 16 +++++----- src/librustc_mir/transform/type_check.rs | 30 +++++++++---------- src/librustc_mir/util/elaborate_drops.rs | 2 +- src/librustc_trans/collector.rs | 10 +++---- src/librustc_trans/mir/analyze.rs | 4 +-- src/librustc_trans/mir/block.rs | 4 +-- src/librustc_trans/mir/constant.rs | 4 +-- src/librustc_trans/mir/lvalue.rs | 2 +- src/librustc_trans/mir/rvalue.rs | 6 ++-- 16 files changed, 72 insertions(+), 56 deletions(-) diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 8ac4e1208b0cb..ba38d97d09261 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -69,6 +69,22 @@ macro_rules! newtype_index { /// Types for locals type LocalDecls<'tcx> = IndexVec>; +pub trait AsLocalDeclsRef<'tcx> { + fn as_ref(&self) -> &LocalDecls<'tcx>; +} + +impl<'tcx> AsLocalDeclsRef<'tcx> for LocalDecls<'tcx> { + fn as_ref(&self) -> &LocalDecls<'tcx> { + self + } +} + +impl<'tcx> AsLocalDeclsRef<'tcx> for Mir<'tcx> { + fn as_ref(&self) -> &LocalDecls<'tcx> { + &self.local_decls + } +} + /// Lowered representation of a single function. #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct Mir<'tcx> { diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index b99c0180eccfd..c99fffe2198b8 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -121,10 +121,10 @@ impl<'tcx> TypeFoldable<'tcx> for LvalueTy<'tcx> { } impl<'tcx> Lvalue<'tcx> { - pub fn ty<'a, 'gcx>(&self, local_decls: &LocalDecls<'tcx>, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> LvalueTy<'tcx> { + pub fn ty<'a, 'gcx, D: AsLocalDeclsRef<'tcx>>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> LvalueTy<'tcx> { match *self { Lvalue::Local(index) => - LvalueTy::Ty { ty: local_decls[index].ty }, + LvalueTy::Ty { ty: local_decls.as_ref()[index].ty }, Lvalue::Static(ref data) => LvalueTy::Ty { ty: data.ty }, Lvalue::Projection(ref proj) => @@ -134,7 +134,7 @@ impl<'tcx> Lvalue<'tcx> { } impl<'tcx> Rvalue<'tcx> { - pub fn ty<'a, 'gcx>(&self, local_decls: &LocalDecls<'tcx>, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> + pub fn ty<'a, 'gcx, D: AsLocalDeclsRef<'tcx>>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> { match *self { Rvalue::Use(ref operand) => operand.ty(local_decls, tcx), @@ -206,7 +206,7 @@ impl<'tcx> Rvalue<'tcx> { } impl<'tcx> Operand<'tcx> { - pub fn ty<'a, 'gcx>(&self, local_decls: &LocalDecls<'tcx>, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> { + pub fn ty<'a, 'gcx, D: AsLocalDeclsRef<'tcx>>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> { match self { &Operand::Consume(ref l) => l.ty(local_decls, tcx).to_ty(tcx), &Operand::Constant(ref c) => c.ty, diff --git a/src/librustc_mir/dataflow/drop_flag_effects.rs b/src/librustc_mir/dataflow/drop_flag_effects.rs index a247cd774501e..daafbecc5dfa3 100644 --- a/src/librustc_mir/dataflow/drop_flag_effects.rs +++ b/src/librustc_mir/dataflow/drop_flag_effects.rs @@ -129,7 +129,7 @@ pub fn move_path_children_matching<'tcx, F>(move_data: &MoveData<'tcx>, fn lvalue_contents_drop_state_cannot_differ<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, mir: &Mir<'tcx>, lv: &mir::Lvalue<'tcx>) -> bool { - let ty = lv.ty(&mir.local_decls, tcx).to_ty(tcx); + let ty = lv.ty(mir, tcx).to_ty(tcx); match ty.sty { ty::TyArray(..) | ty::TySlice(..) | ty::TyRef(..) | ty::TyRawPtr(..) => { debug!("lvalue_contents_drop_state_cannot_differ lv: {:?} ty: {:?} refd => true", @@ -216,7 +216,7 @@ pub(crate) fn on_all_drop_children_bits<'a, 'tcx, F>( { on_all_children_bits(tcx, mir, &ctxt.move_data, path, |child| { let lvalue = &ctxt.move_data.move_paths[path].lvalue; - let ty = lvalue.ty(&mir.local_decls, tcx).to_ty(tcx); + let ty = lvalue.ty(mir, tcx).to_ty(tcx); debug!("on_all_drop_children_bits({:?}, {:?} : {:?})", path, lvalue, ty); if ty.needs_drop(tcx, ctxt.param_env) { @@ -263,7 +263,7 @@ pub(crate) fn drop_flag_effects_for_location<'a, 'tcx, F>( // don't move out of non-Copy things let lvalue = &move_data.move_paths[path].lvalue; - let ty = lvalue.ty(&mir.local_decls, tcx).to_ty(tcx); + let ty = lvalue.ty(mir, tcx).to_ty(tcx); if !ty.moves_by_default(tcx, param_env, DUMMY_SP) { continue; } diff --git a/src/librustc_mir/dataflow/move_paths/mod.rs b/src/librustc_mir/dataflow/move_paths/mod.rs index e92ece7505f6d..d7ed0938e886a 100644 --- a/src/librustc_mir/dataflow/move_paths/mod.rs +++ b/src/librustc_mir/dataflow/move_paths/mod.rs @@ -286,7 +286,7 @@ impl<'a, 'tcx> MoveDataBuilder<'a, 'tcx> { -> Result { let base = try!(self.move_path_for(&proj.base)); - let lv_ty = proj.base.ty(&self.mir.local_decls, self.tcx).to_ty(self.tcx); + let lv_ty = proj.base.ty(self.mir, self.tcx).to_ty(self.tcx); match lv_ty.sty { // error: can't move out of borrowed content ty::TyRef(..) | ty::TyRawPtr(..) => return Err(MovePathError::IllegalMove), @@ -504,7 +504,7 @@ impl<'a, 'tcx> MoveDataBuilder<'a, 'tcx> { fn gather_move(&mut self, loc: Location, lval: &Lvalue<'tcx>) { debug!("gather_move({:?}, {:?})", loc, lval); - let lv_ty = lval.ty(&self.mir.local_decls, self.tcx).to_ty(self.tcx); + let lv_ty = lval.ty(self.mir, self.tcx).to_ty(self.tcx); if !lv_ty.moves_by_default(self.tcx, self.param_env, DUMMY_SP) { debug!("gather_move({:?}, {:?}) - {:?} is Copy. skipping", loc, lval, lv_ty); return diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index db951a7fef8c1..d3fee8045e6e3 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -250,7 +250,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { work_list.push(target); // If the location doesn't actually need dropping, treat it like // a regular goto. - let ty = location.ty(&callee_mir.local_decls, tcx).subst(tcx, callsite.substs); + let ty = location.ty(callee_mir, tcx).subst(tcx, callsite.substs); let ty = ty.to_ty(tcx); if ty.needs_drop(tcx, param_env) { cost += CALL_PENALTY; @@ -390,7 +390,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { BorrowKind::Mut, destination.0); - let ty = dest.ty(&caller_mir.local_decls, self.tcx); + let ty = dest.ty(caller_mir, self.tcx); let temp = LocalDecl::new_temp(ty, callsite.location.span); @@ -422,7 +422,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { bug!("Constant arg to \"box_free\""); }; - let ptr_ty = args[0].ty(&caller_mir.local_decls, self.tcx); + let ptr_ty = args[0].ty(caller_mir, self.tcx); vec![self.cast_box_free_arg(arg, ptr_ty, &callsite, caller_mir)] } else { // Copy the arguments if needed. @@ -475,7 +475,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { BorrowKind::Mut, arg.deref()); - let ty = arg.ty(&caller_mir.local_decls, self.tcx); + let ty = arg.ty(caller_mir, self.tcx); let ref_tmp = LocalDecl::new_temp(ty, callsite.location.span); let ref_tmp = caller_mir.local_decls.push(ref_tmp); let ref_tmp = Lvalue::Local(ref_tmp); @@ -529,7 +529,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { // Otherwise, create a temporary for the arg let arg = Rvalue::Use(a); - let ty = arg.ty(&caller_mir.local_decls, tcx); + let ty = arg.ty(caller_mir, tcx); let arg_tmp = LocalDecl::new_temp(ty, callsite.location.span); let arg_tmp = caller_mir.local_decls.push(arg_tmp); diff --git a/src/librustc_mir/transform/instcombine.rs b/src/librustc_mir/transform/instcombine.rs index 65d20d3be8768..88a368077d4f5 100644 --- a/src/librustc_mir/transform/instcombine.rs +++ b/src/librustc_mir/transform/instcombine.rs @@ -87,7 +87,7 @@ impl<'b, 'a, 'tcx> Visitor<'tcx> for OptimizationFinder<'b, 'a, 'tcx> { fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) { if let Rvalue::Ref(_, _, Lvalue::Projection(ref projection)) = *rvalue { if let ProjectionElem::Deref = projection.elem { - if projection.base.ty(&self.mir.local_decls, self.tcx).to_ty(self.tcx).is_region_ptr() { + if projection.base.ty(self.mir, self.tcx).to_ty(self.tcx).is_region_ptr() { self.optimizations.and_stars.insert(location); } } diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index 8cb6c0b055e7f..e1c4602b045eb 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -362,13 +362,13 @@ pub fn promote_candidates<'a, 'tcx>(mir: &mut Mir<'tcx>, continue; } } - (statement.source_info.span, dest.ty(&mir.local_decls, tcx).to_ty(tcx)) + (statement.source_info.span, dest.ty(mir, tcx).to_ty(tcx)) } Candidate::ShuffleIndices(bb) => { let terminator = mir[bb].terminator(); let ty = match terminator.kind { TerminatorKind::Call { ref args, .. } => { - args[2].ty(&mir.local_decls, tcx) + args[2].ty(mir, tcx) } _ => { span_bug!(terminator.source_info.span, diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 3180133b05a51..68b687a2e6182 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -507,7 +507,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { this.add(Qualif::STATIC); } - let base_ty = proj.base.ty(&this.mir.local_decls, this.tcx).to_ty(this.tcx); + let base_ty = proj.base.ty(this.mir, this.tcx).to_ty(this.tcx); if let ty::TyRawPtr(_) = base_ty.sty { this.add(Qualif::NOT_CONST); if this.mode != Mode::Fn { @@ -530,7 +530,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { "cannot refer to the interior of another \ static, use a constant instead"); } - let ty = lvalue.ty(&this.mir.local_decls, this.tcx).to_ty(this.tcx); + let ty = lvalue.ty(this.mir, this.tcx).to_ty(this.tcx); this.qualif.restrict(ty, this.tcx, this.param_env); } @@ -606,7 +606,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { self.add(Qualif::STATIC_REF); } - let ty = lvalue.ty(&self.mir.local_decls, self.tcx).to_ty(self.tcx); + let ty = lvalue.ty(self.mir, self.tcx).to_ty(self.tcx); if kind == BorrowKind::Mut { // In theory, any zero-sized value could be borrowed // mutably without consequences. However, only &mut [] @@ -671,7 +671,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } Rvalue::Cast(CastKind::Misc, ref operand, cast_ty) => { - let operand_ty = operand.ty(&self.mir.local_decls, self.tcx); + let operand_ty = operand.ty(self.mir, self.tcx); let cast_in = CastTy::from_ty(operand_ty).expect("bad input type for cast"); let cast_out = CastTy::from_ty(cast_ty).expect("bad output type for cast"); match (cast_in, cast_out) { @@ -689,7 +689,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } Rvalue::BinaryOp(op, ref lhs, _) => { - if let ty::TyRawPtr(_) = lhs.ty(&self.mir.local_decls, self.tcx).sty { + if let ty::TyRawPtr(_) = lhs.ty(self.mir, self.tcx).sty { assert!(op == BinOp::Eq || op == BinOp::Ne || op == BinOp::Le || op == BinOp::Lt || op == BinOp::Ge || op == BinOp::Gt || @@ -727,7 +727,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } if Some(def.did) == self.tcx.lang_items.unsafe_cell_type() { - let ty = rvalue.ty(&self.mir.local_decls, self.tcx); + let ty = rvalue.ty(self.mir, self.tcx); self.add_type(ty); assert!(self.qualif.intersects(Qualif::MUTABLE_INTERIOR)); // Even if the value inside may not need dropping, @@ -748,7 +748,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { if let TerminatorKind::Call { ref func, ref args, ref destination, .. } = *kind { self.visit_operand(func, location); - let fn_ty = func.ty(&self.mir.local_decls, self.tcx); + let fn_ty = func.ty(self.mir, self.tcx); let (is_shuffle, is_const_fn) = match fn_ty.sty { ty::TyFnDef(def_id, _) => { (self.tcx.fn_sig(def_id).abi() == Abi::PlatformIntrinsic && @@ -828,7 +828,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } else { // Be conservative about the returned value of a const fn. let tcx = self.tcx; - let ty = dest.ty(&self.mir.local_decls, tcx).to_ty(tcx); + let ty = dest.ty(self.mir, tcx).to_ty(tcx); self.qualif = Qualif::empty(); self.add_type(ty); diff --git a/src/librustc_mir/transform/type_check.rs b/src/librustc_mir/transform/type_check.rs index 1175f955b4ed0..7e6fccf30192c 100644 --- a/src/librustc_mir/transform/type_check.rs +++ b/src/librustc_mir/transform/type_check.rs @@ -84,7 +84,7 @@ impl<'a, 'b, 'gcx, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'gcx, 'tcx> { fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) { self.super_rvalue(rvalue, location); - let rval_ty = rvalue.ty(&self.mir.local_decls, self.tcx()); + let rval_ty = rvalue.ty(self.mir, self.tcx()); self.sanitize_type(rvalue, rval_ty); } @@ -178,7 +178,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { } ProjectionElem::Index(ref i) => { self.visit_operand(i, location); - let index_ty = i.ty(&self.mir.local_decls, tcx); + let index_ty = i.ty(self.mir, tcx); if index_ty != tcx.types.usize { LvalueTy::Ty { ty: span_mirbug_and_err!(self, i, "index by non-usize {:?}", i) @@ -378,15 +378,15 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { let tcx = self.tcx(); match stmt.kind { StatementKind::Assign(ref lv, ref rv) => { - let lv_ty = lv.ty(&mir.local_decls, tcx).to_ty(tcx); - let rv_ty = rv.ty(&mir.local_decls, tcx); + let lv_ty = lv.ty(mir, tcx).to_ty(tcx); + let rv_ty = rv.ty(mir, tcx); if let Err(terr) = self.sub_types(rv_ty, lv_ty) { span_mirbug!(self, stmt, "bad assignment ({:?} = {:?}): {:?}", lv_ty, rv_ty, terr); } } StatementKind::SetDiscriminant{ ref lvalue, variant_index } => { - let lvalue_type = lvalue.ty(&mir.local_decls, tcx).to_ty(tcx); + let lvalue_type = lvalue.ty(mir, tcx).to_ty(tcx); let adt = match lvalue_type.sty { TypeVariants::TyAdt(adt, _) if adt.is_enum() => adt, _ => { @@ -438,15 +438,15 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { ref value, .. } => { - let lv_ty = location.ty(&mir.local_decls, tcx).to_ty(tcx); - let rv_ty = value.ty(&mir.local_decls, tcx); + let lv_ty = location.ty(mir, tcx).to_ty(tcx); + let rv_ty = value.ty(mir, tcx); if let Err(terr) = self.sub_types(rv_ty, lv_ty) { span_mirbug!(self, term, "bad DropAndReplace ({:?} = {:?}): {:?}", lv_ty, rv_ty, terr); } } TerminatorKind::SwitchInt { ref discr, switch_ty, .. } => { - let discr_ty = discr.ty(&mir.local_decls, tcx); + let discr_ty = discr.ty(mir, tcx); if let Err(terr) = self.sub_types(discr_ty, switch_ty) { span_mirbug!(self, term, "bad SwitchInt ({:?} on {:?}): {:?}", switch_ty, discr_ty, terr); @@ -459,7 +459,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { // FIXME: check the values } TerminatorKind::Call { ref func, ref args, ref destination, .. } => { - let func_ty = func.ty(&mir.local_decls, tcx); + let func_ty = func.ty(mir, tcx); debug!("check_terminator: call, func_ty={:?}", func_ty); let sig = match func_ty.sty { ty::TyFnDef(..) | ty::TyFnPtr(_) => func_ty.fn_sig(tcx), @@ -479,16 +479,16 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { } } TerminatorKind::Assert { ref cond, ref msg, .. } => { - let cond_ty = cond.ty(&mir.local_decls, tcx); + let cond_ty = cond.ty(mir, tcx); if cond_ty != tcx.types.bool { span_mirbug!(self, term, "bad Assert ({:?}, not bool", cond_ty); } if let AssertMessage::BoundsCheck { ref len, ref index } = *msg { - if len.ty(&mir.local_decls, tcx) != tcx.types.usize { + if len.ty(mir, tcx) != tcx.types.usize { span_mirbug!(self, len, "bounds-check length non-usize {:?}", len) } - if index.ty(&mir.local_decls, tcx) != tcx.types.usize { + if index.ty(mir, tcx) != tcx.types.usize { span_mirbug!(self, index, "bounds-check index non-usize {:?}", index) } } @@ -504,7 +504,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { let tcx = self.tcx(); match *destination { Some((ref dest, _)) => { - let dest_ty = dest.ty(&mir.local_decls, tcx).to_ty(tcx); + let dest_ty = dest.ty(mir, tcx).to_ty(tcx); if let Err(terr) = self.sub_types(sig.output(), dest_ty) { span_mirbug!(self, term, "call dest mismatch ({:?} <- {:?}): {:?}", @@ -532,7 +532,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { span_mirbug!(self, term, "call to {:?} with wrong # of args", sig); } for (n, (fn_arg, op_arg)) in sig.inputs().iter().zip(args).enumerate() { - let op_arg_ty = op_arg.ty(&mir.local_decls, self.tcx()); + let op_arg_ty = op_arg.ty(mir, self.tcx()); if let Err(terr) = self.sub_types(op_arg_ty, fn_arg) { span_mirbug!(self, term, "bad arg #{:?} ({:?} <- {:?}): {:?}", n, fn_arg, op_arg_ty, terr); @@ -581,7 +581,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { return; } - let ty = args[0].ty(&mir.local_decls, self.tcx()); + let ty = args[0].ty(mir, self.tcx()); let arg_ty = match ty.sty { ty::TyRawPtr(mt) => mt.ty, ty::TyAdt(def, _) if def.is_box() => ty.boxed_ty(), diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index efeffbbe7d140..da7e218439cf0 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -130,7 +130,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> where D: DropElaborator<'b, 'tcx> { fn lvalue_ty(&self, lvalue: &Lvalue<'tcx>) -> Ty<'tcx> { - lvalue.ty(&self.elaborator.mir().local_decls, self.tcx()).to_ty(self.tcx()) + lvalue.ty(self.elaborator.mir(), self.tcx()).to_ty(self.tcx()) } fn tcx(&self) -> ty::TyCtxt<'b, 'tcx, 'tcx> { diff --git a/src/librustc_trans/collector.rs b/src/librustc_trans/collector.rs index 4eb7efc593d8e..a76abcf7b49a6 100644 --- a/src/librustc_trans/collector.rs +++ b/src/librustc_trans/collector.rs @@ -474,7 +474,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { mir::Rvalue::Cast(mir::CastKind::Unsize, ref operand, target_ty) => { let target_ty = self.scx.tcx().trans_apply_param_substs(self.param_substs, &target_ty); - let source_ty = operand.ty(&self.mir.local_decls, self.scx.tcx()); + let source_ty = operand.ty(self.mir, self.scx.tcx()); let source_ty = self.scx.tcx().trans_apply_param_substs(self.param_substs, &source_ty); let (source_ty, target_ty) = find_vtable_types_for_unsizing(self.scx, @@ -491,13 +491,13 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { } } mir::Rvalue::Cast(mir::CastKind::ReifyFnPointer, ref operand, _) => { - let fn_ty = operand.ty(&self.mir.local_decls, self.scx.tcx()); + let fn_ty = operand.ty(self.mir, self.scx.tcx()); let fn_ty = self.scx.tcx().trans_apply_param_substs(self.param_substs, &fn_ty); visit_fn_use(self.scx, fn_ty, false, &mut self.output); } mir::Rvalue::Cast(mir::CastKind::ClosureFnPointer, ref operand, _) => { - let source_ty = operand.ty(&self.mir.local_decls, self.scx.tcx()); + let source_ty = operand.ty(self.mir, self.scx.tcx()); let source_ty = self.scx.tcx().trans_apply_param_substs(self.param_substs, &source_ty); match source_ty.sty { @@ -555,13 +555,13 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { let tcx = self.scx.tcx(); match *kind { mir::TerminatorKind::Call { ref func, .. } => { - let callee_ty = func.ty(&self.mir.local_decls, tcx); + let callee_ty = func.ty(self.mir, tcx); let callee_ty = tcx.trans_apply_param_substs(self.param_substs, &callee_ty); visit_fn_use(self.scx, callee_ty, true, &mut self.output); } mir::TerminatorKind::Drop { ref location, .. } | mir::TerminatorKind::DropAndReplace { ref location, .. } => { - let ty = location.ty(&self.mir.local_decls, self.scx.tcx()) + let ty = location.ty(self.mir, self.scx.tcx()) .to_ty(self.scx.tcx()); let ty = tcx.trans_apply_param_substs(self.param_substs, &ty); visit_drop_use(self.scx, ty, true, self.output); diff --git a/src/librustc_trans/mir/analyze.rs b/src/librustc_trans/mir/analyze.rs index 5c9f6f3b2976d..45afcf51b5203 100644 --- a/src/librustc_trans/mir/analyze.rs +++ b/src/librustc_trans/mir/analyze.rs @@ -137,7 +137,7 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> { // Allow uses of projections of immediate pair fields. if let mir::Lvalue::Projection(ref proj) = *lvalue { if let mir::Lvalue::Local(_) = proj.base { - let ty = proj.base.ty(&self.cx.mir.local_decls, self.cx.ccx.tcx()); + let ty = proj.base.ty(self.cx.mir, self.cx.ccx.tcx()); let ty = self.cx.monomorphize(&ty.to_ty(self.cx.ccx.tcx())); if common::type_is_imm_pair(self.cx.ccx, ty) { @@ -168,7 +168,7 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> { } LvalueContext::Drop => { - let ty = lvalue.ty(&self.cx.mir.local_decls, self.cx.ccx.tcx()); + let ty = lvalue.ty(self.cx.mir, self.cx.ccx.tcx()); let ty = self.cx.monomorphize(&ty.to_ty(self.cx.ccx.tcx())); // Only need the lvalue if we're actually dropping it. diff --git a/src/librustc_trans/mir/block.rs b/src/librustc_trans/mir/block.rs index 8cc1e7879283f..9bb29c340d983 100644 --- a/src/librustc_trans/mir/block.rs +++ b/src/librustc_trans/mir/block.rs @@ -263,7 +263,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { } mir::TerminatorKind::Drop { ref location, target, unwind } => { - let ty = location.ty(&self.mir.local_decls, bcx.tcx()).to_ty(bcx.tcx()); + let ty = location.ty(self.mir, bcx.tcx()).to_ty(bcx.tcx()); let ty = self.monomorphize(&ty); let drop_fn = monomorphize::resolve_drop_in_place(bcx.ccx.shared(), ty); @@ -438,7 +438,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { let extra_args = &args[sig.inputs().len()..]; let extra_args = extra_args.iter().map(|op_arg| { - let op_ty = op_arg.ty(&self.mir.local_decls, bcx.tcx()); + let op_ty = op_arg.ty(self.mir, bcx.tcx()); self.monomorphize(&op_ty) }).collect::>(); diff --git a/src/librustc_trans/mir/constant.rs b/src/librustc_trans/mir/constant.rs index d2479f1d88378..fcb4b25e6fe88 100644 --- a/src/librustc_trans/mir/constant.rs +++ b/src/librustc_trans/mir/constant.rs @@ -275,7 +275,7 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> { let span = statement.source_info.span; match statement.kind { mir::StatementKind::Assign(ref dest, ref rvalue) => { - let ty = dest.ty(&self.mir.local_decls, tcx); + let ty = dest.ty(self.mir, tcx); let ty = self.monomorphize(&ty).to_ty(tcx); match self.const_rvalue(rvalue, ty, span) { Ok(value) => self.store(dest, value, span), @@ -331,7 +331,7 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> { } mir::TerminatorKind::Call { ref func, ref args, ref destination, .. } => { - let fn_ty = func.ty(&self.mir.local_decls, tcx); + let fn_ty = func.ty(self.mir, tcx); let fn_ty = self.monomorphize(&fn_ty); let (def_id, substs) = match fn_ty.sty { ty::TyFnDef(def_id, substs) => (def_id, substs), diff --git a/src/librustc_trans/mir/lvalue.rs b/src/librustc_trans/mir/lvalue.rs index 40cbb4e6537cb..af8976967a1e7 100644 --- a/src/librustc_trans/mir/lvalue.rs +++ b/src/librustc_trans/mir/lvalue.rs @@ -408,7 +408,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { pub fn monomorphized_lvalue_ty(&self, lvalue: &mir::Lvalue<'tcx>) -> Ty<'tcx> { let tcx = self.ccx.tcx(); - let lvalue_ty = lvalue.ty(&self.mir.local_decls, tcx); + let lvalue_ty = lvalue.ty(self.mir, tcx); self.monomorphize(&lvalue_ty.to_ty(tcx)) } } diff --git a/src/librustc_trans/mir/rvalue.rs b/src/librustc_trans/mir/rvalue.rs index 695dd278bc8e6..4bd5091a4f35f 100644 --- a/src/librustc_trans/mir/rvalue.rs +++ b/src/librustc_trans/mir/rvalue.rs @@ -422,7 +422,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { mir::Rvalue::Discriminant(ref lvalue) => { let discr_lvalue = self.trans_lvalue(&bcx, lvalue); let enum_ty = discr_lvalue.ty.to_ty(bcx.tcx()); - let discr_ty = rvalue.ty(&self.mir.local_decls, bcx.tcx()); + let discr_ty = rvalue.ty(&*self.mir, bcx.tcx()); let discr_type = type_of::immediate_type_of(bcx.ccx, discr_ty); let discr = adt::trans_get_discr(&bcx, enum_ty, discr_lvalue.llval, discr_lvalue.alignment, Some(discr_type), true); @@ -476,7 +476,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { mir::Rvalue::Aggregate(..) => { // According to `rvalue_creates_operand`, only ZST // aggregate rvalues are allowed to be operands. - let ty = rvalue.ty(&self.mir.local_decls, self.ccx.tcx()); + let ty = rvalue.ty(self.mir, self.ccx.tcx()); (bcx, OperandRef::new_zst(self.ccx, self.monomorphize(&ty))) } } @@ -676,7 +676,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { true, mir::Rvalue::Repeat(..) | mir::Rvalue::Aggregate(..) => { - let ty = rvalue.ty(&self.mir.local_decls, self.ccx.tcx()); + let ty = rvalue.ty(self.mir, self.ccx.tcx()); let ty = self.monomorphize(&ty); common::type_is_zero_size(self.ccx, ty) } From e1ad1909db65562c6289bf692722d4b31b555125 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 12 Jul 2017 13:15:29 -0700 Subject: [PATCH 080/123] rename trait to conform with 'getter trait' pattern --- src/librustc/mir/mod.rs | 12 ++++++------ src/librustc/mir/tcx.rs | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index ba38d97d09261..d176ae761e181 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -69,18 +69,18 @@ macro_rules! newtype_index { /// Types for locals type LocalDecls<'tcx> = IndexVec>; -pub trait AsLocalDeclsRef<'tcx> { - fn as_ref(&self) -> &LocalDecls<'tcx>; +pub trait HasLocalDecls<'tcx> { + fn local_decls(&self) -> &LocalDecls<'tcx>; } -impl<'tcx> AsLocalDeclsRef<'tcx> for LocalDecls<'tcx> { - fn as_ref(&self) -> &LocalDecls<'tcx> { +impl<'tcx> HasLocalDecls<'tcx> for LocalDecls<'tcx> { + fn local_decls(&self) -> &LocalDecls<'tcx> { self } } -impl<'tcx> AsLocalDeclsRef<'tcx> for Mir<'tcx> { - fn as_ref(&self) -> &LocalDecls<'tcx> { +impl<'tcx> HasLocalDecls<'tcx> for Mir<'tcx> { + fn local_decls(&self) -> &LocalDecls<'tcx> { &self.local_decls } } diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index c99fffe2198b8..d3b87c1201dcf 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -121,10 +121,10 @@ impl<'tcx> TypeFoldable<'tcx> for LvalueTy<'tcx> { } impl<'tcx> Lvalue<'tcx> { - pub fn ty<'a, 'gcx, D: AsLocalDeclsRef<'tcx>>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> LvalueTy<'tcx> { + pub fn ty<'a, 'gcx, D: HasLocalDecls<'tcx>>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> LvalueTy<'tcx> { match *self { Lvalue::Local(index) => - LvalueTy::Ty { ty: local_decls.as_ref()[index].ty }, + LvalueTy::Ty { ty: local_decls.local_decls()[index].ty }, Lvalue::Static(ref data) => LvalueTy::Ty { ty: data.ty }, Lvalue::Projection(ref proj) => @@ -134,7 +134,7 @@ impl<'tcx> Lvalue<'tcx> { } impl<'tcx> Rvalue<'tcx> { - pub fn ty<'a, 'gcx, D: AsLocalDeclsRef<'tcx>>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> + pub fn ty<'a, 'gcx, D: HasLocalDecls<'tcx>>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> { match *self { Rvalue::Use(ref operand) => operand.ty(local_decls, tcx), @@ -206,7 +206,7 @@ impl<'tcx> Rvalue<'tcx> { } impl<'tcx> Operand<'tcx> { - pub fn ty<'a, 'gcx, D: AsLocalDeclsRef<'tcx>>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> { + pub fn ty<'a, 'gcx, D: HasLocalDecls<'tcx>>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> { match self { &Operand::Consume(ref l) => l.ty(local_decls, tcx).to_ty(tcx), &Operand::Constant(ref c) => c.ty, From 0bbc3158300452dbb45931ab8d6740faa840d486 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 12 Jul 2017 13:19:58 -0700 Subject: [PATCH 081/123] please tidy by shortening lines --- src/librustc/mir/tcx.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index d3b87c1201dcf..1af80771fb952 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -121,7 +121,9 @@ impl<'tcx> TypeFoldable<'tcx> for LvalueTy<'tcx> { } impl<'tcx> Lvalue<'tcx> { - pub fn ty<'a, 'gcx, D: HasLocalDecls<'tcx>>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> LvalueTy<'tcx> { + pub fn ty<'a, 'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> LvalueTy<'tcx> + where D: HasLocalDecls<'tcx> + { match *self { Lvalue::Local(index) => LvalueTy::Ty { ty: local_decls.local_decls()[index].ty }, @@ -134,7 +136,8 @@ impl<'tcx> Lvalue<'tcx> { } impl<'tcx> Rvalue<'tcx> { - pub fn ty<'a, 'gcx, D: HasLocalDecls<'tcx>>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> + pub fn ty<'a, 'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> + where D: HasLocalDecls<'tcx> { match *self { Rvalue::Use(ref operand) => operand.ty(local_decls, tcx), @@ -206,7 +209,9 @@ impl<'tcx> Rvalue<'tcx> { } impl<'tcx> Operand<'tcx> { - pub fn ty<'a, 'gcx, D: HasLocalDecls<'tcx>>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> { + pub fn ty<'a, 'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> + where D: HasLocalDecls<'tcx> + { match self { &Operand::Consume(ref l) => l.ty(local_decls, tcx).to_ty(tcx), &Operand::Constant(ref c) => c.ty, From b7a4c54413a88ee94fb7a5c31169c9fb0c3a7f3f Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Wed, 12 Jul 2017 16:34:18 -0600 Subject: [PATCH 082/123] Change language in Travis configuration to shell In theory, this will give us more disk space to work with and unblock the queue. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 21877ecb43e10..3d3c1ca4082cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -language: generic +language: shell sudo: required dist: trusty services: From 250346128b0083c8137171af503bda194c6124dd Mon Sep 17 00:00:00 2001 From: Ty Coghlan Date: Sun, 9 Jul 2017 11:01:27 -0400 Subject: [PATCH 083/123] Updated docker images to factor out common scripts --- src/ci/docker/arm-android/Dockerfile | 25 +------- src/ci/docker/armhf-gnu/Dockerfile | 11 ++-- src/ci/docker/asmjs/Dockerfile | 5 -- src/ci/docker/cross/Dockerfile | 2 - .../disabled/dist-aarch64-android/Dockerfile | 24 +------ .../disabled/dist-armv7-android/Dockerfile | 22 +------ .../disabled/dist-i686-android/Dockerfile | 22 +------ .../disabled/dist-x86_64-android/Dockerfile | 24 +------ src/ci/docker/disabled/wasm32/Dockerfile | 5 -- src/ci/docker/dist-aarch64-linux/Dockerfile | 64 ++++--------------- src/ci/docker/dist-android/Dockerfile | 22 +------ src/ci/docker/dist-arm-linux/Dockerfile | 64 ++++--------------- src/ci/docker/dist-armhf-linux/Dockerfile | 64 ++++--------------- src/ci/docker/dist-armv7-linux/Dockerfile | 64 ++++--------------- src/ci/docker/dist-fuchsia/Dockerfile | 11 ++-- .../docker/dist-i586-gnu-i686-musl/Dockerfile | 11 ++-- src/ci/docker/dist-i686-freebsd/Dockerfile | 11 ++-- src/ci/docker/dist-i686-linux/Dockerfile | 5 +- src/ci/docker/dist-mips-linux/Dockerfile | 12 ++-- src/ci/docker/dist-mips64-linux/Dockerfile | 11 ++-- src/ci/docker/dist-mips64el-linux/Dockerfile | 12 ++-- src/ci/docker/dist-mipsel-linux/Dockerfile | 11 ++-- src/ci/docker/dist-powerpc-linux/Dockerfile | 64 ++++--------------- src/ci/docker/dist-powerpc64-linux/Dockerfile | 64 ++++--------------- .../docker/dist-powerpc64le-linux/Dockerfile | 64 ++++--------------- src/ci/docker/dist-s390x-linux/Dockerfile | 64 ++++--------------- src/ci/docker/dist-x86_64-freebsd/Dockerfile | 11 ++-- src/ci/docker/dist-x86_64-linux/Dockerfile | 5 +- src/ci/docker/dist-x86_64-musl/Dockerfile | 11 ++-- src/ci/docker/dist-x86_64-netbsd/Dockerfile | 64 ++++--------------- src/ci/docker/i686-gnu-nopt/Dockerfile | 12 ++-- src/ci/docker/i686-gnu/Dockerfile | 12 ++-- src/ci/docker/scripts/android-base-apt-get.sh | 27 ++++++++ src/ci/docker/scripts/cross-apt-packages.sh | 36 +++++++++++ src/ci/docker/scripts/crosstool-ng.sh | 20 ++++++ src/ci/docker/scripts/make3.sh | 19 ++++++ src/ci/docker/scripts/rustbuild-setup.sh | 14 ++++ src/ci/docker/x86_64-gnu-aux/Dockerfile | 11 ++-- src/ci/docker/x86_64-gnu-debug/Dockerfile | 11 ++-- src/ci/docker/x86_64-gnu-distcheck/Dockerfile | 11 ++-- .../x86_64-gnu-full-bootstrap/Dockerfile | 11 ++-- .../docker/x86_64-gnu-incremental/Dockerfile | 11 ++-- src/ci/docker/x86_64-gnu-llvm-3.7/Dockerfile | 11 ++-- src/ci/docker/x86_64-gnu-nopt/Dockerfile | 11 ++-- src/ci/docker/x86_64-gnu/Dockerfile | 11 ++-- 45 files changed, 366 insertions(+), 711 deletions(-) create mode 100644 src/ci/docker/scripts/android-base-apt-get.sh create mode 100644 src/ci/docker/scripts/cross-apt-packages.sh create mode 100644 src/ci/docker/scripts/crosstool-ng.sh create mode 100644 src/ci/docker/scripts/make3.sh create mode 100644 src/ci/docker/scripts/rustbuild-setup.sh diff --git a/src/ci/docker/arm-android/Dockerfile b/src/ci/docker/arm-android/Dockerfile index 2a928c5ec7e89..6cdaf6acfef64 100644 --- a/src/ci/docker/arm-android/Dockerfile +++ b/src/ci/docker/arm-android/Dockerfile @@ -1,31 +1,15 @@ FROM ubuntu:16.04 -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - ca-certificates \ - cmake \ - curl \ - file \ - g++ \ - git \ - libssl-dev \ - make \ - pkg-config \ - python2.7 \ - sudo \ - unzip \ - xz-utils - -# dumb-init +COPY scripts/android-base-apt-get.sh /scripts/ +RUN sh /scripts/android-base-apt-get.sh + COPY scripts/dumb-init.sh /scripts/ RUN sh /scripts/dumb-init.sh -# ndk COPY scripts/android-ndk.sh /scripts/ RUN . /scripts/android-ndk.sh && \ download_and_make_toolchain android-ndk-r13b-linux-x86_64.zip arm 9 -# sdk RUN dpkg --add-architecture i386 && \ apt-get update && \ apt-get install -y --no-install-recommends \ @@ -39,7 +23,6 @@ COPY scripts/android-sdk.sh /scripts/ RUN . /scripts/android-sdk.sh && \ download_and_create_avd tools_r25.2.5-linux.zip armeabi-v7a 18 -# env ENV PATH=$PATH:/android/sdk/tools ENV PATH=$PATH:/android/sdk/platform-tools @@ -51,10 +34,8 @@ ENV RUST_CONFIGURE_ARGS \ ENV SCRIPT python2.7 ../x.py test --target $TARGETS -# sccache COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh -# init COPY scripts/android-start-emulator.sh /scripts/ ENTRYPOINT ["/usr/bin/dumb-init", "--", "/scripts/android-start-emulator.sh"] diff --git a/src/ci/docker/armhf-gnu/Dockerfile b/src/ci/docker/armhf-gnu/Dockerfile index 03e0b78ba89b3..d289a93c35295 100644 --- a/src/ci/docker/armhf-gnu/Dockerfile +++ b/src/ci/docker/armhf-gnu/Dockerfile @@ -73,13 +73,12 @@ RUN arm-linux-gnueabihf-gcc addentropy.c -o rootfs/addentropy -static # TODO: What is this?! RUN curl -O http://ftp.nl.debian.org/debian/dists/jessie/main/installer-armhf/current/images/device-tree/vexpress-v2p-ca15-tc1.dtb -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENV RUST_CONFIGURE_ARGS \ diff --git a/src/ci/docker/asmjs/Dockerfile b/src/ci/docker/asmjs/Dockerfile index 899ce1e4569df..1c39e8523daaa 100644 --- a/src/ci/docker/asmjs/Dockerfile +++ b/src/ci/docker/asmjs/Dockerfile @@ -13,15 +13,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gdb \ xz-utils -# dumb-init COPY scripts/dumb-init.sh /scripts/ RUN sh /scripts/dumb-init.sh -# emscripten COPY scripts/emscripten.sh /scripts/ RUN bash /scripts/emscripten.sh -# env ENV PATH=$PATH:/emsdk-portable ENV PATH=$PATH:/emsdk-portable/clang/e1.37.13_64bit/ ENV PATH=$PATH:/emsdk-portable/emscripten/1.37.13/ @@ -36,9 +33,7 @@ ENV RUST_CONFIGURE_ARGS --target=$TARGETS ENV SCRIPT python2.7 ../x.py test --target $TARGETS -# cache COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh -# init ENTRYPOINT ["/usr/bin/dumb-init", "--"] diff --git a/src/ci/docker/cross/Dockerfile b/src/ci/docker/cross/Dockerfile index b4399a8d53ff0..70dfbb53da24e 100644 --- a/src/ci/docker/cross/Dockerfile +++ b/src/ci/docker/cross/Dockerfile @@ -21,7 +21,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libssl-dev \ pkg-config -# dumb-init COPY scripts/dumb-init.sh /scripts/ RUN sh /scripts/dumb-init.sh @@ -68,5 +67,4 @@ ENV SCRIPT python2.7 ../x.py dist --target $TARGETS COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh -# init ENTRYPOINT ["/usr/bin/dumb-init", "--"] diff --git a/src/ci/docker/disabled/dist-aarch64-android/Dockerfile b/src/ci/docker/disabled/dist-aarch64-android/Dockerfile index 918d2911ae28f..1c9e036f093da 100644 --- a/src/ci/docker/disabled/dist-aarch64-android/Dockerfile +++ b/src/ci/docker/disabled/dist-aarch64-android/Dockerfile @@ -1,31 +1,15 @@ FROM ubuntu:16.04 -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - ca-certificates \ - cmake \ - curl \ - file \ - g++ \ - git \ - libssl-dev \ - make \ - pkg-config \ - python2.7 \ - sudo \ - unzip \ - xz-utils - -# dumb-init +COPY scripts/android-base-apt-get.sh /scripts/ +RUN sh /scripts/android-base-apt-get.sh + COPY scripts/dumb-init.sh /scripts/ RUN sh /scripts/dumb-init.sh -# ndk COPY scripts/android-ndk.sh /scripts/ RUN . /scripts/android-ndk.sh && \ download_and_make_toolchain android-ndk-r13b-linux-x86_64.zip arm64 21 -# env ENV PATH=$PATH:/android/ndk/arm64-21/bin ENV DEP_Z_ROOT=/android/ndk/arm64-21/sysroot/usr/ @@ -42,9 +26,7 @@ ENV RUST_CONFIGURE_ARGS \ ENV SCRIPT python2.7 ../x.py dist --target $HOSTS --host $HOSTS -# sccache COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh -# init ENTRYPOINT ["/usr/bin/dumb-init", "--"] diff --git a/src/ci/docker/disabled/dist-armv7-android/Dockerfile b/src/ci/docker/disabled/dist-armv7-android/Dockerfile index aed82e6c13872..326e00548b1ce 100644 --- a/src/ci/docker/disabled/dist-armv7-android/Dockerfile +++ b/src/ci/docker/disabled/dist-armv7-android/Dockerfile @@ -1,26 +1,11 @@ FROM ubuntu:16.04 -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - ca-certificates \ - cmake \ - curl \ - file \ - g++ \ - git \ - libssl-dev \ - make \ - pkg-config \ - python2.7 \ - sudo \ - unzip \ - xz-utils +COPY scripts/android-base-apt-get.sh /scripts/ +RUN sh /scripts/android-base-apt-get.sh -# dumb-init COPY scripts/dumb-init.sh /scripts/ RUN sh /scripts/dumb-init.sh -# ndk COPY scripts/android-ndk.sh /scripts/ RUN . /scripts/android-ndk.sh && \ download_ndk android-ndk-r13b-linux-x86_64.zip && \ @@ -31,7 +16,6 @@ RUN . /scripts/android-ndk.sh && \ RUN chmod 777 /android/ndk && \ ln -s /android/ndk/arm-21 /android/ndk/arm -# env ENV PATH=$PATH:/android/ndk/arm-9/bin ENV DEP_Z_ROOT=/android/ndk/arm-9/sysroot/usr/ @@ -60,9 +44,7 @@ ENV SCRIPT \ ln -s /android/ndk/arm-9 /android/ndk/arm && \ python2.7 ../x.py dist --host $HOSTS --target $HOSTS) -# sccache COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh -# init ENTRYPOINT ["/usr/bin/dumb-init", "--"] diff --git a/src/ci/docker/disabled/dist-i686-android/Dockerfile b/src/ci/docker/disabled/dist-i686-android/Dockerfile index f012e869e7885..d01648e2b9d7f 100644 --- a/src/ci/docker/disabled/dist-i686-android/Dockerfile +++ b/src/ci/docker/disabled/dist-i686-android/Dockerfile @@ -1,26 +1,11 @@ FROM ubuntu:16.04 -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - ca-certificates \ - cmake \ - curl \ - file \ - g++ \ - git \ - libssl-dev \ - make \ - pkg-config \ - python2.7 \ - sudo \ - unzip \ - xz-utils +COPY scripts/android-base-apt-get.sh /scripts/ +RUN sh /scripts/android-base-apt-get.sh -# dumb-init COPY scripts/dumb-init.sh /scripts/ RUN sh /scripts/dumb-init.sh -# ndk COPY scripts/android-ndk.sh /scripts/ RUN . /scripts/android-ndk.sh && \ download_ndk android-ndk-r13b-linux-x86_64.zip && \ @@ -31,7 +16,6 @@ RUN . /scripts/android-ndk.sh && \ RUN chmod 777 /android/ndk && \ ln -s /android/ndk/x86-21 /android/ndk/x86 -# env ENV PATH=$PATH:/android/ndk/x86-9/bin ENV DEP_Z_ROOT=/android/ndk/x86-9/sysroot/usr/ @@ -60,9 +44,7 @@ ENV SCRIPT \ ln -s /android/ndk/x86-9 /android/ndk/x86 && \ python2.7 ../x.py dist --host $HOSTS --target $HOSTS) -# sccache COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh -# init ENTRYPOINT ["/usr/bin/dumb-init", "--"] diff --git a/src/ci/docker/disabled/dist-x86_64-android/Dockerfile b/src/ci/docker/disabled/dist-x86_64-android/Dockerfile index 0c586452840f9..2622b4b3fac3b 100644 --- a/src/ci/docker/disabled/dist-x86_64-android/Dockerfile +++ b/src/ci/docker/disabled/dist-x86_64-android/Dockerfile @@ -1,31 +1,15 @@ FROM ubuntu:16.04 -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - ca-certificates \ - cmake \ - curl \ - file \ - g++ \ - git \ - libssl-dev \ - make \ - pkg-config \ - python2.7 \ - sudo \ - unzip \ - xz-utils - -# dumb-init +COPY scripts/android-base-apt-get.sh /scripts/ +RUN sh /scripts/android-base-apt-get.sh + COPY scripts/dumb-init.sh /scripts/ RUN sh /scripts/dumb-init.sh -# ndk COPY scripts/android-ndk.sh /scripts/ RUN . /scripts/android-ndk.sh && \ download_and_make_toolchain android-ndk-r13b-linux-x86_64.zip x86_64 21 -# env ENV PATH=$PATH:/android/ndk/x86_64-21/bin ENV DEP_Z_ROOT=/android/ndk/x86_64-21/sysroot/usr/ @@ -42,9 +26,7 @@ ENV RUST_CONFIGURE_ARGS \ ENV SCRIPT python2.7 ../x.py dist --target $HOSTS --host $HOSTS -# sccache COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh -# init ENTRYPOINT ["/usr/bin/dumb-init", "--"] diff --git a/src/ci/docker/disabled/wasm32/Dockerfile b/src/ci/docker/disabled/wasm32/Dockerfile index c75b5d455c522..66d7c48022263 100644 --- a/src/ci/docker/disabled/wasm32/Dockerfile +++ b/src/ci/docker/disabled/wasm32/Dockerfile @@ -15,20 +15,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ jq \ bzip2 -# dumb-init COPY scripts/dumb-init.sh /scripts/ RUN sh /scripts/dumb-init.sh -# emscripten COPY scripts/emscripten-wasm.sh /scripts/ RUN bash /scripts/emscripten-wasm.sh COPY disabled/wasm32/node.sh /usr/local/bin/node -# cache COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh -# env ENV PATH=$PATH:/emsdk-portable ENV PATH=$PATH:/emsdk-portable/clang/e1.37.13_64bit/ ENV PATH=$PATH:/emsdk-portable/emscripten/1.37.13/ @@ -42,5 +38,4 @@ ENV RUST_CONFIGURE_ARGS --target=$TARGETS --experimental-targets=WebAssembly ENV SCRIPT python2.7 ../x.py test --target $TARGETS -# init ENTRYPOINT ["/usr/bin/dumb-init", "--"] diff --git a/src/ci/docker/dist-aarch64-linux/Dockerfile b/src/ci/docker/dist-aarch64-linux/Dockerfile index 0134a5407932a..cc3b6b8c692a6 100644 --- a/src/ci/docker/dist-aarch64-linux/Dockerfile +++ b/src/ci/docker/dist-aarch64-linux/Dockerfile @@ -1,58 +1,23 @@ FROM ubuntu:16.04 -RUN apt-get update && apt-get install -y --no-install-recommends \ - automake \ - bison \ - bzip2 \ - ca-certificates \ - cmake \ - curl \ - file \ - flex \ - g++ \ - gawk \ - gdb \ - git \ - gperf \ - help2man \ - libncurses-dev \ - libtool-bin \ - make \ - patch \ - python2.7 \ - sudo \ - texinfo \ - wget \ - xz-utils \ - libssl-dev \ - pkg-config +COPY scripts/cross-apt-packages.sh /scripts/ +RUN sh /scripts/cross-apt-packages.sh + +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] -# Ubuntu 16.04 (this contianer) ships with make 4, but something in the +# Ubuntu 16.04 (this container) ships with make 4, but something in the # toolchains we build below chokes on that, so go back to make 3 -RUN curl https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf - && \ - cd make-3.81 && \ - ./configure --prefix=/usr && \ - make && \ - make install && \ - cd .. && \ - rm -rf make-3.81 +COPY scripts/make3.sh /scripts/ +RUN sh /scripts/make3.sh -RUN curl http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.bz2 | \ - tar xjf - && \ - cd crosstool-ng && \ - ./configure --prefix=/usr/local && \ - make -j$(nproc) && \ - make install && \ - cd .. && \ - rm -rf crosstool-ng +COPY scripts/crosstool-ng.sh /scripts/ +RUN sh /scripts/crosstool-ng.sh -RUN groupadd -r rustbuild && useradd -m -r -g rustbuild rustbuild -RUN mkdir /x-tools && chown rustbuild:rustbuild /x-tools +COPY scripts/rustbuild-setup.sh /scripts/ +RUN sh /scripts/rustbuild-setup.sh USER rustbuild WORKDIR /tmp @@ -61,9 +26,8 @@ RUN ./build-toolchains.sh USER root -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh ENV PATH=$PATH:/x-tools/aarch64-unknown-linux-gnueabi/bin diff --git a/src/ci/docker/dist-android/Dockerfile b/src/ci/docker/dist-android/Dockerfile index 31389dd148a8a..f3beddfae0a16 100644 --- a/src/ci/docker/dist-android/Dockerfile +++ b/src/ci/docker/dist-android/Dockerfile @@ -1,22 +1,8 @@ FROM ubuntu:16.04 -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - ca-certificates \ - cmake \ - curl \ - file \ - g++ \ - git \ - libssl-dev \ - make \ - pkg-config \ - python2.7 \ - sudo \ - unzip \ - xz-utils - -# dumb-init +COPY scripts/android-base-apt-get.sh /scripts/ +RUN sh /scripts/android-base-apt-get.sh + COPY scripts/dumb-init.sh /scripts/ RUN sh /scripts/dumb-init.sh @@ -48,9 +34,7 @@ ENV RUST_CONFIGURE_ARGS \ ENV SCRIPT python2.7 ../x.py dist --target $TARGETS -# cache COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh -# init ENTRYPOINT ["/usr/bin/dumb-init", "--"] diff --git a/src/ci/docker/dist-arm-linux/Dockerfile b/src/ci/docker/dist-arm-linux/Dockerfile index 862818a7c9182..590d6eb98b382 100644 --- a/src/ci/docker/dist-arm-linux/Dockerfile +++ b/src/ci/docker/dist-arm-linux/Dockerfile @@ -1,58 +1,23 @@ FROM ubuntu:16.04 -RUN apt-get update && apt-get install -y --no-install-recommends \ - automake \ - bison \ - bzip2 \ - ca-certificates \ - cmake \ - curl \ - file \ - flex \ - g++ \ - gawk \ - gdb \ - git \ - gperf \ - help2man \ - libncurses-dev \ - libtool-bin \ - make \ - patch \ - python2.7 \ - sudo \ - texinfo \ - wget \ - xz-utils \ - libssl-dev \ - pkg-config +COPY scripts/cross-apt-packages.sh /scripts/ +RUN sh /scripts/cross-apt-packages.sh + +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] -# Ubuntu 16.04 (this contianer) ships with make 4, but something in the +# Ubuntu 16.04 (this container) ships with make 4, but something in the # toolchains we build below chokes on that, so go back to make 3 -RUN curl https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf - && \ - cd make-3.81 && \ - ./configure --prefix=/usr && \ - make && \ - make install && \ - cd .. && \ - rm -rf make-3.81 +COPY scripts/make3.sh /scripts/ +RUN sh /scripts/make3.sh -RUN curl http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.bz2 | \ - tar xjf - && \ - cd crosstool-ng && \ - ./configure --prefix=/usr/local && \ - make -j$(nproc) && \ - make install && \ - cd .. && \ - rm -rf crosstool-ng +COPY scripts/crosstool-ng.sh /scripts/ +RUN sh /scripts/crosstool-ng.sh -RUN groupadd -r rustbuild && useradd -m -r -g rustbuild rustbuild -RUN mkdir /x-tools && chown rustbuild:rustbuild /x-tools +COPY scripts/rustbuild-setup.sh /scripts/ +RUN sh /scripts/rustbuild-setup.sh USER rustbuild WORKDIR /tmp @@ -61,9 +26,8 @@ RUN ./build-toolchains.sh USER root -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh ENV PATH=$PATH:/x-tools/arm-unknown-linux-gnueabi/bin diff --git a/src/ci/docker/dist-armhf-linux/Dockerfile b/src/ci/docker/dist-armhf-linux/Dockerfile index 7f1f91f844c77..b3dedc4b7f0fe 100644 --- a/src/ci/docker/dist-armhf-linux/Dockerfile +++ b/src/ci/docker/dist-armhf-linux/Dockerfile @@ -1,58 +1,23 @@ FROM ubuntu:16.04 -RUN apt-get update && apt-get install -y --no-install-recommends \ - automake \ - bison \ - bzip2 \ - ca-certificates \ - cmake \ - curl \ - file \ - flex \ - g++ \ - gawk \ - gdb \ - git \ - gperf \ - help2man \ - libncurses-dev \ - libtool-bin \ - make \ - patch \ - python2.7 \ - sudo \ - texinfo \ - wget \ - xz-utils \ - libssl-dev \ - pkg-config +COPY scripts/cross-apt-packages.sh /scripts/ +RUN sh /scripts/cross-apt-packages.sh + +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] -# Ubuntu 16.04 (this contianer) ships with make 4, but something in the +# Ubuntu 16.04 (this container) ships with make 4, but something in the # toolchains we build below chokes on that, so go back to make 3 -RUN curl https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf - && \ - cd make-3.81 && \ - ./configure --prefix=/usr && \ - make && \ - make install && \ - cd .. && \ - rm -rf make-3.81 +COPY scripts/make3.sh /scripts/ +RUN sh /scripts/make3.sh -RUN curl http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.bz2 | \ - tar xjf - && \ - cd crosstool-ng && \ - ./configure --prefix=/usr/local && \ - make -j$(nproc) && \ - make install && \ - cd .. && \ - rm -rf crosstool-ng +COPY scripts/crosstool-ng.sh /scripts/ +RUN sh /scripts/crosstool-ng.sh -RUN groupadd -r rustbuild && useradd -m -r -g rustbuild rustbuild -RUN mkdir /x-tools && chown rustbuild:rustbuild /x-tools +COPY scripts/rustbuild-setup.sh /scripts/ +RUN sh /scripts/rustbuild-setup.sh USER rustbuild WORKDIR /tmp @@ -61,9 +26,8 @@ RUN ./build-toolchains.sh USER root -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh ENV PATH=$PATH:/x-tools/arm-unknown-linux-gnueabihf/bin diff --git a/src/ci/docker/dist-armv7-linux/Dockerfile b/src/ci/docker/dist-armv7-linux/Dockerfile index 030fd24ebcdd0..82536b68bbe06 100644 --- a/src/ci/docker/dist-armv7-linux/Dockerfile +++ b/src/ci/docker/dist-armv7-linux/Dockerfile @@ -1,58 +1,23 @@ FROM ubuntu:16.04 -RUN apt-get update && apt-get install -y --no-install-recommends \ - automake \ - bison \ - bzip2 \ - ca-certificates \ - cmake \ - curl \ - file \ - flex \ - g++ \ - gawk \ - gdb \ - git \ - gperf \ - help2man \ - libncurses-dev \ - libtool-bin \ - make \ - patch \ - python2.7 \ - sudo \ - texinfo \ - wget \ - xz-utils \ - libssl-dev \ - pkg-config +COPY scripts/cross-apt-packages.sh /scripts/ +RUN sh /scripts/cross-apt-packages.sh + +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] -# Ubuntu 16.04 (this contianer) ships with make 4, but something in the +# Ubuntu 16.04 (this container) ships with make 4, but something in the # toolchains we build below chokes on that, so go back to make 3 -RUN curl https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf - && \ - cd make-3.81 && \ - ./configure --prefix=/usr && \ - make && \ - make install && \ - cd .. && \ - rm -rf make-3.81 +COPY scripts/make3.sh /scripts/ +RUN sh /scripts/make3.sh -RUN curl http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.bz2 | \ - tar xjf - && \ - cd crosstool-ng && \ - ./configure --prefix=/usr/local && \ - make -j$(nproc) && \ - make install && \ - cd .. && \ - rm -rf crosstool-ng +COPY scripts/crosstool-ng.sh /scripts/ +RUN sh /scripts/crosstool-ng.sh -RUN groupadd -r rustbuild && useradd -m -r -g rustbuild rustbuild -RUN mkdir /x-tools && chown rustbuild:rustbuild /x-tools +COPY scripts/rustbuild-setup.sh /scripts/ +RUN sh /scripts/rustbuild-setup.sh USER rustbuild WORKDIR /tmp @@ -61,9 +26,8 @@ RUN ./build-toolchains.sh USER root -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh ENV PATH=$PATH:/x-tools/armv7-unknown-linux-gnueabihf/bin diff --git a/src/ci/docker/dist-fuchsia/Dockerfile b/src/ci/docker/dist-fuchsia/Dockerfile index d1d9767d35e63..24ad12a49007c 100644 --- a/src/ci/docker/dist-fuchsia/Dockerfile +++ b/src/ci/docker/dist-fuchsia/Dockerfile @@ -24,14 +24,13 @@ WORKDIR /tmp COPY dist-fuchsia/shared.sh dist-fuchsia/build-toolchain.sh dist-fuchsia/compiler-rt-dso-handle.patch /tmp/ RUN /tmp/build-toolchain.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + ENTRYPOINT ["/usr/bin/dumb-init", "--"] -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh ENV \ AR_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-ar \ diff --git a/src/ci/docker/dist-i586-gnu-i686-musl/Dockerfile b/src/ci/docker/dist-i586-gnu-i686-musl/Dockerfile index 805d238de1f9b..036dce2a73526 100644 --- a/src/ci/docker/dist-i586-gnu-i686-musl/Dockerfile +++ b/src/ci/docker/dist-i586-gnu-i686-musl/Dockerfile @@ -20,14 +20,13 @@ WORKDIR /build/ COPY dist-i586-gnu-i686-musl/musl-libunwind-patch.patch dist-i586-gnu-i686-musl/build-musl.sh /build/ RUN sh /build/build-musl.sh && rm -rf /build -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + ENTRYPOINT ["/usr/bin/dumb-init", "--"] -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh ENV RUST_CONFIGURE_ARGS \ --target=i686-unknown-linux-musl,i586-unknown-linux-gnu \ diff --git a/src/ci/docker/dist-i686-freebsd/Dockerfile b/src/ci/docker/dist-i686-freebsd/Dockerfile index 9c4d43bfa92bc..c40881332a108 100644 --- a/src/ci/docker/dist-i686-freebsd/Dockerfile +++ b/src/ci/docker/dist-i686-freebsd/Dockerfile @@ -19,14 +19,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ COPY dist-i686-freebsd/build-toolchain.sh /tmp/ RUN /tmp/build-toolchain.sh i686 -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + ENTRYPOINT ["/usr/bin/dumb-init", "--"] -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh ENV \ AR_i686_unknown_freebsd=i686-unknown-freebsd10-ar \ diff --git a/src/ci/docker/dist-i686-linux/Dockerfile b/src/ci/docker/dist-i686-linux/Dockerfile index 9145e9dfc8d1a..beb53783bac40 100644 --- a/src/ci/docker/dist-i686-linux/Dockerfile +++ b/src/ci/docker/dist-i686-linux/Dockerfile @@ -81,9 +81,8 @@ RUN curl -Lo /rustroot/dumb-init \ chmod +x /rustroot/dumb-init ENTRYPOINT ["/rustroot/dumb-init", "--"] -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh ENV HOSTS=i686-unknown-linux-gnu diff --git a/src/ci/docker/dist-mips-linux/Dockerfile b/src/ci/docker/dist-mips-linux/Dockerfile index c23240f0c70f9..81997e0508ac5 100644 --- a/src/ci/docker/dist-mips-linux/Dockerfile +++ b/src/ci/docker/dist-mips-linux/Dockerfile @@ -16,13 +16,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libssl-dev \ pkg-config -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh + ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENV HOSTS=mips-unknown-linux-gnu diff --git a/src/ci/docker/dist-mips64-linux/Dockerfile b/src/ci/docker/dist-mips64-linux/Dockerfile index 415dca99d95ee..646cb4d256ac0 100644 --- a/src/ci/docker/dist-mips64-linux/Dockerfile +++ b/src/ci/docker/dist-mips64-linux/Dockerfile @@ -16,13 +16,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libssl-dev \ pkg-config -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENV HOSTS=mips64-unknown-linux-gnuabi64 diff --git a/src/ci/docker/dist-mips64el-linux/Dockerfile b/src/ci/docker/dist-mips64el-linux/Dockerfile index 2aba5f615baba..1abb04fd8b286 100644 --- a/src/ci/docker/dist-mips64el-linux/Dockerfile +++ b/src/ci/docker/dist-mips64el-linux/Dockerfile @@ -16,13 +16,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libssl-dev \ pkg-config -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh + ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENV HOSTS=mips64el-unknown-linux-gnuabi64 diff --git a/src/ci/docker/dist-mipsel-linux/Dockerfile b/src/ci/docker/dist-mipsel-linux/Dockerfile index d15e3010863c4..a78e39e7d7129 100644 --- a/src/ci/docker/dist-mipsel-linux/Dockerfile +++ b/src/ci/docker/dist-mipsel-linux/Dockerfile @@ -16,13 +16,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libssl-dev \ pkg-config -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENV HOSTS=mipsel-unknown-linux-gnu diff --git a/src/ci/docker/dist-powerpc-linux/Dockerfile b/src/ci/docker/dist-powerpc-linux/Dockerfile index 0074665f34f7e..ed9f883cc83f7 100644 --- a/src/ci/docker/dist-powerpc-linux/Dockerfile +++ b/src/ci/docker/dist-powerpc-linux/Dockerfile @@ -1,58 +1,23 @@ FROM ubuntu:16.04 -RUN apt-get update && apt-get install -y --no-install-recommends \ - automake \ - bison \ - bzip2 \ - ca-certificates \ - cmake \ - curl \ - file \ - flex \ - g++ \ - gawk \ - gdb \ - git \ - gperf \ - help2man \ - libncurses-dev \ - libtool-bin \ - make \ - patch \ - python2.7 \ - sudo \ - texinfo \ - wget \ - xz-utils \ - libssl-dev \ - pkg-config +COPY scripts/cross-apt-packages.sh /scripts/ +RUN sh /scripts/cross-apt-packages.sh + +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] -# Ubuntu 16.04 (this contianer) ships with make 4, but something in the +# Ubuntu 16.04 (this container) ships with make 4, but something in the # toolchains we build below chokes on that, so go back to make 3 -RUN curl https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf - && \ - cd make-3.81 && \ - ./configure --prefix=/usr && \ - make && \ - make install && \ - cd .. && \ - rm -rf make-3.81 +COPY scripts/make3.sh /scripts/ +RUN sh /scripts/make3.sh -RUN curl http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.bz2 | \ - tar xjf - && \ - cd crosstool-ng && \ - ./configure --prefix=/usr/local && \ - make -j$(nproc) && \ - make install && \ - cd .. && \ - rm -rf crosstool-ng +COPY scripts/crosstool-ng.sh /scripts/ +RUN sh /scripts/crosstool-ng.sh -RUN groupadd -r rustbuild && useradd -m -r -g rustbuild rustbuild -RUN mkdir /x-tools && chown rustbuild:rustbuild /x-tools +COPY scripts/rustbuild-setup.sh /scripts/ +RUN sh /scripts/rustbuild-setup.sh USER rustbuild WORKDIR /tmp @@ -62,9 +27,8 @@ RUN ./build-powerpc-toolchain.sh USER root -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh ENV PATH=$PATH:/x-tools/powerpc-unknown-linux-gnu/bin diff --git a/src/ci/docker/dist-powerpc64-linux/Dockerfile b/src/ci/docker/dist-powerpc64-linux/Dockerfile index bd38ee0c11158..523211498fb43 100644 --- a/src/ci/docker/dist-powerpc64-linux/Dockerfile +++ b/src/ci/docker/dist-powerpc64-linux/Dockerfile @@ -1,58 +1,23 @@ FROM ubuntu:16.04 -RUN apt-get update && apt-get install -y --no-install-recommends \ - automake \ - bison \ - bzip2 \ - ca-certificates \ - cmake \ - curl \ - file \ - flex \ - g++ \ - gawk \ - gdb \ - git \ - gperf \ - help2man \ - libncurses-dev \ - libtool-bin \ - make \ - patch \ - python2.7 \ - sudo \ - texinfo \ - wget \ - xz-utils \ - libssl-dev \ - pkg-config +COPY scripts/cross-apt-packages.sh /scripts/ +RUN sh /scripts/cross-apt-packages.sh + +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] -# Ubuntu 16.04 (this contianer) ships with make 4, but something in the +# Ubuntu 16.04 (this container) ships with make 4, but something in the # toolchains we build below chokes on that, so go back to make 3 -RUN curl https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf - && \ - cd make-3.81 && \ - ./configure --prefix=/usr && \ - make && \ - make install && \ - cd .. && \ - rm -rf make-3.81 +COPY scripts/make3.sh /scripts/ +RUN sh /scripts/make3.sh -RUN curl http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.bz2 | \ - tar xjf - && \ - cd crosstool-ng && \ - ./configure --prefix=/usr/local && \ - make -j$(nproc) && \ - make install && \ - cd .. && \ - rm -rf crosstool-ng +COPY scripts/crosstool-ng.sh /scripts/ +RUN sh /scripts/crosstool-ng.sh -RUN groupadd -r rustbuild && useradd -m -r -g rustbuild rustbuild -RUN mkdir /x-tools && chown rustbuild:rustbuild /x-tools +COPY scripts/rustbuild-setup.sh /scripts/ +RUN sh /scripts/rustbuild-setup.sh USER rustbuild WORKDIR /tmp @@ -62,9 +27,8 @@ RUN ./build-powerpc64-toolchain.sh USER root -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh ENV PATH=$PATH:/x-tools/powerpc64-unknown-linux-gnu/bin diff --git a/src/ci/docker/dist-powerpc64le-linux/Dockerfile b/src/ci/docker/dist-powerpc64le-linux/Dockerfile index cbded156b4cbd..06b262c515a24 100644 --- a/src/ci/docker/dist-powerpc64le-linux/Dockerfile +++ b/src/ci/docker/dist-powerpc64le-linux/Dockerfile @@ -1,58 +1,23 @@ FROM ubuntu:16.04 -RUN apt-get update && apt-get install -y --no-install-recommends \ - automake \ - bison \ - bzip2 \ - ca-certificates \ - cmake \ - curl \ - file \ - flex \ - g++ \ - gawk \ - gdb \ - git \ - gperf \ - help2man \ - libncurses-dev \ - libtool-bin \ - make \ - patch \ - python2.7 \ - sudo \ - texinfo \ - wget \ - xz-utils \ - libssl-dev \ - pkg-config +COPY scripts/cross-apt-packages.sh /scripts/ +RUN sh /scripts/cross-apt-packages.sh + +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] -# Ubuntu 16.04 (this contianer) ships with make 4, but something in the +# Ubuntu 16.04 (this container) ships with make 4, but something in the # toolchains we build below chokes on that, so go back to make 3 -RUN curl https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf - && \ - cd make-3.81 && \ - ./configure --prefix=/usr && \ - make && \ - make install && \ - cd .. && \ - rm -rf make-3.81 +COPY scripts/make3.sh /scripts/ +RUN sh /scripts/make3.sh -RUN curl http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.bz2 | \ - tar xjf - && \ - cd crosstool-ng && \ - ./configure --prefix=/usr/local && \ - make -j$(nproc) && \ - make install && \ - cd .. && \ - rm -rf crosstool-ng +COPY scripts/crosstool-ng.sh /scripts/ +RUN sh /scripts/crosstool-ng.sh -RUN groupadd -r rustbuild && useradd -m -r -g rustbuild rustbuild -RUN mkdir /x-tools && chown rustbuild:rustbuild /x-tools +COPY scripts/rustbuild-setup.sh /scripts/ +RUN sh /scripts/rustbuild-setup.sh USER rustbuild WORKDIR /tmp @@ -62,9 +27,8 @@ RUN apt-get install -y --no-install-recommends rpm2cpio cpio COPY dist-powerpc64le-linux/shared.sh dist-powerpc64le-linux/build-powerpc64le-toolchain.sh /tmp/ RUN ./build-powerpc64le-toolchain.sh -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh ENV \ AR_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-ar \ diff --git a/src/ci/docker/dist-s390x-linux/Dockerfile b/src/ci/docker/dist-s390x-linux/Dockerfile index 5c00287107aa3..84769af12b5a6 100644 --- a/src/ci/docker/dist-s390x-linux/Dockerfile +++ b/src/ci/docker/dist-s390x-linux/Dockerfile @@ -1,58 +1,23 @@ FROM ubuntu:16.04 -RUN apt-get update && apt-get install -y --no-install-recommends \ - automake \ - bison \ - bzip2 \ - ca-certificates \ - cmake \ - curl \ - file \ - flex \ - g++ \ - gawk \ - gdb \ - git \ - gperf \ - help2man \ - libncurses-dev \ - libtool-bin \ - make \ - patch \ - python2.7 \ - sudo \ - texinfo \ - wget \ - xz-utils \ - libssl-dev \ - pkg-config +COPY scripts/cross-apt-packages.sh /scripts/ +RUN sh /scripts/cross-apt-packages.sh + +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] -# Ubuntu 16.04 (this contianer) ships with make 4, but something in the +# Ubuntu 16.04 (this container) ships with make 4, but something in the # toolchains we build below chokes on that, so go back to make 3 -RUN curl https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf - && \ - cd make-3.81 && \ - ./configure --prefix=/usr && \ - make && \ - make install && \ - cd .. && \ - rm -rf make-3.81 +COPY scripts/make3.sh /scripts/ +RUN sh /scripts/make3.sh -RUN curl http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.bz2 | \ - tar xjf - && \ - cd crosstool-ng && \ - ./configure --prefix=/usr/local && \ - make -j$(nproc) && \ - make install && \ - cd .. && \ - rm -rf crosstool-ng +COPY scripts/crosstool-ng.sh /scripts/ +RUN sh /scripts/crosstool-ng.sh -RUN groupadd -r rustbuild && useradd -m -r -g rustbuild rustbuild -RUN mkdir /x-tools && chown rustbuild:rustbuild /x-tools +COPY scripts/rustbuild-setup.sh /scripts/ +RUN sh /scripts/rustbuild-setup.sh USER rustbuild WORKDIR /tmp @@ -62,9 +27,8 @@ RUN ./build-s390x-toolchain.sh USER root -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh ENV PATH=$PATH:/x-tools/s390x-ibm-linux-gnu/bin diff --git a/src/ci/docker/dist-x86_64-freebsd/Dockerfile b/src/ci/docker/dist-x86_64-freebsd/Dockerfile index a6c4eee5e812c..b62b46701a764 100644 --- a/src/ci/docker/dist-x86_64-freebsd/Dockerfile +++ b/src/ci/docker/dist-x86_64-freebsd/Dockerfile @@ -19,14 +19,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ COPY dist-x86_64-freebsd/build-toolchain.sh /tmp/ RUN /tmp/build-toolchain.sh x86_64 -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + ENTRYPOINT ["/usr/bin/dumb-init", "--"] -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh ENV \ AR_x86_64_unknown_freebsd=x86_64-unknown-freebsd10-ar \ diff --git a/src/ci/docker/dist-x86_64-linux/Dockerfile b/src/ci/docker/dist-x86_64-linux/Dockerfile index 78b62839a35d5..d0ab47ad3dcd8 100644 --- a/src/ci/docker/dist-x86_64-linux/Dockerfile +++ b/src/ci/docker/dist-x86_64-linux/Dockerfile @@ -81,9 +81,8 @@ RUN curl -Lo /rustroot/dumb-init \ chmod +x /rustroot/dumb-init ENTRYPOINT ["/rustroot/dumb-init", "--"] -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh ENV HOSTS=x86_64-unknown-linux-gnu diff --git a/src/ci/docker/dist-x86_64-musl/Dockerfile b/src/ci/docker/dist-x86_64-musl/Dockerfile index 2eea5ab146972..eebc283e96642 100644 --- a/src/ci/docker/dist-x86_64-musl/Dockerfile +++ b/src/ci/docker/dist-x86_64-musl/Dockerfile @@ -20,14 +20,13 @@ WORKDIR /build/ COPY dist-x86_64-musl/build-musl.sh /build/ RUN sh /build/build-musl.sh && rm -rf /build -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + ENTRYPOINT ["/usr/bin/dumb-init", "--"] -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh ENV RUST_CONFIGURE_ARGS \ --target=x86_64-unknown-linux-musl \ diff --git a/src/ci/docker/dist-x86_64-netbsd/Dockerfile b/src/ci/docker/dist-x86_64-netbsd/Dockerfile index f76e6271f4c8c..0c1405002666b 100644 --- a/src/ci/docker/dist-x86_64-netbsd/Dockerfile +++ b/src/ci/docker/dist-x86_64-netbsd/Dockerfile @@ -1,58 +1,23 @@ FROM ubuntu:16.04 -RUN apt-get update && apt-get install -y --no-install-recommends \ - automake \ - bison \ - bzip2 \ - ca-certificates \ - cmake \ - curl \ - file \ - flex \ - g++ \ - gawk \ - gdb \ - git \ - gperf \ - help2man \ - libncurses-dev \ - libtool-bin \ - make \ - patch \ - python2.7 \ - sudo \ - texinfo \ - wget \ - xz-utils \ - libssl-dev \ - pkg-config +COPY scripts/cross-apt-packages.sh /scripts/ +RUN sh /scripts/cross-apt-packages.sh + +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] -# Ubuntu 16.04 (this contianer) ships with make 4, but something in the +# Ubuntu 16.04 (this container) ships with make 4, but something in the # toolchains we build below chokes on that, so go back to make 3 -RUN curl https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf - && \ - cd make-3.81 && \ - ./configure --prefix=/usr && \ - make && \ - make install && \ - cd .. && \ - rm -rf make-3.81 +COPY scripts/make3.sh /scripts/ +RUN sh /scripts/make3.sh -RUN curl http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.bz2 | \ - tar xjf - && \ - cd crosstool-ng && \ - ./configure --prefix=/usr/local && \ - make -j$(nproc) && \ - make install && \ - cd .. && \ - rm -rf crosstool-ng +COPY scripts/crosstool-ng.sh /scripts/ +RUN sh /scripts/crosstool-ng.sh -RUN groupadd -r rustbuild && useradd -m -r -g rustbuild rustbuild -RUN mkdir /x-tools && chown rustbuild:rustbuild /x-tools +COPY scripts/rustbuild-setup.sh /scripts/ +RUN sh /scripts/rustbuild-setup.sh USER rustbuild WORKDIR /tmp @@ -61,9 +26,8 @@ RUN ./build-netbsd-toolchain.sh USER root -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh ENV PATH=$PATH:/x-tools/x86_64-unknown-netbsd/bin diff --git a/src/ci/docker/i686-gnu-nopt/Dockerfile b/src/ci/docker/i686-gnu-nopt/Dockerfile index 076be8f429116..56ff9922ae347 100644 --- a/src/ci/docker/i686-gnu-nopt/Dockerfile +++ b/src/ci/docker/i686-gnu-nopt/Dockerfile @@ -13,13 +13,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gdb \ xz-utils -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh + ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENV RUST_CONFIGURE_ARGS --build=i686-unknown-linux-gnu --disable-optimize-tests diff --git a/src/ci/docker/i686-gnu/Dockerfile b/src/ci/docker/i686-gnu/Dockerfile index 5fac057357467..1c1333cd7c84f 100644 --- a/src/ci/docker/i686-gnu/Dockerfile +++ b/src/ci/docker/i686-gnu/Dockerfile @@ -13,13 +13,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gdb \ xz-utils -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh + ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENV RUST_CONFIGURE_ARGS --build=i686-unknown-linux-gnu diff --git a/src/ci/docker/scripts/android-base-apt-get.sh b/src/ci/docker/scripts/android-base-apt-get.sh new file mode 100644 index 0000000000000..7ae3bf39a3832 --- /dev/null +++ b/src/ci/docker/scripts/android-base-apt-get.sh @@ -0,0 +1,27 @@ +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex + +apt-get update +apt-get install -y --no-install-recommends \ + ca-certificates \ + cmake \ + curl \ + file \ + g++ \ + git \ + libssl-dev \ + make \ + pkg-config \ + python2.7 \ + sudo \ + unzip \ + xz-utils diff --git a/src/ci/docker/scripts/cross-apt-packages.sh b/src/ci/docker/scripts/cross-apt-packages.sh new file mode 100644 index 0000000000000..f6c9cc960c56d --- /dev/null +++ b/src/ci/docker/scripts/cross-apt-packages.sh @@ -0,0 +1,36 @@ +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +apt-get update && apt-get install -y --no-install-recommends \ + automake \ + bison \ + bzip2 \ + ca-certificates \ + cmake \ + curl \ + file \ + flex \ + g++ \ + gawk \ + gdb \ + git \ + gperf \ + help2man \ + libncurses-dev \ + libssl-dev \ + libtool-bin \ + make \ + patch \ + pkg-config \ + python2.7 \ + sudo \ + texinfo \ + wget \ + xz-utils diff --git a/src/ci/docker/scripts/crosstool-ng.sh b/src/ci/docker/scripts/crosstool-ng.sh new file mode 100644 index 0000000000000..8b2747cf21309 --- /dev/null +++ b/src/ci/docker/scripts/crosstool-ng.sh @@ -0,0 +1,20 @@ +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex + +url="http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.bz2" +curl $url | tar xjf - +cd crosstool-ng +./configure --prefix=/usr/local +make -j$(nproc) +make install +cd .. +rm -rf crosstool-ng diff --git a/src/ci/docker/scripts/make3.sh b/src/ci/docker/scripts/make3.sh new file mode 100644 index 0000000000000..8a7845cb8f384 --- /dev/null +++ b/src/ci/docker/scripts/make3.sh @@ -0,0 +1,19 @@ +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex + +curl https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf - +cd make-3.81 +./configure --prefix=/usr +make +make install +cd .. +rm -rf make-3.81 diff --git a/src/ci/docker/scripts/rustbuild-setup.sh b/src/ci/docker/scripts/rustbuild-setup.sh new file mode 100644 index 0000000000000..96efccfdff386 --- /dev/null +++ b/src/ci/docker/scripts/rustbuild-setup.sh @@ -0,0 +1,14 @@ +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex + +groupadd -r rustbuild && useradd -m -r -g rustbuild rustbuild +mkdir /x-tools && chown rustbuild:rustbuild /x-tools diff --git a/src/ci/docker/x86_64-gnu-aux/Dockerfile b/src/ci/docker/x86_64-gnu-aux/Dockerfile index 06c7c2824fd9d..a449526efcce2 100644 --- a/src/ci/docker/x86_64-gnu-aux/Dockerfile +++ b/src/ci/docker/x86_64-gnu-aux/Dockerfile @@ -14,13 +14,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ xz-utils \ pkg-config -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENV RUST_CONFIGURE_ARGS --build=x86_64-unknown-linux-gnu diff --git a/src/ci/docker/x86_64-gnu-debug/Dockerfile b/src/ci/docker/x86_64-gnu-debug/Dockerfile index 6ea54ac4db3e7..8111118ad3d91 100644 --- a/src/ci/docker/x86_64-gnu-debug/Dockerfile +++ b/src/ci/docker/x86_64-gnu-debug/Dockerfile @@ -13,13 +13,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gdb \ xz-utils -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENV RUST_CONFIGURE_ARGS \ diff --git a/src/ci/docker/x86_64-gnu-distcheck/Dockerfile b/src/ci/docker/x86_64-gnu-distcheck/Dockerfile index e24c660a8c36d..c3fe8ea51cb3f 100644 --- a/src/ci/docker/x86_64-gnu-distcheck/Dockerfile +++ b/src/ci/docker/x86_64-gnu-distcheck/Dockerfile @@ -15,13 +15,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libssl-dev \ pkg-config -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENV RUST_CONFIGURE_ARGS --build=x86_64-unknown-linux-gnu diff --git a/src/ci/docker/x86_64-gnu-full-bootstrap/Dockerfile b/src/ci/docker/x86_64-gnu-full-bootstrap/Dockerfile index 78035c7fe3d7f..377e086955779 100644 --- a/src/ci/docker/x86_64-gnu-full-bootstrap/Dockerfile +++ b/src/ci/docker/x86_64-gnu-full-bootstrap/Dockerfile @@ -13,13 +13,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gdb \ xz-utils -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENV RUST_CONFIGURE_ARGS \ diff --git a/src/ci/docker/x86_64-gnu-incremental/Dockerfile b/src/ci/docker/x86_64-gnu-incremental/Dockerfile index 0aaed64e384ed..a21a99e965e83 100644 --- a/src/ci/docker/x86_64-gnu-incremental/Dockerfile +++ b/src/ci/docker/x86_64-gnu-incremental/Dockerfile @@ -13,13 +13,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gdb \ xz-utils -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENV RUST_CONFIGURE_ARGS --build=x86_64-unknown-linux-gnu diff --git a/src/ci/docker/x86_64-gnu-llvm-3.7/Dockerfile b/src/ci/docker/x86_64-gnu-llvm-3.7/Dockerfile index 7c136fa39bc8b..1a9f1d2d737b8 100644 --- a/src/ci/docker/x86_64-gnu-llvm-3.7/Dockerfile +++ b/src/ci/docker/x86_64-gnu-llvm-3.7/Dockerfile @@ -16,13 +16,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ zlib1g-dev \ xz-utils -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENV RUST_CONFIGURE_ARGS \ diff --git a/src/ci/docker/x86_64-gnu-nopt/Dockerfile b/src/ci/docker/x86_64-gnu-nopt/Dockerfile index 4499736967cf4..e008b21f66fe2 100644 --- a/src/ci/docker/x86_64-gnu-nopt/Dockerfile +++ b/src/ci/docker/x86_64-gnu-nopt/Dockerfile @@ -13,13 +13,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gdb \ xz-utils -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENV RUST_CONFIGURE_ARGS --build=x86_64-unknown-linux-gnu --disable-optimize-tests diff --git a/src/ci/docker/x86_64-gnu/Dockerfile b/src/ci/docker/x86_64-gnu/Dockerfile index 0bbbded57f27d..3a6760b476225 100644 --- a/src/ci/docker/x86_64-gnu/Dockerfile +++ b/src/ci/docker/x86_64-gnu/Dockerfile @@ -13,13 +13,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gdb \ xz-utils -RUN curl -o /usr/local/bin/sccache \ - https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl && \ - chmod +x /usr/local/bin/sccache +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh -RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \ - dpkg -i dumb-init_*.deb && \ - rm dumb-init_*.deb ENTRYPOINT ["/usr/bin/dumb-init", "--"] ENV RUST_CONFIGURE_ARGS --build=x86_64-unknown-linux-gnu --enable-sanitizers --enable-profiler From 0d617ce4c9a798697d32bf8272e9d2d04213457f Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 12 Jul 2017 20:37:18 -0600 Subject: [PATCH 084/123] Update tcp.rs --- src/libstd/sys/redox/net/tcp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/sys/redox/net/tcp.rs b/src/libstd/sys/redox/net/tcp.rs index 5d1067e4039ba..98ec3aa3e2959 100644 --- a/src/libstd/sys/redox/net/tcp.rs +++ b/src/libstd/sys/redox/net/tcp.rs @@ -32,7 +32,7 @@ impl TcpStream { Ok(TcpStream(File::open(&Path::new(path.as_str()), &options)?)) } - pub fn connect_timeout(_addr: &SocketAddr, _timeout: Duration) -> Result<()> { + pub fn connect_timeout(_addr: &SocketAddr, _timeout: Duration) -> Result { Err(Error::new(ErrorKind::Other, "TcpStream::connect_timeout not implemented")) } From bd9428a46b7290b8f87d830655b473099207ae0d Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 12 Jul 2017 20:39:02 -0600 Subject: [PATCH 085/123] Update mod.rs --- src/libstd/sys/redox/mod.rs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/libstd/sys/redox/mod.rs b/src/libstd/sys/redox/mod.rs index 31c40ea58b1de..bd5b40de9a071 100644 --- a/src/libstd/sys/redox/mod.rs +++ b/src/libstd/sys/redox/mod.rs @@ -40,23 +40,7 @@ pub mod time; #[cfg(not(test))] pub fn init() { - use alloc::oom; - - oom::set_oom_handler(oom_handler); - - // A nicer handler for out-of-memory situations than the default one. This - // one prints a message to stderr before aborting. It is critical that this - // code does not allocate any memory since we are in an OOM situation. Any - // errors are ignored while printing since there's nothing we can do about - // them and we are about to exit anyways. - fn oom_handler() -> ! { - use intrinsics; - let msg = "fatal runtime error: out of memory\n"; - unsafe { - let _ = syscall::write(2, msg.as_bytes()); - intrinsics::abort(); - } - } + } pub fn decode_error_kind(errno: i32) -> ErrorKind { From 362dd8a98690adaf3a3f6b5b9f6edc697fbd3ed9 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 12 Jul 2017 20:40:43 -0600 Subject: [PATCH 086/123] Update fs.rs --- src/libstd/sys/redox/fs.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libstd/sys/redox/fs.rs b/src/libstd/sys/redox/fs.rs index 87e50c4014832..27ded432b9565 100644 --- a/src/libstd/sys/redox/fs.rs +++ b/src/libstd/sys/redox/fs.rs @@ -384,8 +384,9 @@ pub fn unlink(p: &Path) -> io::Result<()> { } pub fn rename(_old: &Path, _new: &Path) -> io::Result<()> { - ::sys_common::util::dumb_print(format_args!("Rename\n")); - unimplemented!(); + copy(old, new)?; + unlink(old)?; + Ok(()) } pub fn set_perm(p: &Path, perm: FilePermissions) -> io::Result<()> { From 21f2ace8cfaa6c6cd137cfa3b11222f4a06a0b87 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 12 Jul 2017 20:48:04 -0600 Subject: [PATCH 087/123] Update mod.rs --- src/libstd/sys/redox/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libstd/sys/redox/mod.rs b/src/libstd/sys/redox/mod.rs index bd5b40de9a071..7c728ebb1af2e 100644 --- a/src/libstd/sys/redox/mod.rs +++ b/src/libstd/sys/redox/mod.rs @@ -39,9 +39,7 @@ pub mod thread_local; pub mod time; #[cfg(not(test))] -pub fn init() { - -} +pub fn init() {} pub fn decode_error_kind(errno: i32) -> ErrorKind { match errno { From 4259ae64755f3b72296b95a9eeabaf883321069b Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 12 Jul 2017 22:16:35 -0600 Subject: [PATCH 088/123] Update fs.rs --- src/libstd/sys/redox/fs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/sys/redox/fs.rs b/src/libstd/sys/redox/fs.rs index 27ded432b9565..918893097f841 100644 --- a/src/libstd/sys/redox/fs.rs +++ b/src/libstd/sys/redox/fs.rs @@ -383,7 +383,7 @@ pub fn unlink(p: &Path) -> io::Result<()> { Ok(()) } -pub fn rename(_old: &Path, _new: &Path) -> io::Result<()> { +pub fn rename(old: &Path, new: &Path) -> io::Result<()> { copy(old, new)?; unlink(old)?; Ok(()) From cb92ab93a224a7728103f837ec761b1dafd5fbb1 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Wed, 12 Jul 2017 10:44:49 +0200 Subject: [PATCH 089/123] Reduce the usage of features in compiletest and libtest --- src/Cargo.lock | 1 + src/libtest/lib.rs | 2 -- src/tools/compiletest/Cargo.toml | 1 + src/tools/compiletest/src/main.rs | 2 -- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index 35634d2532550..368a503b3101b 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -284,6 +284,7 @@ dependencies = [ "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 92cfb862b1669..bf71b11fc7766 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -35,9 +35,7 @@ #![feature(asm)] #![feature(libc)] -#![feature(rustc_private)] #![feature(set_stdio)] -#![feature(staged_api)] #![feature(panic_unwind)] extern crate getopts; diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml index 543e6784a72ac..f8282cc5f8d9b 100644 --- a/src/tools/compiletest/Cargo.toml +++ b/src/tools/compiletest/Cargo.toml @@ -10,3 +10,4 @@ filetime = "0.1" getopts = "0.2" log = "0.3" rustc-serialize = "0.3" +libc = "0.2" diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index cc42544ef02b7..91f80a7afecdc 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -10,9 +10,7 @@ #![crate_name = "compiletest"] -#![feature(box_syntax)] #![feature(test)] -#![feature(libc)] #![deny(warnings)] From bdcebc938b461808ed69075543a7c5a3c4777908 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 12 Jul 2017 22:22:25 -0700 Subject: [PATCH 090/123] Update the `cargo` submodule Notably pull in an update to the `jobserver` crate to have Cargo set the `CARGO_MAKEFLAGS` environment variable instead of the `MAKEFLAGS` environment variable. --- src/Cargo.lock | 10 +++++----- src/tools/cargo | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index 35634d2532550..4985009f66df9 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -180,7 +180,7 @@ dependencies = [ "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jobserver 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jobserver 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)", "libgit2-sys 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -556,7 +556,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "jobserver" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1077,7 +1077,7 @@ dependencies = [ "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "fmt_macros 0.0.0", "graphviz 0.0.0", - "jobserver 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jobserver 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_back 0.0.0", @@ -1389,7 +1389,7 @@ dependencies = [ "crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)", - "jobserver 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jobserver 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", @@ -2037,7 +2037,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6a22814455d41612f41161581c2883c0c6a1c41852729b17d5ed88f01e153aa" "checksum idna 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2233d4940b1f19f0418c158509cd7396b8d70a5db5705ce410914dc8fa603b37" "checksum itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2f404fbc66fd9aac13e998248505e7ecb2ad8e44ab6388684c5fb11c6c251c" -"checksum jobserver 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4e28adc987f6d0521ef66ad60b055968107b164b3bb3cf3dc8474e0a380474a6" +"checksum jobserver 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "443ae8bc0af6c106e6e8b77e04684faecc1a5ce94e058f4c2b0a037b0ea1b133" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum languageserver-types 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "680aee78c75504fdcb172635a7b7da0dccaafa4c42d935e19576c14b27942362" "checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" diff --git a/src/tools/cargo b/src/tools/cargo index eb6cf012a6cc2..f709c35a35687 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit eb6cf012a6cc23c9c89c4009564de9fccc38b9cb +Subproject commit f709c35a35687b2665eb290695825375be91410b From 3bf8116280f96cf1440cc5c47870257078daf3de Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Fri, 7 Jul 2017 16:20:24 -0700 Subject: [PATCH 091/123] Split old and experimental wasm builders --- src/ci/docker/disabled/wasm32-exp/Dockerfile | 42 ++++++++++++++++++++ src/ci/docker/disabled/wasm32-exp/node.sh | 18 +++++++++ src/ci/docker/disabled/wasm32/Dockerfile | 13 +++--- src/ci/docker/scripts/emscripten-wasm.sh | 27 +++---------- 4 files changed, 71 insertions(+), 29 deletions(-) create mode 100644 src/ci/docker/disabled/wasm32-exp/Dockerfile create mode 100755 src/ci/docker/disabled/wasm32-exp/node.sh diff --git a/src/ci/docker/disabled/wasm32-exp/Dockerfile b/src/ci/docker/disabled/wasm32-exp/Dockerfile new file mode 100644 index 0000000000000..4e337883165bd --- /dev/null +++ b/src/ci/docker/disabled/wasm32-exp/Dockerfile @@ -0,0 +1,42 @@ +FROM ubuntu:16.04 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + g++ \ + make \ + file \ + curl \ + ca-certificates \ + python \ + git \ + cmake \ + sudo \ + gdb \ + xz-utils \ + jq \ + bzip2 + +# dumb-init +COPY scripts/dumb-init.sh /scripts/ +RUN sh /scripts/dumb-init.sh + +# emscripten +COPY scripts/emscripten-wasm.sh /scripts/ +COPY disabled/wasm32-exp/node.sh /usr/local/bin/node +RUN bash /scripts/emscripten-wasm.sh + +# cache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh + +# env +ENV PATH=/wasm-install/emscripten:/wasm-install/bin:$PATH +ENV EM_CONFIG=/root/.emscripten + +ENV TARGETS=wasm32-experimental-emscripten + +ENV RUST_CONFIGURE_ARGS --target=$TARGETS --experimental-targets=WebAssembly + +ENV SCRIPT python2.7 ../x.py test --target $TARGETS + +# init +ENTRYPOINT ["/usr/bin/dumb-init", "--"] diff --git a/src/ci/docker/disabled/wasm32-exp/node.sh b/src/ci/docker/disabled/wasm32-exp/node.sh new file mode 100755 index 0000000000000..dfa7f221ffa20 --- /dev/null +++ b/src/ci/docker/disabled/wasm32-exp/node.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# Copyright 2017 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +path="$(dirname $1)" +file="$(basename $1)" + +shift + +cd "$path" +exec /node-v8.0.0-linux-x64/bin/node "$file" "$@" diff --git a/src/ci/docker/disabled/wasm32/Dockerfile b/src/ci/docker/disabled/wasm32/Dockerfile index 66d7c48022263..60b15d7afb47d 100644 --- a/src/ci/docker/disabled/wasm32/Dockerfile +++ b/src/ci/docker/disabled/wasm32/Dockerfile @@ -11,15 +11,14 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ cmake \ sudo \ gdb \ - xz-utils \ - jq \ - bzip2 + xz-utils COPY scripts/dumb-init.sh /scripts/ RUN sh /scripts/dumb-init.sh -COPY scripts/emscripten-wasm.sh /scripts/ -RUN bash /scripts/emscripten-wasm.sh +# emscripten +COPY scripts/emscripten.sh /scripts/ +RUN bash /scripts/emscripten.sh COPY disabled/wasm32/node.sh /usr/local/bin/node COPY scripts/sccache.sh /scripts/ @@ -32,9 +31,9 @@ ENV EMSCRIPTEN=/emsdk-portable/emscripten/1.37.13/ ENV BINARYEN_ROOT=/emsdk-portable/clang/e1.37.13_64bit/binaryen/ ENV EM_CONFIG=/emsdk-portable/.emscripten -ENV TARGETS=wasm32-unknown-emscripten,wasm32-experimental-emscripten +ENV TARGETS=wasm32-unknown-emscripten -ENV RUST_CONFIGURE_ARGS --target=$TARGETS --experimental-targets=WebAssembly +ENV RUST_CONFIGURE_ARGS --target=$TARGETS ENV SCRIPT python2.7 ../x.py test --target $TARGETS diff --git a/src/ci/docker/scripts/emscripten-wasm.sh b/src/ci/docker/scripts/emscripten-wasm.sh index e693f975f69bc..0e7da45907fcc 100644 --- a/src/ci/docker/scripts/emscripten-wasm.sh +++ b/src/ci/docker/scripts/emscripten-wasm.sh @@ -27,11 +27,6 @@ exit 1 set -x } -# Download emsdk -cd / -curl -L https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \ - tar -xz - # Download last known good emscripten from WebAssembly waterfall BUILD=$(curl -L https://storage.googleapis.com/wasm-llvm/builds/linux/lkgr.json | \ jq '.build | tonumber') @@ -43,22 +38,10 @@ cd / curl -L https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \ tar -xJ -cd /emsdk-portable -./emsdk update -hide_output ./emsdk install sdk-1.37.13-64bit -./emsdk activate sdk-1.37.13-64bit - # Make emscripten use wasm-ready node and LLVM tools -echo "NODE_JS='/node-v8.0.0-linux-x64/bin/node'" >> /root/.emscripten +echo "EMSCRIPTEN_ROOT = '/wasm-install/emscripten'" >> /root/.emscripten +echo "NODE_JS='/usr/local/bin/node'" >> /root/.emscripten echo "LLVM_ROOT='/wasm-install/bin'" >> /root/.emscripten - -# Make emsdk usable by any user -cp /root/.emscripten /emsdk-portable -chmod a+rxw -R /emsdk-portable - -# Compile and cache libc -source ./emsdk_env.sh -echo "main(){}" > a.c -HOME=/emsdk-portable/ emcc a.c -HOME=/emsdk-portable/ emcc -s WASM=1 a.c -rm -f a.* +echo "BINARYEN_ROOT = '/wasm-install'" >> /root/.emscripten +echo "COMPILER_ENGINE = NODE_JS" >> /root/.emscripten +echo "JS_ENGINES = [NODE_JS]" >> /root/.emscripten From 03f22fdf5e290618d2055d48881e31439a6b74ec Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 13 Jul 2017 11:14:35 -0700 Subject: [PATCH 092/123] windows::fs::symlink_dir: fix example to actually use symlink_dir --- src/libstd/sys/windows/ext/fs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/sys/windows/ext/fs.rs b/src/libstd/sys/windows/ext/fs.rs index 67348a0049417..a1c63e3358840 100644 --- a/src/libstd/sys/windows/ext/fs.rs +++ b/src/libstd/sys/windows/ext/fs.rs @@ -477,7 +477,7 @@ pub fn symlink_file, Q: AsRef>(src: P, dst: Q) /// use std::os::windows::fs; /// /// # fn foo() -> std::io::Result<()> { -/// fs::symlink_file("a", "b")?; +/// fs::symlink_dir("a", "b")?; /// # Ok(()) /// # } /// ``` From b90e5107c0e460486f5e3992d92907c3a038e6fc Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 5 Jul 2017 20:21:29 +0200 Subject: [PATCH 093/123] Forward more Iterator methods for str::Bytes These are overridden by slice::Iter --- src/libcore/str/mod.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 624c3638df5cc..3862b4a2eb046 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -710,6 +710,37 @@ impl<'a> Iterator for Bytes<'a> { fn nth(&mut self, n: usize) -> Option { self.0.nth(n) } + + #[inline] + fn all(&mut self, f: F) -> bool where F: FnMut(Self::Item) -> bool { + self.0.all(f) + } + + #[inline] + fn any(&mut self, f: F) -> bool where F: FnMut(Self::Item) -> bool { + self.0.any(f) + } + + #[inline] + fn find

(&mut self, predicate: P) -> Option where + P: FnMut(&Self::Item) -> bool + { + self.0.find(predicate) + } + + #[inline] + fn position

(&mut self, predicate: P) -> Option where + P: FnMut(Self::Item) -> bool + { + self.0.position(predicate) + } + + #[inline] + fn rposition

(&mut self, predicate: P) -> Option where + P: FnMut(Self::Item) -> bool + { + self.0.rposition(predicate) + } } #[stable(feature = "rust1", since = "1.0.0")] @@ -718,6 +749,13 @@ impl<'a> DoubleEndedIterator for Bytes<'a> { fn next_back(&mut self) -> Option { self.0.next_back() } + + #[inline] + fn rfind

(&mut self, predicate: P) -> Option where + P: FnMut(&Self::Item) -> bool + { + self.0.rfind(predicate) + } } #[stable(feature = "rust1", since = "1.0.0")] From 2007987099309e05c08d65e6a0e722c5ec1d0653 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 5 Jul 2017 20:23:55 +0200 Subject: [PATCH 094/123] Forward more Iterator methods for iter::Rev `position` could not be implemented because calling `rposition` on the inner iterator would require more trait bounds. --- src/libcore/iter/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index decd718d65e15..79e6b11beaca6 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -359,11 +359,19 @@ impl Iterator for Rev where I: DoubleEndedIterator { #[inline] fn size_hint(&self) -> (usize, Option) { self.iter.size_hint() } + #[inline] fn find

(&mut self, predicate: P) -> Option where P: FnMut(&Self::Item) -> bool { self.iter.rfind(predicate) } + + #[inline] + fn rposition

(&mut self, predicate: P) -> Option where + P: FnMut(Self::Item) -> bool + { + self.iter.position(predicate) + } } #[stable(feature = "rust1", since = "1.0.0")] From b5c5a0c3fd91e2f3a61e26bf5a00297a6e2b3366 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Thu, 13 Jul 2017 14:12:57 -0700 Subject: [PATCH 095/123] Fix regression involving identifiers in `macro_rules!` patterns. --- src/libsyntax/ext/tt/quoted.rs | 3 ++- src/test/run-pass/issue-40847.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/test/run-pass/issue-40847.rs diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index 4e9e30857b1e8..74fa85d130b02 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -196,7 +196,8 @@ fn parse_tree(tree: tokenstream::TokenTree, num_captures: name_captures, })) } - Some(tokenstream::TokenTree::Token(ident_span, token::Ident(ident))) => { + Some(tokenstream::TokenTree::Token(ident_span, ref token)) if token.is_ident() => { + let ident = token.ident().unwrap(); let span = Span { lo: span.lo, ..ident_span }; if ident.name == keywords::Crate.name() { let ident = ast::Ident { name: keywords::DollarCrate.name(), ..ident }; diff --git a/src/test/run-pass/issue-40847.rs b/src/test/run-pass/issue-40847.rs new file mode 100644 index 0000000000000..2fa99984401c1 --- /dev/null +++ b/src/test/run-pass/issue-40847.rs @@ -0,0 +1,26 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! gen { + ($name:ident ( $($dol:tt $var:ident)* ) $($body:tt)*) => { + macro_rules! $name { + ($($dol $var:ident)*) => { + $($body)* + } + } + } +} + +gen!(m($var) $var); + +fn main() { + let x = 1; + assert_eq!(m!(x), 1); +} From 1da51cca9ea13aa9dea06d8434d55aac95541c63 Mon Sep 17 00:00:00 2001 From: kennytm Date: Fri, 14 Jul 2017 09:55:39 +0800 Subject: [PATCH 096/123] Fix minor typo in std::path documentation. Replace all `'C' as u8` with `b'C'`. --- src/libstd/path.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index e7c7be981d25f..bb1ba8a771d61 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -135,12 +135,12 @@ use sys::path::{is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix}; /// get_path_prefix(r"\\?\pictures\kittens")); /// assert_eq!(VerbatimUNC(OsStr::new("server"), OsStr::new("share")), /// get_path_prefix(r"\\?\UNC\server\share")); -/// assert_eq!(VerbatimDisk('C' as u8), get_path_prefix(r"\\?\c:\")); +/// assert_eq!(VerbatimDisk(b'C'), get_path_prefix(r"\\?\c:\")); /// assert_eq!(DeviceNS(OsStr::new("BrainInterface")), /// get_path_prefix(r"\\.\BrainInterface")); /// assert_eq!(UNC(OsStr::new("server"), OsStr::new("share")), /// get_path_prefix(r"\\server\share")); -/// assert_eq!(Disk('C' as u8), get_path_prefix(r"C:\Users\Rust\Pictures\Ferris")); +/// assert_eq!(Disk(b'C'), get_path_prefix(r"C:\Users\Rust\Pictures\Ferris")); /// # } /// ``` #[derive(Copy, Clone, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)] @@ -235,10 +235,10 @@ impl<'a> Prefix<'a> { /// /// assert!(Verbatim(OsStr::new("pictures")).is_verbatim()); /// assert!(VerbatimUNC(OsStr::new("server"), OsStr::new("share")).is_verbatim()); - /// assert!(VerbatimDisk('C' as u8).is_verbatim()); + /// assert!(VerbatimDisk(b'C').is_verbatim()); /// assert!(!DeviceNS(OsStr::new("BrainInterface")).is_verbatim()); /// assert!(!UNC(OsStr::new("server"), OsStr::new("share")).is_verbatim()); - /// assert!(!Disk('C' as u8).is_verbatim()); + /// assert!(!Disk(b'C').is_verbatim()); /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] @@ -401,7 +401,7 @@ enum State { /// let path = Path::new(r"c:\you\later\"); /// match path.components().next().unwrap() { /// Component::Prefix(prefix_component) => { -/// assert_eq!(Prefix::Disk('C' as u8), prefix_component.kind()); +/// assert_eq!(Prefix::Disk(b'C'), prefix_component.kind()); /// assert_eq!(OsStr::new("c:"), prefix_component.as_os_str()); /// } /// _ => unreachable!(), @@ -1040,7 +1040,7 @@ impl<'a> cmp::Ord for Components<'a> { /// [`Deref`]: ../ops/trait.Deref.html /// /// More details about the overall approach can be found in -/// the module documentation. +/// the [module documentation](index.html). /// /// # Examples /// @@ -1186,7 +1186,7 @@ impl PathBuf { self.inner.push(path); } - /// Truncate `self` to [`self.parent`]. + /// Truncates `self` to [`self.parent`]. /// /// Returns `false` and does nothing if [`self.file_name`] is [`None`]. /// Otherwise, returns `true`. @@ -1512,7 +1512,7 @@ impl AsRef for PathBuf { /// [`PathBuf`]: struct.PathBuf.html /// /// More details about the overall approach can be found in -/// the module documentation. +/// the [module documentation](index.html). /// /// # Examples /// @@ -1689,7 +1689,7 @@ impl Path { self.has_root() && (cfg!(unix) || cfg!(target_os = "redox") || self.prefix().is_some()) } - /// Return `false` if the `Path` is relative, i.e. not absolute. + /// Returns `true` if the `Path` is relative, i.e. not absolute. /// /// See [`is_absolute`]'s documentation for more details. /// @@ -2019,7 +2019,7 @@ impl Path { /// * Repeated separators are ignored, so `a/b` and `a//b` both have /// `a` and `b` as components. /// - /// * Occurentces of `.` are normalized away, exept if they are at the + /// * Occurences of `.` are normalized away, except if they are at the /// beginning of the path. For example, `a/./b`, `a/b/`, `a/b/.` and /// `a/b` all have `a` and `b` as components, but `./a/b` starts with /// an additional [`CurDir`] component. From 5757e0561975b40f81a739feb73abdc377eeda3a Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 13 Jul 2017 20:07:37 -0600 Subject: [PATCH 097/123] Fix backtrace on Redox --- src/libstd/sys/redox/backtrace.rs | 15 ++++++++++++--- src/libstd/sys_common/mod.rs | 3 ++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/libstd/sys/redox/backtrace.rs b/src/libstd/sys/redox/backtrace.rs index 961148fb6b4a8..6cafe3e69bac1 100644 --- a/src/libstd/sys/redox/backtrace.rs +++ b/src/libstd/sys/redox/backtrace.rs @@ -8,16 +8,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use libc; use io; use sys_common::backtrace::Frame; -pub use sys_common::gnu::libbacktrace::*; +pub use sys_common::gnu::libbacktrace::{foreach_symbol_fileline, resolve_symname}; pub struct BacktraceContext; #[inline(never)] -pub fn unwind_backtrace(frames: &mut [Frame]) +pub fn unwind_backtrace(_frames: &mut [Frame]) -> io::Result<(usize, BacktraceContext)> { Ok((0, BacktraceContext)) } + +pub mod gnu { + use io; + use fs; + use libc::c_char; + + pub fn get_executable_filename() -> io::Result<(Vec, fs::File)> { + Err(io::Error::new(io::ErrorKind::Other, "Not implemented")) + } +} diff --git a/src/libstd/sys_common/mod.rs b/src/libstd/sys_common/mod.rs index d4d3365dc0198..ccd4b91a7b733 100644 --- a/src/libstd/sys_common/mod.rs +++ b/src/libstd/sys_common/mod.rs @@ -52,7 +52,8 @@ pub mod net; #[cfg(feature = "backtrace")] #[cfg(any(all(unix, not(any(target_os = "macos", target_os = "ios", target_os = "emscripten"))), - all(windows, target_env = "gnu")))] + all(windows, target_env = "gnu"), + target_os = "redox"))] pub mod gnu; // common error constructors From e760ba2fa1c1b53f8ba0e19120c3fb1cffeb76b7 Mon Sep 17 00:00:00 2001 From: steveklabnik Date: Fri, 14 Jul 2017 13:33:19 -0400 Subject: [PATCH 098/123] Update the books. --- src/doc/book | 2 +- src/doc/nomicon | 2 +- src/doc/reference | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/book b/src/doc/book index 325c3da0814f4..4ee596df22f8e 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit 325c3da0814f44916bef00ff225f934f2d613203 +Subproject commit 4ee596df22f8ecaa9a0b2ddc0624b0104540dbf7 diff --git a/src/doc/nomicon b/src/doc/nomicon index eee5ffb127734..81134a4dff811 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit eee5ffb12773469bc02895d6b5e7e663b3a572a2 +Subproject commit 81134a4dff811403b3b2f349b0c59a819f0fe0c1 diff --git a/src/doc/reference b/src/doc/reference index 876582e9d0fbd..1abfbaa70313f 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 876582e9d0fbdc9cecb03133c28db96e9ff8c844 +Subproject commit 1abfbaa70313fdf527cf799ffd9b9a096a62105c From 30ad6252a3ab9e396c22d234a8b018df29c1dde9 Mon Sep 17 00:00:00 2001 From: "Zack M. Davis" Date: Fri, 14 Jul 2017 08:50:22 -0700 Subject: [PATCH 099/123] add u128/i128 to sum/product implementors Resolves #43235. --- src/libcore/iter/traits.rs | 2 +- src/test/run-pass/i128.rs | 4 ++++ src/test/run-pass/u128.rs | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs index 679cf3a9b23ee..d35aa026685dd 100644 --- a/src/libcore/iter/traits.rs +++ b/src/libcore/iter/traits.rs @@ -732,7 +732,7 @@ macro_rules! float_sum_product { )*) } -integer_sum_product! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } +integer_sum_product! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } float_sum_product! { f32 f64 } /// An iterator adapter that produces output as long as the underlying diff --git a/src/test/run-pass/i128.rs b/src/test/run-pass/i128.rs index c5057f70c065a..7c14d34b0ee12 100644 --- a/src/test/run-pass/i128.rs +++ b/src/test/run-pass/i128.rs @@ -109,4 +109,8 @@ fn main() { assert_eq!(b(-87559967289969187895646876466835277875_i128) / b(84285771033834995895337664386045050880_i128), -1i128); + + // iter-arithmetic traits + assert_eq!(10i128, [1i128, 2, 3, 4].iter().sum()); + assert_eq!(24i128, [1i128, 2, 3, 4].iter().product()); } diff --git a/src/test/run-pass/u128.rs b/src/test/run-pass/u128.rs index cfd616c56b4f0..b16f6c7b6af55 100644 --- a/src/test/run-pass/u128.rs +++ b/src/test/run-pass/u128.rs @@ -122,4 +122,8 @@ fn main() { assert_eq!(b(0x679289ac23bb334f_36144401cf882172_u128) / b(0x7b0b271b64865f05_f54a7b72746c062f_u128), 0u128); + + // iter-arithmetic traits + assert_eq!(10u128, [1u128, 2, 3, 4].iter().sum()); + assert_eq!(24u128, [1u128, 2, 3, 4].iter().product()); } From 0af5c002a25688e826f5821b495e415f6f941bb4 Mon Sep 17 00:00:00 2001 From: William Brown Date: Sat, 17 Jun 2017 13:42:56 +1000 Subject: [PATCH 100/123] Add support for dylibs with Address Sanitizer. This supports cdylibs and staticlibs on gnu-linux targets. --- src/librustc_metadata/creader.rs | 57 ++++++++++++++----- .../run-make/sanitizer-address/overflow.rs | 2 +- .../run-make/sanitizer-cdylib-link/Makefile | 19 +++++++ .../run-make/sanitizer-cdylib-link/library.rs | 15 +++++ .../run-make/sanitizer-cdylib-link/program.rs | 17 ++++++ .../run-make/sanitizer-dylib-link/Makefile | 19 +++++++ .../run-make/sanitizer-dylib-link/library.rs | 15 +++++ .../run-make/sanitizer-dylib-link/program.rs | 17 ++++++ src/test/run-make/sanitizer-dylib/Makefile | 8 --- .../sanitizer-invalid-cratetype/Makefile | 18 ++++++ .../hello.rs | 0 .../sanitizer-staticlib-link/Makefile | 18 ++++++ .../sanitizer-staticlib-link/library.rs | 15 +++++ .../sanitizer-staticlib-link/program.c | 8 +++ 14 files changed, 205 insertions(+), 23 deletions(-) create mode 100644 src/test/run-make/sanitizer-cdylib-link/Makefile create mode 100644 src/test/run-make/sanitizer-cdylib-link/library.rs create mode 100644 src/test/run-make/sanitizer-cdylib-link/program.rs create mode 100644 src/test/run-make/sanitizer-dylib-link/Makefile create mode 100644 src/test/run-make/sanitizer-dylib-link/library.rs create mode 100644 src/test/run-make/sanitizer-dylib-link/program.rs delete mode 100644 src/test/run-make/sanitizer-dylib/Makefile create mode 100644 src/test/run-make/sanitizer-invalid-cratetype/Makefile rename src/test/run-make/{sanitizer-dylib => sanitizer-invalid-cratetype}/hello.rs (100%) create mode 100644 src/test/run-make/sanitizer-staticlib-link/Makefile create mode 100644 src/test/run-make/sanitizer-staticlib-link/library.rs create mode 100644 src/test/run-make/sanitizer-staticlib-link/program.c diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index ac39da48ac1fc..d15843b4f318b 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -856,21 +856,48 @@ impl<'a> CrateLoader<'a> { return } - if !self.sess.crate_types.borrow().iter().all(|ct| { - match *ct { - // Link the runtime - config::CrateTypeExecutable => true, - // This crate will be compiled with the required - // instrumentation pass - config::CrateTypeRlib => false, - _ => { - self.sess.err(&format!("Only executables and rlibs can be \ - compiled with `-Z sanitizer`")); - false + // firstyear 2017 - during testing I was unable to access an OSX machine + // to make this work on different crate types. As a result, today I have + // only been able to test and support linux as a target. + if self.sess.target.target.llvm_target == "x86_64-unknown-linux-gnu" { + if !self.sess.crate_types.borrow().iter().all(|ct| { + match *ct { + // Link the runtime + config::CrateTypeStaticlib | + config::CrateTypeExecutable => true, + // This crate will be compiled with the required + // instrumentation pass + config::CrateTypeRlib | + config::CrateTypeDylib | + config::CrateTypeCdylib => + false, + _ => { + self.sess.err(&format!("Only executables, staticlibs, \ + cdylibs, dylibs and rlibs can be compiled with \ + `-Z sanitizer`")); + false + } } + }) { + return + } + } else { + if !self.sess.crate_types.borrow().iter().all(|ct| { + match *ct { + // Link the runtime + config::CrateTypeExecutable => true, + // This crate will be compiled with the required + // instrumentation pass + config::CrateTypeRlib => false, + _ => { + self.sess.err(&format!("Only executables and rlibs can be \ + compiled with `-Z sanitizer`")); + false + } + } + }) { + return } - }) { - return } let mut uses_std = false; @@ -890,7 +917,7 @@ impl<'a> CrateLoader<'a> { info!("loading sanitizer: {}", name); let symbol = Symbol::intern(name); - let dep_kind = DepKind::Implicit; + let dep_kind = DepKind::Explicit; let (_, data) = self.resolve_crate(&None, symbol, symbol, None, DUMMY_SP, PathKind::Crate, dep_kind); @@ -900,6 +927,8 @@ impl<'a> CrateLoader<'a> { self.sess.err(&format!("the crate `{}` is not a sanitizer runtime", name)); } + } else { + self.sess.err(&format!("Must link std to be compiled with `-Z sanitizer`")); } } } diff --git a/src/test/run-make/sanitizer-address/overflow.rs b/src/test/run-make/sanitizer-address/overflow.rs index e35c3873f7eb5..1f3c64c8c322d 100644 --- a/src/test/run-make/sanitizer-address/overflow.rs +++ b/src/test/run-make/sanitizer-address/overflow.rs @@ -10,5 +10,5 @@ fn main() { let xs = [0, 1, 2, 3]; - let y = unsafe { *xs.as_ptr().offset(4) }; + let _y = unsafe { *xs.as_ptr().offset(4) }; } diff --git a/src/test/run-make/sanitizer-cdylib-link/Makefile b/src/test/run-make/sanitizer-cdylib-link/Makefile new file mode 100644 index 0000000000000..9b0470fb277a9 --- /dev/null +++ b/src/test/run-make/sanitizer-cdylib-link/Makefile @@ -0,0 +1,19 @@ +-include ../tools.mk + +# This test builds a shared object, then an executable that links it as a native +# rust library (constrast to an rlib). The shared library and executable both +# are compiled with address sanitizer, and we assert that a fault in the cdylib +# is correctly detected. + +ifeq ($(TARGET),x86_64-unknown-linux-gnu) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) +EXTRA_RUSTFLAG= +endif + +all: +ifeq ($(ASAN_SUPPORT),1) + $(RUSTC) -g -Z sanitizer=address --crate-type cdylib --target $(TARGET) library.rs + $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) -llibrary program.rs + LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | grep -q stack-buffer-overflow +endif + diff --git a/src/test/run-make/sanitizer-cdylib-link/library.rs b/src/test/run-make/sanitizer-cdylib-link/library.rs new file mode 100644 index 0000000000000..4ceef5d3f5272 --- /dev/null +++ b/src/test/run-make/sanitizer-cdylib-link/library.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] +pub extern fn overflow() { + let xs = [0, 1, 2, 3]; + let _y = unsafe { *xs.as_ptr().offset(4) }; +} diff --git a/src/test/run-make/sanitizer-cdylib-link/program.rs b/src/test/run-make/sanitizer-cdylib-link/program.rs new file mode 100644 index 0000000000000..9f52817c85100 --- /dev/null +++ b/src/test/run-make/sanitizer-cdylib-link/program.rs @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern { + fn overflow(); +} + +fn main() { + unsafe { overflow() } +} diff --git a/src/test/run-make/sanitizer-dylib-link/Makefile b/src/test/run-make/sanitizer-dylib-link/Makefile new file mode 100644 index 0000000000000..d75241f09710a --- /dev/null +++ b/src/test/run-make/sanitizer-dylib-link/Makefile @@ -0,0 +1,19 @@ +-include ../tools.mk + +# This test builds a shared object, then an executable that links it as a native +# rust library (constrast to an rlib). The shared library and executable both +# are compiled with address sanitizer, and we assert that a fault in the dylib +# is correctly detected. + +ifeq ($(TARGET),x86_64-unknown-linux-gnu) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) +EXTRA_RUSTFLAG= +endif + +all: +ifeq ($(ASAN_SUPPORT),1) + $(RUSTC) -g -Z sanitizer=address --crate-type dylib --target $(TARGET) library.rs + $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) -llibrary program.rs + LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | grep -q stack-buffer-overflow +endif + diff --git a/src/test/run-make/sanitizer-dylib-link/library.rs b/src/test/run-make/sanitizer-dylib-link/library.rs new file mode 100644 index 0000000000000..4ceef5d3f5272 --- /dev/null +++ b/src/test/run-make/sanitizer-dylib-link/library.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] +pub extern fn overflow() { + let xs = [0, 1, 2, 3]; + let _y = unsafe { *xs.as_ptr().offset(4) }; +} diff --git a/src/test/run-make/sanitizer-dylib-link/program.rs b/src/test/run-make/sanitizer-dylib-link/program.rs new file mode 100644 index 0000000000000..9f52817c85100 --- /dev/null +++ b/src/test/run-make/sanitizer-dylib-link/program.rs @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern { + fn overflow(); +} + +fn main() { + unsafe { overflow() } +} diff --git a/src/test/run-make/sanitizer-dylib/Makefile b/src/test/run-make/sanitizer-dylib/Makefile deleted file mode 100644 index 835d5b0d9d8cd..0000000000000 --- a/src/test/run-make/sanitizer-dylib/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -ifeq ($(TARGET),x86_64-unknown-linux-gnu) -all: - $(RUSTC) -Z sanitizer=leak --crate-type dylib --target $(TARGET) hello.rs 2>&1 | grep -q 'Only executables and rlibs can be compiled with `-Z sanitizer`' -else -all: -endif diff --git a/src/test/run-make/sanitizer-invalid-cratetype/Makefile b/src/test/run-make/sanitizer-invalid-cratetype/Makefile new file mode 100644 index 0000000000000..d03bbf84c1d11 --- /dev/null +++ b/src/test/run-make/sanitizer-invalid-cratetype/Makefile @@ -0,0 +1,18 @@ +-include ../tools.mk + +# NOTE the address sanitizer only supports x86_64 linux and macOS + +ifeq ($(TARGET),x86_64-apple-darwin) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) +EXTRA_RUSTFLAG=-C rpath +else +ifeq ($(TARGET),x86_64-unknown-linux-gnu) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) +EXTRA_RUSTFLAG= +endif +endif + +all: +ifeq ($(ASAN_SUPPORT),1) + $(RUSTC) -Z sanitizer=address --crate-type proc-macro --target $(TARGET) hello.rs 2>&1 | grep -q -- '-Z sanitizer' +endif diff --git a/src/test/run-make/sanitizer-dylib/hello.rs b/src/test/run-make/sanitizer-invalid-cratetype/hello.rs similarity index 100% rename from src/test/run-make/sanitizer-dylib/hello.rs rename to src/test/run-make/sanitizer-invalid-cratetype/hello.rs diff --git a/src/test/run-make/sanitizer-staticlib-link/Makefile b/src/test/run-make/sanitizer-staticlib-link/Makefile new file mode 100644 index 0000000000000..f92dc52b44575 --- /dev/null +++ b/src/test/run-make/sanitizer-staticlib-link/Makefile @@ -0,0 +1,18 @@ +-include ../tools.mk + +# This test builds a staticlib, then an executable that links to it. +# The staticlib and executable both are compiled with address sanitizer, +# and we assert that a fault in the staticlib is correctly detected. + +ifeq ($(TARGET),x86_64-unknown-linux-gnu) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) +EXTRA_RUSTFLAG= +endif + +all: +ifeq ($(ASAN_SUPPORT),1) + $(RUSTC) -g -Z sanitizer=address --crate-type staticlib --target $(TARGET) library.rs + $(CC) program.c $(call STATICLIB,library) $(call OUT_EXE,program) $(EXTRACFLAGS) $(EXTRACXXFLAGS) + LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | grep -q stack-buffer-overflow +endif + diff --git a/src/test/run-make/sanitizer-staticlib-link/library.rs b/src/test/run-make/sanitizer-staticlib-link/library.rs new file mode 100644 index 0000000000000..4ceef5d3f5272 --- /dev/null +++ b/src/test/run-make/sanitizer-staticlib-link/library.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] +pub extern fn overflow() { + let xs = [0, 1, 2, 3]; + let _y = unsafe { *xs.as_ptr().offset(4) }; +} diff --git a/src/test/run-make/sanitizer-staticlib-link/program.c b/src/test/run-make/sanitizer-staticlib-link/program.c new file mode 100644 index 0000000000000..abd5d508e7295 --- /dev/null +++ b/src/test/run-make/sanitizer-staticlib-link/program.c @@ -0,0 +1,8 @@ +// ignore-license +void overflow(); + +int main() { + overflow(); + return 0; +} + From db19bf06244d969361b60e780566acdae13b696e Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Sat, 15 Jul 2017 15:35:03 +0200 Subject: [PATCH 101/123] Document default values for primitive types --- src/libcore/default.rs | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/libcore/default.rs b/src/libcore/default.rs index 0d7c1672fbcd2..45ab4f38b05e6 100644 --- a/src/libcore/default.rs +++ b/src/libcore/default.rs @@ -126,32 +126,33 @@ pub trait Default: Sized { } macro_rules! default_impl { - ($t:ty, $v:expr) => { + ($t:ty, $v:expr, $doc:expr) => { #[stable(feature = "rust1", since = "1.0.0")] impl Default for $t { #[inline] + #[doc = $doc] fn default() -> $t { $v } } } } -default_impl! { (), () } -default_impl! { bool, false } -default_impl! { char, '\x00' } +default_impl! { (), (), "Defaults to `()`" } +default_impl! { bool, false, "Defaults to `false`" } +default_impl! { char, '\x00', "Defaults to `\\x00`" } -default_impl! { usize, 0 } -default_impl! { u8, 0 } -default_impl! { u16, 0 } -default_impl! { u32, 0 } -default_impl! { u64, 0 } -default_impl! { u128, 0 } +default_impl! { usize, 0, "Defaults to `0`" } +default_impl! { u8, 0, "Defaults to `0`" } +default_impl! { u16, 0, "Defaults to `0`" } +default_impl! { u32, 0, "Defaults to `0`" } +default_impl! { u64, 0, "Defaults to `0`" } +default_impl! { u128, 0, "Defaults to `0`" } -default_impl! { isize, 0 } -default_impl! { i8, 0 } -default_impl! { i16, 0 } -default_impl! { i32, 0 } -default_impl! { i64, 0 } -default_impl! { i128, 0 } +default_impl! { isize, 0, "Defaults to `0`" } +default_impl! { i8, 0, "Defaults to `0`" } +default_impl! { i16, 0, "Defaults to `0`" } +default_impl! { i32, 0, "Defaults to `0`" } +default_impl! { i64, 0, "Defaults to `0`" } +default_impl! { i128, 0, "Defaults to `0`" } -default_impl! { f32, 0.0f32 } -default_impl! { f64, 0.0f64 } +default_impl! { f32, 0.0f32, "Defaults to `0.0`" } +default_impl! { f64, 0.0f64, "Defaults to `0.0`" } From caf125f414cc7bcdacdbfeab5c3b62eba772c8a3 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Sat, 15 Jul 2017 17:34:37 +0200 Subject: [PATCH 102/123] Rephrase the doc string --- src/libcore/default.rs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/libcore/default.rs b/src/libcore/default.rs index 45ab4f38b05e6..244df1a9966d4 100644 --- a/src/libcore/default.rs +++ b/src/libcore/default.rs @@ -136,23 +136,23 @@ macro_rules! default_impl { } } -default_impl! { (), (), "Defaults to `()`" } -default_impl! { bool, false, "Defaults to `false`" } -default_impl! { char, '\x00', "Defaults to `\\x00`" } +default_impl! { (), (), "Returns the default value of `()`" } +default_impl! { bool, false, "Returns the default value of `false`" } +default_impl! { char, '\x00', "Returns the default value of `\\x00`" } -default_impl! { usize, 0, "Defaults to `0`" } -default_impl! { u8, 0, "Defaults to `0`" } -default_impl! { u16, 0, "Defaults to `0`" } -default_impl! { u32, 0, "Defaults to `0`" } -default_impl! { u64, 0, "Defaults to `0`" } -default_impl! { u128, 0, "Defaults to `0`" } +default_impl! { usize, 0, "Returns the default value of `0`" } +default_impl! { u8, 0, "Returns the default value of `0`" } +default_impl! { u16, 0, "Returns the default value of `0`" } +default_impl! { u32, 0, "Returns the default value of `0`" } +default_impl! { u64, 0, "Returns the default value of `0`" } +default_impl! { u128, 0, "Returns the default value of `0`" } -default_impl! { isize, 0, "Defaults to `0`" } -default_impl! { i8, 0, "Defaults to `0`" } -default_impl! { i16, 0, "Defaults to `0`" } -default_impl! { i32, 0, "Defaults to `0`" } -default_impl! { i64, 0, "Defaults to `0`" } -default_impl! { i128, 0, "Defaults to `0`" } +default_impl! { isize, 0, "Returns the default value of `0`" } +default_impl! { i8, 0, "Returns the default value of `0`" } +default_impl! { i16, 0, "Returns the default value of `0`" } +default_impl! { i32, 0, "Returns the default value of `0`" } +default_impl! { i64, 0, "Returns the default value of `0`" } +default_impl! { i128, 0, "Returns the default value of `0`" } -default_impl! { f32, 0.0f32, "Defaults to `0.0`" } -default_impl! { f64, 0.0f64, "Defaults to `0.0`" } +default_impl! { f32, 0.0f32, "Returns the default value of `0.0`" } +default_impl! { f64, 0.0f64, "Returns the default value of `0.0`" } From 5f37110e5e1ae14a19aa7ee036f27e47e08ee73d Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 16 Jul 2017 02:02:34 +0300 Subject: [PATCH 103/123] Compile `compiler_builtins` with `abort` panic strategy --- src/bootstrap/bin/rustc.rs | 7 ++++++- src/librustc/middle/dependency_format.rs | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 497a5ab6c536c..134406b1acdb3 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -150,7 +150,12 @@ fn main() { // This... is a bit of a hack how we detect this. Ideally this // information should be encoded in the crate I guess? Would likely // require an RFC amendment to RFC 1513, however. - if crate_name == "panic_abort" { + // + // `compiler_builtins` are unconditionally compiled with panic=abort to + // workaround undefined references to `rust_eh_unwind_resume` generated + // otherwise, see issue https://github.com/rust-lang/rust/issues/43095. + if crate_name == "panic_abort" || + crate_name == "compiler_builtins" && stage != "0" { cmd.arg("-C").arg("panic=abort"); } diff --git a/src/librustc/middle/dependency_format.rs b/src/librustc/middle/dependency_format.rs index 9af93d0d49424..837ab4fd4a3cc 100644 --- a/src/librustc/middle/dependency_format.rs +++ b/src/librustc/middle/dependency_format.rs @@ -396,7 +396,8 @@ fn verify_ok<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, list: &[Linkage]) { } let cnum = CrateNum::new(i + 1); let found_strategy = sess.cstore.panic_strategy(cnum); - if desired_strategy == found_strategy { + let is_compiler_builtins = sess.cstore.is_compiler_builtins(cnum); + if is_compiler_builtins || desired_strategy == found_strategy { continue } From b11596867df57b8a7bffeac80957a7950a27ce0f Mon Sep 17 00:00:00 2001 From: Sam Cappleman-Lynes Date: Sun, 16 Jul 2017 17:34:09 +0100 Subject: [PATCH 104/123] Fix `range_covered_by_constructor` for exclusive ranges. This resolves #43253 --- src/librustc_const_eval/_match.rs | 8 ++-- src/test/ui/check_match/issue-43253.rs | 51 ++++++++++++++++++++++ src/test/ui/check_match/issue-43253.stderr | 20 +++++++++ 3 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 src/test/ui/check_match/issue-43253.rs create mode 100644 src/test/ui/check_match/issue-43253.stderr diff --git a/src/librustc_const_eval/_match.rs b/src/librustc_const_eval/_match.rs index 98d90188312df..9e40364cbcb6b 100644 --- a/src/librustc_const_eval/_match.rs +++ b/src/librustc_const_eval/_match.rs @@ -845,14 +845,14 @@ fn range_covered_by_constructor(tcx: TyCtxt, span: Span, match *ctor { ConstantValue(ref value) => { let to = cmp_to(value)?; - let end = (to != Ordering::Greater) || - (end == RangeEnd::Excluded && to == Ordering::Equal); + let end = (to == Ordering::Less) || + (end == RangeEnd::Included && to == Ordering::Equal); Ok(cmp_from(value)? && end) }, ConstantRange(ref from, ref to, RangeEnd::Included) => { let to = cmp_to(to)?; - let end = (to != Ordering::Greater) || - (end == RangeEnd::Excluded && to == Ordering::Equal); + let end = (to == Ordering::Less) || + (end == RangeEnd::Included && to == Ordering::Equal); Ok(cmp_from(from)? && end) }, ConstantRange(ref from, ref to, RangeEnd::Excluded) => { diff --git a/src/test/ui/check_match/issue-43253.rs b/src/test/ui/check_match/issue-43253.rs new file mode 100644 index 0000000000000..c77fa74f6e0e5 --- /dev/null +++ b/src/test/ui/check_match/issue-43253.rs @@ -0,0 +1,51 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(exclusive_range_pattern)] + +fn main() { + // These cases should generate no warning. + match 10 { + 1..10 => {}, + 10 => {}, + _ => {}, + } + + match 10 { + 1..10 => {}, + 9...10 => {}, + _ => {}, + } + + match 10 { + 1..10 => {}, + 10...10 => {}, + _ => {}, + } + + // These cases should generate an "unreachable pattern" warning. + match 10 { + 1..10 => {}, + 9 => {}, + _ => {}, + } + + match 10 { + 1..10 => {}, + 8...9 => {}, + _ => {}, + } + + match 10 { + 1..10 => {}, + 9...9 => {}, + _ => {}, + } +} \ No newline at end of file diff --git a/src/test/ui/check_match/issue-43253.stderr b/src/test/ui/check_match/issue-43253.stderr new file mode 100644 index 0000000000000..0d4a2ecf512de --- /dev/null +++ b/src/test/ui/check_match/issue-43253.stderr @@ -0,0 +1,20 @@ +warning: unreachable pattern + --> $DIR/issue-43253.rs:36:9 + | +36 | 9 => {}, + | ^ + | + = note: #[warn(unreachable_patterns)] on by default + +warning: unreachable pattern + --> $DIR/issue-43253.rs:42:9 + | +42 | 8...9 => {}, + | ^^^^^ + +warning: unreachable pattern + --> $DIR/issue-43253.rs:48:9 + | +48 | 9...9 => {}, + | ^^^^^ + From 1b3c339560ceb8cc6680ba5e7dc051c9e1698a15 Mon Sep 17 00:00:00 2001 From: Sam Cappleman-Lynes Date: Sun, 16 Jul 2017 18:05:03 +0100 Subject: [PATCH 105/123] Update function name to reflect reality --- src/librustc_const_eval/_match.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_const_eval/_match.rs b/src/librustc_const_eval/_match.rs index 9e40364cbcb6b..bae44c0047e2e 100644 --- a/src/librustc_const_eval/_match.rs +++ b/src/librustc_const_eval/_match.rs @@ -835,7 +835,7 @@ fn slice_pat_covered_by_constructor(_tcx: TyCtxt, _span: Span, Ok(true) } -fn range_covered_by_constructor(tcx: TyCtxt, span: Span, +fn constructor_covered_by_range(tcx: TyCtxt, span: Span, ctor: &Constructor, from: &ConstVal, to: &ConstVal, end: RangeEnd) @@ -933,7 +933,7 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>( "unexpected const-val {:?} with ctor {:?}", value, constructor) }, _ => { - match range_covered_by_constructor( + match constructor_covered_by_range( cx.tcx, pat.span, constructor, value, value, RangeEnd::Included ) { Ok(true) => Some(vec![]), @@ -945,7 +945,7 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>( } PatternKind::Range { ref lo, ref hi, ref end } => { - match range_covered_by_constructor( + match constructor_covered_by_range( cx.tcx, pat.span, constructor, lo, hi, end.clone() ) { Ok(true) => Some(vec![]), From 25797938b0300232b1ac575b9a4cd670e9a6df3a Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Mon, 22 May 2017 14:08:31 +1200 Subject: [PATCH 106/123] Remove exception from license check for strings.rs --- src/tools/tidy/src/deps.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index ba02ee0c6d73b..8b7da2267cded 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -32,7 +32,6 @@ static EXCEPTIONS: &'static [&'static str] = &[ "openssl", // BSD+advertising clause, cargo, mdbook "pest", // MPL2, mdbook via handlebars "thread-id", // Apache-2.0, mdbook - "strings", // this is actually MIT/Apache-2.0 but it's not in the manifest yet ]; pub fn check(path: &Path, bad: &mut bool) { From 04415dc64c5af86957b4e3b45e124108c93263c4 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Sat, 1 Jul 2017 06:58:54 +1200 Subject: [PATCH 107/123] Run RLS tests --- src/Cargo.lock | 120 +++++++++++++++++++++++++---------- src/Cargo.toml | 14 ++++ src/bootstrap/check.rs | 36 ++++++++--- src/bootstrap/mk/Makefile.in | 3 +- src/bootstrap/step.rs | 6 +- src/tools/rls | 2 +- 6 files changed, 135 insertions(+), 46 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index dae1aea341864..3c8d1164863de 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -102,6 +102,14 @@ dependencies = [ "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "bin_lib" +version = "0.1.0" + +[[package]] +name = "bin_lib_no_cfg_test" +version = "0.1.0" + [[package]] name = "bitflags" version = "0.7.0" @@ -132,6 +140,10 @@ dependencies = [ "toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "borrow_error" +version = "0.1.0" + [[package]] name = "bufstream" version = "0.1.3" @@ -155,7 +167,7 @@ dependencies = [ [[package]] name = "cargo" version = "0.21.0" -source = "git+https://github.com/rust-lang/cargo#1566c92b5d28e435613918e59dc94755f99d73b1" +source = "git+https://github.com/rust-lang/cargo#5982cf904be1d72f575dcbd1e750c07bf730b966" replace = "cargo 0.21.0" [[package]] @@ -191,8 +203,8 @@ dependencies = [ "psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde_ignored 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "shell-escape 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -218,7 +230,7 @@ dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -289,6 +301,10 @@ dependencies = [ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "completion" +version = "0.1.0" + [[package]] name = "core" version = "0.0.0" @@ -302,8 +318,8 @@ version = "0.10.0" dependencies = [ "curl 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -370,8 +386,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -426,6 +442,14 @@ dependencies = [ "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "find_all_refs" +version = "0.1.0" + +[[package]] +name = "find_all_refs_no_cfg_test" +version = "0.1.0" + [[package]] name = "flate2" version = "0.2.19" @@ -493,6 +517,10 @@ name = "glob" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "goto_def" +version = "0.1.0" + [[package]] name = "graphviz" version = "0.0.0" @@ -516,7 +544,7 @@ dependencies = [ "pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -525,6 +553,14 @@ name = "hex" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "highlight" +version = "0.1.0" + +[[package]] +name = "hover" +version = "0.1.0" + [[package]] name = "idna" version = "0.1.2" @@ -579,8 +615,8 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -677,7 +713,7 @@ dependencies = [ "open 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -718,6 +754,10 @@ dependencies = [ "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "multiple_bins" +version = "0.1.0" + [[package]] name = "net2" version = "0.2.29" @@ -957,6 +997,14 @@ dependencies = [ "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "reformat" +version = "0.1.0" + +[[package]] +name = "reformat_with_range" +version = "0.1.0" + [[package]] name = "regex" version = "0.1.80" @@ -999,6 +1047,10 @@ version = "0.1.0" name = "remote-test-server" version = "0.1.0" +[[package]] +name = "rename" +version = "0.1.0" + [[package]] name = "rls" version = "0.1.0" @@ -1009,13 +1061,13 @@ dependencies = [ "languageserver-types 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "racer 2.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-analysis 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-analysis 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rls-data 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rustfmt-nightly 0.1.8 (git+https://github.com/rust-lang-nursery/rustfmt?branch=rustfmt-42492)", - "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "rustfmt-nightly 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1024,7 +1076,7 @@ dependencies = [ [[package]] name = "rls-analysis" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "derive-new 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1049,8 +1101,8 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1463,8 +1515,8 @@ dependencies = [ [[package]] name = "rustfmt-nightly" -version = "0.1.8" -source = "git+https://github.com/rust-lang-nursery/rustfmt?branch=rustfmt-42492#7333dfc95b4af5c7283ba03f33c50f108d2be3f5" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1473,8 +1525,8 @@ dependencies = [ "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "strings 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1503,7 +1555,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1513,12 +1565,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_derive" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1540,7 +1592,7 @@ name = "serde_ignored" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1551,7 +1603,7 @@ dependencies = [ "dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1837,7 +1889,7 @@ name = "toml" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1908,7 +1960,7 @@ name = "url_serde" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2082,19 +2134,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b" "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" "checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db" -"checksum rls-analysis 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "34c9957e6a7e336978f9262dff7552f80b6c8588483f221a8e63f5b436010862" +"checksum rls-analysis 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ea940411ed2ad6d1e705fc2a0b146a0a3f30f8098ba4e61b45b4e5f2bfa7ed63" "checksum rls-data 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e502ac679bc35e023e982506c32d0278ef89e29af1e4ad21cb70c44b525b87a9" "checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a" "checksum rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ffd34691a510938bb67fe0444fb363103c73ffb31c121d1e16bc92d8945ea8ff" "checksum rustc-demangle 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3058a43ada2c2d0b92b3ae38007a2d0fa5e9db971be260e0171408a4ff471c95" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" -"checksum rustfmt-nightly 0.1.8 (git+https://github.com/rust-lang-nursery/rustfmt?branch=rustfmt-42492)" = "" +"checksum rustfmt-nightly 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6693f90ac7d0a2291aa309f5214f5f3ac1bd79961c11116fcf6d5545749bf2e7" "checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7" "checksum scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f417c22df063e9450888a7561788e9bd46d3bb3c1466435b4eccb903807f147d" "checksum semver 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fdd61b85a0fa777f7fb7c454b9189b2941b110d1385ce84d7f76efdf1606a85" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6a7c6b751a2e8d5df57a5ff71b5b4fc8aaee9ee28ff1341d640dd130bb5f4f7a" -"checksum serde_derive 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "2f6ca58905ebd3c3b285a8a6d4f3ac92b92c0d7951d5649b1bdd212549c06639" +"checksum serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "433d7d9f8530d5a939ad5e0e72a6243d2e42a24804f70bf592c679363dcacb2f" +"checksum serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "7b707cf0d4cab852084f573058def08879bb467fda89d99052485e7d00edd624" "checksum serde_derive_internals 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "37aee4e0da52d801acfbc0cc219eb1eda7142112339726e427926a6f6ee65d3a" "checksum serde_ignored 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c10e798e4405d7dcec3658989e35ee6706f730a9ed7c1184d5ebd84317e82f46" "checksum serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "48b04779552e92037212c3615370f6bd57a40ebba7f20e554ff9f55e41a69a7b" diff --git a/src/Cargo.toml b/src/Cargo.toml index 9cf6297d463be..f027965e791be 100644 --- a/src/Cargo.toml +++ b/src/Cargo.toml @@ -17,6 +17,20 @@ members = [ "tools/rust-installer", "tools/cargo", "tools/rls", + # FIXME(https://github.com/rust-lang/cargo/issues/4089): move these to exclude + "tools/rls/test_data/borrow_error", + "tools/rls/test_data/completion", + "tools/rls/test_data/find_all_refs", + "tools/rls/test_data/find_all_refs_no_cfg_test", + "tools/rls/test_data/goto_def", + "tools/rls/test_data/highlight", + "tools/rls/test_data/hover", + "tools/rls/test_data/rename", + "tools/rls/test_data/reformat", + "tools/rls/test_data/bin_lib_no_cfg_test", + "tools/rls/test_data/multiple_bins", + "tools/rls/test_data/bin_lib", + "tools/rls/test_data/reformat_with_range", ] # Curiously, compiletest will segfault if compiled with opt-level=3 on 64-bit diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 371512908a031..e4b0e2fb9ca0c 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -15,6 +15,7 @@ use std::collections::HashSet; use std::env; +use std::ffi::OsString; use std::iter; use std::fmt; use std::fs::{self, File}; @@ -117,14 +118,7 @@ pub fn cargotest(build: &Build, stage: u32, host: &str) { /// Runs `cargo test` for `cargo` packaged with Rust. pub fn cargo(build: &Build, stage: u32, host: &str) { - let ref compiler = Compiler::new(stage, host); - - // Configure PATH to find the right rustc. NB. we have to use PATH - // and not RUSTC because the Cargo test suite has tests that will - // fail if rustc is not spelled `rustc`. - let path = build.sysroot(compiler).join("bin"); - let old_path = env::var_os("PATH").unwrap_or_default(); - let newpath = env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect(""); + let compiler = &Compiler::new(stage, host); let mut cargo = build.cargo(compiler, Mode::Tool, host, "test"); cargo.arg("--manifest-path").arg(build.src.join("src/tools/cargo/Cargo.toml")); @@ -139,7 +133,31 @@ pub fn cargo(build: &Build, stage: u32, host: &str) { // available. cargo.env("CFG_DISABLE_CROSS_TESTS", "1"); - try_run(build, cargo.env("PATH", newpath)); + try_run(build, cargo.env("PATH", &path_for_cargo(build, compiler))); +} + +/// Runs `cargo test` for the rls. +pub fn rls(build: &Build, stage: u32, host: &str) { + let compiler = &Compiler::new(stage, host); + + let mut cargo = build.cargo(compiler, Mode::Tool, host, "test"); + cargo.arg("--manifest-path").arg(build.src.join("src/tools/rls/Cargo.toml")); + + // Don't build tests dynamically, just a pain to work with + cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); + + build.add_rustc_lib_path(compiler, &mut cargo); + + try_run(build, &mut cargo); +} + +fn path_for_cargo(build: &Build, compiler: &Compiler) -> OsString { + // Configure PATH to find the right rustc. NB. we have to use PATH + // and not RUSTC because the Cargo test suite has tests that will + // fail if rustc is not spelled `rustc`. + let path = build.sysroot(compiler).join("bin"); + let old_path = env::var_os("PATH").unwrap_or_default(); + env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("") } /// Runs the `tidy` tool as compiled in `stage` by the `host` compiler. diff --git a/src/bootstrap/mk/Makefile.in b/src/bootstrap/mk/Makefile.in index 47c792a510b1b..ad0ee8d47d643 100644 --- a/src/bootstrap/mk/Makefile.in +++ b/src/bootstrap/mk/Makefile.in @@ -55,7 +55,8 @@ check: check-aux: $(Q)$(BOOTSTRAP) test \ src/tools/cargotest \ - cargo \ + src/tools/cargo \ + src/tools/rls \ src/test/pretty \ src/test/run-pass/pretty \ src/test/run-fail/pretty \ diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs index 5a1ef818ccfc9..a1b26f44b7de1 100644 --- a/src/bootstrap/step.rs +++ b/src/bootstrap/step.rs @@ -472,10 +472,14 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { .dep(|s| s.name("librustc")) .host(true) .run(move |s| check::cargotest(build, s.stage, s.target)); - rules.test("check-cargo", "cargo") + rules.test("check-cargo", "src/tools/cargo") .dep(|s| s.name("tool-cargo")) .host(true) .run(move |s| check::cargo(build, s.stage, s.target)); + rules.test("check-rls", "src/tools/rls") + .dep(|s| s.name("tool-rls")) + .host(true) + .run(move |s| check::rls(build, s.stage, s.target)); rules.test("check-tidy", "src/tools/tidy") .dep(|s| s.name("tool-tidy").stage(0)) .default(true) diff --git a/src/tools/rls b/src/tools/rls index 70b89fdd7e5e7..618f802f0dceb 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit 70b89fdd7e5e77a3b88fc68982861d39d155be29 +Subproject commit 618f802f0dcebc9f23a527afd3cd228c1fa468f8 From 4a286639e8448476b0235c8fb2c8eeb7779b9251 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 16 May 2017 15:11:34 +0200 Subject: [PATCH 108/123] Move some tests from compile-fail to ui --- .../ui-fulldeps/auxiliary/attr_proc_macro.rs | 23 ++++++ .../ui-fulldeps/auxiliary/bang_proc_macro.rs | 23 ++++++ .../ui-fulldeps/auxiliary/derive-clona.rs | 23 ++++++ src/test/ui-fulldeps/auxiliary/derive-foo.rs | 23 ++++++ .../resolve-error.rs | 17 ----- src/test/ui-fulldeps/resolve-error.stderr | 76 +++++++++++++++++++ ...cast-to-unsized-trait-object-suggestion.rs | 6 -- ...-to-unsized-trait-object-suggestion.stderr | 18 +++++ src/test/{compile-fail => ui}/issue-35675.rs | 0 src/test/ui/issue-35675.stderr | 74 ++++++++++++++++++ .../macros}/macro-name-typo.rs | 2 - src/test/ui/macros/macro-name-typo.stderr | 10 +++ .../macros}/macro_undefined.rs | 4 - src/test/ui/macros/macro_undefined.stderr | 18 +++++ src/test/ui/resolve-error.stderr | 76 +++++++++++++++++++ 15 files changed, 364 insertions(+), 29 deletions(-) create mode 100644 src/test/ui-fulldeps/auxiliary/attr_proc_macro.rs create mode 100644 src/test/ui-fulldeps/auxiliary/bang_proc_macro.rs create mode 100644 src/test/ui-fulldeps/auxiliary/derive-clona.rs create mode 100644 src/test/ui-fulldeps/auxiliary/derive-foo.rs rename src/test/{compile-fail-fulldeps/proc-macro => ui-fulldeps}/resolve-error.rs (57%) create mode 100644 src/test/ui-fulldeps/resolve-error.stderr rename src/test/{compile-fail => ui}/cast-to-unsized-trait-object-suggestion.rs (67%) create mode 100644 src/test/ui/cast-to-unsized-trait-object-suggestion.stderr rename src/test/{compile-fail => ui}/issue-35675.rs (100%) create mode 100644 src/test/ui/issue-35675.stderr rename src/test/{compile-fail => ui/macros}/macro-name-typo.rs (87%) create mode 100644 src/test/ui/macros/macro-name-typo.stderr rename src/test/{compile-fail => ui/macros}/macro_undefined.rs (74%) create mode 100644 src/test/ui/macros/macro_undefined.stderr create mode 100644 src/test/ui/resolve-error.stderr diff --git a/src/test/ui-fulldeps/auxiliary/attr_proc_macro.rs b/src/test/ui-fulldeps/auxiliary/attr_proc_macro.rs new file mode 100644 index 0000000000000..db0c19e96f821 --- /dev/null +++ b/src/test/ui-fulldeps/auxiliary/attr_proc_macro.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic +#![feature(proc_macro)] +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn attr_proc_macro(_: TokenStream, input: TokenStream) -> TokenStream { + input +} diff --git a/src/test/ui-fulldeps/auxiliary/bang_proc_macro.rs b/src/test/ui-fulldeps/auxiliary/bang_proc_macro.rs new file mode 100644 index 0000000000000..89ac11b309d75 --- /dev/null +++ b/src/test/ui-fulldeps/auxiliary/bang_proc_macro.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic +#![feature(proc_macro)] +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro] +pub fn bang_proc_macro(input: TokenStream) -> TokenStream { + input +} diff --git a/src/test/ui-fulldeps/auxiliary/derive-clona.rs b/src/test/ui-fulldeps/auxiliary/derive-clona.rs new file mode 100644 index 0000000000000..719fbdb15ef2a --- /dev/null +++ b/src/test/ui-fulldeps/auxiliary/derive-clona.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(Clona)] +pub fn derive_clonea(input: TokenStream) -> TokenStream { + "".parse().unwrap() +} diff --git a/src/test/ui-fulldeps/auxiliary/derive-foo.rs b/src/test/ui-fulldeps/auxiliary/derive-foo.rs new file mode 100644 index 0000000000000..64dcf72ba2029 --- /dev/null +++ b/src/test/ui-fulldeps/auxiliary/derive-foo.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(FooWithLongName)] +pub fn derive_foo(input: TokenStream) -> TokenStream { + "".parse().unwrap() +} diff --git a/src/test/compile-fail-fulldeps/proc-macro/resolve-error.rs b/src/test/ui-fulldeps/resolve-error.rs similarity index 57% rename from src/test/compile-fail-fulldeps/proc-macro/resolve-error.rs rename to src/test/ui-fulldeps/resolve-error.rs index ddd8631f02e62..dfaa1d7a32e57 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/resolve-error.rs +++ b/src/test/ui-fulldeps/resolve-error.rs @@ -35,46 +35,29 @@ macro_rules! attr_proc_mac { } #[derive(FooWithLongNan)] -//~^ ERROR cannot find derive macro `FooWithLongNan` in this scope -//~^^ HELP did you mean `FooWithLongName`? struct Foo; #[attr_proc_macra] -//~^ ERROR cannot find attribute macro `attr_proc_macra` in this scope -//~^^ HELP did you mean `attr_proc_macro`? struct Bar; #[FooWithLongNan] -//~^ ERROR cannot find attribute macro `FooWithLongNan` in this scope struct Asdf; #[derive(Dlone)] -//~^ ERROR cannot find derive macro `Dlone` in this scope -//~^^ HELP did you mean `Clone`? struct A; #[derive(Dlona)] -//~^ ERROR cannot find derive macro `Dlona` in this scope -//~^^ HELP did you mean `Clona`? struct B; #[derive(attr_proc_macra)] -//~^ ERROR cannot find derive macro `attr_proc_macra` in this scope struct C; fn main() { FooWithLongNama!(); - //~^ ERROR cannot find macro `FooWithLongNama!` in this scope - //~^^ HELP did you mean `FooWithLongNam!`? attr_proc_macra!(); - //~^ ERROR cannot find macro `attr_proc_macra!` in this scope - //~^^ HELP did you mean `attr_proc_mac!`? Dlona!(); - //~^ ERROR cannot find macro `Dlona!` in this scope bang_proc_macrp!(); - //~^ ERROR cannot find macro `bang_proc_macrp!` in this scope - //~^^ HELP did you mean `bang_proc_macro!`? } diff --git a/src/test/ui-fulldeps/resolve-error.stderr b/src/test/ui-fulldeps/resolve-error.stderr new file mode 100644 index 0000000000000..cfc15d69feb63 --- /dev/null +++ b/src/test/ui-fulldeps/resolve-error.stderr @@ -0,0 +1,76 @@ +error: cannot find derive macro `FooWithLongNan` in this scope + --> $DIR/resolve-error.rs:36:10 + | +36 | #[derive(FooWithLongNan)] + | ^^^^^^^^^^^^^^ + | + = help: did you mean `FooWithLongName`? + +error: cannot find attribute macro `attr_proc_macra` in this scope + --> $DIR/resolve-error.rs:39:3 + | +39 | #[attr_proc_macra] + | ^^^^^^^^^^^^^^^ + | + = help: did you mean `attr_proc_macro`? + +error: cannot find attribute macro `FooWithLongNan` in this scope + --> $DIR/resolve-error.rs:42:3 + | +42 | #[FooWithLongNan] + | ^^^^^^^^^^^^^^ + +error: cannot find derive macro `Dlone` in this scope + --> $DIR/resolve-error.rs:45:10 + | +45 | #[derive(Dlone)] + | ^^^^^ + | + = help: did you mean `Clone`? + +error: cannot find derive macro `Dlona` in this scope + --> $DIR/resolve-error.rs:48:10 + | +48 | #[derive(Dlona)] + | ^^^^^ + | + = help: did you mean `Clona`? + +error: cannot find derive macro `attr_proc_macra` in this scope + --> $DIR/resolve-error.rs:51:10 + | +51 | #[derive(attr_proc_macra)] + | ^^^^^^^^^^^^^^^ + +error: cannot find macro `FooWithLongNama!` in this scope + --> $DIR/resolve-error.rs:55:5 + | +55 | FooWithLongNama!(); + | ^^^^^^^^^^^^^^^ + | + = help: did you mean `FooWithLongNam!`? + +error: cannot find macro `attr_proc_macra!` in this scope + --> $DIR/resolve-error.rs:57:5 + | +57 | attr_proc_macra!(); + | ^^^^^^^^^^^^^^^ + | + = help: did you mean `attr_proc_mac!`? + +error: cannot find macro `Dlona!` in this scope + --> $DIR/resolve-error.rs:59:5 + | +59 | Dlona!(); + | ^^^^^ + +error: cannot find macro `bang_proc_macrp!` in this scope + --> $DIR/resolve-error.rs:61:5 + | +61 | bang_proc_macrp!(); + | ^^^^^^^^^^^^^^^ + | + = help: did you mean `bang_proc_macro!`? + +error: aborting due to 10 previous errors + diff --git a/src/test/compile-fail/cast-to-unsized-trait-object-suggestion.rs b/src/test/ui/cast-to-unsized-trait-object-suggestion.rs similarity index 67% rename from src/test/compile-fail/cast-to-unsized-trait-object-suggestion.rs rename to src/test/ui/cast-to-unsized-trait-object-suggestion.rs index d18746cdf0ba5..c793454798275 100644 --- a/src/test/compile-fail/cast-to-unsized-trait-object-suggestion.rs +++ b/src/test/ui/cast-to-unsized-trait-object-suggestion.rs @@ -10,11 +10,5 @@ fn main() { &1 as Send; - //~^ ERROR cast to unsized type - //~| HELP try casting to a reference instead: - //~| SUGGESTION &1 as &Send; Box::new(1) as Send; - //~^ ERROR cast to unsized type - //~| HELP try casting to a `Box` instead: - //~| SUGGESTION Box::new(1) as Box; } diff --git a/src/test/ui/cast-to-unsized-trait-object-suggestion.stderr b/src/test/ui/cast-to-unsized-trait-object-suggestion.stderr new file mode 100644 index 0000000000000..dd9c2d14ef24e --- /dev/null +++ b/src/test/ui/cast-to-unsized-trait-object-suggestion.stderr @@ -0,0 +1,18 @@ +error: cast to unsized type: `&{integer}` as `std::marker::Send` + --> $DIR/cast-to-unsized-trait-object-suggestion.rs:12:5 + | +12 | &1 as Send; + | ^^^^^^---- + | | + | help: try casting to a reference instead: `&Send` + +error: cast to unsized type: `std::boxed::Box<{integer}>` as `std::marker::Send` + --> $DIR/cast-to-unsized-trait-object-suggestion.rs:13:5 + | +13 | Box::new(1) as Send; + | ^^^^^^^^^^^^^^^---- + | | + | help: try casting to a `Box` instead: `Box` + +error: aborting due to previous error(s) + diff --git a/src/test/compile-fail/issue-35675.rs b/src/test/ui/issue-35675.rs similarity index 100% rename from src/test/compile-fail/issue-35675.rs rename to src/test/ui/issue-35675.rs diff --git a/src/test/ui/issue-35675.stderr b/src/test/ui/issue-35675.stderr new file mode 100644 index 0000000000000..22322a388c5f2 --- /dev/null +++ b/src/test/ui/issue-35675.stderr @@ -0,0 +1,74 @@ +error[E0412]: cannot find type `Apple` in this scope + --> $DIR/issue-35675.rs:20:29 + | +20 | fn should_return_fruit() -> Apple { + | ^^^^^ not found in this scope + | +help: there is an enum variant `Fruit::Apple`, did you mean to use `Fruit`? + --> $DIR/issue-35675.rs:14:5 + | +14 | Apple(i64), + | ^^^^^^^^^^ + +error[E0425]: cannot find function `Apple` in this scope + --> $DIR/issue-35675.rs:23:5 + | +23 | Apple(5) + | ^^^^^ not found in this scope + | +help: possible candidate is found in another module, you can import it into scope + | use Fruit::Apple; + +error[E0573]: expected type, found variant `Fruit::Apple` + --> $DIR/issue-35675.rs:28:33 + | +28 | fn should_return_fruit_too() -> Fruit::Apple { + | ^^^^^^^^^^^^ not a type + | +help: there is an enum variant `Fruit::Apple`, did you mean to use `Fruit`? + --> $DIR/issue-35675.rs:14:5 + | +14 | Apple(i64), + | ^^^^^^^^^^ + +error[E0425]: cannot find function `Apple` in this scope + --> $DIR/issue-35675.rs:31:5 + | +31 | Apple(5) + | ^^^^^ not found in this scope + | +help: possible candidate is found in another module, you can import it into scope + | use Fruit::Apple; + +error[E0573]: expected type, found variant `Ok` + --> $DIR/issue-35675.rs:36:13 + | +36 | fn foo() -> Ok { + | ^^ not a type + | + = help: there is an enum variant `std::prelude::v1::Ok`, did you mean to use `std::prelude::v1`? + = help: there is an enum variant `std::prelude::v1::Result::Ok`, did you mean to use `std::prelude::v1::Result`? + +error[E0412]: cannot find type `Variant3` in this scope + --> $DIR/issue-35675.rs:44:13 + | +44 | fn bar() -> Variant3 { + | ^^^^^^^^ not found in this scope + | +help: there is an enum variant `x::Enum::Variant3`, did you mean to use `x::Enum`? + --> $DIR/issue-35675.rs:63:9 + | +63 | Variant3(usize), + | ^^^^^^^^^^^^^^^ + +error[E0573]: expected type, found variant `Some` + --> $DIR/issue-35675.rs:49:13 + | +49 | fn qux() -> Some { + | ^^^^ not a type + | + = help: there is an enum variant `std::option::Option::Some`, did you mean to use `std::option::Option`? + = help: there is an enum variant `std::prelude::v1::Some`, did you mean to use `std::prelude::v1`? + +error: aborting due to previous error(s) + diff --git a/src/test/compile-fail/macro-name-typo.rs b/src/test/ui/macros/macro-name-typo.rs similarity index 87% rename from src/test/compile-fail/macro-name-typo.rs rename to src/test/ui/macros/macro-name-typo.rs index 4840205fee4c3..ec8d27f9138f7 100644 --- a/src/test/compile-fail/macro-name-typo.rs +++ b/src/test/ui/macros/macro-name-typo.rs @@ -10,6 +10,4 @@ fn main() { printlx!("oh noes!"); - //~^ ERROR cannot find macro - //~^^ HELP did you mean `println!`? } diff --git a/src/test/ui/macros/macro-name-typo.stderr b/src/test/ui/macros/macro-name-typo.stderr new file mode 100644 index 0000000000000..c54de468d133f --- /dev/null +++ b/src/test/ui/macros/macro-name-typo.stderr @@ -0,0 +1,10 @@ +error: cannot find macro `printlx!` in this scope + --> $DIR/macro-name-typo.rs:12:5 + | +12 | printlx!("oh noes!"); + | ^^^^^^^ + | + = help: did you mean `println!`? + +error: aborting due to previous error(s) + diff --git a/src/test/compile-fail/macro_undefined.rs b/src/test/ui/macros/macro_undefined.rs similarity index 74% rename from src/test/compile-fail/macro_undefined.rs rename to src/test/ui/macros/macro_undefined.rs index 00c8d44f30602..db93ba5e2c41d 100644 --- a/src/test/compile-fail/macro_undefined.rs +++ b/src/test/ui/macros/macro_undefined.rs @@ -19,9 +19,5 @@ mod m { fn main() { k!(); - //~^ ERROR cannot find macro `k!` in this scope - //~^^ HELP did you mean `kl!`? kl!(); - //~^ ERROR cannot find macro `kl!` in this scope - //~^^ HELP have you added the `#[macro_use]` on the module/import? } diff --git a/src/test/ui/macros/macro_undefined.stderr b/src/test/ui/macros/macro_undefined.stderr new file mode 100644 index 0000000000000..152de056991c8 --- /dev/null +++ b/src/test/ui/macros/macro_undefined.stderr @@ -0,0 +1,18 @@ +error: cannot find macro `kl!` in this scope + --> $DIR/macro_undefined.rs:22:5 + | +22 | kl!(); + | ^^ + | + = help: have you added the `#[macro_use]` on the module/import? + +error: cannot find macro `k!` in this scope + --> $DIR/macro_undefined.rs:21:5 + | +21 | k!(); + | ^ + | + = help: did you mean `kl!`? + +error: aborting due to previous error(s) + diff --git a/src/test/ui/resolve-error.stderr b/src/test/ui/resolve-error.stderr new file mode 100644 index 0000000000000..946eaba45fc13 --- /dev/null +++ b/src/test/ui/resolve-error.stderr @@ -0,0 +1,76 @@ +error: cannot find derive macro `FooWithLongNan` in this scope + --> $DIR/resolve-error.rs:37:10 + | +37 | #[derive(FooWithLongNan)] + | ^^^^^^^^^^^^^^ + | + = help: did you mean `FooWithLongName`? + +error: cannot find attribute macro `attr_proc_macra` in this scope + --> $DIR/resolve-error.rs:40:3 + | +40 | #[attr_proc_macra] + | ^^^^^^^^^^^^^^^ + | + = help: did you mean `attr_proc_macro`? + +error: cannot find attribute macro `FooWithLongNan` in this scope + --> $DIR/resolve-error.rs:43:3 + | +43 | #[FooWithLongNan] + | ^^^^^^^^^^^^^^ + +error: cannot find derive macro `Dlone` in this scope + --> $DIR/resolve-error.rs:46:10 + | +46 | #[derive(Dlone)] + | ^^^^^ + | + = help: did you mean `Clone`? + +error: cannot find derive macro `Dlona` in this scope + --> $DIR/resolve-error.rs:49:10 + | +49 | #[derive(Dlona)] + | ^^^^^ + | + = help: did you mean `Clona`? + +error: cannot find derive macro `attr_proc_macra` in this scope + --> $DIR/resolve-error.rs:52:10 + | +52 | #[derive(attr_proc_macra)] + | ^^^^^^^^^^^^^^^ + +error: cannot find macro `FooWithLongNama!` in this scope + --> $DIR/resolve-error.rs:56:5 + | +56 | FooWithLongNama!(); + | ^^^^^^^^^^^^^^^ + | + = help: did you mean `FooWithLongNam!`? + +error: cannot find macro `attr_proc_macra!` in this scope + --> $DIR/resolve-error.rs:58:5 + | +58 | attr_proc_macra!(); + | ^^^^^^^^^^^^^^^ + | + = help: did you mean `attr_proc_mac!`? + +error: cannot find macro `Dlona!` in this scope + --> $DIR/resolve-error.rs:60:5 + | +60 | Dlona!(); + | ^^^^^ + +error: cannot find macro `bang_proc_macrp!` in this scope + --> $DIR/resolve-error.rs:62:5 + | +62 | bang_proc_macrp!(); + | ^^^^^^^^^^^^^^^ + | + = help: did you mean `bang_proc_macro!`? + +error: aborting due to previous error(s) + From a9d9a4aab4f6c51d16c2f13e69abcbe8f6c76725 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 16 May 2017 15:12:24 +0200 Subject: [PATCH 109/123] Change some helps to suggestions --- src/librustc_borrowck/borrowck/mod.rs | 2 +- src/librustc_errors/diagnostic.rs | 12 ++++ src/librustc_errors/emitter.rs | 2 +- src/librustc_resolve/lib.rs | 20 +++--- src/librustc_resolve/macros.rs | 5 +- src/librustc_typeck/check/cast.rs | 4 +- src/librustc_typeck/check/op.rs | 2 +- src/libsyntax/parse/parser.rs | 4 +- src/test/ui-fulldeps/resolve-error.stderr | 68 ++++++++----------- ...-to-unsized-trait-object-suggestion.stderr | 6 +- src/test/ui/issue-35675.stderr | 51 +++++++------- .../issue-40402-1.stderr | 2 +- src/test/ui/macros/macro-name-typo.stderr | 6 +- src/test/ui/macros/macro_undefined.stderr | 6 +- .../ui/mismatched_types/issue-19109.stderr | 2 +- src/test/ui/resolve-error.stderr | 28 ++------ src/test/ui/resolve/issue-14254.stderr | 38 +++++------ src/test/ui/resolve/issue-2356.stderr | 12 ++-- .../resolve/resolve-assoc-suggestions.stderr | 6 +- .../resolve-speculative-adjustment.stderr | 4 +- .../ui/resolve/token-error-correct-3.stderr | 2 +- .../unresolved_static_type_field.stderr | 2 +- src/test/ui/span/issue-39018.stderr | 2 +- src/test/ui/span/suggestion-non-ascii.stderr | 2 +- .../ui/suggestions/tuple-float-index.stderr | 2 +- .../ui/type-check/assignment-in-if.stderr | 8 +-- 26 files changed, 139 insertions(+), 159 deletions(-) diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 3be7c43cab938..1bfc5805bc8fd 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -991,7 +991,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { .span_suggestion(err.span, &format!("to force the closure to take ownership of {} \ (and any other referenced variables), \ - use the `move` keyword, as shown:", + use the `move` keyword", cmt_path_or_string), suggestion) .emit(); diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index d7c21127474a4..ee07b6e909f7d 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -211,6 +211,18 @@ impl Diagnostic { /// Prints out a message with a suggested edit of the code. /// + /// In case of short messages and a simple suggestion, + /// rustc displays it as a label like + /// + /// "try adding parentheses: `(tup.0).1`" + /// + /// The message + /// * should not end in any punctuation (a `:` is added automatically) + /// * should not be a question + /// * should not contain any parts like "the following", "as shown" + /// * may look like "to do xyz, use" or "to do xyz, use abc" + /// * may contain a name of a function, variable or type, but not whole expressions + /// /// See `diagnostic::CodeSuggestion` for more information. pub fn span_suggestion(&mut self, sp: Span, msg: &str, suggestion: String) -> &mut Self { self.suggestions.push(CodeSuggestion { diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 2aea6d125f201..3e8bd093f4f93 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -51,7 +51,7 @@ impl Emitter for EmitterWriter { // This substitution is only removal, don't show it format!("help: {}", sugg.msg) } else { - format!("help: {} `{}`", sugg.msg, substitution) + format!("help: {}: `{}`", sugg.msg, substitution) }; primary_span.push_span_label(sugg.substitution_spans().next().unwrap(), msg); } else { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 7754cd7366ecf..49e6929aeef1d 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -2409,13 +2409,15 @@ impl<'a> Resolver<'a> { .map(|suggestion| import_candidate_to_paths(&suggestion)).collect::>(); enum_candidates.sort(); for (sp, variant_path, enum_path) in enum_candidates { - let msg = format!("there is an enum variant `{}`, did you mean to use `{}`?", - variant_path, - enum_path); if sp == DUMMY_SP { + let msg = format!("there is an enum variant `{}`, \ + try using `{}`?", + variant_path, + enum_path); err.help(&msg); } else { - err.span_help(sp, &msg); + err.span_suggestion(span, "you can try using the variant's enum", + enum_path); } } } @@ -2424,18 +2426,20 @@ impl<'a> Resolver<'a> { let self_is_available = this.self_value_is_available(path[0].ctxt, span); match candidate { AssocSuggestion::Field => { - err.span_label(span, format!("did you mean `self.{}`?", path_str)); + err.span_suggestion(span, "try", + format!("self.{}", path_str)); if !self_is_available { err.span_label(span, format!("`self` value is only available in \ methods with `self` parameter")); } } AssocSuggestion::MethodWithSelf if self_is_available => { - err.span_label(span, format!("did you mean `self.{}(...)`?", - path_str)); + err.span_suggestion(span, "try", + format!("self.{}", path_str)); } AssocSuggestion::MethodWithSelf | AssocSuggestion::AssocItem => { - err.span_label(span, format!("did you mean `Self::{}`?", path_str)); + err.span_suggestion(span, "try", + format!("Self::{}", path_str)); } } return err; diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 0fbc596f2e1c2..a993aca92dd12 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -658,9 +658,10 @@ impl<'a> Resolver<'a> { if let Some(suggestion) = suggestion { if suggestion != name { if let MacroKind::Bang = kind { - err.help(&format!("did you mean `{}!`?", suggestion)); + err.span_suggestion(span, "you could try the macro", + format!("{}!", suggestion)); } else { - err.help(&format!("did you mean `{}`?", suggestion)); + err.span_suggestion(span, "try", suggestion.to_string()); } } else { err.help("have you added the `#[macro_use]` on the module/import?"); diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 7bd24c939caf0..b3f62de5b570b 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -253,7 +253,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { match fcx.tcx.sess.codemap().span_to_snippet(self.cast_span) { Ok(s) => { err.span_suggestion(self.cast_span, - "try casting to a reference instead:", + "try casting to a reference instead", format!("&{}{}", mtstr, s)); } Err(_) => { @@ -272,7 +272,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { match fcx.tcx.sess.codemap().span_to_snippet(self.cast_span) { Ok(s) => { err.span_suggestion(self.cast_span, - "try casting to a `Box` instead:", + "try casting to a `Box` instead", format!("Box<{}>", s)); } Err(_) => span_help!(err, self.cast_span, "did you mean `Box<{}>`?", tstr), diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 4d69b37b113cf..032e37a34a887 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -320,7 +320,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { from a string reference. String concatenation \ appends the string on the right to the string \ on the left and may require reallocation. This \ - requires ownership of the string on the left."), suggestion); + requires ownership of the string on the left"), suggestion); is_string_addition = true; } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 74b2ea1df323a..90d9ae383a491 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1490,7 +1490,7 @@ impl<'a> Parser<'a> { s.print_bounds(" +", &bounds)?; s.pclose() }); - err.span_suggestion(sum_span, "try adding parentheses:", sum_with_parens); + err.span_suggestion(sum_span, "try adding parentheses", sum_with_parens); } TyKind::Ptr(..) | TyKind::BareFn(..) => { err.span_label(sum_span, "perhaps you forgot parentheses?"); @@ -5280,7 +5280,7 @@ impl<'a> Parser<'a> { `pub(in path::to::module)`: visible only on the specified path"##; let path = self.parse_path(PathStyle::Mod)?; let path_span = self.prev_span; - let help_msg = format!("make this visible only to module `{}` with `in`:", path); + let help_msg = format!("make this visible only to module `{}` with `in`", path); self.expect(&token::CloseDelim(token::Paren))?; // `)` let mut err = self.span_fatal_help(path_span, msg, suggestion); err.span_suggestion(path_span, &help_msg, format!("in {}", path)); diff --git a/src/test/ui-fulldeps/resolve-error.stderr b/src/test/ui-fulldeps/resolve-error.stderr index cfc15d69feb63..754f6bc4f1c1c 100644 --- a/src/test/ui-fulldeps/resolve-error.stderr +++ b/src/test/ui-fulldeps/resolve-error.stderr @@ -1,76 +1,62 @@ error: cannot find derive macro `FooWithLongNan` in this scope - --> $DIR/resolve-error.rs:36:10 + --> $DIR/resolve-error.rs:37:10 | -36 | #[derive(FooWithLongNan)] - | ^^^^^^^^^^^^^^ - | - = help: did you mean `FooWithLongName`? +37 | #[derive(FooWithLongNan)] + | ^^^^^^^^^^^^^^ help: try: `FooWithLongName` error: cannot find attribute macro `attr_proc_macra` in this scope - --> $DIR/resolve-error.rs:39:3 - | -39 | #[attr_proc_macra] - | ^^^^^^^^^^^^^^^ + --> $DIR/resolve-error.rs:40:3 | - = help: did you mean `attr_proc_macro`? +40 | #[attr_proc_macra] + | ^^^^^^^^^^^^^^^ help: try: `attr_proc_macro` error: cannot find attribute macro `FooWithLongNan` in this scope - --> $DIR/resolve-error.rs:42:3 + --> $DIR/resolve-error.rs:43:3 | -42 | #[FooWithLongNan] +43 | #[FooWithLongNan] | ^^^^^^^^^^^^^^ error: cannot find derive macro `Dlone` in this scope - --> $DIR/resolve-error.rs:45:10 + --> $DIR/resolve-error.rs:46:10 | -45 | #[derive(Dlone)] - | ^^^^^ - | - = help: did you mean `Clone`? +46 | #[derive(Dlone)] + | ^^^^^ help: try: `Clone` error: cannot find derive macro `Dlona` in this scope - --> $DIR/resolve-error.rs:48:10 - | -48 | #[derive(Dlona)] - | ^^^^^ + --> $DIR/resolve-error.rs:49:10 | - = help: did you mean `Clona`? +49 | #[derive(Dlona)] + | ^^^^^ help: try: `Clona` error: cannot find derive macro `attr_proc_macra` in this scope - --> $DIR/resolve-error.rs:51:10 + --> $DIR/resolve-error.rs:52:10 | -51 | #[derive(attr_proc_macra)] +52 | #[derive(attr_proc_macra)] | ^^^^^^^^^^^^^^^ error: cannot find macro `FooWithLongNama!` in this scope - --> $DIR/resolve-error.rs:55:5 + --> $DIR/resolve-error.rs:56:5 | -55 | FooWithLongNama!(); - | ^^^^^^^^^^^^^^^ - | - = help: did you mean `FooWithLongNam!`? +56 | FooWithLongNama!(); + | ^^^^^^^^^^^^^^^ help: you could try the macro: `FooWithLongNam!` error: cannot find macro `attr_proc_macra!` in this scope - --> $DIR/resolve-error.rs:57:5 - | -57 | attr_proc_macra!(); - | ^^^^^^^^^^^^^^^ + --> $DIR/resolve-error.rs:58:5 | - = help: did you mean `attr_proc_mac!`? +58 | attr_proc_macra!(); + | ^^^^^^^^^^^^^^^ help: you could try the macro: `attr_proc_mac!` error: cannot find macro `Dlona!` in this scope - --> $DIR/resolve-error.rs:59:5 + --> $DIR/resolve-error.rs:60:5 | -59 | Dlona!(); +60 | Dlona!(); | ^^^^^ error: cannot find macro `bang_proc_macrp!` in this scope - --> $DIR/resolve-error.rs:61:5 - | -61 | bang_proc_macrp!(); - | ^^^^^^^^^^^^^^^ + --> $DIR/resolve-error.rs:62:5 | - = help: did you mean `bang_proc_macro!`? +62 | bang_proc_macrp!(); + | ^^^^^^^^^^^^^^^ help: you could try the macro: `bang_proc_macro!` error: aborting due to 10 previous errors diff --git a/src/test/ui/cast-to-unsized-trait-object-suggestion.stderr b/src/test/ui/cast-to-unsized-trait-object-suggestion.stderr index dd9c2d14ef24e..4d4eb7b4ecfdb 100644 --- a/src/test/ui/cast-to-unsized-trait-object-suggestion.stderr +++ b/src/test/ui/cast-to-unsized-trait-object-suggestion.stderr @@ -1,4 +1,4 @@ -error: cast to unsized type: `&{integer}` as `std::marker::Send` +error[E0620]: cast to unsized type: `&{integer}` as `std::marker::Send` --> $DIR/cast-to-unsized-trait-object-suggestion.rs:12:5 | 12 | &1 as Send; @@ -6,7 +6,7 @@ error: cast to unsized type: `&{integer}` as `std::marker::Send` | | | help: try casting to a reference instead: `&Send` -error: cast to unsized type: `std::boxed::Box<{integer}>` as `std::marker::Send` +error[E0620]: cast to unsized type: `std::boxed::Box<{integer}>` as `std::marker::Send` --> $DIR/cast-to-unsized-trait-object-suggestion.rs:13:5 | 13 | Box::new(1) as Send; @@ -14,5 +14,5 @@ error: cast to unsized type: `std::boxed::Box<{integer}>` as `std::marker::Send` | | | help: try casting to a `Box` instead: `Box` -error: aborting due to previous error(s) +error: aborting due to 2 previous errors diff --git a/src/test/ui/issue-35675.stderr b/src/test/ui/issue-35675.stderr index 22322a388c5f2..36fdbe986262c 100644 --- a/src/test/ui/issue-35675.stderr +++ b/src/test/ui/issue-35675.stderr @@ -2,13 +2,10 @@ error[E0412]: cannot find type `Apple` in this scope --> $DIR/issue-35675.rs:20:29 | 20 | fn should_return_fruit() -> Apple { - | ^^^^^ not found in this scope - | -help: there is an enum variant `Fruit::Apple`, did you mean to use `Fruit`? - --> $DIR/issue-35675.rs:14:5 - | -14 | Apple(i64), - | ^^^^^^^^^^ + | ^^^^^ + | | + | not found in this scope + | help: you can try using the variant's enum: `Fruit` error[E0425]: cannot find function `Apple` in this scope --> $DIR/issue-35675.rs:23:5 @@ -17,19 +14,18 @@ error[E0425]: cannot find function `Apple` in this scope | ^^^^^ not found in this scope | help: possible candidate is found in another module, you can import it into scope - | use Fruit::Apple; + | +12 | use Fruit::Apple; + | error[E0573]: expected type, found variant `Fruit::Apple` --> $DIR/issue-35675.rs:28:33 | 28 | fn should_return_fruit_too() -> Fruit::Apple { - | ^^^^^^^^^^^^ not a type - | -help: there is an enum variant `Fruit::Apple`, did you mean to use `Fruit`? - --> $DIR/issue-35675.rs:14:5 - | -14 | Apple(i64), - | ^^^^^^^^^^ + | ^^^^^^^^^^^^ + | | + | not a type + | help: you can try using the variant's enum: `Fruit` error[E0425]: cannot find function `Apple` in this scope --> $DIR/issue-35675.rs:31:5 @@ -38,7 +34,9 @@ error[E0425]: cannot find function `Apple` in this scope | ^^^^^ not found in this scope | help: possible candidate is found in another module, you can import it into scope - | use Fruit::Apple; + | +12 | use Fruit::Apple; + | error[E0573]: expected type, found variant `Ok` --> $DIR/issue-35675.rs:36:13 @@ -46,20 +44,17 @@ error[E0573]: expected type, found variant `Ok` 36 | fn foo() -> Ok { | ^^ not a type | - = help: there is an enum variant `std::prelude::v1::Ok`, did you mean to use `std::prelude::v1`? - = help: there is an enum variant `std::prelude::v1::Result::Ok`, did you mean to use `std::prelude::v1::Result`? + = help: there is an enum variant `std::prelude::v1::Ok`, try using `std::prelude::v1`? + = help: there is an enum variant `std::result::Result::Ok`, try using `std::result::Result`? error[E0412]: cannot find type `Variant3` in this scope --> $DIR/issue-35675.rs:44:13 | 44 | fn bar() -> Variant3 { - | ^^^^^^^^ not found in this scope - | -help: there is an enum variant `x::Enum::Variant3`, did you mean to use `x::Enum`? - --> $DIR/issue-35675.rs:63:9 - | -63 | Variant3(usize), - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^ + | | + | not found in this scope + | help: you can try using the variant's enum: `x::Enum` error[E0573]: expected type, found variant `Some` --> $DIR/issue-35675.rs:49:13 @@ -67,8 +62,8 @@ error[E0573]: expected type, found variant `Some` 49 | fn qux() -> Some { | ^^^^ not a type | - = help: there is an enum variant `std::option::Option::Some`, did you mean to use `std::option::Option`? - = help: there is an enum variant `std::prelude::v1::Some`, did you mean to use `std::prelude::v1`? + = help: there is an enum variant `std::option::Option::Some`, try using `std::option::Option`? + = help: there is an enum variant `std::prelude::v1::Some`, try using `std::prelude::v1`? -error: aborting due to previous error(s) +error: aborting due to 7 previous errors diff --git a/src/test/ui/issue-40402-ref-hints/issue-40402-1.stderr b/src/test/ui/issue-40402-ref-hints/issue-40402-1.stderr index de110ac12b703..26f150811b7db 100644 --- a/src/test/ui/issue-40402-ref-hints/issue-40402-1.stderr +++ b/src/test/ui/issue-40402-ref-hints/issue-40402-1.stderr @@ -4,7 +4,7 @@ error[E0507]: cannot move out of indexed content 19 | let e = f.v[0]; | ^^^^^^ | | - | help: consider using a reference instead `&f.v[0]` + | help: consider using a reference instead: `&f.v[0]` | cannot move out of indexed content error: aborting due to previous error diff --git a/src/test/ui/macros/macro-name-typo.stderr b/src/test/ui/macros/macro-name-typo.stderr index c54de468d133f..7c83250fe8ada 100644 --- a/src/test/ui/macros/macro-name-typo.stderr +++ b/src/test/ui/macros/macro-name-typo.stderr @@ -2,9 +2,7 @@ error: cannot find macro `printlx!` in this scope --> $DIR/macro-name-typo.rs:12:5 | 12 | printlx!("oh noes!"); - | ^^^^^^^ - | - = help: did you mean `println!`? + | ^^^^^^^ help: you could try the macro: `println!` -error: aborting due to previous error(s) +error: aborting due to previous error diff --git a/src/test/ui/macros/macro_undefined.stderr b/src/test/ui/macros/macro_undefined.stderr index 152de056991c8..5c33ae99734e8 100644 --- a/src/test/ui/macros/macro_undefined.stderr +++ b/src/test/ui/macros/macro_undefined.stderr @@ -10,9 +10,7 @@ error: cannot find macro `k!` in this scope --> $DIR/macro_undefined.rs:21:5 | 21 | k!(); - | ^ - | - = help: did you mean `kl!`? + | ^ help: you could try the macro: `kl!` -error: aborting due to previous error(s) +error: aborting due to 2 previous errors diff --git a/src/test/ui/mismatched_types/issue-19109.stderr b/src/test/ui/mismatched_types/issue-19109.stderr index 2b4b8242af6fb..2d8d557d9f35f 100644 --- a/src/test/ui/mismatched_types/issue-19109.stderr +++ b/src/test/ui/mismatched_types/issue-19109.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-19109.rs:14:5 | 13 | fn function(t: &mut Trait) { - | - help: possibly return type missing here? `-> *mut Trait ` + | - help: possibly return type missing here?: `-> *mut Trait ` 14 | t as *mut Trait | ^^^^^^^^^^^^^^^ expected (), found *-ptr | diff --git a/src/test/ui/resolve-error.stderr b/src/test/ui/resolve-error.stderr index 946eaba45fc13..27f93939246c0 100644 --- a/src/test/ui/resolve-error.stderr +++ b/src/test/ui/resolve-error.stderr @@ -2,17 +2,13 @@ error: cannot find derive macro `FooWithLongNan` in this scope --> $DIR/resolve-error.rs:37:10 | 37 | #[derive(FooWithLongNan)] - | ^^^^^^^^^^^^^^ - | - = help: did you mean `FooWithLongName`? + | ^^^^^^^^^^^^^^ help: try: `FooWithLongName` error: cannot find attribute macro `attr_proc_macra` in this scope --> $DIR/resolve-error.rs:40:3 | 40 | #[attr_proc_macra] - | ^^^^^^^^^^^^^^^ - | - = help: did you mean `attr_proc_macro`? + | ^^^^^^^^^^^^^^^ help: try: `attr_proc_macro` error: cannot find attribute macro `FooWithLongNan` in this scope --> $DIR/resolve-error.rs:43:3 @@ -24,17 +20,13 @@ error: cannot find derive macro `Dlone` in this scope --> $DIR/resolve-error.rs:46:10 | 46 | #[derive(Dlone)] - | ^^^^^ - | - = help: did you mean `Clone`? + | ^^^^^ help: try: `Clone` error: cannot find derive macro `Dlona` in this scope --> $DIR/resolve-error.rs:49:10 | 49 | #[derive(Dlona)] - | ^^^^^ - | - = help: did you mean `Clona`? + | ^^^^^ help: try: `Clona` error: cannot find derive macro `attr_proc_macra` in this scope --> $DIR/resolve-error.rs:52:10 @@ -46,17 +38,13 @@ error: cannot find macro `FooWithLongNama!` in this scope --> $DIR/resolve-error.rs:56:5 | 56 | FooWithLongNama!(); - | ^^^^^^^^^^^^^^^ - | - = help: did you mean `FooWithLongNam!`? + | ^^^^^^^^^^^^^^^ help: you could try the macro: `FooWithLongNam!` error: cannot find macro `attr_proc_macra!` in this scope --> $DIR/resolve-error.rs:58:5 | 58 | attr_proc_macra!(); - | ^^^^^^^^^^^^^^^ - | - = help: did you mean `attr_proc_mac!`? + | ^^^^^^^^^^^^^^^ help: you could try the macro: `attr_proc_mac!` error: cannot find macro `Dlona!` in this scope --> $DIR/resolve-error.rs:60:5 @@ -68,9 +56,7 @@ error: cannot find macro `bang_proc_macrp!` in this scope --> $DIR/resolve-error.rs:62:5 | 62 | bang_proc_macrp!(); - | ^^^^^^^^^^^^^^^ - | - = help: did you mean `bang_proc_macro!`? + | ^^^^^^^^^^^^^^^ help: you could try the macro: `bang_proc_macro!` error: aborting due to previous error(s) diff --git a/src/test/ui/resolve/issue-14254.stderr b/src/test/ui/resolve/issue-14254.stderr index 11268e593c413..7aa0c2707b56f 100644 --- a/src/test/ui/resolve/issue-14254.stderr +++ b/src/test/ui/resolve/issue-14254.stderr @@ -2,7 +2,7 @@ error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:29:9 | 29 | baz(); - | ^^^ did you mean `self.baz(...)`? + | ^^^ help: try: `self.baz` error[E0425]: cannot find value `a` in this scope --> $DIR/issue-14254.rs:32:9 @@ -14,19 +14,19 @@ error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:40:9 | 40 | baz(); - | ^^^ did you mean `self.baz(...)`? + | ^^^ help: try: `self.baz` error[E0425]: cannot find value `x` in this scope --> $DIR/issue-14254.rs:43:9 | 43 | x; - | ^ did you mean `self.x`? + | ^ help: try: `self.x` error[E0425]: cannot find value `y` in this scope --> $DIR/issue-14254.rs:46:9 | 46 | y; - | ^ did you mean `self.y`? + | ^ help: try: `self.y` error[E0425]: cannot find value `a` in this scope --> $DIR/issue-14254.rs:49:9 @@ -38,7 +38,7 @@ error[E0425]: cannot find value `bah` in this scope --> $DIR/issue-14254.rs:52:9 | 52 | bah; - | ^^^ did you mean `Self::bah`? + | ^^^ help: try: `Self::bah` error[E0425]: cannot find value `b` in this scope --> $DIR/issue-14254.rs:55:9 @@ -50,19 +50,19 @@ error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:63:9 | 63 | baz(); - | ^^^ did you mean `self.baz(...)`? + | ^^^ help: try: `self.baz` error[E0425]: cannot find value `x` in this scope --> $DIR/issue-14254.rs:66:9 | 66 | x; - | ^ did you mean `self.x`? + | ^ help: try: `self.x` error[E0425]: cannot find value `y` in this scope --> $DIR/issue-14254.rs:69:9 | 69 | y; - | ^ did you mean `self.y`? + | ^ help: try: `self.y` error[E0425]: cannot find value `a` in this scope --> $DIR/issue-14254.rs:72:9 @@ -74,7 +74,7 @@ error[E0425]: cannot find value `bah` in this scope --> $DIR/issue-14254.rs:75:9 | 75 | bah; - | ^^^ did you mean `Self::bah`? + | ^^^ help: try: `Self::bah` error[E0425]: cannot find value `b` in this scope --> $DIR/issue-14254.rs:78:9 @@ -86,61 +86,61 @@ error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:86:9 | 86 | baz(); - | ^^^ did you mean `self.baz(...)`? + | ^^^ help: try: `self.baz` error[E0425]: cannot find value `bah` in this scope --> $DIR/issue-14254.rs:89:9 | 89 | bah; - | ^^^ did you mean `Self::bah`? + | ^^^ help: try: `Self::bah` error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:97:9 | 97 | baz(); - | ^^^ did you mean `self.baz(...)`? + | ^^^ help: try: `self.baz` error[E0425]: cannot find value `bah` in this scope --> $DIR/issue-14254.rs:100:9 | 100 | bah; - | ^^^ did you mean `Self::bah`? + | ^^^ help: try: `Self::bah` error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:108:9 | 108 | baz(); - | ^^^ did you mean `self.baz(...)`? + | ^^^ help: try: `self.baz` error[E0425]: cannot find value `bah` in this scope --> $DIR/issue-14254.rs:111:9 | 111 | bah; - | ^^^ did you mean `Self::bah`? + | ^^^ help: try: `Self::bah` error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:119:9 | 119 | baz(); - | ^^^ did you mean `self.baz(...)`? + | ^^^ help: try: `self.baz` error[E0425]: cannot find value `bah` in this scope --> $DIR/issue-14254.rs:122:9 | 122 | bah; - | ^^^ did you mean `Self::bah`? + | ^^^ help: try: `Self::bah` error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:130:9 | 130 | baz(); - | ^^^ did you mean `self.baz(...)`? + | ^^^ help: try: `self.baz` error[E0425]: cannot find value `bah` in this scope --> $DIR/issue-14254.rs:133:9 | 133 | bah; - | ^^^ did you mean `Self::bah`? + | ^^^ help: try: `Self::bah` error[E0601]: main function not found diff --git a/src/test/ui/resolve/issue-2356.stderr b/src/test/ui/resolve/issue-2356.stderr index 039887d8da65f..9c683f4418972 100644 --- a/src/test/ui/resolve/issue-2356.stderr +++ b/src/test/ui/resolve/issue-2356.stderr @@ -8,13 +8,13 @@ error[E0425]: cannot find function `clone` in this scope --> $DIR/issue-2356.rs:35:5 | 35 | clone(); - | ^^^^^ did you mean `self.clone(...)`? + | ^^^^^ help: try: `self.clone` error[E0425]: cannot find function `default` in this scope --> $DIR/issue-2356.rs:43:5 | 43 | default(); - | ^^^^^^^ did you mean `Self::default`? + | ^^^^^^^ help: try: `Self::default` error[E0425]: cannot find value `whiskers` in this scope --> $DIR/issue-2356.rs:52:5 @@ -22,14 +22,14 @@ error[E0425]: cannot find value `whiskers` in this scope 52 | whiskers -= other; | ^^^^^^^^ | | - | did you mean `self.whiskers`? + | help: try: `self.whiskers` | `self` value is only available in methods with `self` parameter error[E0425]: cannot find function `shave` in this scope --> $DIR/issue-2356.rs:57:5 | 57 | shave(4); - | ^^^^^ did you mean `Self::shave`? + | ^^^^^ help: try: `Self::shave` error[E0425]: cannot find function `purr` in this scope --> $DIR/issue-2356.rs:60:5 @@ -83,7 +83,7 @@ error[E0425]: cannot find value `whiskers` in this scope --> $DIR/issue-2356.rs:104:5 | 104 | whiskers = 0; - | ^^^^^^^^ did you mean `self.whiskers`? + | ^^^^^^^^ help: try: `self.whiskers` error[E0425]: cannot find value `whiskers` in this scope --> $DIR/issue-2356.rs:110:5 @@ -91,7 +91,7 @@ error[E0425]: cannot find value `whiskers` in this scope 110 | whiskers = 4; | ^^^^^^^^ | | - | did you mean `self.whiskers`? + | help: try: `self.whiskers` | `self` value is only available in methods with `self` parameter error[E0425]: cannot find function `purr_louder` in this scope diff --git a/src/test/ui/resolve/resolve-assoc-suggestions.stderr b/src/test/ui/resolve/resolve-assoc-suggestions.stderr index 7975c168de7d4..77aa545e2ad6b 100644 --- a/src/test/ui/resolve/resolve-assoc-suggestions.stderr +++ b/src/test/ui/resolve/resolve-assoc-suggestions.stderr @@ -14,13 +14,13 @@ error[E0425]: cannot find value `field` in this scope --> $DIR/resolve-assoc-suggestions.rs:32:9 | 32 | field; - | ^^^^^ did you mean `self.field`? + | ^^^^^ help: try: `self.field` error[E0412]: cannot find type `Type` in this scope --> $DIR/resolve-assoc-suggestions.rs:36:16 | 36 | let _: Type; - | ^^^^ did you mean `Self::Type`? + | ^^^^ help: try: `Self::Type` error[E0531]: cannot find tuple struct/variant `Type` in this scope --> $DIR/resolve-assoc-suggestions.rs:39:13 @@ -50,7 +50,7 @@ error[E0425]: cannot find value `method` in this scope --> $DIR/resolve-assoc-suggestions.rs:52:9 | 52 | method; - | ^^^^^^ did you mean `self.method(...)`? + | ^^^^^^ help: try: `self.method` error: aborting due to 9 previous errors diff --git a/src/test/ui/resolve/resolve-speculative-adjustment.stderr b/src/test/ui/resolve/resolve-speculative-adjustment.stderr index e7df8140bc577..3e1b075679a50 100644 --- a/src/test/ui/resolve/resolve-speculative-adjustment.stderr +++ b/src/test/ui/resolve/resolve-speculative-adjustment.stderr @@ -14,13 +14,13 @@ error[E0425]: cannot find value `field` in this scope --> $DIR/resolve-speculative-adjustment.rs:35:9 | 35 | field; - | ^^^^^ did you mean `self.field`? + | ^^^^^ help: try: `self.field` error[E0425]: cannot find function `method` in this scope --> $DIR/resolve-speculative-adjustment.rs:38:9 | 38 | method(); - | ^^^^^^ did you mean `self.method(...)`? + | ^^^^^^ help: try: `self.method` error: aborting due to 4 previous errors diff --git a/src/test/ui/resolve/token-error-correct-3.stderr b/src/test/ui/resolve/token-error-correct-3.stderr index bd3bdf35da609..2e8cc40dc5175 100644 --- a/src/test/ui/resolve/token-error-correct-3.stderr +++ b/src/test/ui/resolve/token-error-correct-3.stderr @@ -35,7 +35,7 @@ error[E0308]: mismatched types --> $DIR/token-error-correct-3.rs:25:13 | 25 | fs::create_dir_all(path.as_ref()).map(|()| true) //~ ERROR: mismatched types - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- help: did you mean to add a semicolon here? `;` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- help: did you mean to add a semicolon here?: `;` | | | expected (), found enum `std::result::Result` | diff --git a/src/test/ui/resolve/unresolved_static_type_field.stderr b/src/test/ui/resolve/unresolved_static_type_field.stderr index 5fbaf66e014af..e598851e3628e 100644 --- a/src/test/ui/resolve/unresolved_static_type_field.stderr +++ b/src/test/ui/resolve/unresolved_static_type_field.stderr @@ -4,7 +4,7 @@ error[E0425]: cannot find value `cx` in this scope 19 | f(cx); | ^^ | | - | did you mean `self.cx`? + | help: try: `self.cx` | `self` value is only available in methods with `self` parameter error: aborting due to previous error diff --git a/src/test/ui/span/issue-39018.stderr b/src/test/ui/span/issue-39018.stderr index a0445eaee9162..d87fc122d8ee2 100644 --- a/src/test/ui/span/issue-39018.stderr +++ b/src/test/ui/span/issue-39018.stderr @@ -4,7 +4,7 @@ error[E0369]: binary operation `+` cannot be applied to type `&'static str` 12 | let x = "Hello " + "World!"; | ^^^^^^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings | -help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left. +help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left | 12 | let x = "Hello ".to_owned() + "World!"; | ^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/span/suggestion-non-ascii.stderr b/src/test/ui/span/suggestion-non-ascii.stderr index c2ab7542d8a98..c67a8fe32b9dd 100644 --- a/src/test/ui/span/suggestion-non-ascii.stderr +++ b/src/test/ui/span/suggestion-non-ascii.stderr @@ -2,7 +2,7 @@ error[E0608]: cannot index into a value of type `({integer},)` --> $DIR/suggestion-non-ascii.rs:14:21 | 14 | println!("☃{}", tup[0]); - | ^^^^^^ help: to access tuple elements, use `tup.0` + | ^^^^^^ help: to access tuple elements, use: `tup.0` error: aborting due to previous error diff --git a/src/test/ui/suggestions/tuple-float-index.stderr b/src/test/ui/suggestions/tuple-float-index.stderr index 8a121b1453662..4b1be26c86b0e 100644 --- a/src/test/ui/suggestions/tuple-float-index.stderr +++ b/src/test/ui/suggestions/tuple-float-index.stderr @@ -5,7 +5,7 @@ error: unexpected token: `1.1` | ------------^^^ | | | | | unexpected token - | help: try parenthesizing the first index `((1, (2, 3)).1).1` + | help: try parenthesizing the first index: `((1, (2, 3)).1).1` error: aborting due to previous error diff --git a/src/test/ui/type-check/assignment-in-if.stderr b/src/test/ui/type-check/assignment-in-if.stderr index a077f37eae6ee..b740a1b776f75 100644 --- a/src/test/ui/type-check/assignment-in-if.stderr +++ b/src/test/ui/type-check/assignment-in-if.stderr @@ -4,7 +4,7 @@ error[E0308]: mismatched types 25 | if x = x { | ^^^^^ | | - | help: did you mean to compare equality? `x == x` + | help: did you mean to compare equality?: `x == x` | expected bool, found () | = note: expected type `bool` @@ -16,7 +16,7 @@ error[E0308]: mismatched types 31 | if (x = x) { | ^^^^^^^ | | - | help: did you mean to compare equality? `x == x` + | help: did you mean to compare equality?: `x == x` | expected bool, found () | = note: expected type `bool` @@ -28,7 +28,7 @@ error[E0308]: mismatched types 37 | if y = (Foo { foo: x }) { | ^^^^^^^^^^^^^^^^^^^^ | | - | help: did you mean to compare equality? `y == (Foo { foo: x })` + | help: did you mean to compare equality?: `y == (Foo { foo: x })` | expected bool, found () | = note: expected type `bool` @@ -40,7 +40,7 @@ error[E0308]: mismatched types 43 | if 3 = x { | ^^^^^ | | - | help: did you mean to compare equality? `3 == x` + | help: did you mean to compare equality?: `3 == x` | expected bool, found () | = note: expected type `bool` From eb7f429ea54db7111b9c1570ce08c3851727d2e5 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 17 Jul 2017 10:16:08 +0200 Subject: [PATCH 110/123] Move resolve diagnostic instability to compile-fail The produced paths aren't stable between builds, since reporting paths inside resolve, before resolve is finished might produce paths resolved to type aliases instead of the concrete type. Compile-fail tests can match just parts of messages, so they don't "suffer" from this issue. This is just a workaround, the instability should be fixed in the future. --- src/test/compile-fail/issue-35675.rs | 67 ++++++++++++++++++++++++++++ src/test/ui/issue-35675.rs | 16 ------- src/test/ui/issue-35675.stderr | 24 ++-------- 3 files changed, 70 insertions(+), 37 deletions(-) create mode 100644 src/test/compile-fail/issue-35675.rs diff --git a/src/test/compile-fail/issue-35675.rs b/src/test/compile-fail/issue-35675.rs new file mode 100644 index 0000000000000..c09e56cbc5bca --- /dev/null +++ b/src/test/compile-fail/issue-35675.rs @@ -0,0 +1,67 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// these two HELPs are actually in a new line between this line and the `enum Fruit` line +enum Fruit { //~ HELP possible candidate is found in another module, you can import it into scope + //~^ HELP possible candidate is found in another module, you can import it into scope + Apple(i64), + Orange(i64), +} + +fn should_return_fruit() -> Apple { + //~^ ERROR cannot find type `Apple` in this scope + //~| NOTE not found in this scope + //~| HELP you can try using the variant's enum + Apple(5) + //~^ ERROR cannot find function `Apple` in this scope + //~| NOTE not found in this scope +} + +fn should_return_fruit_too() -> Fruit::Apple { + //~^ ERROR expected type, found variant `Fruit::Apple` + //~| HELP you can try using the variant's enum + //~| NOTE not a type + Apple(5) + //~^ ERROR cannot find function `Apple` in this scope + //~| NOTE not found in this scope +} + +fn foo() -> Ok { + //~^ ERROR expected type, found variant `Ok` + //~| NOTE not a type + //~| HELP there is an enum variant + //~| HELP there is an enum variant + Ok(()) +} + +fn bar() -> Variant3 { + //~^ ERROR cannot find type `Variant3` in this scope + //~| HELP you can try using the variant's enum + //~| NOTE not found in this scope +} + +fn qux() -> Some { + //~^ ERROR expected type, found variant `Some` + //~| NOTE not a type + //~| HELP there is an enum variant + //~| HELP there is an enum variant + Some(1) +} + +fn main() {} + +mod x { + enum Enum { + Variant1, + Variant2(), + Variant3(usize), + Variant4 {}, + } +} diff --git a/src/test/ui/issue-35675.rs b/src/test/ui/issue-35675.rs index 001c1f2eddca1..391e1f2db5c02 100644 --- a/src/test/ui/issue-35675.rs +++ b/src/test/ui/issue-35675.rs @@ -33,27 +33,11 @@ fn should_return_fruit_too() -> Fruit::Apple { //~| NOTE not found in this scope } -fn foo() -> Ok { - //~^ ERROR expected type, found variant `Ok` - //~| NOTE not a type - //~| HELP there is an enum variant - //~| HELP there is an enum variant - Ok(()) -} - fn bar() -> Variant3 { //~^ ERROR cannot find type `Variant3` in this scope //~| NOTE not found in this scope } -fn qux() -> Some { - //~^ ERROR expected type, found variant `Some` - //~| NOTE not a type - //~| HELP there is an enum variant - //~| HELP there is an enum variant - Some(1) -} - fn main() {} mod x { diff --git a/src/test/ui/issue-35675.stderr b/src/test/ui/issue-35675.stderr index 36fdbe986262c..c2c10724646ef 100644 --- a/src/test/ui/issue-35675.stderr +++ b/src/test/ui/issue-35675.stderr @@ -38,32 +38,14 @@ help: possible candidate is found in another module, you can import it into scop 12 | use Fruit::Apple; | -error[E0573]: expected type, found variant `Ok` - --> $DIR/issue-35675.rs:36:13 - | -36 | fn foo() -> Ok { - | ^^ not a type - | - = help: there is an enum variant `std::prelude::v1::Ok`, try using `std::prelude::v1`? - = help: there is an enum variant `std::result::Result::Ok`, try using `std::result::Result`? - error[E0412]: cannot find type `Variant3` in this scope - --> $DIR/issue-35675.rs:44:13 + --> $DIR/issue-35675.rs:36:13 | -44 | fn bar() -> Variant3 { +36 | fn bar() -> Variant3 { | ^^^^^^^^ | | | not found in this scope | help: you can try using the variant's enum: `x::Enum` -error[E0573]: expected type, found variant `Some` - --> $DIR/issue-35675.rs:49:13 - | -49 | fn qux() -> Some { - | ^^^^ not a type - | - = help: there is an enum variant `std::option::Option::Some`, try using `std::option::Option`? - = help: there is an enum variant `std::prelude::v1::Some`, try using `std::prelude::v1`? - -error: aborting due to 7 previous errors +error: aborting due to 5 previous errors From 5580c19f8def49489877eb9a0edf421f8605b76a Mon Sep 17 00:00:00 2001 From: Matthew Hammer Date: Mon, 17 Jul 2017 12:33:43 -0600 Subject: [PATCH 111/123] write log of queries --- src/librustc_driver/profile/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/librustc_driver/profile/mod.rs b/src/librustc_driver/profile/mod.rs index 965919169a2db..b54d1798c22a3 100644 --- a/src/librustc_driver/profile/mod.rs +++ b/src/librustc_driver/profile/mod.rs @@ -54,6 +54,11 @@ fn profile_queries_thread(r:Receiver) { write!(html_file, "\n").unwrap(); trace::write_traces(&mut html_file, &mut counts_file, &frame.traces); write!(html_file, "\n\n").unwrap(); + + let mut queries_file = File::create(format!("{}.log.txt", path)).unwrap(); + for q in queries.iter() { + writeln!(&mut queries_file, "{:?}", q).unwrap() + }; } continue } From 9967e9e3e974872a311399a913e6a2d57a16b697 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 7 Jun 2017 00:17:14 +0300 Subject: [PATCH 112/123] Support generic lifetime arguments in method calls --- src/librustc_passes/ast_validation.rs | 15 +--- src/librustc_typeck/check/method/confirm.rs | 46 +++------- src/librustc_typeck/diagnostics.rs | 88 +------------------ src/test/compile-fail/E0036.rs | 24 ----- ...> method-call-lifetime-args-unresolved.rs} | 12 +-- .../compile-fail/method-call-lifetime-args.rs | 33 +++++++ .../compile-fail/method-call-type-binding.rs | 2 +- src/test/compile-fail/trait-test-2.rs | 5 +- 8 files changed, 53 insertions(+), 172 deletions(-) delete mode 100644 src/test/compile-fail/E0036.rs rename src/test/compile-fail/{E0035.rs => method-call-lifetime-args-unresolved.rs} (63%) create mode 100644 src/test/compile-fail/method-call-lifetime-args.rs diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index 72c7b92fe6e30..99a49dbd7d732 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -127,18 +127,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> { } ExprKind::MethodCall(ref segment, ..) => { if let Some(ref params) = segment.parameters { - match **params { - PathParameters::AngleBracketed(ref param_data) => { - if !param_data.bindings.is_empty() { - let binding_span = param_data.bindings[0].span; - self.err_handler().span_err(binding_span, - "type bindings cannot be used in method calls"); - } - } - PathParameters::Parenthesized(..) => { - self.err_handler().span_err(expr.span, - "parenthesized parameters cannot be used on method calls"); - } + if let PathParameters::Parenthesized(..) = **params { + self.err_handler().span_err(expr.span, + "parenthesized parameters cannot be used on method calls"); } } } diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 0829951e12deb..a647a8bf6f86c 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -10,6 +10,7 @@ use super::{probe, MethodCallee}; +use astconv::AstConv; use check::{FnCtxt, LvalueOp, callee}; use hir::def_id::DefId; use rustc::ty::subst::Substs; @@ -282,52 +283,25 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { segment: &hir::PathSegment, substs: &Substs<'tcx>) -> &'tcx Substs<'tcx> { - let supplied_method_types = match segment.parameters { - hir::AngleBracketedParameters(ref data) => &data.types, - _ => bug!("unexpected generic arguments: {:?}", segment.parameters), - }; - // Determine the values for the generic parameters of the method. // If they were not explicitly supplied, just construct fresh // variables. - let num_supplied_types = supplied_method_types.len(); let method_generics = self.tcx.generics_of(pick.item.def_id); - let num_method_types = method_generics.types.len(); - - if num_supplied_types > 0 && num_supplied_types != num_method_types { - if num_method_types == 0 { - struct_span_err!(self.tcx.sess, - self.span, - E0035, - "does not take type parameters") - .span_label(self.span, "called with unneeded type parameters") - .emit(); - } else { - struct_span_err!(self.tcx.sess, - self.span, - E0036, - "incorrect number of type parameters given for this method: \ - expected {}, found {}", - num_method_types, - num_supplied_types) - .span_label(self.span, - format!("Passed {} type argument{}, expected {}", - num_supplied_types, - if num_supplied_types != 1 { "s" } else { "" }, - num_method_types)) - .emit(); - } - } + let mut fn_segment = Some((segment, method_generics)); + self.fcx.check_path_parameter_count(self.span, &mut fn_segment); // Create subst for early-bound lifetime parameters, combining // parameters from the type and those from the method. - // - // FIXME -- permit users to manually specify lifetimes - let supplied_start = substs.len() + method_generics.regions.len(); + let (supplied_types, supplied_lifetimes) = match segment.parameters { + hir::AngleBracketedParameters(ref data) => (&data.types, &data.lifetimes), + _ => bug!("unexpected generic arguments: {:?}", segment.parameters), + }; Substs::for_item(self.tcx, pick.item.def_id, |def, _| { let i = def.index as usize; if i < substs.len() { substs.region_at(i) + } else if let Some(lifetime) = supplied_lifetimes.get(i - substs.len()) { + AstConv::ast_region_to_region(self.fcx, lifetime, Some(def)) } else { self.region_var_for_def(self.span, def) } @@ -335,7 +309,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { let i = def.index as usize; if i < substs.len() { substs.type_at(i) - } else if let Some(ast_ty) = supplied_method_types.get(i - supplied_start) { + } else if let Some(ast_ty) = supplied_types.get(i - substs.len()) { self.to_ty(ast_ty) } else { self.type_var_for_def(self.span, def, cur_substs) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 87e59683fd2a8..1e26a734e7640 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -332,92 +332,6 @@ fn main() { ``` "##, -E0035: r##" -You tried to give a type parameter where it wasn't needed. Erroneous code -example: - -```compile_fail,E0035 -struct Test; - -impl Test { - fn method(&self) {} -} - -fn main() { - let x = Test; - - x.method::(); // Error: Test::method doesn't need type parameter! -} -``` - -To fix this error, just remove the type parameter: - -``` -struct Test; - -impl Test { - fn method(&self) {} -} - -fn main() { - let x = Test; - - x.method(); // OK, we're good! -} -``` -"##, - -E0036: r##" -This error occurrs when you pass too many or not enough type parameters to -a method. Erroneous code example: - -```compile_fail,E0036 -struct Test; - -impl Test { - fn method(&self, v: &[T]) -> usize { - v.len() - } -} - -fn main() { - let x = Test; - let v = &[0]; - - x.method::(v); // error: only one type parameter is expected! -} -``` - -To fix it, just specify a correct number of type parameters: - -``` -struct Test; - -impl Test { - fn method(&self, v: &[T]) -> usize { - v.len() - } -} - -fn main() { - let x = Test; - let v = &[0]; - - x.method::(v); // OK, we're good! -} -``` - -Please note on the last example that we could have called `method` like this: - -``` -# struct Test; -# impl Test { fn method(&self, v: &[T]) -> usize { v.len() } } -# let x = Test; -# let v = &[0]; -x.method(v); -``` -"##, - E0040: r##" It is not allowed to manually call destructors in Rust. It is also not necessary to do this since `drop` is called automatically whenever a value goes @@ -4681,6 +4595,8 @@ error, just declare a function. } register_diagnostics! { +// E0035, merged into E0087/E0089 +// E0036, merged into E0087/E0089 // E0068, // E0085, // E0086, diff --git a/src/test/compile-fail/E0036.rs b/src/test/compile-fail/E0036.rs deleted file mode 100644 index ecb6dac66f218..0000000000000 --- a/src/test/compile-fail/E0036.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Test; - -impl Test { - fn method(&self, v: &[T]) -> usize { - v.len() - } -} - -fn main() { - let x = Test; - let v = &[0]; - x.method::(v); //~ ERROR E0036 - //~| NOTE Passed 2 type arguments, expected 1 -} diff --git a/src/test/compile-fail/E0035.rs b/src/test/compile-fail/method-call-lifetime-args-unresolved.rs similarity index 63% rename from src/test/compile-fail/E0035.rs rename to src/test/compile-fail/method-call-lifetime-args-unresolved.rs index 9322d21d2a88d..4910bfaf4f60d 100644 --- a/src/test/compile-fail/E0035.rs +++ b/src/test/compile-fail/method-call-lifetime-args-unresolved.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,14 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Test; - -impl Test { - fn method(&self) {} -} - fn main() { - let x = Test; - x.method::(); //~ ERROR E0035 - //~| NOTE called with unneeded type parameters + 0.clone::<'a>(); //~ ERROR use of undeclared lifetime name `'a` } diff --git a/src/test/compile-fail/method-call-lifetime-args.rs b/src/test/compile-fail/method-call-lifetime-args.rs new file mode 100644 index 0000000000000..75c469ecd3268 --- /dev/null +++ b/src/test/compile-fail/method-call-lifetime-args.rs @@ -0,0 +1,33 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct S; + +impl S { + fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} } + fn life_and_type<'a, T>(&self) -> &'a T { loop {} } +} + +fn main() { + S.late(&0, &0); // OK + S.late::<'static>(&0, &0); + //~^ ERROR expected at most 0 lifetime parameters, found 1 lifetime parameter + S.late::<'static, 'static, 'static>(&0, &0); + //~^ ERROR expected at most 0 lifetime parameters, found 3 lifetime parameter + S.early(); // OK + S.early::<'static>(); + //~^ ERROR expected 2 lifetime parameters, found 1 lifetime parameter + S.early::<'static, 'static, 'static>(); + //~^ ERROR expected at most 2 lifetime parameters, found 3 lifetime parameters + let _: &u8 = S.life_and_type::<'static>(); + S.life_and_type::(); + S.life_and_type::<'static, u8>(); +} diff --git a/src/test/compile-fail/method-call-type-binding.rs b/src/test/compile-fail/method-call-type-binding.rs index acffb06ebecf2..3ae878ed1cbc0 100644 --- a/src/test/compile-fail/method-call-type-binding.rs +++ b/src/test/compile-fail/method-call-type-binding.rs @@ -9,5 +9,5 @@ // except according to those terms. fn main() { - 0.clone::(); //~ ERROR type bindings cannot be used in method calls + 0.clone::(); //~ ERROR unexpected binding of associated item } diff --git a/src/test/compile-fail/trait-test-2.rs b/src/test/compile-fail/trait-test-2.rs index 2d4df77f96045..b08aab6da852a 100644 --- a/src/test/compile-fail/trait-test-2.rs +++ b/src/test/compile-fail/trait-test-2.rs @@ -15,9 +15,8 @@ impl bar for i32 { fn dup(&self) -> i32 { *self } fn blah(&self) {} } impl bar for u32 { fn dup(&self) -> u32 { *self } fn blah(&self) {} } fn main() { - 10.dup::(); //~ ERROR does not take type parameters - 10.blah::(); - //~^ ERROR incorrect number of type parameters given for this method: expected 1, found 2 + 10.dup::(); //~ ERROR expected at most 0 type parameters, found 1 type parameter + 10.blah::(); //~ ERROR expected at most 1 type parameter, found 2 type parameters (box 10 as Box).dup(); //~^ ERROR E0038 //~| ERROR E0038 From 7ca378b251329755ca94fa70221c4aa7f7af06ac Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 24 Jun 2017 00:56:25 +0300 Subject: [PATCH 113/123] Prohibit lifetime arguments in path segments with late bound lifetime parameters --- src/librustc/ich/impls_ty.rs | 2 + src/librustc/lint/builtin.rs | 7 ++ src/librustc/ty/mod.rs | 1 + src/librustc_lint/lib.rs | 6 +- src/librustc_typeck/check/method/confirm.rs | 2 +- src/librustc_typeck/check/mod.rs | 81 ++++++++++++------- src/librustc_typeck/collect.rs | 6 +- src/test/compile-fail/E0088.rs | 11 +-- .../method-call-lifetime-args-lint.rs | 76 +++++++++++++++++ .../compile-fail/method-call-lifetime-args.rs | 56 +++++++++++-- src/test/incremental/hashes/inherent_impls.rs | 2 +- src/test/incremental/hashes/trait_defs.rs | 2 +- 12 files changed, 202 insertions(+), 50 deletions(-) create mode 100644 src/test/compile-fail/method-call-lifetime-args-lint.rs diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index a1dd2caf786c2..3e227872848ef 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -346,6 +346,7 @@ impl<'a, 'gcx, 'tcx> HashStable> for ty::Ge // `def_id.index` (`def_id.krate` is the same as the item's). type_param_to_index: _, // Don't hash this has_self, + has_late_bound_regions, } = *self; parent.hash_stable(hcx, hasher); @@ -354,6 +355,7 @@ impl<'a, 'gcx, 'tcx> HashStable> for ty::Ge regions.hash_stable(hcx, hasher); types.hash_stable(hcx, hasher); has_self.hash_stable(hcx, hasher); + has_late_bound_regions.hash_stable(hcx, hasher); } } diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 2d088c4f6d172..3e71ac539a341 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -204,6 +204,12 @@ declare_lint! { "detects parenthesized generic parameters in type and module names" } +declare_lint! { + pub LATE_BOUND_LIFETIME_ARGUMENTS, + Deny, + "detects generic lifetime arguments in path segments with late bound lifetime parameters" +} + declare_lint! { pub DEPRECATED, Warn, @@ -249,6 +255,7 @@ impl LintPass for HardwiredLints { LEGACY_CONSTRUCTOR_VISIBILITY, MISSING_FRAGMENT_SPECIFIER, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, + LATE_BOUND_LIFETIME_ARGUMENTS, DEPRECATED ) } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 5aaba526e265f..1fee0dd98634a 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -719,6 +719,7 @@ pub struct Generics { pub type_param_to_index: BTreeMap, pub has_self: bool, + pub has_late_bound_regions: bool, } impl Generics { diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index a03f12c3dfbca..21dca7f6c61c4 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -235,7 +235,11 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { FutureIncompatibleInfo { id: LintId::of(PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES), reference: "issue #42238 ", - } + }, + FutureIncompatibleInfo { + id: LintId::of(LATE_BOUND_LIFETIME_ARGUMENTS), + reference: "issue #42868 ", + }, ]); // Register renamed and removed lints diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index a647a8bf6f86c..c28ddf876b3cd 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -288,7 +288,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { // variables. let method_generics = self.tcx.generics_of(pick.item.def_id); let mut fn_segment = Some((segment, method_generics)); - self.fcx.check_path_parameter_count(self.span, &mut fn_segment); + self.fcx.check_path_parameter_count(self.span, &mut fn_segment, true); // Create subst for early-bound lifetime parameters, combining // parameters from the type and those from the method. diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index cdbe5e14e9094..917bffbc22f00 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4491,8 +4491,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // variables. If the user provided some types, we may still need // to add defaults. If the user provided *too many* types, that's // a problem. - self.check_path_parameter_count(span, &mut type_segment); - self.check_path_parameter_count(span, &mut fn_segment); + self.check_path_parameter_count(span, &mut type_segment, false); + self.check_path_parameter_count(span, &mut fn_segment, false); let (fn_start, has_self) = match (type_segment, fn_segment) { (_, Some((_, generics))) => { @@ -4618,7 +4618,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// Report errors if the provided parameters are too few or too many. fn check_path_parameter_count(&self, span: Span, - segment: &mut Option<(&hir::PathSegment, &ty::Generics)>) { + segment: &mut Option<(&hir::PathSegment, &ty::Generics)>, + is_method_call: bool) { let (lifetimes, types, infer_types, bindings) = { match segment.map(|(s, _)| &s.parameters) { Some(&hir::AngleBracketedParameters(ref data)) => { @@ -4632,6 +4633,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { None => (&[][..], &[][..], true, &[][..]) } }; + let infer_lifetimes = lifetimes.len() == 0; let count_lifetime_params = |n| { format!("{} lifetime parameter{}", n, if n == 1 { "" } else { "s" }) @@ -4640,32 +4642,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { format!("{} type parameter{}", n, if n == 1 { "" } else { "s" }) }; - // Check provided lifetime parameters. - let lifetime_defs = segment.map_or(&[][..], |(_, generics)| &generics.regions); - if lifetimes.len() > lifetime_defs.len() { - let expected_text = count_lifetime_params(lifetime_defs.len()); - let actual_text = count_lifetime_params(lifetimes.len()); - struct_span_err!(self.tcx.sess, span, E0088, - "too many lifetime parameters provided: \ - expected at most {}, found {}", - expected_text, actual_text) - .span_label(span, format!("expected {}", expected_text)) - .emit(); - } else if lifetimes.len() > 0 && lifetimes.len() < lifetime_defs.len() { - let expected_text = count_lifetime_params(lifetime_defs.len()); - let actual_text = count_lifetime_params(lifetimes.len()); - struct_span_err!(self.tcx.sess, span, E0090, - "too few lifetime parameters provided: \ - expected {}, found {}", - expected_text, actual_text) - .span_label(span, format!("expected {}", expected_text)) - .emit(); - } - - // The case where there is not enough lifetime parameters is not checked, - // because this is not possible - a function never takes lifetime parameters. - // See discussion for Pull Request 36208. - // Check provided type parameters. let type_defs = segment.map_or(&[][..], |(_, generics)| { if generics.parent.is_none() { @@ -4690,7 +4666,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // type parameters, we force instantiate_value_path to // use inference variables instead of the provided types. *segment = None; - } else if !infer_types && types.len() < required_len { + } else if types.len() < required_len && !infer_types { let expected_text = count_type_params(required_len); let actual_text = count_type_params(types.len()); struct_span_err!(self.tcx.sess, span, E0089, @@ -4706,6 +4682,51 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { "unexpected binding of associated item in expression path \ (only allowed in type paths)"); } + + // Check provided lifetime parameters. + let lifetime_defs = segment.map_or(&[][..], |(_, generics)| &generics.regions); + let required_len = lifetime_defs.len(); + + // Prohibit explicit lifetime arguments if late bound lifetime parameters are present. + let has_late_bound_lifetime_defs = + segment.map_or(false, |(_, generics)| generics.has_late_bound_regions); + if has_late_bound_lifetime_defs && !lifetimes.is_empty() { + // Report this as a lint only if no error was reported previously. + if !is_method_call && (lifetimes.len() > lifetime_defs.len() || + lifetimes.len() < required_len && !infer_lifetimes) { + self.tcx.sess.span_err(lifetimes[0].span, + "cannot specify lifetime arguments explicitly \ + if late bound lifetime parameters are present"); + } else { + self.tcx.sess.add_lint(lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS, + lifetimes[0].id, lifetimes[0].span, + format!("cannot specify lifetime arguments explicitly \ + if late bound lifetime parameters are present")); + } + *segment = None; + return; + } + + if lifetimes.len() > lifetime_defs.len() { + let span = lifetimes[lifetime_defs.len()].span; + let expected_text = count_lifetime_params(lifetime_defs.len()); + let actual_text = count_lifetime_params(lifetimes.len()); + struct_span_err!(self.tcx.sess, span, E0088, + "too many lifetime parameters provided: \ + expected at most {}, found {}", + expected_text, actual_text) + .span_label(span, format!("expected {}", expected_text)) + .emit(); + } else if lifetimes.len() < required_len && !infer_lifetimes { + let expected_text = count_lifetime_params(lifetime_defs.len()); + let actual_text = count_lifetime_params(lifetimes.len()); + struct_span_err!(self.tcx.sess, span, E0090, + "too few lifetime parameters provided: \ + expected {}, found {}", + expected_text, actual_text) + .span_label(span, format!("expected {}", expected_text)) + .emit(); + } } fn structurally_resolve_type_or_else(&self, sp: Span, ty: Ty<'tcx>, f: F) diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 002a148c459a3..25707229dbc5a 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -876,11 +876,13 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let has_self = opt_self.is_some(); let mut parent_has_self = false; + let mut parent_has_late_bound_regions = false; let mut own_start = has_self as u32; let (parent_regions, parent_types) = parent_def_id.map_or((0, 0), |def_id| { let generics = tcx.generics_of(def_id); assert_eq!(has_self, false); parent_has_self = generics.has_self; + parent_has_late_bound_regions = generics.has_late_bound_regions; own_start = generics.count() as u32; (generics.parent_regions + generics.regions.len() as u32, generics.parent_types + generics.types.len() as u32) @@ -898,6 +900,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } }).collect::>(); + let has_late_bound_regions = regions.len() != ast_generics.lifetimes.len(); let object_lifetime_defaults = tcx.named_region_map.object_lifetime_defaults.get(&node_id); @@ -959,7 +962,8 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, regions: regions, types: types, type_param_to_index: type_param_to_index, - has_self: has_self || parent_has_self + has_self: has_self || parent_has_self, + has_late_bound_regions: has_late_bound_regions || parent_has_late_bound_regions, }) } diff --git a/src/test/compile-fail/E0088.rs b/src/test/compile-fail/E0088.rs index de188677a1121..db84a4edc487c 100644 --- a/src/test/compile-fail/E0088.rs +++ b/src/test/compile-fail/E0088.rs @@ -9,14 +9,9 @@ // except according to those terms. fn f() {} -fn g<'a>() {} +fn g<'a>() -> &'a u8 { loop {} } fn main() { - f::<'static>(); - //~^ ERROR expected at most 0 lifetime parameters, found 1 lifetime parameter [E0088] - //~| NOTE expected 0 lifetime parameters - - g::<'static, 'static>(); - //~^ ERROR expected at most 0 lifetime parameters, found 2 lifetime parameters [E0088] - //~| NOTE expected 0 lifetime parameters + f::<'static>(); //~ ERROR E0088 + g::<'static, 'static>(); //~ ERROR E0088 } diff --git a/src/test/compile-fail/method-call-lifetime-args-lint.rs b/src/test/compile-fail/method-call-lifetime-args-lint.rs new file mode 100644 index 0000000000000..28f1035cad7e0 --- /dev/null +++ b/src/test/compile-fail/method-call-lifetime-args-lint.rs @@ -0,0 +1,76 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused)] + +struct S; + +impl S { + fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + fn late_implicit(self, _: &u8, _: &u8) {} + fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } +} + +fn method_call() { + S.late(&0, &0); // OK + S.late::<'static>(&0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late::<'static, 'static>(&0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late::<'static, 'static, 'static>(&0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late_early(&0); // OK + S.late_early::<'static>(&0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late_early::<'static, 'static>(&0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late_early::<'static, 'static, 'static>(&0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + + S.late_implicit(&0, &0); // OK + // S.late_implicit::<'static>(&0, &0); + //FIXME ERROR cannot specify lifetime arguments explicitly + //FIXME WARN this was previously accepted + // S.late_implicit::<'static, 'static>(&0, &0); + //FIXME ERROR cannot specify lifetime arguments explicitly + //FIXME WARN this was previously accepted + // S.late_implicit::<'static, 'static, 'static>(&0, &0); + //FIXME ERROR cannot specify lifetime arguments explicitly + //FIXME WARN this was previously accepted + S.late_implicit_early(&0); // OK + S.late_implicit_early::<'static>(&0); + //FIXME ERROR cannot specify lifetime arguments explicitly + //FIXME WARN this was previously accepted + // S.late_implicit_early::<'static, 'static>(&0); + //FIXME ERROR cannot specify lifetime arguments explicitly + //FIXME WARN this was previously accepted + // S.late_implicit_early::<'static, 'static, 'static>(&0); + //FIXME ERROR cannot specify lifetime arguments explicitly + //FIXME WARN this was previously accepted +} + +fn ufcs() { + S::late_early::<'static>(S, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + + S::late_implicit_early::<'static>(S, &0); + //FIXME ERROR cannot specify lifetime arguments explicitly + //FIXME WARN this was previously accepted +} + +fn main() {} diff --git a/src/test/compile-fail/method-call-lifetime-args.rs b/src/test/compile-fail/method-call-lifetime-args.rs index 75c469ecd3268..00c03c3c8599a 100644 --- a/src/test/compile-fail/method-call-lifetime-args.rs +++ b/src/test/compile-fail/method-call-lifetime-args.rs @@ -12,16 +12,14 @@ struct S; impl S { fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + fn late_implicit(self, _: &u8, _: &u8) {} fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} } - fn life_and_type<'a, T>(&self) -> &'a T { loop {} } + fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + fn life_and_type<'a, T>(self) -> &'a T { loop {} } } -fn main() { - S.late(&0, &0); // OK - S.late::<'static>(&0, &0); - //~^ ERROR expected at most 0 lifetime parameters, found 1 lifetime parameter - S.late::<'static, 'static, 'static>(&0, &0); - //~^ ERROR expected at most 0 lifetime parameters, found 3 lifetime parameter +fn method_call() { S.early(); // OK S.early::<'static>(); //~^ ERROR expected 2 lifetime parameters, found 1 lifetime parameter @@ -31,3 +29,47 @@ fn main() { S.life_and_type::(); S.life_and_type::<'static, u8>(); } + +fn ufcs() { + S::late(S, &0, &0); // OK + S::late::<'static>(S, &0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late::<'static, 'static>(S, &0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late::<'static, 'static, 'static>(S, &0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_early(S, &0); // OK + S::late_early::<'static, 'static>(S, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_early::<'static, 'static, 'static>(S, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + + S::late_implicit(S, &0, &0); // OK + S::late_implicit::<'static>(S, &0, &0); + //~^ ERROR expected at most 0 lifetime parameters, found 1 lifetime parameter + //FIXME ERROR cannot specify lifetime arguments explicitly + S::late_implicit::<'static, 'static>(S, &0, &0); + //~^ ERROR expected at most 0 lifetime parameters, found 2 lifetime parameters + //FIXME ERROR cannot specify lifetime arguments explicitly + S::late_implicit::<'static, 'static, 'static>(S, &0, &0); + //~^ ERROR expected at most 0 lifetime parameters, found 3 lifetime parameters + //FIXME ERROR cannot specify lifetime arguments explicitly + S::late_implicit_early(S, &0); // OK + S::late_implicit_early::<'static, 'static>(S, &0); + //~^ ERROR expected at most 1 lifetime parameter, found 2 lifetime parameters + //FIXME ERROR cannot specify lifetime arguments explicitly + S::late_implicit_early::<'static, 'static, 'static>(S, &0); + //~^ ERROR expected at most 1 lifetime parameter, found 3 lifetime parameters + //FIXME ERROR cannot specify lifetime arguments explicitly + + S::early(S); // OK + S::early::<'static>(S); + //~^ ERROR expected 2 lifetime parameters, found 1 lifetime parameter + S::early::<'static, 'static, 'static>(S); + //~^ ERROR expected at most 2 lifetime parameters, found 3 lifetime parameters + let _: &u8 = S::life_and_type::<'static>(S); + S::life_and_type::(S); + S::life_and_type::<'static, u8>(S); +} + +fn main() {} diff --git a/src/test/incremental/hashes/inherent_impls.rs b/src/test/incremental/hashes/inherent_impls.rs index 899aefa24a033..370e07ba6c9e9 100644 --- a/src/test/incremental/hashes/inherent_impls.rs +++ b/src/test/incremental/hashes/inherent_impls.rs @@ -369,7 +369,7 @@ impl Foo { impl Foo { #[rustc_dirty(label="Hir", cfg="cfail2")] #[rustc_clean(label="Hir", cfg="cfail3")] - #[rustc_metadata_clean(cfg="cfail2")] // Apparently unused lifetimes don't show up in the type. + #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] pub fn add_lifetime_parameter_to_method<'a>(&self) { } } diff --git a/src/test/incremental/hashes/trait_defs.rs b/src/test/incremental/hashes/trait_defs.rs index e47556a790b62..44950ee8a601f 100644 --- a/src/test/incremental/hashes/trait_defs.rs +++ b/src/test/incremental/hashes/trait_defs.rs @@ -448,7 +448,7 @@ trait TraitAddLifetimeParameterToMethod { trait TraitAddLifetimeParameterToMethod { #[rustc_dirty(label="Hir", cfg="cfail2")] #[rustc_clean(label="Hir", cfg="cfail3")] - #[rustc_metadata_clean(cfg="cfail2")] // Unused lifetimes don't seem to show up in type? + #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] fn method<'a>(); } From e40cedb3932060abf4496254959e9dd307eb6a2f Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 24 Jun 2017 23:30:05 +0300 Subject: [PATCH 114/123] Detect implicitly defined late bound lifetime parameters as well --- src/librustc_typeck/collect.rs | 91 ++++++++++++++++++- .../compile-fail/constructor-lifetime-args.rs | 36 ++++++++ .../method-call-lifetime-args-lint.rs | 38 ++++---- .../compile-fail/method-call-lifetime-args.rs | 38 ++++++-- src/test/incremental/hashes/inherent_impls.rs | 2 +- 5 files changed, 171 insertions(+), 34 deletions(-) create mode 100644 src/test/compile-fail/constructor-lifetime-args.rs diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 25707229dbc5a..32ccfc511fc4b 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -772,6 +772,92 @@ fn trait_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx.alloc_trait_def(def) } +fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, + node: hir_map::Node<'tcx>) + -> bool { + struct LateBoundRegionsDetector<'a, 'tcx: 'a> { + tcx: TyCtxt<'a, 'tcx, 'tcx>, + binder_depth: usize, + has_late_bound_regions: bool, + } + + impl<'a, 'tcx> Visitor<'tcx> for LateBoundRegionsDetector<'a, 'tcx> { + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + NestedVisitorMap::None + } + + fn visit_ty(&mut self, ty: &'tcx hir::Ty) { + if self.has_late_bound_regions { return } + match ty.node { + hir::TyBareFn(..) => { + self.binder_depth += 1; + intravisit::walk_ty(self, ty); + self.binder_depth -= 1; + } + _ => intravisit::walk_ty(self, ty) + } + } + + fn visit_poly_trait_ref(&mut self, + tr: &'tcx hir::PolyTraitRef, + m: hir::TraitBoundModifier) { + if self.has_late_bound_regions { return } + self.binder_depth += 1; + intravisit::walk_poly_trait_ref(self, tr, m); + self.binder_depth -= 1; + } + + fn visit_lifetime(&mut self, lt: &'tcx hir::Lifetime) { + if self.has_late_bound_regions { return } + + match self.tcx.named_region_map.defs.get(<.id).cloned() { + Some(rl::Region::Static) | Some(rl::Region::EarlyBound(..)) => {} + _ => self.has_late_bound_regions = true + } + } + } + + fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, + generics: &'tcx hir::Generics, + decl: &'tcx hir::FnDecl) + -> bool { + let mut visitor = LateBoundRegionsDetector { + tcx, binder_depth: 0, has_late_bound_regions: false + }; + for lifetime in &generics.lifetimes { + if tcx.named_region_map.late_bound.contains(&lifetime.lifetime.id) { + return true; + } + } + visitor.visit_fn_decl(decl); + visitor.has_late_bound_regions + } + + match node { + hir_map::NodeTraitItem(item) => match item.node { + hir::TraitItemKind::Method(ref sig, _) => + has_late_bound_regions(tcx, &sig.generics, &sig.decl), + _ => false, + }, + hir_map::NodeImplItem(item) => match item.node { + hir::ImplItemKind::Method(ref sig, _) => + has_late_bound_regions(tcx, &sig.generics, &sig.decl), + _ => false, + }, + hir_map::NodeForeignItem(item) => match item.node { + hir::ForeignItemFn(ref fn_decl, _, ref generics) => + has_late_bound_regions(tcx, generics, fn_decl), + _ => false, + }, + hir_map::NodeItem(item) => match item.node { + hir::ItemFn(ref fn_decl, .., ref generics, _) => + has_late_bound_regions(tcx, generics, fn_decl), + _ => false, + }, + _ => false + } +} + fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Generics { @@ -876,13 +962,11 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let has_self = opt_self.is_some(); let mut parent_has_self = false; - let mut parent_has_late_bound_regions = false; let mut own_start = has_self as u32; let (parent_regions, parent_types) = parent_def_id.map_or((0, 0), |def_id| { let generics = tcx.generics_of(def_id); assert_eq!(has_self, false); parent_has_self = generics.has_self; - parent_has_late_bound_regions = generics.has_late_bound_regions; own_start = generics.count() as u32; (generics.parent_regions + generics.regions.len() as u32, generics.parent_types + generics.types.len() as u32) @@ -900,7 +984,6 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } }).collect::>(); - let has_late_bound_regions = regions.len() != ast_generics.lifetimes.len(); let object_lifetime_defaults = tcx.named_region_map.object_lifetime_defaults.get(&node_id); @@ -963,7 +1046,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, types: types, type_param_to_index: type_param_to_index, has_self: has_self || parent_has_self, - has_late_bound_regions: has_late_bound_regions || parent_has_late_bound_regions, + has_late_bound_regions: has_late_bound_regions(tcx, node), }) } diff --git a/src/test/compile-fail/constructor-lifetime-args.rs b/src/test/compile-fail/constructor-lifetime-args.rs new file mode 100644 index 0000000000000..50db9707355f4 --- /dev/null +++ b/src/test/compile-fail/constructor-lifetime-args.rs @@ -0,0 +1,36 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// All lifetime parameters in struct constructors are currently considered early bound, +// i.e. `S::` is interpreted kinda like an associated item `S::::ctor`. +// This behavior is a bit weird, because if equivalent constructor were written manually +// it would get late bound lifetime parameters. +// Variant constructors behave in the same way, lifetime parameters are considered +// belonging to the enum and being early bound. +// https://github.com/rust-lang/rust/issues/30904 + +struct S<'a, 'b>(&'a u8, &'b u8); +enum E<'a, 'b> { + V(&'a u8), + U(&'b u8), +} + +fn main() { + S(&0, &0); // OK + S::<'static>(&0, &0); + //~^ ERROR expected 2 lifetime parameters, found 1 lifetime parameter + S::<'static, 'static, 'static>(&0, &0); + //~^ ERROR expected at most 2 lifetime parameters, found 3 lifetime parameters + E::V(&0); // OK + E::V::<'static>(&0); + //~^ ERROR expected 2 lifetime parameters, found 1 lifetime parameter + E::V::<'static, 'static, 'static>(&0); + //~^ ERROR expected at most 2 lifetime parameters, found 3 lifetime parameters +} diff --git a/src/test/compile-fail/method-call-lifetime-args-lint.rs b/src/test/compile-fail/method-call-lifetime-args-lint.rs index 28f1035cad7e0..9bf34de92fe8d 100644 --- a/src/test/compile-fail/method-call-lifetime-args-lint.rs +++ b/src/test/compile-fail/method-call-lifetime-args-lint.rs @@ -42,25 +42,25 @@ fn method_call() { //~| WARN this was previously accepted S.late_implicit(&0, &0); // OK - // S.late_implicit::<'static>(&0, &0); - //FIXME ERROR cannot specify lifetime arguments explicitly - //FIXME WARN this was previously accepted - // S.late_implicit::<'static, 'static>(&0, &0); - //FIXME ERROR cannot specify lifetime arguments explicitly - //FIXME WARN this was previously accepted - // S.late_implicit::<'static, 'static, 'static>(&0, &0); - //FIXME ERROR cannot specify lifetime arguments explicitly - //FIXME WARN this was previously accepted + S.late_implicit::<'static>(&0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late_implicit::<'static, 'static>(&0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late_implicit::<'static, 'static, 'static>(&0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted S.late_implicit_early(&0); // OK S.late_implicit_early::<'static>(&0); - //FIXME ERROR cannot specify lifetime arguments explicitly - //FIXME WARN this was previously accepted - // S.late_implicit_early::<'static, 'static>(&0); - //FIXME ERROR cannot specify lifetime arguments explicitly - //FIXME WARN this was previously accepted - // S.late_implicit_early::<'static, 'static, 'static>(&0); - //FIXME ERROR cannot specify lifetime arguments explicitly - //FIXME WARN this was previously accepted + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late_implicit_early::<'static, 'static>(&0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late_implicit_early::<'static, 'static, 'static>(&0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted } fn ufcs() { @@ -69,8 +69,8 @@ fn ufcs() { //~| WARN this was previously accepted S::late_implicit_early::<'static>(S, &0); - //FIXME ERROR cannot specify lifetime arguments explicitly - //FIXME WARN this was previously accepted + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted } fn main() {} diff --git a/src/test/compile-fail/method-call-lifetime-args.rs b/src/test/compile-fail/method-call-lifetime-args.rs index 00c03c3c8599a..c29701804a741 100644 --- a/src/test/compile-fail/method-call-lifetime-args.rs +++ b/src/test/compile-fail/method-call-lifetime-args.rs @@ -16,7 +16,17 @@ impl S { fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} } fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} } + fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} } fn life_and_type<'a, T>(self) -> &'a T { loop {} } + + // 'late lifetimes here belong to nested types not to the tested functions. + fn early_tricky_explicit<'a>(_: for<'late> fn(&'late u8), + _: Box Fn(&'late u8)>) + -> &'a u8 { loop {} } + fn early_tricky_implicit<'a>(_: fn(&u8), + _: Box) + -> &'a u8 { loop {} } } fn method_call() { @@ -46,21 +56,26 @@ fn ufcs() { S::late_implicit(S, &0, &0); // OK S::late_implicit::<'static>(S, &0, &0); - //~^ ERROR expected at most 0 lifetime parameters, found 1 lifetime parameter - //FIXME ERROR cannot specify lifetime arguments explicitly + //~^ ERROR cannot specify lifetime arguments explicitly S::late_implicit::<'static, 'static>(S, &0, &0); - //~^ ERROR expected at most 0 lifetime parameters, found 2 lifetime parameters - //FIXME ERROR cannot specify lifetime arguments explicitly + //~^ ERROR cannot specify lifetime arguments explicitly S::late_implicit::<'static, 'static, 'static>(S, &0, &0); - //~^ ERROR expected at most 0 lifetime parameters, found 3 lifetime parameters - //FIXME ERROR cannot specify lifetime arguments explicitly + //~^ ERROR cannot specify lifetime arguments explicitly S::late_implicit_early(S, &0); // OK S::late_implicit_early::<'static, 'static>(S, &0); - //~^ ERROR expected at most 1 lifetime parameter, found 2 lifetime parameters - //FIXME ERROR cannot specify lifetime arguments explicitly + //~^ ERROR cannot specify lifetime arguments explicitly S::late_implicit_early::<'static, 'static, 'static>(S, &0); - //~^ ERROR expected at most 1 lifetime parameter, found 3 lifetime parameters - //FIXME ERROR cannot specify lifetime arguments explicitly + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_implicit_self_early(&S); // OK + S::late_implicit_self_early::<'static, 'static>(&S); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_implicit_self_early::<'static, 'static, 'static>(&S); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_unused_early(S); // OK + S::late_unused_early::<'static, 'static>(S); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_unused_early::<'static, 'static, 'static>(S); + //~^ ERROR cannot specify lifetime arguments explicitly S::early(S); // OK S::early::<'static>(S); @@ -70,6 +85,9 @@ fn ufcs() { let _: &u8 = S::life_and_type::<'static>(S); S::life_and_type::(S); S::life_and_type::<'static, u8>(S); + + S::early_tricky_explicit::<'static>(loop {}, loop {}); // OK + S::early_tricky_implicit::<'static>(loop {}, loop {}); // OK } fn main() {} diff --git a/src/test/incremental/hashes/inherent_impls.rs b/src/test/incremental/hashes/inherent_impls.rs index 370e07ba6c9e9..daddc0c9f5459 100644 --- a/src/test/incremental/hashes/inherent_impls.rs +++ b/src/test/incremental/hashes/inherent_impls.rs @@ -369,7 +369,7 @@ impl Foo { impl Foo { #[rustc_dirty(label="Hir", cfg="cfail2")] #[rustc_clean(label="Hir", cfg="cfail3")] - #[rustc_metadata_dirty(cfg="cfail2")] + #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] pub fn add_lifetime_parameter_to_method<'a>(&self) { } } From 46f427bee9ac60d4ce31baa95430223d5ec110b3 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Tue, 11 Jul 2017 23:12:06 +0300 Subject: [PATCH 115/123] Fix incorrect subst index Fix treatment of lifetimes defined in nested types during detection of late bound regions in signatures. Do not replace substs with inference variables when "cannot specify lifetime arguments explicitly..." is reported as a lint. --- src/librustc_typeck/check/method/confirm.rs | 17 +++++++------ src/librustc_typeck/check/mod.rs | 2 +- src/librustc_typeck/collect.rs | 9 ++++--- .../method-call-lifetime-args-lint.rs | 20 +++++++++++++++ .../method-call-lifetime-args-subst-index.rs | 25 +++++++++++++++++++ .../compile-fail/method-call-lifetime-args.rs | 11 -------- 6 files changed, 62 insertions(+), 22 deletions(-) create mode 100644 src/test/compile-fail/method-call-lifetime-args-subst-index.rs diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index c28ddf876b3cd..ad4ee5a9d6dcf 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -281,7 +281,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { fn instantiate_method_substs(&mut self, pick: &probe::Pick<'tcx>, segment: &hir::PathSegment, - substs: &Substs<'tcx>) + parent_substs: &Substs<'tcx>) -> &'tcx Substs<'tcx> { // Determine the values for the generic parameters of the method. // If they were not explicitly supplied, just construct fresh @@ -296,20 +296,23 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { hir::AngleBracketedParameters(ref data) => (&data.types, &data.lifetimes), _ => bug!("unexpected generic arguments: {:?}", segment.parameters), }; + assert_eq!(method_generics.parent_count(), parent_substs.len()); Substs::for_item(self.tcx, pick.item.def_id, |def, _| { let i = def.index as usize; - if i < substs.len() { - substs.region_at(i) - } else if let Some(lifetime) = supplied_lifetimes.get(i - substs.len()) { + if i < parent_substs.len() { + parent_substs.region_at(i) + } else if let Some(lifetime) = + supplied_lifetimes.get(i - parent_substs.len()) { AstConv::ast_region_to_region(self.fcx, lifetime, Some(def)) } else { self.region_var_for_def(self.span, def) } }, |def, cur_substs| { let i = def.index as usize; - if i < substs.len() { - substs.type_at(i) - } else if let Some(ast_ty) = supplied_types.get(i - substs.len()) { + if i < parent_substs.len() { + parent_substs.type_at(i) + } else if let Some(ast_ty) = + supplied_types.get(i - parent_substs.len() - method_generics.regions.len()) { self.to_ty(ast_ty) } else { self.type_var_for_def(self.span, def, cur_substs) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 917bffbc22f00..af11cacb247b6 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4697,13 +4697,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.tcx.sess.span_err(lifetimes[0].span, "cannot specify lifetime arguments explicitly \ if late bound lifetime parameters are present"); + *segment = None; } else { self.tcx.sess.add_lint(lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS, lifetimes[0].id, lifetimes[0].span, format!("cannot specify lifetime arguments explicitly \ if late bound lifetime parameters are present")); } - *segment = None; return; } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 32ccfc511fc4b..72bd084330dd3 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -777,7 +777,7 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, -> bool { struct LateBoundRegionsDetector<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, - binder_depth: usize, + binder_depth: u32, has_late_bound_regions: bool, } @@ -812,7 +812,10 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, match self.tcx.named_region_map.defs.get(<.id).cloned() { Some(rl::Region::Static) | Some(rl::Region::EarlyBound(..)) => {} - _ => self.has_late_bound_regions = true + Some(rl::Region::LateBound(debruijn, _)) | + Some(rl::Region::LateBoundAnon(debruijn, _)) + if debruijn.depth < self.binder_depth => {} + _ => self.has_late_bound_regions = true, } } } @@ -822,7 +825,7 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, decl: &'tcx hir::FnDecl) -> bool { let mut visitor = LateBoundRegionsDetector { - tcx, binder_depth: 0, has_late_bound_regions: false + tcx, binder_depth: 1, has_late_bound_regions: false }; for lifetime in &generics.lifetimes { if tcx.named_region_map.late_bound.contains(&lifetime.lifetime.id) { diff --git a/src/test/compile-fail/method-call-lifetime-args-lint.rs b/src/test/compile-fail/method-call-lifetime-args-lint.rs index 9bf34de92fe8d..b206924e538f3 100644 --- a/src/test/compile-fail/method-call-lifetime-args-lint.rs +++ b/src/test/compile-fail/method-call-lifetime-args-lint.rs @@ -17,6 +17,14 @@ impl S { fn late_implicit(self, _: &u8, _: &u8) {} fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + + // 'late lifetimes here belong to nested types not to the tested functions. + fn early_tricky_explicit<'a>(_: for<'late> fn(&'late u8), + _: Box Fn(&'late u8)>) + -> &'a u8 { loop {} } + fn early_tricky_implicit<'a>(_: fn(&u8), + _: Box) + -> &'a u8 { loop {} } } fn method_call() { @@ -61,6 +69,9 @@ fn method_call() { S.late_implicit_early::<'static, 'static, 'static>(&0); //~^ ERROR cannot specify lifetime arguments explicitly //~| WARN this was previously accepted + + S::early_tricky_explicit::<'static>(loop {}, loop {}); // OK + S::early_tricky_implicit::<'static>(loop {}, loop {}); // OK } fn ufcs() { @@ -73,4 +84,13 @@ fn ufcs() { //~| WARN this was previously accepted } +fn lint_not_inference_error() { + fn f<'early, 'late, T: 'early>() {} + + // Make sure `u8` is substituted and not replaced with an inference variable + f::<'static, u8>; + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted +} + fn main() {} diff --git a/src/test/compile-fail/method-call-lifetime-args-subst-index.rs b/src/test/compile-fail/method-call-lifetime-args-subst-index.rs new file mode 100644 index 0000000000000..a9505e4f936a1 --- /dev/null +++ b/src/test/compile-fail/method-call-lifetime-args-subst-index.rs @@ -0,0 +1,25 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![allow(unused)] + +struct S; + +impl S { + fn early_and_type<'a, T>(self) -> &'a T { loop {} } +} + +fn test() { + S.early_and_type::(); +} + +#[rustc_error] +fn main() {} //~ ERROR compilation successful diff --git a/src/test/compile-fail/method-call-lifetime-args.rs b/src/test/compile-fail/method-call-lifetime-args.rs index c29701804a741..f0a87c7470386 100644 --- a/src/test/compile-fail/method-call-lifetime-args.rs +++ b/src/test/compile-fail/method-call-lifetime-args.rs @@ -19,14 +19,6 @@ impl S { fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} } fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} } fn life_and_type<'a, T>(self) -> &'a T { loop {} } - - // 'late lifetimes here belong to nested types not to the tested functions. - fn early_tricky_explicit<'a>(_: for<'late> fn(&'late u8), - _: Box Fn(&'late u8)>) - -> &'a u8 { loop {} } - fn early_tricky_implicit<'a>(_: fn(&u8), - _: Box) - -> &'a u8 { loop {} } } fn method_call() { @@ -85,9 +77,6 @@ fn ufcs() { let _: &u8 = S::life_and_type::<'static>(S); S::life_and_type::(S); S::life_and_type::<'static, u8>(S); - - S::early_tricky_explicit::<'static>(loop {}, loop {}); // OK - S::early_tricky_implicit::<'static>(loop {}, loop {}); // OK } fn main() {} From 36be634ce712816570f4c9651ffbf7619b7460b8 Mon Sep 17 00:00:00 2001 From: Matthew Hammer Date: Mon, 17 Jul 2017 15:25:55 -0600 Subject: [PATCH 116/123] rustc waits for profile-queries dump to complete --- src/librustc/util/common.rs | 2 +- src/librustc_driver/driver.rs | 5 ++++- src/librustc_driver/profile/mod.rs | 20 +++++++++++++------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 7fb43485270b6..fcd0b4d31e135 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -49,7 +49,7 @@ pub enum ProfileQueriesMsg { /// query is satisfied by a provider terminating with a value ProviderEnd, /// dump a record of the queries to the given path - Dump(String), + Dump(String, Sender<()>), /// stop the profilequeriesmsg service Halt } diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 23b3a4d057c36..532977e4470e8 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -1076,7 +1076,10 @@ pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, translation.link.crate_hash)); if tcx.sess.opts.debugging_opts.profile_queries { - profq_msg(ProfileQueriesMsg::Dump("profile_queries".to_string())) + use std::sync::mpsc::{channel}; + let (tx, rx) = channel(); + profq_msg(ProfileQueriesMsg::Dump("profile_queries".to_string(), tx)); + let _ = rx.recv().unwrap(); } translation diff --git a/src/librustc_driver/profile/mod.rs b/src/librustc_driver/profile/mod.rs index b54d1798c22a3..72a94e4f27b54 100644 --- a/src/librustc_driver/profile/mod.rs +++ b/src/librustc_driver/profile/mod.rs @@ -33,10 +33,19 @@ fn profile_queries_thread(r:Receiver) { // Meta-level versus _actual_ queries messages match msg { ProfileQueriesMsg::Halt => return, - ProfileQueriesMsg::Dump(path) => { + ProfileQueriesMsg::Dump(path, ack) => { assert!(stack.len() == 0); assert!(frame.parse_st == trace::ParseState::NoQuery); - { // write HTML file + { + // write log + if false { + let mut queries_file = File::create(format!("{}.log.txt", path)).unwrap(); + for q in queries.iter() { + writeln!(&mut queries_file, "{:?}", q).unwrap() + }; + } + + // write HTML file, and counts file let html_path = format!("{}.html", path); let mut html_file = File::create(&html_path).unwrap(); @@ -55,10 +64,7 @@ fn profile_queries_thread(r:Receiver) { trace::write_traces(&mut html_file, &mut counts_file, &frame.traces); write!(html_file, "\n\n").unwrap(); - let mut queries_file = File::create(format!("{}.log.txt", path)).unwrap(); - for q in queries.iter() { - writeln!(&mut queries_file, "{:?}", q).unwrap() - }; + ack.send(()).unwrap(); } continue } @@ -67,7 +73,7 @@ fn profile_queries_thread(r:Receiver) { queries.push(msg.clone()); match (frame.parse_st.clone(), msg) { (_,ProfileQueriesMsg::Halt) => unreachable!(), - (_,ProfileQueriesMsg::Dump(_)) => unreachable!(), + (_,ProfileQueriesMsg::Dump(_,_)) => unreachable!(), // Parse State: NoQuery (ParseState::NoQuery, From 9153bb32b03c24e790e15b5cc01106065a1ed0fa Mon Sep 17 00:00:00 2001 From: Matthew Hammer Date: Mon, 17 Jul 2017 15:29:09 -0600 Subject: [PATCH 117/123] add minimal doc --- src/librustc_driver/profile/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/librustc_driver/profile/mod.rs b/src/librustc_driver/profile/mod.rs index 72a94e4f27b54..4c503928b8611 100644 --- a/src/librustc_driver/profile/mod.rs +++ b/src/librustc_driver/profile/mod.rs @@ -4,6 +4,7 @@ use std::io::{Write}; pub mod trace; +// begin a thread, if not already running pub fn begin() { use std::thread; use std::sync::mpsc::{channel}; @@ -13,6 +14,7 @@ pub fn begin() { } } +// profiling thread; retains state (in local variables) and dump traces, upon request. fn profile_queries_thread(r:Receiver) { use self::trace::*; use std::fs::File; From f9fabc1d36b3eeb18d6a2c111476620eb5c6df47 Mon Sep 17 00:00:00 2001 From: Matthew Hammer Date: Mon, 17 Jul 2017 15:32:35 -0600 Subject: [PATCH 118/123] tidy --- src/librustc/ty/maps.rs | 2 +- src/librustc/util/common.rs | 6 +++--- src/librustc_driver/profile/mod.rs | 10 ++++++++++ src/librustc_driver/profile/trace.rs | 10 ++++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index 0f7fb4db91ba9..1c5f6b57e774e 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -476,7 +476,7 @@ macro_rules! define_maps { key, span); - profq_msg!(tcx, + profq_msg!(tcx, ProfileQueriesMsg::QueryBegin(span.clone(), QueryMsg::$name(format!("{:?}", key)))); diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index fcd0b4d31e135..17e448f787e50 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -61,13 +61,13 @@ pub fn profq_msg(msg: ProfileQueriesMsg) { s.send(msg).unwrap() } else { panic!("no channel on which to send profq_msg: {:?}", msg) - } + } }) } pub fn profq_set_chan(s: Sender) -> bool { - PROFQ_CHAN.with(|chan|{ - let is_none = + PROFQ_CHAN.with(|chan|{ + let is_none = if let None = chan.borrow().as_ref() { true } else { false } diff --git a/src/librustc_driver/profile/mod.rs b/src/librustc_driver/profile/mod.rs index 4c503928b8611..fce279e5182a8 100644 --- a/src/librustc_driver/profile/mod.rs +++ b/src/librustc_driver/profile/mod.rs @@ -1,3 +1,13 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + use rustc::util::common::{ProfileQueriesMsg,profq_set_chan}; use std::sync::mpsc::{Receiver}; use std::io::{Write}; diff --git a/src/librustc_driver/profile/trace.rs b/src/librustc_driver/profile/trace.rs index b8b43a51f6322..9d5dde3188f37 100644 --- a/src/librustc_driver/profile/trace.rs +++ b/src/librustc_driver/profile/trace.rs @@ -1,3 +1,13 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + use super::*; use syntax_pos::Span; use rustc::ty::maps::QueryMsg; From 39114f916905b16b414f51031426309b63f856a9 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Tue, 18 Jul 2017 00:33:44 +0300 Subject: [PATCH 119/123] Make `late_bound_lifetime_arguments` lint warn-by-default --- src/librustc/lint/builtin.rs | 2 +- src/test/compile-fail/method-call-lifetime-args-lint.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 3e71ac539a341..cbe642a9a76a6 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -206,7 +206,7 @@ declare_lint! { declare_lint! { pub LATE_BOUND_LIFETIME_ARGUMENTS, - Deny, + Warn, "detects generic lifetime arguments in path segments with late bound lifetime parameters" } diff --git a/src/test/compile-fail/method-call-lifetime-args-lint.rs b/src/test/compile-fail/method-call-lifetime-args-lint.rs index b206924e538f3..b2a94e0af420d 100644 --- a/src/test/compile-fail/method-call-lifetime-args-lint.rs +++ b/src/test/compile-fail/method-call-lifetime-args-lint.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![deny(late_bound_lifetime_arguments)] #![allow(unused)] struct S; From c843661d9a30ca23a6f7f36ad2121c9b03b95d60 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 17 Jul 2017 10:55:27 -0700 Subject: [PATCH 120/123] travis: Make a few `curl` invocations more resilient Use the `-f` flag to indicate that, for example, a 500 response code is to be considered a failure, triggering the normal retry logic. Also ignore errors where we check the date from google.com, as a failure there shouldn't fail the build. --- .travis.yml | 10 +++++----- src/ci/docker/scripts/android-ndk.sh | 2 +- src/ci/docker/scripts/android-sdk.sh | 2 +- src/ci/docker/scripts/crosstool-ng.sh | 2 +- src/ci/docker/scripts/dumb-init.sh | 2 +- src/ci/docker/scripts/emscripten-wasm.sh | 6 +++--- src/ci/docker/scripts/emscripten.sh | 4 ++-- src/ci/docker/scripts/make3.sh | 2 +- src/ci/docker/scripts/sccache.sh | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index d351bea477722..eb8db13c0bb7f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,9 +64,9 @@ matrix: os: osx osx_image: xcode8.2 install: &osx_install_sccache > - travis_retry curl -o /usr/local/bin/sccache https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-apple-darwin && + travis_retry curl -fo /usr/local/bin/sccache https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-apple-darwin && chmod +x /usr/local/bin/sccache && - travis_retry curl -o /usr/local/bin/stamp https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-17-stamp-x86_64-apple-darwin && + travis_retry curl -fo /usr/local/bin/stamp https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-17-stamp-x86_64-apple-darwin && chmod +x /usr/local/bin/stamp - env: > RUST_CHECK_TARGET=check @@ -144,7 +144,7 @@ env: # Note that this is overridden on OSX builders install: > - travis_retry curl -o $HOME/stamp https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-17-stamp-x86_64-unknown-linux-musl && + travis_retry curl -fo $HOME/stamp https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-17-stamp-x86_64-unknown-linux-musl && chmod +x $HOME/stamp && export PATH=$PATH:$HOME @@ -183,10 +183,10 @@ before_script: # clock drift. Timezones don't matter since relative deltas give all the necessary info. script: - > - date && curl -s --head https://google.com | grep ^Date: | sed 's/Date: //g' + date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true) - stamp sh -x -c "$RUN_SCRIPT" - > - date && curl -s --head https://google.com | grep ^Date: | sed 's/Date: //g' + date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true) after_success: - > diff --git a/src/ci/docker/scripts/android-ndk.sh b/src/ci/docker/scripts/android-ndk.sh index c3d83c087e52f..7fc2ebafea8c2 100644 --- a/src/ci/docker/scripts/android-ndk.sh +++ b/src/ci/docker/scripts/android-ndk.sh @@ -15,7 +15,7 @@ URL=https://dl.google.com/android/repository download_ndk() { mkdir -p /android/ndk cd /android/ndk - curl -O $URL/$1 + curl -sO $URL/$1 unzip -q $1 rm $1 mv android-ndk-* ndk diff --git a/src/ci/docker/scripts/android-sdk.sh b/src/ci/docker/scripts/android-sdk.sh index 7d8110efedec9..90257dc411ea8 100644 --- a/src/ci/docker/scripts/android-sdk.sh +++ b/src/ci/docker/scripts/android-sdk.sh @@ -15,7 +15,7 @@ URL=https://dl.google.com/android/repository download_sdk() { mkdir -p /android/sdk cd /android/sdk - curl -O $URL/$1 + curl -sO $URL/$1 unzip -q $1 rm -rf $1 } diff --git a/src/ci/docker/scripts/crosstool-ng.sh b/src/ci/docker/scripts/crosstool-ng.sh index 8b2747cf21309..53ad0f8a2ebc5 100644 --- a/src/ci/docker/scripts/crosstool-ng.sh +++ b/src/ci/docker/scripts/crosstool-ng.sh @@ -11,7 +11,7 @@ set -ex url="http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.22.0.tar.bz2" -curl $url | tar xjf - +curl -s $url | tar xjf - cd crosstool-ng ./configure --prefix=/usr/local make -j$(nproc) diff --git a/src/ci/docker/scripts/dumb-init.sh b/src/ci/docker/scripts/dumb-init.sh index 839c390799278..616288f572b11 100644 --- a/src/ci/docker/scripts/dumb-init.sh +++ b/src/ci/docker/scripts/dumb-init.sh @@ -10,6 +10,6 @@ set -ex -curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb +curl -sOL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb dpkg -i dumb-init_*.deb rm dumb-init_*.deb diff --git a/src/ci/docker/scripts/emscripten-wasm.sh b/src/ci/docker/scripts/emscripten-wasm.sh index 0e7da45907fcc..18792c139ba76 100644 --- a/src/ci/docker/scripts/emscripten-wasm.sh +++ b/src/ci/docker/scripts/emscripten-wasm.sh @@ -28,14 +28,14 @@ exit 1 } # Download last known good emscripten from WebAssembly waterfall -BUILD=$(curl -L https://storage.googleapis.com/wasm-llvm/builds/linux/lkgr.json | \ +BUILD=$(curl -sL https://storage.googleapis.com/wasm-llvm/builds/linux/lkgr.json | \ jq '.build | tonumber') -curl -L https://storage.googleapis.com/wasm-llvm/builds/linux/$BUILD/wasm-binaries.tbz2 | \ +curl -sL https://storage.googleapis.com/wasm-llvm/builds/linux/$BUILD/wasm-binaries.tbz2 | \ hide_output tar xvkj # node 8 is required to run wasm cd / -curl -L https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \ +curl -sL https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \ tar -xJ # Make emscripten use wasm-ready node and LLVM tools diff --git a/src/ci/docker/scripts/emscripten.sh b/src/ci/docker/scripts/emscripten.sh index cf5eecbdb6c8c..0a570f18bfe75 100644 --- a/src/ci/docker/scripts/emscripten.sh +++ b/src/ci/docker/scripts/emscripten.sh @@ -28,7 +28,7 @@ exit 1 } cd / -curl -L https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \ +curl -sL https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \ tar -xz cd /emsdk-portable @@ -49,5 +49,5 @@ chmod a+rxw -R /emsdk-portable # node 8 is required to run wasm cd / -curl -L https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \ +curl -sL https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \ tar -xJ diff --git a/src/ci/docker/scripts/make3.sh b/src/ci/docker/scripts/make3.sh index 8a7845cb8f384..a0b15cca1f146 100644 --- a/src/ci/docker/scripts/make3.sh +++ b/src/ci/docker/scripts/make3.sh @@ -10,7 +10,7 @@ set -ex -curl https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf - +curl -s https://ftp.gnu.org/gnu/make/make-3.81.tar.gz | tar xzf - cd make-3.81 ./configure --prefix=/usr make diff --git a/src/ci/docker/scripts/sccache.sh b/src/ci/docker/scripts/sccache.sh index 7a2befaf6715f..4e497a6c9ce94 100644 --- a/src/ci/docker/scripts/sccache.sh +++ b/src/ci/docker/scripts/sccache.sh @@ -10,7 +10,7 @@ set -ex -curl -o /usr/local/bin/sccache \ +curl -so /usr/local/bin/sccache \ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-05-12-sccache-x86_64-unknown-linux-musl chmod +x /usr/local/bin/sccache From d245dc4df2d8b29d8db43b222ec358bb79893436 Mon Sep 17 00:00:00 2001 From: Matthew Hammer Date: Tue, 23 May 2017 14:49:08 -0600 Subject: [PATCH 121/123] add '-Z profile-queries' debug flag --- src/librustc/session/config.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 4b41572c1a104..82332932bc606 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -981,6 +981,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv)"), query_dep_graph: bool = (false, parse_bool, [UNTRACKED], "enable queries of the dependency graph for regression testing"), + profile_queries: bool = (false, parse_bool, [UNTRACKED], + "trace and profile the queries of the incremental compilation framework"), no_analysis: bool = (false, parse_bool, [UNTRACKED], "parse and expand the source, but run no analysis"), extra_plugins: Vec = (Vec::new(), parse_list, [TRACKED], @@ -2521,6 +2523,8 @@ mod tests { assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); opts.debugging_opts.query_dep_graph = true; assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); + opts.profile_queries = true; + assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); opts.debugging_opts.no_analysis = true; assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); opts.debugging_opts.unstable_options = true; From 081ab8e54c0834a8eb6ec3aea5a8c89ca22b9b98 Mon Sep 17 00:00:00 2001 From: Matthew Hammer Date: Mon, 17 Jul 2017 15:32:35 -0600 Subject: [PATCH 122/123] tidy --- src/librustc/ty/maps.rs | 5 + src/librustc/util/common.rs | 46 +++++ src/librustc_driver/profile/mod.rs | 167 ++++++++++++++++++ src/librustc_driver/profile/trace.rs | 246 +++++++++++++++++++++++++++ 4 files changed, 464 insertions(+) create mode 100644 src/librustc_driver/profile/mod.rs create mode 100644 src/librustc_driver/profile/trace.rs diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index e94308f351011..ac3bb9f8f2b9b 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -580,8 +580,13 @@ macro_rules! define_maps { key, span); + profq_msg!(tcx, + ProfileQueriesMsg::QueryBegin(span.clone(), + QueryMsg::$name(format!("{:?}", key)))); + if let Some(&(ref result, dep_node_index)) = tcx.maps.$name.borrow().map.get(&key) { tcx.dep_graph.read_index(dep_node_index); + profq_msg!(tcx, ProfileQueriesMsg::CacheHit); return Ok(f(result)); } diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 17564671a1e36..1f350aa672140 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -29,6 +29,52 @@ pub struct ErrorReported; thread_local!(static TIME_DEPTH: Cell = Cell::new(0)); +/// Initialized for -Z profile-queries +thread_local!(static PROFQ_CHAN: RefCell>> = RefCell::new(None)); + +/// A sequence of these messages induce a trace of query-based incremental compilation. +/// FIXME(matthewhammer): Determine whether we should include cycle detection here or not. +#[derive(Clone,Debug)] +pub enum ProfileQueriesMsg { + /// begin a new query + QueryBegin(Span,QueryMsg), + /// query is satisfied by using an already-known value for the given key + CacheHit, + /// query requires running a provider; providers may nest, permitting queries to nest. + ProviderBegin, + /// query is satisfied by a provider terminating with a value + ProviderEnd, + /// dump a record of the queries to the given path + Dump(String, Sender<()>), + /// stop the profilequeriesmsg service + Halt +} + +// If enabled, send a message to the profile-queries thread +pub fn profq_msg(msg: ProfileQueriesMsg) { + PROFQ_CHAN.with(|sender|{ + if let Some(s) = sender.borrow().as_ref() { + s.send(msg).unwrap() + } else { + panic!("no channel on which to send profq_msg: {:?}", msg) + } + }) +} + +pub fn profq_set_chan(s: Sender) -> bool { + PROFQ_CHAN.with(|chan|{ + let is_none = + if let None = chan.borrow().as_ref() { + true + } else { false } + ; + if is_none { + *chan.borrow_mut() = Some(s); + true + } else { false } + }) +} + /// Read the current depth of `time()` calls. This is used to /// encourage indentation across threads. pub fn time_depth() -> usize { diff --git a/src/librustc_driver/profile/mod.rs b/src/librustc_driver/profile/mod.rs new file mode 100644 index 0000000000000..fce279e5182a8 --- /dev/null +++ b/src/librustc_driver/profile/mod.rs @@ -0,0 +1,167 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use rustc::util::common::{ProfileQueriesMsg,profq_set_chan}; +use std::sync::mpsc::{Receiver}; +use std::io::{Write}; + +pub mod trace; + +// begin a thread, if not already running +pub fn begin() { + use std::thread; + use std::sync::mpsc::{channel}; + let (tx, rx) = channel(); + if profq_set_chan(tx) { + thread::spawn(move||profile_queries_thread(rx)); + } +} + +// profiling thread; retains state (in local variables) and dump traces, upon request. +fn profile_queries_thread(r:Receiver) { + use self::trace::*; + use std::fs::File; + use std::time::{Instant}; + + let mut queries : Vec = vec![]; + let mut frame : StackFrame = StackFrame{ parse_st:ParseState::NoQuery, traces:vec![] }; + let mut stack : Vec = vec![]; + loop { + let msg = r.recv(); + if let Err(_recv_err) = msg { + // FIXME: Perhaps do something smarter than simply quitting? + break + }; + let msg = msg.unwrap(); + debug!("profile_queries_thread: {:?}", msg); + + // Meta-level versus _actual_ queries messages + match msg { + ProfileQueriesMsg::Halt => return, + ProfileQueriesMsg::Dump(path, ack) => { + assert!(stack.len() == 0); + assert!(frame.parse_st == trace::ParseState::NoQuery); + { + // write log + if false { + let mut queries_file = File::create(format!("{}.log.txt", path)).unwrap(); + for q in queries.iter() { + writeln!(&mut queries_file, "{:?}", q).unwrap() + }; + } + + // write HTML file, and counts file + let html_path = format!("{}.html", path); + let mut html_file = File::create(&html_path).unwrap(); + + let counts_path = format!("{}.counts.txt", path); + let mut counts_file = File::create(&counts_path).unwrap(); + + write!(html_file, "\n").unwrap(); + write!(html_file, + "\n\n", + "profile_queries.css").unwrap(); + write!(html_file, "\n").unwrap(); + write!(html_file, "\n").unwrap(); + write!(html_file, "\n").unwrap(); + trace::write_traces(&mut html_file, &mut counts_file, &frame.traces); + write!(html_file, "\n\n").unwrap(); + + ack.send(()).unwrap(); + } + continue + } + // Actual query message: + msg => { + queries.push(msg.clone()); + match (frame.parse_st.clone(), msg) { + (_,ProfileQueriesMsg::Halt) => unreachable!(), + (_,ProfileQueriesMsg::Dump(_,_)) => unreachable!(), + + // Parse State: NoQuery + (ParseState::NoQuery, + ProfileQueriesMsg::QueryBegin(span,querymsg)) => { + let start = Instant::now(); + frame.parse_st = ParseState::HaveQuery + (Query{span:span, msg:querymsg}, start) + }, + (ParseState::NoQuery, + ProfileQueriesMsg::CacheHit) => { + panic!("parse error: unexpected CacheHit; expected QueryBegin") + }, + (ParseState::NoQuery, + ProfileQueriesMsg::ProviderBegin) => { + panic!("parse error: expected QueryBegin before beginning a provider") + }, + (ParseState::NoQuery, + ProfileQueriesMsg::ProviderEnd) => { + let provider_extent = frame.traces; + match stack.pop() { + None => + panic!("parse error: expected a stack frame; found an empty stack"), + Some(old_frame) => { + match old_frame.parse_st { + ParseState::NoQuery => + panic!("parse error: expected a stack frame for a query"), + ParseState::HaveQuery(q,start) => { + let duration = start.elapsed(); + frame = StackFrame{ + parse_st:ParseState::NoQuery, + traces:old_frame.traces + }; + let trace = Rec { + effect: Effect::QueryBegin(q, CacheCase::Miss), + extent: Box::new(provider_extent), + start: start, + duration: duration, + }; + frame.traces.push( trace ); + } + } + } + } + } + + // Parse State: HaveQuery + (ParseState::HaveQuery(q,start), + ProfileQueriesMsg::CacheHit) => { + let duration = start.elapsed(); + let trace : Rec = Rec{ + effect: Effect::QueryBegin(q, CacheCase::Hit), + extent: Box::new(vec![]), + start: start, + duration: duration, + }; + frame.traces.push( trace ); + frame.parse_st = ParseState::NoQuery; + }, + (ParseState::HaveQuery(_,_), + ProfileQueriesMsg::ProviderBegin) => { + stack.push(frame); + frame = StackFrame{parse_st:ParseState::NoQuery, traces:vec![]}; + }, + (ParseState::HaveQuery(q,_), + ProfileQueriesMsg::ProviderEnd) => { + panic!("parse error: unexpected ProviderEnd; +expected something else to follow BeginQuery for {:?}", q) + }, + (ParseState::HaveQuery(q1,_), + ProfileQueriesMsg::QueryBegin(span2,querymsg2)) => { + panic!("parse error: unexpected QueryBegin; +earlier query is unfinished: {:?} and now {:?}", + q1, Query{span:span2, msg:querymsg2}) + }, + } + } + } + } +} diff --git a/src/librustc_driver/profile/trace.rs b/src/librustc_driver/profile/trace.rs new file mode 100644 index 0000000000000..9d5dde3188f37 --- /dev/null +++ b/src/librustc_driver/profile/trace.rs @@ -0,0 +1,246 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use super::*; +use syntax_pos::Span; +use rustc::ty::maps::QueryMsg; +use std::fs::File; +use std::time::{Duration, Instant}; +use std::collections::hash_map::HashMap; + +#[derive(Debug, Clone, Eq, PartialEq)] +pub struct Query { + pub span: Span, + pub msg: QueryMsg, +} +pub enum Effect { + QueryBegin(Query, CacheCase), +} +pub enum CacheCase { + Hit, Miss +} +/// Recursive trace structure +pub struct Rec { + pub effect: Effect, + pub start: Instant, + pub duration: Duration, + pub extent: Box>, +} +/// State for parsing recursive trace structure +#[derive(Clone, Eq, PartialEq)] +pub enum ParseState { + NoQuery, + HaveQuery(Query, Instant), +} +pub struct StackFrame { + pub parse_st: ParseState, + pub traces: Vec, +} +pub struct QueryMetric { + pub count: usize, + pub duration: Duration, +} + +pub fn cons_of_query_msg(q: &trace::Query) -> String { + let s = format!("{:?}", q.msg); + let cons: Vec<&str> = s.split(|d| d == '(' || d == '{').collect(); + assert!(cons.len() > 0 && cons[0] != ""); + cons[0].to_string() +} + +// First return value is text; second return value is a CSS class +pub fn html_of_effect(eff: &Effect) -> (String, String) { + match *eff { + Effect::QueryBegin(ref qmsg, ref cc) => { + let cons = cons_of_query_msg(qmsg); + (cons.clone(), + format!("{} {}", + cons, + match *cc { + CacheCase::Hit => "hit", + CacheCase::Miss => "miss", + })) + } + } +} + +// First return value is text; second return value is a CSS class +fn html_of_duration(_start: &Instant, dur: &Duration) -> (String, String) { + use rustc::util::common::duration_to_secs_str; + (duration_to_secs_str(dur.clone()), + "".to_string() + ) +} + +fn html_of_fraction(frac: f64) -> (String, String) { + let css = { + if frac > 0.50 { format!("frac-50") } + else if frac > 0.40 { format!("frac-40") } + else if frac > 0.30 { format!("frac-30") } + else if frac > 0.20 { format!("frac-20") } + else if frac > 0.10 { format!("frac-10") } + else if frac > 0.05 { format!("frac-05") } + else if frac > 0.02 { format!("frac-02") } + else if frac > 0.01 { format!("frac-01") } + else if frac > 0.001 { format!("frac-001") } + else { format!("frac-0") } + }; + let percent = frac * 100 as f64; + if percent > 0.1 as f64 { (format!("{:.1}%", percent), css) } + else { (format!("< 0.1%", ), css) } +} + +fn total_duration(traces: &Vec) -> Duration { + let mut sum : Duration = Duration::new(0,0); + for t in traces.iter() { + sum += t.duration; + } + return sum +} + +fn duration_div(nom: Duration, den: Duration) -> f64 { + let nom_sec = nom.as_secs(); + let den_sec = den.as_secs(); + let nom_nanos = nom.subsec_nanos(); + let den_nanos = den.subsec_nanos(); + if nom_sec == den_sec { + if nom_sec == 0 { + nom_nanos as f64 / den_nanos as f64 + } else { + panic!("FIXME(matthewhammer)") + } + } else { + panic!("FIXME(matthewhammer)") + } +} + +fn write_traces_rec(file: &mut File, traces: &Vec, total: Duration, depth: usize) { + for t in traces { + let (eff_text, eff_css_classes) = html_of_effect(&t.effect); + let (dur_text, dur_css_classes) = html_of_duration(&t.start, &t.duration); + let fraction = duration_div(t.duration, total); + let percent = fraction * 100 as f64; + let (frc_text, frc_css_classes) = html_of_fraction(fraction); + write!(file, "

\n", + depth, + t.extent.len(), + /* Heuristic for 'important' CSS class: */ + if t.extent.len() > 5 || percent >= 1.0 as f64 { + " important" } + else { "" }, + eff_css_classes, + dur_css_classes, + frc_css_classes, + ).unwrap(); + write!(file, "
{}
\n", eff_text).unwrap(); + write!(file, "
{}
\n", dur_text).unwrap(); + write!(file, "
{}
\n", frc_text).unwrap(); + write_traces_rec(file, &t.extent, total, depth + 1); + write!(file, "
\n").unwrap(); + } +} + +fn compute_counts_rec(counts: &mut HashMap, traces: &Vec) { + for t in traces.iter() { + match t.effect { + Effect::QueryBegin(ref qmsg, ref _cc) => { + let qcons = cons_of_query_msg(qmsg); + let qm = match counts.get(&qcons) { + Some(qm) => + QueryMetric{ + count: qm.count + 1, + duration: qm.duration + t.duration + }, + None => QueryMetric{ + count: 1, + duration: t.duration + } + }; + counts.insert(qcons, qm); + } + } + compute_counts_rec(counts, &t.extent) + } +} + +pub fn write_counts(count_file: &mut File, counts: &mut HashMap) { + use rustc::util::common::duration_to_secs_str; + use std::cmp::Ordering; + + let mut data = vec![]; + for (ref cons, ref qm) in counts.iter() { + data.push((cons.clone(), qm.count.clone(), qm.duration.clone())); + }; + data.sort_by(|&(_,_,d1),&(_,_,d2)| + if d1 > d2 { Ordering::Less } else { Ordering::Greater } ); + for (cons, count, duration) in data { + write!(count_file, "{},{},{}\n", + cons, count, duration_to_secs_str(duration) + ).unwrap(); + } +} + +pub fn write_traces(html_file: &mut File, counts_file: &mut File, traces: &Vec) { + let mut counts : HashMap = HashMap::new(); + compute_counts_rec(&mut counts, traces); + write_counts(counts_file, &mut counts); + + let total : Duration = total_duration(traces); + write_traces_rec(html_file, traces, total, 0) +} + +pub fn write_style(html_file: &mut File) { + write!(html_file,"{}", " +body { + font-family: sans-serif; + background: black; +} +.trace { + color: black; + display: inline-block; + border-style: solid; + border-color: red; + border-width: 1px; + border-radius: 5px; + padding: 0px; + margin: 1px; + font-size: 0px; +} +.miss { + border-color: red; + border-width: 1px; +} +.extent-0 { + padding: 2px; +} +.important { + border-width: 3px; + font-size: 12px; + color: white; + border-color: #f77; +} +.hit { + padding: 0px; + border-color: blue; + border-width: 3px; +} +.eff { + color: #fff; + display: inline-block; +} +.frc { + color: #7f7; + display: inline-block; +} +.dur { + display: none +} +").unwrap(); +} From 74a7234dc93919ef09ca43ef071b646918a0f314 Mon Sep 17 00:00:00 2001 From: Matthew Hammer Date: Tue, 18 Jul 2017 11:58:05 -0600 Subject: [PATCH 123/123] fix nits from Niko --- src/librustc/session/mod.rs | 2 +- src/librustc/ty/maps.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index b3e8650faf8bc..4b41edd483a22 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -396,7 +396,7 @@ impl Session { } pub fn verbose(&self) -> bool { self.opts.debugging_opts.verbose } pub fn time_passes(&self) -> bool { self.opts.debugging_opts.time_passes } - //pub fn profile_queries(&self) -> bool { self.opts.debugging_opts.profile_queries } + pub fn profile_queries(&self) -> bool { self.opts.debugging_opts.profile_queries } pub fn count_llvm_insns(&self) -> bool { self.opts.debugging_opts.count_llvm_insns } diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index 472431f01a241..845cd978b4475 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -27,7 +27,7 @@ use ty::steal::Steal; use ty::subst::Substs; use ty::fast_reject::SimplifiedType; -use util::common::{profq_msg,ProfileQueriesMsg}; +use util::common::{profq_msg, ProfileQueriesMsg}; use util::nodemap::{DefIdSet, NodeSet}; use rustc_data_structures::indexed_vec::IndexVec;