Skip to content

Proc macros not expanding again in rust 1.78 #17231

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
mkolopanis opened this issue May 14, 2024 · 10 comments
Closed

Proc macros not expanding again in rust 1.78 #17231

mkolopanis opened this issue May 14, 2024 · 10 comments
Labels
Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug

Comments

@mkolopanis
Copy link

rust-analyzer version: rust-analyzer version: 0.4.1959-standalone

rustc version: rustc 1.78.0 (9b00956e5 2024-04-29)

editor or extension: VS-Code 1.89.1
dc96b837cf6bb4af9cd736aa3af08cf8279f7685
x64

relevant settings: None

Appears to be the same issue as #16331 again, as mentioned in #17178.

Have tried using the pre-release and stable releases of rust-analyzer in vscode which has no effect.
This seems to be the best MWE mentioned in #16331 and the proc macro expansion still fails with this MWE.
Occurs on a brand new project and even after removing target directory.

I haven't been able to find anything on this on the Forums, and the linked issues were asked to make a new one (e.g. this one).

image

Rust Analyzer Output
024-05-14T16:22:21.270686Z ERROR rust_analyzer::main_loop: FetchBuildDataError:
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1959-linux-x64/server/rust-analyzer /home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/clippy-driver /home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc - --crate-name ___ --print=file-names --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg` (exit status: 1)
  --- stderr
  error: Unrecognized option: 'keep-going'


error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1959-linux-x64/server/rust-analyzer /home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/clippy-driver /home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc - --crate-name ___ --print=file-names --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg` (exit status: 1)
  --- stderr
  error: Unrecognized option: 'keep-going'

code snippet to reproduce:

#![no_std]

#[cfg(feature = "std")]
extern crate std;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(thiserror::Error))]
enum Test {
    One,
    Two,
}
impl core::fmt::Display for Test {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{:?}", self)
    }
}
fn main() {}

Cargo.toml

[package]
 name    = "rust-test"
 version = "0.1.0"
 edition = "2021"

[features]
 std = [ "dep:thiserror" ]

[dependencies]
 thiserror = { version = "1.0.60", optional = true }
@Veykril
Copy link
Member

Veykril commented May 14, 2024

Do you have any relevant cargo configs set in the vscode settings? I am a bit confused as to why the clippy-driver appears in your logs

#17127 related

@Veykril Veykril added the Broken Window Bugs / technical debt to be addressed immediately label May 14, 2024
bors added a commit that referenced this issue May 14, 2024
fix: Don't emit --keep-going for custom build script commands

Might be the cause for #17231
@mkolopanis
Copy link
Author

I was a bit confused to see that myself. I do have these overrides I found I needed to get the "Problems" tab to populate correctly with the clippy outputs at one point. Though they could be holdovers from a early workaround or something.

 "[rust]": {
        "editor.defaultFormatter": "rust-lang.rust-analyzer",
        "editor.formatOnSave": true
    },
 "rust-analyzer.cargo.features": "all",

 "editor.formatOnSave": true,
 "rust-analyzer.cargo.buildScripts.overrideCommand": [
    
        "cargo",
        "clippy",
        "--all-features",
        "--quiet",
        "--workspace",
        "--message-format=json",
        "--all-targets",
        "--",
        "-D",
        "warnings"
    ],
    "rust-analyzer.procMacro.enable": true,
    "rust-analyzer.check.command": "clippy",
    "rust-analyzer.check.extraArgs": [
        "--quiet",
        "--",
        "-D",
        "warnings"
    ],

@micolore
Copy link

image

neovim
rust 1.78
rust-analyzer 2024-05-13

upgrade rust version(1.78) has this error

@Veykril
Copy link
Member

Veykril commented May 15, 2024

That rust-analyzer.cargo.buildScripts.overrideCommand is certainly questionable, but confirms my suspicion. #17232 should fix this, please try the latest nightly r-a release or next monday's stable

@mkolopanis
Copy link
Author

Thank you!

lnicola pushed a commit to lnicola/rust that referenced this issue May 19, 2024
…eykril

fix: Don't emit --keep-going for custom build script commands

Might be the cause for rust-lang/rust-analyzer#17231
@Veykril Veykril closed this as completed May 28, 2024
@JuiceDrinker
Copy link

I'm still experiencing this issue in 1.79. Using rust-analyzer in neovim via rustaceanvim with default configuration. Have tried re-installing toolchains, deleting target/ directory, re-installing components via rustup but no luck anywhere. My specific error message is a bit different however: "proc-macro server's api version (4) is newer than rust-analyzer's (2)".

@Veykril
Copy link
Member

Veykril commented Jul 3, 2024

That hints at your rust-analyzer installation being way too old

@DragonDev1906
Copy link

proc macro feature not expanded: No proc-macros present for crate

#[cfg_attr(feature = "wasm", derive(Tsify), tsify(into_wasm_abi, from_wasm_abi))]

I have this issue in both vscode and zed, with the latest version: 0.3.2037-standalone and I do not have a custom build command configured.

@TiloPapke
Copy link

had a simliar problem, suddenly there where a lot of proc macro feature not expanded: No proc-macros present for crate errors.
the reasons was that the rust-analyzer extention was updated (v0.3.2045) but my rustc was at version 1.72.
after updating rustc to 1.79 the errors disappeared

@mdeltito
Copy link

Confirming this issue exists with RA v0.3.2045 + rust toolchain 1.72. Rolling back to an earlier RA version v0.3.1896 resolved this in my case.

@rust-lang rust-lang locked as resolved and limited conversation to collaborators Jul 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

7 participants