Skip to content

Commit 17a28f7

Browse files
committed
add test for numeric literal cast
1 parent 0ff0669 commit 17a28f7

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn foo(_: u16) {}
12+
fn main() {
13+
foo(8u8);
14+
}
15+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/numeric-literal-cast.rs:13:9
3+
|
4+
LL | foo(8u8);
5+
| ^^^ expected u16, found u8
6+
help: change the type of the numeric literal from `u8` to `u16`
7+
|
8+
LL | foo(8u16);
9+
| ^^^^
10+
11+
error: aborting due to previous error
12+
13+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)