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

compiletest: limitation of compile-fail error message collection #37871

Closed
xen0n opened this issue Nov 19, 2016 · 4 comments
Closed

compiletest: limitation of compile-fail error message collection #37871

xen0n opened this issue Nov 19, 2016 · 4 comments
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-feature-request Category: A feature request, i.e: not implemented / a PR.

Comments

@xen0n
Copy link
Contributor

xen0n commented Nov 19, 2016

Apparently the compiletest harness couldn't cope with multiple #[cfg]'d items expected to error. During fixing of the testsuite on MIPS I got very frustrated over some of the cases, such as this one:

// irrelevant parts omitted
#[cfg(any(target_arch = "mips",
          target_arch = "mips64"))]
asm!("move $0, $1" : "=r"(x) : "=r"(5));
#[cfg(any(target_arch = "x86",
          target_arch = "x86_64",
          target_arch = "arm",
          target_arch = "aarch64"))]
asm!("mov $1, $0" : "=r"(x) : "=r"(5));
//~^ ERROR operand constraint contains '='
#[cfg(any(target_arch = "mips",
          target_arch = "mips64"))]
asm!("move $0, $1" : "=r"(x) : "=r"(5));
#[cfg(any(target_arch = "x86",
          target_arch = "x86_64",
          target_arch = "arm",
          target_arch = "aarch64"))]
asm!("mov $1, $0" : "=r"(y) : "+r"(5));
//~^ ERROR operand constraint contains '+'
---- [compile-fail] compile-fail/asm-in-bad-modifier.rs stdout ----

error: /opt/store/src/rust/src/test/compile-fail/asm-in-bad-modifier.rs:23: unexpected "error": '23:40: 23:44: input operand constraint contains '=''

error: /opt/store/src/rust/src/test/compile-fail/asm-in-bad-modifier.rs:32: unexpected "error": '32:40: 32:44: input operand constraint contains '=''

error: /opt/store/src/rust/src/test/compile-fail/asm-in-bad-modifier.rs:28: expected error not found: operand constraint contains '='

error: /opt/store/src/rust/src/test/compile-fail/asm-in-bad-modifier.rs:37: expected error not found: operand constraint contains '+'

error: 2 unexpected errors found, 2 expected errors not found

If I copy and cfg the whole function, the error is even more confusing:

#[cfg(any(target_arch = "x86",
          target_arch = "x86_64",
          target_arch = "arm",
          target_arch = "aarch64"))]
pub fn main() {
    let x: isize;
    unsafe {
        asm!("mov $1, $0" : "r"(x) : "r"(5)); //~ ERROR output operand constraint lacks '='
    }
    foo(x);
}

#[cfg(any(target_arch = "mips",
          target_arch = "mips64"))]
pub fn main() {
    let x: isize;
    unsafe {
        asm!("move $0, $1" : "r"(x) : "r"(5)); //~ ERROR output operand constraint lacks '='
    }
    foo(x);
}
error: /opt/store/src/rust/src/test/compile-fail/asm-out-no-modifier.rs:24: expected error not found: output operand constraint lacks '='

error: 0 unexpected errors found, 1 expected errors not found

Apart from duplicating the whole test case file, is there any way to fix it in compiletest instead? However upon looking at the "parsing" code used I realize it's a huge undertake as the proper solution at least needs a proper AST to begin with...

@xen0n
Copy link
Contributor Author

xen0n commented Nov 19, 2016

Clarification: I'm asking if fixing compiletest to handle that is even worth the effort. I can always duplicate the testcases for the best practice of separating arch-dependent code according to, well, arches.

@Mark-Simulacrum Mark-Simulacrum added the A-testsuite Area: The testsuite used to check the correctness of rustc label May 16, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Jul 26, 2017
@Enselic
Copy link
Member

Enselic commented Sep 14, 2023

I'm asking if fixing compiletest to handle that is even worth the effort.

Triage: Let's interpret 7 years of silence as "it is not worth the effort" and close this issue.

@Enselic Enselic closed this as not planned Won't fix, can't repro, duplicate, stale Sep 14, 2023
@Noratrieb
Copy link
Member

@oli-obk since you're rewriting compiletest, here's something you may or may not want to consider

@oli-obk
Copy link
Contributor

oli-obk commented Sep 14, 2023

I believe this would be resolved by fixing oli-obk/ui_test#73

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-feature-request Category: A feature request, i.e: not implemented / a PR.
Projects
None yet
Development

No branches or pull requests

5 participants