jiebi/CodeConvo huggingface dataset:
Change:
This code is wrong, but the error message is confusing: Because I used accidentally as a type name when not using the right syntax ... this is pretty confusing:
One solution would be to add detail after the expected/found lines if primitive shadowing has come into play. This would not change the language, but make the error look like:

Discussion:
}; if !is_simple_error { <del> diag.note_expected_found(&"type", &expected, &found); </del> <ins> if expected == found { if let &TypeError::Sorts(ref values) = terr { diag.note_expected_found_extra( &"type", &expected, &found, &format!(" ({})", values.expected.sort_string(self.tcx)), &format!(" ({})", values.found.sort_string(self.tcx))); } else { diag.note_expected_found(&"type", &expected, &found); } } else { diag.note_expected_found(&"type", &expected, &found); } </ins> } }

} impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> { <del> fn sort_string(&self, tcx: TyCtxt<'a, 'gcx, 'lcx>) -> String { </del> <ins> pub fn sort_string(&self, tcx: TyCtxt<'a, 'gcx, 'lcx>) -> String { </ins> match self.sty { ty::TyBool | ty::TyChar | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) | ty::TyStr | ty::TyNever => self.to_string(),

found: &fmt::Display) -> &mut DiagnosticBuilder<'a> { <ins> self.note_expected_found_extra(label, expected, found, &"", &"") } pub fn note_expected_found_extra(&mut self, label: &fmt::Display, expected: &fmt::Display, found: &fmt::Display, expected_extra: &fmt::Display, found_extra: &fmt::Display) -> &mut DiagnosticBuilder<'a> { </ins> // For now, just attach these as notes <del> self.note(&format!("expected {} `{}`", label, expected)); self.note(&format!("   found {} `{}`", label, found)); </del> <ins> self.note(&format!("expected {} `{}`{}", label, expected, expected_extra)); self.note(&format!("   found {} `{}`{}", label, found, found_extra)); </ins> self }

Some(t) => t, None => diag.bug(&msg()), } <del> } </del>  No newline at end of file <ins> } </ins>

<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. // rustc-env:RUST_NEW_ERROR_FORMAT trait Parser<T> { fn parse(text: &str) -> Option<T>; } impl<bool> Parser<bool> for bool { fn parse(text: &str) -> Option<bool> { Some(true) } } fn main() { println!("{}", bool::parse("ok").unwrap_or(false)); } </ins>

<ins> error[E0308]: mismatched types --> $DIR/issue-35030.rs:19:14 | 19 |         Some(true) |              ^^^^ expected type parameter, found bool | = note: expected type `bool` (type parameter) = note:    found type `bool` (bool) error: aborting due to previous error </ins>
Change:
From: src/test/compile- We need to add a span_label to update E0001 from: To:
Taking it

Discussion:
hir::MatchSource::Normal => { let mut err = struct_span_err!(cx.tcx.sess, pat.span, E0001, "unreachable pattern"); <ins> err.span_label(pat.span, &format!("this is an unreachable pattern")); </ins> // if we had a catchall pattern, hint at that for row in &seen.0 { if pat_is_catchall(&cx.tcx.def_map.borrow(), row[0].0) {

//~^ NOTE this pattern matches any value Var2 => (), //~^ ERROR unreachable pattern <ins> //~^^ NOTE this is an unreachable pattern </ins> }; match &s { &Var1 => (),

//~^ NOTE this pattern matches any value &Var2 => (), //~^ ERROR unreachable pattern <ins> //~^^ NOTE this is an unreachable pattern </ins> }; let t = (Var1, Var1); match t {

//~^ NOTE this pattern matches any value anything => () //~^ ERROR unreachable pattern <ins> //~^^ NOTE this is an unreachable pattern </ins> }; // `_` need not emit a note, it is pretty obvious already. let t = (Var1, Var1);

_ => (), anything => () //~^ ERROR unreachable pattern <ins> //~^^ NOTE this is an unreachable pattern </ins> }; }
Change:
From: src/test/compile- A span_label is needed on E0010, taking it from: To:
Hi, I've got my attempt at updating E0010. It's based on my reading of , and it seems to output what I'd expect when I test it.
This should be fixed by .

Discussion:
Rvalue::Box(_) => { self.add(Qualif::NOT_CONST); if self.mode != Mode::Fn { <del> span_err!(self.tcx.sess, self.span, E0010, "allocations are not allowed in {}s", self.mode); </del> <ins> struct_span_err!(self.tcx.sess, self.span, E0010, "allocations are not allowed in {}s", self.mode) .span_label(self.span, &format!("allocation not allowed in {}s", self.mode)) .emit(); </ins> } }

#![feature(box_syntax)] const CON : Box<i32> = box 0; //~ ERROR E0010 <ins> //~| NOTE allocation not allowed in </ins> fn main() {}
Change:
I got in my : but still seems to attempt using /usr/bin/llvm-config cc
I think that the actual behavior (from IRC) that happened here was that configuration change in , but the build script wasn't re-run. The build script should probably print out pointing at if it exists, passed through via rustbuild.
I think the build script doesn't point to with ; is it possible we could make this into an E-easy issue? I get the feeling that this would also make a decent intro into rustbuild.
Certainly! I think we'll need to pass the path of via an env var, but that shouldn't be too onerous to do in rustbuild either. If anyone's got any questions please feel free to ask!
I would like to work on this. Can I use the env var to pass the path of from ? Or or .
I think an env var would probably be the best approach. seems good, but that can be bikeshedded in the PR. Let us know if we can do anything to help!

Discussion:
if build.is_rust_llvm(target) { cargo.env("LLVM_RUSTLLVM", "1"); } <ins> if let Some(ref cfg_file) = build.flags.config { let cfg_path = t!(PathBuf::from(cfg_file).canonicalize()); cargo.env("CFG_LLVM_TOML", cfg_path.into_os_string()); } </ins> cargo.env("LLVM_CONFIG", build.llvm_config(target)); let target_config = build.config.target_config.get(target); if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) {

println!("cargo:rerun-if-changed={}", llvm_config.display()); <ins> if let Some(cfg_toml) = env::var_os("CFG_LLVM_TOML") { let cfg_path = PathBuf::from(cfg_toml); println!("cargo:rerun-if-changed={}", cfg_path.display()); } </ins> // Test whether we're cross-compiling LLVM. This is a pretty rare case // currently where we're producing an LLVM for a different platform than // what this build script is currently running on.
Change:
From: src/test/compile- Error E0094 needs a span_label, updating it from: To: Bonus: That span is pretty long, though I'm not sure if it can be fixed. Worth seeing if we can shrink the span to:
I would take this one.

Discussion:
})); let i_n_tps = i_ty.generics.types.len(subst::FnSpace); if i_n_tps != n_tps { <del> span_err!(tcx.sess, it.span, E0094, </del> <ins> struct_span_err!(tcx.sess, it.span, E0094, </ins> "intrinsic has wrong number of type  parameters: found {}, expected {}", <del> i_n_tps, n_tps); </del> <ins> i_n_tps, n_tps) .span_label(it.span, &format!("expected {} type parameter", n_tps)) .emit(); </ins> } else { require_same_types(ccx, TypeOrigin::IntrinsicType(it.span),

#![feature(intrinsics)] extern "rust-intrinsic" { fn size_of<T, U>() -> usize; //~ ERROR E0094 <ins> //~| NOTE expected 1 type parameter </ins> } fn main() {
Change:
From: src/test/compile- Error E0106 needs a span_label, updating it from: To:
I'll try this one.
I think "expected lifetime parameter" is a better label. bonus: have the label on the ampersand only.
to suggestions
Do you mean like this? Or like this, with the primary span changed?
I think he means the second one:

Discussion:
None => match rscope.anon_regions(default_span, 1) { Ok(rs) => rs[0], Err(params) => { <del> let mut err = struct_span_err!(self.tcx().sess, default_span, E0106, "missing lifetime specifier"); </del> <ins> let ampersand_span = Span { hi: default_span.lo, ..default_span}; let mut err = struct_span_err!(self.tcx().sess, ampersand_span, E0106, "missing lifetime specifier"); err.span_label(ampersand_span, &format!("expected lifetime parameter")); </ins> if let Some(params) = params { report_elision_failure(&mut err, params); }

// except according to those terms. struct Foo { <del> x: &bool, //~ ERROR E0106 </del> <ins> x: &bool, //~^ ERROR E0106 //~| NOTE expected lifetime parameter </ins> } enum Bar { A(u8), <del> B(&bool), //~ ERROR E0106 </del> <ins> B(&bool), //~^ ERROR E0106 //~| NOTE expected lifetime parameter </ins> } <del> type MyStr = &str; //~ ERROR E0106 </del> <ins> type MyStr = &str; //~^ ERROR E0106 //~| NOTE expected lifetime parameter </ins> fn main() { }
Change:
From: src/test/compile- Error E0117 needs a span_label, updated error text, and a note, updating it from: to:
In case no one is working with this yet, I can give this a go.

Discussion:
fn check_item(&self, item: &hir::Item) { let def_id = self.tcx.map.local_def_id(item.id); match item.node { <del> hir::ItemImpl(_, _, _, None, _, _) => { </del> <ins> hir::ItemImpl(_, _, _, None, ref ty, _) => { </ins> // For inherent impls, self type must be a nominal type // defined in this crate. debug!("coherence2::orphan check: inherent impl {}",

return; } _ => { <del> struct_span_err!(self.tcx.sess, item.span, E0118, </del> <ins> struct_span_err!(self.tcx.sess, ty.span, E0118, </ins> "no base type found for inherent implementation") <del> .span_help(item.span, "either implement a trait on it or create a newtype to wrap it  instead") </del> <ins> .span_label(ty.span, &format!("impl requires a base type")) .note(&format!("either implement a trait on it or create a newtype  to wrap it instead")) </ins> .emit(); return; }

match traits::orphan_check(self.tcx, def_id) { Ok(()) => { } Err(traits::OrphanCheckErr::NoLocalInputType) => { <del> span_err!( </del> <ins> struct_span_err!( </ins> self.tcx.sess, item.span, E0117, <del> "the impl does not reference any  types defined in this crate;  only traits defined in the current crate can be  implemented for arbitrary types"); </del> <ins> "only traits defined in the current crate can be  implemented for arbitrary types") .span_label(item.span, &format!("impl doesn't use types inside crate")) .note(&format!("the impl does not reference any  types defined in this crate")) .emit(); </ins> return; } Err(traits::OrphanCheckErr::UncoveredTy(param_ty)) => {

// except according to those terms. impl Drop for u32 {} //~ ERROR E0117 <ins> //~^ NOTE impl doesn't use types inside crate //~| NOTE the impl does not reference any types defined in this crate </ins> fn main() { }

// except according to those terms. impl (u8, u8) { //~ ERROR E0118 <ins> //~^ NOTE impl requires a base type //~| NOTE either implement a trait on it or create a newtype to wrap it instead </ins> fn get_state(&self) -> String { String::new() }
Change:
From: src/test/compile- Error E0118 needs a spanlabel and a spannote to be a simple note, updating from: To: Bonus: It'd be good if we could underline the type it's complaining about.
In case no one is working with this yet, I can give this a go.

Discussion:
fn check_item(&self, item: &hir::Item) { let def_id = self.tcx.map.local_def_id(item.id); match item.node { <del> hir::ItemImpl(_, _, _, None, _, _) => { </del> <ins> hir::ItemImpl(_, _, _, None, ref ty, _) => { </ins> // For inherent impls, self type must be a nominal type // defined in this crate. debug!("coherence2::orphan check: inherent impl {}",

return; } _ => { <del> struct_span_err!(self.tcx.sess, item.span, E0118, </del> <ins> struct_span_err!(self.tcx.sess, ty.span, E0118, </ins> "no base type found for inherent implementation") <del> .span_help(item.span, "either implement a trait on it or create a newtype to wrap it  instead") </del> <ins> .span_label(ty.span, &format!("impl requires a base type")) .note(&format!("either implement a trait on it or create a newtype  to wrap it instead")) </ins> .emit(); return; }

match traits::orphan_check(self.tcx, def_id) { Ok(()) => { } Err(traits::OrphanCheckErr::NoLocalInputType) => { <del> span_err!( </del> <ins> struct_span_err!( </ins> self.tcx.sess, item.span, E0117, <del> "the impl does not reference any  types defined in this crate;  only traits defined in the current crate can be  implemented for arbitrary types"); </del> <ins> "only traits defined in the current crate can be  implemented for arbitrary types") .span_label(item.span, &format!("impl doesn't use types inside crate")) .note(&format!("the impl does not reference any  types defined in this crate")) .emit(); </ins> return; } Err(traits::OrphanCheckErr::UncoveredTy(param_ty)) => {

// except according to those terms. impl Drop for u32 {} //~ ERROR E0117 <ins> //~^ NOTE impl doesn't use types inside crate //~| NOTE the impl does not reference any types defined in this crate </ins> fn main() { }

// except according to those terms. impl (u8, u8) { //~ ERROR E0118 <ins> //~^ NOTE impl requires a base type //~| NOTE either implement a trait on it or create a newtype to wrap it instead </ins> fn get_state(&self) -> String { String::new() }
Change:
From: src/test/compile- Error E0119 needs a spanlabel and a spannote converted to a span_label, updating it from: To:
Grabbed this one from the list.

Discussion:
self.tcx.sess, self.tcx.span_of_impl(impl_def_id).unwrap(), E0119, "conflicting implementations of trait `{}`{}:", overlap.trait_desc, <del> overlap.self_desc.map_or(String::new(), |ty| format!(" for type `{}`", ty))); </del> <ins> overlap.self_desc.clone().map_or(String::new(), |ty| format!(" for type `{}`", ty))); </ins> match self.tcx.span_of_impl(overlap.with_impl) { Ok(span) => { <del> err.span_note(span, "conflicting implementation is here:"); </del> <ins> err.span_label(span, &format!("first implementation here")); err.span_label(self.tcx.span_of_impl(impl_def_id).unwrap(), &format!("conflicting implementation{}", overlap.self_desc .map_or(String::new(), |ty| format!(" for `{}`", ty)))); </ins> } Err(cname) => { err.note(&format!("conflicting implementation in crate `{}`",

fn get(&self) -> usize; } <del> impl<T> MyTrait for T { </del> <ins> impl<T> MyTrait for T { //~ NOTE first implementation here </ins> fn get(&self) -> usize { 0 } }

} impl MyTrait for Foo { //~ ERROR E0119 <ins> //~| NOTE conflicting implementation for `Foo` </ins> fn get(&self) -> usize { self.value } }

struct MyStruct; impl Drop for MyStruct { <del> //~^ NOTE conflicting implementation is here </del> <ins> //~^ NOTE first implementation here </ins> fn drop(&mut self) { } } impl Drop for MyStruct { //~^ ERROR conflicting implementations of trait <ins> //~| NOTE conflicting implementation for `MyStruct` </ins> fn drop(&mut self) { } }
Change:
From: src/test/compile- Error E0124 needs a spanlabel and a spannote replaced with a span_label, updating it from: To:
Error message updated in .

Discussion:
let fid = ccx.tcx.map.local_def_id(f.id); let dup_span = seen_fields.get(&f.name).cloned(); if let Some(prev_span) = dup_span { <del> let mut err = struct_span_err!(ccx.tcx.sess, f.span, E0124, "field `{}` is already declared", f.name); span_note!(&mut err, prev_span, "previously declared here"); err.emit(); </del> <ins> struct_span_err!(ccx.tcx.sess, f.span, E0124, "field `{}` is already declared", f.name) .span_label(f.span, &"field already declared") .span_label(prev_span, &format!("`{}` first declared here", f.name)) .emit(); </ins> } else { seen_fields.insert(f.name, f.span); }

// except according to those terms. struct Foo { <ins> field1: i32, //~ NOTE `field1` first declared here </ins> field1: i32, <del> field1: i32, //~ ERROR E0124 </del> <ins> //~^ ERROR field `field1` is already declared [E0124] //~| NOTE field already declared </ins> } fn main() {

// except according to those terms. struct BuildData { <ins> foo: isize, //~ NOTE `foo` first declared here </ins> foo: isize, <del> foo: isize, //~ ERROR field `foo` is already declared </del> <ins> //~^ ERROR field `foo` is already declared [E0124] //~| NOTE field already declared </ins> } fn main() {
Change:
From: src/test/compile- Error E0184 needs a span_label, updating it from: To: Bonus: I'm not sure that note is helping, you can probably just remove it.
On it
- I am releasing this one so someone else can take it, but feel free to come grab another one

Discussion:
let &(ref first_arm_pats, _) = &arms[0]; let first_pat = &first_arm_pats[0]; let span = first_pat.span; <del> span_err!(cx.tcx.sess, span, E0165, "irrefutable while-let pattern"); </del> <ins> struct_span_err!(cx.tcx.sess, span, E0165, "irrefutable while-let pattern") .span_label(span, &format!("irrefutable pattern")) .emit(); </ins> }, hir::MatchSource::ForLoopDesugar => {

tcx.sess.add_lint(lint::builtin::MATCH_OF_UNIT_VARIANT_VIA_PAREN_DOTDOT, pat.id, pat.span, msg); } else { <del> span_err!(tcx.sess, pat.span, E0164, "{}", msg); </del> <ins> struct_span_err!(tcx.sess, pat.span, E0164, "{}", msg) .span_label(pat.span, &format!("not a tuple variant or struct")).emit(); </ins> on_error(); } };

.emit(); } Err(CopyImplementationError::HasDestructor) => { <del> span_err!(tcx.sess, span, E0184, </del> <ins> struct_span_err!(tcx.sess, span, E0184, </ins> "the trait `Copy` may not be implemented for this type;  <del> the type has a destructor"); </del> <ins> the type has a destructor") .span_label(span, &format!("Copy not allowed on types with destructors")) .emit(); </ins> } } });

fn bar(foo: Foo) -> u32 { match foo { Foo::B(i) => i, //~ ERROR E0164 <ins> //~| NOTE not a tuple variant or struct </ins> } }

fn main() { let irr = Irrefutable(0); while let Irrefutable(x) = irr { //~ ERROR E0165 <ins> //~| irrefutable pattern </ins> // ... } }

// except according to those terms. #[derive(Copy)] //~ ERROR E0184 <ins> //~| NOTE Copy not allowed on types with destructors //~| NOTE in this expansion of #[derive(Copy)] </ins> struct Foo; impl Drop for Foo {
Change:
: “set directory where libjemallocpic.a is located”, but it actually expects full path of , not a directory. When I set (and --enable-rustbuild), then build fails: The problem is in . It works fine with .
A friendly ping, this would break most distros on a major release.

Discussion:
"CFG_JEMALLOC_ROOT" if value.len() > 0 => { let target = self.target_config.entry(self.build.clone()) .or_insert(Target::default()); <del> target.jemalloc = Some(parse_configure_path(value)); </del> <ins> target.jemalloc = Some(parse_configure_path(value).join("libjemalloc_pic.a")); </ins> } "CFG_ARM_LINUX_ANDROIDEABI_NDK" if value.len() > 0 => { let target = "arm-linux-androideabi".to_string();
Change:
I have tried this command to dump MIR things : But it won't create the directory for me, I need to create the directory before running the command. If the directory doesn't exist, it won't show any error message and it won't generate any MIR file. I think we should create the directory automatically. Even not doing so, we should show some error message. Addtionally, I wonder what are other people's opinions on setting default MIR dumping directory to somewhere like instead of current directory. Using : rustc 1.12.0-nightly ( 2016-08-05) cargo 0.13.0-nightly ( 2016-08-05)
I'm marking this as E-easy and E-mentor; we need to add a call on the parent directory of the file path. Let me know if you'd like to work on this.
sure, I can work on this :)
Go ahead! Please cc me on the PR when you create it, and let us know if you need any help; leaving a comment here works, or you can find help on IRC (#rust-internals on ).

Discussion:
let p = Path::new(file_dir); file_path.push(p); }; <ins> let _ = fs::create_dir_all(&file_path); </ins> let file_name = format!("rustc.node{}{}{}.{}.{}.mir", source.item_id(), promotion_id, pass_num, pass_name, disambiguator); file_path.push(&file_name);
Change:
From: src/test/compile-fail/regions-escape-loop-via- E0503 needs a spanlabel and a spannote converted to a span_label, updating: To:
I can take this

Discussion:
struct_span_err!(self.bccx, span, E0503, "cannot use `{}` because it was mutably borrowed", &self.bccx.loan_path_to_string(copy_path)) <del> .span_note(loan_span, </del> <ins> .span_label(loan_span, </ins> &format!("borrow of `{}` occurs here", &self.bccx.loan_path_to_string(&loan_path)) ) <ins> .span_label(span, &format!("use of borrowed `{}`", &self.bccx.loan_path_to_string(&loan_path))) </ins> .emit(); } }

let _x = &mut a.x; //~^ NOTE borrow of `a.x` occurs here let _y = a.y; //~ ERROR cannot use <ins> //~^ NOTE use of borrowed `a.x` </ins> } fn move_after_mut_borrow() {

let _x = &mut a.x.x; //~^ NOTE borrow of `a.x.x` occurs here let _y = a.y; //~ ERROR cannot use <ins> //~^ NOTE use of borrowed `a.x.x` </ins> } fn move_after_mut_borrow_nested() {

($this:expr) => { $this.width.unwrap() //~^ ERROR cannot use `self.width` because it was mutably borrowed <ins> //~| NOTE use of borrowed `*self` </ins> } );

fn broken() { let mut x = 3; let mut _y = vec!(&mut x); <ins> //~^ NOTE borrow of `x` occurs here //~| NOTE borrow of `x` occurs here //~| NOTE borrow of `x` occurs here </ins> while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed <ins> //~^ NOTE use of borrowed `x` </ins> let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed <ins> //~^ NOTE use of borrowed `x` </ins> _y.push(&mut z); //~ ERROR `z` does not live long enough <ins> //~^ NOTE does not live long enough </ins> x += 1; //~ ERROR cannot assign <ins> //~^ NOTE assignment to borrowed `x` occurs here </ins> } <ins> //~^ NOTE borrowed value only valid until here </ins> } <ins> //~^ NOTE borrowed value must be valid until here </ins> fn main() { }