Skip to content

Rustup #9323

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

Merged
merged 26 commits into from
Aug 11, 2022
Merged

Rustup #9323

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
af8ae10
Generate correct suggestion with named arguments used positionally
PrestonFrom Jul 16, 2022
67c405c
Merge commit '3c7e7dbc1583a0b06df5bd7623dd354a4debd23d' into clippyup
flip1995 Jul 28, 2022
61c6d16
Auto merge of #99660 - PrestonFrom:issue_99265, r=compiler-errors
bors Jul 29, 2022
1a6f02b
Remove `TreeAndSpacing`.
nnethercote Jul 28, 2022
ca0996e
Change maybe_body_owned_by to take local def id
kckeiks Jul 16, 2022
29a0f69
Rename local_did to def_id
kckeiks Jul 19, 2022
ce5fa10
Change enclosing_body_owner to return LocalDefId
kckeiks Jul 19, 2022
6c1110e
Avoid ICE when fetching LocalDefId
kckeiks Jul 20, 2022
ab7e555
Auto merge of #99887 - nnethercote:rm-TreeAndSpacing, r=petrochenkov
bors Jul 30, 2022
3641b0c
Auto merge of #99948 - Dylan-DPC:rollup-ed5136t, r=Dylan-DPC
bors Jul 30, 2022
6290772
Use LocalDefId for closures more
camsteffen Jul 12, 2022
72649cf
Rollup merge of #99186 - camsteffen:closure-localdefid, r=cjgillot
Dylan-DPC Jul 31, 2022
cd13574
Always include a position span in rustc_parse_format::Argument
Alexendoo Jul 31, 2022
09f9ace
Shrink `Token`.
nnethercote Jul 27, 2022
80a5687
Auto merge of #99884 - nnethercote:lexer-improvements, r=matklad
bors Aug 1, 2022
d17a30a
Store associated item defaultness in impl_defaultness.
cjgillot Mar 12, 2022
119247a
Remove DefId from AssocItemContainer.
cjgillot Mar 12, 2022
2fcaac7
move [`assertions_on_result_states`] to restriction
tabokie Aug 1, 2022
4546f5d
Rollup merge of #99987 - Alexendoo:parse-format-position-span, r=fee1…
matthiaskrgr Aug 2, 2022
7aaeee7
Rollup merge of #100053 - flip1995:clippy_backport, r=xFrednet
matthiaskrgr Aug 2, 2022
f232402
Warn about dead tuple struct fields
FabianWolff Jul 25, 2022
ccbc965
Add `traits::fully_solve_obligation` that acts like `traits::fully_no…
compiler-errors Aug 2, 2022
f719599
Auto merge of #99743 - compiler-errors:fulfillment-context-cleanups, …
bors Aug 6, 2022
879855b
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Aug 11, 2022
eda0b00
Bump nightly version -> 2022-08-11
flip1995 Aug 11, 2022
280b527
Bump Clippy version -> 0.1.65
flip1995 Aug 11, 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 Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clippy"
version = "0.1.64"
version = "0.1.65"
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
repository = "https://github.com/rust-lang/rust-clippy"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion clippy_dev/src/new_lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ fn setup_mod_file(path: &Path, lint: &LintData<'_>) -> io::Result<&'static str>
let mut lint_context = None;

let mut iter = rustc_lexer::tokenize(&file_contents).map(|t| {
let range = offset..offset + t.len;
let range = offset..offset + t.len as usize;
offset = range.end;

LintDeclSearchResult {
Expand Down
6 changes: 3 additions & 3 deletions clippy_dev/src/update_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ pub(crate) struct LintDeclSearchResult<'a> {
fn parse_contents(contents: &str, module: &str, lints: &mut Vec<Lint>) {
let mut offset = 0usize;
let mut iter = tokenize(contents).map(|t| {
let range = offset..offset + t.len;
let range = offset..offset + t.len as usize;
offset = range.end;

LintDeclSearchResult {
Expand Down Expand Up @@ -899,7 +899,7 @@ fn parse_contents(contents: &str, module: &str, lints: &mut Vec<Lint>) {
fn parse_deprecated_contents(contents: &str, lints: &mut Vec<DeprecatedLint>) {
let mut offset = 0usize;
let mut iter = tokenize(contents).map(|t| {
let range = offset..offset + t.len;
let range = offset..offset + t.len as usize;
offset = range.end;

LintDeclSearchResult {
Expand Down Expand Up @@ -946,7 +946,7 @@ fn parse_renamed_contents(contents: &str, lints: &mut Vec<RenamedLint>) {
for line in contents.lines() {
let mut offset = 0usize;
let mut iter = tokenize(line).map(|t| {
let range = offset..offset + t.len;
let range = offset..offset + t.len as usize;
offset = range.end;

LintDeclSearchResult {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clippy_lints"
version = "0.1.64"
version = "0.1.65"
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
repository = "https://github.com/rust-lang/rust-clippy"
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/crate_in_macro_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ fn contains_unhygienic_crate_reference(tts: &TokenStream) -> Option<Span> {

fn is_crate_keyword(tt: &TokenTree) -> Option<Span> {
if_chain! {
if let TokenTree::Token(Token { kind: TokenKind::Ident(symbol, _), span }) = tt;
if let TokenTree::Token(Token { kind: TokenKind::Ident(symbol, _), span }, _) = tt;
if symbol.as_str() == "crate";
then { Some(*span) } else { None }
}
}

fn is_token(tt: &TokenTree, kind: &TokenKind) -> bool {
if let TokenTree::Token(Token { kind: other, .. }) = tt {
if let TokenTree::Token(Token { kind: other, .. }, _) = tt {
kind == other
} else {
false
Expand Down
8 changes: 5 additions & 3 deletions clippy_lints/src/eta_reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,11 @@ fn check_sig<'tcx>(cx: &LateContext<'tcx>, closure_ty: Ty<'tcx>, call_ty: Ty<'tc
}

fn get_ufcs_type_name(cx: &LateContext<'_>, method_def_id: DefId) -> String {
match cx.tcx.associated_item(method_def_id).container {
ty::TraitContainer(def_id) => cx.tcx.def_path_str(def_id),
ty::ImplContainer(def_id) => {
let assoc_item = cx.tcx.associated_item(method_def_id);
let def_id = assoc_item.container_id(cx.tcx);
match assoc_item.container {
ty::TraitContainer => cx.tcx.def_path_str(def_id),
ty::ImplContainer => {
let ty = cx.tcx.type_of(def_id);
match ty.kind() {
ty::Adt(adt, _) => cx.tcx.def_path_str(adt.did()),
Expand Down
6 changes: 2 additions & 4 deletions clippy_lints/src/future_not_send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_middle::ty::{EarlyBinder, Opaque, PredicateKind::Trait};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::{sym, Span};
use rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt;
use rustc_trait_selection::traits::{self, FulfillmentError, TraitEngine};
use rustc_trait_selection::traits::{self, FulfillmentError};

declare_clippy_lint! {
/// ### What it does
Expand Down Expand Up @@ -80,9 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
let span = decl.output.span();
let send_errors = cx.tcx.infer_ctxt().enter(|infcx| {
let cause = traits::ObligationCause::misc(span, hir_id);
let mut fulfillment_cx = traits::FulfillmentContext::new();
fulfillment_cx.register_bound(&infcx, cx.param_env, ret_ty, send_trait, cause);
fulfillment_cx.select_all_or_error(&infcx)
traits::fully_solve_bound(&infcx, cause, cx.param_env, ret_ty, send_trait)
});
if !send_errors.is_empty() {
span_lint_and_then(
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ fn span_contains_cfg(cx: &LateContext<'_>, s: Span) -> bool {
let mut pos = 0usize;
let mut iter = tokenize(&snip).map(|t| {
let start = pos;
pos += t.len;
pos += t.len as usize;
(t.kind, start..pos)
});

Expand Down
3 changes: 2 additions & 1 deletion clippy_lints/src/methods/suspicious_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ pub fn check<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, count_recv: &hi
if_chain! {
if is_trait_method(cx, count_recv, sym::Iterator);
let closure = expr_or_init(cx, map_arg);
if let Some(body_id) = cx.tcx.hir().maybe_body_owned_by(closure.hir_id);
if let Some(def_id) = cx.tcx.hir().opt_local_def_id(closure.hir_id);
if let Some(body_id) = cx.tcx.hir().maybe_body_owned_by(def_id);
let closure_body = cx.tcx.hir().body(body_id);
if !cx.typeck_results().expr_ty(&closure_body.value).is_unit();
then {
Expand Down
15 changes: 7 additions & 8 deletions clippy_lints/src/missing_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,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::{self, DefIdTree};
use rustc_middle::ty::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 @@ -175,13 +175,12 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {

fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx hir::ImplItem<'_>) {
// If the method is an impl for a trait, don't doc.
match cx.tcx.associated_item(impl_item.def_id).container {
ty::TraitContainer(_) => return,
ty::ImplContainer(cid) => {
if cx.tcx.impl_trait_ref(cid).is_some() {
return;
}
},
if let Some(cid) = cx.tcx.associated_item(impl_item.def_id).impl_container(cx.tcx) {
if cx.tcx.impl_trait_ref(cid).is_some() {
return;
}
} else {
return;
}

let (article, desc) = cx.tcx.article_and_description(impl_item.def_id.to_def_id());
Expand Down
10 changes: 6 additions & 4 deletions clippy_lints/src/missing_inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
match tit_.kind {
hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => {},
hir::TraitItemKind::Fn(..) => {
if tit.defaultness.has_value() {
if cx.tcx.impl_defaultness(tit.id.def_id).has_value() {
// trait method with default body needs inline in case
// an impl is not provided
let desc = "a default trait method";
Expand Down Expand Up @@ -151,9 +151,11 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
hir::ImplItemKind::Const(..) | hir::ImplItemKind::TyAlias(_) => return,
};

let trait_def_id = match cx.tcx.associated_item(impl_item.def_id).container {
TraitContainer(cid) => Some(cid),
ImplContainer(cid) => cx.tcx.impl_trait_ref(cid).map(|t| t.def_id),
let assoc_item = cx.tcx.associated_item(impl_item.def_id);
let container_id = assoc_item.container_id(cx.tcx);
let trait_def_id = match assoc_item.container {
TraitContainer => Some(container_id),
ImplContainer => cx.tcx.impl_trait_ref(container_id).map(|t| t.def_id),
};

if let Some(trait_def_id) = trait_def_id {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/undocumented_unsafe_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ fn text_has_safety_comment(src: &str, line_starts: &[BytePos], offset: usize) ->
if line.starts_with("/*") {
let src = src[line_start..line_starts.last().unwrap().to_usize() - offset].trim_start();
let mut tokens = tokenize(src);
return src[..tokens.next().unwrap().len]
return src[..tokens.next().unwrap().len as usize]
.to_ascii_uppercase()
.contains("SAFETY:")
&& tokens.all(|t| t.kind == TokenKind::Whitespace);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/utils/author.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl<'tcx> LateLintPass<'tcx> for Author {

fn check_item(cx: &LateContext<'_>, hir_id: HirId) {
let hir = cx.tcx.hir();
if let Some(body_id) = hir.maybe_body_owned_by(hir_id) {
if let Some(body_id) = hir.maybe_body_owned_by(hir_id.expect_owner()) {
check_node(cx, hir_id, |v| {
v.expr(&v.bind("expr", &hir.body(body_id).value));
});
Expand Down
14 changes: 8 additions & 6 deletions clippy_lints/src/utils/internal_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,12 +496,14 @@ impl<'tcx> LateLintPass<'tcx> for LintWithoutLintPass {
cx,
};
let body_id = cx.tcx.hir().body_owned_by(
impl_item_refs
.iter()
.find(|iiref| iiref.ident.as_str() == "get_lints")
.expect("LintPass needs to implement get_lints")
.id
.hir_id(),
cx.tcx.hir().local_def_id(
impl_item_refs
.iter()
.find(|iiref| iiref.ident.as_str() == "get_lints")
.expect("LintPass needs to implement get_lints")
.id
.hir_id(),
),
);
collector.visit_expr(&cx.tcx.hir().body(body_id).value);
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ impl SimpleFormatArgs {
}
}
},
ArgumentNamed(n, _) => {
ArgumentNamed(n) => {
let n = Symbol::intern(n);
if let Some(x) = self.named.iter_mut().find(|x| x.0 == n) {
match x.1.as_slice() {
Expand Down
2 changes: 1 addition & 1 deletion clippy_utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clippy_utils"
version = "0.1.64"
version = "0.1.65"
edition = "2021"
publish = false

Expand Down
4 changes: 2 additions & 2 deletions clippy_utils/src/hir_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl HirEqInterExpr<'_, '_, '_> {
let mut left_pos = 0;
let left = tokenize(&left)
.map(|t| {
let end = left_pos + t.len;
let end = left_pos + t.len as usize;
let s = &left[left_pos..end];
left_pos = end;
(t, s)
Expand All @@ -156,7 +156,7 @@ impl HirEqInterExpr<'_, '_, '_> {
let mut right_pos = 0;
let right = tokenize(&right)
.map(|t| {
let end = right_pos + t.len;
let end = right_pos + t.len as usize;
let s = &right[right_pos..end];
right_pos = end;
(t, s)
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 @@ -969,7 +969,7 @@ pub fn can_move_expr_to_closure<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'
}
},
ExprKind::Closure { .. } => {
let closure_id = self.cx.tcx.hir().local_def_id(e.hir_id).to_def_id();
let closure_id = self.cx.tcx.hir().local_def_id(e.hir_id);
for capture in self.cx.typeck_results().closure_min_captures_flattened(closure_id) {
let local_id = match capture.place.base {
PlaceBase::Local(id) => id,
Expand Down Expand Up @@ -1354,7 +1354,7 @@ pub fn is_integer_const(cx: &LateContext<'_>, e: &Expr<'_>, value: u128) -> bool
if is_integer_literal(e, value) {
return true;
}
let enclosing_body = cx.tcx.hir().local_def_id(cx.tcx.hir().enclosing_body_owner(e.hir_id));
let enclosing_body = cx.tcx.hir().enclosing_body_owner(e.hir_id);
if let Some((Constant::Int(v), _)) = constant(cx, cx.tcx.typeck(enclosing_body), e) {
return value == v;
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2022-07-28"
channel = "nightly-2022-08-11"
components = ["cargo", "llvm-tools-preview", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]
1 change: 1 addition & 0 deletions tests/ui/borrow_interior_mutable_const/auxiliary/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// As the most common case is the `http` crate, it replicates `http::HeadewrName`'s structure.

#![allow(clippy::declare_interior_mutable_const)]
#![allow(unused_tuple_struct_fields)]

use std::sync::atomic::AtomicUsize;

Expand Down
1 change: 1 addition & 0 deletions tests/ui/format.fixed
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// run-rustfix

#![allow(
unused_tuple_struct_fields,
clippy::print_literal,
clippy::redundant_clone,
clippy::to_string_in_format_args,
Expand Down
1 change: 1 addition & 0 deletions tests/ui/format.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// run-rustfix

#![allow(
unused_tuple_struct_fields,
clippy::print_literal,
clippy::redundant_clone,
clippy::to_string_in_format_args,
Expand Down
Loading