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

Prevent call site environment from affecting assume!'s behavior #2

Merged
merged 1 commit into from Sep 20, 2021

Conversation

yvt
Copy link
Contributor

@yvt yvt commented Sep 20, 2021

Paths generated by macros are resolved in the call site's context. This means unprefixed paths like cfg!can refer to whichever the item imported in the call site's environment, not the one defined by the standard library. This PR rewrites all such paths to fix the issue.

/// Rogue macro
macro_rules! cfg {
    ($($tt:tt)*) => {
        return
    };
}

/// Rogue "crate"
mod core {}

#[test]
#[should_panic]
#[cfg(debug_assertions)]
fn should_not_affected_by_call_site_environment() {
    assume!(unsafe: @unreachable);
}

@NicholasGorski NicholasGorski merged commit 10ac5e6 into NicholasGorski:master Sep 20, 2021
@NicholasGorski
Copy link
Owner

Really appreciate you making this better, thank you!

@yvt yvt deleted the fix-fmt branch September 21, 2021 00:28
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

2 participants