rust/tests/ui/return/return-from-residual-sugg-issue-125997.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
732 B
Rust
Raw Normal View History

//@ run-rustfix
#![allow(unused_imports)]
#![allow(dead_code)]
use std::fs::File;
use std::io::prelude::*;
fn test1() {
let mut _file = File::create("foo.txt")?;
//~^ ERROR the `?` operator can only be used in a function
}
fn test2() {
let mut _file = File::create("foo.txt")?;
//~^ ERROR the `?` operator can only be used in a function
println!();
}
macro_rules! mac {
() => {
fn test3() {
let mut _file = File::create("foo.txt")?;
//~^ ERROR the `?` operator can only be used in a function
println!();
}
};
}
fn main() {
let mut _file = File::create("foo.txt")?;
//~^ ERROR the `?` operator can only be used in a function
mac!();
}