Rollup merge of #125466 - compiler-errors:dont-probe-for-ambig-in-sug… · rust-lang/rust@09e7592 (original) (raw)
File tree
3 files changed
lines changed
- compiler/rustc_hir_typeck/src/method
3 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -395,8 +395,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | ||
395 | 395 | // ambiguous. |
396 | 396 | if let Some(bad_ty) = &steps.opt_bad_ty { |
397 | 397 | if is_suggestion.0 { |
398 | -// Ambiguity was encountered during a suggestion. Just keep going. | |
399 | -debug!("ProbeContext: encountered ambiguity in suggestion"); | |
398 | +// Ambiguity was encountered during a suggestion. There's really | |
399 | +// not much use in suggesting methods in this case. | |
400 | +return Err(MethodError::NoMatch(NoMatchData { | |
401 | +static_candidates: Vec::new(), | |
402 | +unsatisfied_predicates: Vec::new(), | |
403 | +out_of_scope_traits: Vec::new(), | |
404 | +similar_candidate: None, | |
405 | + mode, | |
406 | +})); | |
400 | 407 | } else if bad_ty.reached_raw_pointer |
401 | 408 | && !self.tcx.features().arbitrary_self_types |
402 | 409 | && !self.tcx.sess.at_least_rust_2018() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
1 | +// Fix for https://github.com/rust-lang/rust/issues/125432. | |
2 | + | |
3 | +fn separate_arms() { | |
4 | +let mut x = None; | |
5 | +match x { | |
6 | +None => { | |
7 | + x = Some(0); | |
8 | +} | |
9 | +Some(right) => { | |
10 | +consume(right); | |
11 | +//~^ ERROR cannot find function `consume` in this scope | |
12 | +} | |
13 | +} | |
14 | +} | |
15 | + | |
16 | +fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
1 | +error[E0425]: cannot find function `consume` in this scope | |
2 | + --> $DIR/suggest-method-on-call-for-ambig-receiver.rs:10:13 | |
3 | + | | |
4 | +LL | consume(right); | |
5 | + | ^^^^^^^ not found in this scope | |
6 | + | |
7 | +error: aborting due to 1 previous error | |
8 | + | |
9 | +For more information about this error, try `rustc --explain E0425`. |