Stream: t-compiler/help

Topic: `HasTargetSpec is not implemented`, but it is...


Edd Barrett (Dec 09 2019 at 11:47, on Zulip):

Hi all,

I've been banging my head against this odd trait error in rustc for a while.

I'm scaffolding a code-gen for an experiment, and I've hit the following error:

error[E0277]: the trait bound `CodegenCx<'_>: rustc_target::spec::HasTargetSpec` is not satisfied
   --> src/librustc_codegen_yksir/lib.rs:705:12
    |
705 | impl<'tcx> HasCodegen<'tcx> for Builder<'tcx> {
    |            ^^^^^^^^^^^^^^^^ the trait `rustc_target::spec::HasTargetSpec` is not implemented for `CodegenCx<'_>`

error[E0277]: the trait bound `Builder<'tcx>: rustc_target::spec::HasTargetSpec` is not satisfied
   --> src/librustc_codegen_yksir/lib.rs:748:16
    |
748 | impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'tcx> {
    |                ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `rustc_target::spec::HasTargetSpec` is not implemented for `Builder<'tcx>`

Yet HasTargetSpec is implemented for both CodeGenCx and Builder in the same file:

  impl HasTargetSpec for CodegenCx<'tcx> {
      fn target_spec(&self) -> &Target {
          unimplemented!();
      }
  }

  impl HasTargetSpec for Builder<'tcx> {
      fn target_spec(&self) -> &Target {
          unimplemented!();
      }
  }

What gives?

Full paste here:
https://paste.sr.ht/%7Evext01/8dfd9cd8be2843f1dedb7130ccb68f0ff5f806e6

(My fork is probably 3 weeks or so out of date)

Thanks

Edd Barrett (Dec 09 2019 at 12:35, on Zulip):

I think this is due to data structure clashes because of the way my dependencies are set up.

Last update: Jan 28 2020 at 01:00UTC