Skip to content

Rust cannot compile itself, as a cargo dependency #44298

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

Closed
kd8azz opened this issue Sep 3, 2017 · 6 comments
Closed

Rust cannot compile itself, as a cargo dependency #44298

kd8azz opened this issue Sep 3, 2017 · 6 comments

Comments

@kd8azz
Copy link

kd8azz commented Sep 3, 2017

Cargo.toml:

[dependencies]
syntax = { git = "https://github.com/rust-lang/rust/", branch = "stable" }

Command:
cargo build --all

Expected: Syntax module is imported.
Actual:
Stable and Beta rustc channels complian "#![feature] may not be used ..."
Nightly rustc channel just doesn't work.

@oli-obk
Copy link
Contributor

oli-obk commented Sep 4, 2017

what's the exact issue on nightly? This is expected not to work on stable/beta

@kd8azz
Copy link
Author

kd8azz commented Sep 4, 2017

Is there a supported way of using libsyntax as a dependency, without using the nightly compiler? I assume the nightly compiler will be broken 3 out of 4 nights.

Here's nightly's error:

$ cargo build --all --verbose
       Fresh serialize v0.0.0 (https://github.com/rust-lang/rust/?branch=stable#f3d6973f)
       Fresh log v0.3.8
       Fresh bitflags v0.8.2
   Compiling rustc_data_structures v0.0.0 (https://github.com/rust-lang/rust/?branch=stable#f3d6973f)
     Running `rustc --crate-name rustc_data_structures /home/user/.cargo/git/checkouts/rust-dd78c2fc2695b8eb/f3d6973/src/librustc_data_structures/lib.rs --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C debuginfo=2 -C metadata=0a44aaf343deb2c8 -C extra-filename=-0a44aaf343deb2c8 --out-dir /home/user/Source/my_project/target/debug/deps -L dependency=/home/user/Source/my_project/target/debug/deps --extern serialize=/home/user/Source/my_project/target/debug/deps/libserialize-18a6ea8c4c6023d1.so --extern serialize=/home/user/Source/my_project/target/debug/deps/libserialize-18a6ea8c4c6023d1.rlib --extern log=/home/user/Source/my_project/target/debug/deps/liblog-5fde67c83969596f.rlib --cap-lints allow`
error[E0308]: mismatched types
   --> /home/user/.cargo/git/checkouts/rust-dd78c2fc2695b8eb/f3d6973/src/librustc_data_structures/array_vec.rs:149:28
    |
149 |                 array_vec: Shared::new(self as *mut _),
    |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `core::ptr::Shared`, found enum `core::option::Option`
    |
    = note: expected type `core::ptr::Shared<array_vec::ArrayVec<A>>`
               found type `core::option::Option<core::ptr::Shared<_>>`
    = help: here are some functions which might fulfill your needs:
            - .unwrap()

error[E0308]: mismatched types
  --> /home/user/.cargo/git/checkouts/rust-dd78c2fc2695b8eb/f3d6973/src/librustc_data_structures/obligation_forest/node_index.rs:22:37
   |
22 |         unsafe { NodeIndex { index: NonZero::new((value as u32) + 1) } }
   |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `core::nonzero::NonZero`, found enum `core::option::Option`
   |
   = note: expected type `core::nonzero::NonZero<_>`
              found type `core::option::Option<core::nonzero::NonZero<_>>`
   = help: here are some functions which might fulfill your needs:
           - .unwrap()

error: aborting due to 2 previous errors

error: Could not compile `rustc_data_structures`.

Caused by:
  process didn't exit successfully: `rustc --crate-name rustc_data_structures /home/user/.cargo/git/checkouts/rust-dd78c2fc2695b8eb/f3d6973/src/librustc_data_structures/lib.rs --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C debuginfo=2 -C metadata=0a44aaf343deb2c8 -C extra-filename=-0a44aaf343deb2c8 --out-dir /home/user/Source/my_project/target/debug/deps -L dependency=/home/user/Source/my_project/target/debug/deps --extern serialize=/home/user/Source/my_project/target/debug/deps/libserialize-18a6ea8c4c6023d1.so --extern serialize=/home/user/Source/my_project/target/debug/deps/libserialize-18a6ea8c4c6023d1.rlib --extern log=/home/user/Source/my_project/target/debug/deps/liblog-5fde67c83969596f.rlib --cap-lints allow` (exit code: 101)

@arielb1
Copy link
Contributor

arielb1 commented Sep 4, 2017

You are trying to compile a stable rustc (see branch=stable) using a nightly rustc. That doesn't work - you should use a nightly rustc instead.

@arielb1
Copy link
Contributor

arielb1 commented Sep 4, 2017

@kd8azz

Also, the nightly compiler is working most of the time - we have quite good CI. You can also pick a good nightly and pin to it, Servo-style.

@kennytm
Copy link
Member

kennytm commented Sep 4, 2017

There is no way to use libsyntax on stable yet. This is currently tracked by #41732.

If you just want to parse Rust on stable, use syn.

If you want to use libsyntax on nightly, just write

#![feature(rustc_private)]
extern crate syntax;

You don't need to add any dependency to Cargo.

@kd8azz
Copy link
Author

kd8azz commented Sep 4, 2017

@arielb1 > You are trying to compile a stable rustc (see branch=stable) using a nightly rustc. That doesn't work - you should use a nightly rustc instead.

Ok, I can accept that.

@arielb1 > Also, the nightly compiler is working most of the time

Thanks, that's good to hear. Sorry for doubting your CI process. I just had a long day trying to get started on a project, and this was my problem.

@kennytm Thanks!

I just changed branch="master" and reran. It is currently broken, but I have a path forward now (as it turns out I was doing things the wrong way).

 $ cargo build --all --verbose
    Updating git repository `https://github.com/rust-lang/rust/`
   Compiling serialize v0.0.0 (https://github.com/rust-lang/rust/#a36d93d3)
     Running `rustc --crate-name serialize /home/user/.cargo/git/checkouts/rust-dd78c2fc2695b8eb/a36d93d3/src/libserialize/lib.rs --crate-type dylib --crate-type rlib --emit=dep-info,link -C prefer-dynamic -C debuginfo=2 -C metadata=c8d63cf921f261f3 -C extra-filename=-c8d63cf921f261f3 --out-dir /home/user/Source/my_project/target/debug/deps -L dependency=/home/user/Source/my_project/target/debug/deps --cap-lints allow`
       Fresh bitflags v0.8.2
   Compiling syntax v0.0.0 (https://github.com/rust-lang/rust/#a36d93d3)
       Fresh log v0.3.8
     Running `rustc --crate-name build_script_build /home/user/.cargo/git/checkouts/rust-dd78c2fc2695b8eb/a36d93d3/src/libsyntax/build.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=f3b37b4175585bbe -C extra-filename=-f3b37b4175585bbe --out-dir /home/user/Source/my_project/target/debug/build/syntax-f3b37b4175585bbe -L dependency=/home/user/Source/my_project/target/debug/deps --cap-lints allow`
     Running `/home/user/Source/my_project/target/debug/build/syntax-f3b37b4175585bbe/build-script-build`
   Compiling rustc_data_structures v0.0.0 (https://github.com/rust-lang/rust/#a36d93d3)
     Running `rustc --crate-name rustc_data_structures /home/user/.cargo/git/checkouts/rust-dd78c2fc2695b8eb/a36d93d3/src/librustc_data_structures/lib.rs --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C debuginfo=2 -C metadata=bb0d1cab5f0c2dc1 -C extra-filename=-bb0d1cab5f0c2dc1 --out-dir /home/user/Source/my_project/target/debug/deps -L dependency=/home/user/Source/my_project/target/debug/deps --extern log=/home/user/Source/my_project/target/debug/deps/liblog-b6e3b66094cb7016.rlib --extern serialize=/home/user/Source/my_project/target/debug/deps/libserialize-c8d63cf921f261f3.so --extern serialize=/home/user/Source/my_project/target/debug/deps/libserialize-c8d63cf921f261f3.rlib --cap-lints allow`
error: use of unstable library feature 'discriminant_value': recently added, follows RFC (see issue #24263)
   --> /home/user/.cargo/git/checkouts/rust-dd78c2fc2695b8eb/a36d93d3/src/librustc_data_structures/stable_hasher.rs:379:34
    |
379 | impl<T, CTX> HashStable<CTX> for ::std::mem::Discriminant<T> {
    |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: add #![feature(discriminant_value)] to the crate attributes to enable

error: aborting due to previous error

error: Could not compile `rustc_data_structures`.

Caused by:
  process didn't exit successfully: `rustc --crate-name rustc_data_structures /home/user/.cargo/git/checkouts/rust-dd78c2fc2695b8eb/a36d93d3/src/librustc_data_structures/lib.rs --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C debuginfo=2 -C metadata=bb0d1cab5f0c2dc1 -C extra-filename=-bb0d1cab5f0c2dc1 --out-dir /home/user/Source/my_project/target/debug/deps -L dependency=/home/user/Source/my_project/target/debug/deps --extern log=/home/user/Source/my_project/target/debug/deps/liblog-b6e3b66094cb7016.rlib --extern serialize=/home/user/Source/my_project/target/debug/deps/libserialize-c8d63cf921f261f3.so --extern serialize=/home/user/Source/my_project/target/debug/deps/libserialize-c8d63cf921f261f3.rlib --cap-lints allow` (exit code: 101)

Thank you everyone for your help.

@kd8azz kd8azz closed this as completed Sep 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants