Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove the const_raw_ptr_comparison feature gate.
We can never supply a meaningful implementation of this. Instead, the follow up commits will create two intrinsics that approximate comparisons: * `ptr_maybe_eq` * `ptr_maybe_ne` The fact that `ptr_maybe_eq(a, b)` is not necessarily the same value as `!ptr_maybe_ne(a, b)` is a symptom of this entire problem.
- Loading branch information
Showing
27 changed files
with
165 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/fn-const-param-call.rs:3:12 | ||
--> $DIR/fn-const-param-call.rs:1:12 | ||
| | ||
LL | #![feature(const_generics, const_compare_raw_pointers)] | ||
LL | #![feature(const_generics)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information | ||
|
||
warning: 1 warning emitted | ||
error: using function pointers as const generic parameters is forbidden | ||
--> $DIR/fn-const-param-call.rs:8:25 | ||
| | ||
LL | struct Wrapper<const F: fn() -> u32>; | ||
| ^^^^^^^^^^^ | ||
|
||
error: using function pointers as const generic parameters is forbidden | ||
--> $DIR/fn-const-param-call.rs:10:15 | ||
| | ||
LL | impl<const F: fn() -> u32> Wrapper<F> { | ||
| ^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors; 1 warning emitted | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,17 @@ | ||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/fn-const-param-infer.rs:1:12 | ||
| | ||
LL | #![feature(const_generics, const_compare_raw_pointers)] | ||
LL | #![feature(const_generics)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/fn-const-param-infer.rs:16:31 | ||
error: using function pointers as const generic parameters is forbidden | ||
--> $DIR/fn-const-param-infer.rs:4:25 | ||
| | ||
LL | let _: Checked<not_one> = Checked::<not_two>; | ||
| ^^^^^^^^^^^^^^^^^^ expected `{not_one as fn(usize) -> bool}`, found `{not_two as fn(usize) -> bool}` | ||
| | ||
= note: expected type `{not_one as fn(usize) -> bool}` | ||
found type `{not_two as fn(usize) -> bool}` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/fn-const-param-infer.rs:20:24 | ||
| | ||
LL | let _ = Checked::<{generic_arg::<u32>}>; | ||
| ^^^^^^^^^^^^^^^^^^ expected `usize`, found `u32` | ||
| | ||
= note: expected fn pointer `fn(usize) -> _` | ||
found fn item `fn(u32) -> _ {generic_arg::<u32>}` | ||
|
||
error[E0282]: type annotations needed | ||
--> $DIR/fn-const-param-infer.rs:22:23 | ||
| | ||
LL | let _ = Checked::<generic>; | ||
| ^^^^^^^ cannot infer type for type parameter `T` declared on the function `generic` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/fn-const-param-infer.rs:25:40 | ||
| | ||
LL | let _: Checked<{generic::<u32>}> = Checked::<{generic::<u16>}>; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{generic::<u32> as fn(usize) -> bool}`, found `{generic::<u16> as fn(usize) -> bool}` | ||
| | ||
= note: expected type `{generic::<u32> as fn(usize) -> bool}` | ||
found type `{generic::<u16> as fn(usize) -> bool}` | ||
LL | struct Checked<const F: fn(usize) -> bool>; | ||
| ^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 4 previous errors; 1 warning emitted | ||
error: aborting due to previous error; 1 warning emitted | ||
|
||
Some errors have detailed explanations: E0282, E0308. | ||
For more information about an error, try `rustc --explain E0282`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 15 additions & 3 deletions
18
src/test/ui/const-generics/raw-ptr-const-param-deref.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/raw-ptr-const-param-deref.rs:2:12 | ||
--> $DIR/raw-ptr-const-param-deref.rs:1:12 | ||
| | ||
LL | #![feature(const_generics, const_compare_raw_pointers)] | ||
LL | #![feature(const_generics)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information | ||
|
||
warning: 1 warning emitted | ||
error: using raw pointers as const generic parameters is forbidden | ||
--> $DIR/raw-ptr-const-param-deref.rs:6:23 | ||
| | ||
LL | struct Const<const P: *const u32>; | ||
| ^^^^^^^^^^ | ||
|
||
error: using raw pointers as const generic parameters is forbidden | ||
--> $DIR/raw-ptr-const-param-deref.rs:8:15 | ||
| | ||
LL | impl<const P: *const u32> Const<P> { | ||
| ^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors; 1 warning emitted | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
#![feature(const_generics, const_compare_raw_pointers)] | ||
#![feature(const_generics)] | ||
//~^ WARN the feature `const_generics` is incomplete | ||
|
||
struct Const<const P: *const u32>; | ||
struct Const<const P: *const u32>; //~ ERROR: using raw pointers as const generic parameters | ||
|
||
fn main() { | ||
let _: Const<{ 15 as *const _ }> = Const::<{ 10 as *const _ }>; //~ mismatched types | ||
let _: Const<{ 15 as *const _ }> = Const::<{ 10 as *const _ }>; | ||
let _: Const<{ 10 as *const _ }> = Const::<{ 10 as *const _ }>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,17 @@ | ||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/raw-ptr-const-param.rs:1:12 | ||
| | ||
LL | #![feature(const_generics, const_compare_raw_pointers)] | ||
LL | #![feature(const_generics)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/raw-ptr-const-param.rs:7:40 | ||
error: using raw pointers as const generic parameters is forbidden | ||
--> $DIR/raw-ptr-const-param.rs:4:23 | ||
| | ||
LL | let _: Const<{ 15 as *const _ }> = Const::<{ 10 as *const _ }>; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{0xf as *const u32}`, found `{0xa as *const u32}` | ||
| | ||
= note: expected type `{0xf as *const u32}` | ||
found type `{0xa as *const u32}` | ||
LL | struct Const<const P: *const u32>; | ||
| ^^^^^^^^^^ | ||
|
||
error: aborting due to previous error; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,6 @@ | ||
#![feature(const_raw_ptr_to_usize_cast, const_compare_raw_pointers, const_raw_ptr_deref)] | ||
|
||
fn main() {} | ||
|
||
// unconst and bad, will thus error in miri | ||
const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; //~ ERROR any use of this | ||
// unconst and bad, will thus error in miri | ||
const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; //~ ERROR any use of this | ||
// unconst and fine | ||
const Y: usize = unsafe { 42usize as *const i32 as usize + 1 }; | ||
// unconst and bad, will thus error in miri | ||
const Y2: usize = unsafe { &1 as *const i32 as usize + 1 }; //~ ERROR any use of this | ||
// unconst and fine | ||
const Z: i32 = unsafe { *(&1 as *const i32) }; | ||
const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; //~ ERROR cannot be compared | ||
// unconst and bad, will thus error in miri | ||
const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR any use of this value will cause | ||
const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR any use of this value will cause | ||
const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; //~ ERROR cannot be compared |
Oops, something went wrong.