aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar/items
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-04-30 19:37:35 +0100
committerGitHub <[email protected]>2020-04-30 19:37:35 +0100
commit745bd45ddb2f8b6165ab7eacfd482d8530cab05a (patch)
tree9e36b55112d3ea5f9d913d36597884b82aa87f68 /crates/ra_parser/src/grammar/items
parent861652ffa6b6440a022a353d2e6b9f5ca780d2ec (diff)
parent513a3615f6d462852c0135dc4ac30a2086e25c5a (diff)
Merge #4227
4227: Report invalid, nested, multi-segment crate-paths r=matklad a=djrenren There was a bug in the previous path-validating code that didn't detect multi-segment paths that started with `crate`. ```rust // Successfully reported use foo::{crate}; // BUG: was not being reported use foo::{crate::bar}; ``` This was due to my confusion about path-associativity. That is, the path with no qualifier is the innermost path, not the outermost. I've updated the code with a lot of comments to explain what's going on. This bug was discovered when I found an erroneous `ok` test which I reported here: https://github.com/rust-analyzer/rust-analyzer/issues/4226 This test now fails and has been modified, hopefully in the spirit of the original test, to be correct. Sorry about submitting the bug in the first place! Co-authored-by: John Renner <[email protected]>
Diffstat (limited to 'crates/ra_parser/src/grammar/items')
-rw-r--r--crates/ra_parser/src/grammar/items/use_item.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/crates/ra_parser/src/grammar/items/use_item.rs b/crates/ra_parser/src/grammar/items/use_item.rs
index e3b991c8c..3a0c7a31a 100644
--- a/crates/ra_parser/src/grammar/items/use_item.rs
+++ b/crates/ra_parser/src/grammar/items/use_item.rs
@@ -47,7 +47,7 @@ fn use_tree(p: &mut Parser, top_level: bool) {
47 // use {crate::path::from::root, or::path::from::crate_name}; // Rust 2018 (with a crate named `or`) 47 // use {crate::path::from::root, or::path::from::crate_name}; // Rust 2018 (with a crate named `or`)
48 // use {path::from::root}; // Rust 2015 48 // use {path::from::root}; // Rust 2015
49 // use ::{some::arbritrary::path}; // Rust 2015 49 // use ::{some::arbritrary::path}; // Rust 2015
50 // use ::{{{crate::export}}}; // Nonsensical but perfectly legal nestnig 50 // use ::{{{root::export}}}; // Nonsensical but perfectly legal nesting
51 T!['{'] => { 51 T!['{'] => {
52 use_tree_list(p); 52 use_tree_list(p);
53 } 53 }