Skip to content

Commit

Permalink
Auto merge of rust-lang#12083 - Veykril:inlays, r=Veykril
Browse files Browse the repository at this point in the history
minor: Add test for parameter and reborrow hint order
  • Loading branch information
bors committed Apr 26, 2022
2 parents a8bc625 + 5e41399 commit 198c075
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions crates/ide/src/inlay_hints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ pub enum LifetimeElisionHints {

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum InlayKind {
ImplicitReborrow,
TypeHint,
ParameterHint,
ClosureReturnTypeHint,
ChainingHint,
ClosureReturnTypeHint,
GenericParamListHint,
ImplicitReborrow,
LifetimeHint,
ParameterHint,
TypeHint,
}

#[derive(Debug)]
Expand Down Expand Up @@ -110,11 +110,11 @@ fn hints(
config: &InlayHintsConfig,
node: SyntaxNode,
) {
let krate = match sema.scope(&node) {
Some(it) => it.krate(),
let famous_defs = match sema.scope(&node) {
Some(it) => FamousDefs(sema, it.krate()),
None => return,
};
let famous_defs = FamousDefs(sema, krate);

if let Some(expr) = ast::Expr::cast(node.clone()) {
chaining_hints(hints, sema, &famous_defs, config, &expr);
match expr {
Expand Down Expand Up @@ -1637,10 +1637,7 @@ fn main() {
fn skip_constructor_and_enum_type_hints() {
check_with_config(
InlayHintsConfig {
render_colons: true,
type_hints: true,
parameter_hints: true,
chaining_hints: true,
hide_named_constructor_hints: true,
..DISABLED_CONFIG
},
Expand Down Expand Up @@ -2147,33 +2144,36 @@ impl () {
#[test]
fn hints_implicit_reborrow() {
check_with_config(
InlayHintsConfig { reborrow_hints: true, ..DISABLED_CONFIG },
InlayHintsConfig { reborrow_hints: true, parameter_hints: true, ..DISABLED_CONFIG },
r#"
fn __() {
let unique = &mut ();
let r_mov = unique;
let foo: &mut _ = unique;
//^^^^^^ &mut *
ref_mut_id(unique);
//^^^^^^ mut_ref
//^^^^^^ &mut *
let shared = ref_id(unique);
//^^^^^^ shared_ref
//^^^^^^ &*
let mov = shared;
let r_mov: &_ = shared;
ref_id(shared);
//^^^^^^ shared_ref
identity(unique);
identity(shared);
}
fn identity<T>(t: T) -> T {
t
}
fn ref_mut_id(x: &mut ()) -> &mut () {
x
//^ &mut *
fn ref_mut_id(mut_ref: &mut ()) -> &mut () {
mut_ref
//^^^^^^^ &mut *
}
fn ref_id(x: &()) -> &() {
x
fn ref_id(shared_ref: &()) -> &() {
shared_ref
}
"#,
);
Expand Down

0 comments on commit 198c075

Please sign in to comment.