Skip to content

Commit d020565

Browse files
committed
Hacky rustup
1 parent 61aa5c9 commit d020565

16 files changed

+91
-123
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ rustc_tools_util = { version = "0.1.1", path = "rustc_tools_util"}
4747
[dev-dependencies]
4848
clippy_dev = { version = "0.0.1", path = "clippy_dev" }
4949
cargo_metadata = "0.7.1"
50-
compiletest_rs = "0.3.19"
50+
compiletest_rs = { version = "=0.3.19", features = ["tmp", "stable"] }
51+
libtest = "0.0.1"
5152
lazy_static = "1.0"
5253
serde_derive = "1.0"
5354
clippy-mini-macro-test = { version = "0.2", path = "mini-macro" }

clippy_lints/src/attrs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ impl LintPass for AttrPass {
208208
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
209209
fn check_attribute(&mut self, cx: &LateContext<'a, 'tcx>, attr: &'tcx Attribute) {
210210
if let Some(items) = &attr.meta_item_list() {
211-
if let Some(ident) = attr.ident_str() {
212-
match ident {
211+
if let Some(ident) = attr.ident() {
212+
match &*ident.as_str() {
213213
"allow" | "warn" | "deny" | "forbid" => {
214214
check_clippy_lint_names(cx, items);
215215
},
@@ -242,8 +242,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
242242

243243
for attr in &item.attrs {
244244
if let Some(lint_list) = &attr.meta_item_list() {
245-
if let Some(ident) = attr.ident_str() {
246-
match ident {
245+
if let Some(ident) = attr.ident() {
246+
match &*ident.as_str() {
247247
"allow" | "warn" | "deny" | "forbid" => {
248248
// whitelist `unused_imports` and `deprecated` for `use` items
249249
// and `unused_imports` for `extern crate` items with `macro_use`

clippy_lints/src/matches.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,11 +516,11 @@ fn check_wild_enum_match(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm]) {
516516
for pat in &arm.pats {
517517
if let PatKind::Path(ref path) = pat.deref().node {
518518
if let QPath::Resolved(_, p) = path {
519-
missing_variants.retain(|e| e.did != p.def.def_id());
519+
missing_variants.retain(|e| e.ctor_def_id != Some(p.def.def_id()));
520520
}
521521
} else if let PatKind::TupleStruct(ref path, ..) = pat.deref().node {
522522
if let QPath::Resolved(_, p) = path {
523-
missing_variants.retain(|e| e.did != p.def.def_id());
523+
missing_variants.retain(|e| e.ctor_def_id != Some(p.def.def_id()));
524524
}
525525
}
526526
}
@@ -539,7 +539,7 @@ fn check_wild_enum_match(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm]) {
539539
String::new()
540540
};
541541
// This path assumes that the enum type is imported into scope.
542-
format!("{}{}{}", ident_str, cx.tcx.def_path_str(v.did), suffix)
542+
format!("{}{}{}", ident_str, cx.tcx.def_path_str(v.def_id), suffix)
543543
})
544544
.collect();
545545

clippy_lints/src/missing_doc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ impl MissingDoc {
5858
if let Some(meta) = meta;
5959
if let MetaItemKind::List(list) = meta.node;
6060
if let Some(meta) = list.get(0);
61-
if let Some(name) = meta.ident_str();
61+
if let Some(name) = meta.ident();
6262
then {
63-
name == "include"
63+
name.as_str() == "include"
6464
} else {
6565
false
6666
}

clippy_lints/src/missing_inline.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
162162
};
163163

164164
if let Some(trait_def_id) = trait_def_id {
165-
if cx.tcx.hir().as_local_node_id(trait_def_id).is_some() {
166-
if !cx.access_levels.is_exported(impl_item.hir_id) {
167-
// If a trait is being implemented for an item, and the
168-
// trait is not exported, we don't need #[inline]
169-
return;
170-
}
165+
if cx.tcx.hir().as_local_node_id(trait_def_id).is_some() && !cx.access_levels.is_exported(impl_item.hir_id)
166+
{
167+
// If a trait is being implemented for an item, and the
168+
// trait is not exported, we don't need #[inline]
169+
return;
171170
}
172171
}
173172

clippy_lints/src/no_effect.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn has_no_effect(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
7272
if let ExprKind::Path(ref qpath) = callee.node {
7373
let def = cx.tables.qpath_def(qpath, callee.hir_id);
7474
match def {
75-
Def::Struct(..) | Def::Variant(..) | Def::StructCtor(..) | Def::VariantCtor(..) => {
75+
Def::Struct(..) | Def::Variant(..) | Def::Ctor(..) => {
7676
!has_drop(cx, cx.tables.expr_ty(expr)) && args.iter().all(|arg| has_no_effect(cx, arg))
7777
},
7878
_ => false,
@@ -166,9 +166,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) -> Option<Vec
166166
if let ExprKind::Path(ref qpath) = callee.node {
167167
let def = cx.tables.qpath_def(qpath, callee.hir_id);
168168
match def {
169-
Def::Struct(..) | Def::Variant(..) | Def::StructCtor(..) | Def::VariantCtor(..)
170-
if !has_drop(cx, cx.tables.expr_ty(expr)) =>
171-
{
169+
Def::Struct(..) | Def::Variant(..) | Def::Ctor(..) if !has_drop(cx, cx.tables.expr_ty(expr)) => {
172170
Some(args.iter().collect())
173171
},
174172
_ => None,

clippy_lints/src/question_mark.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl Pass {
128128
},
129129
ExprKind::Ret(Some(ref expr)) => Self::expression_returns_none(cx, expr),
130130
ExprKind::Path(ref qp) => {
131-
if let Def::VariantCtor(def_id, _) = cx.tables.qpath_def(qp, expression.hir_id) {
131+
if let Def::Ctor(def_id, def::CtorOf::Variant, _) = cx.tables.qpath_def(qp, expression.hir_id) {
132132
return match_def_path(cx.tcx, def_id, &OPTION_NONE);
133133
}
134134

clippy_lints/src/ranges.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,25 +157,31 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
157157
}) = higher::range(cx, expr);
158158
if let Some(y) = y_plus_one(end);
159159
then {
160+
let span = expr.span
161+
.ctxt()
162+
.outer()
163+
.expn_info()
164+
.map(|info| info.call_site)
165+
.unwrap_or(expr.span);
160166
span_lint_and_then(
161167
cx,
162168
RANGE_PLUS_ONE,
163-
expr.span,
169+
span,
164170
"an inclusive range would be more readable",
165171
|db| {
166172
let start = start.map_or(String::new(), |x| Sugg::hir(cx, x, "x").to_string());
167173
let end = Sugg::hir(cx, y, "y");
168-
if let Some(is_wrapped) = &snippet_opt(cx, expr.span) {
174+
if let Some(is_wrapped) = &snippet_opt(cx, span) {
169175
if is_wrapped.starts_with('(') && is_wrapped.ends_with(')') {
170176
db.span_suggestion(
171-
expr.span,
177+
span,
172178
"use",
173179
format!("({}..={})", start, end),
174180
Applicability::MaybeIncorrect,
175181
);
176182
} else {
177183
db.span_suggestion(
178-
expr.span,
184+
span,
179185
"use",
180186
format!("{}..={}", start, end),
181187
Applicability::MachineApplicable, // snippet

clippy_lints/src/use_self.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> {
233233
if path.segments.last().expect(SEGMENTS_MSG).ident.name != SelfUpper.name() {
234234
if self.item_path.def == path.def {
235235
span_use_self_lint(self.cx, path);
236-
} else if let Def::StructCtor(ctor_did, CtorKind::Fn) = path.def {
236+
} else if let Def::Ctor(ctor_did, def::CtorOf::Struct, CtorKind::Fn) = path.def {
237237
if self.item_path.def.opt_def_id() == self.cx.tcx.parent(ctor_did) {
238238
span_use_self_lint(self.cx, path);
239239
}

clippy_lints/src/utils/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ pub fn is_refutable(cx: &LateContext<'_, '_>, pat: &Pat) -> bool {
863863
fn is_enum_variant(cx: &LateContext<'_, '_>, qpath: &QPath, id: HirId) -> bool {
864864
matches!(
865865
cx.tables.qpath_def(qpath, id),
866-
def::Def::Variant(..) | def::Def::VariantCtor(..)
866+
def::Def::Variant(..) | def::Def::Ctor(_, def::CtorOf::Variant, _)
867867
)
868868
}
869869

0 commit comments

Comments
 (0)