Skip to content

Commit 15ab2ff

Browse files
committed
use the correct ParamEnv when checking future's return type in missing_errors_doc
1 parent b8e569e commit 15ab2ff

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

clippy_lints/src/doc/missing_headers.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{DocHeaders, MISSING_ERRORS_DOC, MISSING_PANICS_DOC, MISSING_SAFETY_DOC, UNNECESSARY_SAFETY_DOC};
22
use clippy_utils::diagnostics::{span_lint, span_lint_and_note};
3-
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
3+
use clippy_utils::ty::{implements_trait_with_env, is_type_diagnostic_item};
44
use clippy_utils::{is_doc_hidden, return_ty};
55
use rustc_hir::{BodyId, FnSig, OwnerId, Safety};
66
use rustc_lint::LateContext;
@@ -70,7 +70,14 @@ pub fn check(
7070
&& let typeck = cx.tcx.typeck_body(body_id)
7171
&& let body = cx.tcx.hir().body(body_id)
7272
&& let ret_ty = typeck.expr_ty(body.value)
73-
&& implements_trait(cx, ret_ty, future, &[])
73+
&& implements_trait_with_env(
74+
cx.tcx,
75+
ty::TypingEnv::non_body_analysis(cx.tcx, owner_id.def_id),
76+
ret_ty,
77+
future,
78+
Some(owner_id.def_id.to_def_id()),
79+
&[],
80+
)
7481
&& let ty::Coroutine(_, subs) = ret_ty.kind()
7582
&& is_type_diagnostic_item(cx, subs.as_coroutine().return_ty(), sym::Result)
7683
{

tests/ui/crashes/ice-13862.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![crate_type = "lib"]
2+
#![no_std]
3+
4+
use core::future::Future;
5+
use core::pin::Pin;
6+
use core::task::{Context, Poll};
7+
8+
pub struct S<const N: u8>;
9+
10+
impl<const N: u8> Future for S<N> {
11+
type Output = ();
12+
fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> {
13+
todo!()
14+
}
15+
}
16+
17+
pub fn f<const N: u8>() -> S<N> {
18+
S
19+
}

0 commit comments

Comments
 (0)