-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add needs-target-has-atomic
directive
#133736
Conversation
Before this commit, the test writer has to specify platforms and architectures by hand for targets that have differing atomic width support. `#[cfg(target_has_atomic)]` is not quite the same because (1) you may have to specify additional matchers manually which has to be maintained individually, and (2) the `#[cfg]` blocks does not communicate to compiletest that a test would be ignored for a given target. This commit implements a `//@ needs-target-has-atomic` directive which admits a comma-separated list of required atomic widths that the target must satisfy in order for the test to run. ``` //@ needs-target-has-atomic: 8, 16, ptr ``` See <rust-lang#87377>. Co-authored-by: kei519 <masaki.keigo.q00@kyoto-u.jp>
rustbot has assigned @Mark-Simulacrum. Use |
r? compiler (or bootstrap) |
let (name, comment) = match ln.split_once([':', ' ']) { | ||
Some((name, comment)) => (name, Some(comment)), | ||
let (name, rest) = match ln.split_once([':', ' ']) { | ||
Some((name, rest)) => (name, Some(rest)), | ||
None => (ln, None), | ||
}; | ||
|
||
// FIXME(jieyouxu): tighten up this parsing to reject using both `:` and ` ` as means to | ||
// delineate value. | ||
if name == "needs-target-has-atomic" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: I didn't want to adjust how directives accept :
for name-value form vs name-comment form in this PR, so this temporarily accepts //@ needs-target-has-atomic 8,16,ptr
but I want to only accept the colon form in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I noted this in the original PR I think. It's fine as long as we acknowledge wanting to fix it in the future.
/// Known widths of `target_has_atomic`. | ||
pub const KNOWN_TARGET_HAS_ATOMIC_WIDTHS: &[&str] = &["8", "16", "32", "64", "128", "ptr"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: this is yet another hard-coded list 😅
@bors r+ rollup |
…llaumeGomez Rollup of 13 pull requests Successful merges: - rust-lang#133603 (Eliminate magic numbers from expression precedence) - rust-lang#133715 (rustdoc-json: Include safety of `static`s) - rust-lang#133721 (rustdoc-json: Add test for `impl Trait for dyn Trait`) - rust-lang#133725 (Remove `//@ compare-output-lines-by-subset`) - rust-lang#133730 (Add pretty-printer parenthesis insertion test) - rust-lang#133736 (Add `needs-target-has-atomic` directive) - rust-lang#133739 (Re-add myself to rotation) - rust-lang#133743 (Fix docs for `<[T]>::as_array`.) - rust-lang#133744 (Fix typo README.md) - rust-lang#133745 (Remove static HashSet for default IDs list) - rust-lang#133749 (mir validator: don't store mir phase) - rust-lang#133751 (remove `Ty::is_copy_modulo_regions`) - rust-lang#133757 (`impl Default for EarlyDiagCtxt`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#133736 - jieyouxu:needs-target-has-atomic, r=compiler-errors Add `needs-target-has-atomic` directive Before this PR, the test writer has to specify platforms and architectures by hand for targets that have differing atomic width support. `#[cfg(target_has_atomic="...")]` is not quite the same because (1) you may have to specify additional matchers manually which has to be maintained individually, and (2) the `#[cfg]` blocks does not communicate to compiletest that a test would be ignored for a given target. This PR implements a `//@ needs-target-has-atomic` directive which admits a comma-separated list of required atomic widths that the target must satisfy in order for the test to run. ``` //@ needs-target-has-atomic: 8, 16, ptr ``` See <rust-lang#87377>. This PR supersedes rust-lang#133095 and is co-authored by `@kei519,` because it was somewhat subtle, and it turned out easier to implement than to review. rustc-dev-guide docs PR: rust-lang/rustc-dev-guide#2154
Before this PR, the test writer has to specify platforms and architectures by hand for targets that have differing atomic width support.
#[cfg(target_has_atomic="...")]
is not quite the same because (1) you may have to specify additional matchers manually which has to be maintained individually, and (2) the#[cfg]
blocks does not communicate to compiletest that a test would be ignored for a given target.This PR implements a
//@ needs-target-has-atomic
directive which admits a comma-separated list of required atomic widths that the target must satisfy in order for the test to run.See #87377.
This PR supersedes #133095 and is co-authored by @kei519, because it was somewhat subtle, and it turned out easier to implement than to review.
rustc-dev-guide docs PR: rust-lang/rustc-dev-guide#2154