diff options
| author | Michael Howell <michael@notriddle.com> | 2022-12-06 08:42:30 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2023-01-20 14:53:34 -0700 |
| commit | dca160a06a85cfe6d961a586543112e772e55b13 (patch) | |
| tree | 6b3f24655c17940dd79be08ce1106899a042602a /compiler/rustc_resolve/src | |
| parent | e237690a28f0d38ab478616fe4b247fb6eb8013f (diff) | |
| download | rust-dca160a06a85cfe6d961a586543112e772e55b13.tar.gz rust-dca160a06a85cfe6d961a586543112e772e55b13.zip | |
diagnostics: use `module_path` to check crate import instead of strings
Diffstat (limited to 'compiler/rustc_resolve/src')
| -rw-r--r-- | compiler/rustc_resolve/src/diagnostics.rs | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index af4d7a8eaff..0b60952ae3c 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -2126,26 +2126,10 @@ impl<'a, 'b> ImportResolver<'a, 'b> { let source_map = self.r.session.source_map(); // Make sure this is actually crate-relative. - let use_and_crate = import.use_span.with_hi(after_crate_name.lo()); - let is_definitely_crate = - source_map.span_to_snippet(use_and_crate).map_or(false, |s| { - let mut s = s.trim(); - debug!("check_for_module_export_macro: s={s:?}",); - s = s - .split_whitespace() - .rev() - .next() - .expect("split_whitespace always yields at least once"); - debug!("check_for_module_export_macro: s={s:?}",); - if s.ends_with("::") { - s = &s[..s.len() - 2]; - } else { - return false; - } - s = s.trim(); - debug!("check_for_module_export_macro: s={s:?}",); - s != "self" && s != "super" - }); + let is_definitely_crate = import + .module_path + .first() + .map_or(false, |f| f.ident.name != kw::SelfLower && f.ident.name != kw::Super); // Add the import to the start, with a `{` if required. let start_point = source_map.start_point(after_crate_name); |
