Skip to content

Commit df7e701

Browse files
committed
refactoring
1 parent c6f36a5 commit df7e701

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

crates/ide-db/src/path_transform.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,8 @@ impl<'a> PathTransform<'a> {
160160
}
161161
(Either::Left(k), None) => {
162162
if let Some(default) = k.default(db) {
163-
eprintln!("\ndefault = {:?}", default);
164163
let default = ast::make::expr_const_value(&default);
165-
fn get_syntax<T: AstNode>(node: T) -> SyntaxNode {
166-
node.syntax().clone_for_update()
167-
}
168-
const_substs.insert(k, default.either(get_syntax, get_syntax));
164+
const_substs.insert(k, default.syntax().clone_for_update());
169165
// FIXME: transform the default value
170166
}
171167
}

crates/syntax/src/ast/make.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
//! API should require to assemble every node piecewise. The trick of
1010
//! `parse(format!())` we use internally is an implementation detail -- long
1111
//! term, it will be replaced with direct tree manipulation.
12-
use either::Either;
1312
use itertools::Itertools;
1413
use stdx::{format_to, never};
1514

@@ -508,9 +507,8 @@ pub fn expr_literal(text: &str) -> ast::Literal {
508507
ast_from_text(&format!("fn f() {{ let _ = {text}; }}"))
509508
}
510509

511-
// FIXME: support `ast::BLOCK_EXPR` too
512-
pub fn expr_const_value(text: &str) -> Either<ast::Literal, ast::PathExpr> {
513-
ast_from_text(&format!("fn f() {{ let _ = {text}; }}"))
510+
pub fn expr_const_value(text: &str) -> ast::Expr {
511+
ast_from_text(&format!("trait Foo<const N: usize = {text}> {{}}"))
514512
}
515513

516514
pub fn expr_empty_block() -> ast::Expr {

0 commit comments

Comments
 (0)