diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2015-02-18 23:50:21 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2015-02-18 23:50:21 +1100 |
| commit | dfc5c0f1e8799f47f9033bdcc8a7cd8a217620a5 (patch) | |
| tree | e9c32f2e58b3462a23dd9c472d2f236640b78811 /src/librustc | |
| parent | 6c065fc8cb036785f61ff03e05c1563cbb2dd081 (diff) | |
| parent | 47f91a9484eceef10536d4caac6ef578cd254567 (diff) | |
| download | rust-dfc5c0f1e8799f47f9033bdcc8a7cd8a217620a5.tar.gz rust-dfc5c0f1e8799f47f9033bdcc8a7cd8a217620a5.zip | |
Manual merge of #22475 - alexcrichton:rollup, r=alexcrichton
One windows bot failed spuriously.
Diffstat (limited to 'src/librustc')
| -rw-r--r-- | src/librustc/README.txt | 4 | ||||
| -rw-r--r-- | src/librustc/lib.rs | 4 | ||||
| -rw-r--r-- | src/librustc/lint/builtin.rs | 67 | ||||
| -rw-r--r-- | src/librustc/middle/stability.rs | 37 | ||||
| -rw-r--r-- | src/librustc/middle/subst.rs | 22 | ||||
| -rw-r--r-- | src/librustc/middle/traits/select.rs | 32 | ||||
| -rw-r--r-- | src/librustc/middle/ty.rs | 36 | ||||
| -rw-r--r-- | src/librustc/session/config.rs | 2 | ||||
| -rw-r--r-- | src/librustc/util/ppaux.rs | 5 |
9 files changed, 53 insertions, 156 deletions
diff --git a/src/librustc/README.txt b/src/librustc/README.txt index 697dddca74f..37097764f71 100644 --- a/src/librustc/README.txt +++ b/src/librustc/README.txt @@ -4,8 +4,8 @@ An informal guide to reading and working on the rustc compiler. If you wish to expand on this document, or have a more experienced Rust contributor add anything else to it, please get in touch: -https://github.com/rust-lang/rust/wiki/Note-development-policy -("Communication" subheading) +* http://internals.rust-lang.org/ +* https://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust or file a bug: diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index abf70813d36..fe9a81bb7c9 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -29,10 +29,10 @@ #![feature(core)] #![feature(hash)] #![feature(int_uint)] -#![feature(io)] +#![feature(old_io)] #![feature(libc)] #![feature(env)] -#![feature(path)] +#![feature(old_path)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index d09e4bd9759..ba108b5488e 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -47,6 +47,7 @@ use syntax::{abi, ast, ast_map}; use syntax::ast_util::is_shift_binop; use syntax::attr::{self, AttrMetaMethods}; use syntax::codemap::{self, Span}; +use syntax::feature_gate::{KNOWN_ATTRIBUTES, AttributeType}; use syntax::parse::token; use syntax::ast::{TyIs, TyUs, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64}; use syntax::ast_util; @@ -640,67 +641,19 @@ impl LintPass for UnusedAttributes { } fn check_attribute(&mut self, cx: &Context, attr: &ast::Attribute) { - static ATTRIBUTE_WHITELIST: &'static [&'static str] = &[ - // FIXME: #14408 whitelist docs since rustdoc looks at them - "doc", - - // FIXME: #14406 these are processed in trans, which happens after the - // lint pass - "cold", - "export_name", - "inline", - "link", - "link_name", - "link_section", - "linkage", - "no_builtins", - "no_mangle", - "no_split_stack", - "no_stack_check", - "packed", - "static_assert", - "thread_local", - "no_debug", - "omit_gdb_pretty_printer_section", - "unsafe_no_drop_flag", - - // used in resolve - "prelude_import", - - // FIXME: #14407 these are only looked at on-demand so we can't - // guarantee they'll have already been checked - "deprecated", - "must_use", - "stable", - "unstable", - "rustc_on_unimplemented", - "rustc_error", - - // FIXME: #19470 this shouldn't be needed forever - "old_orphan_check", - "old_impl_check", - "rustc_paren_sugar", // FIXME: #18101 temporary unboxed closure hack - ]; - - static CRATE_ATTRS: &'static [&'static str] = &[ - "crate_name", - "crate_type", - "feature", - "no_start", - "no_main", - "no_std", - "no_builtins", - ]; - - for &name in ATTRIBUTE_WHITELIST { - if attr.check_name(name) { - break; + for &(ref name, ty) in KNOWN_ATTRIBUTES { + match ty { + AttributeType::Whitelisted + | AttributeType::Gated(_, _) if attr.check_name(name) => { + break; + }, + _ => () } } if !attr::is_used(attr) { cx.span_lint(UNUSED_ATTRIBUTES, attr.span, "unused attribute"); - if CRATE_ATTRS.contains(&&attr.name()[]) { + if KNOWN_ATTRIBUTES.contains(&(&attr.name()[], AttributeType::CrateLevel)) { let msg = match attr.node.style { ast::AttrOuter => "crate-level attribute should be an inner \ attribute: add an exclamation mark: #![foo]", @@ -1761,7 +1714,7 @@ impl LintPass for Stability { } fn check_item(&mut self, cx: &Context, item: &ast::Item) { - stability::check_item(cx.tcx, item, + stability::check_item(cx.tcx, item, false, &mut |id, sp, stab| self.lint(cx, id, sp, stab)); } diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index a086e91f4d9..0a0f555f977 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -261,12 +261,12 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { if self.tcx.sess.features.borrow().unmarked_api { self.tcx.sess.span_warn(span, "use of unmarked library feature"); self.tcx.sess.span_note(span, "this is either a bug in the library you are \ - using and a bug in the compiler - please \ + using or a bug in the compiler - please \ report it in both places"); } else { self.tcx.sess.span_err(span, "use of unmarked library feature"); self.tcx.sess.span_note(span, "this is either a bug in the library you are \ - using and a bug in the compiler - please \ + using or a bug in the compiler - please \ report it in both places"); self.tcx.sess.span_note(span, "use #![feature(unmarked_api)] in the \ crate attributes to override this"); @@ -283,7 +283,7 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Checker<'a, 'tcx> { // name `__test` if item.span == DUMMY_SP && item.ident.as_str() == "__test" { return } - check_item(self.tcx, item, + check_item(self.tcx, item, true, &mut |id, sp, stab| self.check(id, sp, stab)); visit::walk_item(self, item); } @@ -302,7 +302,7 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Checker<'a, 'tcx> { } /// Helper for discovering nodes to check for stability -pub fn check_item(tcx: &ty::ctxt, item: &ast::Item, +pub fn check_item(tcx: &ty::ctxt, item: &ast::Item, warn_about_defns: bool, cb: &mut FnMut(ast::DefId, Span, &Option<Stability>)) { match item.node { ast::ItemExternCrate(_) => { @@ -316,6 +316,35 @@ pub fn check_item(tcx: &ty::ctxt, item: &ast::Item, let id = ast::DefId { krate: cnum, node: ast::CRATE_NODE_ID }; maybe_do_stability_check(tcx, id, item.span, cb); } + + // For implementations of traits, check the stability of each item + // individually as it's possible to have a stable trait with unstable + // items. + ast::ItemImpl(_, _, _, Some(ref t), _, ref impl_items) => { + let trait_did = tcx.def_map.borrow()[t.ref_id].def_id(); + let trait_items = ty::trait_items(tcx, trait_did); + + for impl_item in impl_items { + let (ident, span) = match *impl_item { + ast::MethodImplItem(ref method) => { + (match method.node { + ast::MethDecl(ident, _, _, _, _, _, _, _) => ident, + ast::MethMac(..) => unreachable!(), + }, method.span) + } + ast::TypeImplItem(ref typedef) => { + (typedef.ident, typedef.span) + } + }; + let item = trait_items.iter().find(|item| { + item.name() == ident.name + }).unwrap(); + if warn_about_defns { + maybe_do_stability_check(tcx, item.def_id(), span, cb); + } + } + } + _ => (/* pass */) } } diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index e27e7a80246..9bf35bd4284 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -530,17 +530,6 @@ impl<'a,T> Iterator for EnumeratedItems<'a,T> { } } -// NOTE(stage0): remove impl after a snapshot -#[cfg(stage0)] -impl<T> IntoIterator for VecPerParamSpace<T> { - type IntoIter = IntoIter<T>; - - fn into_iter(self) -> IntoIter<T> { - self.into_vec().into_iter() - } -} - -#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot impl<T> IntoIterator for VecPerParamSpace<T> { type Item = T; type IntoIter = IntoIter<T>; @@ -550,17 +539,6 @@ impl<T> IntoIterator for VecPerParamSpace<T> { } } -// NOTE(stage0): remove impl after a snapshot -#[cfg(stage0)] -impl<'a,T> IntoIterator for &'a VecPerParamSpace<T> { - type IntoIter = Iter<'a, T>; - - fn into_iter(self) -> Iter<'a, T> { - self.as_slice().into_iter() - } -} - -#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot impl<'a,T> IntoIterator for &'a VecPerParamSpace<T> { type Item = &'a T; type IntoIter = Iter<'a, T>; diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index 6f58f4655fe..061557eb7dc 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -20,7 +20,7 @@ use self::EvaluationResult::*; use super::{DerivedObligationCause}; use super::{project}; use super::project::Normalized; -use super::{PredicateObligation, Obligation, TraitObligation, ObligationCause}; +use super::{PredicateObligation, TraitObligation, ObligationCause}; use super::{ObligationCauseCode, BuiltinDerivedObligation}; use super::{SelectionError, Unimplemented, Overflow, OutputTypeParameterMismatch}; use super::{Selection}; @@ -34,7 +34,7 @@ use super::{util}; use middle::fast_reject; use middle::mem_categorization::Typer; use middle::subst::{Subst, Substs, TypeSpace, VecPerParamSpace}; -use middle::ty::{self, AsPredicate, RegionEscape, ToPolyTraitRef, Ty}; +use middle::ty::{self, RegionEscape, ToPolyTraitRef, Ty}; use middle::infer; use middle::infer::{InferCtxt, TypeFreshener}; use middle::ty_fold::TypeFoldable; @@ -1459,22 +1459,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ty::BoundSync | ty::BoundSend => { - // Note: technically, a region pointer is only - // sendable if it has lifetime - // `'static`. However, we don't take regions - // into account when doing trait matching: - // instead, when we decide that `T : Send`, we - // will register a separate constraint with - // the region inferencer that `T : 'static` - // holds as well (because the trait `Send` - // requires it). This will ensure that there - // is no borrowed data in `T` (or else report - // an inference error). The reason we do it - // this way is that we do not yet *know* what - // lifetime the borrowed reference has, since - // we haven't finished running inference -- in - // other words, there's a kind of - // chicken-and-egg problem. Ok(If(vec![referent_ty])) } } @@ -1817,21 +1801,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } }) }).collect::<Result<_, _>>(); - let mut obligations = match obligations { + let obligations = match obligations { Ok(o) => o, Err(ErrorReported) => Vec::new() }; - // as a special case, `Send` requires `'static` - if bound == ty::BoundSend { - obligations.push(Obligation { - cause: obligation.cause.clone(), - recursion_depth: obligation.recursion_depth+1, - predicate: ty::Binder(ty::OutlivesPredicate(obligation.self_ty(), - ty::ReStatic)).as_predicate(), - }); - } - let obligations = VecPerParamSpace::new(obligations, Vec::new(), Vec::new()); debug!("vtable_builtin_data: obligations={}", diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 107715a8261..8618bde95fe 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -73,8 +73,6 @@ use std::cell::{Cell, RefCell}; use std::cmp; use std::fmt; use std::hash::{Hash, Writer, SipHasher, Hasher}; -#[cfg(stage0)] -use std::marker; use std::mem; use std::ops; use std::rc::Rc; @@ -944,26 +942,6 @@ pub struct TyS<'tcx> { // the maximal depth of any bound regions appearing in this type. region_depth: u32, - - // force the lifetime to be invariant to work-around - // region-inference issues with a covariant lifetime. - #[cfg(stage0)] - marker: ShowInvariantLifetime<'tcx>, -} - -#[cfg(stage0)] -struct ShowInvariantLifetime<'a>(marker::InvariantLifetime<'a>); -#[cfg(stage0)] -impl<'a> ShowInvariantLifetime<'a> { - fn new() -> ShowInvariantLifetime<'a> { - ShowInvariantLifetime(marker::InvariantLifetime) - } -} -#[cfg(stage0)] -impl<'a> fmt::Debug for ShowInvariantLifetime<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "InvariantLifetime") - } } impl fmt::Debug for TypeFlags { @@ -972,14 +950,6 @@ impl fmt::Debug for TypeFlags { } } -#[cfg(stage0)] -impl<'tcx> PartialEq for TyS<'tcx> { - fn eq<'a,'b>(&'a self, other: &'b TyS<'tcx>) -> bool { - let other: &'a TyS<'tcx> = unsafe { mem::transmute(other) }; - (self as *const _) == (other as *const _) - } -} -#[cfg(not(stage0))] impl<'tcx> PartialEq for TyS<'tcx> { fn eq(&self, other: &TyS<'tcx>) -> bool { // (self as *const _) == (other as *const _) @@ -2562,12 +2532,6 @@ fn intern_ty<'tcx>(type_arena: &'tcx TypedArena<TyS<'tcx>>, let flags = FlagComputation::for_sty(&st); let ty = match () { - #[cfg(stage0)] - () => type_arena.alloc(TyS { sty: st, - flags: flags.flags, - region_depth: flags.depth, - marker: ShowInvariantLifetime::new(), }), - #[cfg(not(stage0))] () => type_arena.alloc(TyS { sty: st, flags: flags.flags, region_depth: flags.depth, }), diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 8340a49b92a..5768539b2cd 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -645,7 +645,7 @@ pub fn build_target_config(opts: &Options, sp: &SpanHandler) -> Config { "32" => (ast::TyI32, ast::TyU32), "64" => (ast::TyI64, ast::TyU64), w => sp.handler().fatal(&format!("target specification was invalid: unrecognized \ - target-word-size {}", w)[]) + target-pointer-width {}", w)[]) }; Config { diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 0363978bada..426101e858a 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -697,9 +697,8 @@ impl<'tcx> UserString<'tcx> for ty::TyTrait<'tcx> { } // Region, if not obviously implied by builtin bounds. - if bounds.region_bound != ty::ReStatic || - !bounds.builtin_bounds.contains(&ty::BoundSend) - { // Region bound is implied by builtin bounds: + if bounds.region_bound != ty::ReStatic { + // Region bound is implied by builtin bounds: components.push(bounds.region_bound.user_string(tcx)); } |
