-
Notifications
You must be signed in to change notification settings - Fork 13k
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 #97716 - compiler-errors:issue-97708, r=wesleywiser
Fix reachability analysis for const methods Use `method_might_be_inlined` directly for `ImplItemKind::Fn` instead of duplicating the logic in `def_id_represents_local_inlined_item`. This is parallel to how we use `item_might_be_inlined` for `ItemKind::Fn` in that same body. Fixes #97708
- Loading branch information
Showing
3 changed files
with
58 additions
and
25 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,41 @@ | ||
use std::{ptr::NonNull, task::Poll}; | ||
|
||
struct TaskRef; | ||
|
||
struct Header { | ||
vtable: &'static Vtable, | ||
} | ||
|
||
struct Vtable { | ||
poll: unsafe fn(TaskRef) -> Poll<()>, | ||
deallocate: unsafe fn(NonNull<Header>), | ||
} | ||
|
||
// in the "Header" type, which is a private type in maitake | ||
impl Header { | ||
pub(crate) const fn new_stub() -> Self { | ||
unsafe fn nop(_ptr: TaskRef) -> Poll<()> { | ||
Poll::Pending | ||
} | ||
|
||
unsafe fn nop_deallocate(ptr: NonNull<Header>) { | ||
unreachable!("stub task ({ptr:p}) should never be deallocated!"); | ||
} | ||
|
||
Self { vtable: &Vtable { poll: nop, deallocate: nop_deallocate } } | ||
} | ||
} | ||
|
||
// This is a public type in `maitake` | ||
#[repr(transparent)] | ||
#[cfg_attr(loom, allow(dead_code))] | ||
pub struct TaskStub { | ||
hdr: Header, | ||
} | ||
|
||
impl TaskStub { | ||
/// Create a new unique stub [`Task`]. | ||
pub const fn new() -> Self { | ||
Self { hdr: Header::new_stub() } | ||
} | ||
} |
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,9 @@ | ||
// build-pass | ||
// aux-build:issue-97708-aux.rs | ||
|
||
extern crate issue_97708_aux; | ||
use issue_97708_aux::TaskStub; | ||
|
||
static TASK_STUB: TaskStub = TaskStub::new(); | ||
|
||
fn main() {} |