Repository navigation
Closed
Closed
Copy link
Labels
A-dyn-traitArea: trait objects, vtable layoutA-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.L-false-positiveLint: False positive (should not have fired).L-refining_impl_traitLint group: refining_impl_traitT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.
Description
When compiling this code (playground):
trait Foo {
fn bar(
&self,
) -> impl Future<Output = Box<dyn Fn(&mut ())>>;
}
struct Nope;
impl Foo for Nope {
fn bar(
&self,
) -> impl Future<Output = Box<dyn Fn(&mut ())>>
{ async { todo!() }}
}I get a refining_impl_trait compiler warning (on stable and nightly)
Warning
Compiling playground v0.0.1 (/playground)
warning: impl trait in impl method signature does not match trait method signature
--> src/lib.rs:13:22
|
6 | ) -> impl Future<Output = Box<dyn Fn(&mut ())>>;
| ------------------------------------------ return type from trait method defined here
...
13 | ) -> impl Future<Output = Box<dyn Fn(&mut ())>>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this bound is stronger than that defined on the trait
|
= note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
= note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information
= note: `#[warn(refining_impl_trait_internal)]` (part of `#[warn(refining_impl_trait)]`) on by default
help: replace the return type so that it matches the trait
|
13 - ) -> impl Future<Output = Box<dyn Fn(&mut ())>>
13 + ) -> impl std::future::Future<Output = std::boxed::Box<(dyn for<'a> std::ops::Fn(&'a mut ()) + 'static)>>
|
warning: `playground` (lib) generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.75s
Meta
rustc --version --verbose:
Stable channel
Build using the Stable version: 1.99.1
Beta channel
Build using the Beta version: 1.100.0-beta.7
(2026-10-17 fd8e211ae301c84a86d1)
Nightly channel
Build using the Nightly version: 1.101.0-nightly
(2026-10-27 41089d07a0a2afc16adf)
Metadata
Metadata
Assignees
Labels
A-dyn-traitArea: trait objects, vtable layoutA-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.L-false-positiveLint: False positive (should not have fired).L-refining_impl_traitLint group: refining_impl_traitT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.
Activity
maxdexh commentedon Oct 28, 2026
Even when writing out the implicit parts:
The diagnostic recommends:
Rustc is drunk and should go home
Rollup merge of rust-lang#165222 - mu001999-contrib:fix-165091, r=fmease
Rollup merge of rust-lang#165222 - mu001999-contrib:fix-165091, r=fmease
Rollup merge of rust-lang#165222 - mu001999-contrib:fix-165091, r=fmease
Unrolled build for #165222 in rollup 165579
Rollup merge of #165222 - mu001999-contrib:fix-165091, r=fmease