diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/html/render/mod.rs | 9 | ||||
| -rw-r--r-- | src/librustdoc/html/static/main.js | 16 | ||||
| -rw-r--r-- | src/librustdoc/html/static/themes/ayu.css | 7 | ||||
| -rw-r--r-- | src/librustdoc/html/static/themes/dark.css | 4 | ||||
| -rw-r--r-- | src/librustdoc/html/static/themes/light.css | 4 | ||||
| -rw-r--r-- | src/test/ui/proc-macro/auxiliary/api/cmp.rs | 21 | ||||
| -rw-r--r-- | src/test/ui/proc-macro/auxiliary/api/mod.rs | 24 | ||||
| -rw-r--r-- | src/test/ui/proc-macro/auxiliary/api/parse.rs | 23 | ||||
| -rw-r--r-- | src/test/ui/proc-macro/test.rs | 12 |
9 files changed, 96 insertions, 24 deletions
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index a288b43722a..318e1b44f86 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1352,8 +1352,11 @@ fn render_impl( } let w = if short_documented && trait_.is_some() { interesting } else { boring }; - if !doc_buffer.is_empty() { - w.write_str("<details class=\"rustdoc-toggle\" open><summary>"); + let toggled = !doc_buffer.is_empty(); + if toggled { + let method_toggle_class = + if item_type == ItemType::Method { " method-toggle" } else { "" }; + write!(w, "<details class=\"rustdoc-toggle{}\" open><summary>", method_toggle_class); } match *item.kind { clean::MethodItem(..) | clean::TyMethodItem(_) => { @@ -1453,7 +1456,7 @@ fn render_impl( } w.push_buffer(info_buffer); - if !doc_buffer.is_empty() { + if toggled { w.write_str("</summary>"); w.push_buffer(doc_buffer); w.push_str("</details>"); diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 7c00cf940c7..82049492672 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -924,24 +924,16 @@ function hideThemeButtonState() { }); } - if (hideMethodDocs) { - onEachLazy(document.getElementsByClassName("method"), function(e) { - var toggle = e.parentNode; - if (toggle) { - toggle = toggle.parentNode; - } - if (toggle && toggle.tagName === "DETAILS") { - toggle.open = false; - } - }); - } - onEachLazy(document.getElementsByTagName("details"), function (e) { var showLargeItem = !hideLargeItemContents && hasClass(e, "type-contents-toggle"); var showImplementor = !hideImplementors && hasClass(e, "implementors-toggle"); if (showLargeItem || showImplementor) { e.open = true; } + if (hideMethodDocs && hasClass(e, "method-toggle")) { + e.open = false; + } + }); var currentType = document.getElementsByClassName("type-decl")[0]; diff --git a/src/librustdoc/html/static/themes/ayu.css b/src/librustdoc/html/static/themes/ayu.css index 989ea7140c5..e59909ffdf0 100644 --- a/src/librustdoc/html/static/themes/ayu.css +++ b/src/librustdoc/html/static/themes/ayu.css @@ -151,17 +151,14 @@ pre, .rustdoc.source .example-wrap { color: #c5c5c5; } -.content a:hover { +.search-results a:hover { background-color: #777; } -.content a:focus { +.search-results a:focus { color: #000 !important; background-color: #c6afb3; } -.content a:focus { - color: #000 !important; -} .search-results a { color: #0096cf; } diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index e6bd16ddd11..a2bcb43f44e 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -109,11 +109,11 @@ pre, .rustdoc.source .example-wrap { color: #ddd; } -.content a:hover { +.search-results a:hover { background-color: #777; } -.content a:focus { +.search-results a:focus { color: #eee !important; background-color: #616161; } diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css index 5481b348aa2..2ad3551d900 100644 --- a/src/librustdoc/html/static/themes/light.css +++ b/src/librustdoc/html/static/themes/light.css @@ -109,11 +109,11 @@ pre, .rustdoc.source .example-wrap { color: #4E4C4C; } -.content a:hover { +.search-results a:hover { background-color: #ddd; } -.content a:focus { +.search-results a:focus { color: #000 !important; background-color: #ccc; } diff --git a/src/test/ui/proc-macro/auxiliary/api/cmp.rs b/src/test/ui/proc-macro/auxiliary/api/cmp.rs new file mode 100644 index 00000000000..5784a6e5d94 --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/api/cmp.rs @@ -0,0 +1,21 @@ +use proc_macro::{LineColumn, Punct, Spacing}; + +pub fn test() { + test_line_column_ord(); + test_punct_eq(); +} + +fn test_line_column_ord() { + let line0_column0 = LineColumn { line: 0, column: 0 }; + let line0_column1 = LineColumn { line: 0, column: 1 }; + let line1_column0 = LineColumn { line: 1, column: 0 }; + assert!(line0_column0 < line0_column1); + assert!(line0_column1 < line1_column0); +} + +fn test_punct_eq() { + let colon_alone = Punct::new(':', Spacing::Alone); + assert_eq!(colon_alone, ':'); + let colon_joint = Punct::new(':', Spacing::Joint); + assert_eq!(colon_joint, ':'); +} diff --git a/src/test/ui/proc-macro/auxiliary/api/mod.rs b/src/test/ui/proc-macro/auxiliary/api/mod.rs new file mode 100644 index 00000000000..739c25132e7 --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/api/mod.rs @@ -0,0 +1,24 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] +#![crate_name = "proc_macro_api_tests"] +#![feature(proc_macro_span)] +#![deny(dead_code)] // catch if a test function is never called + +extern crate proc_macro; + +mod cmp; +mod parse; + +use proc_macro::TokenStream; + +#[proc_macro] +pub fn run(input: TokenStream) -> TokenStream { + assert!(input.is_empty()); + + cmp::test(); + parse::test(); + + TokenStream::new() +} diff --git a/src/test/ui/proc-macro/auxiliary/api/parse.rs b/src/test/ui/proc-macro/auxiliary/api/parse.rs new file mode 100644 index 00000000000..4105236b7f2 --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/api/parse.rs @@ -0,0 +1,23 @@ +use proc_macro::Literal; + +pub fn test() { + test_parse_literal(); +} + +fn test_parse_literal() { + assert_eq!("1".parse::<Literal>().unwrap().to_string(), "1"); + assert_eq!("1.0".parse::<Literal>().unwrap().to_string(), "1.0"); + assert_eq!("'a'".parse::<Literal>().unwrap().to_string(), "'a'"); + assert_eq!("\"\n\"".parse::<Literal>().unwrap().to_string(), "\"\n\""); + assert_eq!("b\"\"".parse::<Literal>().unwrap().to_string(), "b\"\""); + assert_eq!("r##\"\"##".parse::<Literal>().unwrap().to_string(), "r##\"\"##"); + assert_eq!("10ulong".parse::<Literal>().unwrap().to_string(), "10ulong"); + + assert!("0 1".parse::<Literal>().is_err()); + assert!("'a".parse::<Literal>().is_err()); + assert!(" 0".parse::<Literal>().is_err()); + assert!("0 ".parse::<Literal>().is_err()); + assert!("/* comment */0".parse::<Literal>().is_err()); + assert!("0/* comment */".parse::<Literal>().is_err()); + assert!("0// comment".parse::<Literal>().is_err()); +} diff --git a/src/test/ui/proc-macro/test.rs b/src/test/ui/proc-macro/test.rs new file mode 100644 index 00000000000..c96aa73175f --- /dev/null +++ b/src/test/ui/proc-macro/test.rs @@ -0,0 +1,12 @@ +// check-pass +// aux-build:api/mod.rs + +//! This is for everything that *would* be a #[test] inside of libproc_macro, +//! except for the fact that proc_macro objects are not capable of existing +//! inside of an ordinary Rust test execution, only inside a macro. + +extern crate proc_macro_api_tests; + +proc_macro_api_tests::run!(); + +fn main() {} |
