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

Incorrect attribute arguments are silently ignored #29000

Closed
wthrowe opened this issue Oct 12, 2015 · 1 comment
Closed

Incorrect attribute arguments are silently ignored #29000

wthrowe opened this issue Oct 12, 2015 · 1 comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`)

Comments

@wthrowe
Copy link
Contributor

wthrowe commented Oct 12, 2015

This test compiles with no warnings and passes.

#[test]
#[should_panic(exepcted = "foo")]
fn foo() {
    panic!("bar");
}

I would expect at least a warning that "exepcted" was unused.

@apasel422 apasel422 added the A-attributes Area: Attributes (`#[…]`, `#![…]`) label Oct 28, 2015
@ExpHP
Copy link
Contributor

ExpHP commented Aug 10, 2016

This still occurs, and is going to make me exceptionally paranoid.

Note: Even #[should_panic = "text"] is silently accepted.

bors added a commit that referenced this issue Nov 18, 2016
Improvements to the #[should_panic] feature

Add more error checking for the `#[should_panic]` attribute, and print the expected panic string when it does not match.

Fixes #29000

Eg:
```running 3 tests
test test2 ... ok
test test1 ... FAILED
: Panic did not include expected string 'foo'
test test3 ... FAILED

failures:

---- test1 stdout ----
	thread 'test1' panicked at 'bar', test.rs:7
note: Run with `RUST_BACKTRACE=1` for a backtrace.

---- test3 stdout ----
	thread 'test3' panicked at 'bar', test.rs:18

```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`)
Projects
None yet
Development

No branches or pull requests

3 participants