Rustup to rustc 1.22.0-nightly (6c476ce46 2017-09-25)
This commit is contained in:
@@ -104,15 +104,15 @@ fn check_fn_inner<'a, 'tcx>(
|
|||||||
for typ in &generics.ty_params {
|
for typ in &generics.ty_params {
|
||||||
for bound in &typ.bounds {
|
for bound in &typ.bounds {
|
||||||
if let TraitTyParamBound(ref trait_ref, _) = *bound {
|
if let TraitTyParamBound(ref trait_ref, _) = *bound {
|
||||||
let bounds = &trait_ref
|
let params = &trait_ref
|
||||||
.trait_ref
|
.trait_ref
|
||||||
.path
|
.path
|
||||||
.segments
|
.segments
|
||||||
.last()
|
.last()
|
||||||
.expect("a path must have at least one segment")
|
.expect("a path must have at least one segment")
|
||||||
.parameters
|
.parameters;
|
||||||
.lifetimes;
|
if let Some(ref params) = *params {
|
||||||
for bound in bounds {
|
for bound in ¶ms.lifetimes {
|
||||||
if bound.name.name() != "'static" && !bound.is_elided() {
|
if bound.name.name() != "'static" && !bound.is_elided() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -121,6 +121,7 @@ fn check_fn_inner<'a, 'tcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if could_use_elision(cx, decl, body, &generics.lifetimes, bounds_lts) {
|
if could_use_elision(cx, decl, body, &generics.lifetimes, bounds_lts) {
|
||||||
span_lint(
|
span_lint(
|
||||||
cx,
|
cx,
|
||||||
@@ -287,7 +288,7 @@ impl<'v, 't> RefVisitor<'v, 't> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn collect_anonymous_lifetimes(&mut self, qpath: &QPath, ty: &Ty) {
|
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() {
|
if !last_path_segment.parenthesized && last_path_segment.lifetimes.is_empty() {
|
||||||
let hir_id = self.cx.tcx.hir.node_to_hir_id(ty.id);
|
let hir_id = self.cx.tcx.hir.node_to_hir_id(ty.id);
|
||||||
match self.cx.tables.qpath_def(qpath, hir_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> {
|
impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
|
||||||
|
|||||||
@@ -100,7 +100,8 @@ fn expr_eq_name(expr: &Expr, id: ast::Name) -> bool {
|
|||||||
let arg_segment = [
|
let arg_segment = [
|
||||||
PathSegment {
|
PathSegment {
|
||||||
name: id,
|
name: id,
|
||||||
parameters: PathParameters::none(),
|
parameters: None,
|
||||||
|
infer_types: true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
!path.is_global() && path.segments[..] == arg_segment
|
!path.is_global() && path.segments[..] == arg_segment
|
||||||
|
|||||||
@@ -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) &&
|
match_path(path, name) &&
|
||||||
path.segments
|
path.segments
|
||||||
.last()
|
.last()
|
||||||
.map_or(false, |s| if s.parameters.parenthesized {
|
.map_or(false, |s| {
|
||||||
|
if let Some(ref params) = s.parameters {
|
||||||
|
if params.parenthesized {
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
s.parameters.types.len() == 1 &&
|
params.types.len() == 1 &&
|
||||||
(is_self_ty(&s.parameters.types[0]) || is_ty(&*s.parameters.types[0], self_ty))
|
(is_self_ty(¶ms.types[0])
|
||||||
|
|| is_ty(&*params.types[0], self_ty))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|||||||
@@ -144,7 +144,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
|
|||||||
let TyPath(QPath::Resolved(_, ref path)) = input.node,
|
let TyPath(QPath::Resolved(_, ref path)) = input.node,
|
||||||
let Some(elem_ty) = path.segments.iter()
|
let Some(elem_ty) = path.segments.iter()
|
||||||
.find(|seg| seg.name == "Vec")
|
.find(|seg| seg.name == "Vec")
|
||||||
.map(|ps| &ps.parameters.types[0]),
|
.and_then(|ref ps| ps.parameters.as_ref())
|
||||||
|
.map(|params| ¶ms.types[0]),
|
||||||
], {
|
], {
|
||||||
let slice_ty = format!("&[{}]", snippet(cx, elem_ty.span, "_"));
|
let slice_ty = format!("&[{}]", snippet(cx, elem_ty.span, "_"));
|
||||||
db.span_suggestion(input.span,
|
db.span_suggestion(input.span,
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ fn check_fn(cx: &LateContext, decl: &FnDecl, fn_id: NodeId, opt_body_id: Option<
|
|||||||
let mut ty_snippet = None;
|
let mut ty_snippet = None;
|
||||||
if_let_chain!([
|
if_let_chain!([
|
||||||
let TyPath(QPath::Resolved(_, ref path)) = walk_ptrs_hir_ty(arg).node,
|
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,
|
parameters.types.len() == 1,
|
||||||
], {
|
], {
|
||||||
ty_snippet = snippet_opt(cx, parameters.types[0].span);
|
ty_snippet = snippet_opt(cx, parameters.types[0].span);
|
||||||
|
|||||||
@@ -194,8 +194,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
|
|||||||
fn get_type_snippet(cx: &LateContext, path: &QPath, to_rty: Ty) -> String {
|
fn get_type_snippet(cx: &LateContext, path: &QPath, to_rty: Ty) -> String {
|
||||||
let seg = last_path_segment(path);
|
let seg = last_path_segment(path);
|
||||||
if_let_chain!{[
|
if_let_chain!{[
|
||||||
!seg.parameters.parenthesized,
|
let Some(ref params) = seg.parameters,
|
||||||
let Some(to_ty) = seg.parameters.types.get(1),
|
!params.parenthesized,
|
||||||
|
let Some(to_ty) = params.types.get(1),
|
||||||
let TyRptr(_, ref to_ty) = to_ty.node,
|
let TyRptr(_, ref to_ty) = to_ty.node,
|
||||||
], {
|
], {
|
||||||
return snippet(cx, to_ty.ty.span, &to_rty.to_string()).to_string();
|
return snippet(cx, to_ty.ty.span, &to_rty.to_string()).to_string();
|
||||||
|
|||||||
@@ -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() {
|
if Some(def_id) == cx.tcx.lang_items().owned_box() {
|
||||||
let last = last_path_segment(qpath);
|
let last = last_path_segment(qpath);
|
||||||
if_let_chain! {[
|
if_let_chain! {[
|
||||||
!last.parameters.parenthesized,
|
let Some(ref params) = last.parameters,
|
||||||
let Some(vec) = last.parameters.types.get(0),
|
!params.parenthesized,
|
||||||
|
let Some(vec) = params.types.get(0),
|
||||||
let TyPath(ref qpath) = vec.node,
|
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))),
|
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),
|
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);
|
check_ty(cx, ty, is_local);
|
||||||
for ty in p.segments
|
for ty in p.segments
|
||||||
.iter()
|
.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);
|
check_ty(cx, ty, is_local);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
QPath::Resolved(None, ref p) => for ty in p.segments
|
QPath::Resolved(None, ref p) => for ty in p.segments
|
||||||
.iter()
|
.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);
|
check_ty(cx, ty, is_local);
|
||||||
},
|
},
|
||||||
QPath::TypeRelative(ref ty, ref seg) => {
|
QPath::TypeRelative(ref ty, ref seg) => {
|
||||||
check_ty(cx, ty, is_local);
|
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);
|
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(),
|
Some(def_id) == cx.tcx.lang_items().owned_box(),
|
||||||
let QPath::Resolved(None, ref path) = *qpath,
|
let QPath::Resolved(None, ref path) = *qpath,
|
||||||
let [ref bx] = *path.segments,
|
let [ref bx] = *path.segments,
|
||||||
!bx.parameters.parenthesized,
|
let Some(ref params) = bx.parameters,
|
||||||
let [ref inner] = *bx.parameters.types
|
!params.parenthesized,
|
||||||
|
let [ref inner] = *params.types
|
||||||
], {
|
], {
|
||||||
if is_any_trait(inner) {
|
if is_any_trait(inner) {
|
||||||
// Ignore `Box<Any>` types, see #1884 for details.
|
// Ignore `Box<Any>` types, see #1884 for details.
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf {
|
|||||||
let Ty_::TyPath(QPath::Resolved(_, ref item_path)) = item_type.node,
|
let Ty_::TyPath(QPath::Resolved(_, ref item_path)) = item_type.node,
|
||||||
], {
|
], {
|
||||||
let parameters = &item_path.segments.last().expect(SEGMENTS_MSG).parameters;
|
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 {
|
let visitor = &mut UseSelfVisitor {
|
||||||
item_path: item_path,
|
item_path: item_path,
|
||||||
cx: cx,
|
cx: cx,
|
||||||
|
|||||||
@@ -214,7 +214,14 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
|
|||||||
fn eq_path_segment(&self, left: &PathSegment, right: &PathSegment) -> bool {
|
fn eq_path_segment(&self, left: &PathSegment, right: &PathSegment) -> bool {
|
||||||
// The == of idents doesn't work with different contexts,
|
// The == of idents doesn't work with different contexts,
|
||||||
// we have to be explicit about hygiene
|
// 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 {
|
fn eq_ty(&self, left: &Ty, right: &Ty) -> bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user