diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2021-08-03 17:28:51 +0200 |
|---|---|---|
| committer | Lukas Wirth <lukastw97@gmail.com> | 2021-08-03 17:28:51 +0200 |
| commit | b96f1adf5cbfaaa0e0538bae63b20caa09484635 (patch) | |
| tree | aa349e69ce61b2f6003ed290b0e3093852bf8a33 /crates/ide/src | |
| parent | 8afa2722b22f941544c6883285b5bd630e6f510f (diff) | |
| download | rust-b96f1adf5cbfaaa0e0538bae63b20caa09484635.tar.gz rust-b96f1adf5cbfaaa0e0538bae63b20caa09484635.zip | |
Give TypeInfo fields and methods more appropriate names
Diffstat (limited to 'crates/ide/src')
| -rw-r--r-- | crates/ide/src/call_hierarchy.rs | 2 | ||||
| -rw-r--r-- | crates/ide/src/goto_type_definition.rs | 4 | ||||
| -rw-r--r-- | crates/ide/src/highlight_related.rs | 2 | ||||
| -rw-r--r-- | crates/ide/src/hover.rs | 22 | ||||
| -rw-r--r-- | crates/ide/src/inlay_hints.rs | 10 | ||||
| -rw-r--r-- | crates/ide/src/syntax_highlighting/highlight.rs | 4 |
6 files changed, 22 insertions, 22 deletions
diff --git a/crates/ide/src/call_hierarchy.rs b/crates/ide/src/call_hierarchy.rs index 428f3f1c6d6..f725247ccb4 100644 --- a/crates/ide/src/call_hierarchy.rs +++ b/crates/ide/src/call_hierarchy.rs @@ -86,7 +86,7 @@ pub(crate) fn outgoing_calls(db: &RootDatabase, position: FilePosition) -> Optio let name_ref = call_node.name_ref()?; let func_target = match call_node { FnCallNode::CallExpr(expr) => { - let callable = sema.type_of_expr(&expr.expr()?)?.ty.as_callable(db)?; + let callable = sema.type_of_expr(&expr.expr()?)?.original.as_callable(db)?; match callable.kind() { hir::CallableKind::Function(it) => it.try_to_nav(db), _ => None, diff --git a/crates/ide/src/goto_type_definition.rs b/crates/ide/src/goto_type_definition.rs index 3e9dfb8cb67..f8105790f4c 100644 --- a/crates/ide/src/goto_type_definition.rs +++ b/crates/ide/src/goto_type_definition.rs @@ -32,8 +32,8 @@ pub(crate) fn goto_type_definition( let (ty, node) = sema.token_ancestors_with_macros(token).find_map(|node| { let ty = match_ast! { match node { - ast::Expr(it) => sema.type_of_expr(&it)?.ty, - ast::Pat(it) => sema.type_of_pat(&it)?.ty, + ast::Expr(it) => sema.type_of_expr(&it)?.original, + ast::Pat(it) => sema.type_of_pat(&it)?.original, ast::SelfParam(it) => sema.type_of_self(&it)?, ast::Type(it) => sema.resolve_type(&it)?, ast::RecordField(it) => sema.to_def(&it).map(|d| d.ty(db.upcast()))?, diff --git a/crates/ide/src/highlight_related.rs b/crates/ide/src/highlight_related.rs index a1c50c6364e..b4715b10a06 100644 --- a/crates/ide/src/highlight_related.rs +++ b/crates/ide/src/highlight_related.rs @@ -123,7 +123,7 @@ fn highlight_exit_points( } } ast::Expr::MethodCallExpr(_) | ast::Expr::CallExpr(_) | ast::Expr::MacroCall(_) => { - if sema.type_of_expr(&expr).map_or(false, |ty| ty.ty.is_never()) { + if sema.type_of_expr(&expr).map_or(false, |ty| ty.original.is_never()) { highlights .push(HighlightedRange { access: None, range: expr.syntax().text_range() }); } diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 9ca20776b54..6789abfb0a7 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -225,29 +225,29 @@ fn hover_type_info( config: &HoverConfig, expr_or_pat: &Either<ast::Expr, ast::Pat>, ) -> Option<HoverResult> { - let TypeInfo { ty, coerced } = match expr_or_pat { + let TypeInfo { original, adjusted } = match expr_or_pat { Either::Left(expr) => sema.type_of_expr(expr)?, Either::Right(pat) => sema.type_of_pat(pat)?, }; let mut res = HoverResult::default(); - res.markup = if let Some(coerced_ty) = coerced { - let uncoerced = ty.display(sema.db).to_string(); - let coerced = coerced_ty.display(sema.db).to_string(); + res.markup = if let Some(adjusted_ty) = adjusted { + let original = original.display(sema.db).to_string(); + let adjusted = adjusted_ty.display(sema.db).to_string(); format!( - "```text\nType: {:>upad$}\nCoerced to: {:>cpad$}\n```\n", - uncoerced = uncoerced, - coerced = coerced, + "```text\nType: {:>apad$}\nCoerced to: {:>opad$}\n```\n", + uncoerced = original, + coerced = adjusted, // 6 base padding for static text prefix of each line - upad = 6 + coerced.len().max(uncoerced.len()), - cpad = uncoerced.len(), + apad = 6 + adjusted.len().max(original.len()), + opad = original.len(), ) .into() } else { if config.markdown() { - Markup::fenced_block(&ty.display(sema.db)) + Markup::fenced_block(&original.display(sema.db)) } else { - ty.display(sema.db).to_string().into() + original.display(sema.db).to_string().into() } }; Some(res) diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs index 48c2f893aaf..3dc1bbf7dca 100644 --- a/crates/ide/src/inlay_hints.rs +++ b/crates/ide/src/inlay_hints.rs @@ -117,7 +117,7 @@ fn get_chaining_hints( next_next = tokens.next()?.kind(); } if next_next == T![.] { - let ty = sema.type_of_expr(&expr)?.ty; + let ty = sema.type_of_expr(&expr)?.original; if ty.is_unknown() { return None; } @@ -189,7 +189,7 @@ fn get_bind_pat_hints( let krate = sema.scope(pat.syntax()).module().map(|it| it.krate()); let famous_defs = FamousDefs(sema, krate); - let ty = sema.type_of_pat(&pat.clone().into())?.ty; + let ty = sema.type_of_pat(&pat.clone().into())?.original; if should_not_display_type_hint(sema, &pat, &ty) { return None; @@ -308,7 +308,7 @@ fn should_not_display_type_hint( return it.in_token().is_none() || it.iterable() .and_then(|iterable_expr| sema.type_of_expr(&iterable_expr)) - .map(TypeInfo::ty) + .map(TypeInfo::original) .map_or(true, |iterable_ty| iterable_ty.is_unknown() || iterable_ty.is_unit()) }, _ => (), @@ -394,7 +394,7 @@ fn is_enum_name_similar_to_param_name( argument: &ast::Expr, param_name: &str, ) -> bool { - match sema.type_of_expr(argument).and_then(|t| t.ty.as_adt()) { + match sema.type_of_expr(argument).and_then(|t| t.original.as_adt()) { Some(hir::Adt::Enum(e)) => to_lower_snake_case(&e.name(sema.db).to_string()) == param_name, _ => false, } @@ -431,7 +431,7 @@ fn get_callable( ) -> Option<(hir::Callable, ast::ArgList)> { match expr { ast::Expr::CallExpr(expr) => { - sema.type_of_expr(&expr.expr()?)?.ty.as_callable(sema.db).zip(expr.arg_list()) + sema.type_of_expr(&expr.expr()?)?.original.as_callable(sema.db).zip(expr.arg_list()) } ast::Expr::MethodCallExpr(expr) => { sema.resolve_method_call_as_callable(expr).zip(expr.arg_list()) diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index 9eab563ffff..3f61a856ddf 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs @@ -123,7 +123,7 @@ pub(super) fn element( let prefix_expr = element.parent().and_then(ast::PrefixExpr::cast)?; let expr = prefix_expr.expr()?; - let ty = sema.type_of_expr(&expr)?.ty; + let ty = sema.type_of_expr(&expr)?.original; if ty.is_raw_ptr() { HlTag::Operator(HlOperator::Other) | HlMod::Unsafe } else if let Some(ast::PrefixOp::Deref) = prefix_expr.op_kind() { @@ -555,7 +555,7 @@ fn highlight_method_call( if let Some(receiver_ty) = method_call.receiver().and_then(|it| sema.type_of_expr(&it)) { - if !receiver_ty.coerced().is_copy(sema.db) { + if !receiver_ty.adjusted().is_copy(sema.db) { h |= HlMod::Consuming } } |
