mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Remove todo!()
s
This commit is contained in:
parent
e243a03da1
commit
5fdd1e36e3
2 changed files with 79 additions and 76 deletions
|
@ -666,10 +666,7 @@ impl ExprCollector<'_> {
|
||||||
let fields = e.fields().map(|it| it.as_name()).collect();
|
let fields = e.fields().map(|it| it.as_name()).collect();
|
||||||
self.alloc_expr(Expr::OffsetOf(OffsetOf { container, fields }), syntax_ptr)
|
self.alloc_expr(Expr::OffsetOf(OffsetOf { container, fields }), syntax_ptr)
|
||||||
}
|
}
|
||||||
ast::Expr::FormatArgsExpr(f) => match self.collect_format_args(f, syntax_ptr) {
|
ast::Expr::FormatArgsExpr(f) => self.collect_format_args(f, syntax_ptr),
|
||||||
Ok(value) => value,
|
|
||||||
Err(value) => return value,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1576,7 +1573,7 @@ impl ExprCollector<'_> {
|
||||||
&mut self,
|
&mut self,
|
||||||
f: ast::FormatArgsExpr,
|
f: ast::FormatArgsExpr,
|
||||||
syntax_ptr: AstPtr<ast::Expr>,
|
syntax_ptr: AstPtr<ast::Expr>,
|
||||||
) -> Result<la_arena::Idx<Expr>, Option<la_arena::Idx<Expr>>> {
|
) -> ExprId {
|
||||||
let mut args = FormatArgumentsCollector::new();
|
let mut args = FormatArgumentsCollector::new();
|
||||||
f.args().for_each(|arg| {
|
f.args().for_each(|arg| {
|
||||||
args.add(FormatArgument {
|
args.add(FormatArgument {
|
||||||
|
@ -1613,7 +1610,7 @@ impl ExprCollector<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
todo!();
|
return self.missing_expr();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create a list of all _unique_ (argument, format trait) combinations.
|
// Create a list of all _unique_ (argument, format trait) combinations.
|
||||||
|
@ -1735,12 +1732,12 @@ impl ExprCollector<'_> {
|
||||||
let Some(new_v1_formatted) =
|
let Some(new_v1_formatted) =
|
||||||
LangItem::FormatArguments.ty_rel_path(self.db, self.krate, name![new_v1_formatted])
|
LangItem::FormatArguments.ty_rel_path(self.db, self.krate, name![new_v1_formatted])
|
||||||
else {
|
else {
|
||||||
todo!()
|
return self.missing_expr();
|
||||||
};
|
};
|
||||||
let Some(unsafe_arg_new) =
|
let Some(unsafe_arg_new) =
|
||||||
LangItem::FormatUnsafeArg.ty_rel_path(self.db, self.krate, name![new])
|
LangItem::FormatUnsafeArg.ty_rel_path(self.db, self.krate, name![new])
|
||||||
else {
|
else {
|
||||||
todo!()
|
return self.missing_expr();
|
||||||
};
|
};
|
||||||
let new_v1_formatted = self.alloc_expr_desugared(Expr::Path(new_v1_formatted));
|
let new_v1_formatted = self.alloc_expr_desugared(Expr::Path(new_v1_formatted));
|
||||||
|
|
||||||
|
@ -1756,14 +1753,14 @@ impl ExprCollector<'_> {
|
||||||
tail: Some(unsafe_arg_new),
|
tail: Some(unsafe_arg_new),
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(self.alloc_expr(
|
self.alloc_expr(
|
||||||
Expr::Call {
|
Expr::Call {
|
||||||
callee: new_v1_formatted,
|
callee: new_v1_formatted,
|
||||||
args: Box::new([lit_pieces, args, format_options, unsafe_arg_new]),
|
args: Box::new([lit_pieces, args, format_options, unsafe_arg_new]),
|
||||||
is_assignee_expr: false,
|
is_assignee_expr: false,
|
||||||
},
|
},
|
||||||
syntax_ptr,
|
syntax_ptr,
|
||||||
))
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate a hir expression for a format_args placeholder specification.
|
/// Generate a hir expression for a format_args placeholder specification.
|
||||||
|
@ -1808,7 +1805,8 @@ impl ExprCollector<'_> {
|
||||||
} = &placeholder.format_options;
|
} = &placeholder.format_options;
|
||||||
let fill = self.alloc_expr_desugared(Expr::Literal(Literal::Char(fill.unwrap_or(' '))));
|
let fill = self.alloc_expr_desugared(Expr::Literal(Literal::Char(fill.unwrap_or(' '))));
|
||||||
|
|
||||||
let Some(align) = LangItem::FormatAlignment.ty_rel_path(
|
let align = {
|
||||||
|
let align = LangItem::FormatAlignment.ty_rel_path(
|
||||||
self.db,
|
self.db,
|
||||||
self.krate,
|
self.krate,
|
||||||
match alignment {
|
match alignment {
|
||||||
|
@ -1817,10 +1815,12 @@ impl ExprCollector<'_> {
|
||||||
Some(FormatAlignment::Center) => name![Center],
|
Some(FormatAlignment::Center) => name![Center],
|
||||||
None => name![Unknown],
|
None => name![Unknown],
|
||||||
},
|
},
|
||||||
) else {
|
);
|
||||||
todo!()
|
match align {
|
||||||
|
Some(path) => self.alloc_expr_desugared(Expr::Path(path)),
|
||||||
|
None => self.missing_expr(),
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let align = self.alloc_expr_desugared(Expr::Path(align));
|
|
||||||
// This needs to match `Flag` in library/core/src/fmt/rt.rs.
|
// This needs to match `Flag` in library/core/src/fmt/rt.rs.
|
||||||
let flags: u32 = ((sign == Some(FormatSign::Plus)) as u32)
|
let flags: u32 = ((sign == Some(FormatSign::Plus)) as u32)
|
||||||
| ((sign == Some(FormatSign::Minus)) as u32) << 1
|
| ((sign == Some(FormatSign::Minus)) as u32) << 1
|
||||||
|
@ -1834,12 +1834,16 @@ impl ExprCollector<'_> {
|
||||||
)));
|
)));
|
||||||
let precision = self.make_count(&precision, argmap);
|
let precision = self.make_count(&precision, argmap);
|
||||||
let width = self.make_count(&width, argmap);
|
let width = self.make_count(&width, argmap);
|
||||||
let Some(format_placeholder_new) =
|
|
||||||
LangItem::FormatPlaceholder.ty_rel_path(self.db, self.krate, name![new])
|
let format_placeholder_new = {
|
||||||
else {
|
let format_placeholder_new =
|
||||||
todo!()
|
LangItem::FormatPlaceholder.ty_rel_path(self.db, self.krate, name![new]);
|
||||||
|
match format_placeholder_new {
|
||||||
|
Some(path) => self.alloc_expr_desugared(Expr::Path(path)),
|
||||||
|
None => self.missing_expr(),
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let format_placeholder_new = self.alloc_expr_desugared(Expr::Path(format_placeholder_new));
|
|
||||||
self.alloc_expr_desugared(Expr::Call {
|
self.alloc_expr_desugared(Expr::Call {
|
||||||
callee: format_placeholder_new,
|
callee: format_placeholder_new,
|
||||||
args: Box::new([position, fill, align, flags, precision, width]),
|
args: Box::new([position, fill, align, flags, precision, width]),
|
||||||
|
@ -1873,11 +1877,8 @@ impl ExprCollector<'_> {
|
||||||
) -> ExprId {
|
) -> ExprId {
|
||||||
match count {
|
match count {
|
||||||
Some(FormatCount::Literal(n)) => {
|
Some(FormatCount::Literal(n)) => {
|
||||||
let Some(count_is) =
|
match LangItem::FormatCount.ty_rel_path(self.db, self.krate, name![Is]) {
|
||||||
LangItem::FormatCount.ty_rel_path(self.db, self.krate, name![Is])
|
Some(count_is) => {
|
||||||
else {
|
|
||||||
todo!()
|
|
||||||
};
|
|
||||||
let count_is = self.alloc_expr_desugared(Expr::Path(count_is));
|
let count_is = self.alloc_expr_desugared(Expr::Path(count_is));
|
||||||
let args = self.alloc_expr_desugared(Expr::Literal(Literal::Uint(
|
let args = self.alloc_expr_desugared(Expr::Literal(Literal::Uint(
|
||||||
*n as u128,
|
*n as u128,
|
||||||
|
@ -1889,14 +1890,15 @@ impl ExprCollector<'_> {
|
||||||
is_assignee_expr: false,
|
is_assignee_expr: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
None => self.missing_expr(),
|
||||||
|
}
|
||||||
|
}
|
||||||
Some(FormatCount::Argument(arg)) => {
|
Some(FormatCount::Argument(arg)) => {
|
||||||
if let Ok(arg_index) = arg.index {
|
if let Ok(arg_index) = arg.index {
|
||||||
let (i, _) = argmap.insert_full((arg_index, ArgumentType::Usize));
|
let (i, _) = argmap.insert_full((arg_index, ArgumentType::Usize));
|
||||||
let Some(count_param) =
|
|
||||||
LangItem::FormatCount.ty_rel_path(self.db, self.krate, name![Param])
|
match LangItem::FormatCount.ty_rel_path(self.db, self.krate, name![Param]) {
|
||||||
else {
|
Some(count_param) => {
|
||||||
todo!()
|
|
||||||
};
|
|
||||||
let count_param = self.alloc_expr_desugared(Expr::Path(count_param));
|
let count_param = self.alloc_expr_desugared(Expr::Path(count_param));
|
||||||
let args = self.alloc_expr_desugared(Expr::Literal(Literal::Uint(
|
let args = self.alloc_expr_desugared(Expr::Literal(Literal::Uint(
|
||||||
i as u128,
|
i as u128,
|
||||||
|
@ -1907,18 +1909,17 @@ impl ExprCollector<'_> {
|
||||||
args: Box::new([args]),
|
args: Box::new([args]),
|
||||||
is_assignee_expr: false,
|
is_assignee_expr: false,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
None => self.missing_expr(),
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
self.missing_expr()
|
self.missing_expr()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => match LangItem::FormatCount.ty_rel_path(self.db, self.krate, name![Implied]) {
|
||||||
let Some(count_param) =
|
Some(count_param) => self.alloc_expr_desugared(Expr::Path(count_param)),
|
||||||
LangItem::FormatCount.ty_rel_path(self.db, self.krate, name![Implied])
|
None => self.missing_expr(),
|
||||||
else {
|
},
|
||||||
todo!()
|
|
||||||
};
|
|
||||||
self.alloc_expr_desugared(Expr::Path(count_param))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1932,7 +1933,7 @@ impl ExprCollector<'_> {
|
||||||
fn make_argument(&mut self, arg: ExprId, ty: ArgumentType) -> ExprId {
|
fn make_argument(&mut self, arg: ExprId, ty: ArgumentType) -> ExprId {
|
||||||
use ArgumentType::*;
|
use ArgumentType::*;
|
||||||
use FormatTrait::*;
|
use FormatTrait::*;
|
||||||
let Some(new_fn) = LangItem::FormatArgument.ty_rel_path(
|
match LangItem::FormatArgument.ty_rel_path(
|
||||||
self.db,
|
self.db,
|
||||||
self.krate,
|
self.krate,
|
||||||
match ty {
|
match ty {
|
||||||
|
@ -1947,9 +1948,8 @@ impl ExprCollector<'_> {
|
||||||
Format(UpperHex) => name![new_upper_hex],
|
Format(UpperHex) => name![new_upper_hex],
|
||||||
Usize => name![from_usize],
|
Usize => name![from_usize],
|
||||||
},
|
},
|
||||||
) else {
|
) {
|
||||||
todo!()
|
Some(new_fn) => {
|
||||||
};
|
|
||||||
let new_fn = self.alloc_expr_desugared(Expr::Path(new_fn));
|
let new_fn = self.alloc_expr_desugared(Expr::Path(new_fn));
|
||||||
self.alloc_expr_desugared(Expr::Call {
|
self.alloc_expr_desugared(Expr::Call {
|
||||||
callee: new_fn,
|
callee: new_fn,
|
||||||
|
@ -1957,6 +1957,9 @@ impl ExprCollector<'_> {
|
||||||
is_assignee_expr: false,
|
is_assignee_expr: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
None => self.missing_expr(),
|
||||||
|
}
|
||||||
|
}
|
||||||
// endregion: format
|
// endregion: format
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,7 @@ impl InferenceContext<'_> {
|
||||||
path.segments().skip(remaining_index),
|
path.segments().skip(remaining_index),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Path::LangItem(_, seg) => (
|
Path::LangItem(..) => (
|
||||||
PathSegment {
|
PathSegment {
|
||||||
name: {
|
name: {
|
||||||
_d = hir_expand::name::known::Unknown;
|
_d = hir_expand::name::known::Unknown;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue