@@ -36,7 +36,6 @@ use syntax_pos::{MultiSpan, Span};
36
36
37
37
use std:: cell:: { Cell , RefCell } ;
38
38
use std:: collections:: BTreeMap ;
39
- use std:: fmt:: Write ;
40
39
use std:: { mem, ptr} ;
41
40
42
41
/// Contains data for specific types of import directives.
@@ -780,17 +779,14 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
780
779
781
780
let msg = format ! ( "`{}` import is ambiguous" , name) ;
782
781
let mut err = self . session . struct_span_err ( span, & msg) ;
783
- let mut suggestion_choices = String :: new ( ) ;
782
+ let mut suggestion_choices = vec ! [ ] ;
784
783
if external_crate. is_some ( ) {
785
- write ! ( suggestion_choices , "`::{}`" , name) ;
784
+ suggestion_choices . push ( format ! ( "`::{}`" , name) ) ;
786
785
err. span_label ( span,
787
786
format ! ( "can refer to external crate `::{}`" , name) ) ;
788
787
}
789
788
if let Some ( result) = results. module_scope {
790
- if !suggestion_choices. is_empty ( ) {
791
- suggestion_choices. push_str ( " or " ) ;
792
- }
793
- write ! ( suggestion_choices, "`self::{}`" , name) ;
789
+ suggestion_choices. push ( format ! ( "`self::{}`" , name) ) ;
794
790
if uniform_paths_feature {
795
791
err. span_label ( result. span ,
796
792
format ! ( "can refer to `self::{}`" , name) ) ;
@@ -803,7 +799,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
803
799
err. span_label ( result. span ,
804
800
format ! ( "shadowed by block-scoped `{}`" , name) ) ;
805
801
}
806
- err. help ( & format ! ( "write {} explicitly instead" , suggestion_choices) ) ;
802
+ err. help ( & format ! ( "write {} explicitly instead" , suggestion_choices. join ( " or " ) ) ) ;
807
803
if uniform_paths_feature {
808
804
err. note ( "relative `use` paths enabled by `#![feature(uniform_paths)]`" ) ;
809
805
} else {
0 commit comments