{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,11,21]],"date-time":"2026-11-21T19:45:07Z","timestamp":1795290307829,"version":"4.10.3"},"reference-count":41,"publisher":"Association for Computing Machinery (ACM)","issue":"OOPSLA","license":[{"start":{"date-parts":[[2020,11,13]],"date-time":"2020-11-13T00:00:00Z","timestamp":1605225600000},"content-version":"vor","delay-in-days":0,"URL":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/"}],"funder":[{"DOI":"10.13039\/501100001711","name":"SNSF","doi-asserted-by":"crossref","award":["200021_169503"],"award-info":[{"award-number":["200021_169503"]}],"id":[{"id":"10.13039\/501100001711","id-type":"DOI","asserted-by":"crossref"}]}],"content-domain":{"domain":["dl.acm.org"],"crossmark-restriction":true},"short-container-title":["Proc. ACM Program. Lang."],"published-print":{"date-parts":[[2020,11,13]]},"abstract":"<jats:p>\n            Rust\u2019s ownership type system enforces a strict discipline on how memory locations are accessed and shared. This discipline allows the compiler to statically prevent memory errors, data races, inadvertent side effects through aliasing, and other errors that frequently occur in conventional imperative programs. However, the restrictions imposed by Rust\u2019s type system make it difficult or impossible to implement certain designs, such as data structures that require aliasing (e.g. doubly-linked lists and shared caches). To work around this limitation, Rust allows code blocks to be declared as\n            <jats:italic>unsafe<\/jats:italic>\n            and thereby exempted from certain restrictions of the type system, for instance, to manipulate C-style raw pointers. Ensuring the safety of unsafe code is the responsibility of the programmer. However, an important assumption of the Rust language, which we dub the\n            <jats:italic>Rust hypothesis<\/jats:italic>\n            , is that programmers use Rust by following three main principles: use unsafe code sparingly, make it easy to review, and hide it behind a safe abstraction such that client code can be written in safe Rust.\n          <\/jats:p>\n          <jats:p>Understanding how Rust programmers use unsafe code and, in particular, whether the Rust hypothesis holds is essential for Rust developers and testers, language and library designers, as well as tool developers. This paper studies empirically how unsafe code is used in practice by analysing a large corpus of Rust projects to assess the validity of the Rust hypothesis and to classify the purpose of unsafe code. We identify queries that can be answered by automatically inspecting the program\u2019s source code, its intermediate representation MIR, as well as type information provided by the Rust compiler; we complement the results by manual code inspection. Our study supports the Rust hypothesis partially: While most unsafe code is simple and well-encapsulated, unsafe features are used extensively, especially for interoperability with other languages.<\/jats:p>","DOI":"10.1145\/3428204","type":"journal-article","created":{"date-parts":[[2020,11,24]],"date-time":"2020-11-24T23:36:06Z","timestamp":1606260966000},"page":"1-27","update-policy":"https:\/\/doi.org\/10.1145\/crossmark-policy","source":"Crossref","is-referenced-by-count":86,"title":["How do programmers use unsafe rust?"],"prefix":"10.1145","volume":"4","author":[{"given":"Vytautas","family":"Astrauskas","sequence":"first","affiliation":[{"name":"ETH Zurich, Switzerland"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"given":"Christoph","family":"Matheja","sequence":"additional","affiliation":[{"name":"ETH Zurich, Switzerland"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"given":"Federico","family":"Poli","sequence":"additional","affiliation":[{"name":"ETH Zurich, Switzerland"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"given":"Peter","family":"M\u00fcller","sequence":"additional","affiliation":[{"name":"ETH Zurich, Switzerland"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"given":"Alexander J.","family":"Summers","sequence":"additional","affiliation":[{"name":"University of British Columbia, Canada"}],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"320","published-online":{"date-parts":[[2020,11,13]]},"reference":[{"key":"e_1_2_2_1_1","volume-title":"The Rustwide library. https:\/\/crates.io\/crates\/rustwide Accessed","author":"Albini Pietro","year":"2020"},{"key":"e_1_2_2_2_1","doi-asserted-by":"publisher","DOI":"10.1145\/3360573"},{"key":"e_1_2_2_3_1","doi-asserted-by":"publisher","DOI":"10.1145\/3139645.3139660"},{"key":"e_1_2_2_4_1","volume-title":"Rust For Systems Programmers. https:\/\/github.com\/nrc\/r4cppp Accessed","author":"Cameron Nick","year":"2020"},{"key":"e_1_2_2_5_1","doi-asserted-by":"publisher","DOI":"10.1145\/286936.286947"},{"key":"e_1_2_2_6_1","volume-title":"Fast Actors. In International Workshop on Programming Based on Actors, Agents, and Decentralized Control (AGERE! 2015 ). ACM, 1-12","author":"Clebsch Sylvan","year":"2015"},{"key":"e_1_2_2_7_1","volume-title":"https:\/\/github.com\/rust-lang\/rust-clippy Accessed","author":"Clippy Clippy","year":"2019"},{"key":"e_1_2_2_8_1","volume-title":"Website of Code QL. https:\/\/semmle.com\/codeql Accessed","author":"Code QL.","year":"2020"},{"key":"e_1_2_2_9_1","volume-title":"Safety of intrinsics. https:\/\/github.com\/rust-lang\/compiler-builtins\/issues\/355 Accessed","year":"2020"},{"key":"e_1_2_2_10_1","volume-title":"Is Rust Used Safely by Software Developers? CoRR abs\/","author":"Evans Ana Nora","year":"2007"},{"key":"e_1_2_2_11_1","volume-title":"Fuchsia Documentation-Unsafe Code in Rust. https:\/\/fuchsia.googlesource.com\/fuchsia\/+\/master\/ docs\/development\/languages\/rust\/unsafe.md Accessed","author":"Team Fuchsia","year":"2020"},{"key":"e_1_2_2_12_1","volume-title":"Demystifying unsafe code (Talk at Rust NYC). https:\/\/youtu.be\/QAz-maaH0KM Accessed on","author":"Gjengset Jon","year":"2020"},{"key":"e_1_2_2_14_1","volume-title":"The Scope of Unsafe. https:\/\/www.ralfj.de\/blog\/2016\/01\/09\/the-scope-of-unsafe. html Accessed","author":"Jung Ralf","year":"2019"},{"key":"e_1_2_2_15_1","doi-asserted-by":"publisher","DOI":"10.1145\/3158154"},{"key":"e_1_2_2_16_1","unstructured":"Ralf Jung Jacques-Henri Jourdan Robbert Krebbers and Derek Dreyer. 2020. Safe Systems Programming in Rust: The Promise and the Challenge. Commun. ACM (to appear) ( 2020 ). https:\/\/people.mpi-sws.org\/~dreyer\/papers\/safe-sysprogrust\/paper.pdf  Ralf Jung Jacques-Henri Jourdan Robbert Krebbers and Derek Dreyer. 2020. Safe Systems Programming in Rust: The Promise and the Challenge. Commun. ACM (to appear) ( 2020 ). https:\/\/people.mpi-sws.org\/~dreyer\/papers\/safe-sysprogrust\/paper.pdf"},{"key":"e_1_2_2_17_1","volume-title":"The Jupyter project. https:\/\/jupyter.org\/ Accessed","author":"Team Jupyter","year":"2020"},{"key":"e_1_2_2_18_1","volume-title":"The Rust Programming Language. https:\/\/doc.rust-lang.org\/book\/ Accessed","author":"Klabnik Steve","year":"2020"},{"key":"e_1_2_2_19_1","doi-asserted-by":"publisher","DOI":"10.1145\/3124680.3124717"},{"key":"e_1_2_2_20_1","volume-title":"LLVM Atomic Instructions and Concurrency Guide. https:\/\/llvm.org\/docs\/Atomics.html Accessed","author":"Team LLVM","year":"2020"},{"key":"e_1_2_2_21_1","unstructured":"Nicholas D. Matsakis. 2016. Unsafe abstractions. http:\/\/smallcultfollowing.com\/babysteps\/blog\/2016\/05\/23\/unsafeabstractions Accessed on May 5th 2020 ; Matsakis is co-leader of the Rust compiler team.  Nicholas D. Matsakis. 2016. Unsafe abstractions. http:\/\/smallcultfollowing.com\/babysteps\/blog\/2016\/05\/23\/unsafeabstractions Accessed on May 5th 2020 ; Matsakis is co-leader of the Rust compiler team."},{"key":"e_1_2_2_22_1","volume-title":"Project idea: datalog output from rustc. https:\/\/smallcultfollowing.com\/babysteps\/blog\/2017\/ 02\/17\/project-idea-datalog-output-from-rustc\/ Accessed","author":"Matsakis Nicholas D.","year":"2020"},{"key":"e_1_2_2_23_1","doi-asserted-by":"publisher","DOI":"10.1109\/QRS.2018.00028"},{"key":"e_1_2_2_24_1","doi-asserted-by":"publisher","DOI":"10.1007\/3-540-45651-1"},{"key":"e_1_2_2_25_1","volume-title":"Unsafe in Rust: Syntactic Patterns. https:\/\/cs.stanford.edu\/~aozdemir\/blog\/unsafe-rust-syntax Accessed on May 5th","author":"Ozdemir Alex","year":"2020"},{"key":"e_1_2_2_26_1","doi-asserted-by":"publisher","DOI":"10.1109\/ICSE.2013.6606620"},{"key":"e_1_2_2_27_1","doi-asserted-by":"publisher","DOI":"10.1145\/3385412.3386036"},{"key":"e_1_2_2_28_1","volume-title":"Snippet from Redox OS Repository. https:\/\/github.com\/redox-os\/relibc\/blob\/ 2cbc78f238b3eda426171def100f44707cfe8ae3\/src\/platform\/pte.rs# L337-L345 Accessed","author":"Redox","year":"2020"},{"key":"e_1_2_2_29_1","volume-title":"Rust Survey 2019 Results. https:\/\/blog.rust-lang.org\/ 2020 \/04\/17\/Rust-survey-2019.html Accessed","author":"Team Rust Language","year":"2020"},{"key":"e_1_2_2_30_1","volume-title":"Rust: The Reference. https:\/\/doc.rust-lang.org\/reference\/ Accessed","author":"Team Rust","year":"2018"},{"key":"e_1_2_2_31_1","volume-title":"Mission Statement of the Secure Code Working Group. https:\/\/github.com\/rust-secure-code\/wg Accessed","author":"Team Rust","year":"2020"},{"key":"e_1_2_2_32_1","volume-title":"The Rustonomicon. https:\/\/doc.rust-lang.org\/nomicon\/ Accessed","author":"Team Rust","year":"2020"},{"key":"e_1_2_2_33_1","volume-title":"The Cargo Book. https:\/\/doc.rust-lang.org\/cargo\/reference\/build-scripts. html#-sys-packages Accessed","author":"Team Rust","year":"2020"},{"key":"e_1_2_2_34_1","volume-title":"File: check_unsafety.rs. https:\/\/github.com\/rust-lang\/rust\/blob\/ 27ae2f0d60d9201133e1f9ec7a04c05c8e55e665\/src\/librustc_mir\/transform\/check_unsafety. rs Accessed","author":"Team Rust","year":"2020"},{"key":"e_1_2_2_35_1","volume-title":"Rust Documentation of Transmute. https:\/\/doc.rust-lang.org\/std\/mem\/fn.transmute. html Accessed","author":"Team Rust","year":"2020"},{"key":"e_1_2_2_36_1","volume-title":"Rust: The Reference-Module std::cell. https:\/\/doc.rust-lang.org\/std\/cell\/index.html Accessed","author":"Team Rust","year":"2020"},{"key":"e_1_2_2_37_1","volume-title":"Rust: The Reference-Module std::slice. https:\/\/doc.rust-lang.org\/std\/slice\/index.html Accessed","author":"Team Rust","year":"2020"},{"key":"e_1_2_2_38_1","volume-title":"Rust: The Reference-Module std::sync::atomic. https:\/\/doc.rust-lang.org\/std\/sync\/atomic\/ Accessed","author":"Team Rust","year":"2020"},{"key":"e_1_2_2_39_1","doi-asserted-by":"publisher","DOI":"10.5281\/zenodo.4085004"},{"key":"e_1_2_2_40_1","volume-title":"Core Repository of the Libra Project. https:\/\/github.com\/libra\/libra\/blob\/ 8d9bba00629e602051e40bab2b80e7ed89f40c0b\/storage\/storage-client\/src\/state_view.rs# L96-L97 Accessed","author":"The Libra Association","year":"2020"},{"key":"e_1_2_2_41_1","volume-title":"Project website. https:\/\/github.com\/rust-lang\/unsafe-code-guidelines Accessed","author":"Unsafe Code Guidelines Working Group","year":"2020"},{"key":"e_1_2_2_42_1","doi-asserted-by":"publisher","DOI":"10.1201\/9781420040579.ch5"}],"container-title":["Proceedings of the ACM on Programming Languages"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3428204","content-type":"unspecified","content-version":"vor","intended-application":"text-mining"},{"URL":"https:\/\/dl.acm.org\/doi\/pdf\/10.1145\/3428204","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2025,6,17]],"date-time":"2025-06-17T22:02:56Z","timestamp":1750197776000},"score":1,"resource":{"primary":{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3428204"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2020,11,13]]},"references-count":41,"journal-issue":{"issue":"OOPSLA","published-print":{"date-parts":[[2020,11,13]]}},"alternative-id":["10.1145\/3428204"],"URL":"https:\/\/doi.org\/10.1145\/3428204","relation":{},"ISSN":["2475-1421"],"issn-type":[{"value":"2475-1421","type":"electronic"}],"subject":[],"published":{"date-parts":[[2020,11,13]]},"assertion":[{"value":"2020-11-13","order":2,"name":"published","label":"Published","group":{"name":"publication_history","label":"Publication History"}}]}}