No fallback in structurally_resolve_types. Further refactoring.

Put all fallback in `apply_fallback_if_possible`.
This commit is contained in:
leonardo.yvens 2017-12-18 17:31:23 -02:00
parent f3cd4a7f64
commit 02084f3304
7 changed files with 59 additions and 54 deletions

View file

@ -7,6 +7,7 @@
// <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.
// compile-flags: --error-format=human
extern {
fn write(fildes: i32, buf: *const i8, nbyte: u64) -> i64;
@ -28,12 +29,7 @@ macro_rules! write {
}}
}
macro_rules! cast {
($x:expr) => ($x as ()) //~ ERROR non-primitive cast
}
fn main() {
let hello = ['H', 'e', 'y'];
write!(hello);
cast!(2);
}

View file

@ -0,0 +1,11 @@
error[E0308]: mismatched types
--> $DIR/issue-26480-1.rs:27:19
|
27 | $arr.len() * size_of($arr[0])); //~ ERROR mismatched types
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u64, found usize
...
34 | write!(hello);
| -------------- in this macro invocation
error: aborting due to previous error

View file

@ -0,0 +1,18 @@
// Copyright 2016 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.
// compile-flags: --error-format=human
macro_rules! cast {
($x:expr) => ($x as ()) //~ ERROR non-primitive cast
}
fn main() {
cast!(2);
}

View file

@ -0,0 +1,13 @@
error[E0605]: non-primitive cast: `i32` as `()`
--> $DIR/issue-26480-2.rs:13:19
|
13 | ($x:expr) => ($x as ()) //~ ERROR non-primitive cast
| ^^^^^^^^
...
17 | cast!(2);
| --------- in this macro invocation
|
= note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
error: aborting due to previous error

View file

@ -7,16 +7,5 @@ error[E0308]: mismatched types
37 | write!(hello);
| -------------- in this macro invocation
error[E0605]: non-primitive cast: `i32` as `()`
--> $DIR/issue-26480.rs:32:19
|
32 | ($x:expr) => ($x as ()) //~ ERROR non-primitive cast
| ^^^^^^^^
...
38 | cast!(2);
| --------- in this macro invocation
|
= note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
error: aborting due to 2 previous errors
error: aborting due to previous error