diff options
| author | bors <bors@rust-lang.org> | 2021-03-24 01:32:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-03-24 01:32:32 +0000 |
| commit | db492ecd5ba6bd82205612cebb9034710653f0c2 (patch) | |
| tree | b7c353ead50b6fac246982ac11529822593427bb /src | |
| parent | 673d0db5e393e9c64897005b470bfeb6d5aec61b (diff) | |
| parent | 5c0d880e4be68c98affee9cc5d40519dcf1e3b7b (diff) | |
| download | rust-db492ecd5ba6bd82205612cebb9034710653f0c2.tar.gz rust-db492ecd5ba6bd82205612cebb9034710653f0c2.zip | |
Auto merge of #83432 - Dylan-DPC:rollup-4z5f6al, r=Dylan-DPC
Rollup of 9 pull requests Successful merges: - #83051 (Sidebar trait items order) - #83313 (Only enable assert_dep_graph when query-dep-graph is enabled.) - #83353 (Add internal io::Error::new_const to avoid allocations.) - #83391 (Allow not emitting `uwtable` on Android) - #83392 (Change `-W help` to display edition level.) - #83393 (Codeblock tooltip position) - #83399 (rustdoc: Record crate name instead of using `None`) - #83405 (Slight visual improvements to warning boxes in the docs) - #83415 (Remove unnecessary `Option` wrapping around `Crate.module`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
29 files changed, 204 insertions, 103 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index e5fe1159928..84210276d35 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -231,7 +231,7 @@ impl Clean<Item> for doctree::Module<'_> { let what_rustc_thinks = Item::from_hir_id_and_parts( self.id, - self.name, + Some(self.name), ModuleItem(Module { is_crate: self.is_crate, items }), cx, ); diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 3dd27933471..142121b7346 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -51,7 +51,7 @@ thread_local!(crate static MAX_DEF_IDX: RefCell<FxHashMap<CrateNum, DefIndex>> = crate struct Crate { crate name: Symbol, crate src: FileName, - crate module: Option<Item>, + crate module: Item, crate externs: Vec<(CrateNum, ExternalCrate)>, crate primitives: Vec<(DefId, PrimitiveType)>, // These are later on moved into `CACHEKEY`, leaving the map empty. diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 6f283d501a4..582cbf69ed1 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -76,7 +76,7 @@ crate fn krate(cx: &mut DocContext<'_>) -> Crate { Crate { name, src, - module: Some(module), + module, externs, primitives, external_traits: cx.external_traits.clone(), diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index c5b5ab0f3d0..5a022b2d40c 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -474,21 +474,19 @@ crate fn run_global_ctxt( let mut krate = tcx.sess.time("clean_crate", || clean::krate(&mut ctxt)); - if let Some(ref m) = krate.module { - if m.doc_value().map(|d| d.is_empty()).unwrap_or(true) { - let help = "The following guide may be of use:\n\ + if krate.module.doc_value().map(|d| d.is_empty()).unwrap_or(true) { + let help = "The following guide may be of use:\n\ https://doc.rust-lang.org/nightly/rustdoc/how-to-write-documentation.html"; - tcx.struct_lint_node( - crate::lint::MISSING_CRATE_LEVEL_DOCS, - DocContext::as_local_hir_id(tcx, m.def_id).unwrap(), - |lint| { - let mut diag = - lint.build("no documentation found for this crate's top-level module"); - diag.help(help); - diag.emit(); - }, - ); - } + tcx.struct_lint_node( + crate::lint::MISSING_CRATE_LEVEL_DOCS, + DocContext::as_local_hir_id(tcx, krate.module.def_id).unwrap(), + |lint| { + let mut diag = + lint.build("no documentation found for this crate's top-level module"); + diag.help(help); + diag.emit(); + }, + ); } fn report_deprecated_attr(name: &str, diag: &rustc_errors::Handler, sp: Span) { @@ -531,7 +529,7 @@ crate fn run_global_ctxt( // Process all of the crate attributes, extracting plugin metadata along // with the passes which we are supposed to run. - for attr in krate.module.as_ref().unwrap().attrs.lists(sym::doc) { + for attr in krate.module.attrs.lists(sym::doc) { let diag = ctxt.sess().diagnostic(); let name = attr.name_or_empty(); diff --git a/src/librustdoc/doctree.rs b/src/librustdoc/doctree.rs index 645b2bb193e..189624c0d80 100644 --- a/src/librustdoc/doctree.rs +++ b/src/librustdoc/doctree.rs @@ -5,7 +5,7 @@ use rustc_span::{self, Span, Symbol}; use rustc_hir as hir; crate struct Module<'hir> { - crate name: Option<Symbol>, + crate name: Symbol, crate where_outer: Span, crate where_inner: Span, crate mods: Vec<Module<'hir>>, @@ -18,7 +18,7 @@ crate struct Module<'hir> { } impl Module<'hir> { - crate fn new(name: Option<Symbol>) -> Module<'hir> { + crate fn new(name: Symbol) -> Module<'hir> { Module { name, id: hir::CRATE_HIR_ID, diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs index 2b980ebe592..376fef6568a 100644 --- a/src/librustdoc/fold.rs +++ b/src/librustdoc/fold.rs @@ -87,7 +87,7 @@ crate trait DocFolder: Sized { } fn fold_crate(&mut self, mut c: Crate) -> Crate { - c.module = c.module.take().and_then(|module| self.fold_item(module)); + c.module = self.fold_item(c.module).unwrap(); { let external_traits = { std::mem::take(&mut *c.external_traits.borrow_mut()) }; diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index 9415caf8b6f..f9a663b38eb 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -182,8 +182,6 @@ impl Cache { self.primitive_locations.insert(prim, def_id); } - self.stack.push(krate.name.to_string()); - krate = CacheBuilder { tcx, cache: self, empty_cache: Cache::default() }.fold_crate(krate); for (trait_did, dids, impl_) in self.orphan_trait_impls.drain(..) { diff --git a/src/librustdoc/formats/renderer.rs b/src/librustdoc/formats/renderer.rs index 9095faf6761..9dcef3a20d6 100644 --- a/src/librustdoc/formats/renderer.rs +++ b/src/librustdoc/formats/renderer.rs @@ -1,5 +1,5 @@ use rustc_middle::ty::TyCtxt; -use rustc_span::edition::Edition; +use rustc_span::{edition::Edition, Symbol}; use crate::clean; use crate::config::RenderOptions; @@ -40,7 +40,7 @@ crate trait FormatRenderer<'tcx>: Sized { /// A handler is available if the renderer wants to report errors. fn after_krate( &mut self, - krate: &clean::Crate, + crate_name: Symbol, diag: &rustc_errors::Handler, ) -> Result<(), Error>; @@ -58,21 +58,15 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>( ) -> Result<(), Error> { let prof = &tcx.sess.prof; - let (mut format_renderer, mut krate) = prof + let (mut format_renderer, krate) = prof .extra_verbose_generic_activity("create_renderer", T::descr()) .run(|| T::init(krate, options, edition, cache, tcx))?; - let mut item = match krate.module.take() { - Some(i) => i, - None => return Ok(()), - }; - - item.name = Some(krate.name); - // Render the crate documentation - let mut work = vec![(format_renderer.make_child_renderer(), item)]; + let crate_name = krate.name; + let mut work = vec![(format_renderer.make_child_renderer(), krate.module)]; - let unknown = rustc_span::Symbol::intern("<unknown item>"); + let unknown = 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 @@ -102,5 +96,5 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>( } } prof.extra_verbose_generic_activity("renderer_after_krate", T::descr()) - .run(|| format_renderer.after_krate(&krate, diag)) + .run(|| format_renderer.after_krate(crate_name, diag)) } diff --git a/src/librustdoc/html/render/cache.rs b/src/librustdoc/html/render/cache.rs index 56fee2c9fec..5d49a494727 100644 --- a/src/librustdoc/html/render/cache.rs +++ b/src/librustdoc/html/render/cache.rs @@ -127,11 +127,8 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt< crate_items.push(&*item); } - let crate_doc = krate - .module - .as_ref() - .map(|module| module.doc_value().map_or_else(String::new, |s| short_markdown_summary(&s))) - .unwrap_or_default(); + let crate_doc = + krate.module.doc_value().map_or_else(String::new, |s| short_markdown_summary(&s)); struct CrateData<'a> { doc: String, diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 05993d8df60..64d413a5f31 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -11,7 +11,7 @@ use rustc_middle::ty::TyCtxt; use rustc_session::Session; use rustc_span::edition::Edition; use rustc_span::source_map::FileName; -use rustc_span::symbol::sym; +use rustc_span::{symbol::sym, Symbol}; use super::cache::{build_index, ExternalLocation}; use super::print_item::{full_path, item_path, print_item}; @@ -343,29 +343,27 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { // Crawl the crate attributes looking for attributes which control how we're // going to emit HTML - if let Some(attrs) = krate.module.as_ref().map(|m| &m.attrs) { - for attr in attrs.lists(sym::doc) { - match (attr.name_or_empty(), attr.value_str()) { - (sym::html_favicon_url, Some(s)) => { - layout.favicon = s.to_string(); - } - (sym::html_logo_url, Some(s)) => { - layout.logo = s.to_string(); - } - (sym::html_playground_url, Some(s)) => { - playground = Some(markdown::Playground { - crate_name: Some(krate.name.to_string()), - url: s.to_string(), - }); - } - (sym::issue_tracker_base_url, Some(s)) => { - issue_tracker_base_url = Some(s.to_string()); - } - (sym::html_no_source, None) if attr.is_word() => { - include_sources = false; - } - _ => {} + for attr in krate.module.attrs.lists(sym::doc) { + match (attr.name_or_empty(), attr.value_str()) { + (sym::html_favicon_url, Some(s)) => { + layout.favicon = s.to_string(); + } + (sym::html_logo_url, Some(s)) => { + layout.logo = s.to_string(); + } + (sym::html_playground_url, Some(s)) => { + playground = Some(markdown::Playground { + crate_name: Some(krate.name.to_string()), + url: s.to_string(), + }); + } + (sym::issue_tracker_base_url, Some(s)) => { + issue_tracker_base_url = Some(s.to_string()); + } + (sym::html_no_source, None) if attr.is_word() => { + include_sources = false; } + _ => {} } } let (sender, receiver) = channel(); @@ -447,12 +445,11 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { fn after_krate( &mut self, - krate: &clean::Crate, + crate_name: Symbol, diag: &rustc_errors::Handler, ) -> Result<(), Error> { - let final_file = self.dst.join(&*krate.name.as_str()).join("all.html"); + let final_file = self.dst.join(&*crate_name.as_str()).join("all.html"); let settings_file = self.dst.join("settings.html"); - let crate_name = krate.name; let mut root_path = self.dst.to_str().expect("invalid path").to_owned(); if !root_path.ends_with('/') { @@ -515,9 +512,9 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { if let Some(ref redirections) = self.shared.redirections { if !redirections.borrow().is_empty() { let redirect_map_path = - self.dst.join(&*krate.name.as_str()).join("redirect-map.json"); + self.dst.join(&*crate_name.as_str()).join("redirect-map.json"); let paths = serde_json::to_string(&*redirections.borrow()).unwrap(); - self.shared.ensure_dir(&self.dst.join(&*krate.name.as_str()))?; + self.shared.ensure_dir(&self.dst.join(&*crate_name.as_str()))?; self.shared.fs.write(&redirect_map_path, paths.as_bytes())?; } } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 128eac8cb0a..05d30187aa8 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -2122,22 +2122,22 @@ fn sidebar_trait(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, t: &clean items: &[clean::Item], before: &str, filter: impl Fn(&clean::Item) -> bool, - write: impl Fn(&mut Buffer, &Symbol), + write: impl Fn(&mut Buffer, &str), after: &str, ) { let mut items = items .iter() .filter_map(|m| match m.name { - Some(ref name) if filter(m) => Some(name), + Some(ref name) if filter(m) => Some(name.as_str()), _ => None, }) .collect::<Vec<_>>(); if !items.is_empty() { - items.sort(); + items.sort_unstable(); out.push_str(before); for item in items.into_iter() { - write(out, item); + write(out, &item); } out.push_str(after); } diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index a65b4ce3a03..6c90fd7c9ee 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -858,6 +858,15 @@ body.blur > :not(#help) { font-size: 1.5em; } +/* Black one-pixel outline around emoji shapes */ +.emoji { + text-shadow: + 1px 0 0 black, + -1px 0 0 black, + 0 1px 0 black, + 0 -1px 0 black; +} + .module-item .stab { border-radius: 3px; display: inline-block; @@ -1353,7 +1362,7 @@ h4 > .notable-traits { to prevent an overlay between the "collapse toggle" and the information tooltip. However, it's not needed with smaller screen width because the doc/code block is always put "one line" below. */ - .information:first-child > .tooltip { + .docblock > .information:first-child > .tooltip { margin-top: 16px; } } diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index 88ac3252bb4..cf2d28bb43f 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -220,8 +220,8 @@ a.test-arrow { } .stab.unstable { background: #FFF5D6; border-color: #FFC600; color: #2f2f2f; } -.stab.deprecated { background: #F3DFFF; border-color: #7F0087; color: #2f2f2f; } -.stab.portability { background: #C4ECFF; border-color: #7BA5DB; color: #2f2f2f; } +.stab.deprecated { background: #ffc4c4; border-color: #db7b7b; color: #2f2f2f; } +.stab.portability { background: #F3DFFF; border-color: #b07bdb; color: #2f2f2f; } .stab.portability > code { background: none; } #help > div { diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css index 9bc21102aaa..7bf6793809c 100644 --- a/src/librustdoc/html/static/themes/light.css +++ b/src/librustdoc/html/static/themes/light.css @@ -218,8 +218,8 @@ a.test-arrow { } .stab.unstable { background: #FFF5D6; border-color: #FFC600; } -.stab.deprecated { background: #F3DFFF; border-color: #7F0087; } -.stab.portability { background: #C4ECFF; border-color: #7BA5DB; } +.stab.deprecated { background: #ffc4c4; border-color: #db7b7b; } +.stab.portability { background: #F3DFFF; border-color: #b07bdb; } .stab.portability > code { background: none; } #help > div { diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index c1dbb5dd33a..a4cdad69865 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -14,7 +14,7 @@ use std::rc::Rc; use rustc_data_structures::fx::FxHashMap; use rustc_middle::ty::TyCtxt; use rustc_session::Session; -use rustc_span::edition::Edition; +use rustc_span::{edition::Edition, Symbol}; use rustdoc_json_types as types; @@ -202,7 +202,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { fn after_krate( &mut self, - _krate: &clean::Crate, + _crate_name: Symbol, _diag: &rustc_errors::Handler, ) -> Result<(), Error> { debug!("Done with crate"); diff --git a/src/librustdoc/passes/collect_trait_impls.rs b/src/librustdoc/passes/collect_trait_impls.rs index 685451b87ed..7b0b2f28fdf 100644 --- a/src/librustdoc/passes/collect_trait_impls.rs +++ b/src/librustdoc/passes/collect_trait_impls.rs @@ -131,12 +131,8 @@ crate fn collect_trait_impls(krate: Crate, cx: &mut DocContext<'_>) -> Crate { } } - let items = if let Some(ref mut it) = krate.module { - if let ModuleItem(Module { ref mut items, .. }) = *it.kind { - items - } else { - panic!("collect-trait-impls can't run"); - } + let items = if let ModuleItem(Module { ref mut items, .. }) = *krate.module.kind { + items } else { panic!("collect-trait-impls can't run"); }; diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index b6782fb75df..17a66d1788e 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -76,7 +76,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { &Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Public }, hir::CRATE_HIR_ID, &krate.item.module, - None, + self.cx.tcx.crate_name, ); top_level_module.is_crate = true; // Attach the crate's exported macros to the top-level module. @@ -114,7 +114,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { _ => continue 'exported_macros, }; // Descend into the child module that matches this path segment (if any). - match cur_mod.mods.iter_mut().find(|child| child.name == Some(path_segment_ty_ns)) { + match cur_mod.mods.iter_mut().find(|child| child.name == path_segment_ty_ns) { Some(child_mod) => cur_mod = &mut *child_mod, None => continue 'exported_macros, } @@ -133,7 +133,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { vis: &'tcx hir::Visibility<'_>, id: hir::HirId, m: &'tcx hir::Mod<'tcx>, - name: Option<Symbol>, + name: Symbol, ) -> Module<'tcx> { let mut om = Module::new(name); om.where_outer = span; @@ -312,13 +312,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { om.items.push((item, renamed)) } hir::ItemKind::Mod(ref m) => { - om.mods.push(self.visit_mod_contents( - item.span, - &item.vis, - item.hir_id(), - m, - Some(name), - )); + om.mods.push(self.visit_mod_contents(item.span, &item.vis, item.hir_id(), m, name)); } hir::ItemKind::Fn(..) | hir::ItemKind::ExternCrate(..) diff --git a/src/test/codegen/default-requires-uwtable.rs b/src/test/codegen/default-requires-uwtable.rs new file mode 100644 index 00000000000..d4c4200c5d2 --- /dev/null +++ b/src/test/codegen/default-requires-uwtable.rs @@ -0,0 +1,15 @@ +// revisions: WINDOWS ANDROID +// needs-llvm-components: x86 arm +// compile-flags: -C panic=abort +// [WINDOWS] compile-flags: --target=x86_64-pc-windows-msvc +// [ANDROID] compile-flags: --target=armv7-linux-androideabi + +#![feature(no_core, lang_items)] +#![crate_type = "lib"] +#![no_core] + +#[lang = "sized"] +trait Sized {} + +// CHECK: attributes #{{.*}} uwtable +pub fn foo() {} diff --git a/src/test/codegen/force-no-unwind-tables.rs b/src/test/codegen/force-no-unwind-tables.rs new file mode 100644 index 00000000000..dc77e6cb709 --- /dev/null +++ b/src/test/codegen/force-no-unwind-tables.rs @@ -0,0 +1,7 @@ +// compile-flags: -C no-prepopulate-passes -C panic=abort -C force-unwind-tables=n +// ignore-windows + +#![crate_type="lib"] + +// CHECK-NOT: attributes #{{.*}} uwtable +pub fn foo() {} diff --git a/src/test/incremental/ich_nested_items.rs b/src/test/incremental/ich_nested_items.rs index aabdaa66411..4f5f6169f36 100644 --- a/src/test/incremental/ich_nested_items.rs +++ b/src/test/incremental/ich_nested_items.rs @@ -3,6 +3,7 @@ // revisions: cfail1 cfail2 // build-pass (FIXME(62277): could be check-pass?) +// compile-flags: -Z query-dep-graph #![crate_type = "rlib"] #![feature(rustc_attrs)] diff --git a/src/test/incremental/ich_resolve_results.rs b/src/test/incremental/ich_resolve_results.rs index 19df2972f89..1fb0f8aa84d 100644 --- a/src/test/incremental/ich_resolve_results.rs +++ b/src/test/incremental/ich_resolve_results.rs @@ -2,6 +2,7 @@ // `use` to something different. // revisions: rpass1 rpass2 rpass3 +// compile-flags: -Z query-dep-graph #![feature(rustc_attrs)] diff --git a/src/test/incremental/spans_significant_w_panic.rs b/src/test/incremental/spans_significant_w_panic.rs index 2574ef5199c..37728af9516 100644 --- a/src/test/incremental/spans_significant_w_panic.rs +++ b/src/test/incremental/spans_significant_w_panic.rs @@ -3,7 +3,7 @@ // revisions:rpass1 rpass2 -// compile-flags: -C overflow-checks=on +// compile-flags: -C overflow-checks=on -Z query-dep-graph #![feature(rustc_attrs)] diff --git a/src/test/rustdoc-gui/check_info_sign_position.goml b/src/test/rustdoc-gui/check_info_sign_position.goml new file mode 100644 index 00000000000..9aa72a3ad53 --- /dev/null +++ b/src/test/rustdoc-gui/check_info_sign_position.goml @@ -0,0 +1,9 @@ +goto: file://|DOC_PATH|/index.html +goto: ./fn.check_list_code_block.html +// If the codeblock is the first element of the docblock, the information tooltip must have +// have some top margin to avoid going over the toggle (the "[+]"). +assert: (".docblock > .information > .compile_fail", { "margin-top": "16px" }) +// Checks that the other codeblocks don't have this top margin. +assert: ("ol > li > .information > .compile_fail", { "margin-top": "0px" }) +assert: ("ol > li > .information > .ignore", { "margin-top": "0px" }) +assert: (".docblock > .information > .ignore", { "margin-top": "0px" }) diff --git a/src/test/rustdoc-gui/lib.rs b/src/test/rustdoc-gui/lib.rs index 15d8dcc6e84..c1e161e1235 100644 --- a/src/test/rustdoc-gui/lib.rs +++ b/src/test/rustdoc-gui/lib.rs @@ -47,26 +47,41 @@ pub fn some_more_function<T: fmt::Debug>(t: &T) -> String { /// Woohoo! A trait! pub trait AnotherOne { + /// Some func 3. + fn func3(); + /// Some func 1. fn func1(); + fn another(); + fn why_not(); + /// Some func 2. fn func2(); - /// Some func 3. - fn func3(); + fn hello(); } +/// ```compile_fail +/// whatever +/// ``` +/// /// Check for "i" signs in lists! /// /// 1. elem 1 -/// 2.test 1 -/// ```compile_fail -/// fn foo() {} -/// ``` +/// 2. test 1 +/// ```compile_fail +/// fn foo() {} +/// ``` /// 3. elem 3 /// 4. ```ignore (it's a test) /// fn foo() {} /// ``` /// 5. elem 5 +/// +/// Final one: +/// +/// ```ignore (still a test) +/// let x = 12; +/// ``` pub fn check_list_code_block() {} diff --git a/src/test/rustdoc-gui/trait-sidebar-item-order.goml b/src/test/rustdoc-gui/trait-sidebar-item-order.goml new file mode 100644 index 00000000000..914486e1c28 --- /dev/null +++ b/src/test/rustdoc-gui/trait-sidebar-item-order.goml @@ -0,0 +1,7 @@ +goto: file://|DOC_PATH|/trait.AnotherOne.html +assert: (".sidebar-links a:nth-of-type(1)", "another") +assert: (".sidebar-links a:nth-of-type(2)", "func1") +assert: (".sidebar-links a:nth-of-type(3)", "func2") +assert: (".sidebar-links a:nth-of-type(4)", "func3") +assert: (".sidebar-links a:nth-of-type(5)", "hello") +assert: (".sidebar-links a:nth-of-type(6)", "why_not") diff --git a/src/test/rustdoc-ui/intra-doc/private-from-crate-level.rs b/src/test/rustdoc-ui/intra-doc/private-from-crate-level.rs new file mode 100644 index 00000000000..e429e75b214 --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/private-from-crate-level.rs @@ -0,0 +1,6 @@ +// check-pass + +//! [my_module] +//~^ WARN public documentation for `private_from_crate_level` links to private item `my_module` + +mod my_module {} diff --git a/src/test/rustdoc-ui/intra-doc/private-from-crate-level.stderr b/src/test/rustdoc-ui/intra-doc/private-from-crate-level.stderr new file mode 100644 index 00000000000..6172cd2e316 --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/private-from-crate-level.stderr @@ -0,0 +1,11 @@ +warning: public documentation for `private_from_crate_level` links to private item `my_module` + --> $DIR/private-from-crate-level.rs:3:6 + | +LL | //! [my_module] + | ^^^^^^^^^ this item is private + | + = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default + = note: this link will resolve properly if you pass `--document-private-items` + +warning: 1 warning emitted + diff --git a/src/test/ui/dep-graph/dep-graph-check-attr.rs b/src/test/ui/dep-graph/dep-graph-check-attr.rs new file mode 100644 index 00000000000..1026efc1b1d --- /dev/null +++ b/src/test/ui/dep-graph/dep-graph-check-attr.rs @@ -0,0 +1,20 @@ +// Test that using rustc_clean/dirty/if_this_changed/then_this_would_need +// are forbidden when `-Z query-dep-graph` is not enabled. + +#![feature(rustc_attrs)] +#![allow(dead_code)] +#![allow(unused_variables)] + +#[rustc_dirty(hir_owner)] //~ ERROR attribute requires -Z query-dep-graph +fn main() {} + +#[rustc_if_this_changed(hir_owner)] //~ ERROR attribute requires -Z query-dep-graph +struct Foo<T> { + f: T, +} + +#[rustc_clean(hir_owner)] //~ ERROR attribute requires -Z query-dep-graph +type TypeAlias<T> = Foo<T>; + +#[rustc_then_this_would_need(variances_of)] //~ ERROR attribute requires -Z query-dep-graph +trait Use<T> {} diff --git a/src/test/ui/dep-graph/dep-graph-check-attr.stderr b/src/test/ui/dep-graph/dep-graph-check-attr.stderr new file mode 100644 index 00000000000..945a4237c12 --- /dev/null +++ b/src/test/ui/dep-graph/dep-graph-check-attr.stderr @@ -0,0 +1,26 @@ +error: attribute requires -Z query-dep-graph to be enabled + --> $DIR/dep-graph-check-attr.rs:8:1 + | +LL | #[rustc_dirty(hir_owner)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: attribute requires -Z query-dep-graph to be enabled + --> $DIR/dep-graph-check-attr.rs:11:1 + | +LL | #[rustc_if_this_changed(hir_owner)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: attribute requires -Z query-dep-graph to be enabled + --> $DIR/dep-graph-check-attr.rs:16:1 + | +LL | #[rustc_clean(hir_owner)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: attribute requires -Z query-dep-graph to be enabled + --> $DIR/dep-graph-check-attr.rs:19:1 + | +LL | #[rustc_then_this_would_need(variances_of)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + |
