Skip to content

Commit 53c4de3

Browse files
committed
Pass a TyCtxt directly to Attribute::from_ast
This allows calling `tcx.struct_span_lint_hir` in the next commit. It also slightly shortens the code.
1 parent 04f993f commit 53c4de3

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

src/librustdoc/clean/inline.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,7 @@ fn merge_attrs(
298298
// when we render them.
299299
if let Some(inner) = new_attrs {
300300
if let Some(new_id) = parent_module {
301-
let diag = cx.sess().diagnostic();
302-
Attributes::from_ast(diag, old_attrs, Some((inner, new_id)), local)
301+
Attributes::from_ast(cx.tcx, old_attrs, Some((inner, new_id)), local)
303302
} else {
304303
let mut both = inner.to_vec();
305304
both.extend_from_slice(old_attrs);

src/librustdoc/clean/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl Clean<Item> for doctree::Module<'_> {
241241
}
242242

243243
fn clean_attrs(attrs: &[ast::Attribute], local: bool, cx: &mut DocContext<'_>) -> Attributes {
244-
Attributes::from_ast(cx.sess().diagnostic(), attrs, None, local)
244+
Attributes::from_ast(cx.tcx, attrs, None, local)
245245
}
246246

247247
impl Clean<GenericBound> for hir::GenericBound<'_> {

src/librustdoc/clean/types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ impl Attributes {
739739
}
740740

741741
crate fn from_ast(
742-
handler: &::rustc_errors::Handler,
742+
tcx: TyCtxt<'_>,
743743
attrs: &[ast::Attribute],
744744
additional_attrs: Option<(&[ast::Attribute], DefId)>,
745745
local: bool,
@@ -801,7 +801,7 @@ impl Attributes {
801801
// Extracted #[doc(cfg(...))]
802802
match Cfg::parse(cfg_mi) {
803803
Ok(new_cfg) => cfg &= new_cfg,
804-
Err(e) => handler.span_err(e.span, e.msg),
804+
Err(e) => tcx.sess.span_err(e.span, e.msg),
805805
}
806806
} else if let Some((filename, contents)) = Attributes::extract_include(&mi)
807807
{

src/librustdoc/doctest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ impl<'a, 'hir, 'tcx> HirCollector<'a, 'hir, 'tcx> {
10931093
nested: F,
10941094
) {
10951095
let attrs = self.tcx.hir().attrs(hir_id);
1096-
let mut attrs = Attributes::from_ast(self.sess.diagnostic(), attrs, None, true);
1096+
let mut attrs = Attributes::from_ast(self.tcx, attrs, None, true);
10971097
if let Some(ref cfg) = attrs.cfg {
10981098
if !cfg.matches(&self.sess.parse_sess, Some(&self.sess.features_untracked())) {
10991099
return;

0 commit comments

Comments
 (0)