Compiling rustc_dev_guide examples

Hello there :slightly_smiling_face: ,

I am trying to get the examples from the rustc dev guide to compile:

What I did is:

  • Create a new binary crate and copy paste one of the example (assuming this one )
  • Install the nightly-2021-03-28 toolchain with rustup toolchain install nightly-2021-03-28 --profile minimal
  • Install the rustc-dev and llvm-tools-preview components with rustup component add rustc-dev llvm-tools-preview --toolchain nightly-2021-03-28

Now, I try to run the example with cargo +nightly-20201-03-28 run, but I get the following error:

error[E0599]: no method named `items` found for struct `rustc_middle::hir::map::Map<'_>` in the current scope
  --> src/main.rs:76:39
   |
76 |                 for item in tcx.hir().items() {
   |                                       ^^^^^ help: there is an associated function with a similar name: `item`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.

I don't understand where this error comes from because the docs seem to show that this entry point is still available.

Any idea how to fix that ?

Best,

Alex

General Kenobi Hi :wave:

Given

it looks like you might need a more recent toolchain; another option, which is the one I'd recommend, would be to, instead, checkout those examples at the time that toolchain of yours was around / at the time the examples / guide were written: that's the point in time where we know the stuff was most in sync.

1 Like

@Yandros Thanks for this quick reply !

I understand why I missed it: I tried to download the proper documentation by adding the rust-docs component, but the rustc_guide link redirects to the online version. Is there any way to compile the rustc guide and the rustc crates docs for a given nightly release?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.