mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
impl Display for AttrInput/ImportAlias
This commit is contained in:
parent
5b6c0c1af2
commit
01df4c04d1
2 changed files with 19 additions and 1 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
use std::{
|
||||
convert::{TryFrom, TryInto},
|
||||
ops,
|
||||
fmt, ops,
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
|
@ -648,6 +648,15 @@ pub enum AttrInput {
|
|||
TokenTree(Subtree),
|
||||
}
|
||||
|
||||
impl fmt::Display for AttrInput {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
AttrInput::Literal(lit) => write!(f, " = \"{}\"", lit.escape_debug()),
|
||||
AttrInput::TokenTree(subtree) => subtree.fmt(f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Attr {
|
||||
fn from_src(
|
||||
db: &dyn DefDatabase,
|
||||
|
|
|
@ -46,6 +46,15 @@ pub enum ImportAlias {
|
|||
Alias(Name),
|
||||
}
|
||||
|
||||
impl Display for ImportAlias {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
ImportAlias::Underscore => f.write_str("_"),
|
||||
ImportAlias::Alias(name) => f.write_str(&name.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ModPath {
|
||||
pub fn from_src(db: &dyn DefDatabase, path: ast::Path, hygiene: &Hygiene) -> Option<ModPath> {
|
||||
let ctx = LowerCtx::with_hygiene(db, hygiene);
|
||||
|
|
Loading…
Reference in a new issue