����� � ���� ������ ������������������������� �������������������������� � � � � � � � � � � �������� ��� ����������� ����� ����� ��� �� ���� ����� �� �� ���� ���� ��� RUST DISTILLED : AN EXPRESSIVE TOWER OF LANGUAGES Aaron Weiss , Daniel Patterson, Amal Ahmed Northeastern University and Inria Paris
“ Rust is a systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety. – the official Rust website
“ systems programming Rust is a systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety. – the official Rust website
“ Rust is a systems programming blazingly fast language that runs blazingly fast, prevents segfaults, and guarantees thread safety. – the official Rust website
“ Rust is a systems programming language that runs blazingly fast, prevents segfaults, and guarantees prevents segfaults, guarantees thread safety. thread safety. – the official Rust website
Memory safety without garbage collection Abstraction without overhead Concurrency without data races Stability without stagnation Hack without fear.
WE HAVE CUTE CRABS
... BUT HOW?
... BUT HOW? Ownership x y z identifiers "own" values
... BUT HOW? Ownership x y z identifiers "own" values Borrowing x y z &x references "borrow" values
A PROGRAM IN RUST extern crate irc; use irc �:; client �:; prelude �:; *; fn main() �-? irc �:; error �:; Result<()> { let config = Config { ��../ }; let mut reactor = IrcReactor �:; new()?; let client = reactor.prepare_client_and_connect(&config)?; client.identify()?; reactor.register_client_with_handler(client, |client, message| { print!("{}", message); Ok(()) }); reactor.run()?; }
A PROGRAM IN RUST extern crate irc; use irc �:; client �:; prelude �:; *; fn main() �-? irc �:; error �:; Result<()> { let config = Config { ��../ }; let mut reactor = IrcReactor �:; new()?; let client = reactor.prepare_client_and_connect(&config)?; client.identify()?; reactor.register_client_with_handler(client, |client, message| { print!("{}", message); Ok(()) }); reactor.run()?; }
A PROGRAM IN RUST extern crate irc; use irc �:; client �:; prelude �:; *; fn main() �-? irc �:; error �:; Result<()> { let config = Config { ��../ }; let mut reactor = IrcReactor �:; new()?; let client = reactor.prepare_client_and_connect(&config)?; client.identify()?; reactor.register_client_with_handler(client, |client, message| { print!("{}", message); Ok(()) }); reactor.run()?; }
A PROGRAM IN RUST extern crate irc; use irc �:; client �:; prelude �:; *; fn main() �-? irc �:; error �:; Result<()> { let config = Config { ��../ }; let mut reactor = IrcReactor �:; new()?; let client = reactor.prepare_client_and_connect(&config)?; client.identify()?; reactor.register_client_with_handler(client, |client, message| { print!("{}", message); Ok(()) }); reactor.run()?; }
A PROGRAM IN RUST extern crate irc; use irc �:; client �:; prelude �:; *; fn main() �-? irc �:; error �:; Result<()> { let config = Config { ��../ }; let mut reactor = IrcReactor �:; new()?; let client = reactor.prepare_client_and_connect(&config)?; client.identify()?; reactor.register_client_with_handler(client, |client, message| { print!("{}", message); Ok(()) }); reactor.run()?; }
A PROGRAM IN RUST extern crate irc; use irc �:; client �:; prelude �:; *; fn main() �-? irc �:; error �:; Result<()> { let config = Config { ��../ }; let mut reactor = IrcReactor �:; new()?; let client = reactor.prepare_client_and_connect(&config)?; client.identify()?; reactor.register_client_with_handler(client, |client, message| { print!("{}", message); Ok(()) }); reactor.run()?; }
A PROGRAM IN RUST extern crate irc; use irc �:; client �:; prelude �:; *; fn main() �-? irc �:; error �:; Result<()> { let config = Config { ��../ }; let mut reactor = IrcReactor �:; new()?; let client = reactor.prepare_client_and_connect(&config)?; &config client.identify()?; reactor.register_client_with_handler(client, |client, message| { print!("{}", message); Ok(()) }); reactor.run()?; }
A PROGRAM IN RUST extern crate irc; use irc �:; client �:; prelude �:; *; fn main() �-? irc �:; error �:; Result<()> { let config = Config { ��../ }; let mut reactor = IrcReactor �:; new()?; let client = reactor.prepare_client_and_connect(&config)?; client.identify()?; reactor.register_client_with_handler(client, |client, message| { client print!("{}", message); Ok(()) }); reactor.run()?; }
⊢ γεια ⊢ ελλάδα
THE CURRENT STATE OF AFFAIRS
THE CURRENT STATE OF AFFAIRS RUST interprocedural static analysis with ad-hoc constraint solving
THE CURRENT STATE OF AFFAIRS RUST interprocedural static analysis with ad-hoc constraint solving RUSTBELT (JUNG, JOURDAN, KREBBERS, AND DREYER, POPL '18) formal language specified in Iris but low-level, in a CPS-style .
BUT WE WANT TO DO BETTER
BUT WE WANT TO DO BETTER
CAPABILITIES FOR OWNERSHIP x y z
CAPABILITIES FOR OWNERSHIP x y z capabilities guard the use of identifiers
BORROWS BREAK CAPABILITIES INTO FRACTIONS x y z
BORROWS BREAK CAPABILITIES INTO FRACTIONS &x x y z
BORROWS BREAK CAPABILITIES INTO FRACTIONS &x x y z
BORROWS BREAK CAPABILITIES INTO FRACTIONS &x &mut z x y z
BORROWS BREAK CAPABILITIES INTO FRACTIONS &x &mut z x y z
MOVES TAKE THE CAPABILITY AND THE HOLE &x &mut z x y z
MOVES TAKE THE CAPABILITY AND THE HOLE &x &mut z x y z w
WE CALL REFERENCE SITES LOANS extern crate irc; use irc �:; client �:; prelude �:; *; fn main() �-? irc �:; error �:; Result<()> { a loan let config = Config { ��../ }; let mut reactor = IrcReactor �:; new()?; let client = reactor.prepare_client_and_connect(&config)?; &config client.identify()?; reactor.register_client_with_handler(client, |client, message| { print!("{}", message); Ok(()) }); reactor.run()?; }
WHAT ABOUT LIFETIMES?
WHAT ABOUT LIFETIMES? x : u32
WHAT ABOUT LIFETIMES? x : u32 &x : &'x u32
WHAT ABOUT LIFETIMES? x : u32 &x : &'x u32 To keep type-checking tractable, regions correspond to sets of loans.
TYPE CHECKING
TYPE CHECKING global context Σ
TYPE CHECKING global context Σ ; Δ type variable context
TYPE CHECKING global context variable context Σ ; Δ ; Γ type variable context
TYPE CHECKING global context variable context Σ ; Δ ; Γ ; L loan context type variable context
TYPE CHECKING global context variable context region context Σ ; Δ ; Γ ; L ; P loan context type variable context
TYPE CHECKING global context variable context region context Σ ; Δ ; Γ ; L ; P ⊢ e loan context type variable context
TYPE CHECKING global context variable context region context Σ ; Δ ; Γ ; L ; P ⊢ e : τ loan context type variable context
TYPE CHECKING global context variable context region context Σ ; Δ ; Γ ; L ; P ⊢ e : τ ⇒ ε ownership effects loan context type variable context
TYPING BORROWS Γ , x : f τ ; L ; P ⊢ &' a x : Σ ; Δ ;
TYPING BORROWS f ≠ 0 Γ , x : f τ ; L ; P ⊢ &' a x : Σ ; Δ ;
TYPING BORROWS f ≠ 0 x : &{ Γ , x : f τ ; L ; P ⊢ &' a ' a } τ Σ ; Δ ;
TYPING BORROWS f ≠ 0 Γ , x : f τ ; L ; P ⊢ &' a x : &{ ' a } τ Σ ; Δ ; ⇒ borrow imm x as ' a
TYPING BRANCHING Σ ; Δ ; Γ ; L ; P ⊢ if { } else { } e 3 : e 1 e 2 Σ ; Δ ;
TYPING BRANCHING Σ ; Δ ; Γ ; L ; P ⊢ e 1 : bool ⇒ ε 1 Σ ; Δ ; Σ ; Δ ; Γ ; L ; P ⊢ if { } else { } e 3 : e 1 e 2 Σ ; Δ ;
TYPING BRANCHING Σ ; Δ ; Γ ; L ; P ⊢ e 1 : bool ⇒ ε 1 Σ ; Δ ; Σ ; Δ ; Σ ; Δ ; ε 1 ( Γ ); ε 1 ( L ); ε 1 ( P ) ⊢ e 2 : τ 2 ⇒ ε 2 Σ ; Δ ; Γ ; L ; P ⊢ if { } else { } e 3 : e 1 e 2 Σ ; Δ ;
TYPING BRANCHING Σ ; Δ ; Γ ; L ; P ⊢ e 1 : bool ⇒ ε 1 Σ ; Δ ; Σ ; Δ ; Σ ; Δ ; ε 1 ( Γ ); ε 1 ( L ); ε 1 ( P ) ⊢ e 2 : τ 2 ⇒ ε 2 Σ ; Δ ; ε 1 ( Γ ); ε 1 ( L ); ε 1 ( P ) ⊢ e 3 : τ 3 ⇒ ε 3 Σ ; Δ ; Σ ; Δ ; Γ ; L ; P ⊢ if { } else { } e 3 : e 1 e 2 Σ ; Δ ;
TYPING BRANCHING Σ ; Δ ; Γ ; L ; P ⊢ e 1 : bool ⇒ ε 1 Σ ; Δ ; Σ ; Δ ; Σ ; Δ ; ε 1 ( Γ ); ε 1 ( L ); ε 1 ( P ) ⊢ e 2 : τ 2 ⇒ ε 2 Σ ; Δ ; ε 1 ( Γ ); ε 1 ( L ); ε 1 ( P ) ⊢ e 3 : τ 3 ⇒ ε 3 Σ ; Δ ; τ 2 ∼ τ 3 ⇒ τ Σ ; Δ ; Γ ; L ; P ⊢ if { } else { } e 3 : e 1 e 2 Σ ; Δ ;
Recommend
More recommend