mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-03 05:13:35 +00:00
Minic rustc's new format_args! expansion
This commit is contained in:
parent
c13859903c
commit
4f8767d790
7 changed files with 366 additions and 41 deletions
|
|
@ -628,6 +628,17 @@ fn main() {
|
|||
#[test]
|
||||
fn orphan_unsafe_format_args() {
|
||||
// Checks that we don't place orphan arguments for formatting under an unsafe block.
|
||||
check_diagnostics(
|
||||
r#"
|
||||
//- minicore: fmt_before_1_89_0
|
||||
fn foo() {
|
||||
let p = 0xDEADBEEF as *const i32;
|
||||
format_args!("", *p);
|
||||
// ^^ error: dereference of raw pointer is unsafe and requires an unsafe function or block
|
||||
}
|
||||
"#,
|
||||
);
|
||||
|
||||
check_diagnostics(
|
||||
r#"
|
||||
//- minicore: fmt
|
||||
|
|
@ -958,4 +969,18 @@ impl FooTrait for S2 {
|
|||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_false_positive_on_format_args_since_1_89_0() {
|
||||
check_diagnostics(
|
||||
r#"
|
||||
//- minicore: fmt
|
||||
fn test() {
|
||||
let foo = 10;
|
||||
let bar = true;
|
||||
let _x = format_args!("{} {0} {} {last}", foo, bar, last = "!");
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue