@@ -5,10 +5,10 @@ use std::mem;
55
66use base_db:: CrateId ;
77use hir_expand:: {
8- name:: { name , AsName , Name } ,
8+ name:: { AsName , Name } ,
99 ExpandError , InFile ,
1010} ;
11- use intern:: Interned ;
11+ use intern:: { sym , Interned } ;
1212use rustc_hash:: FxHashMap ;
1313use smallvec:: SmallVec ;
1414use span:: AstIdMap ;
@@ -187,8 +187,10 @@ impl ExprCollector<'_> {
187187 {
188188 let is_mutable =
189189 self_param. mut_token ( ) . is_some ( ) && self_param. amp_token ( ) . is_none ( ) ;
190- let binding_id: la_arena:: Idx < Binding > =
191- self . alloc_binding ( name ! [ self ] , BindingAnnotation :: new ( is_mutable, false ) ) ;
190+ let binding_id: la_arena:: Idx < Binding > = self . alloc_binding (
191+ Name :: new_symbol_root ( sym:: self_) ,
192+ BindingAnnotation :: new ( is_mutable, false ) ,
193+ ) ;
192194 self . body . self_param = Some ( binding_id) ;
193195 self . source_map . self_param = Some ( self . expander . in_file ( AstPtr :: new ( & self_param) ) ) ;
194196 }
@@ -1588,18 +1590,22 @@ impl ExprCollector<'_> {
15881590 } ) ;
15891591 let mut mappings = vec ! [ ] ;
15901592 let fmt = match template. and_then ( |it| self . expand_macros_to_string ( it) ) {
1591- Some ( ( s, is_direct_literal) ) => format_args:: parse (
1592- & s,
1593- fmt_snippet,
1594- args,
1595- is_direct_literal,
1596- |name| self . alloc_expr_desugared ( Expr :: Path ( Path :: from ( name) ) ) ,
1597- |name, span| {
1598- if let Some ( span) = span {
1599- mappings. push ( ( span, name) )
1600- }
1601- } ,
1602- ) ,
1593+ Some ( ( s, is_direct_literal) ) => {
1594+ let call_ctx = self . expander . syntax_context ( ) ;
1595+ format_args:: parse (
1596+ & s,
1597+ fmt_snippet,
1598+ args,
1599+ is_direct_literal,
1600+ |name| self . alloc_expr_desugared ( Expr :: Path ( Path :: from ( name) ) ) ,
1601+ |name, span| {
1602+ if let Some ( span) = span {
1603+ mappings. push ( ( span, name) )
1604+ }
1605+ } ,
1606+ call_ctx,
1607+ )
1608+ }
16031609 None => FormatArgs {
16041610 template : Default :: default ( ) ,
16051611 arguments : args. finish ( ) ,
@@ -1723,14 +1729,18 @@ impl ExprCollector<'_> {
17231729 // unsafe { ::core::fmt::UnsafeArg::new() }
17241730 // )
17251731
1726- let Some ( new_v1_formatted) =
1727- LangItem :: FormatArguments . ty_rel_path ( self . db , self . krate , name ! [ new_v1_formatted] )
1728- else {
1732+ let Some ( new_v1_formatted) = LangItem :: FormatArguments . ty_rel_path (
1733+ self . db ,
1734+ self . krate ,
1735+ Name :: new_symbol_root ( sym:: new_v1_formatted) ,
1736+ ) else {
17291737 return self . missing_expr ( ) ;
17301738 } ;
1731- let Some ( unsafe_arg_new) =
1732- LangItem :: FormatUnsafeArg . ty_rel_path ( self . db , self . krate , name ! [ new] )
1733- else {
1739+ let Some ( unsafe_arg_new) = LangItem :: FormatUnsafeArg . ty_rel_path (
1740+ self . db ,
1741+ self . krate ,
1742+ Name :: new_symbol_root ( sym:: new) ,
1743+ ) else {
17341744 return self . missing_expr ( ) ;
17351745 } ;
17361746 let new_v1_formatted = self . alloc_expr_desugared ( Expr :: Path ( new_v1_formatted) ) ;
@@ -1812,10 +1822,10 @@ impl ExprCollector<'_> {
18121822 self . db ,
18131823 self . krate ,
18141824 match alignment {
1815- Some ( FormatAlignment :: Left ) => name ! [ Left ] ,
1816- Some ( FormatAlignment :: Right ) => name ! [ Right ] ,
1817- Some ( FormatAlignment :: Center ) => name ! [ Center ] ,
1818- None => name ! [ Unknown ] ,
1825+ Some ( FormatAlignment :: Left ) => Name :: new_symbol_root ( sym :: Left ) ,
1826+ Some ( FormatAlignment :: Right ) => Name :: new_symbol_root ( sym :: Right ) ,
1827+ Some ( FormatAlignment :: Center ) => Name :: new_symbol_root ( sym :: Center ) ,
1828+ None => Name :: new_symbol_root ( sym :: Unknown ) ,
18191829 } ,
18201830 ) ;
18211831 match align {
@@ -1838,8 +1848,11 @@ impl ExprCollector<'_> {
18381848 let width = self . make_count ( width, argmap) ;
18391849
18401850 let format_placeholder_new = {
1841- let format_placeholder_new =
1842- LangItem :: FormatPlaceholder . ty_rel_path ( self . db , self . krate , name ! [ new] ) ;
1851+ let format_placeholder_new = LangItem :: FormatPlaceholder . ty_rel_path (
1852+ self . db ,
1853+ self . krate ,
1854+ Name :: new_symbol_root ( sym:: new) ,
1855+ ) ;
18431856 match format_placeholder_new {
18441857 Some ( path) => self . alloc_expr_desugared ( Expr :: Path ( path) ) ,
18451858 None => self . missing_expr ( ) ,
@@ -1883,11 +1896,14 @@ impl ExprCollector<'_> {
18831896 * n as u128 ,
18841897 Some ( BuiltinUint :: Usize ) ,
18851898 ) ) ) ;
1886- let count_is =
1887- match LangItem :: FormatCount . ty_rel_path ( self . db , self . krate , name ! [ Is ] ) {
1888- Some ( count_is) => self . alloc_expr_desugared ( Expr :: Path ( count_is) ) ,
1889- None => self . missing_expr ( ) ,
1890- } ;
1899+ let count_is = match LangItem :: FormatCount . ty_rel_path (
1900+ self . db ,
1901+ self . krate ,
1902+ Name :: new_symbol_root ( sym:: Is ) ,
1903+ ) {
1904+ Some ( count_is) => self . alloc_expr_desugared ( Expr :: Path ( count_is) ) ,
1905+ None => self . missing_expr ( ) ,
1906+ } ;
18911907 self . alloc_expr_desugared ( Expr :: Call {
18921908 callee : count_is,
18931909 args : Box :: new ( [ args] ) ,
@@ -1905,7 +1921,7 @@ impl ExprCollector<'_> {
19051921 let count_param = match LangItem :: FormatCount . ty_rel_path (
19061922 self . db ,
19071923 self . krate ,
1908- name ! [ Param ] ,
1924+ Name :: new_symbol_root ( sym :: Param ) ,
19091925 ) {
19101926 Some ( count_param) => self . alloc_expr_desugared ( Expr :: Path ( count_param) ) ,
19111927 None => self . missing_expr ( ) ,
@@ -1921,7 +1937,11 @@ impl ExprCollector<'_> {
19211937 self . missing_expr ( )
19221938 }
19231939 }
1924- None => match LangItem :: FormatCount . ty_rel_path ( self . db , self . krate , name ! [ Implied ] ) {
1940+ None => match LangItem :: FormatCount . ty_rel_path (
1941+ self . db ,
1942+ self . krate ,
1943+ Name :: new_symbol_root ( sym:: Implied ) ,
1944+ ) {
19251945 Some ( count_param) => self . alloc_expr_desugared ( Expr :: Path ( count_param) ) ,
19261946 None => self . missing_expr ( ) ,
19271947 } ,
@@ -1942,18 +1962,18 @@ impl ExprCollector<'_> {
19421962 let new_fn = match LangItem :: FormatArgument . ty_rel_path (
19431963 self . db ,
19441964 self . krate ,
1945- match ty {
1946- Format ( Display ) => name ! [ new_display] ,
1947- Format ( Debug ) => name ! [ new_debug] ,
1948- Format ( LowerExp ) => name ! [ new_lower_exp] ,
1949- Format ( UpperExp ) => name ! [ new_upper_exp] ,
1950- Format ( Octal ) => name ! [ new_octal] ,
1951- Format ( Pointer ) => name ! [ new_pointer] ,
1952- Format ( Binary ) => name ! [ new_binary] ,
1953- Format ( LowerHex ) => name ! [ new_lower_hex] ,
1954- Format ( UpperHex ) => name ! [ new_upper_hex] ,
1955- Usize => name ! [ from_usize] ,
1956- } ,
1965+ Name :: new_symbol_root ( match ty {
1966+ Format ( Display ) => sym :: new_display,
1967+ Format ( Debug ) => sym :: new_debug,
1968+ Format ( LowerExp ) => sym :: new_lower_exp,
1969+ Format ( UpperExp ) => sym :: new_upper_exp,
1970+ Format ( Octal ) => sym :: new_octal,
1971+ Format ( Pointer ) => sym :: new_pointer,
1972+ Format ( Binary ) => sym :: new_binary,
1973+ Format ( LowerHex ) => sym :: new_lower_hex,
1974+ Format ( UpperHex ) => sym :: new_upper_hex,
1975+ Usize => sym :: from_usize,
1976+ } ) ,
19571977 ) {
19581978 Some ( new_fn) => self . alloc_expr_desugared ( Expr :: Path ( new_fn) ) ,
19591979 None => self . missing_expr ( ) ,
0 commit comments