From 1bf9f69579e525a35fd712b7f00f2f24eebc6387 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 14 Jan 2020 19:21:10 +0100 Subject: [PATCH 1/8] Prevent urls in headings --- src/librustdoc/html/markdown.rs | 8 ++++++-- src/test/rustdoc/remove-url-from-headings.rs | 12 ++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/test/rustdoc/remove-url-from-headings.rs diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index c5f88f9f7f421..b2f5c8e81ff7e 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -380,7 +380,11 @@ impl<'a, 'b, 'ids, I: Iterator>> Iterator for HeadingLinks<'a, } _ => {} } - self.buf.push_back(event); + match event { + Event::Start(Tag::Link(_, _, text)) => self.buf.push_back(Event::Text(text)), + Event::End(Tag::Link(..)) => {} + event => self.buf.push_back(event), + } } let id = self.id_map.derive(id); @@ -395,7 +399,7 @@ impl<'a, 'b, 'ids, I: Iterator>> Iterator for HeadingLinks<'a, let start_tags = format!( "\ - ", + ", id = id, level = level ); diff --git a/src/test/rustdoc/remove-url-from-headings.rs b/src/test/rustdoc/remove-url-from-headings.rs new file mode 100644 index 0000000000000..7fbcdbafa7486 --- /dev/null +++ b/src/test/rustdoc/remove-url-from-headings.rs @@ -0,0 +1,12 @@ +#![crate_name = "foo"] + +// @has foo/fn.foo.html +// !@has - '//a[@href="http://a.a"]' +// @has - '//a[@href="#implementing-stuff-somewhere"]' 'Implementing stuff somewhere' + +/// fooo +/// +/// # Implementing [stuff](http://a.a) somewhere +/// +/// hello +pub fn foo() {} From 0e6a941820dcb39f5abab156e423cf3e28970c9f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 16 Jan 2020 14:19:37 +0100 Subject: [PATCH 2/8] Don't keep link title either, text is generated outside of the link tag --- src/librustdoc/html/markdown.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index b2f5c8e81ff7e..c87964af0200c 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -381,8 +381,7 @@ impl<'a, 'b, 'ids, I: Iterator>> Iterator for HeadingLinks<'a, _ => {} } match event { - Event::Start(Tag::Link(_, _, text)) => self.buf.push_back(Event::Text(text)), - Event::End(Tag::Link(..)) => {} + Event::Start(Tag::Link(_, _, _)) | Event::End(Tag::Link(..)) => {} event => self.buf.push_back(event), } } From 5022dd3b854792dd72d396e1586aa5b5c09975b2 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 16 Jan 2020 14:26:43 +0100 Subject: [PATCH 3/8] Extend url in titles test --- src/test/rustdoc/remove-url-from-headings.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/rustdoc/remove-url-from-headings.rs b/src/test/rustdoc/remove-url-from-headings.rs index 7fbcdbafa7486..50e45a7f53a1e 100644 --- a/src/test/rustdoc/remove-url-from-headings.rs +++ b/src/test/rustdoc/remove-url-from-headings.rs @@ -3,10 +3,15 @@ // @has foo/fn.foo.html // !@has - '//a[@href="http://a.a"]' // @has - '//a[@href="#implementing-stuff-somewhere"]' 'Implementing stuff somewhere' +// @has - '//a[@href="#another-one-urg"]' 'Another one urg' /// fooo /// /// # Implementing [stuff](http://a.a) somewhere /// /// hello +/// +/// # Another [one][two] urg +/// +/// [two]: http://a.a pub fn foo() {} From 298e8ad5dc79ecb9b5b6140499e950d6ac5f09b1 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 17 Jan 2020 19:49:03 +0100 Subject: [PATCH 4/8] Extend url in heading test a bit --- src/test/rustdoc/remove-url-from-headings.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/rustdoc/remove-url-from-headings.rs b/src/test/rustdoc/remove-url-from-headings.rs index 50e45a7f53a1e..9761c1ddbe23f 100644 --- a/src/test/rustdoc/remove-url-from-headings.rs +++ b/src/test/rustdoc/remove-url-from-headings.rs @@ -7,7 +7,7 @@ /// fooo /// -/// # Implementing [stuff](http://a.a) somewhere +/// # Implementing [stuff](http://a.a "title") somewhere /// /// hello /// From af6282f92a6d4dd9c556535fc40b4b04f531b8a5 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sat, 18 Jan 2020 13:33:17 +0100 Subject: [PATCH 5/8] Fix table of syscalls in docs of std::time::Instant. --- src/libstd/time.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 0b6e728dceb1d..2e3e3b743a49f 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -65,7 +65,7 @@ pub use core::time::Duration; /// /// | Platform | System call | /// |:---------:|:--------------------------------------------------------------------:| -/// | Cloud ABI | [clock_time_get (Monotonic Clock)] | +/// | CloudABI | [clock_time_get (Monotonic Clock)] | /// | SGX | [`insecure_time` usercall]. More information on [timekeeping in SGX] | /// | UNIX | [clock_gettime (Monotonic Clock)] | /// | Darwin | [mach_absolute_time] | @@ -79,7 +79,7 @@ pub use core::time::Duration; /// [__wasi_clock_time_get (Monotonic Clock)]: https://github.com/CraneStation/wasmtime/blob/master/docs/WASI-api.md#clock_time_get /// [clock_gettime (Monotonic Clock)]: https://linux.die.net/man/3/clock_gettime /// [mach_absolute_time]: https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/services/services.html -/// [clock_time_get (Monotonic Clock)]: https://github.com/NuxiNL/cloudabi/blob/master/cloudabi.txt +/// [clock_time_get (Monotonic Clock)]: https://nuxi.nl/cloudabi/#clock_time_get /// /// **Disclaimer:** These system calls might change over time. /// From 366f619a49162588770af9f23099ca9407d1992a Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sat, 18 Jan 2020 13:33:17 +0100 Subject: [PATCH 6/8] Fix table of syscalls in docs of std::time::SystemTime. --- src/libstd/time.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 2e3e3b743a49f..5bc8fe5ae6d79 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -144,7 +144,7 @@ pub struct Instant(time::Instant); /// /// | Platform | System call | /// |:---------:|:--------------------------------------------------------------------:| -/// | Cloud ABI | [clock_time_get (Realtime Clock)] | +/// | CloudABI | [clock_time_get (Realtime Clock)] | /// | SGX | [`insecure_time` usercall]. More information on [timekeeping in SGX] | /// | UNIX | [clock_gettime (Realtime Clock)] | /// | DARWIN | [gettimeofday] | @@ -152,7 +152,7 @@ pub struct Instant(time::Instant); /// | WASI | [__wasi_clock_time_get (Realtime Clock)] | /// | Windows | [GetSystemTimeAsFileTime] | /// -/// [clock_time_get (Realtime Clock)]: https://github.com/NuxiNL/cloudabi/blob/master/cloudabi.txt +/// [clock_time_get (Realtime Clock)]: https://nuxi.nl/cloudabi/#clock_time_get /// [`insecure_time` usercall]: https://edp.fortanix.com/docs/api/fortanix_sgx_abi/struct.Usercalls.html#method.insecure_time /// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode /// [gettimeofday]: http://man7.org/linux/man-pages/man2/gettimeofday.2.html From 6b7f3e50df3b4235756df9354ea90cf821460a8b Mon Sep 17 00:00:00 2001 From: lcnr/Bastian Kauschke Date: Sat, 18 Jan 2020 14:43:08 +0100 Subject: [PATCH 7/8] improve type_name_of_val docs --- src/libcore/any.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 7935c9b1b392d..c5dcdfed12ae0 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -476,11 +476,15 @@ pub const fn type_name() -> &'static str { /// /// This is intended for diagnostic use. The exact contents and format of the /// string are not specified, other than being a best-effort description of the -/// type. For example, `type_name_of::>(None)` could return +/// type. For example, `type_name_of_val::>(None)` could return /// `"Option"` or `"std::option::Option"`, but not /// `"foobar"`. In addition, the output may change between versions of the /// compiler. /// +/// This function does not resolve trait objects, +/// meaning that `type_name_of_val(&7u32 as &dyn Debug)` +/// may return `"dyn Debug"`, but not `"u32"`. +/// /// The type name should not be considered a unique identifier of a type; /// multiple types may share the same type name. /// From 9746b05da995629780f559e68cde2a3d41b3b2bc Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 18 Jan 2020 13:12:30 +0100 Subject: [PATCH 8/8] clean up e0200 explanation --- src/librustc_error_codes/error_codes/E0200.md | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0200.md b/src/librustc_error_codes/error_codes/E0200.md index 865e91430ac44..7245bb59ce5ff 100644 --- a/src/librustc_error_codes/error_codes/E0200.md +++ b/src/librustc_error_codes/error_codes/E0200.md @@ -1,14 +1,23 @@ +An unsafe trait was implemented without an unsafe implementation. + +Erroneous code example: + +```compile_fail,E0200 +struct Foo; + +unsafe trait Bar { } + +impl Bar for Foo { } // error! +``` + Unsafe traits must have unsafe implementations. This error occurs when an implementation for an unsafe trait isn't marked as unsafe. This may be resolved by marking the unsafe implementation as unsafe. -```compile_fail,E0200 +``` struct Foo; unsafe trait Bar { } -// this won't compile because Bar is unsafe and impl isn't unsafe -impl Bar for Foo { } -// this will compile -unsafe impl Bar for Foo { } +unsafe impl Bar for Foo { } // ok! ```