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

Remove redundancy from the implementation of C variadics. #63492

Merged
merged 4 commits into from
Sep 29, 2019

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Aug 12, 2019

This cleanup was first described in #44930 (comment):

  • AST doesn't track c_variadic: bool anymore, relying solely on a trailing CVarArgs type in fn signatures
  • HIR doesn't have a CVarArgs anymore, relying solely on c_variadic: bool
    • same for ty::FnSig (see tests for diagnostics improvements from that)
    • {hir,mir}::Body have one extra argument than the signature when c_variadic == true
    • rustc_typeck and rustc_mir::{build,borrowck} need to give that argument the right type (which no longer uses a lifetime parameter, but a function-internal scope)
  • rustc_target::abi::call doesn't need special hacks anymore (since it never sees the VaListImpl now, it's all inside the body)

r? @nagisa / @rkruppe cc @dlrobertson @oli-obk

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

Copy link
Contributor

@dlrobertson dlrobertson left a comment

Choose a reason for hiding this comment

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

👍 Great stuff! This is much cleaner.

@@ -2102,7 +2097,14 @@ impl<'a> LoweringContext<'a> {
}

fn lower_fn_args_to_names(&mut self, decl: &FnDecl) -> hir::HirVec<Ident> {
decl.inputs
// Skip the `...` (`CVarArgs`) trailing arguments from the AST,
Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea to skip this here.

@eddyb eddyb force-pushed the cvarargs branch 2 times, most recently from 8b9d92c to f6d4b3b Compare August 14, 2019 10:58
@bors
Copy link
Contributor

bors commented Aug 17, 2019

☔ The latest upstream changes (presumably #63655) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 17, 2019
@eddyb
Copy link
Member Author

eddyb commented Aug 18, 2019

cc @matthewjasper @nikomatsakis for the MIR changes

@totsteps
Copy link
Member

Ping from triage, can someone from @rust-lang/compiler review this PR.

Thanks

@totsteps totsteps added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 27, 2019
@JohnCSimon JohnCSimon 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 7, 2019
@JohnCSimon
Copy link
Member

Ping from triage
@eddyb This has sat idle for a bit and has taken on several merge conflicts.
Thank you.

@joelpalmer
Copy link

Ping from Triage: Closing due to inactivity. If or when there are updates, please re-open. @eddyb Thanks for the PR.

@joelpalmer joelpalmer closed this Sep 16, 2019
@joelpalmer joelpalmer added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 16, 2019
@eddyb eddyb reopened this Sep 26, 2019
@nagisa
Copy link
Member

nagisa commented Sep 27, 2019

@eddyb overall r=me, with the two nits fixed.

@nagisa nagisa added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. labels Sep 27, 2019
va_list.layout.ty,
scope,
variable_access,
VariableKind::ArgumentVariable(arg_index + 1),
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't this one too far? arg_index is already one beyond the list of normal arguments

Copy link
Member Author

Choose a reason for hiding this comment

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

+ 1 is pre-existing, I'm not sure what the deal is (see my comment on this in some of the prereq commits in #56231).

@@ -1100,8 +1100,26 @@ fn check_fn<'a, 'tcx>(
let outer_hir_id = fcx.tcx.hir().as_local_hir_id(outer_def_id).unwrap();
GatherLocalsVisitor { fcx: &fcx, parent_id: outer_hir_id, }.visit_body(body);

// C-variadic fns also have a `VaList` input that's not listed in `fn_sig`
// (as it's created inside the body itself, not passed in from outside).
let maybe_va_list = if fn_sig.c_variadic {
Copy link
Contributor

Choose a reason for hiding this comment

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

almost the same code snippet appears in src/librustc_mir/build/mod.rs

factor out into a function?

Copy link
Member Author

Choose a reason for hiding this comment

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

Feel free to open an issue but I think there is a more general problem here and it also involves the whole liberated_fn_sigs.

That is, there should be a common way to get the "function signature as viewed from inside the body" - possibly including reading the types associated with the hir::Body arguments as opposed to computing them from tcx.fn_sig(def_id).

Copy link
Member Author

@eddyb eddyb Sep 27, 2019

Choose a reason for hiding this comment

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

Point is, I don't want a shared function for just the c_variadic part of this.

@Centril
Copy link
Contributor

Centril commented Sep 28, 2019

Failed in #64860 (comment), @bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 28, 2019
@Centril
Copy link
Contributor

Centril commented Sep 28, 2019

@bors retry

@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 28, 2019
@eddyb
Copy link
Member Author

eddyb commented Sep 28, 2019

@bors r-

r? @matthewjasper for the MIR/NLL borrowck (I had to redo it, first attempt was flawed)

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 28, 2019
@eddyb eddyb added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 28, 2019
@matthewjasper
Copy link
Contributor

@bors r=nagisa,matthewjasper

@bors
Copy link
Contributor

bors commented Sep 28, 2019

📌 Commit 057f23d has been approved by nagisa,matthewjasper

@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 Sep 28, 2019
Centril added a commit to Centril/rust that referenced this pull request Sep 29, 2019
Remove redundancy from the implementation of C variadics.

This cleanup was first described in rust-lang#44930 (comment):

* AST doesn't track `c_variadic: bool` anymore, relying solely on a trailing `CVarArgs` type in fn signatures
* HIR doesn't have a `CVarArgs` anymore, relying solely on `c_variadic: bool`
  * same for `ty::FnSig` (see tests for diagnostics improvements from that)
  * `{hir,mir}::Body` have one extra argument than the signature when `c_variadic == true`
  * `rustc_typeck` and `rustc_mir::{build,borrowck}` need to give that argument the right type (which no longer uses a lifetime parameter, but a function-internal scope)
* `rustc_target::abi::call` doesn't need special hacks anymore (since it never sees the `VaListImpl` now, it's all inside the body)

r? @nagisa / @rkruppe cc @dlrobertson @oli-obk
bors added a commit that referenced this pull request Sep 29, 2019
Rollup of 5 pull requests

Successful merges:

 - #63492 (Remove redundancy from the implementation of C variadics.)
 - #64589 (Differentiate AArch64 bare-metal targets between hf and non-hf.)
 - #64799 (Fix double panic when printing query stack during an ICE)
 - #64824 (No StableHasherResult everywhere)
 - #64884 (Add pkg-config to dependency list if building for Linux on Linux)

Failed merges:

r? @ghost
@bors bors merged commit 057f23d into rust-lang:master Sep 29, 2019
@eddyb eddyb deleted the cvarargs branch September 29, 2019 10:42
tesuji added a commit to tesuji/rust-clippy that referenced this pull request Sep 29, 2019
bors added a commit to rust-lang/rust-clippy that referenced this pull request Sep 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.