Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit09e7592

Browse files
Rollup merge of#125466 - compiler-errors:dont-probe-for-ambig-in-sugg, r=jieyouxu
Don't continue probing for method if in suggestion and autoderef hits ambiguityThe title is somewhat self-explanatory. When we hit ambiguity in method autoderef steps, we previously would continue to probe for methods if we were giving a suggestion. This seems useless, and causes an ICE when we are not able to unify the receiver later on in confirmation.Fixes#125432
2 parents5860d43 +4bc41b9 commit09e7592

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

‎compiler/rustc_hir_typeck/src/method/probe.rs‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
395395
// ambiguous.
396396
ifletSome(bad_ty) =&steps.opt_bad_ty{
397397
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+
returnErr(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+
}));
400407
}elseif bad_ty.reached_raw_pointer
401408
&& !self.tcx.features().arbitrary_self_types
402409
&& !self.tcx.sess.at_least_rust_2018()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Fix for <https://github.com/rust-lang/rust/issues/125432>.
2+
3+
fnseparate_arms(){
4+
letmut 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+
fnmain(){}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff 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`.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp