jiebi/CodeConvo huggingface dataset:
Change:
Suppose I've written code like: The variable is unused, and the error message I get looks like: The help is incorrect; is invalid. It should suggest replacing with
This bad suggestion was fixed in most cases by , but this case would seem to have evaded it. (Notice that on Nightly you can omit the ampersands from the match guards (due to the ergonomic) and receive the correct suggestion!)

Discussion:
#![feature(pointer_methods)] #![feature(inclusive_range_fields)] #![cfg_attr(stage0, feature(generic_param_attrs))] <ins> #![feature(rustc_const_unstable)] </ins> #![cfg_attr(not(test), feature(fn_traits, i128))] #![cfg_attr(test, feature(test))]

impl<T, A: Alloc> RawVec<T, A> { /// Like `new` but parameterized over the choice of allocator for /// the returned RawVec. <del> pub fn new_in(a: A) -> Self { </del> <ins> pub const fn new_in(a: A) -> Self { </ins> // !0 is usize::MAX. This branch should be stripped at compile time. <del> let cap = if mem::size_of::<T>() == 0 { !0 } else { 0 }; </del> <ins> // FIXME(mark-i-m): use this line when `if`s are allowed in `const` //let cap = if mem::size_of::<T>() == 0 { !0 } else { 0 }; </ins> // Unique::empty() doubles as "unallocated" and "zero-sized allocation" RawVec { ptr: Unique::empty(), <del> cap, </del> <ins> // FIXME(mark-i-m): use `cap` when ifs are allowed in const cap: [0, !0][(mem::size_of::<T>() == 0) as usize], </ins> a, } }

/// RawVec with capacity 0. If T has 0 size, then it makes a /// RawVec with capacity `usize::MAX`. Useful for implementing /// delayed allocation. <del> pub fn new() -> Self { </del> <ins> pub const fn new() -> Self { </ins> Self::new_in(Global) }

/// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] <del> pub fn new() -> Vec<T> { </del> <ins> #[rustc_const_unstable(feature = "const_vec_new")] pub const fn new() -> Vec<T> { </ins> Vec { buf: RawVec::new(), len: 0,

/// This is useful for initializing types which lazily allocate, like /// `Vec::new` does. // FIXME: rename to dangling() to match NonNull? <del> pub fn empty() -> Self { </del> <ins> pub const fn empty() -> Self { </ins> unsafe { <del> let ptr = mem::align_of::<T>() as *mut T; Unique::new_unchecked(ptr) </del> <ins> Unique::new_unchecked(mem::align_of::<T>() as *mut T) </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 Vec::new() can be used for constants #![feature(const_vec_new)] const MY_VEC: Vec<usize> = Vec::new(); pub fn main() {} </ins>
Change:
I recently updated my nightly toolchain for rust, and compiled a project I was working on. Previously I was on the version, and updated to the version. I encountered a compiler error when dealing with statements and Associated Constants, centered around alignment issues of the associated constant. After some testing, I managed to create a simple example with the code below: : : I've also tested and encountered this error on the following versions: nightly-2018-04-27-x8664-pc-windows-msvc nightly-2018-04-28-x8664-pc-windows-msvc nightly-2018-04-29-x8664-pc-windows-msvc nightly-2018-04-30-x8664-pc-windows-msvc
Sounds like some alignment check is getting the alignment from the wrong side of an assignment. I hope it wasn't introduced in a beta backported bugfix, we need to check that.
Ok, It's just in nightly, not in beta! I'll try to bisect

Discussion:
ConstVal::Value(miri) => const_val_field( self.tcx, self.param_env, instance, variant_opt, field, miri, cv.ty, <del> ).unwrap(), </del> <ins> ).expect("field access failed"), </ins> _ => bug!("{:#?} is not a valid adt", cv), }; self.const_to_pat(instance, val, id, span)

use syntax::ast::FloatTy; let layout = self.layout_of(ty)?; <del> // do the strongest layout check of the two let align = layout.align.max(ptr_align); self.memory.check_align(ptr, align)?; </del> <ins> self.memory.check_align(ptr, ptr_align)?; </ins> if layout.size.bytes() == 0 { return Ok(Some(Value::ByVal(PrimVal::Undef)));

<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. // compile-pass #[derive(Copy, Clone, PartialEq, Eq)] #[repr(packed)] pub struct Num(u64); impl Num { pub const ZERO: Self = Num(0); } pub fn decrement(a: Num) -> Num { match a { Num::ZERO => Num::ZERO, a => Num(a.0 - 1) } } fn main() { } </ins>
Change:
To reproduce, run on the following library: Expected output: Actual output: Version info:
It looks like the indentation was removed in , but the was left behind for the first line.
Going to take a look at this :+1:

Discussion:
for &(ref f, ref stdout) in &state.not_failures { successes.push(f.name.to_string()); if !stdout.is_empty() { <del> stdouts.push_str(&format!("---- {} stdout ----nt", f.name)); </del> <ins> stdouts.push_str(&format!("---- {} stdout ----n", f.name)); </ins> let output = String::from_utf8_lossy(stdout); stdouts.push_str(&output); stdouts.push_str("n");

for &(ref f, ref stdout) in &state.failures { failures.push(f.name.to_string()); if !stdout.is_empty() { <del> fail_out.push_str(&format!("---- {} stdout ----nt", f.name)); </del> <ins> fail_out.push_str(&format!("---- {} stdout ----n", f.name)); </ins> let output = String::from_utf8_lossy(stdout); fail_out.push_str(&output); fail_out.push_str("n");
Change:
The new script doesn't compute subdirectories correctly, I fear: Those files should have been placed in . Looking more closely at the bash script, the reason is fairly clear. cc
This patch seems to work for me, though I think it may fail if you run from the wrong directory .. maybe?
Yes, apologies! I'll try to post a fix asap.

Discussion:
echo "   $0 ../../../build/x86_64-apple-darwin/test/ui *.rs */*.rs" fi <ins> MYDIR=$(dirname $0) </ins> BUILD_DIR="$1" shift

shopt -s nullglob while [[ "$1" != "" ]]; do <del> MYDIR=$(dirname $1) </del> for EXT in "stderr" "stdout" "fixed"; do for OUT_NAME in $BUILD_DIR/${1%.rs}.*$EXT; do <ins> OUT_DIR=`dirname "$1"` </ins> OUT_BASE=`basename "$OUT_NAME"` <del> if ! (diff $OUT_NAME $MYDIR/$OUT_BASE >& /dev/null); then echo updating $MYDIR/$OUT_BASE cp $OUT_NAME $MYDIR </del> <ins> if ! (diff $OUT_NAME $MYDIR/$OUT_DIR/$OUT_BASE >& /dev/null); then echo updating $MYDIR/$OUT_DIR/$OUT_BASE cp $OUT_NAME $MYDIR/$OUT_DIR </ins> fi done done
Change:
Testcase: I was mostly fooling around trying to see if there was any way I could get rustc to believe that it would always know whether Bears<Twas Drop regardless of T; for the test case, I changed it to Clone and got rid of actually setting the constant to true in the default case, as well as some unsafe keywords, to avoid muddying the waters with Drop's semantics. Note that the array trick for turning a constant into a compile time error comes from , so it's not as contrived as it initially appears. Stacktrace:
The test case overflows on ` <details</details
The code doesn't produce ICE anymore (tested on ), instead, the following error is produced: ()
this no longer crashes , marking as needs-test modify labels: E-needs-test

Discussion:
<ins> #![feature(specialization)] #![allow(incomplete_features)] pub trait ReflectDrop { const REFLECT_DROP: bool = false; } impl<T> ReflectDrop for T where T: Clone {} pub trait PinDropInternal { fn is_valid() where Self: ReflectDrop; } struct Bears<T>(T); default impl<T> ReflectDrop for Bears<T> {} impl<T: Sized> PinDropInternal for Bears<T> { fn is_valid() where Self: ReflectDrop, { let _ = [(); 0 - !!(<Bears<T> as ReflectDrop>::REFLECT_DROP) as usize]; //~ ERROR constant expression depends on a generic parameter } } fn main() {} </ins>

<ins> error: constant expression depends on a generic parameter --> $DIR/issue-50439.rs:25:22 | LL |         let _ = [(); 0 - !!(<Bears<T> as ReflectDrop>::REFLECT_DROP) as usize]; |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this may fail depending on what value the parameter takes error: aborting due to previous error </ins>
Change:
At This is used by is_null() Backtrace: cc solson/miri
Minimal repro:

Discussion:
if self.type_is_fat_ptr(src.ty) { match (src.value, self.type_is_fat_ptr(dest_ty)) { (Value::ByRef { .. }, _) | <ins> // pointers to extern types (Value::ByVal(_),_) | // slices and trait objects to other slices/trait objects </ins> (Value::ByValPair(..), true) => { let valty = ValTy { value: src.value,

}; self.write_value(valty, dest)?; } <ins> // slices and trait objects to thin pointers (dropping the metadata) </ins> (Value::ByValPair(data, _), false) => { let valty = ValTy { value: Value::ByVal(data),

}; self.write_value(valty, dest)?; } <del> (Value::ByVal(_), _) => bug!("expected fat ptr"), </del> } } else { let src_layout = self.layout_of(src.ty)?;

<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. // compile-pass #![feature(extern_types)] extern { type Opaque; } const FOO: *const u8 = &42 as *const _ as *const Opaque as *const u8; fn main() { let _foo = FOO; } </ins>

<del> Subproject commit f48fed70d4447445b586a35c4ae88683542ffc72 </del> <ins> Subproject commit e0e1bd7ff778e5913b566c9e03224faecc0eb486 </ins>
Change:
The below example : I've tried minimizing the example as much as possible and that's the best I can do for now. Version: rustc 1.27.0-nightly ( 2018-05-06)
I have the same error, interesstingly the error seems to have something to do with PhantomData: Edit 1 & 2: Smaller example
After some testing i found out it has nothing to do with the PhantomData, since the following code still gives the same error: edit: further simplification
I think it's related to promoting references to fat pointers in const contexts. In your example you promote a closure to (?). In my example, I promote to .
It seems that the Problem only occurs, when using the associated constant from inside the implementation block:
I found a different example which gives the same error: It only ICEs if I initialize with a . It compiles after replacing the line with Moving the function outside the impl block still ICEs, but with a different error:
Hit this in , in stable(1.28.0), beta(1.29.0-beta.1) and nightly ( 2018-08-03). Here's the commit which exemplifies the issue: (run to trigger). Basically, I cant newtype-wrap a struct with , which requires me to duplicate doc comments :(
Triage: both the original example and the once_cell bug no longer reproduce for me on 1.31.1 (2018 release) and 1.34.1 (stable at the time of writing). The issue should probably be closed. Or do we want to add run-pass test just in case?
Lets add a regression test.

Discussion:
<ins> // compile-pass use std::marker::PhantomData; struct Meta<A> { value: i32, type_: PhantomData<A> } trait MetaTrait { fn get_value(&self) -> i32; } impl<A> MetaTrait for Meta<A> { fn get_value(&self) -> i32 { self.value } } trait Bar { fn get_const(&self) -> &dyn MetaTrait; } struct Foo<A> { _value: A } impl<A: 'static> Foo<A> { const CONST: &'static dyn MetaTrait = &Meta::<Self> { value: 10, type_: PhantomData }; } impl<A: 'static> Bar for Foo<A> { fn get_const(&self) -> &dyn MetaTrait { Self::CONST } } fn main() { let foo = Foo::<i32> { _value: 10 }; let bar: &dyn Bar = &foo; println!("const {}", bar.get_const().get_value()); } </ins>
Change:
having a function signature like the following, results in a stack overflow during compilation on rustc 1.26.0 ( 2018-05-07), rustc 1.26.0-beta.18 (2018-05-03 ), and rustc 1.27.0-nightly ( 2018-05-09) Adding the Output parameter, like the example below, still results in a stack overflow: A signature looking like however does compile. A playground link to make things more clear:
This might be the same issue as

Discussion:
use rustc::ty::{self, TyCtxt, Ty, TypeFoldable}; use rustc::ty::fold::TypeVisitor; use rustc::ty::maps::Providers; <ins> use rustc::ty::subst::UnpackedKind; </ins> use rustc::util::nodemap::NodeSet; use syntax::ast::{self, CRATE_NODE_ID, Ident}; use syntax::symbol::keywords;

use std::cmp; use std::mem::replace; <ins> use rustc_data_structures::fx::FxHashSet; </ins> use rustc_data_structures::sync::Lrc; mod diagnostics;

in_body: bool, span: Span, empty_tables: &'a ty::TypeckTables<'tcx>, <ins> visited_anon_tys: FxHashSet<DefId> </ins> } impl<'a, 'tcx> TypePrivacyVisitor<'a, 'tcx> {

self.tcx.sess.span_err(self.span, &msg); return true; } <del> // `Self` here is the same `TyAnon`, so skip it to avoid infinite recursion for subst in trait_ref.substs.iter().skip(1) { </del> <ins> for subst in trait_ref.substs.iter() { // Skip repeated `TyAnon`s to avoid infinite recursion. if let UnpackedKind::Type(ty) = subst.unpack() { if let ty::TyAnon(def_id, ..) = ty.sty { if !self.visited_anon_tys.insert(def_id) { continue; } } } </ins> if subst.visit_with(self) { return true; }

in_body: false, span: krate.span, empty_tables: &empty_tables, <ins> visited_anon_tys: FxHashSet() </ins> }; intravisit::walk_crate(&mut visitor, krate);

<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. // Tests for nested self-reference which caused a stack overflow. use std::fmt::Debug; use std::ops::*; fn gen() -> impl PartialOrd + PartialEq + Debug { } struct Bar {} trait Foo<T = Self> {} impl Foo for Bar {} fn foo() -> impl Foo { Bar {} } fn test_impl_ops() -> impl Add + Sub + Mul + Div { 1 } fn test_impl_assign_ops() -> impl AddAssign + SubAssign + MulAssign + DivAssign { 1 } fn main() {} </ins>
Change:
Test case: Actual result (nightly): Expected result: Ideally the parser would guess that there was meant to be a comma at the end of the line. Then: The "expected comma" error could highlight the line missing a comma (and suggest a fix-it), rather than highlighting the first token in the next line. After producing an error, it could recover by pretending the comma was there, adding the and fields to the struct to avoid the latter two errors.
I propose to work on that one.

Discussion:
return Err(err); } } <del> _ => return Err(self.span_fatal_help(self.span, &format!("expected `,`, or `}}`, found `{}`", self.this_token_to_string()), "struct fields should be separated by commas")), </del> <ins> _ => { let sp = self.sess.codemap().next_point(self.prev_span); let mut err = self.struct_span_err(sp, &format!("expected `,`, or `}}`, found `{}`", self.this_token_to_string())); if self.token.is_ident() { // This is likely another field; emit the diagnostic and keep going err.span_suggestion(sp, "try adding a comma", ",".into()); err.emit(); } else { return Err(err) } } </ins> } Ok(a_var) }

<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. // compile-flags: -Z parse-only // Issue #50636 struct S { foo: u32 //~ expected `,`, or `}`, found `bar` //     ~^ HELP try adding a comma: ',' bar: u32 } fn main() { let s = S { foo: 5, bar: 6 }; } </ins>

<ins> error: expected `,`, or `}`, found `bar` --> $DIR/struct-missing-comma.rs:16:13 | LL |     foo: u32 //~ expected `,`, or `}`, found `bar` |             ^ help: try adding a comma: `,` error: aborting due to previous error </ins>
Change:
(Non-minimized) Repro case: It can correct fail with E0308 "mismatched types" if that line is removed. <details<summaryCrash log</summary</detailsThe ICE is repro with 1.27-beta and nightly. <details<summaryOn 1.26-stable, this will produce an infinite recursion instead.</summary</detailsMaybe the same as .
This, I think, can be closed: in nightly and 1.36.0 the code no longer produces an ICE and instead fails with an error "just fine".
Do you think you could create a minimal test to close this issue with?
This still needs a more minimal reproduction. I can't get to build using any of the compilers that are problematic. The reproduction should show what is happening from including that causes this issue.

Discussion:
<ins> // This previously caused an ICE at: // librustc/traits/structural_impls.rs:180: impossible case reached #![no_main] use std::borrow::Borrow; use std::io; use std::io::Write; trait Constraint {} struct Container<T> { t: T, } struct Borrowed; struct Owned; impl<'a, T> Write for &'a Container<T> where T: Constraint, &'a T: Write, { fn write(&mut self, buf: &[u8]) -> io::Result<usize> { Ok(buf.len()) } fn flush(&mut self) -> io::Result<()> { Ok(()) } } impl Borrow<Borrowed> for Owned { fn borrow(&self) -> &Borrowed { &Borrowed } } fn func(owned: Owned) { let _: () = Borrow::borrow(&owned); //~ ERROR mismatched types } </ins>

<ins> error[E0308]: mismatched types --> $DIR/issue-50687-ice-on-borrow.rs:40:17 | LL |     let _: () = Borrow::borrow(&owned); |            --   ^^^^^^^^^^^^^^^^^^^^^^ |            |    | |            |    expected `()`, found reference |            |    help: consider dereferencing the borrow: `*Borrow::borrow(&owned)` |            expected due to this | = note: expected unit type `()` found reference `&_` error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. </ins>
Change:
Input: Output: This is on commit .
I've edited that code just recently so would want to work on this
Made PR to fix this
Thanks for fixing this :-) I also reported a couple of other looping-related bugs in in case you also want to have a look at those.
wow those are quite nice bugs :p. Will have a look.

Discussion:
self.with_context(LabeledBlock, |v| v.visit_block(&b)); } hir::ExprBreak(label, ref opt_expr) => { <ins> opt_expr.as_ref().map(|e| self.visit_expr(e)); </ins> if self.require_label_in_labeled_block(e.span, &label, "break") { // If we emitted an error about an unlabeled break in a labeled // block, we don't need any further checking for this break any more

<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. #[allow(unreachable_code)] fn main() { loop { break while continue { //~ ERROR E0590 } } } </ins>

<ins> error[E0590]: `break` or `continue` with no label in the condition of a `while` loop --> $DIR/issue-50802.rs:15:21 | LL |         break while continue { //~ ERROR E0590 |                     ^^^^^^^^ unlabeled `continue` in the condition of a `while` loop error: aborting due to previous error For more information about this error, try `rustc --explain E0590`. </ins>
Change:
See for details. Let me know if anything needs clarification.
cc
Oh! That could use some clarification. Thanks for the report!
You're welcome!

Discussion:
an example block that looks like this: ```text <del> /// Some documentation. # fn foo() {} </del> <ins> /// /// Some documentation. /// # fn foo() {} // this function will be hidden /// println!("Hello, World!"); </ins> ``` It will render like this:

```rust /// Some documentation. # fn foo() {} <ins> println!("Hello, World!"); </ins> ``` Yes, that's right: you can add lines that start with `# `, and they will
Change:
Hi, I'm running into an issue I believe introduced in the nightly compiler sometime after . I filed another issue in earlier: , but believe that it is a compiler change that caused this to occur. I've created a test-case repository here: On my current nightly, the wasm code produced fails validation with with the error: , but this does not occur with nightly-2018-05-09. I've included the rustc version that I ran against in the test-case repository, but please let me know if any other information would be useful!
Thanks for the report here I've been able to reproduce with these instructions! It looks like somewhere along the way LLVM is producing an invalid object file for wasm. Using I get: Sure enough using to reassemble one of the intermediate bytecode files I'm also able to generate the same error. I've opened an to track this for LLVM
This has been and I've to update our LLVM with that fix

Discussion:
<del> Subproject commit 56c931901cfb85cd6f7ed44c7d7520a8de1edf97 </del> <ins> Subproject commit 9ad4b7e8d7d1618fc9686aa8d3d0b4de3b7a6f36 </ins>
Change:
Currently we have some rather complex rules for when an object type (or etc) for a trait implements the trait . I think we should just say that does not implement . We can instead add a deriving mode to derive an implementation of for , , or . There are a number of unsoundness issues that can result from object types implementing their associated trait. Consider the following examples: We can come up with rules that prevent these examples, but those rules ultimately get quite complex. Simply saying that avoids all these problems. Then we can add a deriving rule. All of the scenarios above would result in a type check violation when you tried to actually write out that impl.
Removed RFC tag as this was agreed to in today's meeting.

Discussion:
p2.recv(); error!("sibling fails"); fail!(); <del> } </del> <ins> } </ins> let (p3,c3) = comm::stream(); c.send(c3); c2.send(()); error!("child blocks"); p3.recv(); <del> }; </del> <ins> }; </ins> error!("parent tries"); assert !p.recv().try_send(()); error!("all done!");