jiebi/CodeConvo huggingface dataset:
Change:
this has shown up before:
The previous fix was , which simply removed one level of header from .

Discussion:
Many of these resources take the form of "books"; we collectively call these "The Rust Bookshelf." Some are large, some are small. <del> ## Learn Rust </del> <ins> # Learn Rust </ins> If you'd like to learn Rust, this is the spot for you! All of these resources assume that you have programmed before, but not in any specific language: <del> ### The Rust Programming Language </del> <ins> ## The Rust Programming Language </ins> Affectionately nicknamed "the book," [The Rust Programming Language](book/index.html) will give you an overview of the language from first principles. You'll build a few projects along the way, and by the end, you'll have a solid grasp of the language. <del> ### Rust By Example </del> <ins> ## Rust By Example </ins> If reading multiple hundreds of pages about a language isn't your style, then [Rust By Example](rust-by-example/index.html) has you covered. While the book talks about code with a lot of words, RBE shows off a bunch of code, and keeps the talking to a minimum. It also includes exercises! <del> ## Use Rust </del> <ins> # Use Rust </ins> Once you've gotten familliar with the language, these resources can help you when you're actually using it day-to-day. <del> ### The Standard Library </del> <ins> ## The Standard Library </ins> Rust's standard library has [extensive API documentation](std/index.html), with explanations of how to use various things, as well as example code for accomplishing various tasks. <del> ### The Cargo Book </del> <ins> ## The Cargo Book </ins> [The Cargo Book](cargo/index.html) is a guide to Cargo, Rust's build tool and dependency manager. <del> ### The Rustdoc Book </del> <ins> ## The Rustdoc Book </ins> [The Rustdoc Book](rustdoc/index.html) describes our documentation tool, `rustdoc`. <del> ### Extended Error Listing </del> <ins> ## Extended Error Listing </ins> Many of Rust's errors come with error codes, and you can request extended diagnostics from the compiler on those errors. You can also [read them here](error-index.html), if you prefer to read them that way. <del> ## Master Rust </del> <ins> # Master Rust </ins> Once you're quite familiar with the language, you may find these advanced resources useful. <del> ### The Reference </del> <ins> ## The Reference </ins> [The Reference](reference/index.html) is not a formal spec, but is more detailed and comprehensive than the book. <del> ### The Rustonomicon </del> <ins> ## The Rustonomicon </ins> [The Rustonomicon](nomicon/index.html) is your guidebook to the dark arts of unsafe Rust. It's also sometimes called "the 'nomicon." <del> ### The Unstable Book </del> <ins> ## The Unstable Book </ins> [The Unstable Book](unstable-book/index.html) has documentation for unstable features.
Change:
use std; import std::vec; fn main() { let vec[int] a = [0]; auto i = 20; while (i 0) { a += a; i -= 1; } } I suspect, but haven't confirmed, the following: If a vector that is in the process of self-appending (v += v) grows, we can realloc the existing vector pointer and invalidate the memory that is being copied.
I'm the last person who touched the vec append glue. I'll look into it.
Yeah, you were exactly right. Fixed by .

Discussion:
<del> Subproject commit a416c5e0f7c4c9473069a58410d3ec3e86b1ac0d </del> <ins> Subproject commit fc24fce73f878e641094b1802df1e748c5fe233a </ins>
Change:
According to the : This seems not to be true in general. On my machine, is slower than when compiling without .
cc
cc , dedicated FMA instructions are not universally available and we can't very well replace with when no such instruction exists (it rounds differently and also has different behavior when NaNs or infinities are involved).

Discussion:
} /// Fused multiply-add. Computes `(self * a) + b` with only one rounding <del> /// error. This produces a more accurate result with better performance than /// a separate multiplication operation followed by an add. </del> <ins> /// error, yielding a more accurate result than an unfused multiply-add. /// /// Using `mul_add` can be more performant than an unfused multiply-add if /// the target architecture has a dedicated `fma` CPU instruction. </ins> /// /// ``` /// use std::f32;

} /// Fused multiply-add. Computes `(self * a) + b` with only one rounding <del> /// error. This produces a more accurate result with better performance than /// a separate multiplication operation followed by an add. </del> <ins> /// error, yielding a more accurate result than an unfused multiply-add. /// /// Using `mul_add` can be more performant than an unfused multiply-add if /// the target architecture has a dedicated `fma` CPU instruction. </ins> /// /// ``` /// let m = 10.0_f64;
Change:
From Gecko profiler uses EHABI information to walk stack. But since rustc doesn't generate EHABI, it cannot walk stack on generated code by rust. says, "-C panic=abort" causes that EHABI isn't emitted", so we need a option not to remove it (or don't remove EHABI even if -C panic=abort).
Note the same actually applies to EH_FRAME info on x86-64, which iirc the Firefox profiler also uses on x86-64. More generally, it can be desirable to have unwind info even when panic doesn't unwind.
For C/C++ code in Firefox we use  to ensure that the compiler generates these when is on: The equivalent for x86-64 is  which is apparently on by default. It seems like having a compiler option to enable this would be good enough, since the behavior here mirrors what gcc does: only emit unwind info if needed for exceptions/unwinding.
LLVM seems to turn on EHABI as default by (EnableARMEHABI is removed by this landing, but still has it) is similar issue for Win64 ABI.
This may or may not be related to , but I can prepare a patch like for the targets here. do you know what targets are in use by Firefox and would need this treatment?

Discussion:
base.is_like_android = true; base.position_independent_executables = true; base.has_elf_tls = false; <ins> base.requires_uwtable = true; </ins> base }

/// Whether a .debug_gdb_scripts section will be added to the output object file pub emit_debug_gdb_scripts: bool, <ins> /// Whether or not to unconditionally `uwtable` attributes on functions, /// typically because the platform needs to unwind for things like stack /// unwinders. pub requires_uwtable: bool, </ins> } impl Default for TargetOptions {

default_hidden_visibility: false, embed_bitcode: false, emit_debug_gdb_scripts: true, <ins> requires_uwtable: false, </ins> } } }

key!(default_hidden_visibility, bool); key!(embed_bitcode, bool); key!(emit_debug_gdb_scripts, bool); <ins> key!(requires_uwtable, bool); </ins> if let Some(array) = obj.find("abi-blacklist").and_then(Json::as_array) { for name in array.iter().filter_map(|abi| abi.as_string()) {

target_option_val!(default_hidden_visibility); target_option_val!(embed_bitcode); target_option_val!(emit_debug_gdb_scripts); <ins> target_option_val!(requires_uwtable); </ins> if default.abi_blacklist != self.options.abi_blacklist { d.insert("abi-blacklist".to_string(), self.options.abi_blacklist.iter()

custom_unwind_resume: true, abi_return_struct_as_int: true, emit_debug_gdb_scripts: false, <ins> requires_uwtable: true, </ins> .. Default::default() }

crt_static_respected: true, abi_return_struct_as_int: true, emit_debug_gdb_scripts: false, <ins> requires_uwtable: true, </ins> .. Default::default() }

// You can also find more info on why Windows is whitelisted here in: //      https://bugzilla.mozilla.org/show_bug.cgi?id=1302078 if !cx.sess().no_landing_pads() || <del> cx.sess().target.target.options.is_like_windows { </del> <ins> cx.sess().target.target.options.requires_uwtable { </ins> attributes::emit_uwtable(lldecl, true); }

// aux-build:nounwind.rs // compile-flags: -C no-prepopulate-passes -C panic=abort -C metadata=a // ignore-windows <ins> // ignore-android </ins> #![crate_type = "lib"]
Change:
Rust 1.23.0 correctly prints . Rust 1.24.0 incorrectly prints . Mentioning because this sounds potentially relevant to or follow-on optimization. (Discovered by in #rust.)
Clearly from rather than a followup, as it's happening in nightly-2017-11-21 and not in nightly-2017-11-20.
This is not specific to but to the enum using both signed extremums of its representation type:

Discussion:
} } <del> let discr = Scalar { </del> <ins> let tag_mask = !0u128 >> (128 - ity.size().bits()); let tag = Scalar { </ins> value: Int(ity, signed), <del> valid_range: (min as u128)..=(max as u128) </del> <ins> valid_range: (min as u128 & tag_mask)..=(max as u128 & tag_mask), </ins> }; <del> let abi = if discr.value.size(dl) == size { Abi::Scalar(discr.clone()) </del> <ins> let abi = if tag.value.size(dl) == size { Abi::Scalar(tag.clone()) </ins> } else { Abi::Aggregate { sized: true } }; tcx.intern_layout(LayoutDetails { variants: Variants::Tagged { <del> discr, </del> <ins> discr: tag, </ins> variants }, fields: FieldPlacement::Arbitrary {

<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. #[derive(Debug)] #[repr(i32)] enum E { Min = -2147483648i32, _Max = 2147483647i32, } fn main() { assert_eq!(Some(E::Min).unwrap() as i32, -2147483648i32); } </ins>
Change:
There is no issue :-) I'm guessing someone intended to mean "we don't have an issue for this", but either the error message emitting machinery needs to suppress it, or it should be given a real error message. Here's what it looks like: You can see it here: https://travis-

Discussion:
GateIssue::Library(lib) => lib, }; <del> let explanation = if let Some(n) = issue { format!("{} (see issue #{})", explain, n) } else { explain.to_owned() </del> <ins> let explanation = match issue { None | Some(0) => explain.to_owned(), Some(n) => format!("{} (see issue #{})", explain, n) </ins> }; let mut err = match level {

<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. extern crate core; // error should not say "(see issue #0)" #[allow(unused_imports)] use core::ptr::Unique; //~ ERROR use of unstable library feature fn main() {} </ins>

<ins> error[E0658]: use of unstable library feature 'ptr_internals': use NonNull instead and consider PhantomData<T> (if you also use #[may_dangle]), Send, and/or Sync --> $DIR/issue-49983-see-issue-0.rs:14:30 | LL | #[allow(unused_imports)] use core::ptr::Unique; //~ ERROR use of unstable library feature |                              ^^^^^^^^^^^^^^^^^ | = help: add #![feature(ptr_internals)] to the crate attributes to enable error: aborting due to previous error For more information about this error, try `rustc --explain E0658`. </ins>
Change:
Currently, around 54 GB is required for a default incremental build (). We may include some tips to decrease disk space requirements in the readme, potentially not building all LLVM targets etc.
I see a 3.6 GB build locally with a fresh checkout and a single run of . Could you clarify if that's the same as your configuration?
I am building on Windows Subsystem for Linux as Windows build didn't work. Fresh checkout + single run is correct. I am attaching a dir size report [1], please note that I ran for a single test since. ! [1]
I'm afraid I cannot reproduce and as such am uncertain whether we can effectively document this; I also don't have access to a WSL environment so I can't test there either. It would also be helpful to have a copy of your .
Here is my Inclusion of some kind of estimate could be helpful to first-time builders, even just giving a ball park. As examples, and gives estimated disk space usages.
So that's a non-standard configuration; I see ~30 GB locally with it. I think it may be somewhat helpful to add a note that a debug configuration could be upwards of 30 GB, however a default configuration (with no configuration flags changed) you'll see about a 3.6 GB build. If you'd like to make a PR adding that, please go ahead! We should probably add it to the CONTRIBUTING file instead of the README, though.

Discussion:
### Building [building]: #building <ins> A default configuration shall use around 3.5 GB of disk space, whereas building a debug configuration may require more than 30 GB. </ins> Dependencies - [build dependencies](README.md#building-from-source) - `gdb` 6.2.0 minimum, 7.1 or later recommended for test builds
Change:
Given: and you'll see: But that's not right! Only the original crate should need this directive, and it indeed has such a directive.

Discussion:
fn from_target_feature( tcx: TyCtxt, <ins> id: DefId, </ins> attr: &ast::Attribute, whitelist: &FxHashMap<String, Option<String>>, target_features: &mut Vec<Symbol>,

Some(name) => bug!("unknown target feature gate {}", name), None => true, }; <del> if !allowed { </del> <ins> if !allowed && id.is_local() { </ins> feature_gate::emit_feature_err( &tcx.sess.parse_sess, feature_gate.as_ref().unwrap(),

`unsafe` function"; tcx.sess.span_err(attr.span, msg); } <del> from_target_feature(tcx, attr, &whitelist, &mut trans_fn_attrs.target_features); </del> <ins> from_target_feature(tcx, id, attr, &whitelist, &mut trans_fn_attrs.target_features); </ins> } else if attr.check_name("linkage") { if let Some(val) = attr.value_str() { trans_fn_attrs.linkage = Some(linkage_by_name(tcx, id, &val.as_str()));

"the `#[naked]` attribute  is an experimental feature", cfg_fn!(naked_functions))), <del> ("target_feature", Normal, Ungated), </del> <ins> ("target_feature", Whitelisted, Ungated), </ins> ("export_name", Whitelisted, Ungated), ("inline", Whitelisted, Ungated), ("link", Whitelisted, Ungated),

<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(mmx_target_feature)] #[inline] #[target_feature(enable = "mmx")] pub unsafe fn foo() {} </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. // only-x86_64 // aux-build:using-target-feature-unstable.rs extern crate using_target_feature_unstable; fn main() { unsafe { using_target_feature_unstable::foo(); } } </ins>
Change:
Given this code: it compiles as: How odd!
Not technically a regression but this needs to be fixed before 1.27 hits stable, so tagging as a nightly regression

Discussion:
fn from_target_feature( tcx: TyCtxt, <ins> id: DefId, </ins> attr: &ast::Attribute, whitelist: &FxHashMap<String, Option<String>>, target_features: &mut Vec<Symbol>,

Some(name) => bug!("unknown target feature gate {}", name), None => true, }; <del> if !allowed { </del> <ins> if !allowed && id.is_local() { </ins> feature_gate::emit_feature_err( &tcx.sess.parse_sess, feature_gate.as_ref().unwrap(),

`unsafe` function"; tcx.sess.span_err(attr.span, msg); } <del> from_target_feature(tcx, attr, &whitelist, &mut trans_fn_attrs.target_features); </del> <ins> from_target_feature(tcx, id, attr, &whitelist, &mut trans_fn_attrs.target_features); </ins> } else if attr.check_name("linkage") { if let Some(val) = attr.value_str() { trans_fn_attrs.linkage = Some(linkage_by_name(tcx, id, &val.as_str()));

"the `#[naked]` attribute  is an experimental feature", cfg_fn!(naked_functions))), <del> ("target_feature", Normal, Ungated), </del> <ins> ("target_feature", Whitelisted, Ungated), </ins> ("export_name", Whitelisted, Ungated), ("inline", Whitelisted, Ungated), ("link", Whitelisted, Ungated),

<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(mmx_target_feature)] #[inline] #[target_feature(enable = "mmx")] pub unsafe fn foo() {} </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. // only-x86_64 // aux-build:using-target-feature-unstable.rs extern crate using_target_feature_unstable; fn main() { unsafe { using_target_feature_unstable::foo(); } } </ins>
Change:
I think I messed something up in . Some work I've been doing locally has indicated that each time I run with the test suite, it is overwriting the expected stderr files in the source tree. (oops!) sorry about that. Will put up PR to fix that pronto.
(filed since the docs could have helped me avoid my mistake here.)

Discussion:
} } <del> let expected_output_path = self.expected_output_path(kind); let output_file = self.output_base_name().with_file_name(&expected_output_path); </del> <ins> let expected_output = self.expected_output_path(kind); // #50113: output is abspath; only want filename component. let expected_output = expected_output.file_name().expect("output path requires file name"); let output_file = self.output_base_name().with_file_name(&expected_output); </ins> match File::create(&output_file).and_then(|mut f| f.write_all(actual.as_bytes())) { Ok(()) => {} Err(e) => self.fatal(&format!(
Change:
Like , but doesn't result in any allocations. I started implementing this in but got stuck, mainly because of limitations in the APIs. <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --This issue has been assigned to via . <!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
claim

Discussion:
ch } <ins> /// Remove all matches of pattern `pat` in the `String`. /// /// # Examples /// /// ``` /// #![feature(string_remove_matches)] /// let mut s = String::from("Trees are not green, the sky is not blue."); /// s.remove_matches("not "); /// assert_eq!("Trees are green, the sky is blue.", s); /// ``` /// /// Matches will be detected and removed iteratively, so in cases where /// patterns overlap, only the first pattern will be removed: /// /// ``` /// #![feature(string_remove_matches)] /// let mut s = String::from("banana"); /// s.remove_matches("ana"); /// assert_eq!("bna", s); /// ``` #[unstable(feature = "string_remove_matches", reason = "new API", issue = "72826")] pub fn remove_matches<'a, P>(&'a mut self, pat: P) where P: for<'x> Pattern<'x>, { use core::str::pattern::Searcher; let matches = { let mut searcher = pat.into_searcher(self); let mut matches = Vec::new(); while let Some(m) = searcher.next_match() { matches.push(m); } matches }; let len = self.len(); let mut shrunk_by = 0; // SAFETY: start and end will be on utf8 byte boundaries per // the Searcher docs unsafe { for (start, end) in matches { ptr::copy( self.vec.as_mut_ptr().add(end - shrunk_by), self.vec.as_mut_ptr().add(start - shrunk_by), len - end, ); shrunk_by += end - start; } self.vec.set_len(len - shrunk_by); } } </ins> /// Retains only the characters specified by the predicate. /// /// In other words, remove all characters `c` such that `f(c)` returns `false`.

#![feature(slice_group_by)] #![feature(vec_extend_from_within)] #![feature(vec_spare_capacity)] <ins> #![feature(string_remove_matches)] </ins> use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher};

} #[test] <ins> fn test_remove_matches() { let mut s = "abc".to_string(); s.remove_matches('b'); assert_eq!(s, "ac"); s.remove_matches('b'); assert_eq!(s, "ac"); let mut s = "abcb".to_string(); s.remove_matches('b'); assert_eq!(s, "ac"); let mut s = "ศไทย中华Việt Nam; foobarศ".to_string(); s.remove_matches('ศ'); assert_eq!(s, "ไทย中华Việt Nam; foobar"); let mut s = "".to_string(); s.remove_matches(""); assert_eq!(s, ""); let mut s = "aaaaa".to_string(); s.remove_matches('a'); assert_eq!(s, ""); } #[test] </ins> fn test_retain() { let mut s = String::from("α_β_γ");
Change:
[][zip] says: However, it is not always true; it actually returns after when the source iterator is not fused. [Playground] [zip]: [Playground]:

Discussion:
/// /// In other words, it zips two iterators together, into a single one. /// <del> /// When either iterator returns [`None`], all further calls to [`next`] /// will return [`None`]. </del> <ins> /// If either iterator returns [`None`], [`next`] will return [`None`]. </ins> /// /// # Examples ///
Change:
(Sorry about the non-informative title, I couldn't come up with a useful description.) As discovered towards the end of , the following code () fails to compile: I get the following error message: Changing the definition of to makes the program compile, but it seems like it should be accepted as it is.
This program is no longer rejected, neither in 1.36, nor in nightly-2019-08-07.
modify labels: E-needstest

Discussion:
<ins> // Tests that HRTBs are correctly accepted -- https://github.com/rust-lang/rust/issues/50301 // check-pass trait Trait where for<'a> &'a Self::IntoIter: IntoIterator<Item = u32>, { type IntoIter; fn get(&self) -> Self::IntoIter; } struct Impl(Vec<u32>); impl Trait for Impl { type IntoIter = ImplIntoIter; fn get(&self) -> Self::IntoIter { ImplIntoIter(self.0.clone()) } } struct ImplIntoIter(Vec<u32>); impl<'a> IntoIterator for &'a ImplIntoIter { type Item = <Self::IntoIter as Iterator>::Item; type IntoIter = std::iter::Cloned<std::slice::Iter<'a, u32>>; fn into_iter(self) -> Self::IntoIter { (&self.0).into_iter().cloned() } } fn main() { } </ins>