Skip to content

Commit d5e2a7a

Browse files
committed
Auto merge of #10539 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents c72c914 + 8134414 commit d5e2a7a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+177
-218
lines changed

COPYRIGHT

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
// REUSE-IgnoreStart
2+
13
Copyright 2014-2022 The Rust Project Developers
24

35
Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
46
http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
57
<LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
68
option. All files in the project carrying such notice may not be
79
copied, modified, or distributed except according to those terms.
10+
11+
// REUSE-IgnoreEnd

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,14 @@ If you want to contribute to Clippy, you can find more information in [CONTRIBUT
275275

276276
## License
277277

278+
<!-- REUSE-IgnoreStart -->
279+
278280
Copyright 2014-2022 The Rust Project Developers
279281

280282
Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
281283
[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)> or the MIT license
282284
<LICENSE-MIT or [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT)>, at your
283285
option. Files in the project may not be
284286
copied, modified, or distributed except according to those terms.
287+
288+
<!-- REUSE-IgnoreEnd -->

clippy_lints/src/cognitive_complexity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl<'tcx> LateLintPass<'tcx> for CognitiveComplexity {
143143
span: Span,
144144
def_id: LocalDefId,
145145
) {
146-
if !cx.tcx.has_attr(def_id.to_def_id(), sym::test) {
146+
if !cx.tcx.has_attr(def_id, sym::test) {
147147
let expr = if is_async_fn(kind) {
148148
match get_async_fn_body(cx.tcx, body) {
149149
Some(b) => b,

clippy_lints/src/derivable_impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
181181
self_ty,
182182
..
183183
}) = item.kind;
184-
if !cx.tcx.has_attr(item.owner_id.to_def_id(), sym::automatically_derived);
184+
if !cx.tcx.has_attr(item.owner_id, sym::automatically_derived);
185185
if !item.span.from_expansion();
186186
if let Some(def_id) = trait_ref.trait_def_id();
187187
if cx.tcx.is_diagnostic_item(sym::Default, def_id);

clippy_lints/src/derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl<'tcx> LateLintPass<'tcx> for Derive {
212212
}) = item.kind
213213
{
214214
let ty = cx.tcx.type_of(item.owner_id).subst_identity();
215-
let is_automatically_derived = cx.tcx.has_attr(item.owner_id.to_def_id(), sym::automatically_derived);
215+
let is_automatically_derived = cx.tcx.has_attr(item.owner_id, sym::automatically_derived);
216216

217217
check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);
218218
check_ord_partial_ord(cx, item.span, trait_ref, ty, is_automatically_derived);

clippy_lints/src/functions/must_use.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ use super::{DOUBLE_MUST_USE, MUST_USE_CANDIDATE, MUST_USE_UNIT};
2222

2323
pub(super) fn check_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
2424
let attrs = cx.tcx.hir().attrs(item.hir_id());
25-
let attr = cx.tcx.get_attr(item.owner_id.to_def_id(), sym::must_use);
25+
let attr = cx.tcx.get_attr(item.owner_id, sym::must_use);
2626
if let hir::ItemKind::Fn(ref sig, _generics, ref body_id) = item.kind {
2727
let is_public = cx.effective_visibilities.is_exported(item.owner_id.def_id);
2828
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
2929
if let Some(attr) = attr {
3030
check_needless_must_use(cx, sig.decl, item.owner_id, item.span, fn_header_span, attr);
31-
} else if is_public && !is_proc_macro(cx.sess(), attrs) && !attrs.iter().any(|a| a.has_name(sym::no_mangle)) {
31+
} else if is_public && !is_proc_macro(attrs) && !attrs.iter().any(|a| a.has_name(sym::no_mangle)) {
3232
check_must_use_candidate(
3333
cx,
3434
sig.decl,
@@ -47,13 +47,10 @@ pub(super) fn check_impl_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Imp
4747
let is_public = cx.effective_visibilities.is_exported(item.owner_id.def_id);
4848
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
4949
let attrs = cx.tcx.hir().attrs(item.hir_id());
50-
let attr = cx.tcx.get_attr(item.owner_id.to_def_id(), sym::must_use);
50+
let attr = cx.tcx.get_attr(item.owner_id, sym::must_use);
5151
if let Some(attr) = attr {
5252
check_needless_must_use(cx, sig.decl, item.owner_id, item.span, fn_header_span, attr);
53-
} else if is_public
54-
&& !is_proc_macro(cx.sess(), attrs)
55-
&& trait_ref_of_method(cx, item.owner_id.def_id).is_none()
56-
{
53+
} else if is_public && !is_proc_macro(attrs) && trait_ref_of_method(cx, item.owner_id.def_id).is_none() {
5754
check_must_use_candidate(
5855
cx,
5956
sig.decl,
@@ -73,12 +70,12 @@ pub(super) fn check_trait_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Tr
7370
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
7471

7572
let attrs = cx.tcx.hir().attrs(item.hir_id());
76-
let attr = cx.tcx.get_attr(item.owner_id.to_def_id(), sym::must_use);
73+
let attr = cx.tcx.get_attr(item.owner_id, sym::must_use);
7774
if let Some(attr) = attr {
7875
check_needless_must_use(cx, sig.decl, item.owner_id, item.span, fn_header_span, attr);
7976
} else if let hir::TraitFn::Provided(eid) = *eid {
8077
let body = cx.tcx.hir().body(eid);
81-
if attr.is_none() && is_public && !is_proc_macro(cx.sess(), attrs) {
78+
if attr.is_none() && is_public && !is_proc_macro(attrs) {
8279
check_must_use_candidate(
8380
cx,
8481
sig.decl,

clippy_lints/src/future_not_send.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
99
use rustc_span::def_id::LocalDefId;
1010
use rustc_span::{sym, Span};
1111
use rustc_trait_selection::traits::error_reporting::suggestions::TypeErrCtxtExt;
12-
use rustc_trait_selection::traits::{self, FulfillmentError};
12+
use rustc_trait_selection::traits::{self, FulfillmentError, ObligationCtxt};
1313

1414
declare_clippy_lint! {
1515
/// ### What it does
@@ -79,8 +79,10 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
7979
let send_trait = cx.tcx.get_diagnostic_item(sym::Send).unwrap();
8080
let span = decl.output.span();
8181
let infcx = cx.tcx.infer_ctxt().build();
82+
let ocx = ObligationCtxt::new(&infcx);
8283
let cause = traits::ObligationCause::misc(span, fn_def_id);
83-
let send_errors = traits::fully_solve_bound(&infcx, cause, cx.param_env, ret_ty, send_trait);
84+
ocx.register_bound(cause, cx.param_env, ret_ty, send_trait);
85+
let send_errors = ocx.select_all_or_error();
8486
if !send_errors.is_empty() {
8587
span_lint_and_then(
8688
cx,

clippy_lints/src/infinite_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ fn is_infinite(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness {
167167
Finite
168168
},
169169
ExprKind::Block(block, _) => block.expr.as_ref().map_or(Finite, |e| is_infinite(cx, e)),
170-
ExprKind::Box(e) | ExprKind::AddrOf(BorrowKind::Ref, _, e) => is_infinite(cx, e),
170+
ExprKind::AddrOf(BorrowKind::Ref, _, e) => is_infinite(cx, e),
171171
ExprKind::Call(path, _) => {
172172
if let ExprKind::Path(ref qpath) = path.kind {
173173
cx.qpath_res(qpath, path.hir_id)

clippy_lints/src/loops/never_loop.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ fn stmt_to_expr<'tcx>(stmt: &Stmt<'tcx>) -> Option<(&'tcx Expr<'tcx>, Option<&'t
124124
#[allow(clippy::too_many_lines)]
125125
fn never_loop_expr(expr: &Expr<'_>, ignore_ids: &mut Vec<HirId>, main_loop_id: HirId) -> NeverLoopResult {
126126
match expr.kind {
127-
ExprKind::Box(e)
128-
| ExprKind::Unary(_, e)
127+
ExprKind::Unary(_, e)
129128
| ExprKind::Cast(e, _)
130129
| ExprKind::Type(e, _)
131130
| ExprKind::Field(e, _)

clippy_lints/src/manual_async_fn.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use clippy_utils::diagnostics::span_lint_and_then;
2-
use clippy_utils::match_function_call_with_def_id;
32
use clippy_utils::source::{position_before_rarrow, snippet_block, snippet_opt};
43
use if_chain::if_chain;
54
use rustc_errors::Applicability;
@@ -184,16 +183,10 @@ fn captures_all_lifetimes(inputs: &[Ty<'_>], output_lifetimes: &[LifetimeName])
184183
fn desugared_async_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'tcx>) -> Option<&'tcx Body<'tcx>> {
185184
if_chain! {
186185
if let Some(block_expr) = block.expr;
187-
if let Some(args) = cx
188-
.tcx
189-
.lang_items()
190-
.identity_future_fn()
191-
.and_then(|def_id| match_function_call_with_def_id(cx, block_expr, def_id));
192-
if args.len() == 1;
193186
if let Expr {
194187
kind: ExprKind::Closure(&Closure { body, .. }),
195188
..
196-
} = args[0];
189+
} = block_expr;
197190
let closure_body = cx.tcx.hir().body(body);
198191
if closure_body.generator_kind == Some(GeneratorKind::Async(AsyncGeneratorKind::Block));
199192
then {

0 commit comments

Comments
 (0)