Skip to content

Commit a8f2e33

Browse files
Add more ICEs due to malformed diagnostic::on_unimplemented
1 parent a60f077 commit a8f2e33

File tree

4 files changed

+56
-35
lines changed

4 files changed

+56
-35
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
11
#[diagnostic::on_unimplemented(aa = "broken")]
2-
pub trait Test {}
2+
pub trait MissingAttr {}
3+
4+
#[diagnostic::on_unimplemented(label = "a", label = "b")]
5+
pub trait DuplicateAttr {}
6+
7+
#[diagnostic::on_unimplemented = "broken"]
8+
pub trait NotMetaList {}
9+
10+
#[diagnostic::on_unimplemented]
11+
pub trait Empty {}
12+
13+
#[diagnostic::on_unimplemented {}]
14+
pub trait WrongDelim {}
15+
16+
#[diagnostic::on_unimplemented(label = "{A:.3}")]
17+
pub trait BadFormatter<A> {}
18+
19+
#[diagnostic::on_unimplemented(label = "test {}")]
20+
pub trait NoImplicitArgs {}
21+
22+
#[diagnostic::on_unimplemented(label = "{missing}")]
23+
pub trait MissingArg {}
24+
25+
#[diagnostic::on_unimplemented(label = "{_}")]
26+
pub trait BadArg {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//@ edition:2021
2+
//@ aux-build:bad_on_unimplemented.rs
3+
4+
// Do not ICE when encountering a malformed `#[diagnostic::on_unimplemented]` annotation in a
5+
// dependency when incorrectly used (#124651).
6+
7+
extern crate bad_on_unimplemented;
8+
9+
use bad_on_unimplemented::*;
10+
11+
fn missing_attr<T: MissingAttr>(_: T) {}
12+
fn duplicate_attr<T: DuplicateAttr>(_: T) {}
13+
fn not_meta_list<T: NotMetaList>(_: T) {}
14+
fn empty<T: Empty>(_: T) {}
15+
fn wrong_delim<T: WrongDelim>(_: T) {}
16+
fn bad_formatter<T: BadFormatter<()>>(_: T) {}
17+
fn no_implicit_args<T: NoImplicitArgs>(_: T) {}
18+
fn missing_arg<T: MissingArg>(_: T) {}
19+
fn bad_arg<T: BadArg>(_: T) {}
20+
21+
fn main() {
22+
missing_attr(()); //~ ERROR E0277
23+
duplicate_attr(()); //~ ERROR E0277
24+
not_meta_list(()); //~ ERROR E0277
25+
empty(()); //~ ERROR E0277
26+
wrong_delim(()); //~ ERROR E0277
27+
bad_formatter(()); //~ ERROR E0277
28+
no_implicit_args(()); //~ ERROR E0277
29+
missing_arg(()); //~ ERROR E0277
30+
bad_arg(()); //~ ERROR E0277
31+
}

tests/ui/diagnostic_namespace/on_unimplemented_ice.rs

-17
This file was deleted.

tests/ui/diagnostic_namespace/on_unimplemented_ice.stderr

-17
This file was deleted.

0 commit comments

Comments
 (0)