Fix async track caller for assoc fn and trait impl fn
This commit is contained in:
parent
4c73b64632
commit
ec4080b236
2 changed files with 16 additions and 2 deletions
|
@ -771,6 +771,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
|
|
||||||
fn lower_trait_item(&mut self, i: &AssocItem) -> &'hir hir::TraitItem<'hir> {
|
fn lower_trait_item(&mut self, i: &AssocItem) -> &'hir hir::TraitItem<'hir> {
|
||||||
let hir_id = self.lower_node_id(i.id);
|
let hir_id = self.lower_node_id(i.id);
|
||||||
|
self.lower_attrs(hir_id, &i.attrs);
|
||||||
let trait_item_def_id = hir_id.expect_owner();
|
let trait_item_def_id = hir_id.expect_owner();
|
||||||
|
|
||||||
let (generics, kind, has_default) = match &i.kind {
|
let (generics, kind, has_default) = match &i.kind {
|
||||||
|
@ -829,7 +830,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
AssocItemKind::MacCall(..) => panic!("macro item shouldn't exist at this point"),
|
AssocItemKind::MacCall(..) => panic!("macro item shouldn't exist at this point"),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.lower_attrs(hir_id, &i.attrs);
|
|
||||||
let item = hir::TraitItem {
|
let item = hir::TraitItem {
|
||||||
owner_id: trait_item_def_id,
|
owner_id: trait_item_def_id,
|
||||||
ident: self.lower_ident(i.ident),
|
ident: self.lower_ident(i.ident),
|
||||||
|
@ -869,6 +869,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
let has_value = true;
|
let has_value = true;
|
||||||
let (defaultness, _) = self.lower_defaultness(i.kind.defaultness(), has_value);
|
let (defaultness, _) = self.lower_defaultness(i.kind.defaultness(), has_value);
|
||||||
let hir_id = self.lower_node_id(i.id);
|
let hir_id = self.lower_node_id(i.id);
|
||||||
|
self.lower_attrs(hir_id, &i.attrs);
|
||||||
|
|
||||||
let (generics, kind) = match &i.kind {
|
let (generics, kind) = match &i.kind {
|
||||||
AssocItemKind::Const(_, ty, expr) => {
|
AssocItemKind::Const(_, ty, expr) => {
|
||||||
|
@ -920,7 +921,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
AssocItemKind::MacCall(..) => panic!("`TyMac` should have been expanded by now"),
|
AssocItemKind::MacCall(..) => panic!("`TyMac` should have been expanded by now"),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.lower_attrs(hir_id, &i.attrs);
|
|
||||||
let item = hir::ImplItem {
|
let item = hir::ImplItem {
|
||||||
owner_id: hir_id.expect_owner(),
|
owner_id: hir_id.expect_owner(),
|
||||||
ident: self.lower_ident(i.ident),
|
ident: self.lower_ident(i.ident),
|
||||||
|
|
|
@ -54,6 +54,19 @@ async fn foo_track_caller() {
|
||||||
bar_track_caller().await
|
bar_track_caller().await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Foo;
|
||||||
|
|
||||||
|
impl Foo {
|
||||||
|
#[track_caller]
|
||||||
|
async fn bar_assoc() {
|
||||||
|
panic!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn foo_assoc() {
|
||||||
|
Foo::bar_assoc().await
|
||||||
|
}
|
||||||
|
|
||||||
fn panicked_at(f: impl FnOnce() + panic::UnwindSafe) -> u32 {
|
fn panicked_at(f: impl FnOnce() + panic::UnwindSafe) -> u32 {
|
||||||
let loc = Arc::new(Mutex::new(None));
|
let loc = Arc::new(Mutex::new(None));
|
||||||
|
|
||||||
|
@ -73,4 +86,5 @@ fn panicked_at(f: impl FnOnce() + panic::UnwindSafe) -> u32 {
|
||||||
fn main() {
|
fn main() {
|
||||||
assert_eq!(panicked_at(|| block_on(foo())), 41);
|
assert_eq!(panicked_at(|| block_on(foo())), 41);
|
||||||
assert_eq!(panicked_at(|| block_on(foo_track_caller())), 54);
|
assert_eq!(panicked_at(|| block_on(foo_track_caller())), 54);
|
||||||
|
assert_eq!(panicked_at(|| block_on(foo_assoc())), 67);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue