Skip to content

Commit 843a062

Browse files
authored
Rollup merge of rust-lang#108667 - compiler-errors:issue-108664, r=estebank
Fix another ICE in `point_at_expr_source_of_inferred_type` Types coming from method probes must only be investigated *structurally*, since they often contain escaping infer variables from generalization and autoderef. We already have a hack in this PR that erases variables from types, so just use that. Fixes rust-lang#108664 The note attached to this error is pretty bad: ``` here the type of `primes` is inferred to be `[_]` ``` But that's unrelated to the PR. --- Side-note: This is a pretty easy to trigger beta regression, so I've nominated it. Alternatively, I'm slightly inclined to remove this code altogether until it can be reformulated to be more accurate and less ICEy.
2 parents 03a6420 + 4b01a1a commit 843a062

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

compiler/rustc_hir_typeck/src/demand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
315315
probe::ProbeScope::TraitsInScope,
316316
None,
317317
) {
318-
Ok(pick) => pick.self_ty,
318+
Ok(pick) => eraser.fold_ty(pick.self_ty),
319319
Err(_) => rcvr_ty,
320320
};
321321
// Remove one layer of references to account for `&mut self` and
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// The error message here still is pretty confusing.
2+
3+
fn main() {
4+
let primes = Vec::new();
5+
primes.contains(3);
6+
//~^ ERROR mismatched types
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/bad-type-in-vec-contains.rs:5:21
3+
|
4+
LL | primes.contains(3);
5+
| -------- ^
6+
| | |
7+
| | expected `&_`, found integer
8+
| | help: consider borrowing here: `&3`
9+
| arguments to this method are incorrect
10+
| here the type of `primes` is inferred to be `[_]`
11+
|
12+
= note: expected reference `&_`
13+
found type `{integer}`
14+
note: method defined here
15+
--> $SRC_DIR/core/src/slice/mod.rs:LL:COL
16+
17+
error: aborting due to previous error
18+
19+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)