Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
014333fb
R
Rust
项目概览
int
/
Rust
接近 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
014333fb
编写于
8月 13, 2017
作者:
E
Eduard-Mihai Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Stabilize rvalue promotion to 'static.
上级
c8862468
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
88 addition
and
99 deletion
+88
-99
src/doc/reference
src/doc/reference
+1
-1
src/doc/unstable-book/src/language-features/rvalue-static-promotion.md
...ble-book/src/language-features/rvalue-static-promotion.md
+0
-23
src/librustc/middle/mem_categorization.rs
src/librustc/middle/mem_categorization.rs
+2
-2
src/libsyntax/feature_gate.rs
src/libsyntax/feature_gate.rs
+2
-3
src/test/compile-fail/borrowck/borrowck-borrow-from-temporary.rs
...t/compile-fail/borrowck/borrowck-borrow-from-temporary.rs
+3
-1
src/test/compile-fail/feature-gate-rvalue_static_promotion.rs
...test/compile-fail/feature-gate-rvalue_static_promotion.rs
+0
-15
src/test/compile-fail/issue-11493.rs
src/test/compile-fail/issue-11493.rs
+3
-1
src/test/compile-fail/issue-17545.rs
src/test/compile-fail/issue-17545.rs
+3
-1
src/test/compile-fail/issue-17718-constants-not-static.rs
src/test/compile-fail/issue-17718-constants-not-static.rs
+3
-1
src/test/compile-fail/issue-27592.rs
src/test/compile-fail/issue-27592.rs
+2
-2
src/test/compile-fail/regions-lifetime-of-struct-or-enum-variant.rs
...ompile-fail/regions-lifetime-of-struct-or-enum-variant.rs
+6
-2
src/test/compile-fail/regions-ret.rs
src/test/compile-fail/regions-ret.rs
+3
-1
src/test/compile-fail/regions-var-type-out-of-scope.rs
src/test/compile-fail/regions-var-type-out-of-scope.rs
+3
-1
src/test/compile-fail/static-reference-to-fn-2.rs
src/test/compile-fail/static-reference-to-fn-2.rs
+7
-4
src/test/compile-fail/static-region-bound.rs
src/test/compile-fail/static-region-bound.rs
+3
-1
src/test/run-pass/rvalue-static-promotion.rs
src/test/run-pass/rvalue-static-promotion.rs
+0
-2
src/test/ui/lifetimes/borrowck-let-suggestion.rs
src/test/ui/lifetimes/borrowck-let-suggestion.rs
+1
-1
src/test/ui/lifetimes/borrowck-let-suggestion.stderr
src/test/ui/lifetimes/borrowck-let-suggestion.stderr
+4
-3
src/test/ui/span/borrowck-let-suggestion-suffixes.rs
src/test/ui/span/borrowck-let-suggestion-suffixes.rs
+5
-3
src/test/ui/span/borrowck-let-suggestion-suffixes.stderr
src/test/ui/span/borrowck-let-suggestion-suffixes.stderr
+15
-15
src/test/ui/span/issue-15480.rs
src/test/ui/span/issue-15480.rs
+3
-1
src/test/ui/span/issue-15480.stderr
src/test/ui/span/issue-15480.stderr
+5
-5
src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs
src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs
+3
-1
src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr
...est/ui/span/regions-close-over-borrowed-ref-in-obj.stderr
+6
-6
src/test/ui/span/slice-borrow.rs
src/test/ui/span/slice-borrow.rs
+1
-1
src/test/ui/span/slice-borrow.stderr
src/test/ui/span/slice-borrow.stderr
+4
-2
未找到文件。
reference
@
266d429a
比较
1abfbaa7
...
266d429a
Subproject commit
1abfbaa70313fdf527cf799ffd9b9a096a62105c
Subproject commit
266d429a48468371d2d90669f6a30dd659bb4bdb
src/doc/unstable-book/src/language-features/rvalue-static-promotion.md
已删除
100644 → 0
浏览文件 @
c8862468
# `rvalue_static_promotion`
The tracking issue for this feature is: [#38865]
[
#38865
]:
https://github.com/rust-lang/rust/issues/38865
------------------------
The
`rvalue_static_promotion`
feature allows directly creating
`'static`
references to
constant
`rvalue`
s, which in particular allowing for more concise code in the common case
in which a
`'static`
reference is all that's needed.
## Examples
```
rust
#![feature(rvalue_static_promotion)]
fn
main
()
{
let
DEFAULT_VALUE
:
&
'static
u32
=
&
42
;
assert_eq!
(
*
DEFAULT_VALUE
,
42
);
}
```
src/librustc/middle/mem_categorization.rs
浏览文件 @
014333fb
...
...
@@ -873,10 +873,10 @@ pub fn cat_rvalue_node(&self,
let
promotable
=
self
.tcx.rvalue_promotable_to_static
.borrow
()
.get
(
&
id
)
.cloned
()
.unwrap_or
(
false
);
//
When the corresponding feature isn't toggled, only promote `[T; 0]`
.
//
Always promote `[T; 0]` (even when e.g. borrowed mutably)
.
let
promotable
=
match
expr_ty
.sty
{
ty
::
TyArray
(
_
,
0
)
=>
true
,
_
=>
promotable
&&
self
.tcx.sess.features
.borrow
()
.rvalue_static_promotion
,
_
=>
promotable
,
};
// Compute maximum lifetime of this rvalue. This is 'static if
...
...
src/libsyntax/feature_gate.rs
浏览文件 @
014333fb
...
...
@@ -345,9 +345,6 @@ pub fn new() -> Features {
// Allows `repr(align(u16))` struct attribute (RFC 1358)
(
active
,
repr_align
,
"1.17.0"
,
Some
(
33626
)),
// See rust-lang/rfcs#1414. Allows code like `let x: &'static u32 = &42` to work.
(
active
,
rvalue_static_promotion
,
"1.15.1"
,
Some
(
38865
)),
// Used to preserve symbols (see llvm.used)
(
active
,
used
,
"1.18.0"
,
Some
(
40289
)),
...
...
@@ -457,6 +454,8 @@ pub fn new() -> Features {
(
accepted
,
associated_consts
,
"1.20.0"
,
Some
(
29646
)),
// Usage of the `compile_error!` macro
(
accepted
,
compile_error
,
"1.20.0"
,
Some
(
40872
)),
// See rust-lang/rfcs#1414. Allows code like `let x: &'static u32 = &42` to work.
(
accepted
,
rvalue_static_promotion
,
"1.21.0"
,
Some
(
38865
)),
);
// If you change this, please modify src/doc/unstable-book as well. You must
...
...
src/test/compile-fail/borrowck/borrowck-borrow-from-temporary.rs
浏览文件 @
014333fb
...
...
@@ -11,10 +11,12 @@
// Test lifetimes are linked properly when we take reference
// to interior.
fn
id
<
T
>
(
x
:
T
)
->
T
{
x
}
struct
Foo
(
isize
);
fn
foo
<
'a
>
()
->
&
'a
isize
{
let
&
Foo
(
ref
x
)
=
&
Foo
(
3
);
//~ ERROR borrowed value does not live long enough
let
&
Foo
(
ref
x
)
=
&
id
(
Foo
(
3
)
);
//~ ERROR borrowed value does not live long enough
x
}
...
...
src/test/compile-fail/feature-gate-rvalue_static_promotion.rs
已删除
100644 → 0
浏览文件 @
c8862468
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[allow(unused_variables)]
fn
main
()
{
let
x
:
&
'static
u32
=
&
42
;
//~ error: does not live long enough
let
y
:
&
'static
Option
<
u32
>
=
&
None
;
//~ error: does not live long enough
}
src/test/compile-fail/issue-11493.rs
浏览文件 @
014333fb
...
...
@@ -10,7 +10,9 @@
// This file must never have a trailing newline
fn
id
<
T
>
(
x
:
T
)
->
T
{
x
}
fn
main
()
{
let
x
=
Some
(
3
);
let
y
=
x
.as_ref
()
.unwrap_or
(
&
5
);
//~ ERROR: borrowed value does not live long enough
let
y
=
x
.as_ref
()
.unwrap_or
(
&
id
(
5
)
);
//~ ERROR: borrowed value does not live long enough
}
src/test/compile-fail/issue-17545.rs
浏览文件 @
014333fb
...
...
@@ -10,9 +10,11 @@
#![feature(fn_traits)]
fn
id
<
T
>
(
x
:
T
)
->
T
{
x
}
pub
fn
foo
<
'a
,
F
:
Fn
(
&
'a
())
>
(
bar
:
F
)
{
bar
.call
((
&
(
),
//~ ERROR borrowed value does not live long enough
&
id
(()
),
//~ ERROR borrowed value does not live long enough
));
}
fn
main
()
{}
src/test/compile-fail/issue-17718-constants-not-static.rs
浏览文件 @
014333fb
...
...
@@ -8,9 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
id
<
T
>
(
x
:
T
)
->
T
{
x
}
const
FOO
:
usize
=
3
;
fn
foo
()
->
&
'static
usize
{
&
FOO
}
fn
foo
()
->
&
'static
usize
{
&
id
(
FOO
)
}
//~^ ERROR: borrowed value does not live long enough
fn
main
()
{
...
...
src/test/compile-fail/issue-27592.rs
浏览文件 @
014333fb
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Regression test for issue #2759
1
.
// Regression test for issue #2759
2
.
fn
write
<
'a
,
F
:
::
std
::
ops
::
FnOnce
()
->
::
std
::
fmt
::
Arguments
<
'a
>
+
'a
>
(
fcn
:
F
)
{
use
std
::
fmt
::
Write
;
...
...
@@ -23,7 +23,7 @@ fn write_str(&mut self, _s: &str) -> ::std::fmt::Result {
}
fn
main
()
{
write
(||
format_args!
(
"{}"
,
"Hello world"
));
write
(||
format_args!
(
"{}"
,
String
::
from
(
"Hello world"
)
));
//~^ ERROR borrowed value does not live long enough
//~| ERROR borrowed value does not live long enough
}
src/test/compile-fail/regions-lifetime-of-struct-or-enum-variant.rs
浏览文件 @
014333fb
...
...
@@ -12,6 +12,8 @@
// are treated as rvalues and their lifetime is not bounded to
// the static scope.
fn
id
<
T
>
(
x
:
T
)
->
T
{
x
}
struct
Test
;
enum
MyEnum
{
...
...
@@ -19,12 +21,14 @@ enum MyEnum {
}
fn
structLifetime
<
'a
>
()
->
&
'a
Test
{
let
testValue
=
&
Test
;
//~ ERROR borrowed value does not live long enough
let
testValue
=
&
id
(
Test
);
//~^ ERROR borrowed value does not live long enough
testValue
}
fn
variantLifetime
<
'a
>
()
->
&
'a
MyEnum
{
let
testValue
=
&
MyEnum
::
Variant1
;
//~ ERROR borrowed value does not live long enough
let
testValue
=
&
id
(
MyEnum
::
Variant1
);
//~^ ERROR borrowed value does not live long enough
testValue
}
...
...
src/test/compile-fail/regions-ret.rs
浏览文件 @
014333fb
...
...
@@ -8,8 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
id
<
T
>
(
x
:
T
)
->
T
{
x
}
fn
f
(
_
x
:
&
isize
)
->
&
isize
{
return
&
3
;
//~ ERROR borrowed value does not live long enough
return
&
id
(
3
)
;
//~ ERROR borrowed value does not live long enough
}
fn
main
()
{
...
...
src/test/compile-fail/regions-var-type-out-of-scope.rs
浏览文件 @
014333fb
...
...
@@ -8,13 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
id
<
T
>
(
x
:
T
)
->
T
{
x
}
fn
foo
(
cond
:
bool
)
{
// Here we will infer a type that uses the
// region of the if stmt then block:
let
mut
x
;
if
cond
{
x
=
&
3
;
//~ ERROR borrowed value does not live long enough
x
=
&
id
(
3
)
;
//~ ERROR borrowed value does not live long enough
assert_eq!
(
*
x
,
3
);
}
}
...
...
src/test/compile-fail/static-reference-to-fn-2.rs
浏览文件 @
014333fb
...
...
@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
id
<
T
>
(
x
:
T
)
->
T
{
x
}
struct
StateMachineIter
<
'a
>
{
statefn
:
&
'a
StateMachineFunc
<
'a
>
}
...
...
@@ -23,19 +25,19 @@ fn next(&mut self) -> Option<&'static str> {
}
fn
state1
(
self_
:
&
mut
StateMachineIter
)
->
Option
<&
'static
str
>
{
self_
.statefn
=
&
(
state2
as
StateMachineFunc
);
self_
.statefn
=
&
id
(
state2
as
StateMachineFunc
);
//~^ ERROR borrowed value does not live long enough
return
Some
(
"state1"
);
}
fn
state2
(
self_
:
&
mut
StateMachineIter
)
->
Option
<
(
&
'static
str
)
>
{
self_
.statefn
=
&
(
state3
as
StateMachineFunc
);
self_
.statefn
=
&
id
(
state3
as
StateMachineFunc
);
//~^ ERROR borrowed value does not live long enough
return
Some
(
"state2"
);
}
fn
state3
(
self_
:
&
mut
StateMachineIter
)
->
Option
<
(
&
'static
str
)
>
{
self_
.statefn
=
&
(
finished
as
StateMachineFunc
);
self_
.statefn
=
&
id
(
finished
as
StateMachineFunc
);
//~^ ERROR borrowed value does not live long enough
return
Some
(
"state3"
);
}
...
...
@@ -46,7 +48,8 @@ fn finished(_: &mut StateMachineIter) -> Option<(&'static str)> {
fn
state_iter
()
->
StateMachineIter
<
'static
>
{
StateMachineIter
{
statefn
:
&
(
state1
as
StateMachineFunc
)
//~ ERROR borrowed value does not live long enough
statefn
:
&
id
(
state1
as
StateMachineFunc
)
//~^ ERROR borrowed value does not live long enough
}
}
...
...
src/test/compile-fail/static-region-bound.rs
浏览文件 @
014333fb
...
...
@@ -10,11 +10,13 @@
#![feature(box_syntax)]
fn
id
<
T
>
(
x
:
T
)
->
T
{
x
}
fn
f
<
T
:
'static
>
(
_
:
T
)
{}
fn
main
()
{
let
x
:
Box
<
_
>
=
box
3
;
f
(
x
);
let
x
=
&
3
;
//~ ERROR borrowed value does not live long enough
let
x
=
&
id
(
3
)
;
//~ ERROR borrowed value does not live long enough
f
(
x
);
}
src/test/run-pass/rvalue-static-promotion.rs
浏览文件 @
014333fb
...
...
@@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(rvalue_static_promotion)]
#[allow(unused_variables)]
fn
main
()
{
let
x
:
&
'static
u32
=
&
42
;
...
...
src/test/ui/lifetimes/borrowck-let-suggestion.rs
浏览文件 @
014333fb
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
fn
f
()
{
let
x
=
[
1
]
.iter
();
let
x
=
vec!
[
1
]
.iter
();
}
fn
main
()
{
...
...
src/test/ui/lifetimes/borrowck-let-suggestion.stderr
浏览文件 @
014333fb
error[E0597]: borrowed value does not live long enough
--> $DIR/borrowck-let-suggestion.rs:12:2
3
--> $DIR/borrowck-let-suggestion.rs:12:2
7
|
12 | let x = [1].iter();
| --- ^ temporary value dropped here while still borrowed
12 | let x =
vec!
[1].iter();
| ---
----
^ temporary value dropped here while still borrowed
| |
| temporary value created here
13 | }
| - temporary value needs to live until here
|
= note: consider using a `let` binding to increase its lifetime
= note: this error originates in a macro outside of the current crate
error: aborting due to previous error
src/test/ui/span/borrowck-let-suggestion-suffixes.rs
浏览文件 @
014333fb
...
...
@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
id
<
T
>
(
x
:
T
)
->
T
{
x
}
fn
f
()
{
let
old
=
[
'o'
];
// statement 0
let
mut
v1
=
Vec
::
new
();
// statement 1
...
...
@@ -21,7 +23,7 @@ fn f() {
let
mut
v3
=
Vec
::
new
();
// statement 5
v3
.push
(
&
'x'
);
// statement 6
v3
.push
(
&
id
(
'x'
)
);
// statement 6
//~^ ERROR borrowed value does not live long enough
//~| NOTE temporary value created here
//~| NOTE temporary value only lives until here
...
...
@@ -31,7 +33,7 @@ fn f() {
let
mut
v4
=
Vec
::
new
();
// (sub) statement 0
v4
.push
(
&
'y'
);
v4
.push
(
&
id
(
'y'
)
);
//~^ ERROR borrowed value does not live long enough
//~| NOTE temporary value created here
//~| NOTE temporary value only lives until here
...
...
@@ -42,7 +44,7 @@ fn f() {
let
mut
v5
=
Vec
::
new
();
// statement 8
v5
.push
(
&
'z'
);
v5
.push
(
&
id
(
'z'
)
);
//~^ ERROR borrowed value does not live long enough
//~| NOTE temporary value created here
//~| NOTE temporary value only lives until here
...
...
src/test/ui/span/borrowck-let-suggestion-suffixes.stderr
浏览文件 @
014333fb
error[E0597]: `young[..]` does not live long enough
--> $DIR/borrowck-let-suggestion-suffixes.rs:5
2
:1
--> $DIR/borrowck-let-suggestion-suffixes.rs:5
4
:1
|
19
| v2.push(&young[0]); // statement 4
21
| v2.push(&young[0]); // statement 4
| -------- borrow occurs here
...
5
2
| }
5
4
| }
| ^ `young[..]` dropped here while still borrowed
|
= note: values in a scope are dropped in the opposite order they are created
error[E0597]: borrowed value does not live long enough
--> $DIR/borrowck-let-suggestion-suffixes.rs:2
4:18
--> $DIR/borrowck-let-suggestion-suffixes.rs:2
6:22
|
2
4 | v3.push(&'x'
); // statement 6
| --- ^ temporary value dropped here while still borrowed
2
6 | v3.push(&id('x')
); // statement 6
| ---
----
^ temporary value dropped here while still borrowed
| |
| temporary value created here
...
5
2
| }
5
4
| }
| - temporary value needs to live until here
|
= note: consider using a `let` binding to increase its lifetime
error[E0597]: borrowed value does not live long enough
--> $DIR/borrowck-let-suggestion-suffixes.rs:3
4:22
--> $DIR/borrowck-let-suggestion-suffixes.rs:3
6:26
|
3
4 | v4.push(&'y'
);
| --- ^ temporary value dropped here while still borrowed
3
6 | v4.push(&id('y')
);
| ---
----
^ temporary value dropped here while still borrowed
| |
| temporary value created here
...
4
0
| } // (statement 7)
4
2
| } // (statement 7)
| - temporary value needs to live until here
|
= note: consider using a `let` binding to increase its lifetime
error[E0597]: borrowed value does not live long enough
--> $DIR/borrowck-let-suggestion-suffixes.rs:4
5:18
--> $DIR/borrowck-let-suggestion-suffixes.rs:4
7:22
|
4
5 | v5.push(&'z'
);
| --- ^ temporary value dropped here while still borrowed
4
7 | v5.push(&id('z')
);
| ---
----
^ temporary value dropped here while still borrowed
| |
| temporary value created here
...
5
2
| }
5
4
| }
| - temporary value needs to live until here
|
= note: consider using a `let` binding to increase its lifetime
...
...
src/test/ui/span/issue-15480.rs
浏览文件 @
014333fb
...
...
@@ -8,9 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn
id
<
T
>
(
x
:
T
)
->
T
{
x
}
fn
main
()
{
let
v
=
vec!
[
&
3
&
id
(
3
)
];
for
&&
x
in
&
v
{
...
...
src/test/ui/span/issue-15480.stderr
浏览文件 @
014333fb
error[E0597]: borrowed value does not live long enough
--> $DIR/issue-15480.rs:1
4
:6
--> $DIR/issue-15480.rs:1
6
:6
|
1
3 | &3
| - temporary value created here
1
4
| ];
1
5 | &id(3)
| -
----
temporary value created here
1
6
| ];
| ^ temporary value dropped here while still borrowed
...
19
| }
21
| }
| - temporary value needs to live until here
|
= note: consider using a `let` binding to increase its lifetime
...
...
src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs
浏览文件 @
014333fb
...
...
@@ -10,6 +10,8 @@
#![feature(box_syntax)]
fn
id
<
T
>
(
x
:
T
)
->
T
{
x
}
trait
Foo
{
}
impl
<
'a
>
Foo
for
&
'a
isize
{
}
...
...
@@ -17,7 +19,7 @@ impl<'a> Foo for &'a isize { }
fn
main
()
{
let
blah
;
{
let
ss
:
&
isize
=
&
1
;
let
ss
:
&
isize
=
&
id
(
1
)
;
blah
=
box
ss
as
Box
<
Foo
>
;
}
}
src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr
浏览文件 @
014333fb
error[E0597]: borrowed value does not live long enough
--> $DIR/regions-close-over-borrowed-ref-in-obj.rs:2
2
:5
--> $DIR/regions-close-over-borrowed-ref-in-obj.rs:2
4
:5
|
2
0 | let ss: &isize = &1
;
| - temporary value created here
2
1
| blah = box ss as Box<Foo>;
2
2
| }
2
2 | let ss: &isize = &id(1)
;
| -
----
temporary value created here
2
3
| blah = box ss as Box<Foo>;
2
4
| }
| ^ temporary value dropped here while still borrowed
2
3
| }
2
5
| }
| - temporary value needs to live until here
error: aborting due to previous error
...
...
src/test/ui/span/slice-borrow.rs
浏览文件 @
014333fb
...
...
@@ -13,7 +13,7 @@
fn
main
()
{
let
y
;
{
let
x
:
&
[
isize
]
=
&
[
1
,
2
,
3
,
4
,
5
];
let
x
:
&
[
isize
]
=
&
vec!
[
1
,
2
,
3
,
4
,
5
];
y
=
&
x
[
1
..
];
}
}
src/test/ui/span/slice-borrow.stderr
浏览文件 @
014333fb
error[E0597]: borrowed value does not live long enough
--> $DIR/slice-borrow.rs:18:5
|
16 | let x: &[isize] = &[1, 2, 3, 4, 5];
| --------------- temporary value created here
16 | let x: &[isize] = &
vec!
[1, 2, 3, 4, 5];
| ---------------
----
temporary value created here
17 | y = &x[1..];
18 | }
| ^ temporary value dropped here while still borrowed
19 | }
| - temporary value needs to live until here
|
= note: this error originates in a macro outside of the current crate
error: aborting due to previous error
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录