Skip to content

Commit 2a280de

Browse files
committed
Auto merge of #94514 - matthiaskrgr:rollup-pdzn82h, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #94464 (Suggest adding a new lifetime parameter when two elided lifetimes should match up for traits and impls.) - #94476 (7 - Make more use of `let_chains`) - #94478 (Fix panic when handling intra doc links generated from macro) - #94482 (compiler: fix some typos) - #94490 (Update books) - #94496 (tests: accept llvm intrinsic in align-checking test) - #94498 (9 - Make more use of `let_chains`) - #94503 (Provide C FFI types via core::ffi, not just in std) - #94513 (update Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 39a3b52 + e89ab08 commit 2a280de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+873
-567
lines changed

compiler/rustc_ast_lowering/src/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
13661366
generics: &Generics,
13671367
itctx: ImplTraitContext<'_, 'hir>,
13681368
) -> GenericsCtor<'hir> {
1369-
// Error if `?Trait` bounds in where clauses don't refer directly to type paramters.
1369+
// Error if `?Trait` bounds in where clauses don't refer directly to type parameters.
13701370
// Note: we used to clone these bounds directly onto the type parameter (and avoid lowering
13711371
// these into hir when we lower thee where clauses), but this makes it quite difficult to
13721372
// keep track of the Span info. Now, `add_implicitly_sized` in `AstConv` checks both param bounds and

compiler/rustc_borrowck/src/region_infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1992,7 +1992,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
19921992
.find_map(|constraint| {
19931993
if let ConstraintCategory::Predicate(predicate_span) = constraint.category {
19941994
// We currentl'y doesn't store the `DefId` in the `ConstraintCategory`
1995-
// for perforamnce reasons. The error reporting code used by NLL only
1995+
// for performances reasons. The error reporting code used by NLL only
19961996
// uses the span, so this doesn't cause any problems at the moment.
19971997
Some(ObligationCauseCode::BindingObligation(
19981998
CRATE_DEF_ID.to_def_id(),

compiler/rustc_builtin_macros/src/cfg_eval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl CfgEval<'_, '_> {
201201

202202
// Re-parse the tokens, setting the `capture_cfg` flag to save extra information
203203
// to the captured `AttrAnnotatedTokenStream` (specifically, we capture
204-
// `AttrAnnotatedTokenTree::AttributesData` for all occurences of `#[cfg]` and `#[cfg_attr]`)
204+
// `AttrAnnotatedTokenTree::AttributesData` for all occurrences of `#[cfg]` and `#[cfg_attr]`)
205205
let mut parser =
206206
rustc_parse::stream_to_parser(&self.cfg.sess.parse_sess, orig_tokens, None);
207207
parser.capture_cfg = true;

compiler/rustc_codegen_ssa/src/back/link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
989989

990990
// ... and otherwise we're processing a `*.dwp` packed dwarf file.
991991
//
992-
// We cannot rely on the .o paths in the exectuable because they may have been
992+
// We cannot rely on the .o paths in the executable because they may have been
993993
// remapped by --remap-path-prefix and therefore invalid, so we need to provide
994994
// the .o/.dwo paths explicitly.
995995
SplitDebuginfo::Packed => link_dwarf_object(sess, codegen_results, out_filename),

compiler/rustc_codegen_ssa/src/back/linker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ impl<'a> Linker for WasmLd<'a> {
13381338
}
13391339

13401340
// LLD will hide these otherwise-internal symbols since it only exports
1341-
// symbols explicity passed via the `--export` flags above and hides all
1341+
// symbols explicitly passed via the `--export` flags above and hides all
13421342
// others. Various bits and pieces of tooling use this, so be sure these
13431343
// symbols make their way out of the linker as well.
13441344
self.cmd.arg("--export=__heap_base");

compiler/rustc_data_structures/src/sso/either_iter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::iter::Iterator;
77
/// one of two specific implementations.
88
///
99
/// Note: For most methods providing custom
10-
/// implementation may margianlly
10+
/// implementation may marginally
1111
/// improve performance by avoiding
1212
/// doing Left/Right match on every step
1313
/// and doing it only once instead.

compiler/rustc_hir/src/definitions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl DefPathTable {
5050
// Continuing with colliding DefPathHashes can lead to correctness
5151
// issues. We must abort compilation.
5252
//
53-
// The likelyhood of such a collision is very small, so actually
53+
// The likelihood of such a collision is very small, so actually
5454
// running into one could be indicative of a poor hash function
5555
// being used.
5656
//

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs

+54-52
Original file line numberDiff line numberDiff line change
@@ -166,59 +166,61 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
166166
if lifetime_sub.name.is_elided() && lifetime_sup.name.is_elided() {
167167
if let Some(anon_reg) = self.tcx().is_suitable_region(sub) {
168168
let hir_id = self.tcx().hir().local_def_id_to_hir_id(anon_reg.def_id);
169-
if let hir::Node::Item(&hir::Item {
170-
kind: hir::ItemKind::Fn(_, ref generics, ..),
171-
..
172-
}) = self.tcx().hir().get(hir_id)
173-
{
174-
let (suggestion_param_name, introduce_new) = generics
175-
.params
176-
.iter()
177-
.find(|p| matches!(p.kind, GenericParamKind::Lifetime { .. }))
178-
.and_then(|p| self.tcx().sess.source_map().span_to_snippet(p.span).ok())
179-
.map(|name| (name, false))
180-
.unwrap_or_else(|| ("'a".to_string(), true));
181-
182-
let mut suggestions = vec![
183-
if let hir::LifetimeName::Underscore = lifetime_sub.name {
184-
(lifetime_sub.span, suggestion_param_name.clone())
185-
} else {
186-
(
187-
lifetime_sub.span.shrink_to_hi(),
188-
suggestion_param_name.clone() + " ",
189-
)
190-
},
191-
if let hir::LifetimeName::Underscore = lifetime_sup.name {
192-
(lifetime_sup.span, suggestion_param_name.clone())
193-
} else {
194-
(
195-
lifetime_sup.span.shrink_to_hi(),
196-
suggestion_param_name.clone() + " ",
197-
)
198-
},
199-
];
200-
201-
if introduce_new {
202-
let new_param_suggestion = match &generics.params {
203-
[] => (generics.span, format!("<{}>", suggestion_param_name)),
204-
[first, ..] => (
205-
first.span.shrink_to_lo(),
206-
format!("{}, ", suggestion_param_name),
207-
),
208-
};
209-
210-
suggestions.push(new_param_suggestion);
211-
}
212-
213-
err.multipart_suggestion(
214-
"consider introducing a named lifetime parameter",
215-
suggestions,
216-
Applicability::MaybeIncorrect,
217-
);
218-
err.note(
219-
"each elided lifetime in input position becomes a distinct lifetime",
220-
);
169+
170+
let node = self.tcx().hir().get(hir_id);
171+
let is_impl = matches!(&node, hir::Node::ImplItem(_));
172+
let generics = match node {
173+
hir::Node::Item(&hir::Item {
174+
kind: hir::ItemKind::Fn(_, ref generics, ..),
175+
..
176+
})
177+
| hir::Node::TraitItem(&hir::TraitItem { ref generics, .. })
178+
| hir::Node::ImplItem(&hir::ImplItem { ref generics, .. }) => generics,
179+
_ => return,
180+
};
181+
182+
let (suggestion_param_name, introduce_new) = generics
183+
.params
184+
.iter()
185+
.find(|p| matches!(p.kind, GenericParamKind::Lifetime { .. }))
186+
.and_then(|p| self.tcx().sess.source_map().span_to_snippet(p.span).ok())
187+
.map(|name| (name, false))
188+
.unwrap_or_else(|| ("'a".to_string(), true));
189+
190+
let mut suggestions = vec![
191+
if let hir::LifetimeName::Underscore = lifetime_sub.name {
192+
(lifetime_sub.span, suggestion_param_name.clone())
193+
} else {
194+
(lifetime_sub.span.shrink_to_hi(), suggestion_param_name.clone() + " ")
195+
},
196+
if let hir::LifetimeName::Underscore = lifetime_sup.name {
197+
(lifetime_sup.span, suggestion_param_name.clone())
198+
} else {
199+
(lifetime_sup.span.shrink_to_hi(), suggestion_param_name.clone() + " ")
200+
},
201+
];
202+
203+
if introduce_new {
204+
let new_param_suggestion = match &generics.params {
205+
[] => (generics.span, format!("<{}>", suggestion_param_name)),
206+
[first, ..] => {
207+
(first.span.shrink_to_lo(), format!("{}, ", suggestion_param_name))
208+
}
209+
};
210+
211+
suggestions.push(new_param_suggestion);
212+
}
213+
214+
let mut sugg = String::from("consider introducing a named lifetime parameter");
215+
if is_impl {
216+
sugg.push_str(" and update trait if needed");
221217
}
218+
err.multipart_suggestion(
219+
sugg.as_str(),
220+
suggestions,
221+
Applicability::MaybeIncorrect,
222+
);
223+
err.note("each elided lifetime in input position becomes a distinct lifetime");
222224
}
223225
}
224226
}

compiler/rustc_mir_transform/src/const_debuginfo.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,8 @@ fn find_optimization_oportunities<'tcx>(body: &Body<'tcx>) -> Vec<(Local, Consta
5555

5656
let mut locals_to_debuginfo = BitSet::new_empty(body.local_decls.len());
5757
for debuginfo in &body.var_debug_info {
58-
if let VarDebugInfoContents::Place(p) = debuginfo.value {
59-
if let Some(l) = p.as_local() {
60-
locals_to_debuginfo.insert(l);
61-
}
58+
if let VarDebugInfoContents::Place(p) = debuginfo.value && let Some(l) = p.as_local() {
59+
locals_to_debuginfo.insert(l);
6260
}
6361
}
6462

compiler/rustc_mir_transform/src/const_prop.rs

+23-27
Original file line numberDiff line numberDiff line change
@@ -633,24 +633,22 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
633633
fn propagate_operand(&mut self, operand: &mut Operand<'tcx>) {
634634
match *operand {
635635
Operand::Copy(l) | Operand::Move(l) => {
636-
if let Some(value) = self.get_const(l) {
637-
if self.should_const_prop(&value) {
638-
// FIXME(felix91gr): this code only handles `Scalar` cases.
639-
// For now, we're not handling `ScalarPair` cases because
640-
// doing so here would require a lot of code duplication.
641-
// We should hopefully generalize `Operand` handling into a fn,
642-
// and use it to do const-prop here and everywhere else
643-
// where it makes sense.
644-
if let interpret::Operand::Immediate(interpret::Immediate::Scalar(
645-
ScalarMaybeUninit::Scalar(scalar),
646-
)) = *value
647-
{
648-
*operand = self.operand_from_scalar(
649-
scalar,
650-
value.layout.ty,
651-
self.source_info.unwrap().span,
652-
);
653-
}
636+
if let Some(value) = self.get_const(l) && self.should_const_prop(&value) {
637+
// FIXME(felix91gr): this code only handles `Scalar` cases.
638+
// For now, we're not handling `ScalarPair` cases because
639+
// doing so here would require a lot of code duplication.
640+
// We should hopefully generalize `Operand` handling into a fn,
641+
// and use it to do const-prop here and everywhere else
642+
// where it makes sense.
643+
if let interpret::Operand::Immediate(interpret::Immediate::Scalar(
644+
ScalarMaybeUninit::Scalar(scalar),
645+
)) = *value
646+
{
647+
*operand = self.operand_from_scalar(
648+
scalar,
649+
value.layout.ty,
650+
self.source_info.unwrap().span,
651+
);
654652
}
655653
}
656654
}
@@ -1086,15 +1084,13 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
10861084
// This will return None if the above `const_prop` invocation only "wrote" a
10871085
// type whose creation requires no write. E.g. a generator whose initial state
10881086
// consists solely of uninitialized memory (so it doesn't capture any locals).
1089-
if let Some(ref value) = self.get_const(place) {
1090-
if self.should_const_prop(value) {
1091-
trace!("replacing {:?} with {:?}", rval, value);
1092-
self.replace_with_const(rval, value, source_info);
1093-
if can_const_prop == ConstPropMode::FullConstProp
1094-
|| can_const_prop == ConstPropMode::OnlyInsideOwnBlock
1095-
{
1096-
trace!("propagated into {:?}", place);
1097-
}
1087+
if let Some(ref value) = self.get_const(place) && self.should_const_prop(value) {
1088+
trace!("replacing {:?} with {:?}", rval, value);
1089+
self.replace_with_const(rval, value, source_info);
1090+
if can_const_prop == ConstPropMode::FullConstProp
1091+
|| can_const_prop == ConstPropMode::OnlyInsideOwnBlock
1092+
{
1093+
trace!("propagated into {:?}", place);
10981094
}
10991095
}
11001096
match can_const_prop {

compiler/rustc_mir_transform/src/coverage/debug.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,12 @@ impl DebugCounters {
357357
if let Some(counters) = &self.some_counters {
358358
if let Some(DebugCounter { counter_kind, some_block_label }) = counters.get(&operand) {
359359
if let CoverageKind::Expression { .. } = counter_kind {
360-
if let Some(block_label) = some_block_label {
361-
if debug_options().counter_format.block {
362-
return format!(
363-
"{}:({})",
364-
block_label,
365-
self.format_counter_kind(counter_kind)
366-
);
367-
}
360+
if let Some(label) = some_block_label && debug_options().counter_format.block {
361+
return format!(
362+
"{}:({})",
363+
label,
364+
self.format_counter_kind(counter_kind)
365+
);
368366
}
369367
return format!("({})", self.format_counter_kind(counter_kind));
370368
}

compiler/rustc_mir_transform/src/coverage/spans.rs

+19-24
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,13 @@ impl CoverageSpan {
191191
/// If the span is part of a macro, and the macro is visible (expands directly to the given
192192
/// body_span), returns the macro name symbol.
193193
pub fn visible_macro(&self, body_span: Span) -> Option<Symbol> {
194-
if let Some(current_macro) = self.current_macro() {
195-
if self
196-
.expn_span
197-
.parent_callsite()
198-
.unwrap_or_else(|| bug!("macro must have a parent"))
199-
.ctxt()
200-
== body_span.ctxt()
201-
{
202-
return Some(current_macro);
203-
}
194+
if let Some(current_macro) = self.current_macro() && self
195+
.expn_span
196+
.parent_callsite()
197+
.unwrap_or_else(|| bug!("macro must have a parent"))
198+
.ctxt() == body_span.ctxt()
199+
{
200+
return Some(current_macro);
204201
}
205202
None
206203
}
@@ -584,21 +581,19 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
584581
/// In either case, no more spans will match the span of `pending_dups`, so
585582
/// add the `pending_dups` if they don't overlap `curr`, and clear the list.
586583
fn check_pending_dups(&mut self) {
587-
if let Some(dup) = self.pending_dups.last() {
588-
if dup.span != self.prev().span {
589-
debug!(
590-
" SAME spans, but pending_dups are NOT THE SAME, so BCBs matched on \
591-
previous iteration, or prev started a new disjoint span"
592-
);
593-
if dup.span.hi() <= self.curr().span.lo() {
594-
let pending_dups = self.pending_dups.split_off(0);
595-
for dup in pending_dups.into_iter() {
596-
debug!(" ...adding at least one pending={:?}", dup);
597-
self.push_refined_span(dup);
598-
}
599-
} else {
600-
self.pending_dups.clear();
584+
if let Some(dup) = self.pending_dups.last() && dup.span != self.prev().span {
585+
debug!(
586+
" SAME spans, but pending_dups are NOT THE SAME, so BCBs matched on \
587+
previous iteration, or prev started a new disjoint span"
588+
);
589+
if dup.span.hi() <= self.curr().span.lo() {
590+
let pending_dups = self.pending_dups.split_off(0);
591+
for dup in pending_dups.into_iter() {
592+
debug!(" ...adding at least one pending={:?}", dup);
593+
self.push_refined_span(dup);
601594
}
595+
} else {
596+
self.pending_dups.clear();
602597
}
603598
}
604599
}

0 commit comments

Comments
 (0)