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

Rollup of 6 pull requests #106480

Closed
Closed
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7df33a0
Account for RPITITs in opt_suggest_box_span
compiler-errors Dec 17, 2022
a313ef0
rename get_parent_node to parent_id
compiler-errors Jan 3, 2023
6af339d
rename find_parent_node to opt_parent_id
compiler-errors Jan 3, 2023
b1b19bd
get_parent and find_parent
compiler-errors Jan 3, 2023
a4974fa
Split `-Zchalk` flag into `-Ztrait-solver=(stock|chalk|next)` flag
compiler-errors Jan 2, 2023
1e81f9a
Update tests, etc
compiler-errors Jan 2, 2023
8b0f43b
Rename stock solver to classic
compiler-errors Jan 4, 2023
01196c5
rustdoc: remove unnecessary wrapper around sidebar and mobile logos
notriddle Jan 4, 2023
a86d33b
Point at expressions where inference refines an unexpected type
estebank Jan 3, 2023
a66bd95
Skip macros to avoid talking about bindings the user can't see
estebank Jan 3, 2023
acff39f
More eagerly resolve expr `ty`s before writing them
estebank Jan 3, 2023
c5d21c2
review comments: do not always point at init expr
estebank Jan 3, 2023
af68e2f
Tweak output
estebank Jan 4, 2023
4a0c5ec
Formatting
estebank Jan 4, 2023
e065d1d
Use `BottomUpFolder`
estebank Jan 4, 2023
7da7342
Account for type error on method arg caused by earlier inference
estebank Jan 5, 2023
b3488b2
Suggest changing argument on type error
estebank Jan 5, 2023
fee334c
review comment: potentially produce more suggestions for arg type mis…
estebank Jan 5, 2023
25cf71e
review comments: reword
estebank Jan 5, 2023
5393c6b
Tweak wording of fn call with wrong number of args
estebank Jan 5, 2023
c686f43
Rollup merge of #105846 - compiler-errors:issue-105838, r=jackh726
compiler-errors Jan 5, 2023
214b33b
Rollup merge of #106385 - compiler-errors:new-solver-flag, r=jackh726
compiler-errors Jan 5, 2023
b6efe90
Rollup merge of #106400 - estebank:type-errs, r=compiler-errors
compiler-errors Jan 5, 2023
edbab30
Rollup merge of #106403 - compiler-errors:rename-hir-methods, r=cjgillot
compiler-errors Jan 5, 2023
fea926c
Rollup merge of #106462 - notriddle:notriddle/logo-container-sidebar,…
compiler-errors Jan 5, 2023
7bbed3e
Rollup merge of #106478 - estebank:tweak-fn-mismatch, r=compiler-errors
compiler-errors Jan 5, 2023
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
Prev Previous commit
Next Next commit
Account for type error on method arg caused by earlier inference
```rust
fn main() {
    let v = Vec::new();
    v.push(0);
    v.push(0);
    v.push("");
}
```

now produces

```
error[E0308]: mismatched types
  --> $DIR/point-at-inference-3.rs:6:12
   |
LL |     v.push(0);
   |            - this is of type `{integer}`, which makes `v` to be inferred as `Vec<{integer}>`
...
LL |     v.push("");
   |       ---- ^^ expected integer, found `&str`
   |       |
   |       arguments to this function are incorrect
   |
note: associated function defined here
  --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
```
  • Loading branch information
estebank committed Jan 5, 2023
commit 7da7342f458535ac22f3cc324e492228e12c7e7d
4 changes: 3 additions & 1 deletion compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
@@ -213,7 +213,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
(expected, Some(err))
}

fn point_at_expr_source_of_inferred_type(
pub fn point_at_expr_source_of_inferred_type(
&self,
err: &mut Diagnostic,
expr: &hir::Expr<'_>,
@@ -387,6 +387,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
)),
);
break;
} else if !param_args.is_empty() {
break;
}
prev = ty;
} else {
12 changes: 12 additions & 0 deletions compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
@@ -801,6 +801,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
full_call_span,
format!("arguments to this {} are incorrect", call_name),
);
if let (Some(callee_ty), hir::ExprKind::MethodCall(_, rcvr, _, _)) =
(callee_ty, &call_expr.kind)
{
// Type that would have accepted this argument if it hadn't been inferred earlier.
// FIXME: We leave an inference variable for now, but it'd be nice to get a more
// specific type to increase the accuracy of the diagnostic.
let expected = self.infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable,
span: full_call_span,
});
self.point_at_expr_source_of_inferred_type(&mut err, rcvr, expected, callee_ty);
}
// Call out where the function is defined
self.label_fn_like(
&mut err,
10 changes: 10 additions & 0 deletions src/test/ui/type/type-check/point-at-inference-3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fn main() {
let v = Vec::new();
v.push(0);
//~^ NOTE this is of type `{integer}`, which makes `v` to be inferred as `Vec<{integer}>`
v.push(0);
v.push(""); //~ ERROR mismatched types
//~^ NOTE expected integer, found `&str`
//~| NOTE arguments to this function are incorrect
//~| NOTE associated function defined here
}
17 changes: 17 additions & 0 deletions src/test/ui/type/type-check/point-at-inference-3.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error[E0308]: mismatched types
--> $DIR/point-at-inference-3.rs:6:12
|
LL | v.push(0);
| - this is of type `{integer}`, which makes `v` to be inferred as `Vec<{integer}>`
...
LL | v.push("");
| ---- ^^ expected integer, found `&str`
| |
| arguments to this function are incorrect
|
note: associated function defined here
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL

error: aborting due to previous error

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