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

saw-rustc doesn't work with const or static values #55

Closed
RyanGlScott opened this issue Aug 30, 2023 · 1 comment · Fixed by #56
Closed

saw-rustc doesn't work with const or static values #55

RyanGlScott opened this issue Aug 30, 2023 · 1 comment · Fixed by #56
Labels

Comments

@RyanGlScott
Copy link
Contributor

pub static X: u32 = 0;
pub const Y: u32 = 0;

pub fn z() -> u32 {
    X + Y
}
$ saw-rustc wat.rs
test build - extract output path - ["rustc", "wat.rs", "--test", "--target", "x86_64-unknown-linux-gnu", "--cfg", "crux"]
test build - ["rustc", "wat.rs", "--target", "x86_64-unknown-linux-gnu", "--cfg", "crux", "--cfg", "crux_top_level", "--crate-type", "rlib"]
note: Emitting MIR for wat/7d4d1b88::X

error: #[test] can only be applied to functions
 --> wat.rs:1:1
  |
1 | pub static X: u32 = 0;
  | ^^^^^^^^^^^^^^^^^

error: #[test] can only be applied to functions
 --> wat.rs:2:1
  |
2 | pub const Y: u32 = 0;
  | ^^^^^^^^^^^^^^^^

note: Emitting MIR for wat/7d4d1b88::z

error: aborting due to 2 previous errors

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ErrorGuaranteed(())', src/bin/mir-json-rustc-wrapper.rs:252:65
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Given that this is the third issue of this sort that we've opened (after #53 and #47), I wonder if we should rethink our approach to what saw-rustc disallows.

@spernsteiner
Copy link
Collaborator

The "#[test] can only be applied to functions" error doesn't really make sense for saw-rustc, where the #[crux::test] attribute is not actually used. Maybe saw-rustc should silently skip unsupported definitions where crux-rustc would produce this error. Then the saw-rustc output would include every function where you could have legally applied #[crux::test].

RyanGlScott added a commit that referenced this issue Sep 9, 2023
…roring

`crux-rustc` makes it an error to annotate non-functions with `#[crux::test]`
attributes. `saw-rustc` effectivelly annotates _everything_ with that
attribute, but we don't want to error when the annotation is applied to a
non-function, as typical Rust code will have more things (e.g., statics) than
just functions. We now make `saw-rustc` skip non-functions (thereby not marking
them as roots) instead of erroring.

Fixes #55.
RyanGlScott added a commit that referenced this issue Sep 11, 2023
…roring

`crux-rustc` makes it an error to annotate non-functions with `#[crux::test]`
attributes. `saw-rustc` effectivelly annotates _everything_ with that
attribute, but we don't want to error when the annotation is applied to a
non-function, as typical Rust code will have more things (e.g., statics) than
just functions. We now make `saw-rustc` skip non-functions (thereby not marking
them as roots) instead of erroring.

Fixes #55.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants