Skip to content

Conversation

@Veykril
Copy link
Member

@Veykril Veykril commented May 8, 2021

Fixes #7443

@Veykril Veykril changed the title Correctly support SelfType when searching for usages fix: Correctly support SelfType when searching for usages May 8, 2021
FileId(0) 28..32
FileId(0) 50..54
"#]],
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s somewhat inconsistent indentation :)

Copy link
Member Author

@Veykril Veykril May 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one downside of expect-testing is rustfmt not touching it while also continuing to pass with a different indentation 😄

let module = sema.to_module_def(root_file)?;
Some(it.ty(sema.db, module))
}
ModuleDef::Trait(_it) => None, // FIXME turn trait into its self-type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s tricky, but this operation doesn’t make sense. Self has surprisingly different semantics in traits and impls.

In traits, it is a type parameter which implements the trait itself (but might as well implement other traits).

in impls, it is a type alias referring to the impl’s type.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ye I didn't realize that, should definitely not do this for Self in trait defs then, changed the tests.

@Veykril
Copy link
Member Author

Veykril commented May 8, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented May 8, 2021

@bors bors bot merged commit cf4d4f6 into rust-lang:master May 8, 2021
@Veykril Veykril deleted the search-self-ty branch May 8, 2021 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Self in struct is not highlighted as usage

2 participants