@@ -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.
@@ -778,17 +777,14 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
778
777
779
778
let msg = format ! ( "`{}` import is ambiguous" , name) ;
780
779
let mut err = self . session . struct_span_err ( span, & msg) ;
781
- let mut suggestion_choices = String :: new ( ) ;
780
+ let mut suggestion_choices = vec ! [ ] ;
782
781
if external_crate. is_some ( ) {
783
- write ! ( suggestion_choices , "`::{}`" , name) ;
782
+ suggestion_choices . push ( format ! ( "`::{}`" , name) ) ;
784
783
err. span_label ( span,
785
784
format ! ( "can refer to external crate `::{}`" , name) ) ;
786
785
}
787
786
if let Some ( result) = results. module_scope {
788
- if !suggestion_choices. is_empty ( ) {
789
- suggestion_choices. push_str ( " or " ) ;
790
- }
791
- write ! ( suggestion_choices, "`self::{}`" , name) ;
787
+ suggestion_choices. push ( format ! ( "`self::{}`" , name) ) ;
792
788
if uniform_paths_feature {
793
789
err. span_label ( result. span ,
794
790
format ! ( "can refer to `self::{}`" , name) ) ;
@@ -801,7 +797,7 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
801
797
err. span_label ( result. span ,
802
798
format ! ( "shadowed by block-scoped `{}`" , name) ) ;
803
799
}
804
- err. help ( & format ! ( "write {} explicitly instead" , suggestion_choices) ) ;
800
+ err. help ( & format ! ( "write {} explicitly instead" , suggestion_choices. join ( " or " ) ) ) ;
805
801
if uniform_paths_feature {
806
802
err. note ( "relative `use` paths enabled by `#![feature(uniform_paths)]`" ) ;
807
803
} else {
0 commit comments