Repository navigation
fix(macros): guard the generated entry with the impl cfg - #555
Merged
Merged
Conversation
Contributor
Author
|
审核结论:需要修改。 impl 上的
|
eric8810
force-pushed
the
fix/issue-541-macros-cfg
branch
from
October 22, 2026 00:08
e2c1c4d to
8948361
Compare
…rked blocks (#541) marked_services: a marked block under #[cfg(any())] and one removed by a cfg_attr build and serve nothing; a self: &Self method is served. The declaration generator's test checks such a method gives no warning.
Contributor
Author
|
接手完成剩余部分(06f62ffa):
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #541 (not all of it yet).
const _/entry/registration now carry the impl block's#[cfg]/#[cfg_attr(..., cfg(...))]. The entry is under the same cfg as its block.pub fn make<T: Default>(&self) -> T) is now rejected at the method, as R5 requires.&'static Tparameters are rejected at the method: decoding owns the value and cannot produce a static borrow.self: &Selfis accepted as a shared receiver by both the macro and thebuild.rsdeclaration generator.Still open in #541: cfg-disabled methods are still validated;
marked()in the generator does not filter impl cfg likemarked_types()does; callback return types are not checked asBoxFuture<'static, Result<..>>; a camelCase collision across two blocks is not detected.End-to-end (
crates/rutis-bridge/tests/marked_services.rs): a marked block under#[cfg(any())]and one removed by#[cfg_attr(not(any()), cfg(any()))], each naming a function that does not exist, build and serve nothing; aself: &Selfmethod is served. The generator's test checks such a method is declared with no warning.Note: rustc removes a cfg-disabled item before it expands the attribute macro on it, so the end-to-end case also builds without the guard; the guard keeps the generated entry under the same cfg as its block regardless.
Tests:
cargo test -p rutis-bridge --test marked_services,cargo test -p rutis-macros,cargo test -p rutis-bridge --features exports --lib build::exports,cargo check -p rutis -p rutis-loader,cargo fmt --check.