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

rustc_codegen_ssa: streamline interactions between Builder's and CodegenCx, layout, etc. #56122

Closed
eddyb opened this issue Nov 21, 2018 · 4 comments
Labels
A-codegen Area: Code generation C-cleanup Category: PRs that clean code up or issues documenting cleanup.

Comments

@eddyb
Copy link
Member

eddyb commented Nov 21, 2018

It would be nice if Builder deref'd to CodegenCx to avoid typing bx.cx() everywhere.
Also, since Builder now has to implement all the layout traits itself, we could start writing e.g. layout.field(bx, i) instead of layout.field(bx.cx(), i).

There are probably a few more ergonomics / cleanup things we could do here as well.

cc @nikomatsakis @sunfishcode @denismerigoux @bjorn3

@eddyb eddyb added C-cleanup Category: PRs that clean code up or issues documenting cleanup. A-codegen Area: Code generation labels Nov 21, 2018
@bjorn3
Copy link
Member

bjorn3 commented Nov 27, 2018

I tried to add Deref<Target = Self::CodegenCx> bound to HasCodegen, but I get an error:

(The end of the first line is a reproducable glitch tc_codegen_ssa)

error[E0391]: cycle detected when computing the supertraits of `traits::HasCodegen`tc_codegen_ssa                                                                                            
  --> src/librustc_codegen_ssa/traits/mod.rs:88:1
   |
88 | pub trait HasCodegen<'tcx>: Backend<'tcx> + ::std::ops::Deref<Target = Self::CodegenCx> {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: ...which again requires computing the supertraits of `traits::HasCodegen`, completing the cycle
note: cycle used when computing the supertraits of `traits::type_::ArgTypeMethods`
  --> src/librustc_codegen_ssa/traits/type_.rs:186:33
   |
186| pub trait ArgTypeMethods<'tcx>: HasCodegen<'tcx> {
   |                                 ^^^^^^^^^^^^^^^^

error: aborting due to previous error

@eddyb
Copy link
Member Author

eddyb commented Nov 27, 2018

I think it's because of Self:: - try writing <Self as Trait>:: instead.

@bjorn3
Copy link
Member

bjorn3 commented Nov 27, 2018

That fixes it! Thanks.

@bjorn3
Copy link
Member

bjorn3 commented Jul 27, 2019

Fixed in #56198.

@eddyb eddyb closed this as completed Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation C-cleanup Category: PRs that clean code up or issues documenting cleanup.
Projects
None yet
Development

No branches or pull requests

2 participants