Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
93eaf15
Add SessionDiagnostic derive macro.
jumbatm Aug 27, 2020
57edf88
Replace some trivial struct_span_err!s in typeck.
jumbatm Aug 27, 2020
5956254
Fix typos in E0224
jumbatm Aug 25, 2020
d80415a
Improve ayu doc source line number contrast
pickfire Sep 5, 2020
4fff14d
rustbuild: Remove `Mode::Codegen`
petrochenkov Sep 5, 2020
5acd272
Fix HashMap visualizers in Visual Studio (Code)
MaulingMonkey Sep 5, 2020
b92b0d6
Fix typo in tracking issue template
dylni Sep 6, 2020
4efe97a
Check placement of more attributes
calebzulawski Jun 14, 2020
f745b34
Emit warnings for misplaced attributes used by some crates
calebzulawski Jul 11, 2020
0c62ef0
Allow #[cold], #[track_caller] on closures. Fix whitespace in error m…
calebzulawski Aug 12, 2020
acd68b5
Fix broken test on musl
calebzulawski Sep 6, 2020
8f69266
Emit warnings on misplaced #[no_mangle]
calebzulawski Sep 6, 2020
9e14033
Update linker-plugin-lto.md to contain up to rust 1.46
elichai Sep 6, 2020
84fc6fd
Fix documentation for TyCtxt::all_impls
scrabsha Sep 6, 2020
2e82589
linker-plugin-lto.md: Convert the rust-clang MxN table to a 2xM table
elichai Sep 6, 2020
720293b
do not premote non-ZST mutable references ever
RalfJung Aug 16, 2020
28ddda7
add compile-fail test for &mut promotion
RalfJung Aug 16, 2020
2656d34
Make bootstrap build on stable
Mark-Simulacrum Sep 6, 2020
936b830
Rollup merge of #73461 - calebzulawski:validate-attribute-placement, …
Dylan-DPC Sep 7, 2020
b5468e1
Rollup merge of #75138 - jumbatm:session-diagnostic-derive, r=oli-obk
Dylan-DPC Sep 7, 2020
fddf315
Rollup merge of #75585 - RalfJung:demotion, r=oli-obk
Dylan-DPC Sep 7, 2020
f037dca
Rollup merge of #76374 - pickfire:patch-4, r=Cldfire
Dylan-DPC Sep 7, 2020
547806c
Rollup merge of #76379 - petrochenkov:nodegen, r=Mark-Simulacrum
Dylan-DPC Sep 7, 2020
b4007b5
Rollup merge of #76389 - MaulingMonkey:pr-natvis-hashmap-vsc, r=petro…
Dylan-DPC Sep 7, 2020
a79c360
Rollup merge of #76396 - dylni:fix-typo-in-tracking-issue-template, r…
Dylan-DPC Sep 7, 2020
9d649ed
Rollup merge of #76402 - elichai:patch-2, r=wesleywiser
Dylan-DPC Sep 7, 2020
910c87c
Rollup merge of #76403 - scileo:doc-all-impls, r=lcnr
Dylan-DPC Sep 7, 2020
4ab3677
Rollup merge of #76423 - Mark-Simulacrum:stable-bootstrap, r=jyn514
Dylan-DPC Sep 7, 2020
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
add compile-fail test for &mut promotion
  • Loading branch information
RalfJung committed Sep 6, 2020
commit 28ddda76b730960cdfd35f188345af0299e29517
10 changes: 10 additions & 0 deletions src/test/ui/consts/promote-no-mut.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// ignore-tidy-linelength
// We do not promote mutable references.
static mut TEST1: Option<&mut [i32]> = Some(&mut [1, 2, 3]); //~ ERROR temporary value dropped while borrowed

static mut TEST2: &'static mut [i32] = {
let x = &mut [1,2,3]; //~ ERROR temporary value dropped while borrowed
x
};

fn main() {}
23 changes: 23 additions & 0 deletions src/test/ui/consts/promote-no-mut.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
error[E0716]: temporary value dropped while borrowed
--> $DIR/promote-no-mut.rs:3:50
|
LL | static mut TEST1: Option<&mut [i32]> = Some(&mut [1, 2, 3]);
| ----------^^^^^^^^^-
| | | |
| | | temporary value is freed at the end of this statement
| | creates a temporary which is freed while still in use
| using this value as a static requires that borrow lasts for `'static`

error[E0716]: temporary value dropped while borrowed
--> $DIR/promote-no-mut.rs:6:18
|
LL | let x = &mut [1,2,3];
| ^^^^^^^ creates a temporary which is freed while still in use
LL | x
| - using this value as a static requires that borrow lasts for `'static`
LL | };
| - temporary value is freed at the end of this statement

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0716`.
2 changes: 1 addition & 1 deletion src/test/ui/consts/promotion-mutable-ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![feature(const_mut_refs)]

static mut TEST: i32 = {
// We cannot promote this, as CTFE needs to be able to mutate it later.
// We must not promote this, as CTFE needs to be able to mutate it later.
let x = &mut [1,2,3];
x[0] += 1;
x[0]
Expand Down