{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,10,2]],"date-time":"2026-10-02T10:20:34Z","timestamp":1790936434497,"version":"4.1.0"},"reference-count":50,"publisher":"Association for Computing Machinery (ACM)","issue":"OOPSLA2","license":[{"start":{"date-parts":[[2023,10,16]],"date-time":"2023-10-16T00:00:00Z","timestamp":1697414400000},"content-version":"vor","delay-in-days":0,"URL":"https:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/"}],"funder":[{"name":"Singapore Ministry of Education","award":["MOE-MOET32021-0001"],"award-info":[{"award-number":["MOE-MOET32021-0001"]}]}],"content-domain":{"domain":["dl.acm.org"],"crossmark-restriction":true},"short-container-title":["Proc. ACM Program. Lang."],"published-print":{"date-parts":[[2023,10,16]]},"abstract":"<jats:p>We present a design and implementation of the automated \"Extract Method\" refactoring for Rust programs. Even though Extract Method is one of the most well-studied and widely used in practice automated refactorings, featured in all major IDEs for all popular programming languages, implementing it soundly for Rust is surprisingly non-trivial due to the restrictions of the Rust's ownership and lifetime-based type system.<\/jats:p>\n          <jats:p>In this work, we provide a systematic decomposition of the Extract Method refactoring for Rust programs into a series of program transformations, each concerned with satisfying a particular aspect of Rust type safety, eventually producing a well-typed Rust program. Our key discovery is the formulation of Extract Method as a composition of naive function hoisting and a series of automated program repair procedures that progressively make the resulting program \"more well-typed\" by relying on the corresponding repair oracles. Those oracles include a novel static intra-procedural ownership analysis that infers correct sharing annotations for the extracted function's parameters, and the lifetime checker of rustc, Rust's reference compiler.<\/jats:p>\n          <jats:p>We implemented our approach in a tool called REM---an automated Extract Method refactoring built on top of IntelliJ IDEA plugin for Rust. Our extensive evaluation on a corpus of changes in five popular Rust projects shows that REM (a) can extract a larger class of feature-rich code fragments into semantically correct functions than other existing refactoring tools, (b) can reproduce method extractions performed manually by human developers in the past, and (c) is efficient enough to be used in interactive development.<\/jats:p>","DOI":"10.1145\/3622821","type":"journal-article","created":{"date-parts":[[2023,10,16]],"date-time":"2023-10-16T15:41:29Z","timestamp":1697470889000},"page":"658-685","update-policy":"https:\/\/doi.org\/10.1145\/crossmark-policy","source":"Crossref","is-referenced-by-count":6,"title":["Adventure of a Lifetime: Extract Method Refactoring for Rust"],"prefix":"10.1145","volume":"7","author":[{"ORCID":"https:\/\/orcid.org\/0009-0005-8798-7809","authenticated-orcid":false,"given":"Sewen","family":"Thy","sequence":"first","affiliation":[{"name":"Yale-NUS College, Singapore, Singapore"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0002-9089-9392","authenticated-orcid":false,"given":"Andreea","family":"Costea","sequence":"additional","affiliation":[{"name":"National University of Singapore, Singapores, Singapore"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0002-1877-9871","authenticated-orcid":false,"given":"Kiran","family":"Gopinathan","sequence":"additional","affiliation":[{"name":"National University of Singapore, Singapore, Singapore"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0003-4250-5392","authenticated-orcid":false,"given":"Ilya","family":"Sergey","sequence":"additional","affiliation":[{"name":"National University of Singapore, Singapore, Singapore"}],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"320","published-online":{"date-parts":[[2023,10,16]]},"reference":[{"key":"e_1_2_1_1_1","volume-title":"Program analysis and specialization for the C programming language. Ph. D. Dissertation","author":"Andersen Lars Ole","unstructured":"Lars Ole Andersen . 1994. Program analysis and specialization for the C programming language. Ph. D. Dissertation . University of Copenhagen. Denmark. Lars Ole Andersen. 1994. Program analysis and specialization for the C programming language. Ph. D. Dissertation. University of Copenhagen. Denmark."},{"key":"e_1_2_1_2_1","unstructured":"Isaiah Ayooluwa Ledru Sylvestre and Ivy Roy. 2020. Rewriting the GNU Coreutils in Rust. https:\/\/lwn.net\/Articles\/857599\/ \t\t\t\t  Isaiah Ayooluwa Ledru Sylvestre and Ivy Roy. 2020. Rewriting the GNU Coreutils in Rust. https:\/\/lwn.net\/Articles\/857599\/"},{"key":"e_1_2_1_3_1","doi-asserted-by":"publisher","DOI":"10.1145\/1094811.1094832"},{"key":"e_1_2_1_4_1","doi-asserted-by":"publisher","DOI":"10.1145\/582419.582440"},{"key":"e_1_2_1_5_1","doi-asserted-by":"publisher","DOI":"10.1007\/3-540-45337-7_2"},{"key":"e_1_2_1_6_1","doi-asserted-by":"publisher","DOI":"10.1145\/582419.582447"},{"key":"e_1_2_1_7_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-642-36946-9_3"},{"key":"e_1_2_1_8_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-540-45070-2_9"},{"key":"e_1_2_1_9_1","doi-asserted-by":"publisher","DOI":"10.1145\/286936.286947"},{"key":"e_1_2_1_10_1","doi-asserted-by":"publisher","DOI":"10.1145\/3485498"},{"key":"e_1_2_1_11_1","volume-title":"Refactoring: Improving the Design of Existing Code","author":"Fowler Martin","year":"1999","unstructured":"Martin Fowler and Kent Beck . 1999 . Refactoring: Improving the Design of Existing Code . Addison-Wesley . Martin Fowler and Kent Beck. 1999. Refactoring: Improving the Design of Existing Code. Addison-Wesley."},{"key":"e_1_2_1_12_1","doi-asserted-by":"publisher","DOI":"10.1145\/1028664.1028669"},{"key":"e_1_2_1_13_1","volume-title":"Program Restructuring as an Aid to Software Maintenance. Ph. D. Dissertation","author":"Griswold William G.","unstructured":"William G. Griswold . 1992. Program Restructuring as an Aid to Software Maintenance. Ph. D. Dissertation . University of Washington. USA . William G. Griswold. 1992. Program Restructuring as an Aid to Software Maintenance. Ph. D. Dissertation. University of Washington. USA."},{"key":"e_1_2_1_14_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-642-31057-7_9"},{"key":"e_1_2_1_15_1","doi-asserted-by":"publisher","DOI":"10.1145\/2398857.2384680"},{"key":"e_1_2_1_16_1","unstructured":"Immunant Inc.. 2022. c2rust. Available at https:\/\/c2rust.com \t\t\t\t  Immunant Inc.. 2022. c2rust. Available at https:\/\/c2rust.com"},{"key":"e_1_2_1_17_1","doi-asserted-by":"publisher","DOI":"10.1145\/1636642.1636655"},{"key":"e_1_2_1_18_1","volume-title":"1st Workshop on Refactoring Tools (WRT). 48\u201349","author":"Juillerat Nicolas","year":"2007","unstructured":"Nicolas Juillerat and B\u00e9at Hirsbrunner . 2007 . Improving Method Extraction: A Novel Approach to Data Flow Analysis Using Boolean Flags and Expressions . In 1st Workshop on Refactoring Tools (WRT). 48\u201349 . Nicolas Juillerat and B\u00e9at Hirsbrunner. 2007. Improving Method Extraction: A Novel Approach to Data Flow Analysis Using Boolean Flags and Expressions. In 1st Workshop on Refactoring Tools (WRT). 48\u201349."},{"key":"e_1_2_1_19_1","doi-asserted-by":"publisher","DOI":"10.1145\/1368088.1368147"},{"key":"e_1_2_1_20_1","doi-asserted-by":"publisher","DOI":"10.1109\/ICSE.2007.70"},{"key":"e_1_2_1_21_1","doi-asserted-by":"publisher","DOI":"10.1016\/j.scico.2004.03.002"},{"key":"e_1_2_1_22_1","doi-asserted-by":"publisher","DOI":"10.1109\/MS.2021.3072577"},{"key":"e_1_2_1_23_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-642-28872-2_34"},{"key":"e_1_2_1_24_1","doi-asserted-by":"publisher","DOI":"10.1016\/j.entcs.2005.02.053"},{"key":"e_1_2_1_25_1","doi-asserted-by":"publisher","DOI":"10.1145\/1297027.1297059"},{"key":"e_1_2_1_26_1","unstructured":"Nicholas D. Matsakis. 2017. The Rust RFC Book: Non-Lexical Lifetimes. https:\/\/rust-lang.github.io\/rfcs\/2094-nll.html \t\t\t\t  Nicholas D. Matsakis. 2017. The Rust RFC Book: Non-Lexical Lifetimes. https:\/\/rust-lang.github.io\/rfcs\/2094-nll.html"},{"key":"e_1_2_1_27_1","unstructured":"Nicholas D. Matsakis. 2017. The Rust RFC Book: Statements and expressions. https:\/\/doc.rust-lang.org\/reference\/statements-and-expressions.html \t\t\t\t  Nicholas D. Matsakis. 2017. The Rust RFC Book: Statements and expressions. https:\/\/doc.rust-lang.org\/reference\/statements-and-expressions.html"},{"key":"e_1_2_1_28_1","doi-asserted-by":"publisher","DOI":"10.1109\/TSE.2004.1265817"},{"key":"e_1_2_1_29_1","unstructured":"Microsoft. 2023. Refactoring in Visual Studio Code.  https:\/\/code.visualstudio.com\/docs\/editor\/refactoring \t\t\t\t  Microsoft. 2023. Refactoring in Visual Studio Code.  https:\/\/code.visualstudio.com\/docs\/editor\/refactoring"},{"key":"e_1_2_1_30_1","doi-asserted-by":"publisher","DOI":"10.1145\/1368088.1368146"},{"key":"e_1_2_1_31_1","volume-title":"ECOOP (LNCS)","author":"Negara Stas","unstructured":"Stas Negara , Nicholas Chen , Mohsen Vakilian , Ralph E. Johnson , and Danny Dig . 2013. A Comparative Study of Manual and Automated Refactorings . In ECOOP (LNCS) . Springer , 552\u2013576. https:\/\/doi.org\/978-3-642-39038-8_23 Stas Negara, Nicholas Chen, Mohsen Vakilian, Ralph E. Johnson, and Danny Dig. 2013. A Comparative Study of Manual and Automated Refactorings. In ECOOP (LNCS). Springer, 552\u2013576. https:\/\/doi.org\/978-3-642-39038-8_23"},{"key":"e_1_2_1_32_1","volume-title":"Refactoring object-oriented frameworks. Ph. D. Dissertation","author":"Opdyke William F.","unstructured":"William F. Opdyke . 1991. Refactoring object-oriented frameworks. Ph. D. Dissertation . University of Illinois at Urbana-Champaign. USA . William F. Opdyke. 1991. Refactoring object-oriented frameworks. Ph. D. Dissertation. University of Illinois at Urbana-Champaign. USA."},{"key":"e_1_2_1_33_1","doi-asserted-by":"publisher","DOI":"10.1145\/3385412.3386036"},{"key":"e_1_2_1_34_1","volume-title":"Automated Refactoring of Rust Programs. Master\u2019s thesis","author":"Ringdal Per Ove","unstructured":"Per Ove Ringdal . 2020. Automated Refactoring of Rust Programs. Master\u2019s thesis . University of Oslo . Per Ove Ringdal. 2020. Automated Refactoring of Rust Programs. Master\u2019s thesis. University of Oslo."},{"key":"e_1_2_1_35_1","doi-asserted-by":"publisher","DOI":"10.5555\/280606.280610"},{"key":"e_1_2_1_36_1","volume-title":"Practical Analysis for Refactoring. Ph. D. Dissertation","author":"Roberts Donald Bradley","unstructured":"Donald Bradley Roberts . 1999. Practical Analysis for Refactoring. Ph. D. Dissertation . University of Illinois at Urbana-Champaign. USA . Donald Bradley Roberts. 1999. Practical Analysis for Refactoring. Ph. D. Dissertation. University of Illinois at Urbana-Champaign. USA."},{"key":"e_1_2_1_37_1","doi-asserted-by":"publisher","DOI":"10.1145\/3314221.3314600"},{"key":"e_1_2_1_38_1","unstructured":"The Rust Reference. 2023. Lifetime Elision.  https:\/\/doc.rust-lang.org\/reference\/lifetime-elision.html \t\t\t\t  The Rust Reference. 2023. Lifetime Elision.  https:\/\/doc.rust-lang.org\/reference\/lifetime-elision.html"},{"key":"e_1_2_1_39_1","unstructured":"The Rust Team. 2017. The Rust programming language.  http:\/\/rust-lang.org \t\t\t\t  The Rust Team. 2017. The Rust programming language.  http:\/\/rust-lang.org"},{"key":"e_1_2_1_40_1","doi-asserted-by":"publisher","DOI":"10.1145\/3014812.3014826"},{"key":"e_1_2_1_41_1","volume-title":"Implementation and Verification of Refactorings. Ph. D. Dissertation","author":"Sch\u00e4fer Max","unstructured":"Max Sch\u00e4fer . 2010. Specification , Implementation and Verification of Refactorings. Ph. D. Dissertation . University of Oxford. UK . Max Sch\u00e4fer. 2010. Specification, Implementation and Verification of Refactorings. Ph. D. Dissertation. University of Oxford. UK."},{"key":"e_1_2_1_42_1","doi-asserted-by":"publisher","DOI":"10.1145\/1869459.1869485"},{"key":"e_1_2_1_43_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-642-28869-2_29"},{"key":"e_1_2_1_44_1","unstructured":"Ilya Sergey Dave Clarke and Alexander Podkhalyuzin. 2010. Automatic refactorings for Scala programs. KU Leuven.  http:\/\/lirias.kuleuven.be\/1652327 \t\t\t\t  Ilya Sergey Dave Clarke and Alexander Podkhalyuzin. 2010. Automatic refactorings for Scala programs. KU Leuven.  http:\/\/lirias.kuleuven.be\/1652327"},{"key":"e_1_2_1_45_1","doi-asserted-by":"publisher","DOI":"10.1145\/3156016"},{"key":"e_1_2_1_46_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-642-03013-0_19"},{"key":"e_1_2_1_47_1","doi-asserted-by":"publisher","DOI":"10.5281\/zenodo.8124395"},{"key":"e_1_2_1_48_1","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-540-74061-2_1"},{"key":"e_1_2_1_49_1","doi-asserted-by":"publisher","DOI":"10.1145\/949305.949308"},{"key":"e_1_2_1_50_1","doi-asserted-by":"publisher","DOI":"10.1109\/ASE.2009.68"}],"container-title":["Proceedings of the ACM on Programming Languages"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3622821","content-type":"unspecified","content-version":"vor","intended-application":"text-mining"},{"URL":"https:\/\/dl.acm.org\/doi\/pdf\/10.1145\/3622821","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2025,6,17]],"date-time":"2025-06-17T16:37:04Z","timestamp":1750178224000},"score":1,"resource":{"primary":{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3622821"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2023,10,16]]},"references-count":50,"journal-issue":{"issue":"OOPSLA2","published-print":{"date-parts":[[2023,10,16]]}},"alternative-id":["10.1145\/3622821"],"URL":"https:\/\/doi.org\/10.1145\/3622821","relation":{},"ISSN":["2475-1421"],"issn-type":[{"value":"2475-1421","type":"electronic"}],"subject":[],"published":{"date-parts":[[2023,10,16]]},"assertion":[{"value":"2023-10-16","order":2,"name":"published","label":"Published","group":{"name":"publication_history","label":"Publication History"}}]}}