From 47b1e6659bbb4a8f490e683a53f261b73f4f586d Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 18 Oct 2021 09:28:38 +0200 Subject: switch release channel to stable --- src/ci/channel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ci/channel b/src/ci/channel index 65b2df87f7d..2bf5ad0447d 100644 --- a/src/ci/channel +++ b/src/ci/channel @@ -1 +1 @@ -beta +stable -- cgit 1.4.1-3-g733a5 From aef5765479b7c7d3d44fc69c8126b2ef5052433f Mon Sep 17 00:00:00 2001 From: Loïc BRANSTETT Date: Thu, 14 Oct 2021 01:50:37 +0200 Subject: Deduplicate macro_rules! from module_exports when documenting them This can append if within the same module a `#[macro_export] macro_rules!` is declared but also a reexport of itself producing two export of the same macro in the same module. In that case we only want to document it once. --- src/librustdoc/visit_ast.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 897b9140fc8..7182310b73a 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -86,13 +86,21 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { // the rexport defines the path that a user will actually see. Accordingly, // we add the rexport as an item here, and then skip over the original // definition in `visit_item()` below. + // + // We also skip `#[macro_export] macro_rules!` that have alredy been inserted, + // this can append if within the same module a `#[macro_export] macro_rules!` + // is declared but also a reexport of itself producing two export of the same + // macro in the same module. + let mut inserted = FxHashSet::default(); for export in self.cx.tcx.module_exports(CRATE_DEF_ID).unwrap_or(&[]) { if let Res::Def(DefKind::Macro(_), def_id) = export.res { if let Some(local_def_id) = def_id.as_local() { if self.cx.tcx.has_attr(def_id, sym::macro_export) { - let hir_id = self.cx.tcx.hir().local_def_id_to_hir_id(local_def_id); - let item = self.cx.tcx.hir().expect_item(hir_id); - top_level_module.items.push((item, None)); + if !inserted.insert(def_id) { + let hir_id = self.cx.tcx.hir().local_def_id_to_hir_id(local_def_id); + let item = self.cx.tcx.hir().expect_item(hir_id); + top_level_module.items.push((item, None)); + } } } } -- cgit 1.4.1-3-g733a5 From f96a40f4db06b81bd7eb9bde965e8835d06a0447 Mon Sep 17 00:00:00 2001 From: Loïc BRANSTETT Date: Thu, 14 Oct 2021 02:12:18 +0200 Subject: Add regression test for #89852 --- src/test/rustdoc-json/reexport/macro.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/test/rustdoc-json/reexport/macro.rs (limited to 'src') diff --git a/src/test/rustdoc-json/reexport/macro.rs b/src/test/rustdoc-json/reexport/macro.rs new file mode 100644 index 00000000000..b86614ffbad --- /dev/null +++ b/src/test/rustdoc-json/reexport/macro.rs @@ -0,0 +1,17 @@ +// edition:2018 + +#![no_core] +#![feature(no_core)] + +// @count macro.json "$.index[*][?(@.name=='macro')].inner.items[*]" 2 + +// @set repro_id = macro.json "$.index[*][?(@.name=='repro')].id" +// @has - "$.index[*][?(@.name=='macro')].inner.items[*]" $repro_id +#[macro_export] +macro_rules! repro { + () => {}; +} + +// @set repro2_id = macro.json "$.index[*][?(@.inner.name=='repro2')].id" +// @has - "$.index[*][?(@.name=='macro')].inner.items[*]" $repro2_id +pub use crate::repro as repro2; -- cgit 1.4.1-3-g733a5 From b5729387f315fe58431d56729d23b65a00071abd Mon Sep 17 00:00:00 2001 From: Loïc BRANSTETT Date: Thu, 14 Oct 2021 10:50:46 +0200 Subject: Oops, inverted condition, fix that --- src/librustdoc/visit_ast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 7182310b73a..8268f10db36 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -96,7 +96,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { if let Res::Def(DefKind::Macro(_), def_id) = export.res { if let Some(local_def_id) = def_id.as_local() { if self.cx.tcx.has_attr(def_id, sym::macro_export) { - if !inserted.insert(def_id) { + if inserted.insert(def_id) { let hir_id = self.cx.tcx.hir().local_def_id_to_hir_id(local_def_id); let item = self.cx.tcx.hir().expect_item(hir_id); top_level_module.items.push((item, None)); -- cgit 1.4.1-3-g733a5 From e05ee65ac3598d47cf712b2f3585ee11720c92db Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 15 Oct 2021 12:21:25 +0200 Subject: Apply documentation suggestions from code review Co-authored-by: Guillaume Gomez --- src/librustdoc/visit_ast.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 8268f10db36..5082a14da2c 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -87,9 +87,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { // we add the rexport as an item here, and then skip over the original // definition in `visit_item()` below. // - // We also skip `#[macro_export] macro_rules!` that have alredy been inserted, - // this can append if within the same module a `#[macro_export] macro_rules!` - // is declared but also a reexport of itself producing two export of the same + // We also skip `#[macro_export] macro_rules!` that have already been inserted, + // it can happen if within the same module a `#[macro_export] macro_rules!` + // is declared but also a reexport of itself producing two exports of the same // macro in the same module. let mut inserted = FxHashSet::default(); for export in self.cx.tcx.module_exports(CRATE_DEF_ID).unwrap_or(&[]) { -- cgit 1.4.1-3-g733a5 From 6307ecb63aedfd4d3bfc93d31b21cf6a7cd6cb84 Mon Sep 17 00:00:00 2001 From: Loïc BRANSTETT Date: Fri, 15 Oct 2021 12:56:47 +0200 Subject: Add equivalent test in src/test/rustdoc --- src/test/rustdoc/issue-89852.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/test/rustdoc/issue-89852.rs (limited to 'src') diff --git a/src/test/rustdoc/issue-89852.rs b/src/test/rustdoc/issue-89852.rs new file mode 100644 index 00000000000..dff2d07ac25 --- /dev/null +++ b/src/test/rustdoc/issue-89852.rs @@ -0,0 +1,14 @@ +// edition:2018 + +#![no_core] +#![feature(no_core)] + +// @count issue_89852/index.html '//*[@class="macro"]' 2 +// @has - '//*[@class="macro"]/@href' 'macro.repro.html' +#[macro_export] +macro_rules! repro { + () => {}; +} + +// @!has issue_89852/macro.repro.html '//*[@class="macro"]/@content' 'repro2' +pub use crate::repro as repro2; -- cgit 1.4.1-3-g733a5 From 7b9189aef301bd0e6cb2ec50835d3ce15eee051f Mon Sep 17 00:00:00 2001 From: Loïc BRANSTETT Date: Fri, 15 Oct 2021 16:54:31 +0200 Subject: Rework the equivalent test to work with sidebar-items.js --- src/test/rustdoc/issue-89852.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/test/rustdoc/issue-89852.rs b/src/test/rustdoc/issue-89852.rs index dff2d07ac25..45544dbeea6 100644 --- a/src/test/rustdoc/issue-89852.rs +++ b/src/test/rustdoc/issue-89852.rs @@ -3,12 +3,12 @@ #![no_core] #![feature(no_core)] -// @count issue_89852/index.html '//*[@class="macro"]' 2 -// @has - '//*[@class="macro"]/@href' 'macro.repro.html' +// @matches 'issue_89852/sidebar-items.js' '"repro"' +// @!matches 'issue_89852/sidebar-items.js' '"repro".*"repro"' + #[macro_export] macro_rules! repro { () => {}; } -// @!has issue_89852/macro.repro.html '//*[@class="macro"]/@content' 'repro2' pub use crate::repro as repro2; -- cgit 1.4.1-3-g733a5