Skip to content

Commit 1d82905

Browse files
committed
Fix rebase
1 parent 88a5321 commit 1d82905

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::traits::normalize_projection_type;
99

1010
use rustc_data_structures::fx::FxHashSet;
1111
use rustc_data_structures::stack::ensure_sufficient_stack;
12+
use rustc_data_structures::sync::Lrc;
1213
use rustc_errors::{error_code, struct_span_err, Applicability, DiagnosticBuilder, Style};
1314
use rustc_hir as hir;
1415
use rustc_hir::def::DefKind;
@@ -678,19 +679,18 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
678679
has_custom_message: bool,
679680
) -> bool {
680681
let span = obligation.cause.span;
681-
let points_at_for_iter = matches!(
682-
span.ctxt().outer_expn_data().kind,
683-
ExpnKind::Desugaring(DesugaringKind::ForLoop(ForLoopLoc::IntoIter))
684-
);
685682

686-
let code =
687-
if let (ObligationCauseCode::FunctionArgumentObligation { parent_code, .. }, false) =
688-
(&obligation.cause.code, points_at_for_iter)
689-
{
690-
parent_code.clone()
691-
} else {
692-
return false;
693-
};
683+
let code = if let ObligationCauseCode::FunctionArgumentObligation { parent_code, .. } =
684+
&obligation.cause.code
685+
{
686+
parent_code.clone()
687+
} else if let ExpnKind::Desugaring(DesugaringKind::ForLoop(ForLoopLoc::IntoIter)) =
688+
span.ctxt().outer_expn_data().kind
689+
{
690+
Lrc::new(obligation.cause.code.clone())
691+
} else {
692+
return false;
693+
};
694694

695695
// List of traits for which it would be nonsensical to suggest borrowing.
696696
// For instance, immutable references are always Copy, so suggesting to

src/test/ui/expr/malformed_closure/ruby_style_closure.stderr

+12-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,19 @@ LL | Some(x * 2)
55
| ^ not found in this scope
66

77
error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<_>`
8-
--> $DIR/ruby_style_closure.rs:10:22
8+
--> $DIR/ruby_style_closure.rs:10:31
99
|
10-
LL | let p = Some(45).and_then({
11-
| ^^^^^^^^ expected an `FnOnce<({integer},)>` closure, found `Option<_>`
10+
LL | let p = Some(45).and_then({
11+
| ______________________--------_^
12+
| | |
13+
| | required by a bound introduced by this call
14+
LL | |
15+
LL | | |x| println!("doubling {}", x);
16+
LL | | Some(x * 2)
17+
| | -----------
18+
LL | |
19+
LL | | });
20+
| |_____^ expected an `FnOnce<({integer},)>` closure, found `Option<_>`
1221
|
1322
= help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>`
1423

0 commit comments

Comments
 (0)