-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 #97508 - JohnTitor:more-strict-placeholder-dyn-obj, r…
…=pnkfelix Harden bad placeholder checks on statics/consts Resubmission of #89161 Fixes #88643 In #83739, I added a check for trait objects on statics/consts but it wasn't robust. `is_suggestable_infer_ty` fn does a more strict check and finds more bad placeholders. See #89161 (comment) for the more detailed explanation. r? `@pnkfelix` as you're the reviewer of the previous PR
- Loading branch information
Showing
9 changed files
with
75 additions
and
9 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
fn main() { | ||
static BUG: fn(_) -> u8 = |_| 8; | ||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions [E0121] | ||
//~| ERROR the placeholder `_` is not allowed within types on item signatures for static items | ||
} |
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,8 +1,9 @@ | ||
const TEST4: fn() -> _ = 42; | ||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions | ||
//~| ERROR the placeholder `_` is not allowed within types on item signatures for constant items | ||
|
||
fn main() { | ||
const TEST5: fn() -> _ = 42; | ||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions | ||
|
||
//~| ERROR the placeholder `_` is not allowed within types on item signatures for constant items | ||
} |
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,19 @@ | ||
// Regression test for the ICE described in #88643. Specifically: | ||
// https://github.com/rust-lang/rust/issues/88643#issuecomment-913128893 | ||
// and https://github.com/rust-lang/rust/issues/88643#issuecomment-913171935 | ||
// and https://github.com/rust-lang/rust/issues/88643#issuecomment-913765984 | ||
|
||
use std::collections::HashMap; | ||
|
||
pub trait T {} | ||
|
||
static CALLBACKS: HashMap<*const dyn T, dyn FnMut(&mut _) + 'static> = HashMap::new(); | ||
//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for static items [E0121] | ||
|
||
static CALLBACKS2: Vec<dyn Fn(& _)> = Vec::new(); | ||
//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for static items [E0121] | ||
|
||
static CALLBACKS3: Option<dyn Fn(& _)> = None; | ||
//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for static items [E0121] | ||
|
||
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,21 @@ | ||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items | ||
--> $DIR/issue-88643.rs:10:56 | ||
| | ||
LL | static CALLBACKS: HashMap<*const dyn T, dyn FnMut(&mut _) + 'static> = HashMap::new(); | ||
| ^ not allowed in type signatures | ||
|
||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items | ||
--> $DIR/issue-88643.rs:13:33 | ||
| | ||
LL | static CALLBACKS2: Vec<dyn Fn(& _)> = Vec::new(); | ||
| ^ not allowed in type signatures | ||
|
||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items | ||
--> $DIR/issue-88643.rs:16:36 | ||
| | ||
LL | static CALLBACKS3: Option<dyn Fn(& _)> = None; | ||
| ^ not allowed in type signatures | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0121`. |
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