Skip to content
Merged

Rustup #7604

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8e563b5
Bless clippy tests.
m-ou-se Aug 12, 2021
1ad5464
Merge commit '7bfc26ec8e7a454786668e7e52ffe527fc649735' into clippyup
flip1995 Aug 12, 2021
fd5427b
Rollup merge of #87885 - m-ou-se:edition-guide-links, r=rylev
GuillaumeGomez Aug 12, 2021
456e48f
Auto merge of #87954 - flip1995:clippyup, r=Manishearth
bors Aug 13, 2021
80bff87
move Constness into TraitPredicate
fee1-dead Jul 22, 2021
b97d4c0
Introduce hir::ExprKind::Let - Take 2
c410-f3r Aug 8, 2021
295225b
Uplift the `invalid_atomic_ordering` lint from clippy to rustc
thomcc Dec 2, 2020
d9c3f0d
Auto merge of #84039 - jyn514:uplift-atomic-ordering, r=wesleywiser
bors Aug 16, 2021
d5e51db
clippy: Fix format_args expansion parsing
camsteffen Jul 16, 2021
4123fed
remove box_syntax uses from cranelift and tools
hellow554 Aug 6, 2021
ae02282
Fix clippy let expressions fallout
camsteffen Aug 19, 2021
5fec618
introduce a Coerce predicate
nikomatsakis Nov 21, 2020
cd4bf7f
cleanup: `Span::new` -> `Span::with_lo`
petrochenkov Aug 21, 2021
e5fe462
Auto merge of #88163 - camsteffen:collapsible-match-fix, r=Manishearth
bors Aug 22, 2021
c860718
Fix typos “a”→“an”
steffahn Aug 22, 2021
21da42c
Fix more “a”/“an” typos
steffahn Aug 22, 2021
8b6529e
Fix typos “an”→“a” and a few different ones that appeared in the same…
steffahn Aug 22, 2021
5868e28
Rollup merge of #88211 - petrochenkov:withhilo, r=jyn514
GuillaumeGomez Aug 22, 2021
4c847c0
Rollup merge of #88230 - steffahn:a_an, r=oli-obk
m-ou-se Aug 23, 2021
72df99a
Auto merge of #83302 - camsteffen:write-piece-unchecked, r=dtolnay
bors Aug 23, 2021
4d627fc
require a `tcx` for `TypeVisitor`
lcnr Mar 13, 2021
19d1fe2
make unevaluated const substs optional
lcnr Mar 15, 2021
b1786f6
add `tcx` to `fn walk`
lcnr Jul 17, 2021
afd892a
update `TypeFlags` to deal with missing ct substs
lcnr Jul 17, 2021
8c4056f
Treat macros as HIR items
inquisitivecrystal Jul 31, 2021
c8262ad
Teach tools that macros are now HIR items
inquisitivecrystal Aug 5, 2021
0b526fd
rename const_evaluatable_checked to generic_const_exprs
BoxyUwU Aug 25, 2021
fd8b150
`feature(const_generics)` -> `feature(const_param_types)`
lcnr Aug 27, 2021
78bf4ac
Fix clippy for let-else
camsteffen Jul 25, 2021
61bb967
Merge remote-tracking branch 'upstream/master' into rustup2
flip1995 Sep 2, 2021
5722a7d
Fix manual_match with let-expressions
camsteffen Aug 26, 2021
588367b
Fix dogfood
camsteffen Aug 26, 2021
c7c2036
Fix remaining dogfood errors
flip1995 Aug 26, 2021
c2bb313
Add higher docs and remove some unneeded fields
camsteffen Aug 27, 2021
8bf2940
Fix matadata collection configuration formatting
xFrednet Aug 28, 2021
fb6839d
Bump nightly version -> 2021-09-02
flip1995 Sep 2, 2021
01b17af
Fix fallout from re-applying patches
flip1995 Sep 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add tcx to fn walk
  • Loading branch information
lcnr committed Aug 26, 2021
commit b1786f62edf8bc20de33a36973ffb307a13962f5
4 changes: 2 additions & 2 deletions clippy_lints/src/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn is_non_trait_box(ty: Ty<'_>) -> bool {
struct EscapeDelegate<'a, 'tcx> {
cx: &'a LateContext<'tcx>,
set: HirIdSet,
trait_self_ty: Option<Ty<'a>>,
trait_self_ty: Option<Ty<'tcx>>,
too_large_for_stack: u64,
}

Expand Down Expand Up @@ -171,7 +171,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
// skip if there is a `self` parameter binding to a type
// that contains `Self` (i.e.: `self: Box<Self>`), see #4804
if let Some(trait_self_ty) = self.trait_self_ty {
if map.name(cmt.hir_id) == kw::SelfLower && contains_ty(cmt.place.ty(), trait_self_ty) {
if map.name(cmt.hir_id) == kw::SelfLower && contains_ty(self.cx.tcx, cmt.place.ty(), trait_self_ty) {
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/let_underscore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
if let Some(init) = local.init;
then {
let init_ty = cx.typeck_results().expr_ty(init);
let contains_sync_guard = init_ty.walk().any(|inner| match inner.unpack() {
let contains_sync_guard = init_ty.walk(cx.tcx).any(|inner| match inner.unpack() {
GenericArgKind::Type(inner_ty) => {
SYNC_GUARD_PATHS.iter().any(|path| match_type(cx, inner_ty, path))
},
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/loops/same_item_push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub(super) fn check<'tcx>(
if same_item_push_visitor.should_lint();
if let Some((vec, pushed_item)) = same_item_push_visitor.vec_push;
let vec_ty = cx.typeck_results().expr_ty(vec);
let ty = vec_ty.walk().nth(1).unwrap().expect_ty();
let ty = vec_ty.walk(cx.tcx).nth(1).unwrap().expect_ty();
if cx
.tcx
.lang_items()
Expand Down
10 changes: 5 additions & 5 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1987,10 +1987,10 @@ impl<'tcx> LateLintPass<'tcx> for Methods {

// walk the return type and check for Self (this does not check associated types)
if let Some(self_adt) = self_ty.ty_adt_def() {
if contains_adt_constructor(ret_ty, self_adt) {
if contains_adt_constructor(cx.tcx, ret_ty, self_adt) {
return;
}
} else if contains_ty(ret_ty, self_ty) {
} else if contains_ty(cx.tcx, ret_ty, self_ty) {
return;
}

Expand All @@ -2001,10 +2001,10 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
if let ty::PredicateKind::Projection(projection_predicate) = predicate.kind().skip_binder() {
// walk the associated type and check for Self
if let Some(self_adt) = self_ty.ty_adt_def() {
if contains_adt_constructor(projection_predicate.ty, self_adt) {
if contains_adt_constructor(cx.tcx, projection_predicate.ty, self_adt) {
return;
}
} else if contains_ty(projection_predicate.ty, self_ty) {
} else if contains_ty(cx.tcx, projection_predicate.ty, self_ty) {
return;
}
}
Expand Down Expand Up @@ -2053,7 +2053,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
if let TraitItemKind::Fn(_, _) = item.kind;
let ret_ty = return_ty(cx, item.hir_id());
let self_ty = TraitRef::identity(cx.tcx, item.def_id.to_def_id()).self_ty();
if !contains_ty(ret_ty, self_ty);
if !contains_ty(cx.tcx, ret_ty, self_ty);

then {
span_lint(
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/returns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ impl<'tcx> Visitor<'tcx> for BorrowVisitor<'_, 'tcx> {
.fn_sig(def_id)
.output()
.skip_binder()
.walk()
.walk(self.cx.tcx)
.any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(_)));
}

Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/self_named_constructors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ impl<'tcx> LateLintPass<'tcx> for SelfNamedConstructors {

// Ensure method is constructor-like
if let Some(self_adt) = self_ty.ty_adt_def() {
if !contains_adt_constructor(ret_ty, self_adt) {
if !contains_adt_constructor(cx.tcx, ret_ty, self_adt) {
return;
}
} else if !contains_ty(ret_ty, self_ty) {
} else if !contains_ty(cx.tcx, ret_ty, self_ty) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/unnecessary_sort_by.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ fn detect_lint(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<LintTrigger> {

fn expr_borrows(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
let ty = cx.typeck_results().expr_ty(expr);
matches!(ty.kind(), ty::Ref(..)) || ty.walk().any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(_)))
matches!(ty.kind(), ty::Ref(..)) || ty.walk(cx.tcx).any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(_)))
}

impl LateLintPass<'_> for UnnecessarySortBy {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/use_self.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
//
// See also https://github.com/rust-lang/rust-clippy/issues/2894.
for (impl_hir_ty, trait_sem_ty) in impl_inputs_outputs.zip(trait_method_sig.inputs_and_output) {
if trait_sem_ty.walk().any(|inner| inner == self_ty.into()) {
if trait_sem_ty.walk(cx.tcx).any(|inner| inner == self_ty.into()) {
let mut visitor = SkipTyCollector::default();
visitor.visit_ty(impl_hir_ty);
types_to_skip.extend(visitor.types_to_skip);
Expand Down
4 changes: 2 additions & 2 deletions clippy_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1627,15 +1627,15 @@ pub fn is_slice_of_primitives(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<S
if is_primitive {
// if we have wrappers like Array, Slice or Tuple, print these
// and get the type enclosed in the slice ref
match expr_type.peel_refs().walk().nth(1).unwrap().expect_ty().kind() {
match expr_type.peel_refs().walk(cx.tcx).nth(1).unwrap().expect_ty().kind() {
rustc_ty::Slice(..) => return Some("slice".into()),
rustc_ty::Array(..) => return Some("array".into()),
rustc_ty::Tuple(..) => return Some("tuple".into()),
_ => {
// is_recursively_primitive_type() should have taken care
// of the rest and we can rely on the type that is found
let refs_peeled = expr_type.peel_refs();
return Some(refs_peeled.walk().last().unwrap().to_string());
return Some(refs_peeled.walk(cx.tcx).last().unwrap().to_string());
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_utils/src/qualify_min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn is_min_const_fn(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, msrv: Option<&Ru
}

fn check_ty(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span) -> McfResult {
for arg in ty.walk() {
for arg in ty.walk(tcx) {
let ty = match arg.unpack() {
GenericArgKind::Type(ty) => ty,

Expand Down
12 changes: 6 additions & 6 deletions clippy_utils/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_hir::{TyKind, Unsafety};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_lint::LateContext;
use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
use rustc_middle::ty::{self, AdtDef, IntTy, Ty, TypeFoldable, UintTy};
use rustc_middle::ty::{self, TyCtxt, AdtDef, IntTy, Ty, TypeFoldable, UintTy};
use rustc_span::sym;
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::DUMMY_SP;
Expand All @@ -36,17 +36,17 @@ pub fn can_partially_move_ty(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
}

/// Walks into `ty` and returns `true` if any inner type is the same as `other_ty`
pub fn contains_ty(ty: Ty<'_>, other_ty: Ty<'_>) -> bool {
ty.walk().any(|inner| match inner.unpack() {
pub fn contains_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, other_ty: Ty<'tcx>) -> bool {
ty.walk(tcx).any(|inner| match inner.unpack() {
GenericArgKind::Type(inner_ty) => ty::TyS::same_type(other_ty, inner_ty),
GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false,
})
}

/// Walks into `ty` and returns `true` if any inner type is an instance of the given adt
/// constructor.
pub fn contains_adt_constructor(ty: Ty<'_>, adt: &AdtDef) -> bool {
ty.walk().any(|inner| match inner.unpack() {
pub fn contains_adt_constructor<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, adt: &'tcx AdtDef) -> bool {
ty.walk(tcx).any(|inner| match inner.unpack() {
GenericArgKind::Type(inner_ty) => inner_ty.ty_adt_def() == Some(adt),
GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false,
})
Expand Down Expand Up @@ -209,7 +209,7 @@ fn is_normalizable_helper<'tcx>(
.iter()
.all(|field| is_normalizable_helper(cx, param_env, field.ty(cx.tcx, substs), cache))
}),
_ => ty.walk().all(|generic_arg| match generic_arg.unpack() {
_ => ty.walk(cx.tcx).all(|generic_arg| match generic_arg.unpack() {
GenericArgKind::Type(inner_ty) if inner_ty != ty => {
is_normalizable_helper(cx, param_env, inner_ty, cache)
},
Expand Down