jiebi/CodeConvo huggingface dataset:
Change:
This code produces a compiler error with but compiles successfully with : The error is:
cc
This has to do with how the result of a checked op is a tuple and the 2's complement wrapping value is accessed through : the fix would be to track an initialization with a checked op in a field of , then treat as constant if is promotable and has that flag. I believe that the promoter will work as-is, it's just the constant qualifier that needs to understand this.
Looking at it again, the const qualifier works fine with fields, but the promoter's initial set of potentially promotable temporaries doesn't include the tuple because one of the uses is by-field.

Discussion:
// Ignore drops, if the temp gets promoted, // then it's constant and thus drop is noop. // Storage live ranges are also irrelevant. <del> match context { LvalueContext::Drop | LvalueContext::StorageLive | LvalueContext::StorageDead => return, _ => {} </del> <ins> if context.is_drop() || context.is_storage_marker() { return; </ins> } let temp = &mut self.temps[index];

_ => { /* mark as unpromotable below */ } } } else if let TempState::Defined { ref mut uses, .. } = *temp { <del> match context { LvalueContext::Borrow {..} | LvalueContext::Consume | LvalueContext::Inspect => { *uses += 1; return; } _ => { /* mark as unpromotable below */ } </del> <ins> // We always allow borrows, even mutable ones, as we need // to promote mutable borrows of some ZSTs e.g. `&mut []`. let allowed_use = match context { LvalueContext::Borrow {..} => true, _ => context.is_nonmutating_use() }; if allowed_use { *uses += 1; return; </ins> } <ins> /* mark as unpromotable below */ </ins> } *temp = TempState::Unpromotable; }

visitor.visit_mir(&mir); for promoted in &mir.promoted { <ins> visitor.mir = promoted; </ins> visitor.visit_mir(promoted); } }

<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(platform_intrinsics, repr_simd)] extern "platform-intrinsic" { fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U; } #[repr(simd)] #[derive(Clone, Copy)] #[allow(non_camel_case_types)] struct u64x2(u64, u64); fn main() { let a = u64x2(1, 2); let r: u64x2 = unsafe { simd_shuffle2(a, a, [0-0, 0-0]) }; assert_eq!(r.0, 1); assert_eq!(r.1, 1); } </ins>
Change:
The following file, when compiled without optimizations, correctly generates an overflow check in : However, compiling with optimizations plus or generates code without the overflow check. However, if I move to a separate no_core crate like this, the issue disappears and the overflow check is generated:
noticed that my panic implementation () is UB according to LLVM (see ), so it optimizes the overflow check out on the assumption that it can never be triggered (since that would be UB). Replacing it with e.g. fixes the issue.

Discussion:
sugar for dynamic allocations via `malloc` and `free`: ```rust,ignore <del> #![feature(lang_items, box_syntax, start, libc)] </del> <ins> #![feature(lang_items, box_syntax, start, libc, core_intrinsics)] </ins> #![no_std] <ins> use core::intrinsics; </ins> extern crate libc; <del> extern { fn abort() -> !; } </del> #[lang = "owned_box"] pub struct Box<T>(*mut T);

// Check if `malloc` failed: if p as usize == 0 { <del> abort(); </del> <ins> intrinsics::abort(); </ins> } p

} #[lang = "eh_personality"] extern fn rust_eh_personality() {} <del> #[lang = "panic_fmt"] extern fn rust_begin_panic() -> ! { loop {} } </del> <ins> #[lang = "panic_fmt"] extern fn rust_begin_panic() -> ! { unsafe { intrinsics::abort() } } </ins> # #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {} # #[no_mangle] pub extern fn rust_eh_register_frames () {} # #[no_mangle] pub extern fn rust_eh_unregister_frames () {}

in the same format as C: ```rust,ignore <del> #![feature(lang_items)] </del> <ins> #![feature(lang_items, core_intrinsics)] </ins> #![feature(start)] #![no_std] <ins> use core::intrinsics; </ins> // Pull in the system libc library for what crt0.o likely requires. extern crate libc;

compiler's name mangling too: ```rust,ignore <del> #![feature(lang_items)] </del> <ins> #![feature(lang_items, core_intrinsics)] </ins> #![feature(start)] #![no_std] #![no_main] <ins> use core::intrinsics; </ins> // Pull in the system libc library for what crt0.o likely requires. extern crate libc;

pub extern fn rust_begin_panic(_msg: core::fmt::Arguments, _file: &'static str, _line: u32) -> ! { <del> loop {} </del> <ins> unsafe { intrinsics::abort() } </ins> } ```
Change:
Code: Console output: rustc info:
Ha, since primitive type fallback works in value namespace as well. Fixed in
So that explains why the ICE won't happen on nightly-2016-11-25.
Pending fix in , right ?
I'm marking this as P-high (regression) and assigning to myself only because GH will not allow me to assign to
Pending fix in , right ? Yes.

Discussion:
} } <del> #[derive(Copy, Clone)] </del> <ins> #[derive(Copy, Clone, PartialEq)] </ins> enum PathScope { Global, Lexical,

// // Such behavior is required for backward compatibility. // The same fallback is used when `a` resolves to nothing. <del> _ if self.primitive_type_table.primitive_types.contains_key(&path[0].name) => { </del> <ins> PathResult::Module(..) | PathResult::Failed(..) if scope == PathScope::Lexical && (ns == TypeNS || path.len() > 1) && self.primitive_type_table.primitive_types.contains_key(&path[0].name) => { </ins> PathResolution { base_def: Def::PrimTy(self.primitive_type_table.primitive_types[&path[0].name]), depth: segments.len() - 1,

<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. fn main() { // Make sure primitive type fallback doesn't work in value namespace std::mem::size_of(u16); //~^ ERROR unresolved name `u16` //~| ERROR this function takes 0 parameters but 1 parameter was supplied // Make sure primitive type fallback doesn't work with global paths let _: ::u8; //~^ ERROR type name `u8` is undefined or not in scope } </ins>
Change:
I declared a vector using vector macro as I expected compiler to complain about the data type Instead, It reported error : Backtrace:
Duplicate of , fixed in

Discussion:
} } <del> #[derive(Copy, Clone)] </del> <ins> #[derive(Copy, Clone, PartialEq)] </ins> enum PathScope { Global, Lexical,

// // Such behavior is required for backward compatibility. // The same fallback is used when `a` resolves to nothing. <del> _ if self.primitive_type_table.primitive_types.contains_key(&path[0].name) => { </del> <ins> PathResult::Module(..) | PathResult::Failed(..) if scope == PathScope::Lexical && (ns == TypeNS || path.len() > 1) && self.primitive_type_table.primitive_types.contains_key(&path[0].name) => { </ins> PathResolution { base_def: Def::PrimTy(self.primitive_type_table.primitive_types[&path[0].name]), depth: segments.len() - 1,

<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. fn main() { // Make sure primitive type fallback doesn't work in value namespace std::mem::size_of(u16); //~^ ERROR unresolved name `u16` //~| ERROR this function takes 0 parameters but 1 parameter was supplied // Make sure primitive type fallback doesn't work with global paths let _: ::u8; //~^ ERROR type name `u8` is undefined or not in scope } </ins>
Change:
Rustbuild now prints which is very not helpful.
I've hit this one too: When there's a stale in Rust's root directory, bootstrap reads paths from there and tries to convert them into windows format using (which it, of course, can't find since we are not running in msys shell). The error message comes from in buildhelper (called from ).

Discussion:
println!("running {}", test_file_name); let nodejs = build.config.nodejs.as_ref().expect("nodejs not configured"); let mut cmd = Command::new(nodejs); <del> cmd.arg(&test_file_name) .stderr(::std::process::Stdio::inherit()); </del> <ins> cmd.arg(&test_file_name); </ins> if build.config.quiet_tests { cmd.arg("--quiet"); }

pub fn run_silent(cmd: &mut Command) { let status = match cmd.status() { Ok(status) => status, <del> Err(e) => fail(&format!("failed to execute command: {}", e)), </del> <ins> Err(e) => fail(&format!("failed to execute command: {:?}nerror: {}", cmd, e)), </ins> }; if !status.success() { fail(&format!("command did not execute successfully: {:?}n

pub fn output(cmd: &mut Command) -> String { let output = match cmd.stderr(Stdio::inherit()).output() { Ok(status) => status, <del> Err(e) => fail(&format!("failed to execute command: {}", e)), </del> <ins> Err(e) => fail(&format!("failed to execute command: {:?}nerror: {}", cmd, e)), </ins> }; if !output.status.success() { panic!("command did not execute successfully: {:?}n
Change:
rustc panics when trying to call a method on a type. I tried this code: I expected to see this happen: An error message telling me that the method doesn't exist or that I'm using it incorrectly. Instead, this happened: Backtrace:
Looks like a duplicate of , which should be fixed by #.
Thanks for looking into this! I'm glad there's a fix already. Looking forward for this being released in nightly.
Since this is a duplicate, I'm giving it a close, thanks!

Discussion:
} } <del> #[derive(Copy, Clone)] </del> <ins> #[derive(Copy, Clone, PartialEq)] </ins> enum PathScope { Global, Lexical,

// // Such behavior is required for backward compatibility. // The same fallback is used when `a` resolves to nothing. <del> _ if self.primitive_type_table.primitive_types.contains_key(&path[0].name) => { </del> <ins> PathResult::Module(..) | PathResult::Failed(..) if scope == PathScope::Lexical && (ns == TypeNS || path.len() > 1) && self.primitive_type_table.primitive_types.contains_key(&path[0].name) => { </ins> PathResolution { base_def: Def::PrimTy(self.primitive_type_table.primitive_types[&path[0].name]), depth: segments.len() - 1,

<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. fn main() { // Make sure primitive type fallback doesn't work in value namespace std::mem::size_of(u16); //~^ ERROR unresolved name `u16` //~| ERROR this function takes 0 parameters but 1 parameter was supplied // Make sure primitive type fallback doesn't work with global paths let _: ::u8; //~^ ERROR type name `u8` is undefined or not in scope } </ins>
Change:
Works on stable and beta but not on nigthly I tried this code in the playground: I expected to get: error[E0425]: unresolved name Instead, this happened: rustc 1.15.0-nightly ( 2016-12-05)
Duplicate of , fixed in
Closing as a duplicate, thanks!

Discussion:
} } <del> #[derive(Copy, Clone)] </del> <ins> #[derive(Copy, Clone, PartialEq)] </ins> enum PathScope { Global, Lexical,

// // Such behavior is required for backward compatibility. // The same fallback is used when `a` resolves to nothing. <del> _ if self.primitive_type_table.primitive_types.contains_key(&path[0].name) => { </del> <ins> PathResult::Module(..) | PathResult::Failed(..) if scope == PathScope::Lexical && (ns == TypeNS || path.len() > 1) && self.primitive_type_table.primitive_types.contains_key(&path[0].name) => { </ins> PathResolution { base_def: Def::PrimTy(self.primitive_type_table.primitive_types[&path[0].name]), depth: segments.len() - 1,

<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. fn main() { // Make sure primitive type fallback doesn't work in value namespace std::mem::size_of(u16); //~^ ERROR unresolved name `u16` //~| ERROR this function takes 0 parameters but 1 parameter was supplied // Make sure primitive type fallback doesn't work with global paths let _: ::u8; //~^ ERROR type name `u8` is undefined or not in scope } </ins>
Change:
Works fine with : This is a bug in LLVM () that has already been fixed in . We only have to backport the fix. cc
Seeing the reproduction involves assembly and jumping to a label that hasn’t been passed as an input for the asm!, I do not think this deserves a backport.
I meant backporting/cherry-picking the upstream fix into our LLVM fork; not a "beta-backport". People that use the targets make pretty much exclusive use of the nightly channel (because Xargo, unstable features, etc.) so whether a fix makes it faster to the stable/beta channel doesn't really make much difference to us. Honest question: How does one pass a function to with the goal of using it as a label? And does that handle the mangling of the function?
There’s no support for doing that directly in LLVM sadly, mostly because this is not a very desired feature; and you can work around the issue with some indirection, which not only handles mangling but also any relocation business you might have going on (pardon my x86): compiles to code like this (PIC) or in static relocation mode.
Clever. The ARM asm parser doesn't seem to like the dereference though:
to branch to an address in a register can do but if you want to branch to a label you need an integer constant constraint.
Thanks, That works nicely and will let me hide more symbols in some crates like f3 . (Using "b $0" with the thumbv6m target still needs though)

Discussion:
<del> Subproject commit d7342a9a957470bb62c890cf88fc655ccfb755cc </del> <ins> Subproject commit ceb177eeefa7d67ca29230d2e7e8584f97d4fdad </ins>

# If this file is modified, then llvm will be forcibly cleaned and then rebuilt. # The actual contents of this file do not matter, but to trigger a change on the # build bots then the contents should be changed so git updates the mtime. <del> 2016-12-08 </del> <ins> 2016-12-16 </ins>
Change:
A friend was teaching me Rust and showing me the distinction between and the value of an expression, and when I tried to put a in a top level , we got a panic. Here's a minimal reproducing case. Fails with:
Seems to be fixed in nightly.

Discussion:
<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. const x: () = { return; //~ ERROR return statement outside of function body }; fn main() {} </ins>
Change:
When you compile rust you get: Regression of cc Maybe rustbuild should be compiled with to prevent errors like these in the future?
cc
Yeah when we fix this let's tag rustbuild with

Discussion:
//! switching compilers for the bootstrap and for build scripts will probably //! never get replaced. <ins> #![deny(warnings)] </ins> extern crate bootstrap; use std::env;

//! //! See comments in `src/bootstrap/rustc.rs` for more information. <ins> #![deny(warnings)] </ins> extern crate bootstrap; use std::env;

Flags { verbose: m.opt_count("v"), <del> stage: m.opt_str("stage").map(|j| j.parse().unwrap()), </del> <ins> stage: stage, </ins> keep_stage: m.opt_str("keep-stage").map(|j| j.parse().unwrap()), build: m.opt_str("build").unwrap_or_else(|| { env::var("BUILD").unwrap()

//! More documentation can be found in each respective module below, and you can //! also check out the `src/bootstrap/README.md` file for more information. <ins> #![deny(warnings)] </ins> extern crate build_helper; extern crate cmake; extern crate filetime;
Change:
After following the steps in the , running gives the following output: See for discussion. believes it to be an issue with invoking without enabling shell expansion.
Invoking fixes the error above, but another error pops up (see below).
Here is a workaround: instead of invoking , invoke . (Wow, it takes a long time—90 seconds until it fails in optimisation for a very basic thing seems inordinate!)
Same, when trying to invoke given command directly, getting instead:
Ah, this seems to be rather related to
Indeed. PR is work in progress. Also emscripten 1.35.0 (latest pre-build binary) does not work (see llvm assertion above). I haven't had the chance to try out emscripten 1.37.0 ()
Yep, that's what was suggested in that other issue and I can confirm it works.
For the sake of completeness, I finally had the time to test everything. This works for windows: Get emscripten 1.37.0: VS 2013 Community (required by emscripten) Rewire rustc to : Workaround for rust 1.14: Fix: PR I guess should check for a minimal required emscripten version, but this is probably out of scope.
Thanks for the investigations and the patch
Looks like the fix is merged.
I get the same error. Unless I run rustc from the same cmd windows I used to run emsdk activate. Running emsdk activate with --global doe not seem to change anything. This may just be how it is intended to work.
Did you run emsdk activate --global in elevated cmd? That's what it would take for it to work and permanently store generated environment variables in registry.

Discussion:
<ins> // Copyright 2014-2015 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. pub fn cmd(name: &str) -> String { if cfg!(windows) { format!("{}.bat", name) } else { name.to_string() } } </ins>

mod arm_base; mod bitrig_base; mod dragonfly_base; <ins> mod emscripten_base; </ins> mod freebsd_base; mod haiku_base; mod linux_base;

// except according to those terms. use super::{Target, TargetOptions}; <ins> use super::emscripten_base::{cmd}; </ins> pub fn target() -> Result<Target, String> { let opts = TargetOptions { <del> linker: "emcc".to_string(), ar: "emar".to_string(), </del> <ins> linker: cmd("emcc"), ar: cmd("emar"), </ins> dynamic_linking: false, executables: true,
Change:
Just like should mention that too can safely return this error without interrupting . Actually, both and could also probably mention this part.

Discussion:
/// variant will be returned. If an error is returned then it must be /// guaranteed that no bytes were read. /// <ins> /// An error of the `ErrorKind::Interrupted` kind is non-fatal and the read /// operation should be retried if there is nothing else to do. /// </ins> /// # Examples /// /// [`File`][file]s implement `Read`:

/// let mut f = File::open("foo.txt")?; /// let mut buffer = [0; 10]; /// <del> /// // read 10 bytes </del> <ins> /// // read up to 10 bytes </ins> /// f.read(&mut buffer[..])?; /// # Ok(()) /// # }

/// It is **not** considered an error if the entire buffer could not be /// written to this writer. /// <ins> /// An error of the `ErrorKind::Interrupted` kind is non-fatal and the /// write operation should be retried if there is nothing else to do. /// </ins> /// # Examples /// /// ```

/// # fn foo() -> std::io::Result<()> { /// let mut buffer = File::create("foo.txt")?; /// <ins> /// // Writes some prefix of the byte string, not necessarily all of it. </ins> /// buffer.write(b"some bytes")?; /// # Ok(()) /// # }

/// Attempts to write an entire buffer into this write. /// <del> /// This method will continuously call `write` while there is more data to /// write. This method will not return until the entire buffer has been /// successfully written or an error occurs. The first error generated from /// this method will be returned. </del> <ins> /// This method will continuously call `write` until there is no more data /// to be written or an error of non-`ErrorKind::Interrupted` kind is /// returned. This method will not return until the entire buffer has been /// successfully written or such an error occurs. The first error that is /// not of `ErrorKind::Interrupted` kind generated from this method will be /// returned. </ins> /// /// # Errors /// <del> /// This function will return the first error that `write` returns. </del> <ins> /// This function will return the first error of /// non-`ErrorKind::Interrupted` kind that `write` returns. </ins> /// /// # Examples ///
Change:
The following program triggers a stack overflow in rustc: My version of rustc: The problem also appears when replacing with .
Interestingly, I don't see a stack trace with Same version of
Well oddly than not it does look to see if there is about half a GB left on disk and if there is not updating would not work. Which is bad because there actually is enough space if I have an older version of it.
This also happens that sometimes it actually uses over than 1 GB of RAM as well for some insanely small code for some unknown reason.
I don't know what you mean by this, but I do no think this is the problem here. The following program also reveals the problem: rust But the following is accepted: Recursive structs are a well-known and important feature of Rust.
contains an , which contains an , which contains an , which contains...
: it does not /contain/ it. It /refers/ to it. Again, recursive structs are a well-known, important feature of Rust. For example, you cannot define linked lists without them.
The issue is not the storage of the struct. The issue is that you are asking the compiler to generate code for an infinite number of instantiations of . Is a very different thing than
Well, but I am not asking the compiler to generate any code here... Or at least, the code that is generated is not used anywhere.
I'm confused then - why is it valuable for it to be possible to define but never use this type?
Btw, now I understand better why my code provokes a stack overflow. But still, there is no reason this code is generated if the code is never used, and even then, this is not an excuse for rustc to do a stack overflow.
Yes there should be some reasonable recursion limit here.
More importantly, rustc should issue a diagnostic instead of overflowing its stack.
This is no longer reproducible with rustc 1.26.0-nightly ( 2018-03-06).
The phenomenon that is describing [above][] is technically known as "polymorphic recursion." [above]: cc But, as noted by above, this particular instance of the diagnostic issue with polymorphic recursion (that I believe persists to this day) no longer seems to replicate. Marking as E-needstest.

Discussion:
<ins> // run-pass struct S<T> { t : T, s : Box<S<fn(u : T)>> } fn f(x : S<u32>) {} fn main () {} </ins>