Rollup merge of #100167 - chenyukang:require-suggestion, r=estebank
Recover `require`, `include` instead of `use` in item Fix #100140
This commit is contained in:
commit
18ddb41184
5 changed files with 35 additions and 3 deletions
|
@ -271,7 +271,10 @@ impl<'a> Parser<'a> {
|
||||||
// MACRO_RULES ITEM
|
// MACRO_RULES ITEM
|
||||||
self.parse_item_macro_rules(vis, has_bang)?
|
self.parse_item_macro_rules(vis, has_bang)?
|
||||||
} else if self.isnt_macro_invocation()
|
} else if self.isnt_macro_invocation()
|
||||||
&& (self.token.is_ident_named(sym::import) || self.token.is_ident_named(sym::using))
|
&& (self.token.is_ident_named(sym::import)
|
||||||
|
|| self.token.is_ident_named(sym::using)
|
||||||
|
|| self.token.is_ident_named(sym::include)
|
||||||
|
|| self.token.is_ident_named(sym::require))
|
||||||
{
|
{
|
||||||
return self.recover_import_as_use();
|
return self.recover_import_as_use();
|
||||||
} else if self.isnt_macro_invocation() && vis.kind.is_pub() {
|
} else if self.isnt_macro_invocation() && vis.kind.is_pub() {
|
||||||
|
|
|
@ -1170,6 +1170,7 @@ symbols! {
|
||||||
repr_packed,
|
repr_packed,
|
||||||
repr_simd,
|
repr_simd,
|
||||||
repr_transparent,
|
repr_transparent,
|
||||||
|
require,
|
||||||
residual,
|
residual,
|
||||||
result,
|
result,
|
||||||
rhs,
|
rhs,
|
||||||
|
|
|
@ -6,10 +6,18 @@ use std::{
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use std::time::Duration;
|
||||||
|
//~^ ERROR expected item, found `require`
|
||||||
|
|
||||||
|
use std::time::Instant;
|
||||||
|
//~^ ERROR expected item, found `include`
|
||||||
|
|
||||||
pub use std::io;
|
pub use std::io;
|
||||||
//~^ ERROR expected item, found `using`
|
//~^ ERROR expected item, found `using`
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = Rc::new(1);
|
let x = Rc::new(1);
|
||||||
let _ = write!(io::stdout(), "{:?}", x);
|
let _ = write!(io::stdout(), "{:?}", x);
|
||||||
|
let _ = Duration::new(5, 0);
|
||||||
|
let _ = Instant::now();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,18 @@ import std::{
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
require std::time::Duration;
|
||||||
|
//~^ ERROR expected item, found `require`
|
||||||
|
|
||||||
|
include std::time::Instant;
|
||||||
|
//~^ ERROR expected item, found `include`
|
||||||
|
|
||||||
pub using std::io;
|
pub using std::io;
|
||||||
//~^ ERROR expected item, found `using`
|
//~^ ERROR expected item, found `using`
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = Rc::new(1);
|
let x = Rc::new(1);
|
||||||
let _ = write!(io::stdout(), "{:?}", x);
|
let _ = write!(io::stdout(), "{:?}", x);
|
||||||
|
let _ = Duration::new(5, 0);
|
||||||
|
let _ = Instant::now();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,23 @@ error: expected item, found `import`
|
||||||
LL | import std::{
|
LL | import std::{
|
||||||
| ^^^^^^ help: items are imported using the `use` keyword
|
| ^^^^^^ help: items are imported using the `use` keyword
|
||||||
|
|
||||||
|
error: expected item, found `require`
|
||||||
|
--> $DIR/use_instead_of_import.rs:9:1
|
||||||
|
|
|
||||||
|
LL | require std::time::Duration;
|
||||||
|
| ^^^^^^^ help: items are imported using the `use` keyword
|
||||||
|
|
||||||
|
error: expected item, found `include`
|
||||||
|
--> $DIR/use_instead_of_import.rs:12:1
|
||||||
|
|
|
||||||
|
LL | include std::time::Instant;
|
||||||
|
| ^^^^^^^ help: items are imported using the `use` keyword
|
||||||
|
|
||||||
error: expected item, found `using`
|
error: expected item, found `using`
|
||||||
--> $DIR/use_instead_of_import.rs:9:5
|
--> $DIR/use_instead_of_import.rs:15:5
|
||||||
|
|
|
|
||||||
LL | pub using std::io;
|
LL | pub using std::io;
|
||||||
| ^^^^^ help: items are imported using the `use` keyword
|
| ^^^^^ help: items are imported using the `use` keyword
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue