Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9f1bfe5

Browse files
committedDec 13, 2023
Auto merge of #118900 - workingjubilee:rollup-wkv9hq1, r=workingjubilee
Rollup of 10 pull requests Successful merges: - #118858 (Remove dead codes in core) - #118864 (Fix alignment passed down to LLVM for simd_masked_load) - #118872 (Add rustX check to codeblock attributes lint) - #118873 (fix `waker_getters` tracking issue number) - #118884 (NFC: simplify merging of two vecs) - #118885 (clippy::complexity fixes) - #118886 (Clean up variables in `search.js`) - #118887 (Typo) - #118889 (more clippy::complexity fixes) - #118891 (Actually parse async gen blocks correctly) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 77d1699 + f9078a4 commit 9f1bfe5

File tree

37 files changed

+307
-171
lines changed

37 files changed

+307
-171
lines changed
 

‎compiler/rustc_codegen_llvm/src/intrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1568,7 +1568,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
15681568

15691569
// Alignment of T, must be a constant integer value:
15701570
let alignment_ty = bx.type_i32();
1571-
let alignment = bx.const_i32(bx.align_of(values_ty).bytes() as i32);
1571+
let alignment = bx.const_i32(bx.align_of(values_elem).bytes() as i32);
15721572

15731573
// Truncate the mask vector to a vector of i1s:
15741574
let (mask, mask_ty) = {

‎compiler/rustc_const_eval/src/interpret/visitor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub trait ValueVisitor<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>: Sized {
2121
/// `read_discriminant` can be hooked for better error messages.
2222
#[inline(always)]
2323
fn read_discriminant(&mut self, v: &Self::V) -> InterpResult<'tcx, VariantIdx> {
24-
Ok(self.ecx().read_discriminant(&v.to_op(self.ecx())?)?)
24+
self.ecx().read_discriminant(&v.to_op(self.ecx())?)
2525
}
2626

2727
/// This function provides the chance to reorder the order in which fields are visited for

‎compiler/rustc_driver_impl/src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -587,10 +587,8 @@ fn show_md_content_with_pager(content: &str, color: ColorConfig) {
587587
let mut print_formatted = if pager_name == "less" {
588588
cmd.arg("-r");
589589
true
590-
} else if ["bat", "catbat", "delta"].iter().any(|v| *v == pager_name) {
591-
true
592590
} else {
593-
false
591+
["bat", "catbat", "delta"].iter().any(|v| *v == pager_name)
594592
};
595593

596594
if color == ColorConfig::Never {

‎compiler/rustc_hir_analysis/src/collect/item_bounds.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,14 @@ fn associated_type_bounds<'tcx>(
3434
let trait_def_id = tcx.local_parent(assoc_item_def_id);
3535
let trait_predicates = tcx.trait_explicit_predicates_and_bounds(trait_def_id);
3636

37-
let bounds_from_parent = trait_predicates
38-
.predicates
39-
.iter()
40-
.copied()
41-
.filter(|(pred, _)| match pred.kind().skip_binder() {
37+
let bounds_from_parent = trait_predicates.predicates.iter().copied().filter(|(pred, _)| {
38+
match pred.kind().skip_binder() {
4239
ty::ClauseKind::Trait(tr) => tr.self_ty() == item_ty,
4340
ty::ClauseKind::Projection(proj) => proj.projection_ty.self_ty() == item_ty,
4441
ty::ClauseKind::TypeOutlives(outlives) => outlives.0 == item_ty,
4542
_ => false,
46-
})
47-
.map(|(clause, span)| (clause, span));
43+
}
44+
});
4845

4946
let all_bounds = tcx.arena.alloc_from_iter(bounds.clauses().chain(bounds_from_parent));
5047
debug!(

‎compiler/rustc_hir_typeck/src/coercion.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
17011701
&& !ty.is_never()
17021702
{
17031703
let indentation = if let None = block.expr
1704-
&& let [.., last] = &block.stmts[..]
1704+
&& let [.., last] = &block.stmts
17051705
{
17061706
tcx.sess.source_map().indentation_before(last.span).unwrap_or_else(String::new)
17071707
} else if let Some(expr) = block.expr {
@@ -1710,7 +1710,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
17101710
String::new()
17111711
};
17121712
if let None = block.expr
1713-
&& let [.., last] = &block.stmts[..]
1713+
&& let [.., last] = &block.stmts
17141714
{
17151715
err.span_suggestion_verbose(
17161716
last.span.shrink_to_hi(),
@@ -1750,7 +1750,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
17501750
}
17511751
}
17521752
if let None = block.expr
1753-
&& let [.., last] = &block.stmts[..]
1753+
&& let [.., last] = &block.stmts
17541754
{
17551755
sugg.push((last.span.shrink_to_hi(), format!("\n{indentation}None")));
17561756
} else if let Some(expr) = block.expr {

‎compiler/rustc_hir_typeck/src/demand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
862862
mutability,
863863
),
864864
),
865-
match &args[..] {
865+
match &args {
866866
[] => (base.span.shrink_to_hi().with_hi(deref.span.hi()), ")".to_string()),
867867
[first, ..] => (base.span.between(first.span), ", ".to_string()),
868868
},

‎compiler/rustc_hir_typeck/src/upvar.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
315315
let final_tupled_upvars_type = Ty::new_tup(self.tcx, &final_upvar_tys);
316316
self.demand_suptype(span, args.tupled_upvars_ty(), final_tupled_upvars_type);
317317

318-
let fake_reads = delegate
319-
.fake_reads
320-
.into_iter()
321-
.map(|(place, cause, hir_id)| (place, cause, hir_id))
322-
.collect();
318+
let fake_reads = delegate.fake_reads;
319+
323320
self.typeck_results.borrow_mut().closure_fake_reads.insert(closure_def_id, fake_reads);
324321

325322
if self.tcx.sess.opts.unstable_opts.profile_closures {

‎compiler/rustc_infer/src/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2452,7 +2452,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
24522452

24532453
if !suggs.is_empty() {
24542454
err.multipart_suggestion_verbose(
2455-
format!("{msg}"),
2455+
msg,
24562456
suggs,
24572457
Applicability::MaybeIncorrect, // Issue #41966
24582458
);

‎compiler/rustc_mir_build/src/thir/pattern/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
174174
span: Span,
175175
) -> Result<PatKind<'tcx>, ErrorGuaranteed> {
176176
if lo_expr.is_none() && hi_expr.is_none() {
177-
let msg = format!("found twice-open range pattern (`..`) outside of error recovery");
177+
let msg = "found twice-open range pattern (`..`) outside of error recovery";
178178
return Err(self.tcx.sess.span_delayed_bug(span, msg));
179179
}
180180

‎compiler/rustc_mir_transform/src/jump_threading.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ impl OpportunitySet {
649649

650650
// `succ` must be a successor of `current`. If it is not, this means this TO is not
651651
// satisfiable and a previous TO erased this edge, so we bail out.
652-
if basic_blocks[current].terminator().successors().find(|s| *s == succ).is_none() {
652+
if !basic_blocks[current].terminator().successors().any(|s| s == succ) {
653653
debug!("impossible");
654654
return;
655655
}

‎compiler/rustc_parse/src/parser/expr.rs

+18-9
Original file line numberDiff line numberDiff line change
@@ -1440,21 +1440,23 @@ impl<'a> Parser<'a> {
14401440
} else if this.eat_keyword(kw::Underscore) {
14411441
Ok(this.mk_expr(this.prev_token.span, ExprKind::Underscore))
14421442
} else if this.token.uninterpolated_span().at_least_rust_2018() {
1443-
// `Span:.at_least_rust_2018()` is somewhat expensive; don't get it repeatedly.
1444-
if this.check_keyword(kw::Async) {
1443+
// `Span::at_least_rust_2018()` is somewhat expensive; don't get it repeatedly.
1444+
if this.token.uninterpolated_span().at_least_rust_2024()
1445+
// check for `gen {}` and `gen move {}`
1446+
// or `async gen {}` and `async gen move {}`
1447+
&& (this.is_gen_block(kw::Gen, 0)
1448+
|| (this.check_keyword(kw::Async) && this.is_gen_block(kw::Gen, 1)))
1449+
{
1450+
// FIXME: (async) gen closures aren't yet parsed.
1451+
this.parse_gen_block()
1452+
} else if this.check_keyword(kw::Async) {
14451453
// FIXME(gen_blocks): Parse `gen async` and suggest swap
14461454
if this.is_gen_block(kw::Async, 0) {
14471455
// Check for `async {` and `async move {`,
1448-
// or `async gen {` and `async gen move {`.
14491456
this.parse_gen_block()
14501457
} else {
14511458
this.parse_expr_closure()
14521459
}
1453-
} else if this.token.uninterpolated_span().at_least_rust_2024()
1454-
&& (this.is_gen_block(kw::Gen, 0)
1455-
|| (this.check_keyword(kw::Async) && this.is_gen_block(kw::Gen, 1)))
1456-
{
1457-
this.parse_gen_block()
14581460
} else if this.eat_keyword_noexpect(kw::Await) {
14591461
this.recover_incorrect_await_syntax(lo, this.prev_token.span)
14601462
} else {
@@ -3227,9 +3229,16 @@ impl<'a> Parser<'a> {
32273229
if self.eat_keyword(kw::Gen) { GenBlockKind::AsyncGen } else { GenBlockKind::Async }
32283230
} else {
32293231
assert!(self.eat_keyword(kw::Gen));
3230-
self.sess.gated_spans.gate(sym::gen_blocks, lo.to(self.token.span));
32313232
GenBlockKind::Gen
32323233
};
3234+
match kind {
3235+
GenBlockKind::Async => {
3236+
// `async` blocks are stable
3237+
}
3238+
GenBlockKind::Gen | GenBlockKind::AsyncGen => {
3239+
self.sess.gated_spans.gate(sym::gen_blocks, lo.to(self.prev_token.span));
3240+
}
3241+
}
32333242
let capture_clause = self.parse_capture_clause()?;
32343243
let (attrs, body) = self.parse_inner_attrs_and_block()?;
32353244
let kind = ExprKind::Gen(capture_clause, body, kind);

‎compiler/rustc_pattern_analysis/src/constructor.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,8 @@ impl ConstructorSet {
979979
&& !(pcx.is_top_level && matches!(self, Self::NoConstructors))
980980
{
981981
// Treat all missing constructors as nonempty.
982-
missing.extend(missing_empty.drain(..));
982+
// This clears `missing_empty`.
983+
missing.append(&mut missing_empty);
983984
}
984985

985986
SplitConstructorSet { present, missing, missing_empty }

‎compiler/rustc_query_system/src/dep_graph/serialized.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const DEP_NODE_PAD: usize = DEP_NODE_SIZE - 1;
7070
const DEP_NODE_WIDTH_BITS: usize = DEP_NODE_SIZE / 2;
7171

7272
/// Data for use when recompiling the **current crate**.
73-
#[derive(Debug)]
73+
#[derive(Debug, Default)]
7474
pub struct SerializedDepGraph {
7575
/// The set of all DepNodes in the graph
7676
nodes: IndexVec<SerializedDepNodeIndex, DepNode>,
@@ -89,18 +89,6 @@ pub struct SerializedDepGraph {
8989
index: Vec<UnhashMap<PackedFingerprint, SerializedDepNodeIndex>>,
9090
}
9191

92-
impl Default for SerializedDepGraph {
93-
fn default() -> Self {
94-
SerializedDepGraph {
95-
nodes: Default::default(),
96-
fingerprints: Default::default(),
97-
edge_list_indices: Default::default(),
98-
edge_list_data: Default::default(),
99-
index: Default::default(),
100-
}
101-
}
102-
}
103-
10492
impl SerializedDepGraph {
10593
#[inline]
10694
pub fn edge_targets_from(

‎compiler/rustc_resolve/src/imports.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1063,12 +1063,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
10631063
initial_binding.res()
10641064
});
10651065
let res = binding.res();
1066-
let has_ambiguity_error = this
1067-
.ambiguity_errors
1068-
.iter()
1069-
.filter(|error| !error.warning)
1070-
.next()
1071-
.is_some();
1066+
let has_ambiguity_error =
1067+
this.ambiguity_errors.iter().any(|error| !error.warning);
10721068
if res == Res::Err || has_ambiguity_error {
10731069
this.tcx
10741070
.sess

‎compiler/rustc_resolve/src/late/diagnostics.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -1829,13 +1829,12 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
18291829
)
18301830
.iter()
18311831
.filter_map(|candidate| candidate.did)
1832-
.filter(|did| {
1832+
.find(|did| {
18331833
self.r
18341834
.tcx
18351835
.get_attrs(*did, sym::rustc_diagnostic_item)
18361836
.any(|attr| attr.value_str() == Some(sym::Default))
1837-
})
1838-
.next();
1837+
});
18391838
let Some(default_trait) = default_trait else {
18401839
return;
18411840
};
@@ -1880,11 +1879,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
18801879
};
18811880

18821881
fields.is_some_and(|fields| {
1883-
fields
1884-
.iter()
1885-
.filter(|vis| !self.r.is_accessible_from(**vis, self.parent_scope.module))
1886-
.next()
1887-
.is_some()
1882+
fields.iter().any(|vis| !self.r.is_accessible_from(*vis, self.parent_scope.module))
18881883
})
18891884
}
18901885

@@ -2178,7 +2173,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
21782173
let (span, text) = match path.segments.first() {
21792174
Some(seg) if let Some(name) = seg.ident.as_str().strip_prefix("let") => {
21802175
// a special case for #117894
2181-
let name = name.strip_prefix("_").unwrap_or(name);
2176+
let name = name.strip_prefix('_').unwrap_or(name);
21822177
(ident_span, format!("let {name}"))
21832178
}
21842179
_ => (ident_span.shrink_to_lo(), "let ".to_string()),

‎compiler/rustc_smir/src/rustc_smir/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
157157
(name == crate_name).then(|| smir_crate(tables.tcx, *crate_num))
158158
})
159159
.into_iter()
160-
.filter_map(|c| c)
160+
.flatten()
161161
.collect();
162162
crates
163163
}

‎compiler/rustc_smir/src/rustc_smir/convert/mir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ impl<'tcx> Stable<'tcx> for rustc_middle::mir::Const<'tcx> {
707707
let id = tables.intern_const(*self);
708708
Const::new(kind, ty, id)
709709
}
710-
mir::Const::Val(val, ty) if matches!(val, mir::ConstValue::ZeroSized) => {
710+
mir::Const::Val(mir::ConstValue::ZeroSized, ty) => {
711711
let ty = ty.stable(tables);
712712
let id = tables.intern_const(*self);
713713
Const::new(ConstantKind::ZeroSized, ty, id)

‎compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ fn encode_ty_name(tcx: TyCtxt<'_>, def_id: DefId) -> String {
364364
// _ZTSFvu27NvNtC1234_5crate6Trait13fooIu22NtC1234_5crate7Struct1Iu3i32ES_EE
365365
//
366366
// The reason for not using v0's extended form of paths is to use a consistent and simpler
367-
// encoding, as the reasoning for using it isn't relevand for type metadata identifiers (i.e.,
367+
// encoding, as the reasoning for using it isn't relevant for type metadata identifiers (i.e.,
368368
// keep symbol names close to how methods are represented in error messages). See
369369
// https://rust-lang.github.io/rfcs/2603-rust-symbol-name-mangling-v0.html#methods.
370370
let mut s = String::new();

‎compiler/rustc_trait_selection/src/infer.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,10 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
101101
self.tcx.impl_trait_ref(impl_def_id).map(|r| (impl_def_id, r))
102102
})
103103
.map(|(impl_def_id, imp)| (impl_def_id, imp.skip_binder()))
104-
.filter(|(_, imp)| match imp.self_ty().peel_refs().kind() {
104+
.find(|(_, imp)| match imp.self_ty().peel_refs().kind() {
105105
ty::Adt(i_def, _) if i_def.did() == def.did() => true,
106106
_ => false,
107107
})
108-
.next()
109108
{
110109
let mut fulfill_cx = FulfillmentCtxt::new(self);
111110
// We get all obligations from the impl to talk about specific

‎compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2167,7 +2167,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
21672167
})
21682168
.collect();
21692169
err.multipart_suggestion(
2170-
format!("consider wrapping the function in a closure"),
2170+
"consider wrapping the function in a closure",
21712171
vec![
21722172
(arg.span.shrink_to_lo(), format!("|{}| ", closure_names.join(", "))),
21732173
(arg.span.shrink_to_hi(), format!("({})", call_names.join(", "))),

‎compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
10691069
if !self.tcx.is_diagnostic_item(sym::Result, def.did()) {
10701070
return None;
10711071
}
1072-
Some(arg.as_type()?)
1072+
arg.as_type()
10731073
};
10741074

10751075
let mut suggested = false;

‎library/core/src/fmt/num.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ trait DisplayInt:
1515
fn zero() -> Self;
1616
fn from_u8(u: u8) -> Self;
1717
fn to_u8(&self) -> u8;
18-
fn to_u16(&self) -> u16;
18+
#[cfg(not(any(target_pointer_width = "64", target_arch = "wasm32")))]
1919
fn to_u32(&self) -> u32;
2020
fn to_u64(&self) -> u64;
2121
fn to_u128(&self) -> u128;
@@ -27,7 +27,7 @@ macro_rules! impl_int {
2727
fn zero() -> Self { 0 }
2828
fn from_u8(u: u8) -> Self { u as Self }
2929
fn to_u8(&self) -> u8 { *self as u8 }
30-
fn to_u16(&self) -> u16 { *self as u16 }
30+
#[cfg(not(any(target_pointer_width = "64", target_arch = "wasm32")))]
3131
fn to_u32(&self) -> u32 { *self as u32 }
3232
fn to_u64(&self) -> u64 { *self as u64 }
3333
fn to_u128(&self) -> u128 { *self as u128 }
@@ -40,7 +40,7 @@ macro_rules! impl_uint {
4040
fn zero() -> Self { 0 }
4141
fn from_u8(u: u8) -> Self { u as Self }
4242
fn to_u8(&self) -> u8 { *self as u8 }
43-
fn to_u16(&self) -> u16 { *self as u16 }
43+
#[cfg(not(any(target_pointer_width = "64", target_arch = "wasm32")))]
4444
fn to_u32(&self) -> u32 { *self as u32 }
4545
fn to_u64(&self) -> u64 { *self as u64 }
4646
fn to_u128(&self) -> u128 { *self as u128 }

‎library/core/src/task/wake.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ impl RawWaker {
4848
/// Get the `data` pointer used to create this `RawWaker`.
4949
#[inline]
5050
#[must_use]
51-
#[unstable(feature = "waker_getters", issue = "87021")]
51+
#[unstable(feature = "waker_getters", issue = "96992")]
5252
pub fn data(&self) -> *const () {
5353
self.data
5454
}
5555

5656
/// Get the `vtable` pointer used to create this `RawWaker`.
5757
#[inline]
5858
#[must_use]
59-
#[unstable(feature = "waker_getters", issue = "87021")]
59+
#[unstable(feature = "waker_getters", issue = "96992")]
6060
pub fn vtable(&self) -> &'static RawWakerVTable {
6161
self.vtable
6262
}
@@ -371,7 +371,7 @@ impl Waker {
371371
/// Get a reference to the underlying [`RawWaker`].
372372
#[inline]
373373
#[must_use]
374-
#[unstable(feature = "waker_getters", issue = "87021")]
374+
#[unstable(feature = "waker_getters", issue = "96992")]
375375
pub fn as_raw(&self) -> &RawWaker {
376376
&self.waker
377377
}
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.