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

Code behaves differently when inside macro when using nightly #77532

Closed
pac85 opened this issue Oct 4, 2020 · 12 comments
Closed

Code behaves differently when inside macro when using nightly #77532

pac85 opened this issue Oct 4, 2020 · 12 comments
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections regression-from-stable-to-beta Performance or correctness regression from stable to beta.

Comments

@pac85
Copy link

pac85 commented Oct 4, 2020

I had a problem while using vulkano-shaders, I narrowed the problem down to this example.
https://gitlab.com/pac85/shaderc-test
I couldn't pin point the exact problem.

If you run the test with the stable compiler everything is fine, if you use nightly the macro panics.
If you take the code inside the macro and run it normally it runs just fine.

@pac85 pac85 added the C-bug Category: This is a bug. label Oct 4, 2020
@camelid camelid added requires-nightly This issue requires a nightly compiler in some way. A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) labels Oct 4, 2020
@pietroalbini pietroalbini added the regression-from-stable-to-beta Performance or correctness regression from stable to beta. label Oct 4, 2020
@pietroalbini
Copy link
Member

@Mark-Simulacrum the reporter says this works on stable but not on beta. cc @rust-lang/release

@pietroalbini
Copy link
Member

Hmm, wait, I can't reproduce on stable, beta nor nightly. @pac85 does it still return an error if you remove the target directory first?

@Mark-Simulacrum
Copy link
Member

Do we have the panic message? There were several macro-related breaking changes this cycle, I think.

I won't have a chance to try to reproduce locally or minimize for a bit, @rustbot ping cleanup - could we get a bisection and/or mcve?

@rustbot
Copy link
Collaborator

rustbot commented Oct 4, 2020

Error: Parsing ping command in comment failed: ...'ng cleanup' | error: expected end of command at >| ' - could w'...

Please let @rust-lang/release know if you're having trouble with this bot.

@shepmaster shepmaster changed the title Code behaves differently when inside macro when ausing nightly Code behaves differently when inside macro when using nightly Oct 4, 2020
@pac85
Copy link
Author

pac85 commented Oct 4, 2020

@pietroalbini

Error message
~/cose/shaderc-test on  master ⌚ 21:04:51
$ cargo clean

~/cose/shaderc-test on  master ⌚ 21:04:57
$ rustup default stable
info: using existing install for 'stable-x86_64-unknown-linux-gnu'
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'

  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.46.0 (04488afe3 2020-08-24)


~/cose/shaderc-test on  master ⌚ 21:05:14
$ cargo test
 ...

    Finished test [unoptimized + debuginfo] target(s) in 4.85s
     Running target/debug/deps/shaderc_test-e9f5c945c9e7bde8

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target/debug/deps/inside_macro-a78288748d256321

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target/debug/deps/out_of_macro-cdd0143a6165bf97

running 1 test
test out_of_macro ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

   Doc-tests shaderc-test

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out


~/cose/shaderc-test on  master ⌚ 21:05:21
$ rustup default nightly
info: using existing install for 'nightly-x86_64-unknown-linux-gnu'
info: default toolchain set to 'nightly-x86_64-unknown-linux-gnu'

  nightly-x86_64-unknown-linux-gnu unchanged - rustc 1.49.0-nightly (25c8c53dd 2020-10-03)


~/cose/shaderc-test on  master ⌚ 21:05:42
$ cargo clean

~/cose/shaderc-test on  master ⌚ 21:05:46
$ cargo test 
   Compiling cc v1.0.60
   Compiling libc v0.2.78
   Compiling cmake v0.1.44
   Compiling shaderc-sys v0.6.2
   Compiling shaderc v0.6.2
   Compiling shaderc-test v0.1.0 (/mnt/void/home/archdata/cose/shaderc-test)
warning: unused import: `shaderc_test`
 --> tests/out_of_macro.rs:1:5
  |
1 | use shaderc_test;
  |     ^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error: proc macro panicked
 --> tests/inside_macro.rs:3:1
  |
3 | test!();
  | ^^^^^^^^
  |
  = help: message: called `Result::unwrap()` on an `Err` value: CompilationError(2, "shader.glsl:3: error: \'#line\' : must by followed by an integral literal\nshader.glsl: error: shader.glsl:-1: \'#line\' : unexpected tokens following directive\n")

error: aborting due to previous error

error: could not compile `shaderc-test`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
warning: 1 warning emitted

error: build failed

@ehuss
Copy link
Contributor

ehuss commented Oct 4, 2020

I think this is the same as #76980. For some reason, shaderc-sys is experiencing some corruption when running within rustc as a proc-macro. In particular, this line is a C++ ostringstream that on stable computes correctly (this particular instance evalutes to the string "#line 1 \"std/foo", but on nightly it is corrupted (it evaluates to "#line ").

@pietroalbini
Copy link
Member

Ok, I was running cargo build, not cargo test. Can confirm it's broken on beta and nightly, and it works on stable.

@pietroalbini pietroalbini removed the requires-nightly This issue requires a nightly compiler in some way. label Oct 4, 2020
@pietroalbini
Copy link
Member

@rustbot ping cleanup

@rustbot rustbot added the ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections label Oct 4, 2020
@rustbot
Copy link
Collaborator

rustbot commented Oct 4, 2020

Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
"Cleanup ICE-breaking candidate". In case it's useful, here are some
instructions for tackling these sorts of bugs. Maybe take a look?
Thanks! <3

cc @AminArria @camelid @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @JamesPatrickGill @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @shekohex @sinato @smmalis37 @spastorino @Stupremee @tamuhey @turboladen @woshilapin @yerke

@ehuss
Copy link
Contributor

ehuss commented Oct 4, 2020

@pietroalbini I don't think that is necessary. This is a duplicate of #76980, and has already been bisected to #73526.

@pietroalbini
Copy link
Member

@ehuss right, missed that message, GitHub live synchronization occasionally messes up :(

Closing this in favor of #76980

@camelid

This comment has been minimized.

@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections regression-from-stable-to-beta Performance or correctness regression from stable to beta.
Projects
None yet
Development

No branches or pull requests

6 participants