1
Fork 0

Move ExternalLocation to clean::types

It was previously defined in `render::search_index` but wasn't used at
all there. `clean::types` seems like a better fit since that's where
`ExternalCrate` is defined.
This commit is contained in:
Noah Lev 2021-12-27 18:57:07 -08:00
parent e19593f0e5
commit 2b801dcdd3
6 changed files with 19 additions and 19 deletions

View file

@ -38,7 +38,6 @@ use crate::clean::Clean;
use crate::core::DocContext;
use crate::formats::cache::Cache;
use crate::formats::item_type::ItemType;
use crate::html::render::search_index::ExternalLocation;
use crate::html::render::Context;
crate use self::FnRetTy::*;
@ -337,6 +336,16 @@ impl ExternalCrate {
}
}
/// Indicates where an external crate can be found.
crate enum ExternalLocation {
/// Remote URL root of the external crate
Remote(String),
/// This external crate can be found in the local doc/ folder
Local,
/// The external crate could not be found.
Unknown,
}
/// Anything with a source location and set of attributes and, optionally, a
/// name. That is, anything that can be documented. This doesn't correspond
/// directly to the AST's concept of an item; it's a strict superset.

View file

@ -6,13 +6,13 @@ use rustc_middle::middle::privacy::AccessLevels;
use rustc_middle::ty::TyCtxt;
use rustc_span::symbol::sym;
use crate::clean::{self, ExternalCrate, ItemId, PrimitiveType};
use crate::clean::{self, types::ExternalLocation, ExternalCrate, ItemId, PrimitiveType};
use crate::core::DocContext;
use crate::fold::DocFolder;
use crate::formats::item_type::ItemType;
use crate::formats::Impl;
use crate::html::markdown::short_markdown_summary;
use crate::html::render::search_index::{get_index_search_type, ExternalLocation};
use crate::html::render::search_index::get_index_search_type;
use crate::html::render::IndexItem;
/// This cache is used to store information about the [`clean::Crate`] being

View file

@ -21,10 +21,12 @@ use rustc_middle::ty::TyCtxt;
use rustc_span::def_id::CRATE_DEF_INDEX;
use rustc_target::spec::abi::Abi;
use crate::clean::{self, utils::find_nearest_parent_module, ExternalCrate, ItemId, PrimitiveType};
use crate::clean::{
self, types::ExternalLocation, utils::find_nearest_parent_module, ExternalCrate, ItemId,
PrimitiveType,
};
use crate::formats::item_type::ItemType;
use crate::html::escape::Escape;
use crate::html::render::search_index::ExternalLocation;
use crate::html::render::Context;
use super::url_parts_builder::UrlPartsBuilder;

View file

@ -14,7 +14,7 @@ use rustc_span::source_map::FileName;
use rustc_span::symbol::sym;
use super::print_item::{full_path, item_path, print_item};
use super::search_index::{build_index, ExternalLocation};
use super::search_index::build_index;
use super::templates;
use super::write_shared::write_shared;
use super::{
@ -22,7 +22,7 @@ use super::{
BASIC_KEYWORDS,
};
use crate::clean::{self, ExternalCrate};
use crate::clean::{self, types::ExternalLocation, ExternalCrate};
use crate::config::RenderOptions;
use crate::docfs::{DocFS, PathError};
use crate::error::Error;

View file

@ -13,16 +13,6 @@ use crate::formats::item_type::ItemType;
use crate::html::markdown::short_markdown_summary;
use crate::html::render::{IndexItem, IndexItemFunctionType, RenderType, TypeWithKind};
/// Indicates where an external crate can be found.
crate enum ExternalLocation {
/// Remote URL root of the external crate
Remote(String),
/// This external crate can be found in the local doc/ folder
Local,
/// The external crate could not be found.
Unknown,
}
/// Builds the search index from the collected metadata
crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<'tcx>) -> String {
let mut defid_to_pathid = FxHashMap::default();

View file

@ -19,12 +19,11 @@ use rustc_session::Session;
use rustdoc_json_types as types;
use crate::clean;
use crate::clean::ExternalCrate;
use crate::clean::types::{ExternalCrate, ExternalLocation};
use crate::config::RenderOptions;
use crate::error::Error;
use crate::formats::cache::Cache;
use crate::formats::FormatRenderer;
use crate::html::render::search_index::ExternalLocation;
use crate::json::conversions::{from_item_id, IntoWithTcx};
#[derive(Clone)]