jiebi/CodeConvo huggingface dataset:
Change:
This generates the following (broken) MIR: As you can see, is dropped but never written to (AFAIK this should be OK because of zeroing) but the boxes are never freed.
cc
EDIT: I wasn’t looking closely enough, it is indeed broken.
This is a problem on latest master ()

Discussion:
self.diverge_cleanup(); let scope = self.scopes.pop().unwrap(); assert_eq!(scope.extent, extent); <del> build_scope_drops(block, &scope, &self.scopes[..], &mut self.cfg) </del> <ins> build_scope_drops(&mut self.cfg, &scope, &self.scopes[..], block) </ins> }

self.hir.span_bug(span, &format!("extent {:?} does not enclose", extent)) }); <ins> let tmp = self.get_unit_temp(); </ins> for (idx, ref scope) in self.scopes.iter().enumerate().rev().take(scope_count) { <del> unpack!(block = build_scope_drops(block, scope, &self.scopes[..idx], &mut self.cfg)); </del> <ins> unpack!(block = build_scope_drops(&mut self.cfg, scope, &self.scopes[..idx], block)); if let Some(ref free_data) = scope.free { let next = self.cfg.start_new_block(); let free = build_free(self.hir.tcx(), tmp.clone(), free_data, next); self.cfg.terminate(block, free); block = next; } </ins> } self.cfg.terminate(block, Terminator::Goto { target: target }); }

} /// Builds drops for pop_scope and exit_scope. <del> fn build_scope_drops<'tcx>(mut block: BasicBlock, </del> <ins> fn build_scope_drops<'tcx>(cfg: &mut CFG<'tcx>, </ins> scope: &Scope<'tcx>, earlier_scopes: &[Scope<'tcx>], <del> cfg: &mut CFG<'tcx>) </del> <ins> mut block: BasicBlock) </ins> -> BlockAnd<()> { let mut iter = scope.drops.iter().rev().peekable(); while let Some(drop_data) = iter.next() {

target = if let Some(cached_block) = free_data.cached_block { cached_block } else { <del> let t = build_free(tcx, cfg, unit_temp, free_data, target); free_data.cached_block = Some(t); t </del> <ins> let into = cfg.start_new_cleanup_block(); cfg.terminate(into, build_free(tcx, unit_temp, free_data, target)); free_data.cached_block = Some(into); into </ins> } };

} fn build_free<'tcx>(tcx: &ty::ctxt<'tcx>, <del> cfg: &mut CFG<'tcx>, </del> unit_temp: Lvalue<'tcx>, data: &FreeData<'tcx>, <del> target: BasicBlock) -> BasicBlock { </del> <ins> target: BasicBlock) -> Terminator<'tcx> { </ins> let free_func = tcx.lang_items.box_free_fn() .expect("box_free language item is missing"); let substs = tcx.mk_substs(Substs::new( VecPerParamSpace::new(vec![], vec![], vec![data.item_ty]), VecPerParamSpace::new(vec![], vec![], vec![]) )); <del> let block = cfg.start_new_cleanup_block(); cfg.terminate(block, Terminator::Call { </del> <ins> Terminator::Call { </ins> func: Operand::Constant(Constant { span: data.span, ty: tcx.lookup_item_type(free_func).ty.subst(tcx, substs),

args: vec![Operand::Consume(data.value.clone())], destination: Some((unit_temp, target)), cleanup: None <del> }); block </del> <ins> } </ins> }
Change:
At the moment, 's and doc pages don't quite make it clear that its contents are in fact contiguous. They imply it in several places... it would be better to make it more clear. In addition, 's documentation refers to it as a "growable list type", which could be misleading in light of this; "list" is more often used to mean a linked list. Perhaps something like one of these would be better as the description line:
A more global description is a nice idea. However, keeping the original text is also a nice thing, it's appreciated to have algorithm's complexity. So from my point of view, this would be perfect:
part of

Discussion:
``` (Notice that unlike the `println!` macro we’ve used in the past, we use square <del> brackets `[]` with `vec!` macro. Rust allows you to use either in either situation, this is just convention.) </del> <ins> brackets `[]` with `vec!` macro. Rust allows you to use either in either situation, this is just convention.) </ins> There’s an alternate form of `vec!` for repeating an initial value:

let v = vec![0; 10]; // ten zeroes ``` <ins> Vectors store their contents as contiguous arrays of `T` on the heap. This means that they must be able to know the size of `T` at compile time (that is, how many bytes are needed to store a `T`?). The size of some things can't be known at compile time. For these you'll have to store a pointer to that thing: thankfully, the [`Box`][box] type works perfectly for this. </ins> ## Accessing elements To get the value at a particular index in the vector, we use `[]`s:

API documentation][vec]. [vec]: ../std/vec/index.html <ins> [box]: ../std/boxed/index.html </ins> [generic]: generics.html [panic]: concurrency.html#panics [get]: http://doc.rust-lang.org/std/vec/struct.Vec.html#method.get

// option. This file may not be copied, modified, or distributed // except according to those terms. <del> //! A growable list type with heap-allocated contents, written `Vec<T>` but //! pronounced 'vector.' </del> <ins> //! A contiguous growable array type with heap-allocated contents, written //! `Vec<T>` but pronounced 'vector.' </ins> //! //! Vectors have `O(1)` indexing, amortized `O(1)` push (to the end) and //! `O(1)` pop (from the end).

use super::range::RangeArgument; <del> /// A growable list type, written `Vec<T>` but pronounced 'vector.' </del> <ins> /// A contiguous growable array type, written `Vec<T>` but pronounced 'vector.' </ins> /// /// # Examples ///
Change:
It just happend with my unrelated pull request on auto-win-msvc-32-opt. It is the only test that dit not complete between this build and the previous. It also contains the comment: "this test will never finish if the child doesn't wake up"
This seems to be relevant. A thread may not wake up on Windows if a socket is shut down.
Hm that just seems to indicate that the child will eventually wake up... I wonder if would fix the problem here?

Discussion:
} #[test] <ins> #[cfg(unix)] // test doesn't work on Windows, see #31657 </ins> fn close_read_wakes_up() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr));
Change:
It just happend with my unrelated pull request on auto-win-msvc-32-opt. It is the only test that dit not complete between this build and the previous. It also contains the comment: "this test will never finish if the child doesn't wake up"
This seems to be relevant. A thread may not wake up on Windows if a socket is shut down.
Hm that just seems to indicate that the child will eventually wake up... I wonder if would fix the problem here?

Discussion:
} #[test] <del> #[cfg(unix)] // test doesn't work on Windows, see #31657 </del> fn close_read_wakes_up() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr));
Change:
Currently the consts translation pass can only handle indexing into a slice if it represents an entire vec, not a sub-vec thereof. Since we don't (presently) have any syntax for making a sub-slice as a const expr, this isn't a big deal. Yet. But it might become one in the future. If so, we need to do a fair bit more work in the const translator, since it appears LLVM doesn't want to feed us back the number-values of consts that depend in any way on the size of a datum. Such as, say, a size bound. Awkward.

Discussion:
~"index is not an integer-constant  expression") }; <del> let (arr, _len) = match ty::get(bt).sty { </del> <ins> let (arr, len) = match ty::get(bt).sty { </ins> ty::ty_evec(_, vstore) | ty::ty_estr(vstore) => match vstore { ty::vstore_fixed(u) =>

a vector or string type") }; <del> // FIXME #3169: This is a little odd but it arises due to a // weird wrinkle in LLVM: it doesn't appear willing to let us // call LLVMConstIntGetZExtValue on the size element of the // slice, or seemingly any integer-const involving a sizeof() // call. Despite that being "a const", it's not the kind of // const you can ask for the integer-value of, evidently. This // might be an LLVM bug, not sure. In any case, to work around // this we obtain the initializer and count how many elements it // has, ignoring the length we pulled out of the slice. (Note // that the initializer might be a struct rather than an array, // if enums are involved.) This only works because we picked out // the original globalvar via const_deref and so can recover the // array-size of the underlying array (or the element count of // the underlying struct), and all this will hold together // exactly as long as we _don't_ support const sub-slices (that // is, slices that represent something other than a whole // array).  At that point we'll have more and uglier work to do // here, but for now this should work. // // In the future, what we should be doing here is the // moral equivalent of: // // let len = llvm::LLVMConstIntGetZExtValue(len) as u64; // // but we might have to do substantially more magic to // make it work. Or figure out what is causing LLVM to // not want to consider sizeof() a constant expression // we can get the value (as a number) out of. let len = llvm::LLVMGetNumOperands(arr) as u64; </del> <ins> let len = llvm::LLVMConstIntGetZExtValue(len) as u64; </ins> let len = match ty::get(bt).sty { ty::ty_estr(*) => {assert len > 0; len - 1}, _ => len
Change:
This code: When run with produces this invalid code because it's losing a newline: With , however, it produces this syntactically correct code:
Moving this bug over to syntex:
Oops, closed the wrong ticket.

Discussion:
} try!(self.maybe_print_comment(attr.span.lo)); if attr.node.is_sugared_doc { <del> word(self.writer(), &attr.value_str().unwrap()) </del> <ins> try!(word(self.writer(), &attr.value_str().unwrap())); hardbreak(self.writer()) </ins> } else { match attr.node.style { ast::AttrStyle::Inner => try!(word(self.writer(), "#![")),

<ins> /// Some doc comment. struct X; // ignore-license // Copyright 2012-2013 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. // pp-exact // Test that rust can properly pretty print a doc comment if it's the first line in a file.  some fn main() { let x = X; } </ins>
Change:
I know that it's implied by the , but it wasn't immediately obvious to me that the chunks returned by can (I'm avoiding use of the term "recursive" here) have or called on themselves (). Is there any interest in a PR that makes this explicit? It seems that especially when working with threads and work-stealing, this is something that users want to do.
Is it enough to stress that each chunk is itself a slice (or mutable slice)?
Hm. What would be the distinction between stressing it and showing it? In theory, it should be obvious that because the chunk is a slice, you can call on it. At the same time, it depends on the intended audience; For the beginner, it means that there's no need to go off to the playpen or ask a question (which may or may not be a good thing, depending on your point of view). Either option is an improvement, and I'm probably over-thinking the whole thing now.
In general, API docs usually are written for an intermediate/advanced user: we don't generally mention "oh and because this has a return type of foo you can call these other things on it." Where does this stop and end?
Fair point. But what about explicitly stating that the functions return slices, as opposed to "an iterator"?
It does return an iterator - an iterator over slices.
Undeniably true, but I don't think it's clear; The docs say "an iterator over / elements_ of the slice".
I'm not sure one would be able to use and correctly without understanding that they yield slices. Once you understand that you can use to divide a slice into more slices, surely it makes sense that one can divide those slices in yet more slices, In much the same way that one can add two numbers and use the result for further addition.
Yes we should clarify the docs to say it returns an iterator whose elements are slices.

Discussion:
} /// Returns an iterator over `size` elements of the slice at a <del> /// time. The chunks do not overlap. If `size` does not divide the </del> <ins> /// time. The chunks are slices and do not overlap. If `size` does not divide the </ins> /// length of the slice, then the last chunk will not have length /// `size`. ///

} /// Returns an iterator over `chunk_size` elements of the slice at a time. <del> /// The chunks are mutable and do not overlap. If `chunk_size` does </del> <ins> /// The chunks are mutable slices, and do not overlap. If `chunk_size` does </ins> /// not divide the length of the slice, then the last chunk will not /// have length `chunk_size`. ///
Change:
Download and unpack: It should contain the same files as but it's missing the following directories: src/bootstrap, src/build_helper, src/rustc, src/grammar, etc. The files that are present in both cases are equal, so the tarball is only missing files. Perhaps a "whitelist" needs to be updated. cc

Discussion:
$(S)configure $(S)Makefile.in               $(S)man                                     $(addprefix $(S)src/,                       <ins> bootstrap                                 build_helper                              </ins> compiletest                               doc                                       driver                                   

rt                                        rtstartup                                 rustllvm                                  <ins> rustc                                     </ins> snapshots.txt                             rust-installer                            rustbook
Change:
Multi-statement macros (macros that expand to multiple statements) are hard to use because hygiene runs separately on each line, meaning it's very easy to "lose" identifiers. The macro is trying to declare a variable in the scope where it was called, but it takes multiple statements to construct. This is a long-standing bug, not a regression. I previously reported this and (can likely be closed) but it wasn't very visible. ping
I am experimentally playing with the idea of using hygiene to hide one object, then exposing another object that refers to the hidden object. The macro I have is Trying to use this fails with
For the record, you can write code that relies on this bug. produces code that , but (which represents what the code would look like were this bug fixed) prints 3, while prints 2.

Discussion:
/// Expand a stmt fn expand_stmt(stmt: Stmt, fld: &mut MacroExpander) -> SmallVector<Stmt> { <ins> // perform all pending renames let stmt = { let pending_renames = &mut fld.cx.syntax_env.info().pending_renames; let mut rename_fld = IdentRenamer{renames:pending_renames}; rename_fld.fold_stmt(stmt).expect_one("rename_fold didn't return one value") }; </ins> let (mac, style, attrs) = match stmt.node { StmtKind::Mac(mac, style, attrs) => (mac, style, attrs), _ => return expand_non_macro_stmt(stmt, fld)

pub fn expand_block_elts(b: P<Block>, fld: &mut MacroExpander) -> P<Block> { b.map(|Block {id, stmts, expr, rules, span}| { let new_stmts = stmts.into_iter().flat_map(|x| { <del> // perform all pending renames let renamed_stmt = { let pending_renames = &mut fld.cx.syntax_env.info().pending_renames; let mut rename_fld = IdentRenamer{renames:pending_renames}; rename_fld.fold_stmt(x).expect_one("rename_fold didn't return one value") }; // expand macros in the statement fld.fold_stmt(renamed_stmt).into_iter() </del> <ins> // perform pending renames and expand macros in the statement fld.fold_stmt(x).into_iter() </ins> }).collect(); let new_expr = expr.map(|x| { let expr = {

<ins> // Copyright 2016 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(rustc_attrs)] #![allow(warnings)] macro_rules! foo { () => { let x = 1; macro_rules! bar { () => {x} } let _ = bar!(); }} macro_rules! bar { // test issue #31856 ($n:ident) => ( let a = 1; let $n = a; ) } macro_rules! baz { ($i:ident) => { let mut $i = 2; $i = $i + 1; } } #[rustc_error] fn main() { //~ ERROR compilation successful foo! {}; bar! {}; let mut a = true; baz!(a); } </ins>
Change:
A documentation comment like the one cited verbatim below, produces a main page summary that includes the first line of the code in the example. This is very surprising since there's an empty line in between, and the code example inserts a large colored box in the overview page (the parent module). cc since it's probably related to PR /// A tuple or fixed size array that can be used to index an array. /// /// /// /// Note the blanket implementation that's not visible in rustdoc: /// !

Discussion:
let text = lines.collect::<Vec<&str>>().join("n"); if rendered { return } PLAYGROUND_KRATE.with(|krate| { <del> let mut s = String::new(); </del> <ins> // insert newline to clearly separate it from the // previous block so we can shorten the html output let mut s = String::from("n"); </ins> krate.borrow().as_ref().map(|krate| { let test = origtext.lines().map(|l| { stripped_filtered_line(l).unwrap_or(l)

#[inline] fn plain_summary_line(s: Option<&str>) -> String { <del> let md = markdown::plain_summary_line(s.unwrap_or("")); shorter(Some(&md)).replace("n", " ") </del> <ins> let line = shorter(s).replace("n", " "); markdown::plain_summary_line(&line[..]) </ins> } fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result {

<ins> // Copyright 2016 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. // @has issue_31899/index.html // @has - 'Make this line a bit longer.' // @!has - 'rust rust-example-rendered' // @!has - 'use ndarray::arr2' // @!has - 'prohibited' /// A tuple or fixed size array that can be used to index an array. /// Make this line a bit longer. /// /// ``` /// use ndarray::arr2; /// /// let mut a = arr2(&[[0, 1], [0, 0]]); /// a[[1, 1]] = 1; /// assert_eq!(a[[0, 1]], 1); /// assert_eq!(a[[1, 1]], 1); /// ``` /// /// **Note** the blanket implementation that's not visible in rustdoc: /// `impl<D> NdIndex for D where D: Dimension { ... }` pub fn bar() {} /// Some line /// /// # prohibited pub fn foo() {} /// Some line /// /// 1. prohibited /// 2. bar pub fn baz() {} /// Some line /// /// - prohibited /// - bar pub fn qux() {} /// Some line /// /// * prohibited /// * bar pub fn quz() {} /// Some line /// /// > prohibited /// > bar pub fn qur() {} /// Some line /// /// prohibited /// ===== /// /// Second /// ------ pub fn qut() {} </ins>
Change:
contains statements like The book used to use , but has switched to , from two methods for error handling/crashing to one.
This has been fixed in nightly:
The first line looks fixed, but the second doesn't, "we can use these two little methods" is still present.
I thought I accepted PRs for all of it, will double check. Thanks.

Discussion:
a special annotation that `io::Result` has. Rust is trying to tell you that you haven’t handled a possible error. The right way to suppress the error is to actually write error handling. Luckily, if we want to crash if there’s <del> a problem, we can use these two little methods. If we can recover from the </del> <ins> a problem, we can use `expect()`. If we can recover from the </ins> error somehow, we’d do something else, but we’ll save that for a future project.
Change:
Since the function is tagged the exact name presumably has to exactly match something that another system is expecting, which may not be snake case. For example, JNI bindings will look something like
Modifying lints requires an RFC now, as it can impact a LOT of code.
(By modifying I mean "major changes" not bugfixes)
Hm, while I think new lints definitely want an RFC, modifications to existing ones can probably go through the lang team's nomination process, leading to either an immediate decision or request for RFC.
I'm fine with that, just following (what I thought was) procedure. :smile:

Discussion:
use lint::{LateContext, LintContext, LintArray}; use lint::{LintPass, LateLintPass}; <ins> use syntax::abi::Abi; </ins> use syntax::ast; use syntax::attr; use syntax_pos::Span;

_ => (), } } <del> FnKind::ItemFn(name, ..) => { </del> <ins> FnKind::ItemFn(name, _, _, _, abi, _, attrs) => { // Skip foreign-ABI #[no_mangle] functions (Issue #31924) if abi != Abi::Rust && attr::find_by_name(attrs, "no_mangle").is_some() { return; } </ins> self.check_snake_case(cx, "function", &name.as_str(), Some(span)) } FnKind::Closure(_) => (),

<ins> // Copyright 2017 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(rustc_attrs)] #![deny(non_snake_case)] #[no_mangle] pub extern "C" fn SparklingGenerationForeignFunctionInterface() {} #[rustc_error] fn main() {} //~ ERROR compilation successful </ins>
Change:
The docs for currently read If I read this correctly, what it is actually saying is Is this what is says?
Yes, that's correct. I'm writing a patch to clarify right now.

Discussion:
Arc { _ptr: unsafe { Shared::new(Box::into_raw(x)) } } } <del> /// Unwraps the contained value if the `Arc<T>` has only one strong reference. /// This will succeed even if there are outstanding weak references. </del> <ins> /// Unwraps the contained value if the `Arc<T>` has exactly one strong reference. </ins> /// /// Otherwise, an `Err` is returned with the same `Arc<T>`. /// <ins> /// This will succeed even if there are outstanding weak references. /// </ins> /// # Examples /// /// ```

} } <del> /// Unwraps the contained value if the `Rc<T>` has only one strong reference. /// This will succeed even if there are outstanding weak references. </del> <ins> /// Unwraps the contained value if the `Rc<T>` has exactly one strong reference. </ins> /// /// Otherwise, an `Err` is returned with the same `Rc<T>`. /// <ins> /// This will succeed even if there are outstanding weak references. /// </ins> /// # Examples /// /// ```