Rustup to rustc 1.22.0-nightly (6c476ce46 2017-09-25)

This commit is contained in:
Manish Goregaokar
2017-09-25 19:04:55 -07:00
parent 8408d48658
commit fabb6b6645
9 changed files with 69 additions and 44 deletions

View File

@@ -104,15 +104,15 @@ fn check_fn_inner<'a, 'tcx>(
for typ in &generics.ty_params {
for bound in &typ.bounds {
if let TraitTyParamBound(ref trait_ref, _) = *bound {
let bounds = &trait_ref
let params = &trait_ref
.trait_ref
.path
.segments
.last()
.expect("a path must have at least one segment")
.parameters
.lifetimes;
for bound in bounds {
.parameters;
if let Some(ref params) = *params {
for bound in &params.lifetimes {
if bound.name.name() != "'static" && !bound.is_elided() {
return;
}
@@ -121,6 +121,7 @@ fn check_fn_inner<'a, 'tcx>(
}
}
}
}
if could_use_elision(cx, decl, body, &generics.lifetimes, bounds_lts) {
span_lint(
cx,
@@ -287,7 +288,7 @@ impl<'v, 't> RefVisitor<'v, 't> {
}
fn collect_anonymous_lifetimes(&mut self, qpath: &QPath, ty: &Ty) {
let last_path_segment = &last_path_segment(qpath).parameters;
if let Some(ref last_path_segment) = last_path_segment(qpath).parameters {
if !last_path_segment.parenthesized && last_path_segment.lifetimes.is_empty() {
let hir_id = self.cx.tcx.hir.node_to_hir_id(ty.id);
match self.cx.tables.qpath_def(qpath, hir_id) {
@@ -307,6 +308,7 @@ impl<'v, 't> RefVisitor<'v, 't> {
}
}
}
}
}
impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {

View File

@@ -100,7 +100,8 @@ fn expr_eq_name(expr: &Expr, id: ast::Name) -> bool {
let arg_segment = [
PathSegment {
name: id,
parameters: PathParameters::none(),
parameters: None,
infer_types: true,
},
];
!path.is_global() && path.segments[..] == arg_segment

View File

@@ -1617,11 +1617,18 @@ fn is_as_ref_or_mut_trait(ty: &hir::Ty, self_ty: &hir::Ty, generics: &hir::Gener
match_path(path, name) &&
path.segments
.last()
.map_or(false, |s| if s.parameters.parenthesized {
.map_or(false, |s| {
if let Some(ref params) = s.parameters {
if params.parenthesized {
false
} else {
s.parameters.types.len() == 1 &&
(is_self_ty(&s.parameters.types[0]) || is_ty(&*s.parameters.types[0], self_ty))
params.types.len() == 1 &&
(is_self_ty(&params.types[0])
|| is_ty(&*params.types[0], self_ty))
}
} else {
false
}
})
} else {
false

View File

@@ -144,7 +144,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
let TyPath(QPath::Resolved(_, ref path)) = input.node,
let Some(elem_ty) = path.segments.iter()
.find(|seg| seg.name == "Vec")
.map(|ps| &ps.parameters.types[0]),
.and_then(|ref ps| ps.parameters.as_ref())
.map(|params| &params.types[0]),
], {
let slice_ty = format!("&[{}]", snippet(cx, elem_ty.span, "_"));
db.span_suggestion(input.span,

View File

@@ -159,7 +159,7 @@ fn check_fn(cx: &LateContext, decl: &FnDecl, fn_id: NodeId, opt_body_id: Option<
let mut ty_snippet = None;
if_let_chain!([
let TyPath(QPath::Resolved(_, ref path)) = walk_ptrs_hir_ty(arg).node,
let Some(&PathSegment{ref parameters, ..}) = path.segments.last(),
let Some(&PathSegment{parameters: Some(ref parameters), ..}) = path.segments.last(),
parameters.types.len() == 1,
], {
ty_snippet = snippet_opt(cx, parameters.types[0].span);

View File

@@ -194,8 +194,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
fn get_type_snippet(cx: &LateContext, path: &QPath, to_rty: Ty) -> String {
let seg = last_path_segment(path);
if_let_chain!{[
!seg.parameters.parenthesized,
let Some(to_ty) = seg.parameters.types.get(1),
let Some(ref params) = seg.parameters,
!params.parenthesized,
let Some(to_ty) = params.types.get(1),
let TyRptr(_, ref to_ty) = to_ty.node,
], {
return snippet(cx, to_ty.ty.span, &to_rty.to_string()).to_string();

View File

@@ -154,8 +154,9 @@ fn check_ty(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool) {
if Some(def_id) == cx.tcx.lang_items().owned_box() {
let last = last_path_segment(qpath);
if_let_chain! {[
!last.parameters.parenthesized,
let Some(vec) = last.parameters.types.get(0),
let Some(ref params) = last.parameters,
!params.parenthesized,
let Some(vec) = params.types.get(0),
let TyPath(ref qpath) = vec.node,
let Some(did) = opt_def_id(cx.tables.qpath_def(qpath, cx.tcx.hir.node_to_hir_id(vec.id))),
match_def_path(cx.tcx, did, &paths::VEC),
@@ -183,22 +184,26 @@ fn check_ty(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool) {
check_ty(cx, ty, is_local);
for ty in p.segments
.iter()
.flat_map(|seg| seg.parameters.types.iter())
.filter_map(|ref seg| seg.parameters.as_ref())
.flat_map(|ref params| params.types.iter())
{
check_ty(cx, ty, is_local);
}
},
QPath::Resolved(None, ref p) => for ty in p.segments
.iter()
.flat_map(|seg| seg.parameters.types.iter())
.filter_map(|ref seg| seg.parameters.as_ref())
.flat_map(|ref params| params.types.iter())
{
check_ty(cx, ty, is_local);
},
QPath::TypeRelative(ref ty, ref seg) => {
check_ty(cx, ty, is_local);
for ty in seg.parameters.types.iter() {
if let Some(ref params) = seg.parameters {
for ty in params.types.iter() {
check_ty(cx, ty, is_local);
}
}
},
}
},
@@ -212,8 +217,9 @@ fn check_ty(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool) {
Some(def_id) == cx.tcx.lang_items().owned_box(),
let QPath::Resolved(None, ref path) = *qpath,
let [ref bx] = *path.segments,
!bx.parameters.parenthesized,
let [ref inner] = *bx.parameters.types
let Some(ref params) = bx.parameters,
!params.parenthesized,
let [ref inner] = *params.types
], {
if is_any_trait(inner) {
// Ignore `Box<Any>` types, see #1884 for details.

View File

@@ -59,7 +59,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf {
let Ty_::TyPath(QPath::Resolved(_, ref item_path)) = item_type.node,
], {
let parameters = &item_path.segments.last().expect(SEGMENTS_MSG).parameters;
if !parameters.parenthesized && parameters.lifetimes.len() == 0 {
if parameters.is_none() {
let visitor = &mut UseSelfVisitor {
item_path: item_path,
cx: cx,

View File

@@ -214,7 +214,14 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
fn eq_path_segment(&self, left: &PathSegment, right: &PathSegment) -> bool {
// The == of idents doesn't work with different contexts,
// we have to be explicit about hygiene
left.name.as_str() == right.name.as_str() && self.eq_path_parameters(&left.parameters, &right.parameters)
if left.name.as_str() != right.name.as_str() {
return false;
}
match (&left.parameters, &right.parameters) {
(&None, &None) => true,
(&Some(ref l), &Some(ref r)) => self.eq_path_parameters(l, r),
_ => false
}
}
fn eq_ty(&self, left: &Ty, right: &Ty) -> bool {