λ€μ μμμ ν΄λ‘μ λ νμν κ²λ³΄λ€ λ μ€λ κ°μ μ°¨μ©ν©λλ€:
fn main () {
let f = |y| { println!("{}", y); };
let x = 4u8;
f(&x);
}
μ»΄νμΌ μ€λ₯κ° λ°μνλ μμΈ:
error: `x` does not live long enough
--> ./test.rs:5:1
|
4 | f(&x);
| - borrow occurs here
5 | }
| ^ `x` dropped here while still borrowed
|
= note: values in a scope are dropped in the opposite order they are created
κ·Έλ¬λ μΈμ μ νμ λͺ μμ μΌλ‘ μ μΈνλ©΄ μμλλ‘ μλν©λλ€.
fn main () {
let f = |y: &u8| { println!("{}", y); };
let x = 4u8;
f(&x);
}
κ·Έκ²μ΄ λ²κ·ΈμΈμ§ μμλλ λμμΈμ§ νμ€νμ§ μμ΅λλ€. λ¬Έμμμ μ΄ ν¨κ³Όμ λν μ€λͺ λ μ°Ύμ μ μμ΅λλ€.
rustc --version --verbose
:
rustc 1.17.0-nightly (24a70eb59 2017-02-09)
binary: rustc
commit-hash: 24a70eb598a76edb0941f628a87946b40f2a1c83
commit-date: 2017-02-09
host: x86_64-unknown-linux-gnu
release: 1.17.0-nightly
LLVM version: 3.9
κ²μ μμ§μ λν μ©μ΄λ₯Ό μμ νκΈ° μν΄: μ€λ μ¬μ©μ ν¬λΌμμ μ΄κ²μ νμνλ©΄μ |x: &u8|
μλνλ μ΄μ κ° HRTBμ λν ννΈ μν μ νλ κ²κ³Ό κ΄λ ¨μ΄ μμ μ μλ€λ κ°ν μΈμμ λ°μμ΅λλ€.
κ΄λ ¨μ΄ μμ μ μμ: λλ μ΄κ²(νΉν huonμ 10μ μμ )λ λ§λ¬μ΅λλ€. μ¦, λͺ μμ μ£Όμ μμ΄ _λ§ μλν©λλ€. https://github.com/rust-lang/rust/issues/22557
Triage: μ΄μ 2018λ
μ μ»΄νμΌλ©λλ€.
2015λ
μ€λ₯:
error[E0597]: `x` does not live long enough
--> src/main.rs:4:8
|
4 | f(&x);
| ^ borrowed value does not live long enough
5 | }
| - `x` dropped here while still borrowed
|
= note: values in a scope are dropped in the opposite order they are created
rustc: 1.32.0
μ΄κ²μ λ μ΄μ λ μλμ λͺ¨λμμ nightlyμμ λ¬Έμ κ° λμ§ μμΌλ―λ‘ μ’ λ£ν©λλ€.
κ°μ₯ μ μ©ν λκΈ
Triage: μ΄μ 2018λ μ μ»΄νμΌλ©λλ€.
2015λ μ€λ₯:
rustc: 1.32.0