Skip to content

Commit 27c4c17

Browse files
authored
Rollup merge of rust-lang#104593 - compiler-errors:rpitit-object-safety-spans, r=fee1-dead
Improve spans for RPITIT object-safety errors No reason why we can't point at the `impl Trait` that causes the object-safety violation. Also [drive-by: Add is_async fn to hir::IsAsync](rust-lang@c4165f3), which touches clippy too.
2 parents f6d4ef9 + 3a2eaa7 commit 27c4c17

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

clippy_lints/src/manual_async_fn.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_errors::Applicability;
66
use rustc_hir::intravisit::FnKind;
77
use rustc_hir::{
88
AsyncGeneratorKind, Block, Body, Closure, Expr, ExprKind, FnDecl, FnRetTy, GeneratorKind, GenericArg, GenericBound,
9-
HirId, IsAsync, ItemKind, LifetimeName, Term, TraitRef, Ty, TyKind, TypeBindingKind,
9+
HirId, ItemKind, LifetimeName, Term, TraitRef, Ty, TyKind, TypeBindingKind,
1010
};
1111
use rustc_lint::{LateContext, LateLintPass};
1212
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualAsyncFn {
4949
) {
5050
if_chain! {
5151
if let Some(header) = kind.header();
52-
if header.asyncness == IsAsync::NotAsync;
52+
if !header.asyncness.is_async();
5353
// Check that this function returns `impl Future`
5454
if let FnRetTy::Return(ret_ty) = decl.output;
5555
if let Some((trait_ref, output_lifetimes)) = future_trait_ref(cx, ret_ty);

clippy_lints/src/unused_async.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
22
use rustc_hir::intravisit::{walk_expr, walk_fn, FnKind, Visitor};
3-
use rustc_hir::{Body, Expr, ExprKind, FnDecl, HirId, IsAsync, YieldSource};
3+
use rustc_hir::{Body, Expr, ExprKind, FnDecl, HirId, YieldSource};
44
use rustc_lint::{LateContext, LateLintPass};
55
use rustc_middle::hir::nested_filter;
66
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -68,7 +68,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAsync {
6868
span: Span,
6969
hir_id: HirId,
7070
) {
71-
if !span.from_expansion() && fn_kind.asyncness() == IsAsync::Async {
71+
if !span.from_expansion() && fn_kind.asyncness().is_async() {
7272
let mut visitor = AsyncFnVisitor { cx, found_await: false };
7373
walk_fn(&mut visitor, fn_kind, fn_decl, body.id(), hir_id);
7474
if !visitor.found_await {

clippy_utils/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ use rustc_hir::hir_id::{HirIdMap, HirIdSet};
8787
use rustc_hir::intravisit::{walk_expr, FnKind, Visitor};
8888
use rustc_hir::LangItem::{OptionNone, ResultErr, ResultOk};
8989
use rustc_hir::{
90-
def, Arm, ArrayLen, BindingAnnotation, Block, BlockCheckMode, Body, Closure, Constness, Destination, Expr,
91-
ExprKind, FnDecl, HirId, Impl, ImplItem, ImplItemKind, IsAsync, Item, ItemKind, LangItem, Local, MatchSource,
92-
Mutability, Node, Param, Pat, PatKind, Path, PathSegment, PrimTy, QPath, Stmt, StmtKind, TraitItem, TraitItemKind,
93-
TraitRef, TyKind, UnOp,
90+
def, Arm, ArrayLen, BindingAnnotation, Block, BlockCheckMode, Body, Closure, Constness,
91+
Destination, Expr, ExprKind, FnDecl, HirId, Impl, ImplItem, ImplItemKind, Item, ItemKind,
92+
LangItem, Local, MatchSource, Mutability, Node, Param, Pat, PatKind, Path, PathSegment, PrimTy,
93+
QPath, Stmt, StmtKind, TraitItem, TraitItemKind, TraitRef, TyKind, UnOp,
9494
};
9595
use rustc_lexer::{tokenize, TokenKind};
9696
use rustc_lint::{LateContext, Level, Lint, LintContext};
@@ -1861,7 +1861,7 @@ pub fn if_sequence<'tcx>(mut expr: &'tcx Expr<'tcx>) -> (Vec<&'tcx Expr<'tcx>>,
18611861

18621862
/// Checks if the given function kind is an async function.
18631863
pub fn is_async_fn(kind: FnKind<'_>) -> bool {
1864-
matches!(kind, FnKind::ItemFn(_, _, header) if header.asyncness == IsAsync::Async)
1864+
matches!(kind, FnKind::ItemFn(_, _, header) if header.asyncness.is_async())
18651865
}
18661866

18671867
/// Peels away all the compiler generated code surrounding the body of an async function,

0 commit comments

Comments
 (0)