Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix another ICE in point_at_expr_source_of_inferred_type #108667

Merged
merged 1 commit into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
probe::ProbeScope::TraitsInScope,
None,
) {
Ok(pick) => pick.self_ty,
Ok(pick) => eraser.fold_ty(pick.self_ty),
compiler-errors marked this conversation as resolved.
Show resolved Hide resolved
Err(_) => rcvr_ty,
};
// Remove one layer of references to account for `&mut self` and
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/typeck/bad-type-in-vec-contains.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// The error message here still is pretty confusing.

fn main() {
let primes = Vec::new();
primes.contains(3);
//~^ ERROR mismatched types
}
19 changes: 19 additions & 0 deletions tests/ui/typeck/bad-type-in-vec-contains.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0308]: mismatched types
--> $DIR/bad-type-in-vec-contains.rs:5:21
|
LL | primes.contains(3);
| -------- ^
| | |
| | expected `&_`, found integer
| | help: consider borrowing here: `&3`
| arguments to this method are incorrect
| here the type of `primes` is inferred to be `[_]`
|
= note: expected reference `&_`
found type `{integer}`
note: method defined here
--> $SRC_DIR/core/src/slice/mod.rs:LL:COL

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.