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

with_sess called before set_parse_sess on nightly #50184

Closed
anna-is-cute opened this issue Apr 23, 2018 · 5 comments
Closed

with_sess called before set_parse_sess on nightly #50184

anna-is-cute opened this issue Apr 23, 2018 · 5 comments
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@anna-is-cute
Copy link

anna-is-cute commented Apr 23, 2018

cargo build output
   Compiling html5ever v0.22.2
   Compiling dotenv v0.11.0
   Compiling git2 v0.7.1
   Compiling string_cache v0.7.2
   Compiling markup5ever v0.7.2
   Compiling tokio-proto v0.1.1
   Compiling tokio-tls v0.1.4
   Compiling ring v0.13.0-alpha
error: failed to run custom build command for `string_cache v0.7.2`
process didn't exit successfully: `/Users/kyleclemens/Code/Rust/Projects/paste/target/debug/build/string_cache-d56e68a236f49db5/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'proc_macro::__internal::with_sess() called before set_parse_sess()!', libproc_macro/lib.rs:1319:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::begin_panic
   6: proc_macro::__internal::with_sess
   7: proc_macro2::imp::Span::call_site
             at /Users/kyleclemens/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-0.3.6/src/unstable.rs:223
   8: proc_macro2::Span::_new
             at /Users/kyleclemens/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-0.3.6/src/lib.rs:186
   9: siphasher::sip::u8to64_le
             at /Users/kyleclemens/.cargo/registry/src/github.com-1ecc6299db9ec823/string_cache_codegen-0.4.1/lib.rs:217
  10: siphasher::sip::u8to64_le
             at /Users/kyleclemens/.cargo/registry/src/github.com-1ecc6299db9ec823/string_cache_codegen-0.4.1/lib.rs:172
  11: string_cache_codegen::AtomType::to_tokens::{{closure}}
             at /Users/kyleclemens/.cargo/registry/src/github.com-1ecc6299db9ec823/string_cache_codegen-0.4.1/lib.rs:272
  12: build_script_build::main
             at ./build.rs:7
  13: std::rt::lang_start::{{closure}}
             at /Users/travis/build/rust-lang/rust/src/libstd/rt.rs:74
  14: std::panicking::try::do_call
  15: __rust_maybe_catch_panic
  16: std::rt::lang_start_internal
  17: std::rt::lang_start
             at /Users/travis/build/rust-lang/rust/src/libstd/rt.rs:74
  18: build_script_build::main

warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `html5ever v0.22.2`
process didn't exit successfully: `/Users/kyleclemens/Code/Rust/Projects/paste/target/debug/build/html5ever-a52d56e779889e57/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'proc_macro::__internal::with_sess() called before set_parse_sess()!', libproc_macro/lib.rs:1319:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::begin_panic
   6: proc_macro::__internal::with_sess
   7: <proc_macro::TokenStream as core::str::FromStr>::from_str
   8: core::alloc::Layout::align
             at /Users/travis/build/rust-lang/rust/src/libcore/str/mod.rs:2550
   9: core::clone::impls::<impl core::clone::Clone for bool>::clone
             at /Users/travis/build/rust-lang/rust/src/liballoc/str.rs:1814
  10: proc_macro2::imp::LexError
             at /Users/kyleclemens/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-0.3.6/src/unstable.rs:30
  11: core::alloc::Layout::align
             at /Users/travis/build/rust-lang/rust/src/libcore/str/mod.rs:2550
  12: core::clone::impls::<impl core::clone::Clone for bool>::clone
             at /Users/travis/build/rust-lang/rust/src/liballoc/str.rs:1814
  13: <syntax::parse::token::DelimToken as core::clone::Clone>::clone
             at /Users/kyleclemens/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-0.3.6/src/lib.rs:85
  14: <proc_macro2::TokenStream as core::clone::Clone>::clone
             at /Users/travis/build/rust-lang/rust/src/libcore/str/mod.rs:2550
  15: <alloc::alloc::Global as core::alloc::Alloc>::realloc
             at /Users/travis/build/rust-lang/rust/src/liballoc/str.rs:1814
  16: syn::parse2::{{closure}}
             at /Users/kyleclemens/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-0.13.1/src/lib.rs:640
  17: syn::parse2::{{closure}}
             at /Users/kyleclemens/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-0.13.1/src/lib.rs:705
  18: build_script_build::match_token::expand
             at ./macros/match_token.rs:114
  19: build_script_build::main
             at ./build.rs:24
  20: std::rt::lang_start::{{closure}}
             at /Users/travis/build/rust-lang/rust/src/libstd/rt.rs:74
  21: std::panicking::try::do_call
  22: __rust_maybe_catch_panic
  23: std::rt::lang_start_internal
  24: std::rt::lang_start
             at /Users/travis/build/rust-lang/rust/src/libstd/rt.rs:74
  25: build_script_build::main

warning: build failed, waiting for other jobs to finish...
error[E0425]: cannot find value `f` in this scope
 --> /Users/kyleclemens/.cargo/registry/src/github.com-1ecc6299db9ec823/dotenv-0.11.0/src/errors.rs:3:17
  |
3 | #[derive(Debug, ErrorChain)]
  |                 ^^^^^^^^^^ not found in this scope

error: aborting due to previous error

For more information about this error, try `rustc --explain E0425`.
error: Could not compile `dotenv`.
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `markup5ever v0.7.2`
process didn't exit successfully: `/Users/kyleclemens/Code/Rust/Projects/paste/target/debug/build/markup5ever-3a7d0e3731af9f38/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'proc_macro::__internal::with_sess() called before set_parse_sess()!', libproc_macro/lib.rs:1319:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::begin_panic
   6: proc_macro::__internal::with_sess
   7: proc_macro2::imp::Span::call_site
             at /Users/kyleclemens/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-0.3.6/src/unstable.rs:223
   8: proc_macro2::Span::_new
             at /Users/kyleclemens/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-0.3.6/src/lib.rs:186
   9: siphasher::sip::u8to64_le
             at /Users/kyleclemens/.cargo/registry/src/github.com-1ecc6299db9ec823/string_cache_codegen-0.4.1/lib.rs:217
  10: string_cache_codegen::AtomType::write_to
             at /Users/kyleclemens/.cargo/registry/src/github.com-1ecc6299db9ec823/string_cache_codegen-0.4.1/lib.rs:172
  11: build_script_build::main
             at ./build.rs:51
  12: std::rt::lang_start::{{closure}}
             at /Users/travis/build/rust-lang/rust/src/libstd/rt.rs:74
  13: std::panicking::try::do_call
  14: __rust_maybe_catch_panic
  15: std::rt::lang_start_internal
  16: std::rt::lang_start
             at /Users/travis/build/rust-lang/rust/src/libstd/rt.rs:74
  17: <build_script_build::named_entities_to_phf::_IMPL_DESERIALIZE_FOR_CharRef::<impl serde::de::Deserialize<'de> for build_script_build::named_entities_to_phf::CharRef>::deserialize::__Visitor<'de> as serde::de::Visitor<'de>>::visit_map

warning: build failed, waiting for other jobs to finish...
error: build failed

This looks awfully similar to #41610.

This is on rustc 1.27.0-nightly (ac3c2288f 2018-04-18), but I can reproduce back to 2018-04-16. I can't test further back because a library restricts the compiler version to newer than 04-16.

macOS 10.13.4, Rust installed via rustup and not brew.

Reproduced on ubuntu Docker image and on a Debian 9 Linode.

This example repository will produce this issue when cargo build is used.

@ishitatsuyuki ishitatsuyuki added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Apr 24, 2018
@BigBigos
Copy link

Hi,

I can also reproduce this problem on Linux with rustup. It happens when I try to compile string_cache that has a build.rs script that uses string_cache_codegen which subsequently relies on proc_macro2.

The oldest nightly version that reproduces this issue is nightly-2018-04-06 (rust version 1.27.0-nightly (48fa6f963 2018-04-05)). Older versions cannot compile proc_macro2 (due to this commit) which is needed for string_cache_codegen (see above).

After debugging more, it seems that something (?) enables the nightly feature of proc_macro2 which is broken. Running a simple test case (just run quote!() from the quote crate) reproduces this issue when nightly feature is enabled in proc_macro2 but does not reproduce by default. I will create another bug report for the broken nightly feature.

@BigBigos
Copy link

@jkcclemens

Your problem seems to be caused by the existence of codegen_next crate in the Rocket repo. It enables the nigthly feature of proc-macro2 which is then shared and used this way in string_cache_codegen which is unsupported.

I guess you cannot build anything using quote!() outside of procedural macros (like string_cache) when this nightly feature is enabled by at least a single dependency.

@anna-is-cute
Copy link
Author

Are there any plans to fix this? It's been a month of no progress, so just curious if it has been looked at.

@Centril Centril added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Mar 10, 2020
@Centril
Copy link
Contributor

Centril commented Mar 10, 2020

@jkcclemens If you could provide a minimal reproducer that would help towards fixing this.

@jyn514
Copy link
Member

jyn514 commented Mar 20, 2023

Your problem seems to be caused by the existence of codegen_next crate in the Rocket repo. It enables the nigthly feature of proc-macro2 which is then shared and used this way in string_cache_codegen which is unsupported.

This sounds like a bug in proc-macro2, not the compiler itself. I haven't seen other issues related to string_cache_codegen so I suspect this was fixed in a later version of proc-macro2.

@jyn514 jyn514 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants