Skip to content

unresolved macro call on standard library macro. #9352

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
Lokathor opened this issue Jun 21, 2021 · 8 comments
Closed

unresolved macro call on standard library macro. #9352

Lokathor opened this issue Jun 21, 2021 · 8 comments
Labels
A-macro macro expansion

Comments

@Lokathor
Copy link

The following code triggers an unresolved macro problem with RA nightly 2021-06-20:

// main.rs
fn main() {
  println!("sse2: {}", cfg!(target_feature = "sse2"));
  println!("sse3: {}", cfg!(target_feature = "sse3"));
  println!("ssse3: {}", cfg!(target_feature = "ssse3"));
  println!("sse4.1: {}", cfg!(target_feature = "sse4.1"));
  println!("sse4.2: {}", cfg!(target_feature = "sse4.2"));
  println!("runtime rdrand: {}", std::is_x86_feature_detected!("rdrand"));
  println!("runtime rdseed: {}", std::is_x86_feature_detected!("rdseed"));
}

Given that I'm building for x86_64 windows, the macro should be in the standard library just fine. Indeed, the program compiles and runs perfectly with cargo run, only RA itself is having the hiccup.

@Veykril Veykril added the A-macro macro expansion label Jun 21, 2021
@Veykril
Copy link
Member

Veykril commented Jun 21, 2021

The macro re-export is gated behind a simd_x86, https://github.com/rust-lang/rust/blob/6b354a13820a444f834a33365ae4a8d97d7d27ce/library/std/src/lib.rs#L541-L542.

When is this supposed to be set? Querying the cfg via rustc --print cfg for my windows target doesn't list it.

@bjorn3
Copy link
Member

bjorn3 commented Jun 21, 2021

That is a stability marker, not a cfg.

@Veykril
Copy link
Member

Veykril commented Jun 21, 2021

Wasn't quite awake yet I suppose 🤦

@Veykril
Copy link
Member

Veykril commented Jun 21, 2021

So ye the problem is we can't resolve std_detect in std it seems.

@bjorn3
Copy link
Member

bjorn3 commented Jun 21, 2021

It probably needs to be added to the list of sysroot crates.

@jonas-schievink
Copy link
Contributor

stdarch is full of cfg_if!, so it probably won't work even then

bors bot added a commit that referenced this issue Jun 21, 2021
9357: fix: Update sysroot crates r=jonas-schievink a=jonas-schievink

Removes `rtstartup`, since that's not a Cargo crate (its files are compiled into object files and linked alongside the stdlib).

Adds  `std_detect`.

Part of #9352 (doesn't fix it since std_detect is full of `cfg_if!`)

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
@jonas-schievink
Copy link
Contributor

With #9357 the crate is now loaded correctly.

cc #7637 for the cfg_if! issue

@Veykril
Copy link
Member

Veykril commented Jul 2, 2022

Since this seems to work fine and the cfg_if! part is tracked in another issue I believe we can close this.

@Veykril Veykril closed this as completed Jul 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion
Projects
None yet
Development

No branches or pull requests

4 participants