diff options
| author | bors <bors@rust-lang.org> | 2021-01-23 21:13:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-23 21:13:14 +0000 |
| commit | 1279b3b9232e4c44112d98f19cfa8846776d1fe8 (patch) | |
| tree | 2656f7f38ceb24cc242b3f814288924f8e9bc7ac /src | |
| parent | 4d0dd02ee07bddad9136f95c9f7846ebf3eb3fc5 (diff) | |
| parent | ebeb6b8b26f78c2c1a412a2e0e65e2e1f5ebc111 (diff) | |
Auto merge of #81304 - jonas-schievink:rollup-d9kuugm, r=jonas-schievink
Rollup of 15 pull requests Successful merges: - #79841 (More clear documentation for NonNull<T>) - #81072 (PlaceRef::ty: use method call syntax) - #81130 (Edit rustc_middle::dep_graph module documentation) - #81170 (Avoid hash_slice in VecDeque's Hash implementation) - #81243 (mir: Improve size_of handling when arg is unsized) - #81245 (Update cargo) - #81249 (Lower closure prototype after its body.) - #81252 (Add more self-profile info to rustc_resolve) - #81275 (Fix <unknown> queries and add more timing info to render_html) - #81281 (Inline methods of Path and OsString) - #81283 (Note library tracking issue template in tracking issue template.) - #81285 (Remove special casing of rustdoc in rustc_lint) - #81288 (rustdoc: Fix visibility of trait and impl items) - #81298 (replace RefCell with Cell in FnCtxt) - #81301 (Fix small typo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 21 | ||||
| -rw-r--r-- | src/librustdoc/formats/renderer.rs | 36 | ||||
| -rw-r--r-- | src/librustdoc/html/render/mod.rs | 4 | ||||
| -rw-r--r-- | src/librustdoc/json/mod.rs | 4 | ||||
| -rw-r--r-- | src/librustdoc/lib.rs | 2 | ||||
| -rw-r--r-- | src/test/rustdoc/visibility.rs | 32 | ||||
| -rw-r--r-- | src/test/ui/closures/local-type-mix.rs | 17 | ||||
| -rw-r--r-- | src/test/ui/closures/local-type-mix.stderr | 51 | ||||
| -rw-r--r-- | src/test/ui/mir/issue-80742.stderr | 34 | ||||
| m--------- | src/tools/cargo | 0 |
10 files changed, 182 insertions, 19 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 8fa60fa7178..a116ed686d9 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1096,7 +1096,10 @@ impl Clean<Item> for hir::TraitItem<'_> { AssocTypeItem(bounds.clean(cx), default.clean(cx)) } }; - Item::from_def_id_and_parts(local_did, Some(self.ident.name), inner, cx) + let what_rustc_thinks = + Item::from_def_id_and_parts(local_did, Some(self.ident.name), inner, cx); + // Trait items always inherit the trait's visibility -- we don't want to show `pub`. + Item { visibility: Inherited, ..what_rustc_thinks } }) } } @@ -1131,7 +1134,21 @@ impl Clean<Item> for hir::ImplItem<'_> { ) } }; - Item::from_def_id_and_parts(local_did, Some(self.ident.name), inner, cx) + + let what_rustc_thinks = + Item::from_def_id_and_parts(local_did, Some(self.ident.name), inner, cx); + let parent_item = cx.tcx.hir().expect_item(cx.tcx.hir().get_parent_item(self.hir_id)); + if let hir::ItemKind::Impl(impl_) = &parent_item.kind { + if impl_.of_trait.is_some() { + // Trait impl items always inherit the impl's visibility -- + // we don't want to show `pub`. + Item { visibility: Inherited, ..what_rustc_thinks } + } else { + what_rustc_thinks + } + } else { + panic!("found impl item with non-impl parent {:?}", parent_item); + } }) } } diff --git a/src/librustdoc/formats/renderer.rs b/src/librustdoc/formats/renderer.rs index 5c0f5e50c9e..6941fa064ec 100644 --- a/src/librustdoc/formats/renderer.rs +++ b/src/librustdoc/formats/renderer.rs @@ -12,6 +12,9 @@ use crate::formats::cache::{Cache, CACHE_KEY}; /// backend renderer has hooks for initialization, documenting an item, entering and exiting a /// module, and cleanup/finalizing output. crate trait FormatRenderer<'tcx>: Clone { + /// Gives a description of the renderer. Used for performance profiling. + fn descr() -> &'static str; + /// Sets up any state required for the renderer. When this is called the cache has already been /// populated. fn init( @@ -57,16 +60,20 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>( edition: Edition, tcx: TyCtxt<'tcx>, ) -> Result<(), Error> { - let (krate, mut cache) = Cache::from_krate( - render_info.clone(), - options.document_private, - &options.extern_html_root_urls, - &options.output, - krate, - ); - - let (mut format_renderer, mut krate) = - T::init(krate, options, render_info, edition, &mut cache, tcx)?; + let (krate, mut cache) = tcx.sess.time("create_format_cache", || { + Cache::from_krate( + render_info.clone(), + options.document_private, + &options.extern_html_root_urls, + &options.output, + krate, + ) + }); + let prof = &tcx.sess.prof; + + let (mut format_renderer, mut krate) = prof + .extra_verbose_generic_activity("create_renderer", T::descr()) + .run(|| T::init(krate, options, render_info, edition, &mut cache, tcx))?; let cache = Arc::new(cache); // Freeze the cache now that the index has been built. Put an Arc into TLS for future @@ -83,6 +90,7 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>( // Render the crate documentation let mut work = vec![(format_renderer.clone(), item)]; + let unknown = rustc_span::Symbol::intern("<unknown item>"); while let Some((mut cx, item)) = work.pop() { if item.is_mod() { // modules are special because they add a namespace. We also need to @@ -91,6 +99,7 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>( if name.is_empty() { panic!("Unexpected module with empty name"); } + let _timer = prof.generic_activity_with_arg("render_mod_item", name.as_str()); cx.mod_item_in(&item, &name, &cache)?; let module = match *item.kind { @@ -104,9 +113,10 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>( cx.mod_item_out(&name)?; } else if item.name.is_some() { - cx.item(item, &cache)?; + prof.generic_activity_with_arg("render_item", &*item.name.unwrap_or(unknown).as_str()) + .run(|| cx.item(item, &cache))?; } } - - format_renderer.after_krate(&krate, &cache, diag) + prof.extra_verbose_generic_activity("renderer_after_krate", T::descr()) + .run(|| format_renderer.after_krate(&krate, &cache, diag)) } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 6167b75ee50..8e010839ad8 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -383,6 +383,10 @@ crate fn initial_ids() -> Vec<String> { /// Generates the documentation for `crate` into the directory `dst` impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { + fn descr() -> &'static str { + "html" + } + fn init( mut krate: clean::Crate, options: RenderOptions, diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index dc50c8a76b2..512c9124727 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -125,6 +125,10 @@ impl JsonRenderer<'_> { } impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { + fn descr() -> &'static str { + "json" + } + fn init( krate: clean::Crate, options: RenderOptions, diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index d17189b416d..83736295beb 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -540,7 +540,7 @@ fn main_options(options: config::Options) -> MainResult { sess.fatal("Compilation failed, aborting rustdoc"); } - let mut global_ctxt = abort_on_err(queries.global_ctxt(), sess).take(); + let mut global_ctxt = abort_on_err(queries.global_ctxt(), sess).peek_mut(); global_ctxt.enter(|tcx| { let (mut krate, render_info, render_opts) = sess.time("run_global_ctxt", || { diff --git a/src/test/rustdoc/visibility.rs b/src/test/rustdoc/visibility.rs index 59427693c5a..beb638406c4 100644 --- a/src/test/rustdoc/visibility.rs +++ b/src/test/rustdoc/visibility.rs @@ -42,3 +42,35 @@ mod a { struct FooBPriv; } } + +// @has 'foo/trait.PubTrait.html' '//pre' 'pub trait PubTrait' +// +// @has 'foo/trait.PubTrait.html' '//pre' 'type Type;' +// @!has 'foo/trait.PubTrait.html' '//pre' 'pub type Type;' +// +// @has 'foo/trait.PubTrait.html' '//pre' 'const CONST: usize;' +// @!has 'foo/trait.PubTrait.html' '//pre' 'pub const CONST: usize;' +// +// @has 'foo/trait.PubTrait.html' '//pre' 'fn function();' +// @!has 'foo/trait.PubTrait.html' '//pre' 'pub fn function();' + +pub trait PubTrait { + type Type; + const CONST: usize; + fn function(); +} + +// @has 'foo/struct.FooPublic.html' '//code' 'type Type' +// @!has 'foo/struct.FooPublic.html' '//code' 'pub type Type' +// +// @has 'foo/struct.FooPublic.html' '//code' 'const CONST: usize' +// @!has 'foo/struct.FooPublic.html' '//code' 'pub const CONST: usize' +// +// @has 'foo/struct.FooPublic.html' '//code' 'fn function()' +// @!has 'foo/struct.FooPublic.html' '//code' 'pub fn function()' + +impl PubTrait for FooPublic { + type Type = usize; + const CONST: usize = 0; + fn function() {} +} diff --git a/src/test/ui/closures/local-type-mix.rs b/src/test/ui/closures/local-type-mix.rs new file mode 100644 index 00000000000..006e6f490f0 --- /dev/null +++ b/src/test/ui/closures/local-type-mix.rs @@ -0,0 +1,17 @@ +// Check that using the parameter name in its type does not ICE. +// edition:2018 + +#![feature(async_closure)] + +fn main() { + let _ = |x: x| x; //~ ERROR expected type + let _ = |x: bool| -> x { x }; //~ ERROR expected type + let _ = async move |x: x| x; //~ ERROR expected type + let _ = async move |x: bool| -> x { x }; //~ ERROR expected type +} + +fn foo(x: x) {} //~ ERROR expected type +fn foo_ret(x: bool) -> x {} //~ ERROR expected type + +async fn async_foo(x: x) {} //~ ERROR expected type +async fn async_foo_ret(x: bool) -> x {} //~ ERROR expected type diff --git a/src/test/ui/closures/local-type-mix.stderr b/src/test/ui/closures/local-type-mix.stderr new file mode 100644 index 00000000000..68c320a065d --- /dev/null +++ b/src/test/ui/closures/local-type-mix.stderr @@ -0,0 +1,51 @@ +error[E0573]: expected type, found local variable `x` + --> $DIR/local-type-mix.rs:7:17 + | +LL | let _ = |x: x| x; + | ^ not a type + +error[E0573]: expected type, found local variable `x` + --> $DIR/local-type-mix.rs:8:26 + | +LL | let _ = |x: bool| -> x { x }; + | ^ not a type + +error[E0573]: expected type, found local variable `x` + --> $DIR/local-type-mix.rs:9:28 + | +LL | let _ = async move |x: x| x; + | ^ not a type + +error[E0573]: expected type, found local variable `x` + --> $DIR/local-type-mix.rs:10:37 + | +LL | let _ = async move |x: bool| -> x { x }; + | ^ not a type + +error[E0573]: expected type, found local variable `x` + --> $DIR/local-type-mix.rs:13:11 + | +LL | fn foo(x: x) {} + | ^ not a type + +error[E0573]: expected type, found local variable `x` + --> $DIR/local-type-mix.rs:14:24 + | +LL | fn foo_ret(x: bool) -> x {} + | ^ not a type + +error[E0573]: expected type, found local variable `x` + --> $DIR/local-type-mix.rs:16:23 + | +LL | async fn async_foo(x: x) {} + | ^ not a type + +error[E0573]: expected type, found local variable `x` + --> $DIR/local-type-mix.rs:17:36 + | +LL | async fn async_foo_ret(x: bool) -> x {} + | ^ not a type + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0573`. diff --git a/src/test/ui/mir/issue-80742.stderr b/src/test/ui/mir/issue-80742.stderr index 2ec0e950528..26f9c786ba1 100644 --- a/src/test/ui/mir/issue-80742.stderr +++ b/src/test/ui/mir/issue-80742.stderr @@ -1,3 +1,17 @@ +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + | +LL | intrinsics::size_of::<T>() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | size_of called on unsized type `dyn Debug` + | inside `std::mem::size_of::<dyn Debug>` at $SRC_DIR/core/src/mem/mod.rs:LL:COL + | + ::: $DIR/issue-80742.rs:23:10 + | +LL | [u8; size_of::<T>() + 1]: , + | -------------- inside `Inline::<dyn Debug>::{constant#0}` at $DIR/issue-80742.rs:23:10 + error[E0599]: no function or associated item named `new` found for struct `Inline<dyn Debug>` in the current scope --> $DIR/issue-80742.rs:31:36 | @@ -21,6 +35,20 @@ LL | pub trait Debug { = note: the method `new` exists but the following trait bounds were not satisfied: `dyn Debug: Sized` +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + | +LL | intrinsics::size_of::<T>() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | size_of called on unsized type `dyn Debug` + | inside `std::mem::size_of::<dyn Debug>` at $SRC_DIR/core/src/mem/mod.rs:LL:COL + | + ::: $DIR/issue-80742.rs:15:10 + | +LL | [u8; size_of::<T>() + 1]: , + | -------------- inside `Inline::<dyn Debug>::{constant#0}` at $DIR/issue-80742.rs:15:10 + error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time --> $DIR/issue-80742.rs:31:15 | @@ -36,7 +64,7 @@ help: consider relaxing the implicit `Sized` restriction LL | struct Inline<T: ?Sized> | ^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 4 previous errors -Some errors have detailed explanations: E0277, E0599. -For more information about an error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0080, E0277, E0599. +For more information about an error, try `rustc --explain E0080`. diff --git a/src/tools/cargo b/src/tools/cargo -Subproject a73e5b7d567c3036b296fc6b33ed52c5edcd882 +Subproject 783bc43c660bf39c1e562c8c429b32078ad3099 |
