File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -723,6 +723,11 @@ mod test {
723723 // with or without slash
724724 assert_redirect ( "/proc-macro" , target, web) ?;
725725 assert_redirect ( "/proc-macro/" , target, web) ?;
726+
727+ let target = "https://doc.rust-lang.org/nightly/nightly-rustc/" ;
728+ // with or without slash
729+ assert_redirect ( "/rustc" , target, web) ?;
730+ assert_redirect ( "/rustc/" , target, web) ?;
726731 Ok ( ( ) )
727732 } )
728733 }
Original file line number Diff line number Diff line change @@ -157,13 +157,18 @@ pub(super) fn build_routes() -> Routes {
157157 for redirect in DOC_RUST_LANG_ORG_REDIRECTS {
158158 routes. internal_page (
159159 & format ! ( "/{}" , redirect) ,
160- super :: rustdoc:: RustLangRedirector :: new ( redirect) ,
160+ super :: rustdoc:: RustLangRedirector :: new ( "stable" , redirect) ,
161161 ) ;
162162 }
163163 // redirect proc-macro to proc_macro
164164 routes. internal_page (
165165 "/proc-macro" ,
166- super :: rustdoc:: RustLangRedirector :: new ( "proc_macro" ) ,
166+ super :: rustdoc:: RustLangRedirector :: new ( "stable" , "proc_macro" ) ,
167+ ) ;
168+ // redirect rustc to nightly rustc docs
169+ routes. internal_page (
170+ "/rustc" ,
171+ super :: rustdoc:: RustLangRedirector :: new ( "nightly" , "nightly-rustc" ) ,
167172 ) ;
168173
169174 routes
Original file line number Diff line number Diff line change @@ -27,11 +27,10 @@ pub struct RustLangRedirector {
2727}
2828
2929impl RustLangRedirector {
30- pub fn new ( target : & ' static str ) -> Self {
31- let url = iron:: url:: Url :: parse ( "https://doc.rust-lang.org/stable/" )
32- . expect ( "failed to parse rust-lang.org base URL" )
33- . join ( target)
34- . expect ( "failed to append crate name to rust-lang.org base URL" ) ;
30+ pub fn new ( version : & str , target : & str ) -> Self {
31+ let url =
32+ iron:: url:: Url :: parse ( & format ! ( "https://doc.rust-lang.org/{}/{}" , version, target) )
33+ . expect ( "failed to parse rust-lang.org doc URL" ) ;
3534 let url = Url :: from_generic_url ( url) . expect ( "failed to convert url::Url to iron::Url" ) ;
3635
3736 Self { url }
You can’t perform that action at this time.
0 commit comments