File tree 3 files changed +16
-4
lines changed
3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -723,6 +723,11 @@ mod test {
723
723
// with or without slash
724
724
assert_redirect ( "/proc-macro" , target, web) ?;
725
725
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) ?;
726
731
Ok ( ( ) )
727
732
} )
728
733
}
Original file line number Diff line number Diff line change @@ -157,13 +157,18 @@ pub(super) fn build_routes() -> Routes {
157
157
for redirect in DOC_RUST_LANG_ORG_REDIRECTS {
158
158
routes. internal_page (
159
159
& format ! ( "/{}" , redirect) ,
160
- super :: rustdoc:: RustLangRedirector :: new ( redirect) ,
160
+ super :: rustdoc:: RustLangRedirector :: new ( "stable" , redirect) ,
161
161
) ;
162
162
}
163
163
// redirect proc-macro to proc_macro
164
164
routes. internal_page (
165
165
"/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" ) ,
167
172
) ;
168
173
169
174
routes
Original file line number Diff line number Diff line change @@ -27,9 +27,11 @@ pub struct RustLangRedirector {
27
27
}
28
28
29
29
impl RustLangRedirector {
30
- pub fn new ( target : & ' static str ) -> Self {
31
- let url = iron:: url:: Url :: parse ( "https://doc.rust-lang.org/stable/ " )
30
+ pub fn new ( version : & str , target : & str ) -> Self {
31
+ let url = iron:: url:: Url :: parse ( "https://doc.rust-lang.org/" )
32
32
. expect ( "failed to parse rust-lang.org base URL" )
33
+ . join ( version)
34
+ . expect ( "failed to append Rust version to rust-lang.org base URL" )
33
35
. join ( target)
34
36
. expect ( "failed to append crate name to rust-lang.org base URL" ) ;
35
37
let url = Url :: from_generic_url ( url) . expect ( "failed to convert url::Url to iron::Url" ) ;
You can’t perform that action at this time.
0 commit comments