Skip to content

Rustup #8728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 29 commits into from
Closed

Rustup #8728

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bca346b
rebase and use ty::Const in patterns again
b-naber Mar 25, 2022
2f78075
get rid of visit_constant in thir visitor
b-naber Apr 6, 2022
7113135
Merge commit '984330a6ee3c4d15626685d6dc8b7b759ff630bd' into clippyup
flip1995 Apr 7, 2022
da26623
Update Cargo.lock
flip1995 Apr 8, 2022
b79f13e
Avoid looking at the internals of Interned directly
oli-obk Apr 8, 2022
2249168
Refactor HIR item-like traversal (part 1)
kckeiks Apr 3, 2022
3363a62
remove CheckVisitor, CollectExternCrateVisitor and ItemLikeVisitor impls
kckeiks Apr 7, 2022
0155a63
Auto merge of #95524 - oli-obk:cached_stable_hash_cleanups, r=nnether…
bors Apr 9, 2022
62d912e
Add new `Deinit` statement kind
JakobDegen Apr 5, 2022
5b7df24
errors: lazily load fallback fluent bundle
davidtwco Apr 12, 2022
27634b0
Auto merge of #94255 - b-naber:use-mir-constant-in-thir, r=oli-obk
bors Apr 13, 2022
a377ebc
Auto merge of #95968 - davidtwco:translation-lazy-fallback, r=oli-obk
bors Apr 13, 2022
0de314b
Reimplement lowering of sym operands for asm! so that it also works w…
Amanieu Mar 1, 2022
dc97080
Update issue-92893.stderr
ouz-a Apr 14, 2022
6f82524
clippy: Update full path to `CString`
petrochenkov Apr 15, 2022
3d5dc41
Rollup merge of #94849 - ouz-a:master4, r=oli-obk
Dylan-DPC Apr 15, 2022
5cf2920
Auto merge of #94468 - Amanieu:global_asm_sym, r=nagisa
bors Apr 16, 2022
cc25cbd
Auto merge of #95655 - kckeiks:create-hir-crate-items-query, r=cjgillot
bors Apr 17, 2022
e4110cf
Bless clippy.
cjgillot Apr 1, 2022
18a4411
Stop using CRATE_DEF_INDEX.
cjgillot Apr 15, 2022
cb1924a
Auto merge of #95779 - cjgillot:ast-lifetimes-undeclared, r=petrochenkov
bors Apr 17, 2022
60bb2a7
Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkov
Dylan-DPC Apr 19, 2022
fabc26f
Stop visiting visibility.
cjgillot Feb 13, 2022
abc8eb7
Drop vis in FieldDef.
cjgillot Feb 13, 2022
6ec33df
Drop vis in ImplItem.
cjgillot Feb 13, 2022
04024ba
Drop vis in Item.
cjgillot Feb 13, 2022
ec3afba
Make clippy inspector more precise.
cjgillot Feb 14, 2022
7fb9342
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Apr 28, 2022
a5cc047
Bump nightly version -> 2022-04-28
flip1995 Apr 28, 2022
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
2 changes: 1 addition & 1 deletion clippy_dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ indoc = "1.0"
itertools = "0.10.1"
opener = "0.5"
shell-escape = "0.1"
tempfile = "3.3"
tempfile = "3.2"
walkdir = "2.3"

[features]
Expand Down
5 changes: 2 additions & 3 deletions clippy_lints/src/case_sensitive_file_extension_comparisons.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use clippy_utils::diagnostics::span_lint_and_help;
use if_chain::if_chain;
use rustc_ast::ast::LitKind;
use rustc_data_structures::intern::Interned;
use rustc_hir::{Expr, ExprKind, PathSegment};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty;
Expand Down Expand Up @@ -56,8 +55,8 @@ fn check_case_sensitive_file_extension_comparison(ctx: &LateContext<'_>, expr: &
ty::Str => {
return Some(span);
},
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did, .. }, _)), _) => {
if ctx.tcx.is_diagnostic_item(sym::String, did) {
ty::Adt(def, _) => {
if ctx.tcx.is_diagnostic_item(sym::String, def.did()) {
return Some(span);
}
},
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/cognitive_complexity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl CognitiveComplexity {

if rust_cc > self.limit.limit() {
let fn_span = match kind {
FnKind::ItemFn(ident, _, _, _) | FnKind::Method(ident, _, _) => ident.span,
FnKind::ItemFn(ident, _, _) | FnKind::Method(ident, _) => ident.span,
FnKind::Closure => {
let header_span = body_span.with_hi(decl.output.span().lo());
let pos = snippet_opt(cx, header_span).and_then(|snip| {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) {

let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
let fallback_bundle =
rustc_errors::fallback_fluent_bundle(false).expect("failed to load fallback fluent bundle");
rustc_errors::fallback_fluent_bundle(rustc_errors::DEFAULT_LOCALE_RESOURCES, false);
let emitter = EmitterWriter::new(
Box::new(io::sink()),
None,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/enum_variants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ impl LateLintPass<'_> for EnumVariantNames {
}
// The `module_name_repetitions` lint should only trigger if the item has the module in its
// name. Having the same name is accepted.
if item.vis.node.is_pub() && item_camel.len() > mod_camel.len() {
if cx.tcx.visibility(item.def_id).is_public() && item_camel.len() > mod_camel.len() {
let matching = count_match_start(mod_camel, &item_camel);
let rmatching = count_match_end(mod_camel, &item_camel);
let nchars = mod_camel.chars().count();
Expand Down
5 changes: 4 additions & 1 deletion clippy_lints/src/exhaustive_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ impl LateLintPass<'_> for ExhaustiveItems {
if !attrs.iter().any(|a| a.has_name(sym::non_exhaustive));
then {
let (lint, msg) = if let ItemKind::Struct(ref v, ..) = item.kind {
if v.fields().iter().any(|f| !f.vis.node.is_pub()) {
if v.fields().iter().any(|f| {
let def_id = cx.tcx.hir().local_def_id(f.hir_id);
!cx.tcx.visibility(def_id).is_public()
}) {
// skip structs with private fields
return;
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ pub(super) fn check_fn<'tcx>(
hir_id: hir::HirId,
) {
let unsafety = match kind {
intravisit::FnKind::ItemFn(_, _, hir::FnHeader { unsafety, .. }, _) => unsafety,
intravisit::FnKind::Method(_, sig, _) => sig.header.unsafety,
intravisit::FnKind::ItemFn(_, _, hir::FnHeader { unsafety, .. }) => unsafety,
intravisit::FnKind::Method(_, sig) => sig.header.unsafety,
intravisit::FnKind::Closure => return,
};

Expand Down
3 changes: 1 addition & 2 deletions clippy_lints/src/functions/too_many_arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ pub(super) fn check_fn(
header: hir::FnHeader { abi: Abi::Rust, .. },
..
},
_,
)
| intravisit::FnKind::ItemFn(_, _, hir::FnHeader { abi: Abi::Rust, .. }, _) => check_arg_number(
| intravisit::FnKind::ItemFn(_, _, hir::FnHeader { abi: Abi::Rust, .. }) => check_arg_number(
cx,
decl,
span.with_hi(decl.output.span().hi()),
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/loops/needless_range_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub(super) fn check<'tcx>(
if let Some(indexed_extent) = indexed_extent {
let parent_def_id = cx.tcx.hir().get_parent_item(expr.hir_id);
let region_scope_tree = cx.tcx.region_scope_tree(parent_def_id);
let pat_extent = region_scope_tree.var_scope(pat.hir_id.local_id);
let pat_extent = region_scope_tree.var_scope(pat.hir_id.local_id).unwrap();
if region_scope_tree.is_subscope_of(indexed_extent, pat_extent) {
return;
}
Expand Down Expand Up @@ -262,7 +262,7 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> {
match res {
Res::Local(hir_id) => {
let parent_def_id = self.cx.tcx.hir().get_parent_item(expr.hir_id);
let extent = self.cx.tcx.region_scope_tree(parent_def_id).var_scope(hir_id.local_id);
let extent = self.cx.tcx.region_scope_tree(parent_def_id).var_scope(hir_id.local_id).unwrap();
if index_used_directly {
self.indexed_directly.insert(
seqvar.segments[0].ident.name,
Expand Down
10 changes: 6 additions & 4 deletions clippy_lints/src/loops/never_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,16 @@ fn never_loop_expr(expr: &Expr<'_>, main_loop_id: HirId) -> NeverLoopResult {
.operands
.iter()
.map(|(o, _)| match o {
InlineAsmOperand::In { expr, .. }
| InlineAsmOperand::InOut { expr, .. }
| InlineAsmOperand::Sym { expr } => never_loop_expr(expr, main_loop_id),
InlineAsmOperand::In { expr, .. } | InlineAsmOperand::InOut { expr, .. } => {
never_loop_expr(expr, main_loop_id)
},
InlineAsmOperand::Out { expr, .. } => never_loop_expr_all(&mut expr.iter(), main_loop_id),
InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
never_loop_expr_all(&mut once(in_expr).chain(out_expr.iter()), main_loop_id)
},
InlineAsmOperand::Const { .. } => NeverLoopResult::Otherwise,
InlineAsmOperand::Const { .. }
| InlineAsmOperand::SymFn { .. }
| InlineAsmOperand::SymStatic { .. } => NeverLoopResult::Otherwise,
})
.fold(NeverLoopResult::Otherwise, combine_both),
ExprKind::Struct(_, _, None)
Expand Down
2 changes: 0 additions & 2 deletions clippy_lints/src/matches/overlapping_arms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ fn all_ranges<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'_>], ty: Ty<'tcx>)
Some(rhs) => constant(cx, cx.typeck_results(), rhs)?.0,
None => miri_to_const(ty.numeric_max_val(cx.tcx)?)?,
};

let lhs_val = lhs_const.int_value(cx, ty)?;
let rhs_val = rhs_const.int_value(cx, ty)?;

let rhs_bound = match range_end {
RangeEnd::Included => EndBound::Included(rhs_val),
RangeEnd::Excluded => EndBound::Excluded(rhs_val),
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/missing_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use if_chain::if_chain;
use rustc_ast::ast::{self, MetaItem, MetaItemKind};
use rustc_hir as hir;
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::ty;
use rustc_middle::ty::{self, DefIdTree};
use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::def_id::CRATE_DEF_ID;
use rustc_span::source_map::Span;
Expand Down Expand Up @@ -131,8 +131,8 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
hir::ItemKind::Fn(..) => {
// ignore main()
if it.ident.name == sym::main {
let def_key = cx.tcx.hir().def_key(it.def_id);
if def_key.parent == Some(hir::def_id::CRATE_DEF_INDEX) {
let at_root = cx.tcx.local_parent(it.def_id) == Some(CRATE_DEF_ID);
if at_root {
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/needless_pass_by_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
}

match kind {
FnKind::ItemFn(.., header, _) => {
FnKind::ItemFn(.., header) => {
let attrs = cx.tcx.hir().attrs(hir_id);
if header.abi != Abi::Rust || requires_exact_signature(attrs) {
return;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/neg_multiply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl<'tcx> LateLintPass<'tcx> for NegMultiply {
fn check_mul(cx: &LateContext<'_>, span: Span, lit: &Expr<'_>, exp: &Expr<'_>) {
if_chain! {
if let ExprKind::Lit(ref l) = lit.kind;
if consts::lit_to_constant(&l.node, cx.typeck_results().expr_ty_opt(lit)) == Constant::Int(1);
if consts::lit_to_mir_constant(&l.node, cx.typeck_results().expr_ty_opt(lit)) == Constant::Int(1);
if cx.typeck_results().expr_ty(exp).is_integral();

then {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/pass_by_ref_or_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue {
}

match kind {
FnKind::ItemFn(.., header, _) => {
FnKind::ItemFn(.., header) => {
if header.abi != Abi::Rust {
return;
}
Expand Down
10 changes: 7 additions & 3 deletions clippy_lints/src/redundant_pub_crate.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use clippy_utils::diagnostics::span_lint_and_then;
use rustc_errors::Applicability;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::{Item, ItemKind, VisibilityKind};
use rustc_hir::{Item, ItemKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty;
use rustc_session::{declare_tool_lint, impl_lint_pass};
use rustc_span::def_id::CRATE_DEF_ID;
use rustc_span::hygiene::MacroKind;

declare_clippy_lint! {
Expand Down Expand Up @@ -44,7 +46,7 @@ impl_lint_pass!(RedundantPubCrate => [REDUNDANT_PUB_CRATE]);
impl<'tcx> LateLintPass<'tcx> for RedundantPubCrate {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
if_chain! {
if let VisibilityKind::Crate { .. } = item.vis.node;
if cx.tcx.visibility(item.def_id) == ty::Visibility::Restricted(CRATE_DEF_ID.to_def_id());
if !cx.access_levels.is_exported(item.def_id) && self.is_exported.last() == Some(&false);
if is_not_macro_export(item);
then {
Expand All @@ -57,7 +59,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantPubCrate {
&format!("pub(crate) {} inside private module", descr),
|diag| {
diag.span_suggestion(
item.vis.span,
item.vis_span,
"consider using",
"pub".to_string(),
Applicability::MachineApplicable,
Expand All @@ -84,6 +86,8 @@ fn is_not_macro_export<'tcx>(item: &'tcx Item<'tcx>) -> bool {
if let Res::Def(DefKind::Macro(MacroKind::Bang), _) = path.res {
return false;
}
} else if let ItemKind::Macro(..) = item.kind {
return false;
}

true
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/return_self_not_must_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl<'tcx> LateLintPass<'tcx> for ReturnSelfNotMustUse {
) {
if_chain! {
// We are only interested in methods, not in functions or associated functions.
if matches!(kind, FnKind::Method(_, _, _));
if matches!(kind, FnKind::Method(_, _));
if let Some(fn_def) = cx.tcx.hir().opt_local_def_id(hir_id);
if let Some(impl_def) = cx.tcx.impl_of_method(fn_def.to_def_id());
// We don't want this method to be te implementation of a trait because the
Expand Down
Loading