Skip to content

Commit 3f7469d

Browse files
committed
Improve output
1 parent 67efbeb commit 3f7469d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::traits::{
3434
ImplSourceUserDefinedData,
3535
};
3636
use crate::traits::{ObjectCastObligation, PredicateObligation, TraitObligation};
37-
use crate::traits::{Obligation, ObligationCause};
37+
use crate::traits::{Obligation, ObligationCause, ObligationCauseCode};
3838
use crate::traits::{SelectionError, Unimplemented};
3939

4040
use super::BuiltinImplConditions;
@@ -533,6 +533,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
533533
let lang_items = self.tcx().lang_items();
534534
if [lang_items.fn_once_trait(), lang_items.fn_trait(), lang_items.fn_mut_trait()]
535535
.contains(&Some(obligation.predicate.def_id()))
536+
// Skip `MiscObligation`s for better output.
537+
&& matches!(obligation.cause.code, ObligationCauseCode::BindingObligation(_, _))
536538
{
537539
// Do not allow `foo::<fn() -> A>();` for `A: !Sized` (#82633)
538540
let fn_sig = obligation.predicate.self_ty().skip_binder().fn_sig(self.tcx());

src/test/ui/closures/closure-return-type-must-be-sized.stderr

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time
22
--> $DIR/closure-return-type-must-be-sized.rs:54:5
33
|
4+
LL | pub fn foo<F: FnOnce<()>>() where F::Output: A {
5+
| ---------- required by this bound in `a::foo`
6+
...
47
LL | a::foo::<fn() -> dyn A>();
58
| ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
69
|

0 commit comments

Comments
 (0)