Skip to content

Commit ccbf081

Browse files
committed
add invalid trait bounds check test
1 parent bb5ed9b commit ccbf081

3 files changed

Lines changed: 38 additions & 4 deletions

File tree

notes.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/checks.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,18 @@ fn missing_variant() {
258258
error
259259
);
260260
}
261+
262+
#[test]
263+
fn trait_bounds() {
264+
let (source, name) = (
265+
include_str!("invalid_programs/trait_bounds.con"),
266+
"invalid_programs/trait_bounds.con",
267+
);
268+
let error = check_invalid_program(source, name);
269+
270+
assert!(
271+
matches!(&error, LoweringError::TraitBoundNotMet(..)),
272+
"{:#?}",
273+
error
274+
);
275+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
mod test {
2+
pub trait ExampleTrait {
3+
fn example(&self) -> u32;
4+
}
5+
6+
struct ExampleStruct {
7+
x: u32,
8+
}
9+
10+
fn run<T: ExampleTrait>(value: T) -> u32 {
11+
return value.example();
12+
}
13+
14+
fn main() -> u32 {
15+
let ex: ExampleStruct = ExampleStruct {
16+
x: 2,
17+
};
18+
19+
let result: u32 = run(ex);
20+
21+
return result;
22+
}
23+
}

0 commit comments

Comments
 (0)