diff options
| author | Michael Goulet <michael@errs.io> | 2023-09-30 19:28:40 +0000 | 
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-10-03 00:37:18 +0000 | 
| commit | 90dfa24415d4f29e1970bf215458ccefec60f85f (patch) | |
| tree | 54b7a0f447c46fb905481b040d9c676d2438afaa /compiler/rustc_lint/src/async_fn_in_trait.rs | |
| parent | afea0b4eab6f5e91edf70102194d77c8f8f20479 (diff) | |
| download | rust-90dfa24415d4f29e1970bf215458ccefec60f85f.tar.gz rust-90dfa24415d4f29e1970bf215458ccefec60f85f.zip | |
Only reachable traits
Diffstat (limited to 'compiler/rustc_lint/src/async_fn_in_trait.rs')
| -rw-r--r-- | compiler/rustc_lint/src/async_fn_in_trait.rs | 6 | 
1 files changed, 6 insertions, 0 deletions
| diff --git a/compiler/rustc_lint/src/async_fn_in_trait.rs b/compiler/rustc_lint/src/async_fn_in_trait.rs index 1329ba3d519..9214e04bb8b 100644 --- a/compiler/rustc_lint/src/async_fn_in_trait.rs +++ b/compiler/rustc_lint/src/async_fn_in_trait.rs @@ -93,10 +93,16 @@ impl<'tcx> LateLintPass<'tcx> for AsyncFnInTrait { if let hir::TraitItemKind::Fn(sig, body) = item.kind && let hir::IsAsync::Async(async_span) = sig.header.asyncness { + // RTN can be used to bound `async fn` in traits in a better way than "always" if cx.tcx.features().return_type_notation { return; } + // Only need to think about library implications of reachable traits + if !cx.tcx.effective_visibilities(()).is_reachable(item.owner_id.def_id) { + return; + } + let hir::FnRetTy::Return(hir::Ty { kind: hir::TyKind::OpaqueDef(def, ..), .. }) = sig.decl.output else { | 
