From 7e0c3de4c473c3779046951abec46517fdba8cc9 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 18 Feb 2017 22:48:36 -0500 Subject: [PATCH 01/20] Remove `else`, unindent. --- src/librustc/traits/error_reporting.rs | 219 ++++++++++++------------- 1 file changed, 109 insertions(+), 110 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 70ca5fe83a932..411e986f62d90 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -525,127 +525,126 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { lint_id) .emit(); return; - } else { - match obligation.predicate { - ty::Predicate::Trait(ref trait_predicate) => { - let trait_predicate = - self.resolve_type_vars_if_possible(trait_predicate); + } + match obligation.predicate { + ty::Predicate::Trait(ref trait_predicate) => { + let trait_predicate = + self.resolve_type_vars_if_possible(trait_predicate); - if self.tcx.sess.has_errors() && trait_predicate.references_error() { - return; + if self.tcx.sess.has_errors() && trait_predicate.references_error() { + return; + } else { + let trait_ref = trait_predicate.to_poly_trait_ref(); + let (post_message, pre_message) = match self.get_parent_trait_ref( + &obligation.cause.code) + { + Some(t) => { + (format!(" in `{}`", t), format!("within `{}`, ", t)) + } + None => (String::new(), String::new()), + }; + let mut err = struct_span_err!( + self.tcx.sess, + span, + E0277, + "the trait bound `{}` is not satisfied{}", + trait_ref.to_predicate(), + post_message); + err.span_label(span, + &format!("{}the trait `{}` is not \ + implemented for `{}`", + pre_message, + trait_ref, + trait_ref.self_ty())); + + // Try to report a help message + + if !trait_ref.has_infer_types() && + self.predicate_can_apply(trait_ref) { + // If a where-clause may be useful, remind the + // user that they can add it. + // + // don't display an on-unimplemented note, as + // these notes will often be of the form + // "the type `T` can't be frobnicated" + // which is somewhat confusing. + err.help(&format!("consider adding a `where {}` bound", + trait_ref.to_predicate())); + } else if let Some(s) = self.on_unimplemented_note(trait_ref, + obligation) { + // If it has a custom "#[rustc_on_unimplemented]" + // error message, let's display it! + err.note(&s); } else { - let trait_ref = trait_predicate.to_poly_trait_ref(); - let (post_message, pre_message) = match self.get_parent_trait_ref( - &obligation.cause.code) - { - Some(t) => { - (format!(" in `{}`", t), format!("within `{}`, ", t)) - } - None => (String::new(), String::new()), - }; - let mut err = struct_span_err!( - self.tcx.sess, - span, - E0277, - "the trait bound `{}` is not satisfied{}", - trait_ref.to_predicate(), - post_message); - err.span_label(span, - &format!("{}the trait `{}` is not \ - implemented for `{}`", - pre_message, - trait_ref, - trait_ref.self_ty())); - - // Try to report a help message - - if !trait_ref.has_infer_types() && - self.predicate_can_apply(trait_ref) { - // If a where-clause may be useful, remind the - // user that they can add it. - // - // don't display an on-unimplemented note, as - // these notes will often be of the form - // "the type `T` can't be frobnicated" - // which is somewhat confusing. - err.help(&format!("consider adding a `where {}` bound", - trait_ref.to_predicate())); - } else if let Some(s) = self.on_unimplemented_note(trait_ref, - obligation) { - // If it has a custom "#[rustc_on_unimplemented]" - // error message, let's display it! - err.note(&s); - } else { - // If we can't show anything useful, try to find - // similar impls. - let impl_candidates = - self.find_similar_impl_candidates(trait_ref); - if impl_candidates.len() > 0 { - self.report_similar_impl_candidates(trait_ref, &mut err); - } + // If we can't show anything useful, try to find + // similar impls. + let impl_candidates = + self.find_similar_impl_candidates(trait_ref); + if impl_candidates.len() > 0 { + self.report_similar_impl_candidates(trait_ref, &mut err); } - err } + err } + } - ty::Predicate::Equate(ref predicate) => { - let predicate = self.resolve_type_vars_if_possible(predicate); - let err = self.equality_predicate(&obligation.cause, - &predicate).err().unwrap(); - struct_span_err!(self.tcx.sess, span, E0278, - "the requirement `{}` is not satisfied (`{}`)", - predicate, err) - } + ty::Predicate::Equate(ref predicate) => { + let predicate = self.resolve_type_vars_if_possible(predicate); + let err = self.equality_predicate(&obligation.cause, + &predicate).err().unwrap(); + struct_span_err!(self.tcx.sess, span, E0278, + "the requirement `{}` is not satisfied (`{}`)", + predicate, err) + } - ty::Predicate::RegionOutlives(ref predicate) => { - let predicate = self.resolve_type_vars_if_possible(predicate); - let err = self.region_outlives_predicate(&obligation.cause, - &predicate).err().unwrap(); - struct_span_err!(self.tcx.sess, span, E0279, - "the requirement `{}` is not satisfied (`{}`)", - predicate, err) - } + ty::Predicate::RegionOutlives(ref predicate) => { + let predicate = self.resolve_type_vars_if_possible(predicate); + let err = self.region_outlives_predicate(&obligation.cause, + &predicate).err().unwrap(); + struct_span_err!(self.tcx.sess, span, E0279, + "the requirement `{}` is not satisfied (`{}`)", + predicate, err) + } - ty::Predicate::Projection(..) | ty::Predicate::TypeOutlives(..) => { - let predicate = - self.resolve_type_vars_if_possible(&obligation.predicate); - struct_span_err!(self.tcx.sess, span, E0280, - "the requirement `{}` is not satisfied", - predicate) - } + ty::Predicate::Projection(..) | ty::Predicate::TypeOutlives(..) => { + let predicate = + self.resolve_type_vars_if_possible(&obligation.predicate); + struct_span_err!(self.tcx.sess, span, E0280, + "the requirement `{}` is not satisfied", + predicate) + } - ty::Predicate::ObjectSafe(trait_def_id) => { - let violations = self.tcx.object_safety_violations(trait_def_id); - self.tcx.report_object_safety_error(span, - trait_def_id, - violations) - } + ty::Predicate::ObjectSafe(trait_def_id) => { + let violations = self.tcx.object_safety_violations(trait_def_id); + self.tcx.report_object_safety_error(span, + trait_def_id, + violations) + } - ty::Predicate::ClosureKind(closure_def_id, kind) => { - let found_kind = self.closure_kind(closure_def_id).unwrap(); - let closure_span = self.tcx.hir.span_if_local(closure_def_id).unwrap(); - let mut err = struct_span_err!( - self.tcx.sess, closure_span, E0525, - "expected a closure that implements the `{}` trait, \ - but this closure only implements `{}`", - kind, - found_kind); - err.span_note( - obligation.cause.span, - &format!("the requirement to implement \ - `{}` derives from here", kind)); - err.emit(); - return; - } + ty::Predicate::ClosureKind(closure_def_id, kind) => { + let found_kind = self.closure_kind(closure_def_id).unwrap(); + let closure_span = self.tcx.hir.span_if_local(closure_def_id).unwrap(); + let mut err = struct_span_err!( + self.tcx.sess, closure_span, E0525, + "expected a closure that implements the `{}` trait, \ + but this closure only implements `{}`", + kind, + found_kind); + err.span_note( + obligation.cause.span, + &format!("the requirement to implement \ + `{}` derives from here", kind)); + err.emit(); + return; + } - ty::Predicate::WellFormed(ty) => { - // WF predicates cannot themselves make - // errors. They can only block due to - // ambiguity; otherwise, they always - // degenerate into other obligations - // (which may fail). - span_bug!(span, "WF predicate not satisfied for {:?}", ty); - } + ty::Predicate::WellFormed(ty) => { + // WF predicates cannot themselves make + // errors. They can only block due to + // ambiguity; otherwise, they always + // degenerate into other obligations + // (which may fail). + span_bug!(span, "WF predicate not satisfied for {:?}", ty); } } } From de2f7e15ba6db2846c80c7ad4ffe391f2c5a4311 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 19 Feb 2017 10:41:36 -0500 Subject: [PATCH 02/20] Rewrite `match` to use combinators. --- src/librustc/traits/error_reporting.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 411e986f62d90..a9f3c54bd73e0 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -535,14 +535,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { return; } else { let trait_ref = trait_predicate.to_poly_trait_ref(); - let (post_message, pre_message) = match self.get_parent_trait_ref( - &obligation.cause.code) - { - Some(t) => { - (format!(" in `{}`", t), format!("within `{}`, ", t)) - } - None => (String::new(), String::new()), - }; + let (post_message, pre_message) = + self.get_parent_trait_ref(&obligation.cause.code) + .map(|t| (format!(" in `{}`", t), format!("within `{}`, ", t))) + .unwrap_or((String::new(), String::new())); let mut err = struct_span_err!( self.tcx.sess, span, From 83fe48d598ee188ae4d64a1fd12928e1026accf7 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 19 Feb 2017 10:46:43 -0500 Subject: [PATCH 03/20] Remove `else`, unindent. --- src/librustc/traits/error_reporting.rs | 91 +++++++++++++------------- 1 file changed, 45 insertions(+), 46 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index a9f3c54bd73e0..193c07166b04e 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -533,55 +533,54 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { if self.tcx.sess.has_errors() && trait_predicate.references_error() { return; + } + let trait_ref = trait_predicate.to_poly_trait_ref(); + let (post_message, pre_message) = + self.get_parent_trait_ref(&obligation.cause.code) + .map(|t| (format!(" in `{}`", t), format!("within `{}`, ", t))) + .unwrap_or((String::new(), String::new())); + let mut err = struct_span_err!( + self.tcx.sess, + span, + E0277, + "the trait bound `{}` is not satisfied{}", + trait_ref.to_predicate(), + post_message); + err.span_label(span, + &format!("{}the trait `{}` is not \ + implemented for `{}`", + pre_message, + trait_ref, + trait_ref.self_ty())); + + // Try to report a help message + + if !trait_ref.has_infer_types() && + self.predicate_can_apply(trait_ref) { + // If a where-clause may be useful, remind the + // user that they can add it. + // + // don't display an on-unimplemented note, as + // these notes will often be of the form + // "the type `T` can't be frobnicated" + // which is somewhat confusing. + err.help(&format!("consider adding a `where {}` bound", + trait_ref.to_predicate())); + } else if let Some(s) = self.on_unimplemented_note(trait_ref, + obligation) { + // If it has a custom "#[rustc_on_unimplemented]" + // error message, let's display it! + err.note(&s); } else { - let trait_ref = trait_predicate.to_poly_trait_ref(); - let (post_message, pre_message) = - self.get_parent_trait_ref(&obligation.cause.code) - .map(|t| (format!(" in `{}`", t), format!("within `{}`, ", t))) - .unwrap_or((String::new(), String::new())); - let mut err = struct_span_err!( - self.tcx.sess, - span, - E0277, - "the trait bound `{}` is not satisfied{}", - trait_ref.to_predicate(), - post_message); - err.span_label(span, - &format!("{}the trait `{}` is not \ - implemented for `{}`", - pre_message, - trait_ref, - trait_ref.self_ty())); - - // Try to report a help message - - if !trait_ref.has_infer_types() && - self.predicate_can_apply(trait_ref) { - // If a where-clause may be useful, remind the - // user that they can add it. - // - // don't display an on-unimplemented note, as - // these notes will often be of the form - // "the type `T` can't be frobnicated" - // which is somewhat confusing. - err.help(&format!("consider adding a `where {}` bound", - trait_ref.to_predicate())); - } else if let Some(s) = self.on_unimplemented_note(trait_ref, - obligation) { - // If it has a custom "#[rustc_on_unimplemented]" - // error message, let's display it! - err.note(&s); - } else { - // If we can't show anything useful, try to find - // similar impls. - let impl_candidates = - self.find_similar_impl_candidates(trait_ref); - if impl_candidates.len() > 0 { - self.report_similar_impl_candidates(trait_ref, &mut err); - } + // If we can't show anything useful, try to find + // similar impls. + let impl_candidates = + self.find_similar_impl_candidates(trait_ref); + if impl_candidates.len() > 0 { + self.report_similar_impl_candidates(trait_ref, &mut err); } - err } + err } ty::Predicate::Equate(ref predicate) => { From a97aed739b84df8d3bdd24e223dcd504e7e92615 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 19 Feb 2017 12:33:59 -0500 Subject: [PATCH 04/20] Remove unnecessary logic when finding simpilar `impl` candidates. --- src/librustc/traits/error_reporting.rs | 34 +++----------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 193c07166b04e..9354a8f735bc6 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -359,34 +359,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } fn report_similar_impl_candidates(&self, - trait_ref: ty::PolyTraitRef<'tcx>, + impl_candidates: Vec>, err: &mut DiagnosticBuilder) { - let simp = fast_reject::simplify_type(self.tcx, - trait_ref.skip_binder().self_ty(), - true); - let mut impl_candidates = Vec::new(); - let trait_def = self.tcx.lookup_trait_def(trait_ref.def_id()); - - match simp { - Some(simp) => trait_def.for_each_impl(self.tcx, |def_id| { - let imp = self.tcx.impl_trait_ref(def_id).unwrap(); - let imp_simp = fast_reject::simplify_type(self.tcx, - imp.self_ty(), - true); - if let Some(imp_simp) = imp_simp { - if simp != imp_simp { - return; - } - } - impl_candidates.push(imp); - }), - None => trait_def.for_each_impl(self.tcx, |def_id| { - impl_candidates.push( - self.tcx.impl_trait_ref(def_id).unwrap()); - }) - }; - if impl_candidates.is_empty() { return; } @@ -574,11 +549,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } else { // If we can't show anything useful, try to find // similar impls. - let impl_candidates = - self.find_similar_impl_candidates(trait_ref); - if impl_candidates.len() > 0 { - self.report_similar_impl_candidates(trait_ref, &mut err); - } + let impl_candidates = self.find_similar_impl_candidates(trait_ref); + self.report_similar_impl_candidates(impl_candidates, &mut err); } err } From 2436d7374caf1e25bfa8bacfb94c85d6d142332c Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 19 Feb 2017 13:00:25 -0500 Subject: [PATCH 05/20] Extract out error message generation. --- src/librustc/traits/error_reporting.rs | 34 +------------------------- src/librustc/traits/object_safety.rs | 20 +++++++++++++++ 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 9354a8f735bc6..11a777d5fe444 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -21,7 +21,6 @@ use super::{ SelectionContext, SelectionError, ObjectSafetyViolation, - MethodViolationCode, }; use fmt_macros::{Parser, Piece, Position}; @@ -679,38 +678,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { if !reported_violations.insert(violation.clone()) { continue; } - let buf; - let note = match violation { - ObjectSafetyViolation::SizedSelf => { - "the trait cannot require that `Self : Sized`" - } - - ObjectSafetyViolation::SupertraitSelf => { - "the trait cannot use `Self` as a type parameter \ - in the supertrait listing" - } - - ObjectSafetyViolation::Method(name, - MethodViolationCode::StaticMethod) => { - buf = format!("method `{}` has no receiver", name); - &buf - } - - ObjectSafetyViolation::Method(name, - MethodViolationCode::ReferencesSelf) => { - buf = format!("method `{}` references the `Self` type \ - in its arguments or return type", - name); - &buf - } - - ObjectSafetyViolation::Method(name, - MethodViolationCode::Generic) => { - buf = format!("method `{}` has generic type parameters", name); - &buf - } - }; - err.note(note); + err.note(&violation.error_msg()); } err } diff --git a/src/librustc/traits/object_safety.rs b/src/librustc/traits/object_safety.rs index 60808fbc741fb..2ebe0d459fab1 100644 --- a/src/librustc/traits/object_safety.rs +++ b/src/librustc/traits/object_safety.rs @@ -23,6 +23,7 @@ use hir::def_id::DefId; use traits; use ty::{self, Ty, TyCtxt, TypeFoldable}; use ty::subst::Substs; +use std::borrow::Cow; use syntax::ast; #[derive(Clone, Debug, PartialEq, Eq, Hash)] @@ -38,6 +39,25 @@ pub enum ObjectSafetyViolation { Method(ast::Name, MethodViolationCode), } +impl ObjectSafetyViolation { + pub fn error_msg(&self) -> Cow<'static, str> { + match *self { + ObjectSafetyViolation::SizedSelf => + "the trait cannot require that `Self : Sized`".into(), + ObjectSafetyViolation::SupertraitSelf => + "the trait cannot use `Self` as a type parameter \ + in the supertrait listing".into(), + ObjectSafetyViolation::Method(name, MethodViolationCode::StaticMethod) => + format!("method `{}` has no receiver", name).into(), + ObjectSafetyViolation::Method(name, MethodViolationCode::ReferencesSelf) => + format!("method `{}` references the `Self` type \ + in its arguments or return type", name).into(), + ObjectSafetyViolation::Method(name, MethodViolationCode::Generic) => + format!("method `{}` has generic type parameters", name).into(), + } + } +} + /// Reasons a method might not be object-safe. #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub enum MethodViolationCode { From 10639d7958e951bb5478750e8fcce3eeda868304 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 19 Feb 2017 13:12:18 -0500 Subject: [PATCH 06/20] Add early return, remove `else`, unindent. --- src/librustc/traits/error_reporting.rs | 80 +++++++++++++------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 11a777d5fe444..c2fbccf82da94 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -708,46 +708,46 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let trait_ref = data.to_poly_trait_ref(); let self_ty = trait_ref.self_ty(); if predicate.references_error() { - } else { - // Typically, this ambiguity should only happen if - // there are unresolved type inference variables - // (otherwise it would suggest a coherence - // failure). But given #21974 that is not necessarily - // the case -- we can have multiple where clauses that - // are only distinguished by a region, which results - // in an ambiguity even when all types are fully - // known, since we don't dispatch based on region - // relationships. - - // This is kind of a hack: it frequently happens that some earlier - // error prevents types from being fully inferred, and then we get - // a bunch of uninteresting errors saying something like " doesn't implement Sized". It may even be true that we - // could just skip over all checks where the self-ty is an - // inference variable, but I was afraid that there might be an - // inference variable created, registered as an obligation, and - // then never forced by writeback, and hence by skipping here we'd - // be ignoring the fact that we don't KNOW the type works - // out. Though even that would probably be harmless, given that - // we're only talking about builtin traits, which are known to be - // inhabited. But in any case I just threw in this check for - // has_errors() to be sure that compilation isn't happening - // anyway. In that case, why inundate the user. - if !self.tcx.sess.has_errors() { - if - self.tcx.lang_items.sized_trait() - .map_or(false, |sized_id| sized_id == trait_ref.def_id()) - { - self.need_type_info(obligation, self_ty); - } else { - let mut err = struct_span_err!(self.tcx.sess, - obligation.cause.span, E0283, - "type annotations required: \ - cannot resolve `{}`", - predicate); - self.note_obligation_cause(&mut err, obligation); - err.emit(); - } + return; + } + // Typically, this ambiguity should only happen if + // there are unresolved type inference variables + // (otherwise it would suggest a coherence + // failure). But given #21974 that is not necessarily + // the case -- we can have multiple where clauses that + // are only distinguished by a region, which results + // in an ambiguity even when all types are fully + // known, since we don't dispatch based on region + // relationships. + + // This is kind of a hack: it frequently happens that some earlier + // error prevents types from being fully inferred, and then we get + // a bunch of uninteresting errors saying something like " doesn't implement Sized". It may even be true that we + // could just skip over all checks where the self-ty is an + // inference variable, but I was afraid that there might be an + // inference variable created, registered as an obligation, and + // then never forced by writeback, and hence by skipping here we'd + // be ignoring the fact that we don't KNOW the type works + // out. Though even that would probably be harmless, given that + // we're only talking about builtin traits, which are known to be + // inhabited. But in any case I just threw in this check for + // has_errors() to be sure that compilation isn't happening + // anyway. In that case, why inundate the user. + if !self.tcx.sess.has_errors() { + if + self.tcx.lang_items.sized_trait() + .map_or(false, |sized_id| sized_id == trait_ref.def_id()) + { + self.need_type_info(obligation, self_ty); + } else { + let mut err = struct_span_err!(self.tcx.sess, + obligation.cause.span, E0283, + "type annotations required: \ + cannot resolve `{}`", + predicate); + self.note_obligation_cause(&mut err, obligation); + err.emit(); } } } From 23d9211f1e2413243590757b68ec18b1fbc5d91f Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 19 Feb 2017 17:02:10 -0500 Subject: [PATCH 07/20] Flatten `for` loop using iterator combinators. --- src/librustc/traits/error_reporting.rs | 98 +++++++++++++------------- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index c2fbccf82da94..f850fd9772781 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -266,61 +266,63 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let span = obligation.cause.span; let mut report = None; - for item in self.tcx.get_attrs(def_id).iter() { - if item.check_name("rustc_on_unimplemented") { - let err_sp = item.meta().span.substitute_dummy(span); - let trait_str = self.tcx.item_path_str(trait_ref.def_id); - if let Some(istring) = item.value_str() { - let istring = &*istring.as_str(); - let generics = self.tcx.item_generics(trait_ref.def_id); - let generic_map = generics.types.iter().map(|param| { - (param.name.as_str().to_string(), - trait_ref.substs.type_for_def(param).to_string()) - }).collect::>(); - let parser = Parser::new(istring); - let mut errored = false; - let err: String = parser.filter_map(|p| { - match p { - Piece::String(s) => Some(s), - Piece::NextArgument(a) => match a.position { - Position::ArgumentNamed(s) => match generic_map.get(s) { - Some(val) => Some(val), - None => { - span_err!(self.tcx.sess, err_sp, E0272, - "the #[rustc_on_unimplemented] \ - attribute on \ - trait definition for {} refers to \ - non-existent type parameter {}", - trait_str, s); - errored = true; - None - } - }, - _ => { - span_err!(self.tcx.sess, err_sp, E0273, - "the #[rustc_on_unimplemented] attribute \ - on trait definition for {} must have \ - named format arguments, eg \ - `#[rustc_on_unimplemented = \ - \"foo {{T}}\"]`", trait_str); + if let Some(item) = self.tcx + .get_attrs(def_id) + .into_iter() + .filter(|a| a.check_name("rustc_on_unimplemented")) + .next() + { + let err_sp = item.meta().span.substitute_dummy(span); + let trait_str = self.tcx.item_path_str(trait_ref.def_id); + if let Some(istring) = item.value_str() { + let istring = &*istring.as_str(); + let generics = self.tcx.item_generics(trait_ref.def_id); + let generic_map = generics.types.iter().map(|param| { + (param.name.as_str().to_string(), + trait_ref.substs.type_for_def(param).to_string()) + }).collect::>(); + let parser = Parser::new(istring); + let mut errored = false; + let err: String = parser.filter_map(|p| { + match p { + Piece::String(s) => Some(s), + Piece::NextArgument(a) => match a.position { + Position::ArgumentNamed(s) => match generic_map.get(s) { + Some(val) => Some(val), + None => { + span_err!(self.tcx.sess, err_sp, E0272, + "the #[rustc_on_unimplemented] \ + attribute on \ + trait definition for {} refers to \ + non-existent type parameter {}", + trait_str, s); errored = true; None } + }, + _ => { + span_err!(self.tcx.sess, err_sp, E0273, + "the #[rustc_on_unimplemented] attribute \ + on trait definition for {} must have \ + named format arguments, eg \ + `#[rustc_on_unimplemented = \ + \"foo {{T}}\"]`", trait_str); + errored = true; + None } } - }).collect(); - // Report only if the format string checks out - if !errored { - report = Some(err); } - } else { - span_err!(self.tcx.sess, err_sp, E0274, - "the #[rustc_on_unimplemented] attribute on \ - trait definition for {} must have a value, \ - eg `#[rustc_on_unimplemented = \"foo\"]`", - trait_str); + }).collect(); + // Report only if the format string checks out + if !errored { + report = Some(err); } - break; + } else { + span_err!(self.tcx.sess, err_sp, E0274, + "the #[rustc_on_unimplemented] attribute on \ + trait definition for {} must have a value, \ + eg `#[rustc_on_unimplemented = \"foo\"]`", + trait_str); } } report From a754ea6d0a6bc901e1c2dd58e3c0d0e283f8ae17 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Mon, 20 Feb 2017 09:23:40 -0500 Subject: [PATCH 08/20] Move `TraitRef` `impl` next to `struct` definition. --- src/librustc/ty/mod.rs | 18 ------------------ src/librustc/ty/sty.rs | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 7937d2ccfe46d..2a6ef13bfd2e2 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -1086,24 +1086,6 @@ impl<'tcx> InstantiatedPredicates<'tcx> { } } -impl<'tcx> TraitRef<'tcx> { - pub fn new(def_id: DefId, substs: &'tcx Substs<'tcx>) -> TraitRef<'tcx> { - TraitRef { def_id: def_id, substs: substs } - } - - pub fn self_ty(&self) -> Ty<'tcx> { - self.substs.type_at(0) - } - - pub fn input_types<'a>(&'a self) -> impl DoubleEndedIterator> + 'a { - // Select only the "input types" from a trait-reference. For - // now this is all the types that appear in the - // trait-reference, but it should eventually exclude - // associated types. - self.substs.types() - } -} - /// When type checking, we use the `ParameterEnvironment` to track /// details about the type/lifetime parameters that are in scope. /// It primarily stores the bounds information. diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 862bc15c05260..64e5ec6aeb24b 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -389,6 +389,24 @@ pub struct TraitRef<'tcx> { pub substs: &'tcx Substs<'tcx>, } +impl<'tcx> TraitRef<'tcx> { + pub fn new(def_id: DefId, substs: &'tcx Substs<'tcx>) -> TraitRef<'tcx> { + TraitRef { def_id: def_id, substs: substs } + } + + pub fn self_ty(&self) -> Ty<'tcx> { + self.substs.type_at(0) + } + + pub fn input_types<'a>(&'a self) -> impl DoubleEndedIterator> + 'a { + // Select only the "input types" from a trait-reference. For + // now this is all the types that appear in the + // trait-reference, but it should eventually exclude + // associated types. + self.substs.types() + } +} + pub type PolyTraitRef<'tcx> = Binder>; impl<'tcx> PolyTraitRef<'tcx> { From d3b8f56ae75a3dad07da0d685ffb16b51c486d68 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 22 Feb 2017 15:27:07 +0100 Subject: [PATCH 09/20] Add missing urls and examples for Condvar docs --- src/libstd/sync/condvar.rs | 246 ++++++++++++++++++++++++++++++++++--- 1 file changed, 230 insertions(+), 16 deletions(-) diff --git a/src/libstd/sync/condvar.rs b/src/libstd/sync/condvar.rs index 7ee1c98565cfd..68c7e88f67fc5 100644 --- a/src/libstd/sync/condvar.rs +++ b/src/libstd/sync/condvar.rs @@ -18,12 +18,57 @@ use time::Duration; /// A type indicating whether a timed wait on a condition variable returned /// due to a time out or not. +/// +/// It is returned by the [`wait_timeout`] method. +/// +/// [`wait_timeout`]: struct.Condvar.html#method.wait_timeout #[derive(Debug, PartialEq, Eq, Copy, Clone)] #[stable(feature = "wait_timeout", since = "1.5.0")] pub struct WaitTimeoutResult(bool); impl WaitTimeoutResult { /// Returns whether the wait was known to have timed out. + /// + /// # Examples + /// + /// This example spawns a thread which will update the boolean value and + /// then wait 100 milliseconds before notifying the condvar. + /// + /// The main thread will wait with a timeout on the condvar and then leave + /// once the boolean has been updated and notified. + /// + /// ``` + /// use std::sync::{Arc, Mutex, Condvar}; + /// use std::thread; + /// use std::time::Duration; + /// + /// let pair = Arc::new((Mutex::new(false), Condvar::new())); + /// let pair2 = pair.clone(); + /// + /// thread::spawn(move|| { + /// let &(ref lock, ref cvar) = &*pair2; + /// let mut started = lock.lock().unwrap(); + /// // We update the boolean value. + /// *started = true; + /// // Let's wait 20 milliseconds before notifying the condvar. + /// thread::sleep(Duration::from_millis(20)); + /// cvar.notify_one(); + /// }); + /// + /// // Wait for the thread to start up. + /// let &(ref lock, ref cvar) = &*pair; + /// let mut started = lock.lock().unwrap(); + /// loop { + /// // Let's put a timeout on the condvar's wait. + /// let result = cvar.wait_timeout(started, Duration::from_millis(10)).unwrap(); + /// // 10 milliseconds have passed, or maybe the value changed! + /// started = result.0; + /// if *started == true { + /// // We received the notification and the value has been updated, we can leave. + /// break + /// } + /// } + /// ``` #[stable(feature = "wait_timeout", since = "1.5.0")] pub fn timed_out(&self) -> bool { self.0 @@ -55,15 +100,16 @@ impl WaitTimeoutResult { /// let pair = Arc::new((Mutex::new(false), Condvar::new())); /// let pair2 = pair.clone(); /// -/// // Inside of our lock, spawn a new thread, and then wait for it to start +/// // Inside of our lock, spawn a new thread, and then wait for it to start. /// thread::spawn(move|| { /// let &(ref lock, ref cvar) = &*pair2; /// let mut started = lock.lock().unwrap(); /// *started = true; +/// // We notify the condvar that the value has changed. /// cvar.notify_one(); /// }); /// -/// // wait for the thread to start up +/// // Wait for the thread to start up. /// let &(ref lock, ref cvar) = &*pair; /// let mut started = lock.lock().unwrap(); /// while !*started { @@ -79,6 +125,14 @@ pub struct Condvar { impl Condvar { /// Creates a new condition variable which is ready to be waited on and /// notified. + /// + /// # Examples + /// + /// ``` + /// use std::sync::Condvar; + /// + /// let condvar = Condvar::new(); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn new() -> Condvar { let mut c = Condvar { @@ -95,10 +149,10 @@ impl Condvar { /// notification. /// /// This function will atomically unlock the mutex specified (represented by - /// `mutex_guard`) and block the current thread. This means that any calls - /// to `notify_*()` which happen logically after the mutex is unlocked are - /// candidates to wake this thread up. When this function call returns, the - /// lock specified will have been re-acquired. + /// `guard`) and block the current thread. This means that any calls + /// to [`notify_one()`] or [`notify_all()`] which happen logically after the + /// mutex is unlocked are candidates to wake this thread up. When this + /// function call returns, the lock specified will have been re-acquired. /// /// Note that this function is susceptible to spurious wakeups. Condition /// variables normally have a boolean predicate associated with them, and @@ -109,14 +163,46 @@ impl Condvar { /// /// This function will return an error if the mutex being waited on is /// poisoned when this thread re-acquires the lock. For more information, - /// see information about poisoning on the Mutex type. + /// see information about [poisoning] on the [`Mutex`] type. /// /// # Panics /// - /// This function will `panic!()` if it is used with more than one mutex + /// This function will [`panic!()`] if it is used with more than one mutex /// over time. Each condition variable is dynamically bound to exactly one /// mutex to ensure defined behavior across platforms. If this functionality /// is not desired, then unsafe primitives in `sys` are provided. + /// + /// [`notify_one()`]: #method.notify_one + /// [`notify_all()`]: #method.notify_all + /// [poisoning]: ../sync/struct.Mutex.html#poisoning + /// [`Mutex`]: ../sync/struct.Mutex.html + /// [`panic!()`]: ../../std/macro.panic.html + /// + /// # Examples + /// + /// ``` + /// use std::sync::{Arc, Mutex, Condvar}; + /// use std::thread; + /// + /// let pair = Arc::new((Mutex::new(false), Condvar::new())); + /// let pair2 = pair.clone(); + /// + /// thread::spawn(move|| { + /// let &(ref lock, ref cvar) = &*pair2; + /// let mut started = lock.lock().unwrap(); + /// *started = true; + /// // We notify the condvar that the value has changed. + /// cvar.notify_one(); + /// }); + /// + /// // Wait for the thread to start up. + /// let &(ref lock, ref cvar) = &*pair; + /// let mut started = lock.lock().unwrap(); + /// // As long as the value inside the `Mutex` is false, we wait. + /// while !*started { + /// started = cvar.wait(started).unwrap(); + /// } + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn wait<'a, T>(&self, guard: MutexGuard<'a, T>) -> LockResult> { @@ -136,7 +222,7 @@ impl Condvar { /// Waits on this condition variable for a notification, timing out after a /// specified duration. /// - /// The semantics of this function are equivalent to `wait()` + /// The semantics of this function are equivalent to [`wait`] /// except that the thread will be blocked for roughly no longer /// than `ms` milliseconds. This method should not be used for /// precise timing due to anomalies such as preemption or platform @@ -150,8 +236,42 @@ impl Condvar { /// The returned boolean is `false` only if the timeout is known /// to have elapsed. /// - /// Like `wait`, the lock specified will be re-acquired when this function + /// Like [`wait`], the lock specified will be re-acquired when this function /// returns, regardless of whether the timeout elapsed or not. + /// + /// [`wait`]: #method.wait + /// + /// # Examples + /// + /// ``` + /// use std::sync::{Arc, Mutex, Condvar}; + /// use std::thread; + /// + /// let pair = Arc::new((Mutex::new(false), Condvar::new())); + /// let pair2 = pair.clone(); + /// + /// thread::spawn(move|| { + /// let &(ref lock, ref cvar) = &*pair2; + /// let mut started = lock.lock().unwrap(); + /// *started = true; + /// // We notify the condvar that the value has changed. + /// cvar.notify_one(); + /// }); + /// + /// // Wait for the thread to start up. + /// let &(ref lock, ref cvar) = &*pair; + /// let mut started = lock.lock().unwrap(); + /// // As long as the value inside the `Mutex` is false, we wait. + /// loop { + /// let result = cvar.wait_timeout_ms(started, 10).unwrap(); + /// // 10 milliseconds have passed, or maybe the value changed! + /// started = result.0; + /// if *started == true { + /// // We received the notification and the value has been updated, we can leave. + /// break + /// } + /// } + /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_deprecated(since = "1.6.0", reason = "replaced by `std::sync::Condvar::wait_timeout`")] pub fn wait_timeout_ms<'a, T>(&self, guard: MutexGuard<'a, T>, ms: u32) @@ -165,7 +285,7 @@ impl Condvar { /// Waits on this condition variable for a notification, timing out after a /// specified duration. /// - /// The semantics of this function are equivalent to `wait()` except that + /// The semantics of this function are equivalent to [`wait`] except that /// the thread will be blocked for roughly no longer than `dur`. This /// method should not be used for precise timing due to anomalies such as /// preemption or platform differences that may not cause the maximum @@ -175,11 +295,47 @@ impl Condvar { /// measured with a monotonic clock, and not affected by the changes made to /// the system time. /// - /// The returned `WaitTimeoutResult` value indicates if the timeout is + /// The returned [`WaitTimeoutResult`] value indicates if the timeout is /// known to have elapsed. /// - /// Like `wait`, the lock specified will be re-acquired when this function + /// Like [`wait`], the lock specified will be re-acquired when this function /// returns, regardless of whether the timeout elapsed or not. + /// + /// [`wait`]: #method.wait + /// [`WaitTimeoutResult`]: struct.WaitTimeoutResult.html + /// + /// # Examples + /// + /// ``` + /// use std::sync::{Arc, Mutex, Condvar}; + /// use std::thread; + /// use std::time::Duration; + /// + /// let pair = Arc::new((Mutex::new(false), Condvar::new())); + /// let pair2 = pair.clone(); + /// + /// thread::spawn(move|| { + /// let &(ref lock, ref cvar) = &*pair2; + /// let mut started = lock.lock().unwrap(); + /// *started = true; + /// // We notify the condvar that the value has changed. + /// cvar.notify_one(); + /// }); + /// + /// // wait for the thread to start up + /// let &(ref lock, ref cvar) = &*pair; + /// let mut started = lock.lock().unwrap(); + /// // as long as the value inside the `Mutex` is false, we wait + /// loop { + /// let result = cvar.wait_timeout(started, Duration::from_millis(10)).unwrap(); + /// // 10 milliseconds have passed, or maybe the value changed! + /// started = result.0; + /// if *started == true { + /// // We received the notification and the value has been updated, we can leave. + /// break + /// } + /// } + /// ``` #[stable(feature = "wait_timeout", since = "1.5.0")] pub fn wait_timeout<'a, T>(&self, guard: MutexGuard<'a, T>, dur: Duration) @@ -200,10 +356,40 @@ impl Condvar { /// Wakes up one blocked thread on this condvar. /// /// If there is a blocked thread on this condition variable, then it will - /// be woken up from its call to `wait` or `wait_timeout`. Calls to + /// be woken up from its call to [`wait`] or [`wait_timeout`]. Calls to /// `notify_one` are not buffered in any way. /// - /// To wake up all threads, see `notify_all()`. + /// To wake up all threads, see [`notify_all()`]. + /// + /// [`wait`]: #method.wait + /// [`wait_timeout`]: #method.wait_timeout + /// [`notify_all()`]: #method.notify_all + /// + /// # Examples + /// + /// ``` + /// use std::sync::{Arc, Mutex, Condvar}; + /// use std::thread; + /// + /// let pair = Arc::new((Mutex::new(false), Condvar::new())); + /// let pair2 = pair.clone(); + /// + /// thread::spawn(move|| { + /// let &(ref lock, ref cvar) = &*pair2; + /// let mut started = lock.lock().unwrap(); + /// *started = true; + /// // We notify the condvar that the value has changed. + /// cvar.notify_one(); + /// }); + /// + /// // Wait for the thread to start up. + /// let &(ref lock, ref cvar) = &*pair; + /// let mut started = lock.lock().unwrap(); + /// // As long as the value inside the `Mutex` is false, we wait. + /// while !*started { + /// started = cvar.wait(started).unwrap(); + /// } + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn notify_one(&self) { unsafe { self.inner.notify_one() } @@ -215,7 +401,35 @@ impl Condvar { /// variable are awoken. Calls to `notify_all()` are not buffered in any /// way. /// - /// To wake up only one thread, see `notify_one()`. + /// To wake up only one thread, see [`notify_one()`]. + /// + /// [`notify_one()`]: #method.notify_one + /// + /// # Examples + /// + /// ``` + /// use std::sync::{Arc, Mutex, Condvar}; + /// use std::thread; + /// + /// let pair = Arc::new((Mutex::new(false), Condvar::new())); + /// let pair2 = pair.clone(); + /// + /// thread::spawn(move|| { + /// let &(ref lock, ref cvar) = &*pair2; + /// let mut started = lock.lock().unwrap(); + /// *started = true; + /// // We notify the condvar that the value has changed. + /// cvar.notify_all(); + /// }); + /// + /// // Wait for the thread to start up. + /// let &(ref lock, ref cvar) = &*pair; + /// let mut started = lock.lock().unwrap(); + /// // As long as the value inside the `Mutex` is false, we wait. + /// while !*started { + /// started = cvar.wait(started).unwrap(); + /// } + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn notify_all(&self) { unsafe { self.inner.notify_all() } From 8c8eda8ecd00f6fa145448dc81e746ab8c8113b7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 23 Feb 2017 12:51:28 +0100 Subject: [PATCH 10/20] Fix nightly-only experimental API display --- src/librustdoc/html/render.rs | 8 ++++---- src/test/rustdoc/issue-27759.rs | 4 ++-- src/test/rustdoc/issue-32374.rs | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index ae4c94d4b38c0..bb39c8c4f22ff 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1878,7 +1878,7 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec 0 => - format!(" ({} #{})", + format!(" ({} #{})", Escape(&stab.feature), tracker_url, issue_no, issue_no), (false, &Some(ref tracker_url), Some(issue_no)) if issue_no > 0 => format!(" (#{})", Escape(&tracker_url), issue_no, @@ -1890,12 +1890,12 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec\ 🔬 \ - This is a nightly-only experimental API.  {}\ + This is a nightly-only experimental API. {}\ ", - unstable_extra)); + unstable_extra)); } else { let text = format!("🔬 \ - This is a nightly-only experimental API.  {}\ + This is a nightly-only experimental API. {}\ {}", unstable_extra, MarkdownHtml(&stab.unstable_reason)); stability.push(format!("
{}
", diff --git a/src/test/rustdoc/issue-27759.rs b/src/test/rustdoc/issue-27759.rs index fe40ce2bd7ddb..e82e93230aa07 100644 --- a/src/test/rustdoc/issue-27759.rs +++ b/src/test/rustdoc/issue-27759.rs @@ -14,12 +14,12 @@ #![unstable(feature="test", issue="27759")] // @has issue_27759/unstable/index.html -// @has - 'test' +// @has - 'test ' // @has - '#27759' #[unstable(feature="test", issue="27759")] pub mod unstable { // @has issue_27759/unstable/fn.issue.html - // @has - 'test_function' + // @has - 'test_function ' // @has - '#1234567890' #[unstable(feature="test_function", issue="1234567890")] pub fn issue() {} diff --git a/src/test/rustdoc/issue-32374.rs b/src/test/rustdoc/issue-32374.rs index 5cca370829201..6d1f8bc1cf9ba 100644 --- a/src/test/rustdoc/issue-32374.rs +++ b/src/test/rustdoc/issue-32374.rs @@ -18,10 +18,10 @@ // @has issue_32374/struct.T.html '//*[@class="stab deprecated"]' \ // 'Deprecated since 1.0.0: text' -// @has - 'test' +// @has - 'test ' // @has - '#32374' // @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' \ -// '🔬 This is a nightly-only experimental API. \(test #32374\)$' +// '🔬 This is a nightly-only experimental API. \(test #32374\)$' #[rustc_deprecated(since = "1.0.0", reason = "text")] #[unstable(feature = "test", issue = "32374")] pub struct T; @@ -29,11 +29,11 @@ pub struct T; // @has issue_32374/struct.U.html '//*[@class="stab deprecated"]' \ // 'Deprecated since 1.0.0: deprecated' // @has issue_32374/struct.U.html '//*[@class="stab unstable"]' \ -// '🔬 This is a nightly-only experimental API. (test #32374)' +// '🔬 This is a nightly-only experimental API. (test #32374)' // @has issue_32374/struct.U.html '//details' \ -// '🔬 This is a nightly-only experimental API. (test #32374)' +// '🔬 This is a nightly-only experimental API. (test #32374)' // @has issue_32374/struct.U.html '//summary' \ -// '🔬 This is a nightly-only experimental API. (test #32374)' +// '🔬 This is a nightly-only experimental API. (test #32374)' // @has issue_32374/struct.U.html '//details/p' \ // 'unstable' #[rustc_deprecated(since = "1.0.0", reason = "deprecated")] From 98fd50a0793e7430c8b8ee2fba67fad83c668ab3 Mon Sep 17 00:00:00 2001 From: Ben Schreiber Date: Sat, 25 Feb 2017 21:42:22 -0600 Subject: [PATCH 11/20] teach rustc about remove_stable_features and removed no-stack-chech feature. fixes #34915 --- src/libsyntax/feature_gate.rs | 31 ++++++++++++++----- .../compile-fail/deprecated_no_stack_check.rs | 16 ++++++++++ 2 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 src/test/compile-fail/deprecated_no_stack_check.rs diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index c2b72edb66c6c..4b23345719775 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -77,12 +77,19 @@ macro_rules! declare_features { }; ($((removed, $feature: ident, $ver: expr, $issue: expr),)+) => { - /// Represents features which has since been removed (it was once Active) + /// Represents unstable features which have since been removed (it was once Active) const REMOVED_FEATURES: &'static [(&'static str, &'static str, Option)] = &[ $((stringify!($feature), $ver, $issue)),+ ]; }; + ($((stable_removed, $feature: ident, $ver: expr, $issue: expr),)+) => { + /// Represents stable features which have since been removed (it was once Accepted) + const STABLE_REMOVED_FEATURES: &'static [(&'static str, &'static str, Option)] = &[ + $((stringify!($feature), $ver, $issue)),+ + ]; + }; + ($((accepted, $feature: ident, $ver: expr, $issue: expr),)+) => { /// Those language feature has since been Accepted (it was once Active) const ACCEPTED_FEATURES: &'static [(&'static str, &'static str, Option)] = &[ @@ -349,6 +356,11 @@ declare_features! ( // rustc internal (removed, unmarked_api, "1.0.0", None), (removed, pushpop_unsafe, "1.2.0", None), + //(removed, no_stack_check, "1.0.0", None), +); + +declare_features! ( + (stable_removed, no_stack_check, "1.0.0", None), ); declare_features! ( @@ -505,9 +517,6 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG not yet settled", cfg_fn!(structural_match))), - // Not used any more, but we can't feature gate it - ("no_stack_check", Normal, Ungated), - ("plugin", CrateLevel, Gated(Stability::Unstable, "plugin", "compiler plugins are experimental \ @@ -909,8 +918,10 @@ fn find_lang_feature_issue(feature: &str) -> Option { // assert!(issue.is_some()) issue } else { - // search in Accepted or Removed features - match ACCEPTED_FEATURES.iter().chain(REMOVED_FEATURES).find(|t| t.0 == feature) { + // search in Accepted, Removed, or Stable Removed features + let found = ACCEPTED_FEATURES.iter().chain(REMOVED_FEATURES).chain(STABLE_REMOVED_FEATURES) + .find(|t| t.0 == feature); + match found { Some(&(_, _, issue)) => issue, None => panic!("Feature `{}` is not declared anywhere", feature), } @@ -1444,9 +1455,15 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute]) -> F feature_checker.collect(&features, mi.span); } else if let Some(&(_, _, _)) = REMOVED_FEATURES.iter() - .find(|& &(n, _, _)| name == n) { + .find(|& &(n, _, _)| name == n) + .or_else(|| STABLE_REMOVED_FEATURES.iter() + .find(|& &(n, _, _)| name == n)) { span_err!(span_handler, mi.span, E0557, "feature has been removed"); } + //else if let Some(&(_, _, _)) = STABLE_REMOVED_FEATURES.iter() + // .find(|& &(n, _, _)| name == n) { + // span_err!(span_handler, mi.span, E0557, "feature has been removed"); + //} else if let Some(&(_, _, _)) = ACCEPTED_FEATURES.iter() .find(|& &(n, _, _)| name == n) { features.declared_stable_lang_features.push((name, mi.span)); diff --git a/src/test/compile-fail/deprecated_no_stack_check.rs b/src/test/compile-fail/deprecated_no_stack_check.rs new file mode 100644 index 0000000000000..38aaefd52b342 --- /dev/null +++ b/src/test/compile-fail/deprecated_no_stack_check.rs @@ -0,0 +1,16 @@ +// Copyright 2013 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. + +#![deny(warnings)] +#![feature(no_stack_check)] +//~^ ERROR: 12:12: 12:26: feature has been removed [E0557] +fn main() { + +} From 9c5e4afb17ce10d9411af3a7e0fae1ce45b1637d Mon Sep 17 00:00:00 2001 From: Ben Schreiber Date: Sat, 25 Feb 2017 21:49:24 -0600 Subject: [PATCH 12/20] removed unneeded comment blocks --- src/libsyntax/feature_gate.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 4b23345719775..1e6ded2019581 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -356,7 +356,6 @@ declare_features! ( // rustc internal (removed, unmarked_api, "1.0.0", None), (removed, pushpop_unsafe, "1.2.0", None), - //(removed, no_stack_check, "1.0.0", None), ); declare_features! ( @@ -1460,10 +1459,6 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute]) -> F .find(|& &(n, _, _)| name == n)) { span_err!(span_handler, mi.span, E0557, "feature has been removed"); } - //else if let Some(&(_, _, _)) = STABLE_REMOVED_FEATURES.iter() - // .find(|& &(n, _, _)| name == n) { - // span_err!(span_handler, mi.span, E0557, "feature has been removed"); - //} else if let Some(&(_, _, _)) = ACCEPTED_FEATURES.iter() .find(|& &(n, _, _)| name == n) { features.declared_stable_lang_features.push((name, mi.span)); From 8079bf35c596eef32ec872d35e28c90e4744f61e Mon Sep 17 00:00:00 2001 From: Robin Stocker Date: Mon, 27 Feb 2017 17:01:47 +1100 Subject: [PATCH 13/20] Example for how to provide stdin using std::process::Command Spawning a child process and writing to its stdin is a bit tricky due to `as_mut` and having to use a limited borrow. An example for this might help newer users. --- src/libstd/process.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 4ff35738b50fb..f846ef3e69e09 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -27,6 +27,31 @@ //! //! assert!(ecode.success()); //! ``` +//! +//! Calling a command with input and reading its output: +//! +//! ```no_run +//! use std::process::{Command, Stdio}; +//! use std::io::Write; +//! +//! let mut child = Command::new("/bin/cat") +//! .stdin(Stdio::piped()) +//! .stdout(Stdio::piped()) +//! .spawn() +//! .expect("failed to execute child"); +//! +//! { +//! // limited borrow of stdin +//! let stdin = child.stdin.as_mut().expect("failed to get stdin"); +//! stdin.write_all(b"test").expect("failed to write to stdin"); +//! } +//! +//! let output = child +//! .wait_with_output() +//! .expect("failed to wait on child"); +//! +//! assert_eq!(b"test", output.stdout.as_slice()); +//! ``` #![stable(feature = "process", since = "1.0.0")] From e998666a776dc73bd7c1c2ca7edde8ece48dfd36 Mon Sep 17 00:00:00 2001 From: Hiroki Kobayashi Date: Tue, 28 Feb 2017 00:47:24 +0900 Subject: [PATCH 14/20] Remove unnecessary "for" --- src/doc/book/src/procedural-macros.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/book/src/procedural-macros.md b/src/doc/book/src/procedural-macros.md index 4f5a6a7c0332d..e02b5a6cdd79b 100644 --- a/src/doc/book/src/procedural-macros.md +++ b/src/doc/book/src/procedural-macros.md @@ -128,7 +128,7 @@ pub fn hello_world(input: TokenStream) -> TokenStream { So there is a lot going on here. We have introduced two new crates: [`syn`] and [`quote`]. As you may have noticed, `input: TokenSteam` is immediately converted to a `String`. This `String` is a string representation of the Rust code for which -we are deriving `HelloWorld` for. At the moment, the only thing you can do with a +we are deriving `HelloWorld`. At the moment, the only thing you can do with a `TokenStream` is convert it to a string. A richer API will exist in the future. So what we really need is to be able to _parse_ Rust code into something From c0dfea62519d3194ba28620f722a18b822725155 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 15 Feb 2017 14:55:26 -0800 Subject: [PATCH 15/20] Add Cargo as a submodule --- .gitmodules | 3 + src/Cargo.lock | 632 ++++++++++++++++++++++++++++++++- src/Cargo.toml | 1 + src/tools/cargo | 1 + src/tools/cargotest/Cargo.toml | 2 +- 5 files changed, 625 insertions(+), 14 deletions(-) create mode 160000 src/tools/cargo diff --git a/.gitmodules b/.gitmodules index 86c5c780c5eb2..2beff77267efa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -18,3 +18,6 @@ [submodule "src/liblibc"] path = src/liblibc url = https://github.com/rust-lang/libc.git +[submodule "src/tools/cargo"] + path = src/tools/cargo + url = https://github.com/rust-lang/cargo diff --git a/src/Cargo.lock b/src/Cargo.lock index 16a641cc96d15..70cca1d5717ba 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -6,6 +6,23 @@ dependencies = [ "libc 0.0.0", ] +[[package]] +name = "advapi32-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "aho-corasick" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "aho-corasick" version = "0.6.2" @@ -73,6 +90,11 @@ dependencies = [ "toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "bufstream" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "build-manifest" version = "0.1.0" @@ -88,9 +110,74 @@ dependencies = [ "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "cargo" +version = "0.18.0" +dependencies = [ + "advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cargotest 0.1.0", + "crates-io 0.7.0", + "crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "docopt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "fs2 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", + "handlebars 0.25.1 (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.20 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "miow 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)", + "psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "shell-escape 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tar 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cargotest" version = "0.1.0" +dependencies = [ + "bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cargo 0.18.0", + "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "hamcrest 0.1.1 (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.20 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tar 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cargotest2" +version = "0.1.0" + +[[package]] +name = "cfg-if" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "clap" @@ -101,7 +188,7 @@ dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "term_size 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "term_size 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -146,6 +233,56 @@ dependencies = [ name = "core" version = "0.0.0" +[[package]] +name = "crates-io" +version = "0.7.0" +dependencies = [ + "curl 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "curl" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "curl-sys 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-probe 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "curl-sys" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gcc 0.3.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "docopt" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "dtoa" version = "0.4.1" @@ -188,15 +325,48 @@ dependencies = [ "gcc 0.3.43 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "flate2" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz-sys 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fmt_macros" version = "0.0.0" +[[package]] +name = "foreign-types" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "fs2" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "gcc" version = "0.3.43" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "gdi32-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "getopts" version = "0.0.0" @@ -206,13 +376,51 @@ name = "getopts" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "git2" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-probe 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "git2-curl" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "curl 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "glob" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "graphviz" version = "0.0.0" +[[package]] +name = "hamcrest" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "handlebars" -version = "0.25.0" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -221,7 +429,17 @@ dependencies = [ "quick-error 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "idna" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-bidi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -255,6 +473,43 @@ name = "libc" version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "libgit2-sys" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cmake 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "curl-sys 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "libssh2-sys 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "libssh2-sys" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cmake 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "libz-sys" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gcc 0.3.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "linkchecker" version = "0.1.0" @@ -268,6 +523,11 @@ name = "log" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "matches" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "mdbook" version = "0.0.16" @@ -275,16 +535,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clap 2.20.5 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "handlebars 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)", + "handlebars 0.25.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "open 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "memchr" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "memchr" version = "1.0.1" @@ -293,6 +561,99 @@ dependencies = [ "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "miniz-sys" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gcc 0.3.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miow" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "net2" +version = "0.2.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.0 (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.20 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-bigint 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", + "num-complex 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", + "num-iter 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", + "num-rational 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-bigint" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-complex" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-integer" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-iter" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-rational" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-bigint 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "num-traits" version = "0.1.36" @@ -306,11 +667,48 @@ dependencies = [ "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "num_cpus" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "open" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "openssl" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "openssl-probe" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "openssl-sys" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gcc 0.3.43 (registry+https://github.com/rust-lang/crates.io-index)", + "gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "panic_abort" version = "0.0.0" @@ -334,6 +732,11 @@ name = "pest" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "pkg-config" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "proc_macro" version = "0.0.0" @@ -350,6 +753,15 @@ dependencies = [ "syntax_pos 0.0.0", ] +[[package]] +name = "psapi-sys" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "pulldown-cmark" version = "0.0.8" @@ -379,6 +791,26 @@ dependencies = [ "core 0.0.0", ] +[[package]] +name = "rand" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex" +version = "0.1.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "regex" version = "0.2.1" @@ -387,10 +819,15 @@ dependencies = [ "aho-corasick 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "regex-syntax" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "regex-syntax" version = "0.4.0" @@ -767,6 +1204,19 @@ dependencies = [ "syntax_pos 0.0.0", ] +[[package]] +name = "semver" +version = "0.6.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)", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "serde" version = "0.9.7" @@ -774,7 +1224,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_json" -version = "0.9.6" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -787,6 +1237,11 @@ dependencies = [ name = "serialize" version = "0.0.0" +[[package]] +name = "shell-escape" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "std" version = "0.0.0" @@ -854,13 +1309,39 @@ dependencies = [ "serialize 0.0.0", ] +[[package]] +name = "tar" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tempdir" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "term" version = "0.0.0" +[[package]] +name = "term" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "term_size" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -876,6 +1357,15 @@ dependencies = [ "term 0.0.0", ] +[[package]] +name = "thread-id" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "thread-id" version = "3.0.0" @@ -887,7 +1377,15 @@ dependencies = [ [[package]] name = "thread_local" -version = "0.3.2" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "thread_local" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "thread-id 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -906,6 +1404,14 @@ dependencies = [ "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "toml" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "toml" version = "0.3.0" @@ -914,6 +1420,19 @@ dependencies = [ "serde 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "unicode-bidi" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unicode-segmentation" version = "1.1.0" @@ -932,6 +1451,29 @@ dependencies = [ "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "url" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "user32-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "utf8-ranges" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "utf8-ranges" version = "1.0.0" @@ -957,49 +1499,113 @@ name = "winapi-build" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [metadata] +"checksum advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e06588080cb19d0acb6739808aafa5f26bfb2ca015b2b6370028b44cf7cb8a9a" +"checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" "checksum aho-corasick 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0638fd549427caa90c499814196d1b9e3725eb4d15d7339d6de073a680ed0ca2" "checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6" "checksum bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4f67931368edf3a9a51d29886d245f1c3db2f1ef0dcc9e35ff70341b78c10d23" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" +"checksum bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7b48dbe2ff0e98fa2f03377d204a9637d3c9816cd431bfe05a8abbd0ea11d074" +"checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c" "checksum clap 2.20.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7db281b0520e97fbd15cd615dcd8f8bcad0c26f5f7d5effe705f090f39e9a758" "checksum cmake 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "a3a6805df695087e7c1bcd9a82e03ad6fb864c8e67ac41b1348229ce5b7f0407" +"checksum crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0c5ea215664ca264da8a9d9c3be80d2eaf30923c259d03e870388eb927508f97" +"checksum curl 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c90e1240ef340dd4027ade439e5c7c2064dd9dc652682117bd50d1486a3add7b" +"checksum curl-sys 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d909dc402ae80b6f7b0118c039203436061b9d9a3ca5d2c2546d93e0a61aaa" +"checksum docopt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab32ea6e284d87987066f21a9e809a73c14720571ef34516f0890b3d355ccfd8" "checksum dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80c8b71fd71146990a9742fc06dcbbde19161a267e0ad4e572c35162f4578c90" "checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f" "checksum env_logger 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "99971fb1b635fe7a0ee3c4d065845bb93cca80a23b5613b5613391ece5de4144" "checksum filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5363ab8e4139b8568a6237db5248646e5a8a2f89bd5ccb02092182b11fd3e922" +"checksum flate2 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "d4e4d0c15ef829cbc1b7cda651746be19cceeb238be7b1049227b14891df9e25" +"checksum foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e4056b9bd47f8ac5ba12be771f77a0dae796d1bbaaf5fd0b9c2d38b69b8a29d" +"checksum fs2 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34edaee07555859dc13ca387e6ae05686bb4d0364c95d649b6dab959511f4baf" "checksum gcc 0.3.43 (registry+https://github.com/rust-lang/crates.io-index)" = "c07c758b972368e703a562686adb39125707cc1ef3399da8c019fc6c2498a75d" +"checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518" "checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685" -"checksum handlebars 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b930077f1422bf853008047b55896efc1409744bfc9903f1eec1a58fcc7edeff" +"checksum git2 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "046ae03385257040b2a35e56d9669d950dd911ba2bf48202fbef73ee6aab27b2" +"checksum git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "68676bc784bf0bef83278898929bf64a251e87c0340723d0b93fa096c9c5bf8e" +"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" +"checksum hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bf088f042a467089e9baa4972f57f9247e42a0cc549ba264c7a04fbb8ecb89d4" +"checksum handlebars 0.25.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b2249f6f0dc5a3bb2b3b1a8f797dfccbc4b053344d773d654ad565e51427d335" +"checksum idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1053236e00ce4f668aeca4a769a09b3bf5a682d802abd6f3cb39374f6b162c11" "checksum itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2f404fbc66fd9aac13e998248505e7ecb2ad8e44ab6388684c5fb11c6c251c" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6abe0ee2e758cd6bc8a2cd56726359007748fbf4128da998b65d0b70f881e19b" "checksum libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" = "684f330624d8c3784fb9558ca46c4ce488073a8d22450415c5eb4f4cfb0d11b5" +"checksum libgit2-sys 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "d951fd5eccae07c74e8c2c1075b05ea1e43be7f8952245af8c2840d1480b1d95" +"checksum libssh2-sys 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "91e135645c2e198a39552c8c7686bb5b83b1b99f64831c040a6c2798a1195934" +"checksum libz-sys 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e5ee912a45d686d393d5ac87fac15ba0ba18daae14e8e7543c63ebf7fb7e970c" "checksum log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054" +"checksum matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efd7622e3022e1a6eaa602c4cea8912254e5582c9c692e9167714182244801b1" "checksum mdbook 0.0.16 (registry+https://github.com/rust-lang/crates.io-index)" = "14e8a6aca534ac51bad1c1886b10f6d6948a14fa70b1b20a1e41c9e5c0fe3019" +"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" "checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4" +"checksum miniz-sys 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "28eaee17666671fa872e567547e8428e83308ebe5808cdf6a0e28397dbe2c726" +"checksum miow 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3a78d2605eb97302c10cf944b8d96b0a2a890c52957caf92fcd1f24f69049579" +"checksum net2 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)" = "5edf9cb6be97212423aed9413dd4729d62b370b5e1c571750e882cebbbc1e3e2" +"checksum num 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "bde7c03b09e7c6a301ee81f6ddf66d7a28ec305699e3d3b056d2fc56470e3120" +"checksum num-bigint 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "88b14378471f7c2adc5262f05b4701ef53e8da376453a8d8fee48e51db745e49" +"checksum num-complex 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "f0c78e054dd19c3fd03419ade63fa661e9c49bb890ce3beb4eee5b7baf93f92f" +"checksum num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "fb24d9bfb3f222010df27995441ded1e954f8f69cd35021f6bef02ca9552fb92" +"checksum num-iter 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "287a1c9969a847055e1122ec0ea7a5c5d6f72aad97934e131c83d5c08ab4e45c" +"checksum num-rational 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "54ff603b8334a72fbb27fe66948aac0abaaa40231b3cecd189e76162f6f38aaf" "checksum num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "a16a42856a256b39c6d3484f097f6713e14feacd9bfb02290917904fae46c81c" "checksum num_cpus 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "cee7e88156f3f9e19bdd598f8d6c9db7bf4078f99f8381f43a55b09648d1a6e3" +"checksum num_cpus 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a225d1e2717567599c24f88e49f00856c6e825a12125181ee42c4257e3688d39" "checksum open 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3478ed1686bd1300c8a981a940abc92b06fac9cbef747f4c668d4e032ff7b842" +"checksum openssl 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f9871ecf7629da3760599e3e547d35940cff3cead49159b49f81cd1250f24f1d" +"checksum openssl-probe 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "756d49c8424483a3df3b5d735112b4da22109ced9a8294f1f5cdf80fb3810919" +"checksum openssl-sys 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)" = "5dd48381e9e8a6dce9c4c402db143b2e243f5f872354532f7a009c289b3998ca" "checksum pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0a6dda33d67c26f0aac90d324ab2eb7239c819fc7b2552fe9faa4fe88441edc8" +"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" +"checksum psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "abcd5d1a07d360e29727f757a9decb3ce8bc6e0efa8969cfaad669a8317a2478" "checksum pulldown-cmark 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1058d7bb927ca067656537eec4e02c2b4b70eaaa129664c5b90c111e20326f41" "checksum quick-error 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0aad603e8d7fb67da22dbdf1f4b826ce8829e406124109e73cf1b2454b93a71c" +"checksum rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "022e0636ec2519ddae48154b028864bdce4eaf7d35226ab8e65c611be97b189d" +"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" "checksum regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4278c17d0f6d62dfef0ab00028feb45bd7d2102843f80763474eeb1be8a10c01" +"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" "checksum regex-syntax 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9191b1f57603095f105d317e375d19b1c9c5c3185ea9633a99a6dcbed04457" "checksum rustc-serialize 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "237546c689f20bb44980270c73c3b9edd0891c1be49cc1274406134a66d3957b" +"checksum semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537" +"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1e0ed773960f90a78567fcfbe935284adf50c5d7cf119aa2cf43bb0b4afa69bb" -"checksum serde_json 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e095e4e94e7382b76f48e93bd845ffddda62df8dfd4c163b1bfa93d40e22e13a" +"checksum serde_json 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)" = "2eb96d30e4e6f9fc52e08f51176d078b6f79b981dc3ed4134f7b850be9f446a8" +"checksum shell-escape 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "dd5cc96481d54583947bfe88bf30c23d53f883c6cd0145368b69989d97b84ef8" "checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694" -"checksum term_size 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "71662702fe5cd2cf95edd4ad655eea42f24a87a0e44059cbaa4e55260b7bc331" +"checksum tar 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "1eb3bf6ec92843ca93f4fcfb5fc6dfe30534815b147885db4b5759b8e2ff7d52" +"checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6" +"checksum term 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d168af3930b369cfe245132550579d47dfd873d69470755a19c2c6568dbbd989" +"checksum term_size 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "07b6c1ac5b3fffd75073276bca1ceed01f67a28537097a2a9539e116e50fb21a" +"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" "checksum thread-id 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4437c97558c70d129e40629a5b385b3fb1ffac301e63941335e4d354081ec14a" -"checksum thread_local 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7793b722f0f77ce716e7f1acf416359ca32ff24d04ffbac4269f44a4a83be05d" +"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" +"checksum thread_local 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c85048c6260d17cf486ceae3282d9fb6b90be220bf5b28c400f5485ffc29f0c7" "checksum toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "0590d72182e50e879c4da3b11c6488dae18fccb1ae0c7a3eda18e16795844796" +"checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4" "checksum toml 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "08272367dd2e766db3fa38f068067d17aa6a9dfd7259af24b3927db92f1e0c2f" +"checksum unicode-bidi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d3a078ebdd62c0e71a709c3d53d2af693fe09fe93fbff8344aebe289b78f9032" +"checksum unicode-normalization 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e28fa37426fceeb5cf8f41ee273faa7c82c47dc8fba5853402841e665fcd86ff" "checksum unicode-segmentation 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18127285758f0e2c6cf325bb3f3d138a12fee27de4f23e146cd6a179f26c2cf3" "checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f" "checksum unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f2ae5ddb18e1c92664717616dd9549dde73f539f01bd7b77c2edb2446bdff91" +"checksum url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5ba8a749fb4479b043733416c244fa9d1d3af3d7c23804944651c8a448cb87e" +"checksum user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47" +"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" "checksum vec_map 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cac5efe5cb0fa14ec2f84f83c701c562ee63f6dcc680861b21d65c682adfb05f" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" +"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" diff --git a/src/Cargo.toml b/src/Cargo.toml index 0dafbb8428e3e..c5ca80accbf02 100644 --- a/src/Cargo.toml +++ b/src/Cargo.toml @@ -13,6 +13,7 @@ members = [ "tools/build-manifest", "tools/qemu-test-client", "tools/qemu-test-server", + "tools/cargo", ] # Curiously, compiletest will segfault if compiled with opt-level=3 on 64-bit diff --git a/src/tools/cargo b/src/tools/cargo new file mode 160000 index 0000000000000..6ed5a43bb566e --- /dev/null +++ b/src/tools/cargo @@ -0,0 +1 @@ +Subproject commit 6ed5a43bb566e0ee3fe7981de5aa5a36e2905ebd diff --git a/src/tools/cargotest/Cargo.toml b/src/tools/cargotest/Cargo.toml index 8108c7f762eeb..f4163a6f1170a 100644 --- a/src/tools/cargotest/Cargo.toml +++ b/src/tools/cargotest/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cargotest" +name = "cargotest2" version = "0.1.0" authors = ["Brian Anderson "] From b70f929396b09de5557e9432417488981b960eb6 Mon Sep 17 00:00:00 2001 From: Josef Brandl Date: Mon, 27 Feb 2017 21:49:05 +0100 Subject: [PATCH 16/20] Make lifetime elision docs clearer --- src/doc/book/src/lifetimes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/book/src/lifetimes.md b/src/doc/book/src/lifetimes.md index 8bca13c28f0bd..042d9af9717d0 100644 --- a/src/doc/book/src/lifetimes.md +++ b/src/doc/book/src/lifetimes.md @@ -349,8 +349,8 @@ to it. ## Lifetime Elision -Rust supports powerful local type inference in the bodies of functions but not in their item signatures. -It's forbidden to allow reasoning about types based on the item signature alone. +Rust supports powerful local type inference in the bodies of functions, but it +deliberately does not perform any reasoning about types for item signatures. However, for ergonomic reasons, a very restricted secondary inference algorithm called “lifetime elision” does apply when judging lifetimes. Lifetime elision is concerned solely with inferring lifetime parameters using three easily memorizable and unambiguous rules. This means lifetime elision From 988be44c36f320e1aff08a0cf9a531441477b9d7 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Thu, 23 Feb 2017 14:04:09 +0900 Subject: [PATCH 17/20] Add compile fail test for unboxed_closures feature --- .../feature-gate-unboxed-closures.rs | 24 +++++++++++++++++++ src/tools/tidy/src/features.rs | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 src/test/compile-fail/feature-gate-unboxed-closures.rs diff --git a/src/test/compile-fail/feature-gate-unboxed-closures.rs b/src/test/compile-fail/feature-gate-unboxed-closures.rs new file mode 100644 index 0000000000000..4005021774443 --- /dev/null +++ b/src/test/compile-fail/feature-gate-unboxed-closures.rs @@ -0,0 +1,24 @@ +// 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 FnOnce<(u32, u32)> for Test { + type Output = u32; + + extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { + a + b + } + //~^^^ ERROR rust-call ABI is subject to change (see issue #29625) +} + +fn main() { + assert_eq!(Test(1u32, 2u32), 3u32); +} diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 2c81382bc9b08..c84fefd872e47 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -169,8 +169,8 @@ pub fn check(path: &Path, bad: &mut bool) { let whitelist = vec![ "abi_ptx", "simd", "cfg_target_has_atomic", - "unboxed_closures", "stmt_expr_attributes", - "cfg_target_thread_local", "unwind_attributes" + "stmt_expr_attributes", + "cfg_target_thread_local", "unwind_attributes", ]; // Only check the number of lang features. From 6f24c6a09dbffb36c2363a7750eda0008772bce5 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 15 Feb 2017 15:57:06 -0800 Subject: [PATCH 18/20] rustbuild: Add support for compiling Cargo This commit adds support to rustbuild for compiling Cargo as part of the release process. Previously rustbuild would simply download a Cargo snapshot and repackage it. With this change we should be able to turn off artifacts from the rust-lang/cargo repository and purely rely on the artifacts Cargo produces here. The infrastructure added here is intended to be extensible to other components, such as the RLS. It won't exactly be a one-line addition, but the addition of Cargo didn't require too much hooplah anyway. The process for release Cargo will now look like: * The rust-lang/rust repository has a Cargo submodule which is used to build a Cargo to pair with the rust-lang/rust release * Periodically we'll update the cargo submodule as necessary on rust-lang/rust's master branch * When branching beta we'll create a new branch of Cargo (as we do today), and the first commit to the beta branch will be to update the Cargo submodule to this exact revision. * When branching stable, we'll ensure that the Cargo submodule is updated and then make a stable release. Backports to Cargo will look like: * Send a PR to cargo's master branch * Send a PR to cargo's release branch (e.g. rust-1.16.0) * Send a PR to rust-lang/rust's beta branch updating the submodule * Eventually send a PR to rust-lang/rust's master branch updating the submodule For reference, the process to add a new component to the rust-lang/rust release would look like: * Add `$foo` as a submodule in `src/tools` * Add a `tool-$foo` step which compiles `$foo` with the specified compiler, likely mirroring what Cargo does. * Add a `dist-$foo` step which uses `src/tools/$foo` and the `tool-$foo` output to create a rust-installer package for `$foo` likely mirroring what Cargo does. * Update the `dist-extended` step with a new dependency on `dist-$foo` * Update `src/tools/build-manifest` for the new component. --- configure | 1 + src/bootstrap/channel.rs | 95 ++++++++++--------- src/bootstrap/compile.rs | 34 +++++-- src/bootstrap/config.rs | 4 + src/bootstrap/config.toml.example | 5 + src/bootstrap/dist.rs | 134 +++++++++++++++------------ src/bootstrap/doc.rs | 9 +- src/bootstrap/install.rs | 4 +- src/bootstrap/lib.rs | 114 ++++++++++++++++++----- src/bootstrap/metadata.rs | 2 + src/bootstrap/native.rs | 100 ++++++++++++++++++++ src/bootstrap/step.rs | 11 ++- src/build_helper/lib.rs | 18 ++++ src/ci/run.sh | 1 + src/tools/build-manifest/src/main.rs | 19 ++-- src/tools/tidy/src/cargo.rs | 2 +- src/tools/tidy/src/deps.rs | 2 + src/tools/tidy/src/main.rs | 1 + 18 files changed, 406 insertions(+), 150 deletions(-) diff --git a/configure b/configure index 70952438a3559..be8628de62832 100755 --- a/configure +++ b/configure @@ -651,6 +651,7 @@ opt locked-deps 0 "force Cargo.lock to be up to date" opt vendor 0 "enable usage of vendored Rust crates" opt sanitizers 0 "build the sanitizer runtimes (asan, lsan, msan, tsan)" opt dist-src 1 "when building tarballs enables building a source tarball" +opt cargo-openssl-static 0 "static openssl in cargo" # Optimization and debugging options. These may be overridden by the release channel, etc. opt_nosave optimize 1 "build optimized rust code" diff --git a/src/bootstrap/channel.rs b/src/bootstrap/channel.rs index 81e745bc76c9e..c126c076a3d4e 100644 --- a/src/bootstrap/channel.rs +++ b/src/bootstrap/channel.rs @@ -15,6 +15,7 @@ //! `package_vers`, and otherwise indicating to the compiler what it should //! print out as part of its version information. +use std::path::Path; use std::process::Command; use build_helper::output; @@ -22,65 +23,69 @@ use build_helper::output; use Build; // The version number -const CFG_RELEASE_NUM: &'static str = "1.17.0"; +pub const CFG_RELEASE_NUM: &'static str = "1.17.0"; // An optional number to put after the label, e.g. '.2' -> '-beta.2' // Be sure to make this starts with a dot to conform to semver pre-release // versions (section 9) -const CFG_PRERELEASE_VERSION: &'static str = ".1"; +pub const CFG_PRERELEASE_VERSION: &'static str = ".1"; -pub fn collect(build: &mut Build) { - build.release_num = CFG_RELEASE_NUM.to_string(); - build.prerelease_version = CFG_RELEASE_NUM.to_string(); +pub struct GitInfo { + inner: Option, +} - // Depending on the channel, passed in `./configure --release-channel`, - // determine various properties of the build. - match &build.config.channel[..] { - "stable" => { - build.release = CFG_RELEASE_NUM.to_string(); - build.package_vers = build.release.clone(); - build.unstable_features = false; - } - "beta" => { - build.release = format!("{}-beta{}", CFG_RELEASE_NUM, - CFG_PRERELEASE_VERSION); - build.package_vers = "beta".to_string(); - build.unstable_features = false; - } - "nightly" => { - build.release = format!("{}-nightly", CFG_RELEASE_NUM); - build.package_vers = "nightly".to_string(); - build.unstable_features = true; - } - _ => { - build.release = format!("{}-dev", CFG_RELEASE_NUM); - build.package_vers = build.release.clone(); - build.unstable_features = true; - } - } - build.version = build.release.clone(); +struct Info { + commit_date: String, + sha: String, + short_sha: String, +} - // If we have a git directory, add in some various SHA information of what - // commit this compiler was compiled from. - if build.src.join(".git").is_dir() { - let ver_date = output(Command::new("git").current_dir(&build.src) +impl GitInfo { + pub fn new(dir: &Path) -> GitInfo { + if !dir.join(".git").is_dir() { + return GitInfo { inner: None } + } + let ver_date = output(Command::new("git").current_dir(dir) .arg("log").arg("-1") .arg("--date=short") .arg("--pretty=format:%cd")); - let ver_hash = output(Command::new("git").current_dir(&build.src) + let ver_hash = output(Command::new("git").current_dir(dir) .arg("rev-parse").arg("HEAD")); let short_ver_hash = output(Command::new("git") - .current_dir(&build.src) + .current_dir(dir) .arg("rev-parse") .arg("--short=9") .arg("HEAD")); - let ver_date = ver_date.trim().to_string(); - let ver_hash = ver_hash.trim().to_string(); - let short_ver_hash = short_ver_hash.trim().to_string(); - build.version.push_str(&format!(" ({} {})", short_ver_hash, - ver_date)); - build.ver_date = Some(ver_date.to_string()); - build.ver_hash = Some(ver_hash); - build.short_ver_hash = Some(short_ver_hash); + GitInfo { + inner: Some(Info { + commit_date: ver_date.trim().to_string(), + sha: ver_hash.trim().to_string(), + short_sha: short_ver_hash.trim().to_string(), + }), + } + } + + pub fn sha(&self) -> Option<&str> { + self.inner.as_ref().map(|s| &s.sha[..]) + } + + pub fn sha_short(&self) -> Option<&str> { + self.inner.as_ref().map(|s| &s.short_sha[..]) + } + + pub fn commit_date(&self) -> Option<&str> { + self.inner.as_ref().map(|s| &s.commit_date[..]) + } + + pub fn version(&self, build: &Build, num: &str) -> String { + let mut version = build.release(num); + if let Some(ref inner) = self.inner { + version.push_str(" ("); + version.push_str(&inner.short_sha); + version.push_str(" "); + version.push_str(&inner.commit_date); + version.push_str(")"); + } + return version } } diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index cea8b13366657..46d8d4b4aab2d 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -24,6 +24,7 @@ use std::process::Command; use build_helper::{output, mtime, up_to_date}; use filetime::FileTime; +use channel::GitInfo; use util::{exe, libdir, is_dylib, copy}; use {Build, Compiler, Mode}; @@ -210,9 +211,9 @@ pub fn rustc(build: &Build, target: &str, compiler: &Compiler) { // Set some configuration variables picked up by build scripts and // the compiler alike - cargo.env("CFG_RELEASE", &build.release) + cargo.env("CFG_RELEASE", build.rust_release()) .env("CFG_RELEASE_CHANNEL", &build.config.channel) - .env("CFG_VERSION", &build.version) + .env("CFG_VERSION", build.rust_version()) .env("CFG_PREFIX", build.config.prefix.clone().unwrap_or(PathBuf::new())); if compiler.stage == 0 { @@ -229,13 +230,13 @@ pub fn rustc(build: &Build, target: &str, compiler: &Compiler) { cargo.env_remove("RUSTC_DEBUGINFO_LINES"); } - if let Some(ref ver_date) = build.ver_date { + if let Some(ref ver_date) = build.rust_info.commit_date() { cargo.env("CFG_VER_DATE", ver_date); } - if let Some(ref ver_hash) = build.ver_hash { + if let Some(ref ver_hash) = build.rust_info.sha() { cargo.env("CFG_VER_HASH", ver_hash); } - if !build.unstable_features { + if !build.unstable_features() { cargo.env("CFG_DISABLE_UNSTABLE_FEATURES", "1"); } // Flag that rust llvm is in use @@ -416,13 +417,32 @@ pub fn tool(build: &Build, stage: u32, target: &str, tool: &str) { // build.clear_if_dirty(&out_dir, &libstd_stamp(build, stage, &host, target)); let mut cargo = build.cargo(&compiler, Mode::Tool, target, "build"); - cargo.arg("--manifest-path") - .arg(build.src.join(format!("src/tools/{}/Cargo.toml", tool))); + let dir = build.src.join("src/tools").join(tool); + cargo.arg("--manifest-path").arg(dir.join("Cargo.toml")); // We don't want to build tools dynamically as they'll be running across // stages and such and it's just easier if they're not dynamically linked. cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); + if let Some(dir) = build.openssl_install_dir(target) { + cargo.env("OPENSSL_STATIC", "1"); + cargo.env("OPENSSL_DIR", dir); + cargo.env("LIBZ_SYS_STATIC", "1"); + } + + cargo.env("CFG_RELEASE_CHANNEL", &build.config.channel); + + let info = GitInfo::new(&dir); + if let Some(sha) = info.sha() { + cargo.env("CFG_COMMIT_HASH", sha); + } + if let Some(sha_short) = info.sha_short() { + cargo.env("CFG_SHORT_COMMIT_HASH", sha_short); + } + if let Some(date) = info.commit_date() { + cargo.env("CFG_COMMIT_DATE", date); + } + build.run(&mut cargo); } diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 8308dc3202fff..438ce6103d624 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -106,6 +106,7 @@ pub struct Config { pub gdb: Option, pub python: Option, pub configure_args: Vec, + pub openssl_static: bool, } /// Per-target configuration stored in the global configuration structure. @@ -155,6 +156,7 @@ struct Build { extended: Option, verbose: Option, sanitizers: Option, + openssl_static: Option, } /// TOML representation of various global install decisions. @@ -305,6 +307,7 @@ impl Config { set(&mut config.extended, build.extended); set(&mut config.verbose, build.verbose); set(&mut config.sanitizers, build.sanitizers); + set(&mut config.openssl_static, build.openssl_static); if let Some(ref install) = toml.install { config.prefix = install.prefix.clone().map(PathBuf::from); @@ -453,6 +456,7 @@ impl Config { ("EXTENDED", self.extended), ("SANITIZERS", self.sanitizers), ("DIST_SRC", self.rust_dist_src), + ("CARGO_OPENSSL_STATIC", self.openssl_static), } match key { diff --git a/src/bootstrap/config.toml.example b/src/bootstrap/config.toml.example index f95e890f346ee..30763e38a336f 100644 --- a/src/bootstrap/config.toml.example +++ b/src/bootstrap/config.toml.example @@ -134,6 +134,11 @@ # Build the sanitizer runtimes #sanitizers = false +# Indicates whether the OpenSSL linked into Cargo will be statically linked or +# not. If static linkage is specified then the build system will download a +# known-good version of OpenSSL, compile it, and link it to Cargo. +#openssl-static = false + # ============================================================================= # General install configuration options # ============================================================================= diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index c468d4896a614..67e4dad83ce88 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -33,19 +33,12 @@ const SH_CMD: &'static str = "sh"; const SH_CMD: &'static str = "bash"; use {Build, Compiler, Mode}; -use util::{cp_r, libdir, is_dylib, cp_filtered, copy}; - -pub fn package_vers(build: &Build) -> &str { - match &build.config.channel[..] { - "stable" => &build.release, - "beta" => "beta", - "nightly" => "nightly", - _ => &build.release, - } -} +use channel; +use util::{cp_r, libdir, is_dylib, cp_filtered, copy, exe}; fn pkgname(build: &Build, component: &str) -> String { - format!("{}-{}", component, package_vers(build)) + assert!(component.starts_with("rust")); // does not work with cargo + format!("{}-{}", component, build.rust_package_vers()) } fn distdir(build: &Build) -> PathBuf { @@ -93,7 +86,7 @@ pub fn docs(build: &Build, stage: u32, host: &str) { // As part of this step, *also* copy the docs directory to a directory which // buildbot typically uploads. if host == build.config.build { - let dst = distdir(build).join("doc").join(&build.package_vers); + let dst = distdir(build).join("doc").join(build.rust_package_vers()); t!(fs::create_dir_all(&dst)); cp_r(&src, &dst); } @@ -162,7 +155,7 @@ pub fn rustc(build: &Build, stage: u32, host: &str) { cp("LICENSE-MIT"); cp("README.md"); // tiny morsel of metadata is used by rust-packaging - let version = &build.version; + let version = build.rust_version(); t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes())); // On MinGW we've got a few runtime DLL dependencies that we need to @@ -312,7 +305,7 @@ pub fn std(build: &Build, compiler: &Compiler, target: &str) { } pub fn rust_src_location(build: &Build) -> PathBuf { - let plain_name = format!("rustc-{}-src", package_vers(build)); + let plain_name = format!("rustc-{}-src", build.rust_package_vers()); distdir(build).join(&format!("{}.tar.gz", plain_name)) } @@ -477,14 +470,14 @@ pub fn rust_src(build: &Build) { build.run(&mut cmd); // Rename directory, so that root folder of tarball has the correct name - let plain_name = format!("rustc-{}-src", package_vers(build)); + let plain_name = format!("rustc-{}-src", build.rust_package_vers()); let plain_dst_src = tmpdir(build).join(&plain_name); let _ = fs::remove_dir_all(&plain_dst_src); t!(fs::create_dir_all(&plain_dst_src)); cp_r(&dst_src, &plain_dst_src); // Create the version file - write_file(&plain_dst_src.join("version"), build.version.as_bytes()); + write_file(&plain_dst_src.join("version"), build.rust_version().as_bytes()); // Create plain source tarball let mut cmd = Command::new("tar"); @@ -536,43 +529,64 @@ fn write_file(path: &Path, data: &[u8]) { t!(vf.write_all(data)); } -// FIXME(#38531) eventually this should package up a Cargo that we just compiled -// and tested locally, but for now we're downloading cargo -// artifacts from their compiled location. pub fn cargo(build: &Build, stage: u32, target: &str) { println!("Dist cargo stage{} ({})", stage, target); + let compiler = Compiler::new(stage, &build.config.build); - let branch = match &build.config.channel[..] { - "stable" | - "beta" => format!("rust-{}", build.release_num), - _ => "master".to_string(), - }; + let src = build.src.join("src/tools/cargo"); + let etc = src.join("src/etc"); + let release_num = &build.crates["cargo"].version; + let name = format!("cargo-{}", build.package_vers(release_num)); + let version = build.cargo_info.version(build, release_num); + + let tmp = tmpdir(build); + let image = tmp.join("cargo-image"); + drop(fs::remove_dir_all(&image)); + t!(fs::create_dir_all(&image)); - let dst = tmpdir(build).join("cargo"); - let _ = fs::remove_dir_all(&dst); - build.run(Command::new("git") - .arg("clone") - .arg("--depth").arg("1") - .arg("--branch").arg(&branch) - .arg("https://github.com/rust-lang/cargo") - .current_dir(dst.parent().unwrap())); - let sha = output(Command::new("git") - .arg("rev-parse") - .arg("HEAD") - .current_dir(&dst)); - let sha = sha.trim(); - println!("\tgot cargo sha: {}", sha); - - let input = format!("https://s3.amazonaws.com/rust-lang-ci/cargo-builds\ - /{}/cargo-nightly-{}.tar.gz", sha, target); - let output = distdir(build).join(format!("cargo-nightly-{}.tar.gz", target)); - println!("\tdownloading {}", input); - let mut curl = Command::new("curl"); - curl.arg("-f") - .arg("-o").arg(&output) - .arg(&input) - .arg("--retry").arg("3"); - build.run(&mut curl); + // Prepare the image directory + t!(fs::create_dir_all(image.join("share/zsh/site-functions"))); + t!(fs::create_dir_all(image.join("etc/bash_completions.d"))); + let cargo = build.cargo_out(&compiler, Mode::Tool, target) + .join(exe("cargo", target)); + install(&cargo, &image.join("bin"), 0o755); + for man in t!(etc.join("man").read_dir()) { + let man = t!(man); + install(&man.path(), &image.join("share/man/man1"), 0o644); + } + install(&etc.join("_cargo"), &image.join("share/zsh/site-functions"), 0o644); + copy(&etc.join("cargo.bashcomp.sh"), + &image.join("etc/bash_completions.d/cargo")); + let doc = image.join("share/doc/cargo"); + install(&src.join("README.md"), &doc, 0o644); + install(&src.join("LICENSE-MIT"), &doc, 0o644); + install(&src.join("LICENSE-APACHE"), &doc, 0o644); + install(&src.join("LICENSE-THIRD-PARTY"), &doc, 0o644); + + // Prepare the overlay + let overlay = tmp.join("cargo-overlay"); + drop(fs::remove_dir_all(&overlay)); + t!(fs::create_dir_all(&overlay)); + install(&src.join("README.md"), &overlay, 0o644); + install(&src.join("LICENSE-MIT"), &overlay, 0o644); + install(&src.join("LICENSE-APACHE"), &overlay, 0o644); + install(&src.join("LICENSE-THIRD-PARTY"), &overlay, 0o644); + t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes())); + + // Generate the installer tarball + let mut cmd = Command::new("sh"); + cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh"))) + .arg("--product-name=Rust") + .arg("--rel-manifest-dir=rustlib") + .arg("--success-message=Rust-is-ready-to-roll.") + .arg(format!("--image-dir={}", sanitize_sh(&image))) + .arg(format!("--work-dir={}", sanitize_sh(&tmpdir(build)))) + .arg(format!("--output-dir={}", sanitize_sh(&distdir(build)))) + .arg(format!("--non-installed-overlay={}", sanitize_sh(&overlay))) + .arg(format!("--package-name={}-{}", name, target)) + .arg("--component-name=cargo") + .arg("--legacy-manifest-dirs=rustlib,cargo"); + build.run(&mut cmd); } /// Creates a combined installer for the specified target in the provided stage. @@ -580,10 +594,13 @@ pub fn extended(build: &Build, stage: u32, target: &str) { println!("Dist extended stage{} ({})", stage, target); let dist = distdir(build); + let cargo_vers = &build.crates["cargo"].version; let rustc_installer = dist.join(format!("{}-{}.tar.gz", pkgname(build, "rustc"), target)); - let cargo_installer = dist.join(format!("cargo-nightly-{}.tar.gz", target)); + let cargo_installer = dist.join(format!("cargo-{}-{}.tar.gz", + build.package_vers(&cargo_vers), + target)); let docs_installer = dist.join(format!("{}-{}.tar.gz", pkgname(build, "rust-docs"), target)); @@ -603,7 +620,7 @@ pub fn extended(build: &Build, stage: u32, target: &str) { install(&build.src.join("COPYRIGHT"), &overlay, 0o644); install(&build.src.join("LICENSE-APACHE"), &overlay, 0o644); install(&build.src.join("LICENSE-MIT"), &overlay, 0o644); - let version = &build.version; + let version = build.rust_version(); t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes())); install(&etc.join("README.md"), &overlay, 0o644); @@ -876,16 +893,16 @@ pub fn extended(build: &Build, stage: u32, target: &str) { } fn add_env(build: &Build, cmd: &mut Command, target: &str) { - let mut parts = build.release_num.split('.'); - cmd.env("CFG_RELEASE_INFO", &build.version) - .env("CFG_RELEASE_NUM", &build.release_num) - .env("CFG_RELEASE", &build.release) - .env("CFG_PRERELEASE_VERSION", &build.prerelease_version) + let mut parts = channel::CFG_RELEASE_NUM.split('.'); + cmd.env("CFG_RELEASE_INFO", build.rust_version()) + .env("CFG_RELEASE_NUM", channel::CFG_RELEASE_NUM) + .env("CFG_RELEASE", build.rust_release()) + .env("CFG_PRERELEASE_VERSION", channel::CFG_PRERELEASE_VERSION) .env("CFG_VER_MAJOR", parts.next().unwrap()) .env("CFG_VER_MINOR", parts.next().unwrap()) .env("CFG_VER_PATCH", parts.next().unwrap()) .env("CFG_VER_BUILD", "0") // just needed to build - .env("CFG_PACKAGE_VERS", package_vers(build)) + .env("CFG_PACKAGE_VERS", build.rust_package_vers()) .env("CFG_PACKAGE_NAME", pkgname(build, "rust")) .env("CFG_BUILD", target) .env("CFG_CHANNEL", &build.config.channel); @@ -925,7 +942,8 @@ pub fn hash_and_sign(build: &Build) { cmd.arg(sign); cmd.arg(distdir(build)); cmd.arg(today.trim()); - cmd.arg(package_vers(build)); + cmd.arg(build.rust_package_vers()); + cmd.arg(build.cargo_info.version(build, &build.crates["cargo"].version)); cmd.arg(addr); t!(fs::create_dir_all(distdir(build))); diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 5fd6570e1610c..d19e5b1b88456 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -77,12 +77,9 @@ pub fn standalone(build: &Build, target: &str) { if !up_to_date(&version_input, &version_info) { let mut info = String::new(); t!(t!(File::open(&version_input)).read_to_string(&mut info)); - let blank = String::new(); - let short = build.short_ver_hash.as_ref().unwrap_or(&blank); - let hash = build.ver_hash.as_ref().unwrap_or(&blank); - let info = info.replace("VERSION", &build.release) - .replace("SHORT_HASH", short) - .replace("STAMP", hash); + let info = info.replace("VERSION", &build.rust_release()) + .replace("SHORT_HASH", build.rust_info.sha_short().unwrap_or("")) + .replace("STAMP", build.rust_info.sha().unwrap_or("")); t!(t!(File::create(&version_info)).write_all(info.as_bytes())); } diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index efc460f35838c..ba8442ebd8c37 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -19,7 +19,7 @@ use std::path::{Path, PathBuf, Component}; use std::process::Command; use Build; -use dist::{package_vers, sanitize_sh, tmpdir}; +use dist::{sanitize_sh, tmpdir}; /// Installs everything. pub fn install(build: &Build, stage: u32, host: &str) { @@ -59,7 +59,7 @@ pub fn install(build: &Build, stage: u32, host: &str) { fn install_sh(build: &Build, package: &str, name: &str, stage: u32, host: &str, prefix: &Path, docdir: &Path, libdir: &Path, mandir: &Path, empty_dir: &Path) { println!("Install {} stage{} ({})", package, stage, host); - let package_name = format!("{}-{}-{}", name, package_vers(build), host); + let package_name = format!("{}-{}-{}", name, build.rust_package_vers(), host); let mut cmd = Command::new("sh"); cmd.current_dir(empty_dir) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 2b34142b3b0f3..b432ef18054c7 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -84,7 +84,7 @@ use std::fs::{self, File}; use std::path::{Component, PathBuf, Path}; use std::process::Command; -use build_helper::{run_silent, output, mtime}; +use build_helper::{run_silent, run_suppressed, output, mtime}; use util::{exe, libdir, add_lib_path}; @@ -148,16 +148,9 @@ pub struct Build { rustc: PathBuf, src: PathBuf, out: PathBuf, - release: String, - unstable_features: bool, - ver_hash: Option, - short_ver_hash: Option, - ver_date: Option, - version: String, - package_vers: String, + rust_info: channel::GitInfo, + cargo_info: channel::GitInfo, local_rebuild: bool, - release_num: String, - prerelease_version: String, // Probed tools at runtime lldb_version: Option, @@ -173,6 +166,7 @@ pub struct Build { #[derive(Debug)] struct Crate { name: String, + version: String, deps: Vec, path: PathBuf, doc_step: String, @@ -236,6 +230,8 @@ impl Build { } None => false, }; + let rust_info = channel::GitInfo::new(&src); + let cargo_info = channel::GitInfo::new(&src.join("src/tools/cargo")); Build { flags: flags, @@ -245,22 +241,15 @@ impl Build { src: src, out: out, - release: String::new(), - unstable_features: false, - ver_hash: None, - short_ver_hash: None, - ver_date: None, - version: String::new(), + rust_info: rust_info, + cargo_info: cargo_info, local_rebuild: local_rebuild, - package_vers: String::new(), cc: HashMap::new(), cxx: HashMap::new(), crates: HashMap::new(), lldb_version: None, lldb_python_dir: None, is_sudo: is_sudo, - release_num: String::new(), - prerelease_version: String::new(), } } @@ -278,15 +267,14 @@ impl Build { cc::find(self); self.verbose("running sanity check"); sanity::check(self); - self.verbose("collecting channel variables"); - channel::collect(self); // If local-rust is the same major.minor as the current version, then force a local-rebuild let local_version_verbose = output( Command::new(&self.rustc).arg("--version").arg("--verbose")); let local_release = local_version_verbose .lines().filter(|x| x.starts_with("release:")) .next().unwrap().trim_left_matches("release:").trim(); - if local_release.split('.').take(2).eq(self.release.split('.').take(2)) { + let my_version = channel::CFG_RELEASE_NUM; + if local_release.split('.').take(2).eq(my_version.split('.').take(2)) { self.verbose(&format!("auto-detected local-rebuild {}", local_release)); self.local_rebuild = true; } @@ -797,6 +785,12 @@ impl Build { run_silent(cmd) } + /// Runs a command, printing out nice contextual information if it fails. + fn run_quiet(&self, cmd: &mut Command) { + self.verbose(&format!("running: {:?}", cmd)); + run_suppressed(cmd) + } + /// Prints a message if this build is configured in verbose mode. fn verbose(&self, msg: &str) { if self.flags.verbose() || self.config.verbose() { @@ -914,6 +908,82 @@ impl Build { compiler.stage >= 2 && self.config.host.iter().any(|h| h == target) } + + /// Returns the directory that OpenSSL artifacts are compiled into if + /// configured to do so. + fn openssl_dir(&self, target: &str) -> Option { + // OpenSSL not used on Windows + if target.contains("windows") { + None + } else if self.config.openssl_static { + Some(self.out.join(target).join("openssl")) + } else { + None + } + } + + /// Returns the directory that OpenSSL artifacts are installed into if + /// configured as such. + fn openssl_install_dir(&self, target: &str) -> Option { + self.openssl_dir(target).map(|p| p.join("install")) + } + + /// Given `num` in the form "a.b.c" return a "release string" which + /// describes the release version number. + /// + /// For example on nightly this returns "a.b.c-nightly", on beta it returns + /// "a.b.c-beta.1" and on stable it just returns "a.b.c". + fn release(&self, num: &str) -> String { + match &self.config.channel[..] { + "stable" => num.to_string(), + "beta" => format!("{}-beta{}", num, channel::CFG_PRERELEASE_VERSION), + "nightly" => format!("{}-nightly", num), + _ => format!("{}-dev", num), + } + } + + /// Returns the value of `release` above for Rust itself. + fn rust_release(&self) -> String { + self.release(channel::CFG_RELEASE_NUM) + } + + /// Returns the "package version" for a component given the `num` release + /// number. + /// + /// The package version is typically what shows up in the names of tarballs. + /// For channels like beta/nightly it's just the channel name, otherwise + /// it's the `num` provided. + fn package_vers(&self, num: &str) -> String { + match &self.config.channel[..] { + "stable" => num.to_string(), + "beta" => "beta".to_string(), + "nightly" => "nightly".to_string(), + _ => format!("{}-dev", num), + } + } + + /// Returns the value of `package_vers` above for Rust itself. + fn rust_package_vers(&self) -> String { + self.package_vers(channel::CFG_RELEASE_NUM) + } + + /// Returns the `version` string associated with this compiler for Rust + /// itself. + /// + /// Note that this is a descriptive string which includes the commit date, + /// sha, version, etc. + fn rust_version(&self) -> String { + self.rust_info.version(self, channel::CFG_RELEASE_NUM) + } + + /// Returns whether unstable features should be enabled for the compiler + /// we're building. + fn unstable_features(&self) -> bool { + match &self.config.channel[..] { + "stable" | "beta" => false, + "nightly" | _ => true, + } + } } impl<'a> Compiler<'a> { diff --git a/src/bootstrap/metadata.rs b/src/bootstrap/metadata.rs index 5ab542b6a2489..5918fe41e7c8b 100644 --- a/src/bootstrap/metadata.rs +++ b/src/bootstrap/metadata.rs @@ -27,6 +27,7 @@ struct Output { struct Package { id: String, name: String, + version: String, source: Option, manifest_path: String, } @@ -72,6 +73,7 @@ fn build_krate(build: &mut Build, krate: &str) { test_step: format!("test-crate-{}", package.name), bench_step: format!("bench-crate-{}", package.name), name: package.name, + version: package.version, deps: Vec::new(), path: path, }); diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index f16fc2092f616..3517623d3b8a3 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -191,3 +191,103 @@ pub fn test_helpers(build: &Build, target: &str) { .file(build.src.join("src/rt/rust_test_helpers.c")) .compile("librust_test_helpers.a"); } +const OPENSSL_VERS: &'static str = "1.0.2k"; +const OPENSSL_SHA256: &'static str = + "6b3977c61f2aedf0f96367dcfb5c6e578cf37e7b8d913b4ecb6643c3cb88d8c0"; + +pub fn openssl(build: &Build, target: &str) { + let out = match build.openssl_dir(target) { + Some(dir) => dir, + None => return, + }; + + let stamp = out.join(".stamp"); + let mut contents = String::new(); + drop(File::open(&stamp).and_then(|mut f| f.read_to_string(&mut contents))); + if contents == OPENSSL_VERS { + return + } + t!(fs::create_dir_all(&out)); + + let name = format!("openssl-{}.tar.gz", OPENSSL_VERS); + let tarball = out.join(&name); + if !tarball.exists() { + let tmp = tarball.with_extension("tmp"); + build.run(Command::new("curl") + .arg("-o").arg(&tmp) + .arg(format!("https://www.openssl.org/source/{}", name))); + let mut shasum = if target.contains("apple") { + let mut cmd = Command::new("shasum"); + cmd.arg("-a").arg("256"); + cmd + } else { + Command::new("sha256sum") + }; + let output = output(&mut shasum.arg(&tmp)); + let found = output.split_whitespace().next().unwrap(); + if found != OPENSSL_SHA256 { + panic!("downloaded openssl sha256 different\n\ + expected: {}\n\ + found: {}\n", OPENSSL_SHA256, found); + } + t!(fs::rename(&tmp, &tarball)); + } + let obj = out.join(format!("openssl-{}", OPENSSL_VERS)); + let dst = build.openssl_install_dir(target).unwrap(); + drop(fs::remove_dir_all(&obj)); + drop(fs::remove_dir_all(&dst)); + build.run(Command::new("tar").arg("xf").arg(&tarball).current_dir(&out)); + + let mut configure = if target == "i686-unknown-linux-gnu" { + let mut cmd = Command::new("setarch"); + cmd.arg("i386").arg(obj.join("Configure")); + cmd + } else { + Command::new(obj.join("Configure")) + }; + + configure.arg(format!("--prefix={}", dst.display())); + configure.arg("no-dso"); + configure.arg("no-ssl2"); + configure.arg("no-ssl3"); + + let os = match target { + "aarch64-unknown-linux-gnu" => "linux-aarch64", + "arm-unknown-linux-gnueabi" => "linux-armv4", + "arm-unknown-linux-gnueabihf" => "linux-armv4", + "armv7-unknown-linux-gnueabihf" => "linux-armv4", + "i686-apple-darwin" => "darwin-i386-cc", + "i686-unknown-freebsd" => "BSD-x86-elf", + "i686-unknown-linux-gnu" => "linux-elf", + "i686-unknown-linux-musl" => "linux-elf", + "mips-unknown-linux-gnu" => "linux-mips32", + "mips64-unknown-linux-gnuabi64" => "linux64-mips64", + "mips64el-unknown-linux-gnuabi64" => "linux64-mips64", + "mipsel-unknown-linux-gnu" => "linux-mips32", + "powerpc-unknown-linux-gnu" => "linux-ppc", + "powerpc64-unknown-linux-gnu" => "linux-ppc64", + "powerpc64le-unknown-linux-gnu" => "linux-ppc64le", + "s390x-unknown-linux-gnu" => "linux64-s390x", + "x86_64-apple-darwin" => "darwin64-x86_64-cc", + "x86_64-unknown-freebsd" => "BSD-x86_64", + "x86_64-unknown-linux-gnu" => "linux-x86_64", + "x86_64-unknown-linux-musl" => "linux-x86_64", + "x86_64-unknown-netbsd" => "BSD-x86_64", + _ => panic!("don't know how to configure OpenSSL for {}", target), + }; + configure.arg(os); + configure.env("CC", build.cc(target)); + for flag in build.cflags(target) { + configure.arg(flag); + } + configure.current_dir(&obj); + println!("Configuring openssl for {}", target); + build.run_quiet(&mut configure); + println!("Building openssl for {}", target); + build.run_quiet(Command::new("make").current_dir(&obj)); + println!("Installing openssl for {}", target); + build.run_quiet(Command::new("make").arg("install").current_dir(&obj)); + + let mut f = t!(File::create(&stamp)); + t!(f.write_all(OPENSSL_VERS.as_bytes())); +} diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs index dcd3407e174aa..b49158d3e8887 100644 --- a/src/bootstrap/step.rs +++ b/src/bootstrap/step.rs @@ -478,9 +478,10 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { .dep(|s| s.name("dist-src")) .run(move |_| check::distcheck(build)); - rules.build("test-helpers", "src/rt/rust_test_helpers.c") .run(move |s| native::test_helpers(build, s.target)); + rules.build("openssl", "path/to/nowhere") + .run(move |s| native::openssl(build, s.target)); // Some test suites are run inside emulators, and most of our test binaries // are linked dynamically which means we need to ship the standard library @@ -547,6 +548,10 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { rules.build("tool-qemu-test-client", "src/tools/qemu-test-client") .dep(|s| s.name("libstd")) .run(move |s| compile::tool(build, s.stage, s.target, "qemu-test-client")); + rules.build("tool-cargo", "src/tools/cargo") + .dep(|s| s.name("libstd")) + .dep(|s| s.stage(0).host(s.target).name("openssl")) + .run(move |s| compile::tool(build, s.stage, s.target, "cargo")); // ======================================================================== // Documentation targets @@ -673,6 +678,7 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { rules.dist("dist-cargo", "cargo") .host(true) .only_host_build(true) + .dep(|s| s.name("tool-cargo")) .run(move |s| dist::cargo(build, s.stage, s.target)); rules.dist("dist-extended", "extended") .default(build.config.extended) @@ -1180,6 +1186,7 @@ mod tests { build_step: "build-crate-std".to_string(), test_step: "test-std".to_string(), bench_step: "bench-std".to_string(), + version: String::new(), }); build.crates.insert("test".to_string(), ::Crate { name: "test".to_string(), @@ -1189,10 +1196,12 @@ mod tests { build_step: "build-crate-test".to_string(), test_step: "test-test".to_string(), bench_step: "bench-test".to_string(), + version: String::new(), }); build.crates.insert("rustc-main".to_string(), ::Crate { name: "rustc-main".to_string(), deps: Vec::new(), + version: String::new(), path: cwd.join("src/rustc-main"), doc_step: "doc-rustc-main".to_string(), build_step: "build-crate-rustc-main".to_string(), diff --git a/src/build_helper/lib.rs b/src/build_helper/lib.rs index 3dfd293808286..08f1f31c2d74b 100644 --- a/src/build_helper/lib.rs +++ b/src/build_helper/lib.rs @@ -53,6 +53,24 @@ pub fn run_silent(cmd: &mut Command) { } } +pub fn run_suppressed(cmd: &mut Command) { + let output = match cmd.output() { + Ok(status) => status, + Err(e) => fail(&format!("failed to execute command: {:?}\nerror: {}", + cmd, e)), + }; + if !output.status.success() { + fail(&format!("command did not execute successfully: {:?}\n\ + expected success, got: {}\n\n\ + stdout ----\n{}\n\ + stderr ----\n{}\n", + cmd, + output.status, + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr))); + } +} + pub fn gnu_target(target: &str) -> String { match target { "i686-pc-windows-msvc" => "i686-pc-win32".to_string(), diff --git a/src/ci/run.sh b/src/ci/run.sh index 53d16f6239e66..4c4836d7ca230 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -27,6 +27,7 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-sccache" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-quiet-tests" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps" +RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-cargo-openssl-static" if [ "$DIST_SRC" = "" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-dist-src" diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index c2c91487b0c17..ceefcc9e0ec46 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -131,7 +131,8 @@ macro_rules! t { } struct Builder { - channel: String, + rust_release: String, + cargo_release: String, input: PathBuf, output: PathBuf, gpg_passphrase: String, @@ -147,13 +148,15 @@ fn main() { let input = PathBuf::from(args.next().unwrap()); let output = PathBuf::from(args.next().unwrap()); let date = args.next().unwrap(); - let channel = args.next().unwrap(); + let rust_release = args.next().unwrap(); + let cargo_release = args.next().unwrap(); let s3_address = args.next().unwrap(); let mut passphrase = String::new(); t!(io::stdin().read_to_string(&mut passphrase)); Builder { - channel: channel, + rust_release: rust_release, + cargo_release: cargo_release, input: input, output: output, gpg_passphrase: passphrase, @@ -184,10 +187,10 @@ impl Builder { manifest.insert("pkg".to_string(), toml::encode(&pkg)); let manifest = toml::Value::Table(manifest).to_string(); - let filename = format!("channel-rust-{}.toml", self.channel); + let filename = format!("channel-rust-{}.toml", self.rust_release); self.write_manifest(&manifest, &filename); - if self.channel != "beta" && self.channel != "nightly" { + if self.rust_release != "beta" && self.rust_release != "nightly" { self.write_manifest(&manifest, "channel-rust-stable.toml"); } } @@ -336,11 +339,11 @@ impl Builder { fn filename(&self, component: &str, target: &str) -> String { if component == "rust-src" { - format!("rust-src-{}.tar.gz", self.channel) + format!("rust-src-{}.tar.gz", self.rust_release) } else if component == "cargo" { - format!("cargo-nightly-{}.tar.gz", target) + format!("cargo-{}-{}.tar.gz", self.cargo_release, target) } else { - format!("{}-{}-{}.tar.gz", component, self.channel, target) + format!("{}-{}-{}.tar.gz", component, self.rust_release, target) } } diff --git a/src/tools/tidy/src/cargo.rs b/src/tools/tidy/src/cargo.rs index 11acb64743a7a..053f0bbe3b81d 100644 --- a/src/tools/tidy/src/cargo.rs +++ b/src/tools/tidy/src/cargo.rs @@ -20,7 +20,7 @@ use std::fs::File; use std::path::Path; pub fn check(path: &Path, bad: &mut bool) { - if path.ends_with("vendor") { + if !super::filter_dirs(path) { return } for entry in t!(path.read_dir(), path).map(|e| t!(e)) { diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index e1c44a20e9756..3bf396db4d39d 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -16,6 +16,7 @@ use std::path::Path; static LICENSES: &'static [&'static str] = &[ "MIT/Apache-2.0", + "MIT / Apache-2.0", "Apache-2.0/MIT", "MIT OR Apache-2.0", "MIT", @@ -25,6 +26,7 @@ static LICENSES: &'static [&'static str] = &[ /// These MPL licensed projects are acceptable, but only these. static EXCEPTIONS: &'static [&'static str] = &[ "mdbook", + "openssl", "pest", "thread-id", ]; diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index 1bb7919c1d35b..2af891b5b8562 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -70,6 +70,7 @@ fn filter_dirs(path: &Path) -> bool { "src/rustllvm", "src/rust-installer", "src/liblibc", + "src/tools/cargo", "src/vendor", ]; skip.iter().any(|p| path.ends_with(p)) From 593356032423f65f75d72bfff4d21b669dd01068 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 27 Feb 2017 19:00:43 +0100 Subject: [PATCH 19/20] Add missing docs and examples for fmt::Write --- src/libcore/fmt/mod.rs | 71 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 9 deletions(-) diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index e6c9e1ed38e4f..dc5a662cdb044 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -65,12 +65,15 @@ pub struct Error; /// A collection of methods that are required to format a message into a stream. /// /// This trait is the type which this modules requires when formatting -/// information. This is similar to the standard library's `io::Write` trait, +/// information. This is similar to the standard library's [`io::Write`] trait, /// but it is only intended for use in libcore. /// /// This trait should generally not be implemented by consumers of the standard -/// library. The `write!` macro accepts an instance of `io::Write`, and the -/// `io::Write` trait is favored over implementing this trait. +/// library. The [`write!`] macro accepts an instance of [`io::Write`], and the +/// [`io::Write`] trait is favored over implementing this trait. +/// +/// [`write!`]: ../../std/macro.write.html +/// [`io::Write`]: ../../std/io/trait.Write.html #[stable(feature = "rust1", since = "1.0.0")] pub trait Write { /// Writes a slice of bytes into this writer, returning whether the write @@ -82,29 +85,79 @@ pub trait Write { /// /// # Errors /// - /// This function will return an instance of `Error` on error. + /// This function will return an instance of [`Error`] on error. + /// + /// [`Error`]: struct.Error.html + /// + /// # Examples + /// + /// ``` + /// use std::fmt::{Error, Write}; + /// + /// fn writer(f: &mut W, s: &str) -> Result<(), Error> { + /// f.write_str(s) + /// } + /// + /// let mut buf = String::new(); + /// writer(&mut buf, "hola").unwrap(); + /// assert_eq!(&buf, "hola"); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn write_str(&mut self, s: &str) -> Result; - /// Writes a `char` into this writer, returning whether the write succeeded. + /// Writes a [`char`] into this writer, returning whether the write succeeded. /// - /// A single `char` may be encoded as more than one byte. + /// A single [`char`] may be encoded as more than one byte. /// This method can only succeed if the entire byte sequence was successfully /// written, and this method will not return until all data has been /// written or an error occurs. /// /// # Errors /// - /// This function will return an instance of `Error` on error. + /// This function will return an instance of [`Error`] on error. + /// + /// [`char`]: ../../std/primitive.char.html + /// [`Error`]: struct.Error.html + /// + /// # Examples + /// + /// ``` + /// use std::fmt::{Error, Write}; + /// + /// fn writer(f: &mut W, c: char) -> Result<(), Error> { + /// f.write_char(c) + /// } + /// + /// let mut buf = String::new(); + /// writer(&mut buf, 'a').unwrap(); + /// writer(&mut buf, 'b').unwrap(); + /// assert_eq!(&buf, "ab"); + /// ``` #[stable(feature = "fmt_write_char", since = "1.1.0")] fn write_char(&mut self, c: char) -> Result { self.write_str(c.encode_utf8(&mut [0; 4])) } - /// Glue for usage of the `write!` macro with implementors of this trait. + /// Glue for usage of the [`write!`] macro with implementors of this trait. /// /// This method should generally not be invoked manually, but rather through - /// the `write!` macro itself. + /// the [`write!`] macro itself. + /// + /// [`write!`]: ../../std/macro.write.html + /// + /// # Examples + /// + /// ``` + /// use std::fmt::{Error, Write}; + /// + /// fn writer(f: &mut W, s: &str) -> Result<(), Error> { + /// f.write_fmt(format_args!("{}", s)) + /// } + /// + /// let mut buf = String::new(); + /// writer(&mut buf, "world").unwrap(); + /// assert_eq!(&buf, "world"); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn write_fmt(&mut self, args: Arguments) -> Result { // This Adapter is needed to allow `self` (of type `&mut From fb2d763eee4bdefdcdb3f0c2fd9a4199626c3777 Mon Sep 17 00:00:00 2001 From: Josh Driver Date: Thu, 23 Feb 2017 21:15:30 +1030 Subject: [PATCH 20/20] Replace ./configure with config.toml in README.md and CONTRIBUTING.md --- CONTRIBUTING.md | 54 +++++++++++++++++++++++++------------------- README.md | 59 +++++++++++++++++++++++++++++++++---------------- 2 files changed, 71 insertions(+), 42 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e9d8c84f40715..1e983cfd726d6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -97,33 +97,38 @@ system internals, try asking in [`#rust-internals`][pound-rust-internals]. Before you can start building the compiler you need to configure the build for your system. In most cases, that will just mean using the defaults provided -for Rust. Configuring involves invoking the `configure` script in the project -root. +for Rust. -``` -./configure -``` +To change configuration, you must copy the file `src/bootstrap/config.toml.example` +to `config.toml` in the directory from which you will be running the build, and +change the settings provided. + +There are large number of options provided in this config file that will alter the +configuration used in the build process. Some options to note: -There are large number of options accepted by this script to alter the -configuration used later in the build process. Some options to note: +#### `[llvm]`: +- `ccache = true` - Use ccache when building llvm -- `--enable-debug` - Build a debug version of the compiler (disables optimizations, - which speeds up compilation of stage1 rustc) -- `--enable-optimize` - Enable optimizations (can be used with `--enable-debug` - to make a debug build with optimizations) -- `--disable-valgrind-rpass` - Don't run tests with valgrind -- `--enable-clang` - Prefer clang to gcc for building dependencies (e.g., LLVM) -- `--enable-ccache` - Invoke clang/gcc with ccache to re-use object files between builds -- `--enable-compiler-docs` - Build compiler documentation +#### `[build]`: +- `compiler-docs = true` - Build compiler documentation -To see a full list of options, run `./configure --help`. +#### `[rust]`: +- `debuginfo = true` - Build a compiler with debuginfo +- `optimize = false` - Disable optimizations to speed up compilation of stage1 rust + +For more options, the `config.toml` file contains commented out defaults, with +descriptions of what each option will do. + +Note: Previously the `./configure` script was used to configure this +project. It can still be used, but it's recommended to use a `config.toml` +file. If you still have a `config.mk` file in your directory - from +`./configure` - you may need to delete it for `config.toml` to work. ### Building -Although the `./configure` script will generate a `Makefile`, this is actually -just a thin veneer over the actual build system driver, `x.py`. This file, at -the root of the repository, is used to build, test, and document various parts -of the compiler. You can execute it as: +The build system uses the `x.py` script to control the build process. This script +is used to build, test, and document various parts of the compiler. You can +execute it as: ```sh python x.py build @@ -185,6 +190,9 @@ To learn about all possible rules you can execute, run: python x.py build --help --verbose ``` +Note: Previously `./configure` and `make` were used to build this project. +They are still available, but `x.py` is the recommended build system. + ### Useful commands Some common invocations of `x.py` are: @@ -235,8 +243,8 @@ feature. We use the 'fork and pull' model described there. Please make pull requests against the `master` branch. -Compiling all of `make check` can take a while. When testing your pull request, -consider using one of the more specialized `make` targets to cut down on the +Compiling all of `./x.py test` can take a while. When testing your pull request, +consider using one of the more specialized `./x.py` targets to cut down on the amount of time you have to wait. You need to have built the compiler at least once before running these will work, but that’s only one full build rather than one each time. @@ -307,7 +315,7 @@ To find documentation-related issues, sort by the [A-docs label][adocs]. [adocs]: https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3AA-docs -In many cases, you don't need a full `make doc`. You can use `rustdoc` directly +In many cases, you don't need a full `./x.py doc`. You can use `rustdoc` directly to check small fixes. For example, `rustdoc src/doc/reference.md` will render reference to `doc/reference.html`. The CSS might be messed up, but you can verify that the HTML is right. diff --git a/README.md b/README.md index c1218e9c600ce..93415adc423f4 100644 --- a/README.md +++ b/README.md @@ -35,15 +35,15 @@ Read ["Installing Rust"] from [The Book]. 3. Build and install: ```sh - $ ./configure - $ make && sudo make install + $ ./x.py build && sudo ./x.py dist --install ``` - > ***Note:*** Install locations can be adjusted by passing a `--prefix` - > argument to `configure`. Various other options are also supported – pass - > `--help` for more information on them. + > ***Note:*** Install locations can be adjusted by copying the config file + > from `./src/bootstrap/config.toml.example` to `./config.toml`, and + > adjusting the `prefix` option under `[install]`. Various other options are + > also supported, and are documented in the config file. - When complete, `sudo make install` will place several programs into + When complete, `sudo ./x.py dist --install` will place several programs into `/usr/local/bin`: `rustc`, the Rust compiler, and `rustdoc`, the API-documentation tool. This install does not include [Cargo], Rust's package manager, which you may also want to build. @@ -59,7 +59,6 @@ for interop with software produced by Visual Studio use the MSVC build of Rust; for interop with GNU software built using the MinGW/MSYS2 toolchain use the GNU build. - #### MinGW [MSYS2][msys2] can be used to easily build Rust on Windows: @@ -94,11 +93,10 @@ build. mingw-w64-x86_64-gcc ``` -4. Navigate to Rust's source code (or clone it), then configure and build it: +4. Navigate to Rust's source code (or clone it), then build it: ```sh - $ ./configure - $ make && make install + $ ./x.py build && ./x.py dist --install ``` #### MSVC @@ -114,13 +112,6 @@ shell with: > python x.py build ``` -If you're running inside of an msys shell, however, you can run: - -```sh -$ ./configure --build=x86_64-pc-windows-msvc -$ make && make install -``` - Currently building Rust only works with some known versions of Visual Studio. If you have a more recent version installed the build system doesn't understand then you may need to force rustbuild to use an older version. This can be done @@ -131,13 +122,43 @@ CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64. python x.py build ``` +#### Specifying an ABI + +Each specific ABI can also be used from either environment (for example, using +the GNU ABI in powershell) by using an explicit build triple. The available +Windows build triples are: +- GNU ABI (using GCC) + - `i686-pc-windows-gnu` + - `x86_64-pc-windows-gnu` +- The MSVC ABI + - `i686-pc-windows-msvc` + - `x86_64-pc-windows-msvc` + +The build triple can be specified by either specifying `--build=ABI` when +invoking `x.py` commands, or by copying the `config.toml` file (as described +in Building From Source), and modifying the `build` option under the `[build]` +section. + +### Configure and Make + +While it's not the recommended build system, this project also provides a +configure script and makefile (the latter of which just invokes `x.py`). + +```sh +$ ./configure +$ make && sudo make install +``` + +When using the configure script, the generated config.mk` file may override the +`config.toml` file. To go back to the `config.toml` file, delete the generated +`config.mk` file. + ## Building Documentation If you’d like to build the documentation, it’s almost the same: ```sh -$ ./configure -$ make docs +$ ./x.py doc ``` The generated documentation will appear in a top-level `doc` directory,