Move issue-26480 cfail to ui test. Fix #33763
This commit is contained in:
parent
428099233a
commit
9cc8debeb7
@ -8,7 +8,7 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![feature(rand, core)]
|
#![feature(rand)]
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
@ -18,6 +18,11 @@ use std::process::Command;
|
|||||||
use std::__rand::{thread_rng, Rng};
|
use std::__rand::{thread_rng, Rng};
|
||||||
use std::{char, env};
|
use std::{char, env};
|
||||||
|
|
||||||
|
pub fn check_old_skool() -> bool {
|
||||||
|
use std::env;
|
||||||
|
env::var("RUST_NEW_ERROR_FORMAT").is_err()
|
||||||
|
}
|
||||||
|
|
||||||
// creates a file with `fn main() { <random ident> }` and checks the
|
// creates a file with `fn main() { <random ident> }` and checks the
|
||||||
// compiler emits a span of the appropriate length (for the
|
// compiler emits a span of the appropriate length (for the
|
||||||
// "unresolved name" message); currently just using the number of code
|
// "unresolved name" message); currently just using the number of code
|
||||||
@ -65,10 +70,17 @@ fn main() {
|
|||||||
|
|
||||||
let err = String::from_utf8_lossy(&result.stderr);
|
let err = String::from_utf8_lossy(&result.stderr);
|
||||||
|
|
||||||
// the span should end the line (e.g no extra ~'s)
|
if check_old_skool() {
|
||||||
let expected_span = format!("^{}\n", repeat("~").take(n - 1)
|
// the span should end the line (e.g no extra ~'s)
|
||||||
.collect::<String>());
|
let expected_span = format!("^{}\n", repeat("~").take(n - 1)
|
||||||
assert!(err.contains(&expected_span));
|
.collect::<String>());
|
||||||
|
assert!(err.contains(&expected_span));
|
||||||
|
} else {
|
||||||
|
// the span should end the line (e.g no extra ~'s)
|
||||||
|
let expected_span = format!("^{}\n", repeat("^").take(n - 1)
|
||||||
|
.collect::<String>());
|
||||||
|
assert!(err.contains(&expected_span));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test multi-column characters and tabs
|
// Test multi-column characters and tabs
|
||||||
@ -77,9 +89,6 @@ fn main() {
|
|||||||
r#"extern "路濫狼á́́" fn foo() {{}} extern "路濫狼á́" fn bar() {{}}"#);
|
r#"extern "路濫狼á́́" fn foo() {{}} extern "路濫狼á́" fn bar() {{}}"#);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extra characters. Every line is preceded by `filename:lineno <actual code>`
|
|
||||||
let offset = main_file.to_str().unwrap().len() + 3;
|
|
||||||
|
|
||||||
let result = Command::new("sh")
|
let result = Command::new("sh")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(format!("{} {}",
|
.arg(format!("{} {}",
|
||||||
@ -91,17 +100,31 @@ fn main() {
|
|||||||
|
|
||||||
// Test both the length of the snake and the leading spaces up to it
|
// Test both the length of the snake and the leading spaces up to it
|
||||||
|
|
||||||
// First snake is 8 ~s long, with 7 preceding spaces (excluding file name/line offset)
|
if check_old_skool() {
|
||||||
let expected_span = format!("\n{}^{}\n",
|
// Extra characters. Every line is preceded by `filename:lineno <actual code>`
|
||||||
repeat(" ").take(offset + 7).collect::<String>(),
|
let offset = main_file.to_str().unwrap().len() + 3;
|
||||||
repeat("~").take(8).collect::<String>());
|
|
||||||
assert!(err.contains(&expected_span));
|
// First snake is 8 ~s long, with 7 preceding spaces (excluding file name/line offset)
|
||||||
// Second snake is only 7 ~s long, with 36 preceding spaces,
|
let expected_span = format!("\n{}^{}\n",
|
||||||
// because rustc counts chars() now rather than width(). This
|
repeat(" ").take(offset + 7).collect::<String>(),
|
||||||
// is because width() functions are to be removed from
|
repeat("~").take(8).collect::<String>());
|
||||||
// librustc_unicode
|
assert!(err.contains(&expected_span));
|
||||||
let expected_span = format!("\n{}^{}\n",
|
// Second snake is only 7 ~s long, with 36 preceding spaces,
|
||||||
repeat(" ").take(offset + 36).collect::<String>(),
|
// because rustc counts chars() now rather than width(). This
|
||||||
repeat("~").take(7).collect::<String>());
|
// is because width() functions are to be removed from
|
||||||
assert!(err.contains(&expected_span));
|
// librustc_unicode
|
||||||
|
let expected_span = format!("\n{}^{}\n",
|
||||||
|
repeat(" ").take(offset + 36).collect::<String>(),
|
||||||
|
repeat("~").take(7).collect::<String>());
|
||||||
|
assert!(err.contains(&expected_span));
|
||||||
|
} else {
|
||||||
|
let expected_span = format!("\n |>{}{}\n",
|
||||||
|
repeat(" ").take(8).collect::<String>(),
|
||||||
|
repeat("^").take(9).collect::<String>());
|
||||||
|
assert!(err.contains(&expected_span));
|
||||||
|
let expected_span = format!("\n |>{}{}\n",
|
||||||
|
repeat(" ").take(37).collect::<String>(),
|
||||||
|
repeat("^").take(8).collect::<String>());
|
||||||
|
assert!(err.contains(&expected_span));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
// rustc-env:RUST_NEW_ERROR_FORMAT
|
||||||
extern {
|
extern {
|
||||||
fn write(fildes: i32, buf: *const i8, nbyte: u64) -> i64;
|
fn write(fildes: i32, buf: *const i8, nbyte: u64) -> i64;
|
||||||
}
|
}
|
||||||
@ -24,25 +25,16 @@ macro_rules! write {
|
|||||||
unsafe {
|
unsafe {
|
||||||
write(stdout, $arr.as_ptr() as *const i8,
|
write(stdout, $arr.as_ptr() as *const i8,
|
||||||
$arr.len() * size_of($arr[0]));
|
$arr.len() * size_of($arr[0]));
|
||||||
//~^ ERROR mismatched types
|
|
||||||
//~| expected u64, found usize
|
|
||||||
//~| expected type
|
|
||||||
//~| found type
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! cast {
|
macro_rules! cast {
|
||||||
($x:expr) => ($x as ()) //~ ERROR non-scalar cast
|
($x:expr) => ($x as ())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let hello = ['H', 'e', 'y'];
|
let hello = ['H', 'e', 'y'];
|
||||||
write!(hello);
|
write!(hello);
|
||||||
//~^ NOTE in this expansion of write!
|
|
||||||
//~| NOTE in this expansion of write!
|
|
||||||
//~| NOTE in this expansion of write!
|
|
||||||
|
|
||||||
cast!(2);
|
cast!(2);
|
||||||
//~^ NOTE in this expansion of cast!
|
|
||||||
}
|
}
|
17
src/test/ui/mismatched_types/issue-26480.stderr
Normal file
17
src/test/ui/mismatched_types/issue-26480.stderr
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
error: mismatched types [--explain E0308]
|
||||||
|
--> $DIR/issue-26480.rs:27:19
|
||||||
|
|>
|
||||||
|
27 |> $arr.len() * size_of($arr[0]));
|
||||||
|
|> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u64, found usize
|
||||||
|
$DIR/issue-26480.rs:38:5: 38:19: note: in this expansion of write! (defined in $DIR/issue-26480.rs)
|
||||||
|
|
||||||
|
|
||||||
|
error: non-scalar cast: `_` as `()`
|
||||||
|
--> $DIR/issue-26480.rs:33:19
|
||||||
|
|>
|
||||||
|
33 |> ($x:expr) => ($x as ())
|
||||||
|
|> ^^^^^^^^
|
||||||
|
$DIR/issue-26480.rs:39:5: 39:14: note: in this expansion of cast! (defined in $DIR/issue-26480.rs)
|
||||||
|
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
Loading…
Reference in New Issue
Block a user