Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
f00e7a2
abby: add test DSL docs
khyperia Oct 12, 2026
2f10cc8
chore: fix tiny typo
TechnoPorg Oct 14, 2026
b1a9a40
doc: write TPDE section
TechnoPorg Oct 14, 2026
225a419
Document that `portable-simd` now uses Josh
Kobzol Nov 2, 2026
e62837b
Merge pull request #3084 from Kobzol/portable-simd-josh
lqd Nov 2, 2026
03b5e66
doc: rename -Ztpde to -Zllvm-tpde as per review on implementation PR
TechnoPorg Oct 16, 2026
dbb3750
Merge pull request #3051 from TechnoPorg/push-kynxnumtplvo
ZuseZ4 Nov 5, 2026
1c77827
Merge pull request #3046 from khyperia/binder-test-dsl
BoxyUwU Nov 6, 2026
b800565
offload: simplify build commands by removing --emit=llvm-bc,llvm-ir -…
sgasho Nov 6, 2026
f12cd09
Recommend labels for fuzzed issues
workingjubilee Nov 7, 2026
aacdb5f
offload: update compile instructions and warning on usage.md
sgasho Nov 7, 2026
6fe9328
Merge pull request #3087 from workingjubilee/suggest-labeling-fuzzing
jieyouxu Nov 7, 2026
a3c9129
Merge pull request #3086 from sgasho/update-offload-usage-ptx-elf
ZuseZ4 Nov 9, 2026
d6a365b
Steer fuzzed miscompiles to llvm-project/issues
workingjubilee Nov 7, 2026
fdb372e
Limit vagueness about directing fuzzed issues to LLVM
workingjubilee Nov 9, 2026
989910c
Fix MSVC calling convention byte counts without non-Windows perf regr…
paradoxicalguy Nov 12, 2026
03f2902
Remove mentions of git subtrees
Kobzol Nov 14, 2026
71e6103
Improve index inference diagnostics
pkondzior Nov 14, 2026
b2d81b9
Update `minifier-rs` dependency version to `0.5.0`
GuillaumeGomez Nov 14, 2026
1a3a6c4
Merge pull request #3094 from Kobzol/clippy-josh
tshepang Nov 15, 2026
40ca863
some space to breathe
tshepang Nov 7, 2026
f890057
borrowck: cleanup needless borrows and returns
malezjaa Nov 15, 2026
76f1225
sembr src/external-repos.md
tshepang Nov 15, 2026
826ddaa
whitespace
tshepang Nov 15, 2026
d690cde
reflow src/external-repos.md
tshepang Nov 15, 2026
b44f791
sembr src/offload/usage.md
tshepang Nov 15, 2026
8fdb63a
sembr src/fuzzing.md
tshepang Nov 15, 2026
5a33430
reflow src/fuzzing.md
tshepang Nov 15, 2026
f4efb0b
sembr src/tpde/debugging.md
tshepang Nov 15, 2026
5dd5d2b
align
tshepang Nov 15, 2026
c6d1082
sembr src/tpde/installation.md
tshepang Nov 15, 2026
e28b264
reflow src/tpde/installation.md
tshepang Nov 15, 2026
aea96f1
sembr src/tpde/internals.md
tshepang Nov 15, 2026
d33b99f
improve tpde/internals.md
tshepang Nov 15, 2026
8467a50
reduce noise
tshepang Nov 15, 2026
0665577
this runs just this once, so should be faster this way
tshepang Nov 15, 2026
a548f80
reflow src/ty-module/binder-test-dsl.md
tshepang Nov 15, 2026
f52627a
improve ty-module/binder-test-dsl.md
tshepang Nov 15, 2026
e05ee18
reflow src/ty-module/binder-test-dsl.md
tshepang Nov 15, 2026
33a50d4
sembr src/borrow-check/moves-and-initialization/move-paths.md
tshepang Nov 15, 2026
548be69
improve borrow-check/moves-and-initialization/move-paths.md
tshepang Nov 15, 2026
edc6d82
reflow src/borrow-check/moves-and-initialization/move-paths.md
tshepang Nov 15, 2026
fb50007
sembr: remove the need to run multiple times
tshepang Nov 15, 2026
dbac547
sembr src/borrow-check/drop-check.md
tshepang Nov 15, 2026
4ee464d
improve borrow-check/drop-check.md
tshepang Nov 15, 2026
5d34ca1
sembr src/borrow-check/moves-and-initialization.md
tshepang Nov 15, 2026
215ea38
improve borrow-check/moves-and-initialization.md
tshepang Nov 15, 2026
0053c7a
sembr src/traits/unsize.md
tshepang Nov 15, 2026
2b19c2c
improve traits/unsize.md
tshepang Nov 15, 2026
f4b11fd
sembr src/traits/caching.md
tshepang Nov 15, 2026
305d339
improve traits/caching.md
tshepang Nov 15, 2026
760cc70
sembr src/traits/canonical-queries.md
tshepang Nov 15, 2026
973c90d
improve traits/canonical-queries.md
tshepang Nov 15, 2026
8958ef8
expose f16b via std::num, not just core::num
RalfJung Nov 15, 2026
b12e656
sembr src/traits/hrtb.md
tshepang Nov 15, 2026
3ab6386
improve src/traits/hrtb.md
tshepang Nov 15, 2026
97926c2
sembr src/solve/proof-trees.md
tshepang Nov 15, 2026
56f5ac4
improve solve/proof-trees.md
tshepang Nov 15, 2026
2a235d2
sembr src/solve/canonicalization.md
tshepang Nov 15, 2026
d8f3694
improve solve/canonicalization.md
tshepang Nov 15, 2026
3d54def
sembr src/solve/opaque-types.md
tshepang Nov 15, 2026
8bc15f0
borrowck: match/if let cleanups
malezjaa Nov 15, 2026
ed626b9
borrowck: more clippy cleanups
malezjaa Nov 15, 2026
6045781
improve solve/opaque-types.md
tshepang Nov 15, 2026
92f79cf
sembr src/solve/significant-changes.md
tshepang Nov 15, 2026
0d6d542
Improve String::insert{,_str} safety comments
T0mstone Nov 15, 2026
a6844d5
add ABI compat checks for new float types
RalfJung Nov 15, 2026
053b6d4
Revert safety hygiene changes to `String::retain`
workingjubilee Nov 15, 2026
3ff4095
Revert optimized implementation of `String::retain`
workingjubilee Nov 15, 2026
08e44b1
library: Reapply String::retain safety doc for tidy
fereidani Nov 15, 2026
6a8e5c1
Update TPDE submodule
TechnoPorg Nov 15, 2026
9d954f8
improve solve/significant-changes.md
tshepang Nov 16, 2026
ae71128
sembr src/solve/trait-solving.md
tshepang Nov 16, 2026
8fe7a6f
Correct and expand E0225 error explanation.
kpreid Nov 16, 2026
cfeea65
improve solve/trait-solving.md
tshepang Nov 16, 2026
2c1d30b
sembr src/borrow-check/two-phase-borrows.md
tshepang Nov 16, 2026
3830262
improve borrow-check/two-phase-borrows.md
tshepang Nov 16, 2026
3415213
sembr src/borrow-check/opaque-types-region-inference-restrictions.md
tshepang Nov 16, 2026
b2b4e20
improve borrow-check/opaque-types-region-inference-restrictions.md
tshepang Nov 16, 2026
02355a9
Merge pull request #3095 from rust-lang/tshepang/misc
tshepang Nov 16, 2026
0137768
Prepare for merging from rust-lang/rust
invalid-email-address Nov 16, 2026
024630f
Merge ref 'c55b900aa3e4' from rust-lang/rust
invalid-email-address Nov 16, 2026
2d66ec1
Merge pull request #3096 from rust-lang/rustc-pull
tshepang Nov 16, 2026
3ab5fda
sembr formatting fixes
tshepang Nov 16, 2026
4a0d9ac
sembr formatting fix
tshepang Nov 16, 2026
c217bcc
Merge pull request #3089 from workingjubilee/guide-issues-to-llvm
tshepang Nov 16, 2026
fe5fc8d
sembr src/fuzzing.md
tshepang Nov 16, 2026
9b49422
sembr src/borrow-check/region-inference.md
tshepang Nov 16, 2026
cebdf67
improve borrow-check/region-inference.md
tshepang Nov 16, 2026
5196b53
sembr src/borrow-check/region-inference/lifetime-parameters.md
tshepang Nov 16, 2026
9bb7e42
improve borrow-check/region-inference/lifetime-parameters.md
tshepang Nov 16, 2026
8ab1d8a
sembr src/borrow-check/region-inference/constraint-propagation.md
tshepang Nov 16, 2026
abebd84
improve borrow-check/region-inference/constraint-propagation.md
tshepang Nov 16, 2026
d78e74e
sembr src/borrow-check/region-inference/closure-constraints.md
tshepang Nov 16, 2026
7c685b2
improve borrow-check/region-inference/closure-constraints.md
tshepang Nov 16, 2026
3d6d10e
sembr src/borrow-check/region-inference/placeholders-and-universes.md
tshepang Nov 16, 2026
f2c9fcd
Normalize the field type of repr simd structs before reading the vect…
bit-aloo Nov 16, 2026
7e7533f
Add regression test for issue 138009 erroneous array length in repr s…
bit-aloo Nov 16, 2026
51b5faf
Add regression test for issue 138008 array length from const item in …
bit-aloo Nov 16, 2026
d990df1
improve borrow-check/region-inference/placeholders-and-universes.md
tshepang Nov 16, 2026
45c0abb
Merge pull request #3097 from rust-lang/tshepang/misc
tshepang Nov 16, 2026
6bbc465
Split packed structs out of `const_struct`
beetrees Nov 16, 2026
76fc661
Make `type_named_struct` set the struct fields
beetrees Nov 16, 2026
6fb761c
Handle trait default values in `mir_for_direct_const`
lapla-cogito Nov 7, 2026
176081b
Don't use `type_ix`/`const_uint`/`const_int` when type-specific metho…
beetrees Nov 16, 2026
61f6e0d
Merge `isize_ty` into `type_isize`
beetrees Nov 16, 2026
e81fe31
join 32-bit and 64-bit virtual function elimination tests
folkertdev Nov 4, 2026
af33912
use `trait_ref`'s def_id
folkertdev Nov 4, 2026
9929010
document and refactor `VCallVisibility`
folkertdev Nov 4, 2026
b9636cb
support a slice of (super)traits in `apply_vcall_visibility_metadata`
folkertdev Nov 4, 2026
3419917
add !type annotations for each (super)trait that is a prefix of a giv…
folkertdev Nov 4, 2026
adba099
pipe_subprocess test: use libtest harness
RalfJung Nov 15, 2026
35a0470
Document AltiVec requirement for powerpc64-unknown-linux-gnuelfv2
Gelbpunkt Nov 16, 2026
d384f89
Add a separate feature gate for EIIs with default impls
bjorn3 Nov 12, 2026
f61e42f
Use an invariant lifetime brand for LLVM attributes
Zalathar Nov 12, 2026
887c53b
Rollup merge of #166011 - workingjubilee:clean-revert-string-retain, …
JonathanBrouwer Nov 16, 2026
4b9a7f4
Rollup merge of #165475 - folkertdev:vfe-upcast, r=WaffleLapkin
JonathanBrouwer Nov 16, 2026
bf05262
Rollup merge of #165881 - paradoxicalguy:fix-msvc-byte-count-v2, r=fo…
JonathanBrouwer Nov 16, 2026
4e90390
Rollup merge of #165882 - bjorn3:eii_defaults_separate_gate, r=Jonath…
JonathanBrouwer Nov 16, 2026
97720b5
Rollup merge of #165979 - pkondzior:fix-105329-index-inference-diagno…
JonathanBrouwer Nov 16, 2026
45199dc
Rollup merge of #165983 - GuillaumeGomez:update-minifier-dep, r=Guill…
JonathanBrouwer Nov 16, 2026
ad530b7
Rollup merge of #165999 - TechnoPorg:push-osuqssntxnxp, r=ZuseZ4
JonathanBrouwer Nov 16, 2026
012598d
Rollup merge of #166005 - RalfJung:float-abi, r=joshtriplett
JonathanBrouwer Nov 16, 2026
d70bd96
Rollup merge of #165613 - lapla-cogito:issue_165471, r=khyperia
JonathanBrouwer Nov 16, 2026
1e95c07
Rollup merge of #165861 - Zalathar:llattr, r=wesleywiser
JonathanBrouwer Nov 16, 2026
758cd53
Rollup merge of #165993 - RalfJung:pipe-subprocess, r=JohnTitor
JonathanBrouwer Nov 16, 2026
2c898ef
Rollup merge of #165998 - malezjaa:cleanup-borrowck, r=fmease
JonathanBrouwer Nov 16, 2026
538a9b2
Rollup merge of #166009 - T0mstone:main, r=thomcc
JonathanBrouwer Nov 16, 2026
75813bc
Rollup merge of #166021 - kpreid:e0225, r=JonathanBrouwer
JonathanBrouwer Nov 16, 2026
d5f7d73
Rollup merge of #166029 - tshepang:rdg-sync, r=tshepang
JonathanBrouwer Nov 16, 2026
88bd312
Rollup merge of #166031 - beetrees:const-packed-struct, r=folkertdev
JonathanBrouwer Nov 16, 2026
d3d1ff4
Rollup merge of #166032 - bit-aloo:2026-11-15-simd-layout-error-const…
JonathanBrouwer Nov 16, 2026
3e75f7d
Rollup merge of #166034 - beetrees:llvm-type-cleanup, r=bjorn3
JonathanBrouwer Nov 16, 2026
eafcf98
Rollup merge of #166047 - Gelbpunkt:altivec-requirement-doc, r=tgross35
JonathanBrouwer Nov 16, 2026
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
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2504,9 +2504,9 @@ dependencies = [

[[package]]
name = "minifier"
version = "0.4.0"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "245c950e30794ed20f72ff60c85ae1cddb0ba54fda4623017a678943f98f636c"
checksum = "56b6ef9682ae78237a99dde4f4060d556c2be0d50573361dd17b20d6f500b609"

[[package]]
name = "minimal-lexical"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/borrow_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl<'tcx> BorrowSet<'tcx> {

// Public method to support Creusot.
pub fn activations_at_location(&self, location: &Location) -> &[BorrowIndex] {
self.activation_map.get(&location).map_or(&[], |activations| &activations[..])
self.activation_map.get(location).map_or(&[], |activations| &activations[..])
}

// Public method to support Creusot.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
if place.ignore_borrow(
self.tcx,
self.body,
&self.borrow_set.locals_state_at_exit(),
self.borrow_set.locals_state_at_exit(),
) {
return;
}
Expand Down
82 changes: 36 additions & 46 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
}

let is_partial_move = move_site_vec.iter().any(|move_site| {
let move_out = self.move_data.move_outs[(*move_site).moi];
let move_out = self.move_data.move_outs[move_site.moi];
let moved_place = &self.move_data.move_paths[move_out.path].place;
// `*(_1)` where `_1` is a `Box` is actually a move out.
let is_box_move = moved_place.as_ref().projection == [ProjectionElem::Deref]
Expand All @@ -154,7 +154,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
.generics_of(item_def.did())
.own_params
.iter()
.filter_map(|param| Some((param.name, args[param.index as usize].to_string())))
.map(|param| (param.name, args[param.index as usize].to_string()))
.collect();
generic_args.push((kw::SelfUpper, this.clone()));

Expand Down Expand Up @@ -215,7 +215,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
let mut seen_spans = FxIndexSet::default();

for move_site in &move_site_vec {
let move_out = self.move_data.move_outs[(*move_site).moi];
let move_out = self.move_data.move_outs[move_site.moi];
let moved_place = &self.move_data.move_paths[move_out.path].place;

let move_spans = self.move_spans(moved_place.as_ref(), move_out.source);
Expand Down Expand Up @@ -871,7 +871,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
let body = tcx.hir_body_owned_by(self.mir_def_id());
let mut visitor =
ConditionVisitor { tcx, spans: all_init_spans.clone(), name, errors: vec![] };
visitor.visit_body(&body);
visitor.visit_body(body);

let mut show_assign_sugg = false;
let isnt_initialized = if let InitializationRequiringAction::PartialAssignment
Expand Down Expand Up @@ -994,7 +994,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
}

let mut visitor = LetVisitor { decl_span, sugg: None };
visitor.visit_body(&body);
visitor.visit_body(body);
if let Some((span, strip_ref)) = visitor.sugg {
self.suggest_assign_value(&mut err, moved_place, span, strip_ref);
}
Expand Down Expand Up @@ -1105,20 +1105,16 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
}
match e.kind {
hir::ExprKind::Let(_) => {
match tcx.parent_hir_node(e.hir_id) {
hir::Node::Expr(hir::Expr {
kind: hir::ExprKind::If(cond, ..), ..
}) => {
if (Finder { hir_id: expr.hir_id }).visit_expr(cond).is_break() {
// The expression where the move error happened is in a `while let`
// condition Don't suggest clone as it will likely end in an
// infinite loop.
// while let Some(_) = foo(non_copy.clone()) { }
// --------- ^^^^^^^^
can_suggest_clone = false;
}
}
_ => {}
if let hir::Node::Expr(hir::Expr { kind: hir::ExprKind::If(cond, ..), .. }) =
tcx.parent_hir_node(e.hir_id)
&& (Finder { hir_id: expr.hir_id }).visit_expr(cond).is_break()
{
// The expression where the move error happened is in a `while let`
// condition. Do not suggest clone, because it will likely cause
// an infinite loop.
// while let Some(_) = foo(non_copy.clone()) { }
// --------- ^^^^^^^^
can_suggest_clone = false;
}
}
hir::ExprKind::Loop(..) => {
Expand Down Expand Up @@ -1482,7 +1478,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
types.insert(
self.infcx
.tcx
.short_string(clause.self_ty().skip_binder(), &mut err.long_ty_path()),
.short_string(clause.self_ty().skip_binder(), err.long_ty_path()),
);
}
let mut span: MultiSpan = type_spans.clone().into();
Expand Down Expand Up @@ -1722,7 +1718,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
});

self.explain_why_borrow_contains_point(location, borrow, None)
.add_explanation_to_diagnostic(&self, &mut err, "", Some(borrow_span), None);
.add_explanation_to_diagnostic(self, &mut err, "", Some(borrow_span), None);
self.suggest_copy_for_type_in_cloned_ref(&mut err, place);
let typeck_results = self.infcx.tcx.typeck(self.mir_def_id());
if let Some(expr) = self.find_expr(borrow_span) {
Expand Down Expand Up @@ -1789,7 +1785,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
});

self.explain_why_borrow_contains_point(location, borrow, None)
.add_explanation_to_diagnostic(&self, &mut err, "", None, None);
.add_explanation_to_diagnostic(self, &mut err, "", None, None);
err
}

Expand Down Expand Up @@ -2085,14 +2081,14 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
});
}

if union_type_name != "" {
if !union_type_name.is_empty() {
err.note(format!(
"{msg_place} is a field of the union `{union_type_name}`, so it overlaps the field {msg_borrow}",
));
}

explanation.add_explanation_to_diagnostic(
&self,
self,
&mut err,
first_borrow_desc,
None,
Expand Down Expand Up @@ -2840,6 +2836,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
closure_local_id: Option<hir::HirId> = None,
closure_call_changes: Vec<(Span, String)> = vec![],
}

impl<'hir> Visitor<'hir> for ExpressionFinder<'hir> {
fn visit_expr(&mut self, e: &'hir hir::Expr<'hir>) {
if e.span.contains(self.capture_span)
Expand All @@ -2853,7 +2850,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
&& let hir::Node::Expr(body) = self.tcx.hir_node(body.hir_id)
{
self.suggest_arg = "this: &Self".to_string();
if inputs.len() > 0 {
if !inputs.is_empty() {
self.suggest_arg.push_str(", ");
}
self.in_closure = true;
Expand Down Expand Up @@ -2901,7 +2898,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
&& let Res::Local(hir_id) = seg.res
&& Some(hir_id) == self.closure_local_id
{
let (span, arg_str) = if args.len() > 0 {
let (span, arg_str) = if !args.is_empty() {
(args[0].span.shrink_to_lo(), "self, ".to_string())
} else {
let span = e.span.trim_start(seg.ident.span).unwrap_or(e.span);
Expand Down Expand Up @@ -2988,15 +2985,10 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
ty.ty_adt_def().filter(|adt| adt.is_union()).map(|_| ty)
};

// Start with an empty tuple, so we can use the functions on `Option` to reduce some
// code duplication (particularly around returning an empty description in the failure
// case).
Some(())
.filter(|_| {
// If we have a conflicting borrow of the same place, then we don't want to add
// an extraneous "via x.y" to our diagnostics, so filter out this case.
first_borrowed_place != second_borrowed_place
})
// If we have a conflicting borrow of the same place, then we don't want to add
// an extraneous "via x.y" to our diagnostics, so filter out this case.
(first_borrowed_place != second_borrowed_place)
.then_some(())
.and_then(|_| {
// We're going to want to traverse the first borrowed place to see if we can find
// field access to a union. If we find that, then we will keep the place of the
Expand Down Expand Up @@ -3258,7 +3250,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {

if let BorrowExplanation::MustBeValidFor { .. } = explanation {
} else {
explanation.add_explanation_to_diagnostic(&self, &mut err, "", None, None);
explanation.add_explanation_to_diagnostic(self, &mut err, "", None, None);
}
} else {
err.span_label(borrow_span, "borrowed value does not live long enough");
Expand All @@ -3271,7 +3263,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
}
});

explanation.add_explanation_to_diagnostic(&self, &mut err, "", Some(borrow_span), None);
explanation.add_explanation_to_diagnostic(self, &mut err, "", Some(borrow_span), None);

// Detect buffer reuse pattern
if let BorrowExplanation::UsedLater(_dropped_local, _, _, _) = explanation {
Expand Down Expand Up @@ -3357,7 +3349,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
_ => {}
}

explanation.add_explanation_to_diagnostic(&self, &mut err, "", None, None);
explanation.add_explanation_to_diagnostic(self, &mut err, "", None, None);

self.buffer_error(err);
}
Expand Down Expand Up @@ -3539,7 +3531,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
}
_ => {}
}
explanation.add_explanation_to_diagnostic(&self, &mut err, "", None, None);
explanation.add_explanation_to_diagnostic(self, &mut err, "", None, None);

borrow_spans.args_subdiag(&mut err, |args_span| {
crate::session_diagnostics::CaptureArgLabel::Capture {
Expand Down Expand Up @@ -4051,7 +4043,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
});

self.explain_why_borrow_contains_point(location, loan, None)
.add_explanation_to_diagnostic(&self, &mut err, "", None, None);
.add_explanation_to_diagnostic(self, &mut err, "", None, None);

self.explain_deref_coercion(loan, &mut err);

Expand Down Expand Up @@ -4434,12 +4426,10 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
// Otherwise, look at other types of assignment.
let assigned_from = match rvalue {
Rvalue::Ref(_, _, assigned_from) => assigned_from,
Rvalue::Use(operand, _) => match operand {
Operand::Copy(assigned_from) | Operand::Move(assigned_from) => {
assigned_from
}
_ => continue,
},
Rvalue::Use(
Operand::Copy(assigned_from) | Operand::Move(assigned_from),
_,
) => assigned_from,
_ => continue,
};
debug!(
Expand Down
45 changes: 18 additions & 27 deletions compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,16 +855,11 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
match rvalue {
// If we see a use, we should check whether it is our data, and if so
// update the place that we're looking for to that new place.
Rvalue::Use(operand, _) => match operand {
Operand::Copy(place) | Operand::Move(place) => {
if let Some(from) = place.as_local() {
if from == target {
target = into;
}
}
Rvalue::Use(Operand::Copy(place) | Operand::Move(place), _) => {
if place.as_local() == Some(target) {
target = into;
}
_ => {}
},
}
// If we see an unsized cast, then if it is our data we should check
// whether it is being cast to a trait object.
Rvalue::Cast(
Expand All @@ -874,24 +869,20 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
) => {
match operand {
Operand::Copy(place) | Operand::Move(place) => {
if let Some(from) = place.as_local() {
if from == target {
debug!("was_captured_by_trait_object: ty={:?}", ty);
// Check the type for a trait object.
return match ty.kind() {
// `&dyn Trait`
ty::Ref(_, ty, _) if ty.is_trait() => true,
// `Box<dyn Trait>`
_ if ty.boxed_ty().is_some_and(Ty::is_trait) => {
true
}

// `dyn Trait`
_ if ty.is_trait() => true,
// Anything else.
_ => false,
};
}
if place.as_local() == Some(target) {
debug!("was_captured_by_trait_object: ty={:?}", ty);
// Check the type for a trait object.
return match ty.kind() {
// `&dyn Trait`
ty::Ref(_, ty, _) if ty.is_trait() => true,
// `Box<dyn Trait>`
_ if ty.boxed_ty().is_some_and(Ty::is_trait) => true,

// `dyn Trait`
_ if ty.is_trait() => true,
// Anything else.
_ => false,
};
}
return false;
}
Expand Down
45 changes: 17 additions & 28 deletions compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
let mut buf = String::new();
let mut ok = self.append_local_to_string(local, &mut buf);

for (index, elem) in place.projection.into_iter().enumerate() {
for (index, elem) in place.projection.iter().enumerate() {
match elem {
ProjectionElem::Deref => {
if index == 0 {
Expand Down Expand Up @@ -425,15 +425,10 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
}

fn describe_name(&self, place: PlaceRef<'tcx>) -> Option<Symbol> {
for elem in place.projection.into_iter() {
match elem {
ProjectionElem::Downcast(Some(name), _) => {
return Some(*name);
}
_ => {}
}
}
None
place.projection.iter().find_map(|elem| match elem {
ProjectionElem::Downcast(Some(name), _) => Some(*name),
_ => None,
})
}

/// Appends end-user visible description of the `local` place to `buf`. If `local` doesn't have
Expand Down Expand Up @@ -1034,24 +1029,18 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {

// StatementKind::FakeRead only contains a def_id if they are introduced as a result
// of pattern matching within a closure.
if let StatementKind::FakeRead((cause, place)) = stmt.kind {
match cause {
FakeReadCause::ForMatchedPlace(Some(closure_def_id))
| FakeReadCause::ForLet(Some(closure_def_id)) => {
debug!("move_spans: def_id={:?} place={:?}", closure_def_id, place);
let places = &[Operand::Move(place)];
if let Some((args_span, closure_kind, capture_kind_span, path_span)) =
self.closure_span(closure_def_id, moved_place, IndexSlice::from_raw(places))
{
return ClosureUse {
closure_kind,
args_span,
capture_kind_span,
path_span,
};
}
}
_ => {}
if let StatementKind::FakeRead((
FakeReadCause::ForMatchedPlace(Some(closure_def_id))
| FakeReadCause::ForLet(Some(closure_def_id)),
place,
)) = stmt.kind
{
debug!("move_spans: def_id={:?} place={:?}", closure_def_id, place);
let places = &[Operand::Move(place)];
if let Some((args_span, closure_kind, capture_kind_span, path_span)) =
self.closure_span(closure_def_id, moved_place, IndexSlice::from_raw(places))
{
return ClosureUse { closure_kind, args_span, capture_kind_span, path_span };
}
}

Expand Down
Loading
Loading