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

Try to diagnose "cannot find type SourceFile" errors better

Merged
merged 1 commit into from Dec 14, 2021
Merged

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Dec 14, 2021

Cargo's logic for what cfg get passed to the build script build, what to the library build, and what to the documentation build is apparently super subtle. See the discussion under rust-lang/docs.rs#1580.

@dtolnay
Copy link
Owner Author

dtolnay commented Dec 14, 2021

The cfg in this PR on the compile_error! is derived from:

proc-macro2/build.rs

Lines 107 to 109 in 3ff70da

if version.nightly || !semver_exempt {
println!("cargo:rustc-cfg=wrap_proc_macro");
}

and:

proc-macro2/build.rs

Lines 115 to 117 in 3ff70da

if semver_exempt && version.nightly {
println!("cargo:rustc-cfg=super_unstable");
}

which means:

all(procmacro2_semver_exempt, wrap_proc_macro, not(super_unstable))

= semver_exempt && wrap_proc_macro && !super_unstable

= semver_exempt && (nightly || !semver_exempt) && !(semver_exempt && nightly)

= true && (nightly || !true) && !(true && nightly) || false && (nightly || !false) && !(false && nightly)

= true && (nightly || false) && !nightly || false

= nightly && !nightly

= false

@dtolnay dtolnay merged commit 5671a59 into master Dec 14, 2021
14 checks passed
@dtolnay dtolnay deleted the cfg branch Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant