Skip to content

Commit

Permalink
add test for numeric literal cast
Browse files Browse the repository at this point in the history
  • Loading branch information
csmoe committed Sep 16, 2018
1 parent 0ff0669 commit 17a28f7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/test/ui/mismatched_types/numeric-literal-cast.rs
@@ -0,0 +1,15 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

fn foo(_: u16) {}
fn main() {
foo(8u8);
}

13 changes: 13 additions & 0 deletions src/test/ui/mismatched_types/numeric-literal-cast.stderr
@@ -0,0 +1,13 @@
error[E0308]: mismatched types
--> $DIR/numeric-literal-cast.rs:13:9
|
LL | foo(8u8);
| ^^^ expected u16, found u8
help: change the type of the numeric literal from `u8` to `u16`
|
LL | foo(8u16);
| ^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.

0 comments on commit 17a28f7

Please sign in to comment.