Use std::mem::take instead of std::mem::replace with default values#157307
Use std::mem::take instead of std::mem::replace with default values#157307theherrovn-sys wants to merge 1 commit into
std::mem::take instead of std::mem::replace with default values#157307Conversation
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @mejrs (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
Replace std::mem::take(&mut x, Default::default()) and equivalent patterns (e.g. String::new(), Vec::new(), false) with the idiomatic std::mem::take(&mut x) in the compiler source. See rust-lang/rust issue 157245.
|
Hi, For the last few months we have been receiving an increased amount of slop by users running bots that generate contributions, and even misconfiguring their bot so it will even send generated apology emails on top. We have no way to distinguish your PR from your other generated ones and no way to determine whether you actually want to contribute. We are a community of contributors, not just a code repository. Thus we focus on contributors who desire to stay around and put in the work to produce high quality contributions or learn to do so. We are thus banning you as per our policies (1) and contribution standards (2). You can contact the moderation team to discuss and possibly reconsider your ban. Thanks for understanding Oli in the name of the mod team |
Replace
std::mem::replace(&mut x, Default::default())and equivalent patterns (e.g.String::new(),Vec::new(),false) with the more idiomaticstd::mem::take(&mut x)across the compiler source.This improves code readability and aligns with Rust best practices, matching the clippy lint
mem_replace_with_default.Closes #157245.
Changes
compiler/rustc_span/src/lib.rsstd::mem::replace(src, String::new())→std::mem::take(src)compiler/rustc_middle/src/dep_graph/serialized.rsmem::replace(&mut local.encoder.data, Vec::new())→mem::take(&mut local.encoder.data)compiler/rustc_passes/src/dead.rsmem::replace(&mut self.in_pat, false)→mem::take(&mut self.in_pat)compiler/rustc_passes/src/check_export.rsstd::mem::replace(&mut self.seen_exportable_in_mod, false)→std::mem::take(...)compiler/rustc_mir_build/src/check_unsafety.rsstd::mem::replace(&mut self.inside_adt, false)→std::mem::take(...)compiler/rustc_middle/src/ty/print/pretty.rsstd::mem::replace(&mut self.in_value, false)→std::mem::take(...)compiler/rustc_builtin_macros/src/proc_macro_harness.rsmem::replace(&mut self.in_root, false)→mem::take(&mut self.in_root)