Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
37216f8
Prevent people from assigning me as a PR reviewer
jyn514 Jul 26, 2023
4315ba6
tests/ui/proc-macro/*: Migrate FIXMEs to check-pass
Enselic Jul 27, 2023
66aa2ef
Move Res check into `should_ignore_res`
GuillaumeGomez Jul 27, 2023
4e93b5a
Move `inherits_doc_hidden` and `should_ignore_res` into `clean/utils.rs`
GuillaumeGomez Jul 27, 2023
37076c9
Don't attempt to compute layout of type referencing error
compiler-errors Jul 16, 2023
77fa702
Fix aksama template
compiler-errors Jul 17, 2023
d45eb41
Dont report CTFE errors that are due to references-error layouts
compiler-errors Jul 27, 2023
9454916
Fix switch-stdout test for none unix/windows platforms
raoulstrackx Jul 28, 2023
8577921
btree/map.rs: remove "Basic usage" text
tshepang Jul 28, 2023
0457eda
doc: replace wrong punctuation mark
tshepang Jul 28, 2023
8548689
Fix issue_15149 test for the SGX target
raoulstrackx Jul 28, 2023
65f311d
Group `write` calls when possible and use new format args
GuillaumeGomez Jul 27, 2023
c59c3f1
Rollup merge of #113773 - compiler-errors:err-layout-bail, r=cjgillot
matthiaskrgr Jul 28, 2023
106a2fc
Rollup merge of #114107 - jyn514:vacation, r=ehuss
matthiaskrgr Jul 28, 2023
d694408
Rollup merge of #114124 - Enselic:proc-fixme, r=cjgillot
matthiaskrgr Jul 28, 2023
3461cd5
Rollup merge of #114129 - GuillaumeGomez:rustdoc-cleanup, r=notriddle
matthiaskrgr Jul 28, 2023
7d30c5d
Rollup merge of #114171 - fortanix:raoul/fix_switch-stdout_test, r=wo…
matthiaskrgr Jul 28, 2023
cef052f
Rollup merge of #114172 - fortanix:raoul/fix_process-spawning_test, r…
matthiaskrgr Jul 28, 2023
a17acec
Rollup merge of #114173 - tshepang:patch-1, r=workingjubilee
matthiaskrgr Jul 28, 2023
2b2fa47
Rollup merge of #114174 - tshepang:patch-6, r=workingjubilee
matthiaskrgr Jul 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move inherits_doc_hidden and should_ignore_res into clean/utils.rs
  • Loading branch information
GuillaumeGomez committed Jul 27, 2023
commit 4e93b5a0931c8b9c2ff161296096bfbea9fd426d
2 changes: 1 addition & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use thin_vec::ThinVec;

use crate::core::{self, DocContext, ImplTraitParam};
use crate::formats::item_type::ItemType;
use crate::visit_ast::{should_ignore_res, Module as DocModule};
use crate::visit_ast::Module as DocModule;

use utils::*;

Expand Down
34 changes: 33 additions & 1 deletion src/librustdoc/clean/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_ast as ast;
use rustc_ast::tokenstream::TokenTree;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE};
use rustc_middle::mir;
use rustc_middle::mir::interpret::ConstValue;
use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, TyCtxt};
Expand Down Expand Up @@ -625,3 +625,35 @@ pub(super) fn display_macro_source(
}
}
}

pub(crate) fn inherits_doc_hidden(
tcx: TyCtxt<'_>,
mut def_id: LocalDefId,
stop_at: Option<LocalDefId>,
) -> bool {
let hir = tcx.hir();
while let Some(id) = tcx.opt_local_parent(def_id) {
if let Some(stop_at) = stop_at && id == stop_at {
return false;
}
def_id = id;
if tcx.is_doc_hidden(def_id.to_def_id()) {
return true;
} else if let Some(node) = hir.find_by_def_id(def_id) &&
matches!(
node,
hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(_), .. }),
)
{
// `impl` blocks stand a bit on their own: unless they have `#[doc(hidden)]` directly
// on them, they don't inherit it from the parent context.
return false;
}
}
false
}

#[inline]
pub(crate) fn should_ignore_res(res: Res) -> bool {
matches!(res, Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..))
}
2 changes: 1 addition & 1 deletion src/librustdoc/passes/check_doc_test_visibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

use super::Pass;
use crate::clean;
use crate::clean::utils::inherits_doc_hidden;
use crate::clean::*;
use crate::core::DocContext;
use crate::html::markdown::{find_testable_code, ErrorCodes, Ignore, LangString};
use crate::visit::DocVisitor;
use crate::visit_ast::inherits_doc_hidden;
use rustc_hir as hir;
use rustc_middle::lint::LintLevelSource;
use rustc_session::lint;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/passes/strip_hidden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use rustc_span::symbol::sym;
use std::mem;

use crate::clean;
use crate::clean::utils::inherits_doc_hidden;
use crate::clean::{Item, ItemIdSet};
use crate::core::DocContext;
use crate::fold::{strip_item, DocFolder};
use crate::passes::{ImplStripper, Pass};
use crate::visit_ast::inherits_doc_hidden;

pub(crate) const STRIP_HIDDEN: Pass = Pass {
name: "strip-hidden",
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/passes/stripper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use rustc_hir::def_id::DefId;
use rustc_middle::ty::{TyCtxt, Visibility};
use std::mem;

use crate::clean::utils::inherits_doc_hidden;
use crate::clean::{self, Item, ItemId, ItemIdSet};
use crate::fold::{strip_item, DocFolder};
use crate::formats::cache::Cache;
use crate::visit_ast::inherits_doc_hidden;
use crate::visit_lib::RustdocEffectiveVisibilities;

pub(crate) struct Stripper<'a, 'tcx> {
Expand Down
33 changes: 1 addition & 32 deletions src/librustdoc/visit_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use rustc_span::Span;

use std::mem;

use crate::clean::utils::{inherits_doc_hidden, should_ignore_res};
use crate::clean::{cfg::Cfg, reexport_chain, AttributesExt, NestedAttributesExt};
use crate::core;

Expand Down Expand Up @@ -73,38 +74,6 @@ fn def_id_to_path(tcx: TyCtxt<'_>, did: DefId) -> Vec<Symbol> {
std::iter::once(crate_name).chain(relative).collect()
}

pub(crate) fn inherits_doc_hidden(
tcx: TyCtxt<'_>,
mut def_id: LocalDefId,
stop_at: Option<LocalDefId>,
) -> bool {
let hir = tcx.hir();
while let Some(id) = tcx.opt_local_parent(def_id) {
if let Some(stop_at) = stop_at && id == stop_at {
return false;
}
def_id = id;
if tcx.is_doc_hidden(def_id.to_def_id()) {
return true;
} else if let Some(node) = hir.find_by_def_id(def_id) &&
matches!(
node,
hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(_), .. }),
)
{
// `impl` blocks stand a bit on their own: unless they have `#[doc(hidden)]` directly
// on them, they don't inherit it from the parent context.
return false;
}
}
false
}

#[inline]
pub(crate) fn should_ignore_res(res: Res) -> bool {
matches!(res, Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..))
}

pub(crate) struct RustdocVisitor<'a, 'tcx> {
cx: &'a mut core::DocContext<'tcx>,
view_item_stack: LocalDefIdSet,
Expand Down