-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #89147 - b-naber:refs_in_check_const_value_eq, r=oli-obk
add case for checking const refs in check_const_value_eq Previously in `check_const_value_eq` we destructured `ConstValue::ByRef` instances, this didn't account for `ty::Ref`s however, which led to an ICE. Fixes #88876 Fixes #88384 r? `@oli-obk`
- Loading branch information
Showing
4 changed files
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// check-pass | ||
|
||
#![feature(fn_traits)] | ||
#![feature(adt_const_params)] | ||
//~^ WARNING the feature `adt_const_params` is incomplete | ||
|
||
#[derive(PartialEq, Eq)] | ||
struct CompileTimeSettings{ | ||
hooks: &'static[fn()], | ||
} | ||
|
||
struct Foo<const T: CompileTimeSettings>; | ||
|
||
impl<const T: CompileTimeSettings> Foo<T> { | ||
fn call_hooks(){ | ||
} | ||
} | ||
|
||
fn main(){ | ||
const SETTINGS: CompileTimeSettings = CompileTimeSettings{ | ||
hooks: &[], | ||
}; | ||
|
||
Foo::<SETTINGS>::call_hooks(); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/refs_check_const_eq-issue-88384.rs:4:12 | ||
| | ||
LL | #![feature(adt_const_params)] | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= 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 | ||
|
12 changes: 12 additions & 0 deletions
12
src/test/ui/consts/refs_check_const_value_eq-issue-88876.rs
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// check-pass | ||
|
||
#![allow(incomplete_features)] | ||
#![feature(adt_const_params)] | ||
|
||
struct FooConst<const ARRAY: &'static [&'static str]> {} | ||
|
||
const FOO_ARR: &[&'static str; 2] = &["Hello", "Friend"]; | ||
|
||
fn main() { | ||
let _ = FooConst::<FOO_ARR> {}; | ||
} |