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

Wf-check the output type of a function in MIR-typeck #57282

Merged
merged 2 commits into from
Jan 3, 2019

Conversation

matthewjasper
Copy link
Contributor

Closes #57265

cc @scalexm

@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(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 Jan 2, 2019
@nikomatsakis
Copy link
Contributor

r? @nikomatsakis

@nikomatsakis
Copy link
Contributor

@bors r+

This seems like a good fix for now anyhow.

It seems to be the equivalent of this code from the standard type-checker:

// we must check that return type of called functions is WF:
self.register_wf_obligation(output, call_expr.span, traits::MiscObligation);

One thing though -- I am having a hard time figuring out where this would occur (in the standard type-checker, I mean) for the case of methods. But still this variant of the example using methods gets an error in the standard checker, so presumably it's happening somewhere.

@bors
Copy link
Contributor

bors commented Jan 2, 2019

📌 Commit 5dfc5f2 has been approved by nikomatsakis

@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-review Status: Awaiting review from the assignee but also interested parties. labels Jan 2, 2019
@nikomatsakis
Copy link
Contributor

@bors p=1 -- regression

@nikomatsakis nikomatsakis added beta-nominated Nominated for backporting to the compiler in the beta channel. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 2, 2019
@nikomatsakis
Copy link
Contributor

Nominating for beta: this is actually a stable-to-stable regression -- maybe it makes sense to backport to beta? Or maybe not worth it.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:20970b74:start=1546459517418038422,finish=1546459518410024818,duration=991986396
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
[00:25:02]    Compiling rustc_errors v0.0.0 (/checkout/src/librustc_errors)
[00:26:33]    Compiling syntax_ext v0.0.0 (/checkout/src/libsyntax_ext)
[00:33:38]    Compiling rustc_mir v0.0.0 (/checkout/src/librustc_mir)
[00:33:38]    Compiling rustc_typeck v0.0.0 (/checkout/src/librustc_typeck)
[00:34:11] error: `<M as interpret::machine::Machine<'_, '_, '_>>::AllocExtra` does not live long enough
[00:34:11]    --> src/librustc_mir/interpret/memory.rs:364:25
[00:34:11]     |
[00:34:11] 364 |             let alloc = Self::get_static_alloc(id, self.tcx, &self.extra).map_err(Err)?;
[00:34:11] 
[00:34:11] 
[00:34:11] error[E0309]: the parameter type `M` may not live long enough
[00:34:11]    --> src/librustc_mir/interpret/memory.rs:394:47
[00:34:11]     |
[00:34:11] 394 |           let a = self.alloc_map.get_mut_or(id, || {
[00:34:11]     |  _______________________________________________^
[00:34:11] 395 | |             // Need to make a copy, even if `get_static_alloc` is able
[00:34:11] 396 | |             // to give us a cheap reference.
[00:34:11] 397 | |             let alloc = Self::get_static_alloc(id, tcx, memory_extra)?;
[00:34:11] 404 | |             }
[00:34:11] 405 | |         });
[00:34:11]     | |_________^
[00:34:11]     |
[00:34:11]     |
[00:34:11]     = help: consider adding an explicit lifetime bound `M: 'tcx`...
[00:34:11] error: unsatisfied lifetime constraints
[00:34:11]    --> src/librustc_mir/interpret/memory.rs:394:47
[00:34:11]     |
[00:34:11]     |
[00:34:11] 304 |   impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
[00:34:11]     |        --  ---- lifetime `'mir` defined here
[00:34:11]     |        lifetime `'a` defined here
[00:34:11] ...
[00:34:11] ...
[00:34:11] 394 |           let a = self.alloc_map.get_mut_or(id, || {
[00:34:11]     |  _______________________________________________^
[00:34:11] 395 | |             // Need to make a copy, even if `get_static_alloc` is able
[00:34:11] 396 | |             // to give us a cheap reference.
[00:34:11] 397 | |             let alloc = Self::get_static_alloc(id, tcx, memory_extra)?;
[00:34:11] 404 | |             }
[00:34:11] 405 | |         });
[00:34:11] 405 | |         });
[00:34:11]     | |_________^ requires that `'a` must outlive `'mir`
[00:34:11] error: unsatisfied lifetime constraints
[00:34:11]    --> src/librustc_mir/interpret/memory.rs:394:47
[00:34:11]     |
[00:34:11]     |
[00:34:11] 304 |   impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
[00:34:11]     |        --  ---- lifetime `'mir` defined here
[00:34:11]     |        lifetime `'a` defined here
[00:34:11] ...
[00:34:11] ...
[00:34:11] 394 |           let a = self.alloc_map.get_mut_or(id, || {
[00:34:11]     |  _______________________________________________^
[00:34:11] 395 | |             // Need to make a copy, even if `get_static_alloc` is able
[00:34:11] 396 | |             // to give us a cheap reference.
[00:34:11] 397 | |             let alloc = Self::get_static_alloc(id, tcx, memory_extra)?;
[00:34:11] 404 | |             }
[00:34:11] 405 | |         });
[00:34:11] 405 | |         });
[00:34:11]     | |_________^ requires that `'mir` must outlive `'a`
[00:34:14] error: aborting due to 4 previous errors
[00:34:14] 
[00:34:14] For more information about this error, try `rustc --explain E0309`.
[00:34:14] error: Could not compile `rustc_mir`.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@matthewjasper
Copy link
Contributor Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Jan 2, 2019

📌 Commit 8ca83e9 has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Jan 3, 2019

⌛ Testing commit 8ca83e9 with merge 1409363...

bors added a commit that referenced this pull request Jan 3, 2019
…akis

Wf-check the output type of a function in MIR-typeck

Closes #57265

cc @scalexm
@bors
Copy link
Contributor

bors commented Jan 3, 2019

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 1409363 to master...

@bors bors merged commit 8ca83e9 into rust-lang:master Jan 3, 2019
@nagisa nagisa added beta-accepted Accepted for backporting to the compiler in the beta channel. and removed beta-nominated Nominated for backporting to the compiler in the beta channel. labels Jan 3, 2019
@nagisa
Copy link
Member

nagisa commented Jan 3, 2019

Discussed at the T-compiler meeting, has been accepted for a backport.

@pietroalbini pietroalbini added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jan 3, 2019
@pietroalbini pietroalbini removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jan 3, 2019
bors added a commit that referenced this pull request Jan 4, 2019
[beta] Rollup backports

Cherry-picked:

* #57053: Fix alignment for array indexing
* #57181: resolve: Fix another ICE in import validation
* #57185: resolve: Fix one more ICE in import validation
* #57282: Wf-check the output type of a function in MIR-typeck
* #55318: Ensure that Rustdoc discovers all necessary auto trait bounds
* #56838: Call poly_project_and_unify_type on types that contain inference types

Rolled up:

* #57300: [beta] Update RLS to include 100% CPU on hover bugfix
* #57301: beta: bootstrap from latest stable (1.31.1)
* #57292: [BETA] Update cargo

r? @ghost
@matthewjasper matthewjasper deleted the wellformed-return-ty branch January 5, 2019 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants