@@ -26,12 +26,13 @@ use crate::formats::item_type::ItemType;
2626use crate :: formats:: { AssocItemRender , Impl , RenderMode } ;
2727use crate :: html:: escape:: Escape ;
2828use crate :: html:: format:: {
29- join_with_double_colon, join_with_slash , print_abi_with_space, print_constness_with_space,
30- print_where_clause , Buffer , PrintWithSpace ,
29+ join_with_double_colon, print_abi_with_space, print_constness_with_space, print_where_clause ,
30+ Buffer , PrintWithSpace ,
3131} ;
3232use crate :: html:: highlight;
3333use crate :: html:: layout:: Page ;
3434use crate :: html:: markdown:: { HeadingOffset , MarkdownSummaryLine } ;
35+ use crate :: html:: url_parts_builder:: UrlPartsBuilder ;
3536
3637use askama:: Template ;
3738
@@ -854,20 +855,21 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
854855 }
855856 }
856857
858+ let mut js_src_path: UrlPartsBuilder = std:: iter:: repeat ( ".." )
859+ . take ( cx. current . len ( ) )
860+ . chain ( std:: iter:: once ( "implementors" ) )
861+ . collect ( ) ;
862+ if it. def_id . is_local ( ) {
863+ js_src_path. extend ( cx. current . iter ( ) . copied ( ) ) ;
864+ } else {
865+ let ( ref path, _) = cache. external_paths [ & it. def_id . expect_def_id ( ) ] ;
866+ js_src_path. extend ( path[ ..path. len ( ) - 1 ] . iter ( ) . copied ( ) ) ;
867+ }
868+ js_src_path. push_fmt ( format_args ! ( "{}.{}.js" , it. type_( ) , it. name. unwrap( ) ) ) ;
857869 write ! (
858870 w,
859- "<script type=\" text/javascript\" \
860- src=\" {root_path}/implementors/{path}/{ty}.{name}.js\" async>\
861- </script>",
862- root_path = vec![ ".." ; cx. current. len( ) ] . join( "/" ) ,
863- path = if it. def_id. is_local( ) {
864- join_with_slash( None , & cx. current)
865- } else {
866- let ( ref path, _) = cache. external_paths[ & it. def_id. expect_def_id( ) ] ;
867- join_with_slash( None , & path[ ..path. len( ) - 1 ] )
868- } ,
869- ty = it. type_( ) ,
870- name = it. name. unwrap( )
871+ "<script type=\" text/javascript\" src=\" {src}\" async></script>" ,
872+ src = js_src_path. finish( ) ,
871873 ) ;
872874}
873875
0 commit comments