#[cfg(test)]
mod tests {
- use crate::tests::check_assist;
+ use crate::tests::{check_assist, check_assist_not_applicable};
use super::*;
",
)
}
+
+ #[test]
+ fn test_empty_use() {
+ check_assist_not_applicable(
+ merge_imports,
+ r"
+use std::<|>
+fn main() {}",
+ );
+ }
}
fn issue4044() {
check_assist_not_applicable(split_import, "use crate::<|>:::self;")
}
+
+ #[test]
+ fn test_empty_use() {
+ check_assist_not_applicable(
+ split_import,
+ r"
+use std::<|>
+fn main() {}",
+ );
+ }
}
}
p.expect(T![>]);
} else {
+ let mut empty = true;
if first {
p.eat(T![::]);
+ empty = false;
}
match p.current() {
IDENT => {
T![self] | T![super] | T![crate] => p.bump_any(),
_ => {
p.err_recover("expected identifier", items::ITEM_RECOVERY_SET);
+ if empty {
+ // test_err empty_segment
+ // use crate::;
+ m.abandon(p);
+ return;
+ }
}
};
}
NAME_REF@4..7
IDENT@4..7 "foo"
COLON2@7..9 "::"
- PATH_SEGMENT@9..11
- ERROR@9..11
- INT_NUMBER@9..11 "92"
+ ERROR@9..11
+ INT_NUMBER@9..11 "92"
SEMICOLON@11..12 ";"
error 9..9: expected identifier
--- /dev/null
+SOURCE_FILE@0..13
+ USE_ITEM@0..12
+ USE_KW@0..3 "use"
+ WHITESPACE@3..4 " "
+ USE_TREE@4..12
+ PATH@4..12
+ PATH@4..9
+ PATH_SEGMENT@4..9
+ CRATE_KW@4..9 "crate"
+ COLON2@9..11 "::"
+ ERROR@11..12
+ SEMICOLON@11..12 ";"
+ WHITESPACE@12..13 "\n"
+error 11..11: expected identifier
+error 12..12: expected SEMICOLON
--- /dev/null
+use crate::;
env UPDATE_EXPECTATIONS=1 cargo qt
```
+After adding a new inline test you need to run `cargo xtest codegen` and also update the test data as described above.
+
# Logging
Logging is done by both rust-analyzer and VS Code, so it might be tricky to