Removed usage of Attributes in FnDecl and ExternalCrate. Relocate part of the fields in Attributes, as functions in AttributesExt.

refacto use from_def_id_and_attrs_and_parts instead of an old trick

most of josha suggestions + check if def_id is not fake before using it in a query

Removed usage of Attributes in FnDecl and ExternalCrate. Relocate part of the Attributes fields as functions in AttributesExt.
This commit is contained in:
Timothée Delabrouille 2021-04-23 22:15:13 +02:00
parent 5da10c0121
commit b4f1dfd2c5
11 changed files with 64 additions and 53 deletions

View file

@ -1,15 +1,17 @@
use std::collections::BTreeMap;
use std::path::Path;
use rustc_ast::ast;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_middle::ty::TyCtxt;
use rustc_span::symbol::{sym, Symbol};
use serde::ser::{Serialize, SerializeStruct, Serializer};
use crate::clean;
use crate::clean::types::{
FnDecl, FnRetTy, GenericBound, Generics, GetDefId, Type, WherePredicate,
AttributesExt, FnDecl, FnRetTy, GenericBound, Generics, GetDefId, Type, TypeKind,
WherePredicate,
};
use crate::clean::{self, AttributesExt};
use crate::formats::cache::Cache;
use crate::formats::item_type::ItemType;
use crate::html::markdown::short_markdown_summary;
@ -30,6 +32,7 @@ crate enum ExternalLocation {
crate fn extern_location(
e: &clean::ExternalCrate,
extern_url: Option<&str>,
ast_attrs: &[ast::Attribute],
dst: &Path,
tcx: TyCtxt<'_>,
) -> ExternalLocation {
@ -50,7 +53,7 @@ crate fn extern_location(
// Failing that, see if there's an attribute specifying where to find this
// external crate
e.attrs
ast_attrs
.lists(sym::doc)
.filter(|a| a.has_name(sym::html_root_url))
.filter_map(|a| a.value_str())