Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ce67033

Browse files
committed
Auto merge of rust-lang#118771 - workingjubilee:rollup-q1p3riz, r=workingjubilee
Rollup of 7 pull requests Successful merges: - rust-lang#118198 (coverage: Use `SpanMarker` to improve coverage spans for `if !` expressions) - rust-lang#118512 (Add tests related to normalization in implied bounds) - rust-lang#118610 (update target feature following LLVM API change) - rust-lang#118666 (coverage: Simplify the heuristic for ignoring `async fn` return spans) - rust-lang#118737 (Extend tidy alphabetical checking to `tests/`.) - rust-lang#118762 (Some more minor `async gen`-related nits) - rust-lang#118764 (Make async generators fused by default) r? `@ghost` `@rustbot` modify labels: rollup
2 parents c416699 + 61dfb1f commit ce67033

File tree

38 files changed

+543
-111
lines changed

38 files changed

+543
-111
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2450,6 +2450,14 @@ impl CoroutineKind {
24502450
matches!(self, CoroutineKind::Gen { .. })
24512451
}
24522452

2453+
pub fn closure_id(self) -> NodeId {
2454+
match self {
2455+
CoroutineKind::Async { closure_id, .. }
2456+
| CoroutineKind::Gen { closure_id, .. }
2457+
| CoroutineKind::AsyncGen { closure_id, .. } => closure_id,
2458+
}
2459+
}
2460+
24532461
/// In this case this is an `async` or `gen` return, the `NodeId` for the generated `impl Trait`
24542462
/// item.
24552463
pub fn return_id(self) -> (NodeId, Span) {

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,10 +1035,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10351035
let (Some(coroutine_kind), Some(body)) = (coroutine_kind, body) else {
10361036
return self.lower_fn_body_block(span, decl, body);
10371037
};
1038-
// FIXME(gen_blocks): Introduce `closure_id` method and remove ALL destructuring.
1039-
let (CoroutineKind::Async { closure_id, .. }
1040-
| CoroutineKind::Gen { closure_id, .. }
1041-
| CoroutineKind::AsyncGen { closure_id, .. }) = coroutine_kind;
1038+
let closure_id = coroutine_kind.closure_id();
10421039

10431040
self.lower_body(|this| {
10441041
let mut parameters: Vec<hir::Param<'_>> = Vec::new();

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
177177
} else {
178178
[sym::gen_future].into()
179179
},
180-
// FIXME(gen_blocks): how does `closure_track_caller`
180+
// FIXME(gen_blocks): how does `closure_track_caller`/`async_fn_track_caller`
181+
// interact with `gen`/`async gen` blocks
181182
allow_async_iterator: [sym::gen_future, sym::async_iterator].into(),
182183
generics_def_id_map: Default::default(),
183184
host_param_id: None,

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,11 +1271,11 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
12711271
// Functions cannot both be `const async` or `const gen`
12721272
if let Some(&FnHeader {
12731273
constness: Const::Yes(cspan),
1274-
coroutine_kind: Some(coro_kind),
1274+
coroutine_kind: Some(coroutine_kind),
12751275
..
12761276
}) = fk.header()
12771277
{
1278-
let aspan = match coro_kind {
1278+
let aspan = match coroutine_kind {
12791279
CoroutineKind::Async { span: aspan, .. }
12801280
| CoroutineKind::Gen { span: aspan, .. }
12811281
| CoroutineKind::AsyncGen { span: aspan, .. } => aspan,

compiler/rustc_builtin_macros/src/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,8 @@ fn check_test_signature(
541541
return Err(sd.emit_err(errors::TestBadFn { span: i.span, cause: span, kind: "unsafe" }));
542542
}
543543

544-
if let Some(coro_kind) = f.sig.header.coroutine_kind {
545-
match coro_kind {
544+
if let Some(coroutine_kind) = f.sig.header.coroutine_kind {
545+
match coroutine_kind {
546546
ast::CoroutineKind::Async { span, .. } => {
547547
return Err(sd.emit_err(errors::TestBadFn {
548548
span: i.span,

compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
100100

101101
let Coverage { kind } = coverage;
102102
match *kind {
103+
// Span markers are only meaningful during MIR instrumentation,
104+
// and have no effect during codegen.
105+
CoverageKind::SpanMarker => {}
103106
CoverageKind::CounterIncrement { id } => {
104107
func_coverage.mark_counter_id_seen(id);
105108
// We need to explicitly drop the `RefMut` before calling into `instrprof_increment`,

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> LLVMFeature<'a> {
263263
"sve2-bitperm",
264264
TargetFeatureFoldStrength::EnableOnly("neon"),
265265
),
266+
// The unaligned-scalar-mem feature was renamed to fast-unaligned-access.
267+
("riscv32" | "riscv64", "fast-unaligned-access") if get_version().0 <= 17 => {
268+
LLVMFeature::new("unaligned-scalar-mem")
269+
}
266270
(_, s) => LLVMFeature::new(s),
267271
}
268272
}

compiler/rustc_codegen_ssa/src/target_features.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ const RISCV_ALLOWED_FEATURES: &[(&str, Stability)] = &[
291291
("d", Unstable(sym::riscv_target_feature)),
292292
("e", Unstable(sym::riscv_target_feature)),
293293
("f", Unstable(sym::riscv_target_feature)),
294+
("fast-unaligned-access", Unstable(sym::riscv_target_feature)),
294295
("m", Stable),
295296
("relax", Unstable(sym::riscv_target_feature)),
296-
("unaligned-scalar-mem", Unstable(sym::riscv_target_feature)),
297297
("v", Unstable(sym::riscv_target_feature)),
298298
("zba", Stable),
299299
("zbb", Stable),

compiler/rustc_lint/src/early.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,8 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
162162
// Explicitly check for lints associated with 'closure_id', since
163163
// it does not have a corresponding AST node
164164
if let ast_visit::FnKind::Fn(_, _, sig, _, _, _) = fk {
165-
if let Some(coro_kind) = sig.header.coroutine_kind {
166-
let (ast::CoroutineKind::Async { closure_id, .. }
167-
| ast::CoroutineKind::Gen { closure_id, .. }
168-
| ast::CoroutineKind::AsyncGen { closure_id, .. }) = coro_kind;
169-
self.check_id(closure_id);
165+
if let Some(coroutine_kind) = sig.header.coroutine_kind {
166+
self.check_id(coroutine_kind.closure_id());
170167
}
171168
}
172169
}
@@ -226,12 +223,10 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
226223
// it does not have a corresponding AST node
227224
match e.kind {
228225
ast::ExprKind::Closure(box ast::Closure {
229-
coroutine_kind: Some(coro_kind), ..
226+
coroutine_kind: Some(coroutine_kind),
227+
..
230228
}) => {
231-
let (ast::CoroutineKind::Async { closure_id, .. }
232-
| ast::CoroutineKind::Gen { closure_id, .. }
233-
| ast::CoroutineKind::AsyncGen { closure_id, .. }) = coro_kind;
234-
self.check_id(closure_id);
229+
self.check_id(coroutine_kind.closure_id());
235230
}
236231
_ => {}
237232
}

compiler/rustc_middle/src/mir/coverage.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ impl Debug for CovTerm {
7676

7777
#[derive(Clone, PartialEq, TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
7878
pub enum CoverageKind {
79+
/// Marks a span that might otherwise not be represented in MIR, so that
80+
/// coverage instrumentation can associate it with its enclosing block/BCB.
81+
///
82+
/// Only used by the `InstrumentCoverage` pass, and has no effect during
83+
/// codegen.
84+
SpanMarker,
85+
7986
/// Marks the point in MIR control flow represented by a coverage counter.
8087
///
8188
/// This is eventually lowered to `llvm.instrprof.increment` in LLVM IR.
@@ -99,6 +106,7 @@ impl Debug for CoverageKind {
99106
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
100107
use CoverageKind::*;
101108
match self {
109+
SpanMarker => write!(fmt, "SpanMarker"),
102110
CounterIncrement { id } => write!(fmt, "CounterIncrement({:?})", id.index()),
103111
ExpressionUsed { id } => write!(fmt, "ExpressionUsed({:?})", id.index()),
104112
}

0 commit comments

Comments
 (0)