-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Make call suggestions more general and more accurate #101100
Make call suggestions more general and more accurate #101100
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
@@ -1,16 +1,28 @@ | |||
// This test case checks the behavior of typeck::check::method::suggest::is_fn on Ty::Error. | |||
|
|||
struct Foo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to fix this test since we no longer say "perhaps you wish to call it" on a method that doesn't exist.
@@ -6,7 +6,7 @@ enum Foo{ | |||
Tup() | |||
} | |||
impl Foo { | |||
fn foo() { } | |||
fn foo(&self) { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to fix this test because the suggestion makes no sense without it
f0a0a65
to
460ebc4
Compare
This comment has been minimized.
This comment has been minimized.
460ebc4
to
cef0482
Compare
8b711fd
to
1256530
Compare
self.flags | ||
.treat_err_as_bug | ||
.map_or(false, |c| self.err_count() + self.lint_err_count >= c.get()) | ||
self.flags.treat_err_as_bug.map_or(false, |c| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I didn't mean to include this, but this is a fix to -Ztreat-err-as-bug
which doesn't count delayed bugs correctly. I can remove it and put it into another PR if needed.
--
detailed explanation: If we emit an error A, delay a bug B, then emit error C. Then:
- running
-Ztreat-err-as-bug=1
will make it ICE on A. - running
-Ztreat-err-as-bug=2
will make it ICE on B. - running
-Ztreat-err-as-bug=3
will skip over B and will make rust skip over C.
So there's literally no value N
such that -Ztreat-err-as-bug=N
will properly work to catch C. We add the delayed good path and span bugs into the count here so this works properly now.
@bors r+ |
…ggestions, r=petrochenkov Make call suggestions more general and more accurate Cleans up some suggestions that have to do with adding `()` to make typeck happy. 1. Drive-by rename of `expr_t` to `base_ty` since it's the type of the `base_expr` 1. Autoderef until we get to a callable type in `suggest_fn_call`. 1. Don't erroneously suggest calling constructor when a method/field does not exist on it. 1. Suggest calling a method receiver if its function output has a method (e.g. `fn.method()` => `fn().method()`) 1. Extend call suggestions to type parameters, fn pointers, trait objects where possible 1. Suggest calling in operators too (fixes rust-lang#101054) 1. Use `/* {ty} */` as argument placeholder instead of just `_`, which is confusing and makes suggestions look less like `if let` syntax.
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#100970 (Allow deriving multipart suggestions) - rust-lang#100984 (Reinstate preloading of some dll imports) - rust-lang#101011 (Use getentropy when possible on all Apple platforms) - rust-lang#101025 (Add tier-3 support for powerpc64 and riscv64 openbsd) - rust-lang#101049 (Remove span fatal from ast lowering) - rust-lang#101100 (Make call suggestions more general and more accurate) - rust-lang#101171 (Fix UB from misalignment and provenance widening in `std::sys::windows`) - rust-lang#101185 (Tweak `WellFormedLoc`s a bit) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Cleans up some suggestions that have to do with adding
()
to make typeck happy.expr_t
tobase_ty
since it's the type of thebase_expr
suggest_fn_call
.fn.method()
=>fn().method()
)size_of
when it is missing parens in a comparison #101054)/* {ty} */
as argument placeholder instead of just_
, which is confusing and makes suggestions look less likeif let
syntax.