Skip to content

Commit 69bcb42

Browse files
committed
fix: Fix TokenStream::to_string implementation dropping quotation marks
1 parent 3d5f430 commit 69bcb42

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

crates/hir-ty/src/display.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use rustc_apfloat::{
3434
};
3535
use smallvec::SmallVec;
3636
use span::Edition;
37-
use stdx::{never, IsNoneOr};
37+
use stdx::never;
3838
use triomphe::Arc;
3939

4040
use crate::{
@@ -1489,8 +1489,7 @@ fn generic_args_sans_defaults<'ga>(
14891489
}
14901490
// otherwise, if the arg is equal to the param default, hide it (unless the
14911491
// default is an error which can happen for the trait Self type)
1492-
#[allow(unstable_name_collisions)]
1493-
default_parameters.get(i).is_none_or(|default_parameter| {
1492+
stdx::IsNoneOr::is_none_or(default_parameters.get(i), |default_parameter| {
14941493
// !is_err(default_parameter.skip_binders())
14951494
// &&
14961495
arg != &default_parameter.clone().substitute(Interner, &parameters)

crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -507,12 +507,17 @@ mod tests {
507507
close: span,
508508
kind: tt::DelimiterKind::Brace,
509509
},
510-
token_trees: Box::new([]),
510+
token_trees: Box::new([tt::TokenTree::Leaf(tt::Leaf::Literal(tt::Literal {
511+
kind: tt::LitKind::Str,
512+
symbol: Symbol::intern("string"),
513+
suffix: None,
514+
span,
515+
}))]),
511516
}),
512517
],
513518
};
514519

515-
assert_eq!(s.to_string(), "struct T {}");
520+
assert_eq!(s.to_string(), "struct T {\"string\"}");
516521
}
517522

518523
#[test]

crates/tt/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ pub fn pretty<S>(tkns: &[TokenTree<S>]) -> String {
603603
TokenTree::Leaf(Leaf::Ident(ident)) => {
604604
format!("{}{}", ident.is_raw.as_str(), ident.sym)
605605
}
606-
TokenTree::Leaf(Leaf::Literal(literal)) => literal.symbol.as_str().to_owned(),
606+
TokenTree::Leaf(Leaf::Literal(literal)) => format!("{literal}"),
607607
TokenTree::Leaf(Leaf::Punct(punct)) => format!("{}", punct.char),
608608
TokenTree::Subtree(subtree) => {
609609
let content = pretty(&subtree.token_trees);

0 commit comments

Comments
 (0)