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

When possible point at argument causing item obligation failure #64498

Merged
merged 8 commits into from
Sep 20, 2019

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Sep 16, 2019

Fix #41781, fix #42855, fix #46658, fix #48099, fix #63143, fix #36775.

@rust-highfive
Copy link
Collaborator

r? @zackmdavis

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 16, 2019
@estebank

This comment has been minimized.

@estebank
Copy link
Contributor Author

estebank commented Sep 16, 2019

Related, but not affected by this PR #61860.

This will likely conflict with #64151.

Follow up to #63870.

@estebank
Copy link
Contributor Author

estebank commented Sep 16, 2019

CC @oli-obk @Centril

I want to acknowledge that this is not the ideal solution, but my attempts at modifying the obligation preemptively and collecting an association between the FnDecl input fields and the bounds was met with some trouble because the FnDecl has hir::Ty while the trait bounds could be checked against ty::TyS. The solution in this PR is 1) partial/incomplete 2) hacky 3) quickly bails if there isn't only one argument that matches 4) somehow increasing the number of E0277 errors being emitted in some cases 5) regressing the errors in ? 6) good enough for the cases most likely to be encountered.

@@ -3222,6 +3222,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
formal_tys.clone()
};

let mut final_arg_types: Vec<(usize, Ty<'_>)> = vec![];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this is going to regress happy-path compile-time perf? (I don't expect by much but still...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no way of doing this without collecting the resolved types for the general case (there's a lazy way to do it that would only work with fully resolved types in the arguments).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sure, just pointing out that there is a cost to this, which may be totally acceptable. :)

src/librustc_typeck/check/mod.rs Outdated Show resolved Hide resolved
@Centril

This comment has been minimized.

@estebank

This comment has been minimized.

@@ -16,6 +17,7 @@ pub fn other() {

let _ = Iterator::next(&mut ());
//~^ ERROR `()` is not an iterator
//~| ERROR `()` is not an iterator
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file shows the case where we duplicate the errors. We should be able to elide the error pointing at Iterator::next with some judicious use of Ty::Error.

@bors

This comment has been minimized.

@estebank
Copy link
Contributor Author

@oli-obk d38e090#diff-4cee39a7c18e8b5ec52efe4563c547fbR7-R11 😀

error[E0277]: the trait bound `fn() -> impl std::future::Future {foo}: std::future::Future` is not satisfied
  --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:9:9
   |
LL | fn bar(f: impl Future<Output=()>) {}
   | --------------------------------- required by `bar`
...
LL |     bar(foo);
   |         ^^^
   |         |
   |         the trait `std::future::Future` is not implemented for `fn() -> impl std::future::Future {foo}`
   |         help: use parentheses to call the function: `foo()`

src/librustc/traits/mod.rs Show resolved Hide resolved
src/librustc/traits/error_reporting.rs Show resolved Hide resolved
src/librustc_typeck/check/mod.rs Show resolved Hide resolved
src/librustc_typeck/check/mod.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/mod.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/mod.rs Outdated Show resolved Hide resolved
@Centril
Copy link
Contributor

Centril commented Sep 19, 2019

r? @Centril

r=me with the elaboration you gave me privately on Discord added as a comment in some fashion. :)

@rust-highfive rust-highfive assigned Centril and unassigned zackmdavis Sep 19, 2019
@Centril Centril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 19, 2019
@estebank
Copy link
Contributor Author

@bors r=Centril

@bors
Copy link
Contributor

bors commented Sep 19, 2019

📌 Commit c34d9e6 has been approved by Centril

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 19, 2019
Centril added a commit to Centril/rust that referenced this pull request Sep 20, 2019
When possible point at argument causing item obligation failure

Fix rust-lang#41781, fix rust-lang#42855, fix rust-lang#46658, fix rust-lang#48099, fix rust-lang#63143.
bors added a commit that referenced this pull request Sep 20, 2019
Rollup of 8 pull requests

Successful merges:

 - #64136 (Document From trait for LhsExpr in parser)
 - #64342 (factor out pluralisation remains after #64280)
 - #64387 (Fix redundant semicolon lint interaction with proc macro attributes)
 - #64498 (When possible point at argument causing item obligation failure)
 - #64615 (rustbuild: Turn down compression on exe installers)
 - #64617 (rustbuild: Turn down compression on msi installers)
 - #64618 (rustbuild: Improve output of `dist` step)
 - #64621 (Add Compatibility Notes to RELEASES.md for 1.38.0)

Failed merges:

r? @ghost
@bors
Copy link
Contributor

bors commented Sep 20, 2019

⌛ Testing commit c34d9e6 with merge 7225264...

bors added a commit that referenced this pull request Sep 20, 2019
When possible point at argument causing item obligation failure

Fix #41781, fix #42855, fix #46658, fix #48099, fix #63143.
@bors
Copy link
Contributor

bors commented Sep 20, 2019

☀️ Test successful - checks-azure
Approved by: Centril
Pushing 7225264 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 20, 2019
@bors bors merged commit c34d9e6 into rust-lang:master Sep 20, 2019
@bors bors mentioned this pull request Sep 20, 2019
@nnethercote
Copy link
Contributor

nnethercote commented Sep 23, 2019

Either this PR or #64584 caused a major regression in rustc perf. It's hard to tell because the graph goes up on this PR, then down for a single run, then stabilizes again at the worse performance after #64584.

I suggest backing out both PRs, opening new PRs, and then doing perf runs on both. That should make it clear which one cause the regression.

cc @rust-lang/compiler

(If I had to guess, I would guess this PR caused the regression.)

@Mark-Simulacrum
Copy link
Member

See #64584 (comment) - I wouldn't do anything just yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment