about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2022-11-12 22:08:07 -0700
committerMichael Howell <michael@notriddle.com>2023-01-20 14:53:33 -0700
commite237690a28f0d38ab478616fe4b247fb6eb8013f (patch)
tree6375efdefc65f144f8157d12b390b4f823c9dbe2 /compiler/rustc_resolve/src
parente9d8d238ef76c7991b316bbfbd9f857d84bd39cf (diff)
downloadrust-e237690a28f0d38ab478616fe4b247fb6eb8013f.tar.gz
rust-e237690a28f0d38ab478616fe4b247fb6eb8013f.zip
diagnostics: add `};` only if `{` was added too
Diffstat (limited to 'compiler/rustc_resolve/src')
-rw-r--r--compiler/rustc_resolve/src/diagnostics.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs
index 2a5cc288380..af4d7a8eaff 100644
--- a/compiler/rustc_resolve/src/diagnostics.rs
+++ b/compiler/rustc_resolve/src/diagnostics.rs
@@ -2161,6 +2161,11 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                             format!("{{{}, {}", import_snippet, start_snippet)
                         },
                     ));
+
+                    // Add a `};` to the end if nested, matching the `{` added at the start.
+                    if !has_nested {
+                        corrections.push((source_map.end_point(after_crate_name), "};".to_string()));
+                    }
                 } else {
                     // If the root import is module-relative, add the import separately
                     corrections.push((
@@ -2168,11 +2173,6 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                         format!("use {module_name}::{import_snippet};\n"),
                     ));
                 }
-
-                // Add a `};` to the end if nested, matching the `{` added at the start.
-                if !has_nested {
-                    corrections.push((source_map.end_point(after_crate_name), "};".to_string()));
-                }
             }
 
             let suggestion = Some((