Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions compiler/rustc_hir_analysis/src/check/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,9 @@ fn resolve_local<'tcx>(
record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id);
}
}
hir::ExprKind::Repeat(subexpr, _) => {
record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id);
}
hir::ExprKind::Cast(subexpr, _) => {
record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id)
}
Expand Down
8 changes: 5 additions & 3 deletions tests/ui/consts/promote-not.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,12 @@ error[E0716]: temporary value dropped while borrowed
--> $DIR/promote-not.rs:90:31
|
LL | let _val: &'static _ = &[&TEST_DROP; 1];
| ---------- ^^^^^^^^^ - temporary value is freed at the end of this statement
| | |
| | creates a temporary value which is freed while still in use
| ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use
| |
| type annotation requires that borrow lasts for `'static`
...
LL | }
| - temporary value is freed at the end of this statement

error[E0716]: temporary value dropped while borrowed
--> $DIR/promote-not.rs:99:26
Expand Down
14 changes: 14 additions & 0 deletions tests/ui/repeat-expr/extending.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//@ run-pass
//! Test that array repeat expressions are extending

#![allow(path_statements)]

fn temp() {}

fn main() {
let _extended = [&temp(); 1];
_extended;

let _extended = [&temp(); 17];
_extended;
}
Loading