Skip to content

Commit 25a1156

Browse files
authored
Merge pull request #3905 from rust-lang/compiletest
Hacky rustup
2 parents 61aa5c9 + 4192779 commit 25a1156

23 files changed

+114
-74
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/enum_glob_use.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ impl LintPass for EnumGlobUse {
3939

4040
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EnumGlobUse {
4141
fn check_mod(&mut self, cx: &LateContext<'a, 'tcx>, m: &'tcx Mod, _: Span, _: HirId) {
42+
let map = cx.tcx.hir();
4243
// only check top level `use` statements
4344
for item in &m.item_ids {
44-
self.lint_item(cx, cx.tcx.hir().expect_item(item.id));
45+
self.lint_item(cx, map.expect_item(map.hir_to_node_id(item.id)));
4546
}
4647
}
4748
}

clippy_lints/src/lifetimes.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,8 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
356356
self.collect_anonymous_lifetimes(path, ty);
357357
},
358358
TyKind::Def(item, _) => {
359-
if let ItemKind::Existential(ref exist_ty) = self.cx.tcx.hir().expect_item(item.id).node {
359+
let map = self.cx.tcx.hir();
360+
if let ItemKind::Existential(ref exist_ty) = map.expect_item(map.hir_to_node_id(item.id)).node {
360361
for bound in &exist_ty.bounds {
361362
if let GenericBound::Outlives(_) = *bound {
362363
self.record(&None);

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: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,25 +157,30 @@ 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_or(expr.span, |info| info.call_site);
160165
span_lint_and_then(
161166
cx,
162167
RANGE_PLUS_ONE,
163-
expr.span,
168+
span,
164169
"an inclusive range would be more readable",
165170
|db| {
166171
let start = start.map_or(String::new(), |x| Sugg::hir(cx, x, "x").to_string());
167172
let end = Sugg::hir(cx, y, "y");
168-
if let Some(is_wrapped) = &snippet_opt(cx, expr.span) {
173+
if let Some(is_wrapped) = &snippet_opt(cx, span) {
169174
if is_wrapped.starts_with('(') && is_wrapped.ends_with(')') {
170175
db.span_suggestion(
171-
expr.span,
176+
span,
172177
"use",
173178
format!("({}..={})", start, end),
174179
Applicability::MaybeIncorrect,
175180
);
176181
} else {
177182
db.span_suggestion(
178-
expr.span,
183+
span,
179184
"use",
180185
format!("{}..={}", start, end),
181186
Applicability::MachineApplicable, // snippet

0 commit comments

Comments
 (0)