-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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 #123130 - oli-obk:missing_type_taint, r=compiler-errors
Load missing type of impl associated constant from trait definition fixes #123092 Also does some cleanups I discovered while analyzing this issue
- Loading branch information
Showing
6 changed files
with
132 additions
and
66 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,28 @@ | ||
//! Test that we compute the right type for associated constants | ||
//! of impls, even if the type is missing. We know it from the trait | ||
//! declaration after all. | ||
|
||
trait Range { | ||
const FIRST: u8; | ||
const LAST: u8; | ||
} | ||
|
||
struct TwoDigits; | ||
impl Range for TwoDigits { | ||
const FIRST: = 10; | ||
//~^ ERROR: missing type for `const` item | ||
const LAST: u8 = 99; | ||
} | ||
|
||
const fn digits(x: u8) -> usize { | ||
match x { | ||
TwoDigits::FIRST..=TwoDigits::LAST => 0, | ||
0..=9 | 100..=255 => panic!(), | ||
} | ||
} | ||
|
||
const FOOMP: [(); { | ||
digits(42) | ||
}] = []; | ||
|
||
fn main() {} |
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,8 @@ | ||
error: missing type for `const` item | ||
--> $DIR/missing_assoc_const_type.rs:12:17 | ||
| | ||
LL | const FIRST: = 10; | ||
| ^ help: provide a type for the associated constant: `u8` | ||
|
||
error: aborting due to 1 previous error | ||
|
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,21 @@ | ||
//! Test that we compute the right type for associated constants | ||
//! of impls, even if the type is missing. We know it from the trait | ||
//! declaration after all. | ||
|
||
trait Range { | ||
const FIRST: u8; | ||
const LAST: u8; | ||
} | ||
|
||
struct TwoDigits; | ||
impl Range for TwoDigits { | ||
const FIRST: = 10; | ||
//~^ ERROR: missing type | ||
const LAST: u8 = 99; | ||
} | ||
|
||
const FOOMP: [(); { | ||
TwoDigits::FIRST as usize | ||
}] = [(); 10]; | ||
|
||
fn main() {} |
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,8 @@ | ||
error: missing type for `const` item | ||
--> $DIR/missing_assoc_const_type2.rs:12:17 | ||
| | ||
LL | const FIRST: = 10; | ||
| ^ help: provide a type for the associated constant: `u8` | ||
|
||
error: aborting due to 1 previous error | ||
|
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