Make some formatting improvements
This commit is contained in:
parent
91e021a59c
commit
f5e0d0cc18
|
@ -1,5 +1,3 @@
|
||||||
// ignore-tidy-filelength
|
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
@ -88,7 +86,6 @@ pub struct Item {
|
||||||
|
|
||||||
impl fmt::Debug for Item {
|
impl fmt::Debug for Item {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
|
||||||
let fake = MAX_DEF_ID.with(|m| m.borrow().get(&self.def_id.krate)
|
let fake = MAX_DEF_ID.with(|m| m.borrow().get(&self.def_id.krate)
|
||||||
.map(|id| self.def_id >= *id).unwrap_or(false));
|
.map(|id| self.def_id >= *id).unwrap_or(false));
|
||||||
let def_id: &dyn fmt::Debug = if fake { &"**FAKE**" } else { &self.def_id };
|
let def_id: &dyn fmt::Debug = if fake { &"**FAKE**" } else { &self.def_id };
|
||||||
|
@ -112,6 +109,7 @@ impl Item {
|
||||||
pub fn doc_value(&self) -> Option<&str> {
|
pub fn doc_value(&self) -> Option<&str> {
|
||||||
self.attrs.doc_value()
|
self.attrs.doc_value()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Finds all `doc` attributes as NameValues and returns their corresponding values, joined
|
/// Finds all `doc` attributes as NameValues and returns their corresponding values, joined
|
||||||
/// with newlines.
|
/// with newlines.
|
||||||
pub fn collapsed_doc_value(&self) -> Option<String> {
|
pub fn collapsed_doc_value(&self) -> Option<String> {
|
||||||
|
@ -174,7 +172,6 @@ impl Item {
|
||||||
pub fn is_keyword(&self) -> bool {
|
pub fn is_keyword(&self) -> bool {
|
||||||
self.type_() == ItemType::Keyword
|
self.type_() == ItemType::Keyword
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_stripped(&self) -> bool {
|
pub fn is_stripped(&self) -> bool {
|
||||||
match self.inner { StrippedItem(..) => true, _ => false }
|
match self.inner { StrippedItem(..) => true, _ => false }
|
||||||
}
|
}
|
||||||
|
@ -456,9 +453,7 @@ impl Attributes {
|
||||||
/// Reads a `MetaItem` from within an attribute, looks for whether it is a
|
/// Reads a `MetaItem` from within an attribute, looks for whether it is a
|
||||||
/// `#[doc(include="file")]`, and returns the filename and contents of the file as loaded from
|
/// `#[doc(include="file")]`, and returns the filename and contents of the file as loaded from
|
||||||
/// its expansion.
|
/// its expansion.
|
||||||
pub fn extract_include(mi: &ast::MetaItem)
|
pub fn extract_include(mi: &ast::MetaItem) -> Option<(String, String)> {
|
||||||
-> Option<(String, String)>
|
|
||||||
{
|
|
||||||
mi.meta_item_list().and_then(|list| {
|
mi.meta_item_list().and_then(|list| {
|
||||||
for meta in list {
|
for meta in list {
|
||||||
if meta.check_name(sym::include) {
|
if meta.check_name(sym::include) {
|
||||||
|
@ -508,8 +503,7 @@ impl Attributes {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_ast(diagnostic: &::errors::Handler,
|
pub fn from_ast(diagnostic: &::errors::Handler, attrs: &[ast::Attribute]) -> Attributes {
|
||||||
attrs: &[ast::Attribute]) -> Attributes {
|
|
||||||
let mut doc_strings = vec![];
|
let mut doc_strings = vec![];
|
||||||
let mut sp = None;
|
let mut sp = None;
|
||||||
let mut cfg = Cfg::True;
|
let mut cfg = Cfg::True;
|
||||||
|
@ -520,7 +514,7 @@ impl Attributes {
|
||||||
/// returns `attr` unchanged.
|
/// returns `attr` unchanged.
|
||||||
pub fn with_doc_comment_markers_stripped<T>(
|
pub fn with_doc_comment_markers_stripped<T>(
|
||||||
attr: &Attribute,
|
attr: &Attribute,
|
||||||
f: impl FnOnce(&Attribute) -> T
|
f: impl FnOnce(&Attribute) -> T,
|
||||||
) -> T {
|
) -> T {
|
||||||
match attr.kind {
|
match attr.kind {
|
||||||
AttrKind::Normal(_) => {
|
AttrKind::Normal(_) => {
|
||||||
|
@ -823,7 +817,6 @@ impl GenericParamDefKind {
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
|
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
|
||||||
pub struct GenericParamDef {
|
pub struct GenericParamDef {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
||||||
pub kind: GenericParamDefKind,
|
pub kind: GenericParamDefKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue