Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #105328

Merged
merged 26 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
34de257
PERs are homogeneous
RalfJung Nov 25, 2022
71fd3ab
Don't update submodules for `x setup`
jyn514 Nov 26, 2022
86251da
Refactor `setup_config_toml` into a function
jyn514 Nov 26, 2022
b771d90
Revamp the order `setup` executes
jyn514 Nov 26, 2022
ab89c17
Ensure required submodules at the same time as updating existing subm…
jyn514 Nov 26, 2022
4c73b64
Use proper HirId for async track_caller attribute check
nbdd0121 Dec 2, 2022
ec4080b
Fix async track caller for assoc fn and trait impl fn
nbdd0121 Dec 2, 2022
3b4cbe9
add test for self-referential future
RalfJung Dec 3, 2022
3fa692c
for now, do not do fake reads on non-Unpin mutable references
RalfJung Dec 3, 2022
faec289
Auto merge of #2713 - RalfJung:not-unpin-fake-read, r=RalfJung
bors Dec 3, 2022
71cf892
std update libc version and freebsd image build dependencies
devnexen Dec 3, 2022
35c00a9
suggest parenthesis around ExprWithBlock BinOp ExprWithBlock
Dec 3, 2022
b151410
Skip recording resolution for duplicated generic params.
cjgillot Dec 3, 2022
c808d0b
more comments
Dec 3, 2022
34c3773
Add fixme note
nbdd0121 Dec 5, 2022
16a9fdf
Preparing for merge from rustc
RalfJung Dec 5, 2022
7481ba7
Merge from rustc
RalfJung Dec 5, 2022
552b63c
Auto merge of #2715 - RalfJung:rustup, r=RalfJung
bors Dec 5, 2022
8ad447c
Rollup merge of #104912 - RalfJung:per, r=Mark-Simulacrum
matthiaskrgr Dec 5, 2022
4b6010c
Rollup merge of #104952 - jyn514:setup, r=Mark-Simulacrum
matthiaskrgr Dec 5, 2022
f4643f5
Rollup merge of #104953 - jyn514:fewer-submodule-updates, r=Mark-Simu…
matthiaskrgr Dec 5, 2022
78cf0b9
Rollup merge of #105180 - nbdd0121:async_track_caller, r=compiler-errors
matthiaskrgr Dec 5, 2022
e84e8f4
Rollup merge of #105222 - devnexen:fbsd_update_img, r=petrochenkov
matthiaskrgr Dec 5, 2022
66a4cb5
Rollup merge of #105223 - lukas-code:(ExprWithBlock), r=petrochenkov
matthiaskrgr Dec 5, 2022
4ebbb20
Rollup merge of #105230 - cjgillot:issue-104312, r=petrochenkov
matthiaskrgr Dec 5, 2022
612e89a
Rollup merge of #105301 - RalfJung:miri, r=oli-obk
matthiaskrgr Dec 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use proper HirId for async track_caller attribute check
  • Loading branch information
nbdd0121 committed Dec 2, 2022
commit 4c73b646328d4adeb66fe67bae57c8206803eef8
30 changes: 16 additions & 14 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
),
ExprKind::Async(capture_clause, closure_node_id, block) => self.make_async_expr(
*capture_clause,
None,
*closure_node_id,
None,
e.span,
Expand Down Expand Up @@ -581,6 +582,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
pub(super) fn make_async_expr(
&mut self,
capture_clause: CaptureBy,
outer_hir_id: Option<hir::HirId>,
closure_node_id: NodeId,
ret_ty: Option<hir::FnRetTy<'hir>>,
span: Span,
Expand Down Expand Up @@ -647,18 +649,20 @@ impl<'hir> LoweringContext<'_, 'hir> {

hir::ExprKind::Closure(c)
};
let parent_has_track_caller = self
.attrs
.values()
.find(|attrs| attrs.into_iter().find(|attr| attr.has_name(sym::track_caller)).is_some())
.is_some();
let unstable_span =
self.mark_span_with_reason(DesugaringKind::Async, span, self.allow_gen_future.clone());

let hir_id = if parent_has_track_caller {
let generator_hir_id = self.lower_node_id(closure_node_id);
let track_caller = outer_hir_id
.and_then(|id| self.attrs.get(&id.local_id))
.map_or(false, |attrs| attrs.into_iter().any(|attr| attr.has_name(sym::track_caller)));

let hir_id = self.lower_node_id(closure_node_id);
if track_caller {
let unstable_span = self.mark_span_with_reason(
DesugaringKind::Async,
span,
self.allow_gen_future.clone(),
);
self.lower_attrs(
generator_hir_id,
hir_id,
&[Attribute {
kind: AttrKind::Normal(ptr::P(NormalAttr {
item: AttrItem {
Expand All @@ -673,10 +677,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
span: unstable_span,
}],
);
generator_hir_id
} else {
self.lower_node_id(closure_node_id)
};
}

let generator = hir::Expr { hir_id, kind: generator_kind, span: self.lower_span(span) };

Expand Down Expand Up @@ -1012,6 +1013,7 @@ impl<'hir> LoweringContext<'_, 'hir> {

let async_body = this.make_async_expr(
capture_clause,
None,
inner_closure_id,
async_ret_ty,
body.span,
Expand Down
24 changes: 18 additions & 6 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
// only cares about the input argument patterns in the function
// declaration (decl), not the return types.
let asyncness = header.asyncness;
let body_id =
this.lower_maybe_async_body(span, &decl, asyncness, body.as_deref());
let body_id = this.lower_maybe_async_body(
span,
hir_id,
&decl,
asyncness,
body.as_deref(),
);

let mut itctx = ImplTraitContext::Universal;
let (generics, decl) = this.lower_generics(generics, id, &mut itctx, |this| {
Expand Down Expand Up @@ -789,7 +794,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
AssocItemKind::Fn(box Fn { sig, generics, body: Some(body), .. }) => {
let asyncness = sig.header.asyncness;
let body_id =
self.lower_maybe_async_body(i.span, &sig.decl, asyncness, Some(&body));
self.lower_maybe_async_body(i.span, hir_id, &sig.decl, asyncness, Some(&body));
let (generics, sig) = self.lower_method_sig(
generics,
sig,
Expand Down Expand Up @@ -863,6 +868,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// Since `default impl` is not yet implemented, this is always true in impls.
let has_value = true;
let (defaultness, _) = self.lower_defaultness(i.kind.defaultness(), has_value);
let hir_id = self.lower_node_id(i.id);

let (generics, kind) = match &i.kind {
AssocItemKind::Const(_, ty, expr) => {
Expand All @@ -875,8 +881,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
AssocItemKind::Fn(box Fn { sig, generics, body, .. }) => {
self.current_item = Some(i.span);
let asyncness = sig.header.asyncness;
let body_id =
self.lower_maybe_async_body(i.span, &sig.decl, asyncness, body.as_deref());
let body_id = self.lower_maybe_async_body(
i.span,
hir_id,
&sig.decl,
asyncness,
body.as_deref(),
);
let (generics, sig) = self.lower_method_sig(
generics,
sig,
Expand Down Expand Up @@ -909,7 +920,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
AssocItemKind::MacCall(..) => panic!("`TyMac` should have been expanded by now"),
};

let hir_id = self.lower_node_id(i.id);
self.lower_attrs(hir_id, &i.attrs);
let item = hir::ImplItem {
owner_id: hir_id.expect_owner(),
Expand Down Expand Up @@ -1043,6 +1053,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn lower_maybe_async_body(
&mut self,
span: Span,
fn_id: hir::HirId,
decl: &FnDecl,
asyncness: Async,
body: Option<&Block>,
Expand Down Expand Up @@ -1193,6 +1204,7 @@ impl<'hir> LoweringContext<'_, 'hir> {

let async_expr = this.make_async_expr(
CaptureBy::Value,
Some(fn_id),
closure_id,
None,
body.span,
Expand Down
11 changes: 11 additions & 0 deletions src/test/ui/async-await/track-caller/issue-105134.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// check-pass
// edition:2021

#[track_caller]
fn f() {
let _ = async {};
}

fn main() {
f();
}