-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Use the more informative generic type inference failure error on method calls on raw pointers #122768
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
Use the more informative generic type inference failure error on method calls on raw pointers #122768
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -441,7 +441,7 @@ E0695: 0695, | |
E0696: 0696, | ||
E0697: 0697, | ||
E0698: 0698, | ||
E0699: 0699, | ||
E0699: 0699, // REMOVED: merged into generic inference var error | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can comment it and move it to the commented list below (but keep your comment). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no I cannot 😆 I tried this first. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait really? O.o Dark magic going on... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment at the top of the file says to not remove things anymore There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hum... E0744 is commented, its file still exists and you can get it from |
||
E0700: 0700, | ||
E0701: 0701, | ||
E0703: 0703, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
error[E0699]: cannot call a method on a raw pointer with an unknown pointee type | ||
--> $DIR/edition-raw-pointer-method-2018.rs:9:15 | ||
error[E0282]: type annotations needed for `*const _` | ||
--> $DIR/edition-raw-pointer-method-2018.rs:8:9 | ||
| | ||
LL | let y = &x as *const _; | ||
| ^ | ||
LL | | ||
LL | let _ = y.is_null(); | ||
| ^^^^^^^ | ||
| ------- cannot call a method on a raw pointer with an unknown pointee type | ||
| | ||
help: consider giving `y` an explicit type, where the placeholders `_` are specified | ||
| | ||
LL | let y: *const _ = &x as *const _; | ||
| ++++++++++ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0699`. | ||
For more information about this error, try `rustc --explain E0282`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,49 @@ | ||
error[E0699]: cannot call a method on a raw pointer with an unknown pointee type | ||
error[E0282]: type annotations needed | ||
--> $DIR/call_method_unknown_pointee.rs:10:41 | ||
| | ||
LL | let _a: i32 = (ptr as *const _).read(); | ||
| ^^^^ | ||
| | | ||
| cannot infer type | ||
| cannot call a method on a raw pointer with an unknown pointee type | ||
|
||
error[E0699]: cannot call a method on a raw pointer with an unknown pointee type | ||
--> $DIR/call_method_unknown_pointee.rs:13:24 | ||
error[E0282]: type annotations needed for `*const _` | ||
--> $DIR/call_method_unknown_pointee.rs:12:13 | ||
| | ||
LL | let b = ptr as *const _; | ||
| ^ | ||
LL | | ||
LL | let _b: u8 = b.read(); | ||
| ^^^^ | ||
| ---- cannot call a method on a raw pointer with an unknown pointee type | ||
| | ||
help: consider giving `b` an explicit type, where the placeholders `_` are specified | ||
| | ||
LL | let b: *const _ = ptr as *const _; | ||
| ++++++++++ | ||
|
||
error[E0699]: cannot call a method on a raw pointer with an unknown pointee type | ||
error[E0282]: type annotations needed | ||
--> $DIR/call_method_unknown_pointee.rs:21:39 | ||
| | ||
LL | let _a: i32 = (ptr as *mut _).read(); | ||
| ^^^^ | ||
| | | ||
| cannot infer type | ||
| cannot call a method on a raw pointer with an unknown pointee type | ||
|
||
error[E0699]: cannot call a method on a raw pointer with an unknown pointee type | ||
--> $DIR/call_method_unknown_pointee.rs:24:11 | ||
error[E0282]: type annotations needed for `*mut _` | ||
--> $DIR/call_method_unknown_pointee.rs:23:13 | ||
| | ||
LL | let b = ptr as *mut _; | ||
| ^ | ||
LL | | ||
LL | b.write(10); | ||
| ^^^^^ | ||
| ----- cannot call a method on a raw pointer with an unknown pointee type | ||
| | ||
help: consider giving `b` an explicit type, where the placeholders `_` are specified | ||
| | ||
LL | let b: *mut _ = ptr as *mut _; | ||
| ++++++++ | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0699`. | ||
For more information about this error, try `rustc --explain E0282`. |
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.
You also need to remove
E0699
from the failing code example attributes just below.