diagnostics: add }; only if { was added too

This commit is contained in:
Michael Howell 2022-11-12 22:08:07 -07:00
parent e9d8d238ef
commit e237690a28
4 changed files with 60 additions and 5 deletions

View file

@ -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((