Rustup to nightly from 2017-01-31

This commit is contained in:
Mrmaxmeier
2017-02-03 11:52:13 +01:00
parent 2be75ef973
commit d68f0797bf
6 changed files with 28 additions and 30 deletions

View File

@@ -181,7 +181,7 @@ fn is_relevant_trait(tcx: ty::TyCtxt, item: &TraitItem) -> bool {
} }
} }
fn is_relevant_block(tcx: ty::TyCtxt, tables: &ty::Tables, block: &Block) -> bool { fn is_relevant_block(tcx: ty::TyCtxt, tables: &ty::TypeckTables, block: &Block) -> bool {
for stmt in &block.stmts { for stmt in &block.stmts {
match stmt.node { match stmt.node {
StmtDecl(_, _) => return true, StmtDecl(_, _) => return true,
@@ -194,7 +194,7 @@ fn is_relevant_block(tcx: ty::TyCtxt, tables: &ty::Tables, block: &Block) -> boo
block.expr.as_ref().map_or(false, |e| is_relevant_expr(tcx, tables, e)) block.expr.as_ref().map_or(false, |e| is_relevant_expr(tcx, tables, e))
} }
fn is_relevant_expr(tcx: ty::TyCtxt, tables: &ty::Tables, expr: &Expr) -> bool { fn is_relevant_expr(tcx: ty::TyCtxt, tables: &ty::TypeckTables, expr: &Expr) -> bool {
match expr.node { match expr.node {
ExprBlock(ref block) => is_relevant_block(tcx, tables, block), ExprBlock(ref block) => is_relevant_block(tcx, tables, block),
ExprRet(Some(ref e)) => is_relevant_expr(tcx, tables, e), ExprRet(Some(ref e)) => is_relevant_expr(tcx, tables, e),

View File

@@ -40,16 +40,13 @@ declare_lint! {
} }
fn is_non_trait_box(ty: ty::Ty) -> bool { fn is_non_trait_box(ty: ty::Ty) -> bool {
match ty.sty { ty.is_box() && !ty.boxed_ty().is_trait()
ty::TyBox(inner) => !inner.is_trait(),
_ => false,
}
} }
struct EscapeDelegate<'a, 'tcx: 'a> { struct EscapeDelegate<'a, 'tcx: 'a> {
set: NodeSet, set: NodeSet,
tcx: ty::TyCtxt<'a, 'tcx, 'tcx>, tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
tables: &'a ty::Tables<'tcx>, tables: &'a ty::TypeckTables<'tcx>,
target: TargetDataLayout, target: TargetDataLayout,
too_large_for_stack: u64, too_large_for_stack: u64,
} }
@@ -204,16 +201,16 @@ impl<'a, 'tcx: 'a> EscapeDelegate<'a, 'tcx> {
fn is_large_box(&self, ty: ty::Ty<'tcx>) -> bool { fn is_large_box(&self, ty: ty::Ty<'tcx>) -> bool {
// Large types need to be boxed to avoid stack // Large types need to be boxed to avoid stack
// overflows. // overflows.
match ty.sty { if ty.is_box() {
ty::TyBox(inner) => { let inner = ty.boxed_ty();
self.tcx.infer_ctxt((), Reveal::All).enter(|infcx| if let Ok(layout) = inner.layout(&infcx) { self.tcx.infer_ctxt((), Reveal::All).enter(|infcx| if let Ok(layout) = inner.layout(&infcx) {
let size = layout.size(&self.target); let size = layout.size(&self.target);
size.bytes() > self.too_large_for_stack size.bytes() > self.too_large_for_stack
} else { } else {
false false
}) })
}, } else {
_ => false, false
} }
} }
} }

View File

@@ -230,6 +230,9 @@ impl<'v, 't> RefVisitor<'v, 't> {
if let Some(ref lt) = *lifetime { if let Some(ref lt) = *lifetime {
if &*lt.name.as_str() == "'static" { if &*lt.name.as_str() == "'static" {
self.lts.push(RefLt::Static); self.lts.push(RefLt::Static);
} else if lt.is_elided() {
// TODO: investigate
self.lts.push(RefLt::Unnamed);
} else { } else {
self.lts.push(RefLt::Named(lt.name)); self.lts.push(RefLt::Named(lt.name));
} }
@@ -275,7 +278,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
fn visit_ty(&mut self, ty: &'tcx Ty) { fn visit_ty(&mut self, ty: &'tcx Ty) {
match ty.node { match ty.node {
TyRptr(None, _) => { TyRptr(ref lt, _) if lt.is_elided() => {
self.record(&None); self.record(&None);
}, },
TyPath(ref path) => { TyPath(ref path) => {

View File

@@ -951,8 +951,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: ty::Ty) -> Option<sug
ty::TySlice(_) => true, ty::TySlice(_) => true,
ty::TyAdt(..) => match_type(cx, ty, &paths::VEC), ty::TyAdt(..) => match_type(cx, ty, &paths::VEC),
ty::TyArray(_, size) => size < 32, ty::TyArray(_, size) => size < 32,
ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) | ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) => may_slice(cx, inner),
ty::TyBox(inner) => may_slice(cx, inner),
_ => false, _ => false,
} }
} }
@@ -966,8 +965,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: ty::Ty) -> Option<sug
} else { } else {
match ty.sty { match ty.sty {
ty::TySlice(_) => sugg::Sugg::hir_opt(cx, expr), ty::TySlice(_) => sugg::Sugg::hir_opt(cx, expr),
ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) | ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) => {
ty::TyBox(inner) => {
if may_slice(cx, inner) { if may_slice(cx, inner) {
sugg::Sugg::hir_opt(cx, expr) sugg::Sugg::hir_opt(cx, expr)
} else { } else {

View File

@@ -702,13 +702,10 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for TypeComplexityVisitor<'a, 'tcx> {
// function types bring a lot of overhead // function types bring a lot of overhead
TyBareFn(..) => (50 * self.nest, 1), TyBareFn(..) => (50 * self.nest, 1),
TyTraitObject(ref bounds) => { TyTraitObject(ref param_bounds, _) => {
let has_lifetimes = bounds.iter() let has_lifetime_parameters = param_bounds.iter()
.any(|bound| match *bound { .any(|bound| !bound.bound_lifetimes.is_empty());
TraitTyParamBound(ref poly_trait, ..) => !poly_trait.bound_lifetimes.is_empty(), if has_lifetime_parameters {
RegionTyParamBound(..) => true,
});
if has_lifetimes {
// complex trait bounds like A<'a, 'b> // complex trait bounds like A<'a, 'b>
(50 * self.nest, 1) (50 * self.nest, 1)
} else { } else {

View File

@@ -142,7 +142,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass {
fn is_lint_ref_type(ty: &Ty) -> bool { fn is_lint_ref_type(ty: &Ty) -> bool {
if let TyRptr(_, MutTy { ty: ref inner, mutbl: MutImmutable }) = ty.node { if let TyRptr(ref lt, MutTy { ty: ref inner, mutbl: MutImmutable }) = ty.node {
if lt.is_elided() {
return false;
}
if let TyPath(ref path) = inner.node { if let TyPath(ref path) = inner.node {
return match_path(path, &paths::LINT); return match_path(path, &paths::LINT);
} }