Skip to content

Commit 2b2190c

Browse files
committed
Auto merge of #9323 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents f7e2cb4 + 280b527 commit 2b2190c

36 files changed

+108
-95
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.64"
3+
version = "0.1.65"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

clippy_dev/src/new_lint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ fn setup_mod_file(path: &Path, lint: &LintData<'_>) -> io::Result<&'static str>
438438
let mut lint_context = None;
439439

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

444444
LintDeclSearchResult {

clippy_dev/src/update_lints.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ pub(crate) struct LintDeclSearchResult<'a> {
836836
fn parse_contents(contents: &str, module: &str, lints: &mut Vec<Lint>) {
837837
let mut offset = 0usize;
838838
let mut iter = tokenize(contents).map(|t| {
839-
let range = offset..offset + t.len;
839+
let range = offset..offset + t.len as usize;
840840
offset = range.end;
841841

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

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

952952
LintDeclSearchResult {

clippy_lints/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_lints"
3-
version = "0.1.64"
3+
version = "0.1.65"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

clippy_lints/src/crate_in_macro_def.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ fn contains_unhygienic_crate_reference(tts: &TokenStream) -> Option<Span> {
110110

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

119119
fn is_token(tt: &TokenTree, kind: &TokenKind) -> bool {
120-
if let TokenTree::Token(Token { kind: other, .. }) = tt {
120+
if let TokenTree::Token(Token { kind: other, .. }, _) = tt {
121121
kind == other
122122
} else {
123123
false

clippy_lints/src/eta_reduction.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,11 @@ fn check_sig<'tcx>(cx: &LateContext<'tcx>, closure_ty: Ty<'tcx>, call_ty: Ty<'tc
220220
}
221221

222222
fn get_ufcs_type_name(cx: &LateContext<'_>, method_def_id: DefId) -> String {
223-
match cx.tcx.associated_item(method_def_id).container {
224-
ty::TraitContainer(def_id) => cx.tcx.def_path_str(def_id),
225-
ty::ImplContainer(def_id) => {
223+
let assoc_item = cx.tcx.associated_item(method_def_id);
224+
let def_id = assoc_item.container_id(cx.tcx);
225+
match assoc_item.container {
226+
ty::TraitContainer => cx.tcx.def_path_str(def_id),
227+
ty::ImplContainer => {
226228
let ty = cx.tcx.type_of(def_id);
227229
match ty.kind() {
228230
ty::Adt(adt, _) => cx.tcx.def_path_str(adt.did()),

clippy_lints/src/future_not_send.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::ty::{EarlyBinder, Opaque, PredicateKind::Trait};
99
use rustc_session::{declare_lint_pass, declare_tool_lint};
1010
use rustc_span::{sym, Span};
1111
use rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt;
12-
use rustc_trait_selection::traits::{self, FulfillmentError, TraitEngine};
12+
use rustc_trait_selection::traits::{self, FulfillmentError};
1313

1414
declare_clippy_lint! {
1515
/// ### What it does
@@ -80,9 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
8080
let span = decl.output.span();
8181
let send_errors = cx.tcx.infer_ctxt().enter(|infcx| {
8282
let cause = traits::ObligationCause::misc(span, hir_id);
83-
let mut fulfillment_cx = traits::FulfillmentContext::new();
84-
fulfillment_cx.register_bound(&infcx, cx.param_env, ret_ty, send_trait, cause);
85-
fulfillment_cx.select_all_or_error(&infcx)
83+
traits::fully_solve_bound(&infcx, cause, cx.param_env, ret_ty, send_trait)
8684
});
8785
if !send_errors.is_empty() {
8886
span_lint_and_then(

clippy_lints/src/matches/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ fn span_contains_cfg(cx: &LateContext<'_>, s: Span) -> bool {
11121112
let mut pos = 0usize;
11131113
let mut iter = tokenize(&snip).map(|t| {
11141114
let start = pos;
1115-
pos += t.len;
1115+
pos += t.len as usize;
11161116
(t.kind, start..pos)
11171117
});
11181118

clippy_lints/src/methods/suspicious_map.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ pub fn check<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, count_recv: &hi
1212
if_chain! {
1313
if is_trait_method(cx, count_recv, sym::Iterator);
1414
let closure = expr_or_init(cx, map_arg);
15-
if let Some(body_id) = cx.tcx.hir().maybe_body_owned_by(closure.hir_id);
15+
if let Some(def_id) = cx.tcx.hir().opt_local_def_id(closure.hir_id);
16+
if let Some(body_id) = cx.tcx.hir().maybe_body_owned_by(def_id);
1617
let closure_body = cx.tcx.hir().body(body_id);
1718
if !cx.typeck_results().expr_ty(&closure_body.value).is_unit();
1819
then {

clippy_lints/src/missing_doc.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use if_chain::if_chain;
1212
use rustc_ast::ast::{self, MetaItem, MetaItemKind};
1313
use rustc_hir as hir;
1414
use rustc_lint::{LateContext, LateLintPass, LintContext};
15-
use rustc_middle::ty::{self, DefIdTree};
15+
use rustc_middle::ty::DefIdTree;
1616
use rustc_session::{declare_tool_lint, impl_lint_pass};
1717
use rustc_span::def_id::CRATE_DEF_ID;
1818
use rustc_span::source_map::Span;
@@ -175,13 +175,12 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
175175

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

187186
let (article, desc) = cx.tcx.article_and_description(impl_item.def_id.to_def_id());

clippy_lints/src/missing_inline.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
105105
match tit_.kind {
106106
hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => {},
107107
hir::TraitItemKind::Fn(..) => {
108-
if tit.defaultness.has_value() {
108+
if cx.tcx.impl_defaultness(tit.id.def_id).has_value() {
109109
// trait method with default body needs inline in case
110110
// an impl is not provided
111111
let desc = "a default trait method";
@@ -151,9 +151,11 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
151151
hir::ImplItemKind::Const(..) | hir::ImplItemKind::TyAlias(_) => return,
152152
};
153153

154-
let trait_def_id = match cx.tcx.associated_item(impl_item.def_id).container {
155-
TraitContainer(cid) => Some(cid),
156-
ImplContainer(cid) => cx.tcx.impl_trait_ref(cid).map(|t| t.def_id),
154+
let assoc_item = cx.tcx.associated_item(impl_item.def_id);
155+
let container_id = assoc_item.container_id(cx.tcx);
156+
let trait_def_id = match assoc_item.container {
157+
TraitContainer => Some(container_id),
158+
ImplContainer => cx.tcx.impl_trait_ref(container_id).map(|t| t.def_id),
157159
};
158160

159161
if let Some(trait_def_id) = trait_def_id {

clippy_lints/src/undocumented_unsafe_blocks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ fn text_has_safety_comment(src: &str, line_starts: &[BytePos], offset: usize) ->
345345
if line.starts_with("/*") {
346346
let src = src[line_start..line_starts.last().unwrap().to_usize() - offset].trim_start();
347347
let mut tokens = tokenize(src);
348-
return src[..tokens.next().unwrap().len]
348+
return src[..tokens.next().unwrap().len as usize]
349349
.to_ascii_uppercase()
350350
.contains("SAFETY:")
351351
&& tokens.all(|t| t.kind == TokenKind::Whitespace);

clippy_lints/src/utils/author.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl<'tcx> LateLintPass<'tcx> for Author {
138138

139139
fn check_item(cx: &LateContext<'_>, hir_id: HirId) {
140140
let hir = cx.tcx.hir();
141-
if let Some(body_id) = hir.maybe_body_owned_by(hir_id) {
141+
if let Some(body_id) = hir.maybe_body_owned_by(hir_id.expect_owner()) {
142142
check_node(cx, hir_id, |v| {
143143
v.expr(&v.bind("expr", &hir.body(body_id).value));
144144
});

clippy_lints/src/utils/internal_lints.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -496,12 +496,14 @@ impl<'tcx> LateLintPass<'tcx> for LintWithoutLintPass {
496496
cx,
497497
};
498498
let body_id = cx.tcx.hir().body_owned_by(
499-
impl_item_refs
500-
.iter()
501-
.find(|iiref| iiref.ident.as_str() == "get_lints")
502-
.expect("LintPass needs to implement get_lints")
503-
.id
504-
.hir_id(),
499+
cx.tcx.hir().local_def_id(
500+
impl_item_refs
501+
.iter()
502+
.find(|iiref| iiref.ident.as_str() == "get_lints")
503+
.expect("LintPass needs to implement get_lints")
504+
.id
505+
.hir_id(),
506+
),
505507
);
506508
collector.visit_expr(&cx.tcx.hir().body(body_id).value);
507509
}

clippy_lints/src/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ impl SimpleFormatArgs {
462462
}
463463
}
464464
},
465-
ArgumentNamed(n, _) => {
465+
ArgumentNamed(n) => {
466466
let n = Symbol::intern(n);
467467
if let Some(x) = self.named.iter_mut().find(|x| x.0 == n) {
468468
match x.1.as_slice() {

clippy_utils/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_utils"
3-
version = "0.1.64"
3+
version = "0.1.65"
44
edition = "2021"
55
publish = false
66

clippy_utils/src/hir_utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl HirEqInterExpr<'_, '_, '_> {
141141
let mut left_pos = 0;
142142
let left = tokenize(&left)
143143
.map(|t| {
144-
let end = left_pos + t.len;
144+
let end = left_pos + t.len as usize;
145145
let s = &left[left_pos..end];
146146
left_pos = end;
147147
(t, s)
@@ -156,7 +156,7 @@ impl HirEqInterExpr<'_, '_, '_> {
156156
let mut right_pos = 0;
157157
let right = tokenize(&right)
158158
.map(|t| {
159-
let end = right_pos + t.len;
159+
let end = right_pos + t.len as usize;
160160
let s = &right[right_pos..end];
161161
right_pos = end;
162162
(t, s)

clippy_utils/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ pub fn can_move_expr_to_closure<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'
969969
}
970970
},
971971
ExprKind::Closure { .. } => {
972-
let closure_id = self.cx.tcx.hir().local_def_id(e.hir_id).to_def_id();
972+
let closure_id = self.cx.tcx.hir().local_def_id(e.hir_id);
973973
for capture in self.cx.typeck_results().closure_min_captures_flattened(closure_id) {
974974
let local_id = match capture.place.base {
975975
PlaceBase::Local(id) => id,
@@ -1354,7 +1354,7 @@ pub fn is_integer_const(cx: &LateContext<'_>, e: &Expr<'_>, value: u128) -> bool
13541354
if is_integer_literal(e, value) {
13551355
return true;
13561356
}
1357-
let enclosing_body = cx.tcx.hir().local_def_id(cx.tcx.hir().enclosing_body_owner(e.hir_id));
1357+
let enclosing_body = cx.tcx.hir().enclosing_body_owner(e.hir_id);
13581358
if let Some((Constant::Int(v), _)) = constant(cx, cx.tcx.typeck(enclosing_body), e) {
13591359
return value == v;
13601360
}

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2022-07-28"
2+
channel = "nightly-2022-08-11"
33
components = ["cargo", "llvm-tools-preview", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]

tests/ui/borrow_interior_mutable_const/auxiliary/helper.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// As the most common case is the `http` crate, it replicates `http::HeadewrName`'s structure.
33

44
#![allow(clippy::declare_interior_mutable_const)]
5+
#![allow(unused_tuple_struct_fields)]
56

67
use std::sync::atomic::AtomicUsize;
78

tests/ui/format.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// run-rustfix
22

33
#![allow(
4+
unused_tuple_struct_fields,
45
clippy::print_literal,
56
clippy::redundant_clone,
67
clippy::to_string_in_format_args,

tests/ui/format.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// run-rustfix
22

33
#![allow(
4+
unused_tuple_struct_fields,
45
clippy::print_literal,
56
clippy::redundant_clone,
67
clippy::to_string_in_format_args,

0 commit comments

Comments
 (0)