Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
07f1e61
Add natvis for NonZero and Wrapping types
wesleywiser Jun 28, 2021
9740dcc
Add natvis for Atomic types
wesleywiser Jun 29, 2021
cad42e0
Add natvis for cell types
wesleywiser Jun 29, 2021
8f1eec3
Fixup natvis for NonNull and Unique types
wesleywiser Jun 29, 2021
f2aba34
Add natvis for Range types
wesleywiser Jun 29, 2021
691ee05
Add natvis for Duration, ManuallyDrop and Pin types
wesleywiser Jun 30, 2021
a6a82c6
Add/improve visualizations for liballoc types
wesleywiser Jun 30, 2021
8500274
Add visualizer for OsString and fixup other string visualizers
wesleywiser Jul 1, 2021
d1852e1
Respond to review feedback
wesleywiser Jul 9, 2021
10b536f
ExprUseVisitor: treat ByValue use of Copy types as ImmBorrow
arora-aman Jul 11, 2021
14fdf8a
Add test for `Unique<T>`, weak ref counts and ref counts for `Weak<T>`
wesleywiser Jul 12, 2021
36f51c9
Add test for copy type in move closure
arora-aman Jul 14, 2021
6c3774e
ExprUseVisitor::Delegate consume only when moving
arora-aman Jul 14, 2021
e753f30
Correct invariant documentation for `steps_between`
dhwthompson Jul 14, 2021
6e357bc
Fix tests for i686
wesleywiser Jul 14, 2021
51142a0
Make --cap-lints and related options leave crate hash alone
jsgf Jul 14, 2021
c4ac836
PR feedback
arora-aman Jul 15, 2021
75291ee
Update compiler/rustc_typeck/src/expr_use_visitor.rs
nikomatsakis Jul 15, 2021
9fe470b
Get the right place type
roxelo Jul 15, 2021
59103d1
Fix layout overflow in type declaration
GuillaumeGomez Jul 15, 2021
25e7403
Add regression test for type declaration layout overflow
GuillaumeGomez Jul 15, 2021
c3c4b9e
Do not hide the sidebar on mobile, move it outside of the viewport in…
GuillaumeGomez Jul 15, 2021
868ffd0
Add test for sidebar display value on mobile
GuillaumeGomez Jul 15, 2021
f4e47ba
Rollup merge of #86983 - wesleywiser:natvis_std_types, r=michaelwoeri…
GuillaumeGomez Jul 16, 2021
c1ffca0
Rollup merge of #87069 - sexxi-goose:copy_ref_always, r=nikomatsakis
GuillaumeGomez Jul 16, 2021
36de877
Rollup merge of #87138 - dhwthompson:fix-range-invariant, r=JohnTitor
GuillaumeGomez Jul 16, 2021
c1b9bbf
Rollup merge of #87145 - jsgf:fix-lint-opt-hash, r=michaelwoerister
GuillaumeGomez Jul 16, 2021
4143379
Rollup merge of #87161 - sexxi-goose:fix-issue-87097, r=nikomatsakis
GuillaumeGomez Jul 16, 2021
a547abe
Rollup merge of #87162 - GuillaumeGomez:type-decl-overflow, r=notriddle
GuillaumeGomez Jul 16, 2021
b19f37c
Rollup merge of #87167 - GuillaumeGomez:sidebar-display-mobile, r=not…
GuillaumeGomez Jul 16, 2021
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
PR feedback
  • Loading branch information
arora-aman committed Jul 15, 2021
commit c4ac8369e2ec05a9c8234608b8bd2a33832b3929
45 changes: 26 additions & 19 deletions compiler/rustc_typeck/src/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ pub trait Delegate<'tcx> {
// The value found at `place` is moved, depending
// on `mode`. Where `diag_expr_id` is the id used for diagnostics for `place`.
//
// Use of a `Copy` type in a ByValue context is considered a use
// by `ImmBorrow` and `borrow` is called instead.
//
//
// The parameter `diag_expr_id` indicates the HIR id that ought to be used for
// diagnostics. Around pattern matching such as `let pat = expr`, the diagnostic
// id will be the id of the expression `expr` but the place itself will have
Expand Down Expand Up @@ -134,16 +138,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
}

fn delegate_consume(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId) {
debug!("delegate_consume(place_with_id={:?})", place_with_id);

let mode = copy_or_move(&self.mc, place_with_id);

match mode {
ConsumeMode::Move => self.delegate.consume(place_with_id, diag_expr_id),
ConsumeMode::Copy => {
self.delegate.borrow(place_with_id, diag_expr_id, ty::BorrowKind::ImmBorrow)
}
}
delegate_consume(&self.mc, self.delegate, place_with_id, diag_expr_id)
}

fn consume_exprs(&mut self, exprs: &[hir::Expr<'_>]) {
Expand Down Expand Up @@ -653,15 +648,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
}
ty::BindByValue(..) => {
debug!("walk_pat binding consuming pat");
let mode = copy_or_move(mc, &place);
match mode {
ConsumeMode::Move => delegate.consume(place, discr_place.hir_id),
ConsumeMode::Copy => delegate.borrow(
place,
discr_place.hir_id,
ty::BorrowKind::ImmBorrow,
),
}
delegate_consume(mc, *delegate, place, discr_place.hir_id);
}
}
}
Expand Down Expand Up @@ -808,3 +795,23 @@ fn copy_or_move<'a, 'tcx>(
ConsumeMode::Copy
}
}

// - If a place is used in a `ByValue` context then move it if it's not a `Copy` type.
// - If the place that is a `Copy` type consider it a `ImmBorrow`.
fn delegate_consume<'a, 'tcx>(
mc: &mc::MemCategorizationContext<'a, 'tcx>,
delegate: &mut (dyn Delegate<'tcx> + 'a),
place_with_id: &PlaceWithHirId<'tcx>,
diag_expr_id: hir::HirId,
) {
debug!("delegate_consume(place_with_id={:?})", place_with_id);

let mode = copy_or_move(&mc, place_with_id);

match mode {
ConsumeMode::Move => delegate.consume(place_with_id, diag_expr_id),
ConsumeMode::Copy => {
delegate.borrow(place_with_id, diag_expr_id, ty::BorrowKind::ImmBorrow)
}
}
}