fix(acl): make ResolvedCommand referenced_by unconditional (fix #15406) - #15603
fix(acl): make ResolvedCommand referenced_by unconditional (fix #15406)#15603tenderdeve wants to merge 2 commits into
Conversation
…-apps#15406) The referenced_by field and ResolvedCommandReference were gated behind cfg(debug_assertions), so generate_context!'s ToTokens output depended on the proc-macro host's debug-assertions rather than the consumer's target. Under mismatched profiles (e.g. profile.release.build-override with debug-assertions = true) the emitted struct literal referenced a field the consumer could not see, failing with E0560. Make the field and its token emission unconditional so the resolved struct shape no longer varies by build profile.
Package Changes Through 95c5dffThere are 14 changes which include tauri with minor, tauri-cli with minor, @tauri-apps/cli with minor, tauri-bundler with minor, tauri-utils with minor, tauri-build with minor, tauri-macos-sign with minor, tauri-runtime-wry with minor, tauri-runtime with minor, tauri-codegen with minor, tauri-macros with minor, tauri-plugin with minor, tauri-driver with minor, @tauri-apps/api with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
Legend-Master
left a comment
There was a problem hiding this comment.
See #15406 (comment)
|
@Legend-Master right that the
In a plain Minimal repro (any tauri v2 app), add to [profile.release.build-override]
debug-assertions = truethen Flip it ( |
|
That sounds right in theory, but I can't seem to reproduce it... |
|
@Legend-Master got a self-contained repro. Two gotchas that make it not reproduce:
You don't even need tauri to see the class of bug — here's a 3-crate workspace that reproduces the exact
[workspace]
members = ["shared", "pmac", "app"]
resolver = "2"
[profile.release.build-override]
debug-assertions = true
#[derive(Default)]
pub struct Cmd {
pub context: u32,
#[cfg(debug_assertions)]
pub referenced_by: String,
}
use proc_macro::TokenStream;
#[proc_macro]
pub fn make_cmd(_: TokenStream) -> TokenStream {
let mut fields = String::from("context: 1u32,");
if cfg!(debug_assertions) { // HOST copy of `shared`, under build-override
fields.push_str("referenced_by: String::new(),");
}
format!("shared::Cmd {{ {fields} }}").parse().unwrap()
}
fn main() { let _c: shared::Cmd = pmac::make_cmd!(); }
Host proc-macro copy of |
|
Could you record a short video on the repro steps? Like from |
|
@Legend-Master can't easily attach a video, but here's the full copy-pasteable transcript from Three things that make it not reproduce (likely why it didn't for you):
The mirror case ( |
|
I see why 🤦♂️, the project I used to test things didn't have any allowed permissions, thanks for the repro |
|
@Legend-Master thanks for confirming. green now except the two android jobs, and those are a cross pre-compile infra thing, nothing to do with this. review's still on changes-requested from before the repro - could you take another look when you have a sec? and if you'd rather keep referenced_by debug-only i can gate it on the target profile instead, just went unconditional since the proc-macro can't read the consumer's debug_assertions. either way works for me. |
Closes #15406.
Closes #13865
ResolvedCommand::referenced_byandResolvedCommandReferencewere gated behind#[cfg(debug_assertions)]. Because a proc-macro'scfg(debug_assertions)reflects the macro's own host build (not the consumer's target),generate_context!'sToTokenscould emit a struct literal whose shape disagreed with the consumer's view ofResolvedCommand.Under mismatched profiles — e.g.:
cargo build --releasefails witherror[E0560]: struct ... has no field named referenced_by.Fix: drop the
cfg(debug_assertions)gating on the field, onResolvedCommandReference, on thereferenced_by_permission_identifierplumbing, and on theToTokensemission, so the resolved struct shape is identical across build profiles. Cost is twoStrings per command, diagnostic-only.Tested:
cargo test -p tauri-utils --features build(41 passing), pluscargo check -p tauriin both debug and release.