Skip to content

Rollup of 9 pull requests #104256

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

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0c158f0
Add a test case for #[track_caller] on async fn
eholk Oct 10, 2022
3db41d1
wip: trying to enable #[track_caller] on async fn
eholk Oct 11, 2022
8e0cac1
rustdoc: refactor `notable_traits_decl` to just act on the type directly
notriddle Nov 7, 2022
303653e
rustdoc: use javascript to layout notable traits popups
notriddle Nov 7, 2022
a45151e
rustdoc: fix font color inheritance from body, and test
notriddle Nov 8, 2022
9bcc083
run-make-fulldeps: fix split debuginfo test
davidtwco Nov 7, 2022
29dc083
llvm: dwo only emitted when object code emitted
davidtwco Nov 7, 2022
0e0bcd9
prevent uninitialized access in black_box for zero-sized-types
krasimirgg Nov 4, 2022
06a77af
Add retry flag to remote-test-server
Ayush1325 Nov 8, 2022
76cab67
Add domain size check to fix ICE
camsteffen Nov 9, 2022
bdced83
Use ObligationCtxt in expected_inputs_for_expected_outputs
compiler-errors Nov 9, 2022
07a47e0
Emit error in `collecting_trait_impl_trait_tys` on mismatched signatures
Noratrieb Nov 9, 2022
53e8b49
rustdoc: sort output to make it deterministic
notriddle Nov 9, 2022
ed6a7cc
Remove save_and_restore_in_snapshot_flag
compiler-errors Nov 9, 2022
63217e0
make dropck_outlives into a proper canonicalized type query
compiler-errors Nov 9, 2022
fa99cb8
Allow and add `track_caller` to generators
bryangarza Nov 8, 2022
509b947
Refactor nested for-loops into find() calls
bryangarza Nov 10, 2022
3074678
Mark `trait_upcasting` feature no longer incomplete.
crlf0710 Nov 7, 2022
0a7dfb2
Rollup merge of #104105 - davidtwco:split-dwarf-lto, r=michaelwoerister
Manishearth Nov 10, 2022
5272d90
Rollup merge of #104110 - krasimirgg:msan-16, r=nagisa
Manishearth Nov 10, 2022
bb4128b
Rollup merge of #104117 - crlf0710:update_feature_gate, r=jackh726
Manishearth Nov 10, 2022
e28498e
Rollup merge of #104129 - notriddle:notriddle/102576-js-notable-trait…
Manishearth Nov 10, 2022
a969253
Rollup merge of #104146 - Ayush1325:remote-test-server, r=jyn514
Manishearth Nov 10, 2022
f1d08bc
Rollup merge of #104202 - camsteffen:103748, r=estebank
Manishearth Nov 10, 2022
7a89b05
Rollup merge of #104206 - compiler-errors:ocx-more-2, r=lcnr
Manishearth Nov 10, 2022
3cc4389
Rollup merge of #104214 - Nilstrieb:returns_impl_Ice, r=compiler-errors
Manishearth Nov 10, 2022
c4561fc
Rollup merge of #104219 - bryangarza:async-track-caller-dup, r=eholk
Manishearth Nov 10, 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
Allow and add track_caller to generators
This patch allows the usage of the `track_caller` annotation on
generators, as well as sets them conditionally if the parent also has
`track_caller` set.

Also add this annotation on the `GenFuture`'s `poll()` function.
  • Loading branch information
bryangarza committed Nov 9, 2022
commit fa99cb82690d99c0df2018d37aedaed29e40e131
60 changes: 37 additions & 23 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,33 +617,47 @@ impl<'hir> LoweringContext<'_, 'hir> {

hir::ExprKind::Closure(c)
};
let generator_hir_id = self.lower_node_id(closure_node_id);
// FIXME: only add track caller if the parent is track_caller
self.lower_attrs(
generator_hir_id,
&[Attribute {
kind: AttrKind::Normal(ptr::P(NormalAttr {
item: AttrItem {
path: Path::from_ident(Ident::new(sym::track_caller, span)),
args: MacArgs::Empty,
let mut parent_has_track_caller = false;
for attrs in self.attrs.values() {
for attr in attrs.into_iter() {
if attr.has_name(sym::track_caller) {
parent_has_track_caller = true;
break;
}
}
if parent_has_track_caller {
break;
}
}
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);
self.lower_attrs(
generator_hir_id,
&[Attribute {
kind: AttrKind::Normal(ptr::P(NormalAttr {
item: AttrItem {
path: Path::from_ident(Ident::new(sym::track_caller, span)),
args: MacArgs::Empty,
tokens: None,
},
tokens: None,
},
tokens: None,
})),
id: self.tcx.sess.parse_sess.attr_id_generator.mk_attr_id(),
style: AttrStyle::Outer,
span,
}],
);
let generator = hir::Expr {
hir_id: generator_hir_id,
kind: generator_kind,
span: self.lower_span(span),
})),
id: self.tcx.sess.parse_sess.attr_id_generator.mk_attr_id(),
style: AttrStyle::Outer,
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) };

// `future::from_generator`:
let unstable_span =
self.mark_span_with_reason(DesugaringKind::Async, span, self.allow_gen_future.clone());
let gen_future = self.expr_lang_item_path(
unstable_span,
hir::LangItem::FromGenerator,
Expand Down
1 change: 1 addition & 0 deletions library/core/src/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ where

impl<T: Generator<ResumeTy, Yield = ()>> Future for GenFuture<T> {
type Output = T::Return;
#[track_caller]
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
// SAFETY: Safe because we're !Unpin + !Drop, and this is just a field projection.
let gen = unsafe { Pin::map_unchecked_mut(self, |s| &mut s.0) };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ fn panicked_at(f: impl FnOnce() + panic::UnwindSafe) -> u32 {
}

fn main() {
assert_eq!(panicked_at(|| block_on(foo())), 39);
assert_eq!(panicked_at(|| block_on(foo_track_caller())), 52);
assert_eq!(panicked_at(|| block_on(foo())), 40);
assert_eq!(panicked_at(|| block_on(foo_track_caller())), 53);
}