-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Cast suggestions #38099
Cast suggestions #38099
Conversation
5c5e1e8
to
3fb3239
Compare
self.fcx.associated_item(def_id, self.item_name) | ||
match self.looking_for { | ||
LookingFor::MethodName(item_name) => self.fcx.associated_item(def_id, item_name), | ||
_ => None, |
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.
@nikomatsakis: This matching is invalid, but I don't know what to put here. We don't have a method name to refer to, just a return type. Won't it always return the same method if I match on it?
@eddyb: Maybe you have an idea here?
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.
Yeah, this method should go away. Callers can just use impl_or_trait_item
instead. I've got a local branch doing that (might also try modifying impl_or_trait_item
to return impl Iterator
, since right now it only considers the first method that matches the return type...?)
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.
Looking good. You're right about associated_item
being wrong now though.
@@ -1364,9 +1364,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { | |||
cause: &ObligationCause<'tcx>, | |||
expected: Ty<'tcx>, | |||
actual: Ty<'tcx>, | |||
err: TypeError<'tcx>) { | |||
err: TypeError<'tcx>) -> DiagnosticBuilder<'tcx> { |
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.
Nit: newline before ->
here
fn format_method_suggestion(&self, method: &AssociatedItem) -> String { | ||
format!(".{}({})", | ||
method.name, | ||
if self.has_not_input_arg(method) { |
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.
Not: has_no_input_arg
or does_not_have_input_arg
or !self.has_input_arg
:)
self.fcx.associated_item(def_id, self.item_name) | ||
match self.looking_for { | ||
LookingFor::MethodName(item_name) => self.fcx.associated_item(def_id, item_name), | ||
_ => None, |
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.
Yeah, this method should go away. Callers can just use impl_or_trait_item
instead. I've got a local branch doing that (might also try modifying impl_or_trait_item
to return impl Iterator
, since right now it only considers the first method that matches the return type...?)
| | ||
= note: expected type `&mut std::string::String` | ||
= note: found type `&std::string::String` | ||
= help: try with `&mut y` |
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.
are these changes that suggest a &
still in the PR?
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.
I couldn't test since the current code was wrong. Once updated, this will follow.
OK, so, I pushed a quick fix, but we still fail 3 compile-fail tests. I'm not 100% sure why, didn't dig into it yet:
each of them fails with a rather useless "error: the type of this value must be known in this context". |
@nikomatsakis: We have an issue. With the current code, it only returns one proposition. For example for the following code: fn foo(_x: String) {}
fn main() {
foo("a");
} It proposes only |
I think that is because the |
Indeed. I'll give it a try then. |
Ok, so I fixed this issue. Code is a bit ugly unfortunately. We still have the same failure for the 3 tests. EDIT: Oh also, suggestions are completely stupid haha. |
☔ The latest upstream changes (presumably #38079) made this pull request unmergeable. Please resolve the merge conflicts. |
df0ebff
to
0b433e9
Compare
@GuillaumeGomez I pushed a commit that cleans up the code a bit, but I still see various failures around inference that I think we need to track down:
|
OK, I see those errors were the cause of your changes to not call BTW, did you have some suggestion tests that were failing because of the fact that we were returning an |
b7dc50f
to
05d1958
Compare
I ran |
I fixed the linter as well. |
@GuillaumeGomez still some kind of issue... |
@nikomatsakis: If you're referring to travis' failure, it seems normal. If not, then what are you referring to? |
I see this, is that normal?
|
I guess that particular configuration does seem to typically have a travis failure of some kind. |
I think that error might be from #38097, where |
Uh?! I guess I failed my update and my rebuild... Taking another look then. |
5816ccc
to
e2c5370
Compare
So as I thought, I needed to rebase once again. Now it's fixed and tests are passing again. |
@GuillaumeGomez sadly it seems like travis is still unhappy! The Some of the output:
|
When we are scanning for suggestions, an unresolved inference variable is not a hard error.
e2c5370
to
28e2c6a
Compare
@nikomatsakis: Indeed, didn't see this one. Should be fixed now. |
And travis tests passed! \o/ |
@nikomatsakis: no r+? |
@bors r+ |
📌 Commit 28e2c6a has been approved by |
Cast suggestions r? @nikomatsakis
This removes the safe_suggestion feature from feature_gate.rs. It was added in commit 164f010 and then removed again in commit c11fe55 . As the removal was in the same PR rust-lang#38099 as the addition, we don't move it to the "removed" section. Removes an element from the whitelist of non gate tested unstable lang features (issue rust-lang#39059).
Mark safe_suggestion and pushpop_unsafe as removed in feature_gate.rs This removes two features from feature_gate.rs: `safe_suggestion` and `pushpop_unsafe`. Both had been removed in other places already, but were forgotten to be removed from feature_gate.rs. * `safe_suggestion` was added in commit 164f010 and then removed again in commit c11fe55 both in the same PR #38099. * `pushpop_unsafe` was added in commit 1829fa5 and removed again in commit d399098 Removes two elements from the whitelist of non gate tested unstable lang features (issue #39059).
Mark safe_suggestion and pushpop_unsafe as removed in feature_gate.rs This removes two features from feature_gate.rs: `safe_suggestion` and `pushpop_unsafe`. Both had been removed in other places already, but were forgotten to be removed from feature_gate.rs. * `safe_suggestion` was added in commit 164f010 and then removed again in commit c11fe55 both in the same PR #38099. * `pushpop_unsafe` was added in commit 1829fa5 and removed again in commit d399098 Removes two elements from the whitelist of non gate tested unstable lang features (issue #39059).
r? @nikomatsakis