-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: Implement object safety and its hovering hint #17814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e31991a to
bdb9daa
Compare
|
☔ The latest upstream changes (presumably #17832) made this pull request unmergeable. Please resolve the merge conflicts. |
bdb9daa to
1dbfb4c
Compare
|
It might take some time because I'm having difficulties re-implementing some functionality in rustc into r-a 😅 (I think I would do it eventually) |
|
☔ The latest upstream changes (presumably #17893) made this pull request unmergeable. Please resolve the merge conflicts. |
1dbfb4c to
059578b
Compare
9fcb78e to
b93159d
Compare
|
☔ The latest upstream changes (presumably #17936) made this pull request unmergeable. Please resolve the merge conflicts. |
1926ed3 to
9fe56f7
Compare
|
I think that basic implementation is complete. Now it's test time |
461e21a to
fd8afe2
Compare
|
While testing this plugged into here; rust-analyzer/crates/hir-ty/src/chalk_db.rs Lines 384 to 387 in 7106cd3
I've found some minor mistakes in my implementation and fixes for them 😅 (All the test are green in my local revision with the above things applied) I'll push them some hours later |
|
☔ The latest upstream changes (presumably #17941) made this pull request unmergeable. Please resolve the merge conflicts. |
dc50b0f to
33ebf59
Compare
|
☔ The latest upstream changes (presumably #17972) made this pull request unmergeable. Please resolve the merge conflicts. |
33ebf59 to
9477836
Compare
| fn take(self, n: usize) -> crate::iter::Take<Self> | ||
| where | ||
| Self: Sized, | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std has this bound, too (and without this, Iterator is not object safe)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I brought every relevant test from https://github.com/rust-lang/rust/tree/ae9f5019f9ce6eb3ecd96206ade4a612efe20fd5/tests/ui/object-safety except one with HRTB - it's still checked as object unsafe as it is in rustc but reason is different because we don't support HRBT yet -
|
Things to do after this(not right after 😅 except the first one);
trait Foo {
fn foo(&self)
where
Self: Sized;
}
fn test(x: &dyn Foo) {
x.foo();
^^^
}
|
19b38de to
19f6a3f
Compare
crates/ide/src/hover/render.rs
Outdated
| name.as_str() | ||
| ); | ||
| let desc = match mvc { | ||
| MethodViolationCode::StaticMethod => "static (no receiver parameter)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| MethodViolationCode::StaticMethod => "static (no receiver parameter)", | |
| MethodViolationCode::StaticMethod => "missing a receiver", |
static isn't too descriptive I think (and might confuse people with a static item)
crates/ide/src/hover/render.rs
Outdated
| let name = hir::Function::from(func).name(db); | ||
| format_to!( | ||
| buf, | ||
| "has a method `{}` that is non dispatchable because of;\n// - ", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "has a method `{}` that is non dispatchable because of;\n// - ", | |
| "has a method `{}` that is non dispatchable because of:\n// - ", |
crates/ide/src/hover/render.rs
Outdated
| MethodViolationCode::ReferencesImplTraitInTrait => { | ||
| "the return type contains `impl Trait`" | ||
| } | ||
| MethodViolationCode::AsyncFn => "async", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| MethodViolationCode::AsyncFn => "async", | |
| MethodViolationCode::AsyncFn => "being async", |
crates/ide/src/hover/render.rs
Outdated
| MethodViolationCode::WhereClauseReferencesSelf => { | ||
| "a where clause references `Self`" | ||
| } | ||
| MethodViolationCode::Generic => "a Generic parameter other than lifetime", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| MethodViolationCode::Generic => "a Generic parameter other than lifetime", | |
| MethodViolationCode::Generic => "a non-lifetime generic parameter", |
crates/ide/src/hover/render.rs
Outdated
| "a where clause references `Self`" | ||
| } | ||
| MethodViolationCode::Generic => "a Generic parameter other than lifetime", | ||
| MethodViolationCode::UndispatchableReceiver => "the non dispatchable receiver type", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| MethodViolationCode::UndispatchableReceiver => "the non dispatchable receiver type", | |
| MethodViolationCode::UndispatchableReceiver => "a non-dispatchable receiver type", |
|
Couple of wording nits, otherwise lgtm! |
|
✌️ @ShoyuVanilla, you can now approve this pull request! If @Veykril told you to " |
19f6a3f to
6520a43
Compare
|
☀️ Test successful - checks-actions |
|
This caused some regressions only in |
Resolves #17779