-
Notifications
You must be signed in to change notification settings - Fork 165
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
Fixed #2500 #3390
base: master
Are you sure you want to change the base?
Fixed #2500 #3390
Conversation
fe57261
to
c8b9399
Compare
#include "rust-hir-inherent-impl-overlap.h" | ||
#include "rust-hir-inherent-impl-check.h" |
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.
Duplicate includes
@@ -0,0 +1,81 @@ | |||
// Copyright (C) 2020-2024 Free Software Foundation, Inc. |
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 believe we're in 2025 now 😅
// Copyright (C) 2020-2024 Free Software Foundation, Inc. | |
// Copyright (C) 2020-2025 Free Software Foundation, Inc. |
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.
Should it be changed from 2020-2024
to just 2025
, since it's a new file?
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.
Great work, you really did a good job using our existing framework and checking for the impls :D It's missing one bit of logic with the lang items I think, but this is honestly impressive - well done!
#include "rust-hir-item.h" | ||
#include "rust-hir-type-check-base.h" | ||
#include "rust-type-util.h" | ||
#include <vector> |
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.
This include should be removed, you should include "rust-system.h" instead if it is necessary
void scan () | ||
|
||
{ |
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.
void scan () | |
{ | |
void scan () | |
{ |
if (is_primitive_type_kind (impl_type->get_kind ())) | ||
{ | ||
possible_primitive_impl.push_back (impl); | ||
} |
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 think this is a good start, but we must also check if the implementation is a lang item. In Rust 1.49, this is the implementation for the official impl
of i8
for example:
#[lang = "i8"]
impl i8 {
int_impl! { i8, i8, u8, 8, -128, 127, "", "", 2, "-0x7e", "0xa", "0x12", "0x12", "0x48",
"[0x12]", "[0x12]", "", "" }
}
because the standard library does define methods for the i8
type so we still need to be able to do that somewhere.
Here is another primitive implementation if you want to take a look: https://github.com/rust-lang/rust/blob/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/core/src/ptr/mut_ptr.rs#L6
We can maybe address this in a later PR if this doesn't cause any regressions though
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'm not sure if all these failed regressions just because missing lang item check, so many! sorry for that! :) maybe some of them need modify , I will take the time to do some reseach about your suggestions, thx!
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.
Yes some of the regressions are due to this, e.g. in gcc/testsuite/rust/compile/const-issue1440.rs where we define the primitive implementation for integers (which I assume will cause your error to trigger). but you'll need to fix the testcase as well to add the attribute
void report_error (HIR::ImplBlock *impl) | ||
|
||
{ |
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.
void report_error (HIR::ImplBlock *impl) | |
{ | |
void report_error (HIR::ImplBlock *impl) | |
{ |
make check-rust pass at local machine, i will fix code format tomorrow |
ac5a768
to
714c863
Compare
Add a seperate typecheck pass collect impl blocks, then report errors. gcc/rust/ChangeLog: * typecheck/rust-hir-inherent-impl-check.h: new typecheck pass * typecheck/rust-hir-type-check.cc: modify the function which test primitive type * typecheck/rust-tyty.cc: the new typecheck pass entrypoint * util/rust-hir-map.cc: add the map lookup lang item by defid * util/rust-hir-map.h: add the map lookup lang item by defid gcc/testsuite/ChangeLog: * rust/compile/issue-2500-rustc.rs: testsuite case same with rustc * rust/compile/issue-2500.rs: testsuite case * rust/compile/const-issue1440.rs: add lang item attribute * rust/compile/issue-1005.rs: add lang item attribute * rust/compile/issue-1130.rs: add lang item attribute * rust/compile/issue-1235.rs: add lang item attribute * rust/compile/issue-1237.rs: add lang item attribute * rust/compile/issue-2190-2.rs: add lang item attribute * rust/compile/issue-2905-2.rs: add lang item attribute * rust/compile/iterators1.rs: add lang item attribute * rust/compile/macros/mbe/macro-issue1233.rs: add lang item attribute * rust/compile/macros/mbe/macro54.rs: add lang item attribute * rust/compile/torture/intrinsics-8.rs: add lang item attribute * rust/compile/torture/issue-1075.rs: add lang item attribute * rust/compile/torture/issue-1432.rs: add lang item attribute * rust/execute/torture/issue-1436.rs: add lang item attribute * rust/execute/torture/issue-2236.rs: add lang item attribute * rust/execute/torture/iter1.rs: add lang item attribute * rust/execute/torture/str-layout1.rs: add lang item attribute Signed-off-by: Zhang He <[email protected]>
// filtering trait-impl-blocks | ||
if (impl->has_trait_ref ()) | ||
return true; | ||
HirId impl_ty_id = impl->get_type ().get_mappings ().get_hirid (); |
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 think some line breaks here will help make this easier to read maybe after those returns
Add a seperate typecheck pass collect impl blocks, then report errors.
Signed-off-by: Zhang He [email protected]
ChangLog:
Thank you for making Rust GCC better!
If your PR fixes an issue, you can add "Fixes #issue_number" into this
PR description and the git commit message. This way the issue will be
automatically closed when your PR is merged. If your change addresses
an issue but does not fully fix it please mark it as "Addresses #issue_number"
in the git commit message.
Here is a checklist to help you with your PR.
make check-rust
passes locallyclang-format
gcc/testsuite/rust/
Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.
*Please write a comment explaining your change. This is the message
that will be part of the merge commit.