jiebi/CodeConvo huggingface dataset:
use rustc::mir::{BasicBlock, Location, Mir}; use rustc::mir::Local; use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; <ins> use rustc::traits; use rustc::infer::InferOk; </ins> use rustc::util::common::ErrorReported; <ins> use borrow_check::nll::type_check::AtLocation; </ins> use rustc_data_structures::fx::FxHashSet; use syntax::codemap::DUMMY_SP; use util::liveness::LivenessResults;
<ins> // Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(nll)] pub struct DescriptorSet<'a> { pub slots: Vec<AttachInfo<'a, Resources>> } pub trait ResourcesTrait<'r>: Sized { type DescriptorSet: 'r; } pub struct Resources; impl<'a> ResourcesTrait<'a> for Resources { type DescriptorSet = DescriptorSet<'a>; } pub enum AttachInfo<'a, R: ResourcesTrait<'a>> { NextDescriptorSet(Box<R::DescriptorSet>) } fn main() { let _x = DescriptorSet {slots: Vec::new()}; } </ins>
// Put the lint store levels and passes back in the session. cx.lint_sess.restore(&sess.lint_store); <del> // Emit all buffered lints from early on in the session now that we've // calculated the lint levels for all AST nodes. for (_id, lints) in cx.buffered.map { for early_lint in lints { span_bug!(early_lint.span, "failed to process buffered lint here"); </del> <ins> // All of the buffered lints should have been emitted at this point. // If not, that means that we somehow buffered a lint for a node id // that was not lint-checked (perhaps it doesn't exist?). This is a bug. // // Rustdoc runs everybody-loops before the early lints and removes // function bodies, so it's totally possible for linted // node ids to not exist (e.g. macros defined within functions for the // unused_macro lint) anymore. So we only run this check // when we're not in rustdoc mode. (see issue #47639) if !sess.opts.actually_rustdoc { for (_id, lints) in cx.buffered.map { for early_lint in lints { span_bug!(early_lint.span, "failed to process buffered lint here"); } </ins> } } }
<ins> // Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // This should not ICE pub fn test() { macro_rules! foo { () => () } } </ins>
let task = get_task_id(); // Expect the weak task service to be alive assert service.try_send(RegisterWeakTask(task, shutdown_chan)); <del> unsafe { rust_inc_kernel_live_count(); } </del> <ins> unsafe { rust_dec_kernel_live_count(); } </ins> do fn&() { let shutdown_port = swap_unwrap(&mut *shutdown_port); f(shutdown_port) }.finally || { <del> unsafe { rust_dec_kernel_live_count(); } </del> <ins> unsafe { rust_inc_kernel_live_count(); } </ins> // Service my have already exited service.send(UnregisterWeakTask(task)); }
let port = swap_unwrap(&mut *port); // The weak task service is itself a weak task debug!("weakening the weak service task"); <del> unsafe { rust_inc_kernel_live_count(); } </del> <ins> unsafe { rust_dec_kernel_live_count(); } </ins> run_weak_task_service(port); }.finally { debug!("unweakening the weak service task"); <del> unsafe { rust_dec_kernel_live_count(); } </del> <ins> unsafe { rust_inc_kernel_live_count(); } </ins> } }
<ins> // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Test that multibyte characters don't crash the compiler fn main() { io::println("마이너스 사인이 없으면"); } </ins>
/// #[stable(feature = "rust1", since = "1.0.0")] pub trait BufRead: Read { <del> /// Fills the internal buffer of this object, returning the buffer contents. </del> <ins> /// Returns the contents of the internal buffer, filling it with more data /// from the inner reader if it is empty. </ins> /// /// This function is a lower-level call. It needs to be paired with the /// [`consume`] method to function properly. When calling this
(accepted, type_alias_enum_variants, "1.37.0", Some(49683)), /// Allows macros to appear in the type position. (accepted, type_macros, "1.13.0", Some(27245)), <ins> /// Allows using type privacy lints (`private_interfaces`, `private_bounds`, `unnameable_types`). (accepted, type_privacy_lints, "CURRENT_RUSTC_VERSION", Some(48054)), </ins> /// Allows `const _: TYPE = VALUE`. (accepted, underscore_const_names, "1.37.0", Some(54912)), /// Allows `use path as _;` and `extern crate c as _;`.
/// Allows creation of instances of a struct by moving fields that have /// not changed from prior instances of the same struct (RFC #2528) (unstable, type_changing_struct_update, "1.58.0", Some(86555)), <del> /// Allows using type privacy lints (`private_interfaces`, `private_bounds`, `unnameable_types`). (unstable, type_privacy_lints, "1.72.0", Some(48054)), </del> /// Enables rustc to generate code that instructs libstd to NOT ignore SIGPIPE. (unstable, unix_sigpipe, "1.65.0", Some(97889)), /// Allows unnamed fields of struct and union type
/// /// It is often expected that if you can obtain an object of type `T`, then /// you can name the type `T` as well, this lint attempts to enforce this rule. <ins> /// The recommended action is to either reexport the type properly to make it nameable, /// or document that users are not supposed to be able to name it for one reason or another. /// /// Besides types, this lint applies to traits because traits can also leak through signatures, /// and you may obtain objects of their `dyn Trait` or `impl Trait` types. </ins> pub UNNAMEABLE_TYPES, Allow, "effective visibility of a type is larger than the area in which it can be named", <del> @feature_gate = sym::type_privacy_lints; </del> } declare_lint! {
<del> warning: unknown lint: `unnameable_types` --> $DIR/feature-gate-type_privacy_lints.rs:3:1 | LL | #![warn(unnameable_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the `unnameable_types` lint is unstable = note: see issue #48054 <https://github.com/rust-lang/rust/issues/48054> for more information = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date = note: `#[warn(unknown_lints)]` on by default warning: 1 warning emitted </del>
error: struct `PubStruct` is reachable but cannot be named <del> --> $DIR/unnameable_types.rs:5:5 </del> <ins> --> $DIR/unnameable_types.rs:4:5 </ins> | LL |     pub struct PubStruct(pub i32); |     ^^^^^^^^^^^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)` | note: the lint level is defined here <del> --> $DIR/unnameable_types.rs:2:9 </del> <ins> --> $DIR/unnameable_types.rs:1:9 </ins> | LL | #![deny(unnameable_types)] |         ^^^^^^^^^^^^^^^^ error: enum `PubE` is reachable but cannot be named <del> --> $DIR/unnameable_types.rs:7:5 </del> <ins> --> $DIR/unnameable_types.rs:6:5 </ins> | LL |     pub enum PubE { |     ^^^^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)` error: trait `PubTr` is reachable but cannot be named <del> --> $DIR/unnameable_types.rs:11:5 </del> <ins> --> $DIR/unnameable_types.rs:10:5 </ins> | LL |     pub trait PubTr { |     ^^^^^^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)`
Basic usage: ``` <del> ", $Feature, "assert_eq!(2", stringify!($SelfT), ".pow(4), 16);", $EndFeature, " </del> <ins> ", $Feature, "assert_eq!(2", stringify!($SelfT), ".pow(5), 32);", $EndFeature, " </ins> ```"), #[stable(feature = "rust1", since = "1.0.0")] #[inline]
- checkout: self fetchDepth: 2 <ins> # Spawn a background process to collect CPU usage statistics which we'll upload # at the end of the build. See the comments in the script here for more # information. - bash: python src/ci/cpu-usage-over-time.py &> cpu-usage.csv & displayName: "Collect CPU-usage statistics in the background" </ins> - bash: printenv | sort displayName: Show environment variables
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY) condition: and(succeeded(), or(eq(variables.DEPLOY, '1'), eq(variables.DEPLOY_ALT, '1'))) displayName: Upload artifacts <ins> # Upload CPU usage statistics that we've been gathering this whole time. Always # execute this step in case we want to inspect failed builds, but don't let # errors here ever fail the build since this is just informational. - bash: aws s3 cp --acl public-read cpu-usage.csv s3://$DEPLOY_BUCKET/rustc-builds/$BUILD_SOURCEVERSION/cpu-$SYSTEM_JOBNAME.csv env: AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY) condition: contains(variables, 'AWS_SECRET_ACCESS_KEY') continueOnError: true displayName: Upload CPU usage statistics </ins>
} else { // recent versions of gcc can be configured to generate position // independent executables by default. We have to pass -no-pie to <del> // explicitly turn that off. if sess.target.target.options.linker_is_gnu { </del> <ins> // explicitly turn that off. Not applicable to ld. if sess.target.target.options.linker_is_gnu && sess.linker_flavor() != LinkerFlavor::Ld { </ins> cmd.no_position_independent_executable(); } }
#[unstable(feature = "proc_macro", issue = "38356")] impl iter::FromIterator<TokenTree> for TokenStream { fn from_iter<I: IntoIterator<Item = TokenTree>>(trees: I) -> Self { <ins> trees.into_iter().map(TokenStream::from).collect() } } #[unstable(feature = "proc_macro", issue = "38356")] impl iter::FromIterator<TokenStream> for TokenStream { fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self { </ins> let mut builder = tokenstream::TokenStreamBuilder::new(); <del> for tree in trees { builder.push(tree.to_internal()); </del> <ins> for stream in streams { builder.push(stream.0); </ins> } TokenStream(builder.build()) }
assigned_map: FxHashMap<Place<'tcx>, FxHashSet<BorrowIndex>>, /// Locations which activate borrows. <del> /// NOTE: A given location may activate more than one borrow in the future /// when more general two-phase borrow support is introduced, but for now we /// only need to store one borrow index activation_map: FxHashMap<Location, BorrowIndex>, </del> <ins> activation_map: FxHashMap<Location, FxHashSet<BorrowIndex>>, </ins> /// Every borrow has a region; this maps each such regions back to /// its borrow-indexes.
idx_vec: IndexVec<BorrowIndex, BorrowData<'tcx>>, location_map: FxHashMap<Location, BorrowIndex>, assigned_map: FxHashMap<Place<'tcx>, FxHashSet<BorrowIndex>>, <del> activation_map: FxHashMap<Location, BorrowIndex>, </del> <ins> activation_map: FxHashMap<Location, FxHashSet<BorrowIndex>>, </ins> region_map: FxHashMap<Region<'tcx>, FxHashSet<BorrowIndex>>, local_map: FxHashMap<mir::Local, FxHashSet<BorrowIndex>>, region_span_map: FxHashMap<RegionKind, Span>,
let idx = self.idx_vec.push(borrow); self.location_map.insert(location, idx); <del> // This assert is a good sanity check until more general 2-phase borrow // support is introduced. See NOTE on the activation_map field for more assert!(!self.activation_map.contains_key(&activate_location), "More than one activation introduced at the same location."); self.activation_map.insert(activate_location, idx); </del> <ins> insert(&mut self.activation_map, &activate_location, idx); </ins> insert(&mut self.assigned_map, assigned_place, idx); insert(&mut self.region_map, &region, idx); if let Some(local) = root_local(borrowed_place) {
location: Location) { // Handle activations match self.activation_map.get(&location) { <del> Some(&activated) => { debug!("activating borrow {:?}", activated); sets.gen(&ReserveOrActivateIndex::active(activated)) </del> <ins> Some(activations) => { for activated in activations { debug!("activating borrow {:?}", activated); sets.gen(&ReserveOrActivateIndex::active(*activated)) } </ins> } None => {} }
<ins> // Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(nll)] struct Foo { } impl Foo { fn method(&mut self, foo: &mut Foo) { } } fn main() { let mut foo = Foo { }; foo.method(&mut foo); //~^     cannot borrow `foo` as mutable more than once at a time //~^^    cannot borrow `foo` as mutable more than once at a time } </ins>
<ins> error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/two-phase-multi-mut.rs:23:16 | LL |     foo.method(&mut foo); |     -----------^^^^^^^^- |     |          | |     |          second mutable borrow occurs here |     first mutable borrow occurs here |     borrow later used here error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/two-phase-multi-mut.rs:23:5 | LL |     foo.method(&mut foo); |     ^^^^^^^^^^^--------^ |     |          | |     |          first mutable borrow occurs here |     second mutable borrow occurs here |     borrow later used here error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0499`. </ins>
<ins> // Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // revisions: lxl nll //[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows //[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll // run-pass use std::io::Result; struct Foo {} pub trait FakeRead { fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>; } impl FakeRead for Foo { fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> { Ok(4) } } fn main() { let mut a = Foo {}; let mut v = Vec::new(); a.read_to_end(&mut v); } </ins>
} } <ins> #[stable(feature = "os_str_str_ref_eq", since = "1.28.0")] impl<'a> PartialEq<&'a str> for OsString { fn eq(&self, other: &&'a str) -> bool { **self == **other } } #[stable(feature = "os_str_str_ref_eq", since = "1.28.0")] impl<'a> PartialEq<OsString> for &'a str { fn eq(&self, other: &OsString) -> bool { **other == **self } } </ins> #[stable(feature = "rust1", since = "1.0.0")] impl Eq for OsString {}
<ins> // Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::ffi::OsString; fn main() { let os_str = OsString::from("Hello Rust!"); assert_eq!(os_str, "Hello Rust!"); assert_eq!("Hello Rust!", os_str); } </ins>
impl Sealed for ops::RangeInclusive<usize> {} #[stable(feature = "slice_get_slice", since = "1.28.0")] impl Sealed for ops::RangeToInclusive<usize> {} <ins> #[stable(feature = "slice_index_with_ops_bound_pair", since = "1.53.0")] impl Sealed for (ops::Bound<usize>, ops::Bound<usize>) {} </ins> } /// A helper trait used for indexing operations.
ops::Range { start, end } } <ins> /// Convert pair of `ops::Bound`s into `ops::Range` without performing any bounds checking and (in debug) overflow checking fn into_range_unchecked( len: usize, (start, end): (ops::Bound<usize>, ops::Bound<usize>), ) -> ops::Range<usize> { use ops::Bound; let start = match start { Bound::Included(i) => i, Bound::Excluded(i) => i + 1, Bound::Unbounded => 0, }; let end = match end { Bound::Included(i) => i + 1, Bound::Excluded(i) => i, Bound::Unbounded => len, }; start..end } /// Convert pair of `ops::Bound`s into `ops::Range`. /// Returns `None` on overflowing indices. fn into_range( len: usize, (start, end): (ops::Bound<usize>, ops::Bound<usize>), ) -> Option<ops::Range<usize>> { use ops::Bound; let start = match start { Bound::Included(start) => start, Bound::Excluded(start) => start.checked_add(1)?, Bound::Unbounded => 0, }; let end = match end { Bound::Included(end) => end.checked_add(1)?, Bound::Excluded(end) => end, Bound::Unbounded => len, }; // Don't bother with checking `start < end` and `end <= len` // since these checks are handled by `Range` impls Some(start..end) } /// Convert pair of `ops::Bound`s into `ops::Range`. /// Panics on overflowing indices. fn into_slice_range( len: usize, (start, end): (ops::Bound<usize>, ops::Bound<usize>), ) -> ops::Range<usize> { use ops::Bound; let start = match start { Bound::Included(start) => start, Bound::Excluded(start) => { start.checked_add(1).unwrap_or_else(|| slice_start_index_overflow_fail()) } Bound::Unbounded => 0, }; let end = match end { Bound::Included(end) => { end.checked_add(1).unwrap_or_else(|| slice_end_index_overflow_fail()) } Bound::Excluded(end) => end, Bound::Unbounded => len, }; // Don't bother with checking `start < end` and `end <= len` // since these checks are handled by `Range` impls start..end } #[stable(feature = "slice_index_with_ops_bound_pair", since = "1.53.0")] unsafe impl<T> SliceIndex<[T]> for (ops::Bound<usize>, ops::Bound<usize>) { type Output = [T]; #[inline] fn get(self, slice: &[T]) -> Option<&Self::Output> { into_range(slice.len(), self)?.get(slice) } #[inline] fn get_mut(self, slice: &mut [T]) -> Option<&mut Self::Output> { into_range(slice.len(), self)?.get_mut(slice) } #[inline] unsafe fn get_unchecked(self, slice: *const [T]) -> *const Self::Output { // SAFETY: the caller has to uphold the safety contract for `get_unchecked`. unsafe { into_range_unchecked(slice.len(), self).get_unchecked(slice) } } #[inline] unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut Self::Output { // SAFETY: the caller has to uphold the safety contract for `get_unchecked_mut`. unsafe { into_range_unchecked(slice.len(), self).get_unchecked_mut(slice) } } #[inline] fn index(self, slice: &[T]) -> &Self::Output { into_slice_range(slice.len(), self).index(slice) } #[inline] fn index_mut(self, slice: &mut [T]) -> &mut Self::Output { into_slice_range(slice.len(), self).index_mut(slice) } } </ins>
bad: data[7..=6]; message: "out of range"; } <ins> in mod boundpair_len { data: [0, 1, 2, 3, 4, 5]; good: data[(Bound::Included(6), Bound::Unbounded)] == []; good: data[(Bound::Unbounded, Bound::Included(5))] == [0, 1, 2, 3, 4, 5]; good: data[(Bound::Unbounded, Bound::Excluded(6))] == [0, 1, 2, 3, 4, 5]; good: data[(Bound::Included(0), Bound::Included(5))] == [0, 1, 2, 3, 4, 5]; good: data[(Bound::Included(0), Bound::Excluded(6))] == [0, 1, 2, 3, 4, 5]; good: data[(Bound::Included(2), Bound::Excluded(4))] == [2, 3]; good: data[(Bound::Excluded(1), Bound::Included(4))] == [2, 3, 4]; good: data[(Bound::Excluded(5), Bound::Excluded(6))] == []; good: data[(Bound::Included(6), Bound::Excluded(6))] == []; good: data[(Bound::Excluded(5), Bound::Included(5))] == []; good: data[(Bound::Included(6), Bound::Included(5))] == []; bad: data[(Bound::Unbounded, Bound::Included(6))]; message: "out of range"; } </ins> } panic_cases! {
bad: data[4..=2]; message: "but ends at"; } <ins> in mod boundpair_neg_width { data: [0, 1, 2, 3, 4, 5]; good: data[(Bound::Included(4), Bound::Excluded(4))] == []; bad: data[(Bound::Included(4), Bound::Excluded(3))]; message: "but ends at"; } </ins> } panic_cases! {
bad: data[..= usize::MAX]; message: "maximum usize"; } <ins> in mod boundpair_overflow_end { data: [0; 1]; bad: data[(Bound::Unbounded, Bound::Included(usize::MAX))]; message: "maximum usize"; } in mod boundpair_overflow_start { data: [0; 1]; bad: data[(Bound::Excluded(usize::MAX), Bound::Unbounded)]; message: "maximum usize"; } </ins> } // panic_cases! }
//! which do not. use rustc_data_structures::bitvec::BitVector; <ins> use rustc_data_structures::control_flow_graph::dominators::Dominators; </ins> use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc::mir::{self, Location, TerminatorKind}; use rustc::mir::visit::{Visitor, PlaceContext};
use type_of::LayoutLlvmExt; use super::FunctionCx; <del> pub fn memory_locals<'a, 'tcx>(fx: &FunctionCx<'a, 'tcx>) -> BitVector { </del> <ins> pub fn non_ssa_locals<'a, 'tcx>(fx: &FunctionCx<'a, 'tcx>) -> BitVector { </ins> let mir = fx.mir; let mut analyzer = LocalAnalyzer::new(fx);
// (e.g. structs) into an alloca unconditionally, just so // that we don't have to deal with having two pathways // (gep vs extractvalue etc). <del> analyzer.mark_as_memory(mir::Local::new(index)); </del> <ins> analyzer.not_ssa(mir::Local::new(index)); </ins> } } <del> analyzer.memory_locals </del> <ins> analyzer.non_ssa_locals </ins> } struct LocalAnalyzer<'mir, 'a: 'mir, 'tcx: 'a> { fx: &'mir FunctionCx<'a, 'tcx>, <del> memory_locals: BitVector, seen_assigned: BitVector </del> <ins> dominators: Dominators<mir::BasicBlock>, non_ssa_locals: BitVector, // The location of the first visited direct assignment to each // local, or an invalid location (out of bounds `block` index). first_assignment: IndexVec<mir::Local, Location> </ins> } impl<'mir, 'a, 'tcx> LocalAnalyzer<'mir, 'a, 'tcx> { fn new(fx: &'mir FunctionCx<'a, 'tcx>) -> LocalAnalyzer<'mir, 'a, 'tcx> { <ins> let invalid_location = mir::BasicBlock::new(fx.mir.basic_blocks().len()).start_location(); </ins> let mut analyzer = LocalAnalyzer { fx, <del> memory_locals: BitVector::new(fx.mir.local_decls.len()), seen_assigned: BitVector::new(fx.mir.local_decls.len()) </del> <ins> dominators: fx.mir.dominators(), non_ssa_locals: BitVector::new(fx.mir.local_decls.len()), first_assignment: IndexVec::from_elem(invalid_location, &fx.mir.local_decls) </ins> }; // Arguments get assigned to by means of the function being called <del> for idx in 0..fx.mir.arg_count { analyzer.seen_assigned.insert(idx + 1); </del> <ins> for arg in fx.mir.args_iter() { analyzer.first_assignment[arg] = mir::START_BLOCK.start_location(); </ins> } analyzer } <del> fn mark_as_memory(&mut self, local: mir::Local) { debug!("marking {:?} as memory", local); self.memory_locals.insert(local.index()); </del> <ins> fn first_assignment(&self, local: mir::Local) -> Option<Location> { let location = self.first_assignment[local]; if location.block.index() < self.fx.mir.basic_blocks().len() { Some(location) } else { None } </ins> } <del> fn mark_assigned(&mut self, local: mir::Local) { if !self.seen_assigned.insert(local.index()) { self.mark_as_memory(local); </del> <ins> fn not_ssa(&mut self, local: mir::Local) { debug!("marking {:?} as non-SSA", local); self.non_ssa_locals.insert(local.index()); } fn assign(&mut self, local: mir::Local, location: Location) { if self.first_assignment(local).is_some() { self.not_ssa(local); } else { self.first_assignment[local] = location; </ins> } } }
debug!("visit_assign(block={:?}, place={:?}, rvalue={:?})", block, place, rvalue); if let mir::Place::Local(index) = *place { <del> self.mark_assigned(index); </del> <ins> self.assign(index, location); </ins> if !self.fx.rvalue_creates_operand(rvalue) { <del> self.mark_as_memory(index); </del> <ins> self.not_ssa(index); </ins> } } else { self.visit_place(place, PlaceContext::Store, location);