jiebi/CodeConvo huggingface dataset:
Change:
clang -S produces nicely commented .s files. It would be nice if rustc did this too. e.g. simd shuffles are commented .loc directives have the corresponding line number comment .loc 1 4 25 isstmt 1 ## test.c:4:25 debug information is commented .byte 14 ## DWFORMstrp .byte 17 ## DWATlowpc .byte 1 ## DWFORMaddr .byte 18 ## DWAThighpc .byte 1 ## DWFORM_addr
There might be a or flag already for this. AFAIK what clang emits comes from LLVM.
This flag is already , should be usable (issue can be closed?):
Any reason not to make this the default?
Likely the fact that it may change the behavior (I don't actually know what that means but this seems like a valid assumption).
it looks like -Z asm-comments doesn't do this. MCOptions.AsmVerbose must be set to true for the assembler to emit them.
So it looks like -Zasm-comments isn't actually used anywhere based on what I can find in the source... or, rather, its uses are in methods that are themselves never called.
Yeah, to get comments I believe I needed to set a verbose flag in some llvm context. Clang does this by default and it would be nice if rustc did too.
IIUC without this neither the playground nor godbolt (compiler-explorer) can map assembly to lines of Rust source code.
Godbolt uses debug info AFAIK? Our debug info isn't always great but in general it's working, isn't it?
It seems like they just don't do it much. Godbolt uses directives in the assembly file, which rustc seems to generate correctly, sorry for the noise.

Discussion:
let is_pie_binary = !find_features && is_pie_binary(sess); let trap_unreachable = sess.target.target.options.trap_unreachable; <ins> let asm_comments = sess.asm_comments(); </ins> Arc::new(move || { let tm = unsafe { llvm::LLVMRustCreateTargetMachine(

fdata_sections, trap_unreachable, singlethread, <ins> asm_comments, </ins> ) };

FunctionSections: bool, DataSections: bool, TrapUnreachable: bool, <del> Singlethread: bool) </del> <ins> Singlethread: bool, AsmComments: bool) </ins> -> Option<&'static mut TargetMachine>; pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine); pub fn LLVMRustAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>, M: &'a Module);

bool PositionIndependentExecutable, bool FunctionSections, bool DataSections, bool TrapUnreachable, <del> bool Singlethread) { </del> <ins> bool Singlethread, bool AsmComments) { </ins> auto OptLevel = fromRust(RustOptLevel); auto RM = fromRust(RustReloc);

} Options.DataSections = DataSections; Options.FunctionSections = FunctionSections; <ins> Options.MCOptions.AsmVerbose = AsmComments; Options.MCOptions.PreserveAsmComments = AsmComments; </ins> if (TrapUnreachable) { // Tell LLVM to codegen `unreachable` into an explicit trap instruction.
Change:
Under rustbuild no needs to exist, and this test tries to open that file. The test should be changed to open something else, preferably not a file on filesystem.
How about opening the test source file itself?

Discussion:
} fn parent() { <del> let file = File::open("Makefile").unwrap(); </del> <ins> let file = File::open(file!()).unwrap(); </ins> let tcp1 = TcpListener::bind("127.0.0.1:0").unwrap(); let tcp2 = tcp1.try_clone().unwrap(); let addr = tcp1.local_addr().unwrap();
Change:
Label message always mention "unsafe call", even when nothing is actually called. It should duplicate the main message instead, or use some paraphrase of it. cc
How about this :
I've made a , please check the error messages again :)
Fix in , should be closed.

Discussion:
struct_span_err!( self.tcx.sess, span, E0133, "{} requires unsafe function or block", description) <del> .span_label(span, &format!("unsafe call requires unsafe function or block")) </del> <ins> .span_label(span, &description) </ins> .emit(); } UnsafeBlock(block_id) => {

fn main() { f(); //~^ ERROR E0133 <del> //~| NOTE unsafe call requires unsafe function or block </del> <ins> //~| NOTE call to unsafe function </ins> }

fn main() { (&ptr::write)(1 as *mut _, 42); //~^ ERROR E0133 <del> //~| NOTE unsafe call requires unsafe function or block </del> <ins> //~| NOTE call to unsafe function </ins> }

// Unsafe actions are not made legal by taking place in an unsafe trait: *self += 1; //~^ ERROR E0133 <del> //~| NOTE unsafe call requires unsafe function or block </del> <ins> //~| NOTE dereference of raw pointer </ins> } }

const VAL: u32 = dummy(0xFFFF); //~^ ERROR E0133 <del> //~| NOTE unsafe call requires unsafe function or block </del> <ins> //~| NOTE call to unsafe function </ins> fn main() { assert_eq!(VAL, 0xFFFF0000);
Change:
For some reason the file is empty. cc
If I run locally, the source package is fine :confused: (although the manifest could be simplified by using bulk dirs). Will investigate further...
So far I've determined that it only fails on linux.
Ah I've tracked down the problem: rust-lang/rust-installer While it's technically a bug in rust-installer, we should probably be using bulk-dirs for the source anyway, and that will fix the problem by shortening the manifest.

Discussion:
<del> Subproject commit c37d3747da75c280237dc2d6b925078e69555499 </del> <ins> Subproject commit 755bc3db4ff795865ea31b5b4f38ac920d8acacb </ins>
Change:
From: src/test/compile- E0445 needs a span_label, updating it from: To:

Discussion:
if name.is_empty() { match span { Some(span) => { <del> span_err!(sess, span, E0454, "#[link(name = "")] given with empty name"); </del> <ins> struct_span_err!(sess, span, E0454, "#[link(name = "")] given with empty name") .span_label(span, &format!("empty name given")) .emit(); </ins> } None => { sess.err("empty library name given via `-l`");

if !vis.is_at_least(self.required_visibility, &self.tcx.map) { if self.tcx.sess.features.borrow().pub_restricted || self.old_error_set.contains(&trait_ref.ref_id) { <del> span_err!(self.tcx.sess, trait_ref.path.span, E0445, "private trait in public interface"); </del> <ins> struct_span_err!(self.tcx.sess, trait_ref.path.span, E0445, "private trait in public interface") .span_label(trait_ref.path.span, &format!( "private trait can't be public")) .emit(); </ins> } else { self.tcx.sess.add_lint(lint::builtin::PRIVATE_IN_PUBLIC, node_id,

fn dummy(&self) { } } <del> pub trait Bar : Foo {} //~ ERROR E0445 pub struct Bar2<T: Foo>(pub T); //~ ERROR E0445 pub fn foo<T: Foo> (t: T) {} //~ ERROR E0445 </del> <ins> pub trait Bar : Foo {} //~^ ERROR private trait in public interface [E0445] //~| NOTE private trait can't be public pub struct Bar2<T: Foo>(pub T); //~^ ERROR private trait in public interface [E0445] //~| NOTE private trait can't be public pub fn foo<T: Foo> (t: T) {} //~^ ERROR private trait in public interface [E0445] //~| NOTE private trait can't be public </ins> fn main() {}

// option. This file may not be copied, modified, or distributed // except according to those terms. <del> #[link(name = "")] extern {} //~ ERROR E0454 </del> <ins> #[link(name = "")] extern {} //~^ ERROR E0454 //~| NOTE empty name given </ins> fn main() { }
Change:
From: src/test/compile- E0453 needs a spanlabel and a spannote changed to a span_label, updating it from: To:

Discussion:
"{}({}) overruled by outer forbid({})", level.as_str(), lint_name, lint_name); <ins> diag_builder.span_label(span, &format!("overruled by previous forbid")); </ins> match now_source { LintSource::Default => &mut diag_builder, LintSource::Node(forbid_source_span) => { <del> diag_builder.span_note(forbid_source_span, "`forbid` lint level set here") </del> <ins> diag_builder.span_label(forbid_source_span, &format!("`forbid` level set here")) </ins> }, LintSource::CommandLine => { diag_builder.note("`forbid` lint level was set on command line")

#![plugin(lint_plugin_test)] #![forbid(test_lint)] //~^ NOTE lint level defined here <del> //~| NOTE `forbid` lint level set here </del> <ins> //~| NOTE `forbid` level set here </ins> fn lintme() { } //~ ERROR item is named 'lintme' <del> #[allow(test_lint)] //~ ERROR allow(test_lint) overruled by outer forbid(test_lint) </del> <ins> #[allow(test_lint)] //~^ ERROR allow(test_lint) overruled by outer forbid(test_lint) //~| NOTE overruled by previous forbid </ins> pub fn main() { lintme(); }

// except according to those terms. #![forbid(non_snake_case)] <ins> //~^ NOTE `forbid` level set here </ins> <del> #[allow(non_snake_case)] //~ ERROR E0453 </del> <ins> #[allow(non_snake_case)] //~^ ERROR allow(non_snake_case) overruled by outer forbid(non_snake_case) //~| NOTE overruled by previous forbid </ins> fn main() { }

// except according to those terms. #![forbid(deprecated)] <del> //~^ NOTE `forbid` lint level set here </del> <ins> //~^ NOTE `forbid` level set here </ins> <del> #[allow(deprecated)] //~ ERROR allow(deprecated) overruled by outer forbid(deprecated) </del> <ins> #[allow(deprecated)] //~^ ERROR allow(deprecated) overruled by outer forbid(deprecated) //~| NOTE overruled by previous forbid </ins> fn main() { }
Change:
From: src/test/compile- E0454 needs a span_label, updating it from: To:

Discussion:
if name.is_empty() { match span { Some(span) => { <del> span_err!(sess, span, E0454, "#[link(name = "")] given with empty name"); </del> <ins> struct_span_err!(sess, span, E0454, "#[link(name = "")] given with empty name") .span_label(span, &format!("empty name given")) .emit(); </ins> } None => { sess.err("empty library name given via `-l`");

if !vis.is_at_least(self.required_visibility, &self.tcx.map) { if self.tcx.sess.features.borrow().pub_restricted || self.old_error_set.contains(&trait_ref.ref_id) { <del> span_err!(self.tcx.sess, trait_ref.path.span, E0445, "private trait in public interface"); </del> <ins> struct_span_err!(self.tcx.sess, trait_ref.path.span, E0445, "private trait in public interface") .span_label(trait_ref.path.span, &format!( "private trait can't be public")) .emit(); </ins> } else { self.tcx.sess.add_lint(lint::builtin::PRIVATE_IN_PUBLIC, node_id,

fn dummy(&self) { } } <del> pub trait Bar : Foo {} //~ ERROR E0445 pub struct Bar2<T: Foo>(pub T); //~ ERROR E0445 pub fn foo<T: Foo> (t: T) {} //~ ERROR E0445 </del> <ins> pub trait Bar : Foo {} //~^ ERROR private trait in public interface [E0445] //~| NOTE private trait can't be public pub struct Bar2<T: Foo>(pub T); //~^ ERROR private trait in public interface [E0445] //~| NOTE private trait can't be public pub fn foo<T: Foo> (t: T) {} //~^ ERROR private trait in public interface [E0445] //~| NOTE private trait can't be public </ins> fn main() {}

// option. This file may not be copied, modified, or distributed // except according to those terms. <del> #[link(name = "")] extern {} //~ ERROR E0454 </del> <ins> #[link(name = "")] extern {} //~^ ERROR E0454 //~| NOTE empty name given </ins> fn main() { }
Change:
From: src/test/compile- E0458 needs a span_label, updating it from: To:

Discussion:
Some("dylib") => cstore::NativeUnknown, Some("framework") => cstore::NativeFramework, Some(k) => { <del> span_err!(self.sess, m.span, E0458, "unknown kind: `{}`", k); </del> <ins> struct_span_err!(self.sess, m.span, E0458, "unknown kind: `{}`", k) .span_label(m.span, &format!("unknown kind")).emit(); </ins> cstore::NativeUnknown } None => cstore::NativeUnknown

let n = match n { Some(n) => n, None => { <del> span_err!(self.sess, m.span, E0459, "#[link(...)] specified without `name = "foo"`"); </del> <ins> struct_span_err!(self.sess, m.span, E0459, "#[link(...)] specified without `name = "foo"`") .span_label(m.span, &format!("missing `name` argument")).emit(); </ins> InternedString::new("foo") } };

// except according to those terms. #[link(kind = "wonderful_unicorn")] extern {} //~ ERROR E0458 <del> //~^ ERROR E0459 </del> <ins> //~| NOTE unknown kind //~| ERROR E0459 //~| NOTE missing `name` argument </ins> fn main() { }

// except according to those terms. #[link(kind = "dylib")] extern {} //~ ERROR E0459 <ins> //~| NOTE missing `name` argument </ins> fn main() { }
Change:
From: src/test/compile- E0459 needs a span_label, updating it from: To:

Discussion:
Some("dylib") => cstore::NativeUnknown, Some("framework") => cstore::NativeFramework, Some(k) => { <del> span_err!(self.sess, m.span, E0458, "unknown kind: `{}`", k); </del> <ins> struct_span_err!(self.sess, m.span, E0458, "unknown kind: `{}`", k) .span_label(m.span, &format!("unknown kind")).emit(); </ins> cstore::NativeUnknown } None => cstore::NativeUnknown

let n = match n { Some(n) => n, None => { <del> span_err!(self.sess, m.span, E0459, "#[link(...)] specified without `name = "foo"`"); </del> <ins> struct_span_err!(self.sess, m.span, E0459, "#[link(...)] specified without `name = "foo"`") .span_label(m.span, &format!("missing `name` argument")).emit(); </ins> InternedString::new("foo") } };

// except according to those terms. #[link(kind = "wonderful_unicorn")] extern {} //~ ERROR E0458 <del> //~^ ERROR E0459 </del> <ins> //~| NOTE unknown kind //~| ERROR E0459 //~| NOTE missing `name` argument </ins> fn main() { }

// except according to those terms. #[link(kind = "dylib")] extern {} //~ ERROR E0459 <ins> //~| NOTE missing `name` argument </ins> fn main() { }
Change:
The iterator never returns , so the at the end will never be reached. The explicit matching against the socket result also seems potentially nonconventional docs-wise?
Also, what are the semantics of this iterator when the listener is set to nonblocking mode? If it's equivalent to it should run the loop with errors until a connection is made.
That's what it'd do, yeah. The method is super simple:

Discussion:
/// /// # Examples /// <del> /// ```no_run </del> <ins> /// ``` /// # use std::io; </ins> /// use std::net::{TcpListener, TcpStream}; /// <del> /// let listener = TcpListener::bind("127.0.0.1:80").unwrap(); /// </del> /// fn handle_client(stream: TcpStream) { ///     // ... /// } /// <ins> /// # fn process() -> io::Result<()> { /// let listener = TcpListener::bind("127.0.0.1:80").unwrap(); /// </ins> /// // accept connections and process them serially /// for stream in listener.incoming() { <del> ///     match stream { ///         Ok(stream) => { ///             handle_client(stream); ///         } ///         Err(e) => { /* connection failed */ } ///     } </del> <ins> ///     handle_client(stream?); </ins> /// } <ins> /// # Ok(()) /// # } </ins> /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub struct TcpListener(net_imp::TcpListener);
Change:
cc , There are no guarantees that the two spans used to create the new one come from the same place or are even valid.

Discussion:
use abi::Abi; use ast::{self, Ident, Generics, Expr, BlockCheckMode, UnOp, PatKind}; use attr; <del> use syntax_pos::{Span, DUMMY_SP, Pos}; </del> <ins> use syntax_pos::{Span, DUMMY_SP}; </ins> use codemap::{dummy_spanned, respan, Spanned}; use ext::base::ExtCtxt; use ptr::P;

} fn expr_field_access(&self, sp: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr> { <del> let field_span = Span { lo: sp.lo - Pos::from_usize(ident.name.as_str().len()), hi: sp.hi, expn_id: sp.expn_id, }; let id = Spanned { node: ident, span: field_span }; </del> <ins> let id = Spanned { node: ident, span: sp }; </ins> self.expr(sp, ast::ExprKind::Field(expr, id)) } fn expr_tup_field_access(&self, sp: Span, expr: P<ast::Expr>, idx: usize) -> P<ast::Expr> { <del> let field_span = Span { lo: sp.lo - Pos::from_usize(idx.to_string().len()), hi: sp.hi, expn_id: sp.expn_id, }; let id = Spanned { node: idx, span: field_span }; </del> <ins> let id = Spanned { node: idx, span: sp }; </ins> self.expr(sp, ast::ExprKind::TupField(expr, id)) } fn expr_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr> {
Change:
From: src/test/compile- E0518 needs a span_label, updating it from: To:

Discussion:
impl<'a> CheckAttrVisitor<'a> { fn check_inline(&self, attr: &ast::Attribute, target: Target) { if target != Target::Fn { <del> span_err!(self.sess, attr.span, E0518, "attribute should be applied to function"); </del> <ins> struct_span_err!(self.sess, attr.span, E0518, "attribute should be applied to function") .span_label(attr.span, &format!("requires a function")) .emit(); </ins> } }

let mut conflicting_reprs = 0; for word in words { let name = match word.name() { Some(word) => word, None => continue, }; <del> let message = match &*name { </del> <ins> let (message, label) = match &*name { </ins> "C" => { conflicting_reprs += 1; if target != Target::Struct && target != Target::Union && target != Target::Enum { <del> "attribute should be applied to struct, enum or union" </del> <ins> ("attribute should be applied to struct, enum or union", "a struct, enum or union") </ins> } else { continue }

// can be used to modify another repr hint if target != Target::Struct && target != Target::Union { <del> "attribute should be applied to struct or union" </del> <ins> ("attribute should be applied to struct or union", "a struct or union") </ins> } else { continue }

"simd" => { conflicting_reprs += 1; if target != Target::Struct { <del> "attribute should be applied to struct" </del> <ins> ("attribute should be applied to struct", "a struct") </ins> } else { continue }

"isize" | "usize" => { conflicting_reprs += 1; if target != Target::Enum { <del> "attribute should be applied to enum" </del> <ins> ("attribute should be applied to enum", "an enum") </ins> } else { continue } } _ => continue, }; <del> span_err!(self.sess, attr.span, E0517, "{}", message); </del> <ins> struct_span_err!(self.sess, attr.span, E0517, "{}", message) .span_label(attr.span, &format!("requires {}", label)) .emit(); </ins> } if conflicting_reprs > 1 { span_warn!(self.sess, attr.span, E0566,

} } hir::TyTypeof(ref _e) => { <del> span_err!(tcx.sess, ast_ty.span, E0516, "`typeof` is a reserved keyword but unimplemented"); </del> <ins> struct_span_err!(tcx.sess, ast_ty.span, E0516, "`typeof` is a reserved keyword but unimplemented") .span_label(ast_ty.span, &format!("reserved keyword")) .emit(); </ins> tcx.types.err } hir::TyInfer => {

fn main() { let x: typeof(92) = 92; //~ ERROR E0516 <ins> //~| reserved keyword </ins> }

// except according to those terms. #[repr(C)] //~ ERROR E0517 <ins> //~| requires a struct, enum or union </ins> type Foo = u8; #[repr(packed)] //~ ERROR E0517 <ins> //~| requires a struct </ins> enum Foo2 {Bar, Baz} #[repr(u8)] //~ ERROR E0517 <ins> //~| requires an enum </ins> struct Foo3 {bar: bool, baz: bool} #[repr(C)] //~ ERROR E0517 <ins> //~| requires a struct, enum or union </ins> impl Foo3 { }

// except according to those terms. #[inline(always)] //~ ERROR E0518 <ins> //~| requires a function </ins> struct Foo; #[inline(never)] //~ ERROR E0518 <ins> //~| requires a function </ins> impl Foo { }
Change:
From: src/test/compile- E0527 needs a span_label, updating it from: To:

Discussion:
let min_len = before.len() + after.len(); if slice.is_none() { if min_len != size { <del> span_err!(tcx.sess, pat.span, E0527, "pattern requires {} elements but array has {}", min_len, size); </del> <ins> struct_span_err!( tcx.sess, pat.span, E0527, "pattern requires {} elements but array has {}", min_len, size) .span_label(pat.span, &format!("expected {} elements",size)) .emit(); </ins> } (inner_ty, tcx.types.err) } else if let Some(rest) = size.checked_sub(min_len) {

fn main() { let r = &[1, 2, 3, 4]; match r { <del> &[a, b] => { //~ ERROR E0527 </del> <ins> &[a, b] => { //~^ ERROR E0527 //~| NOTE expected 4 elements </ins> println!("a={}, b={}", a, b); } }
Change:
The following code makes panic: Before panicking, gives a warning: : Backtrace:
This works fine on 1.7.0 and ice's on any later stable releases as well as current beta / nightly.
A regression from stable to stable! A use for the tag! "Fortunately", this appears to be bug in the type-checking pass run on the MIR. It's probably not handling the associated type properly for this case. I'm surprised this hasn't come up sooner to be honest.

Discussion:
hir::DefaultReturn(..) => self.tcx().mk_nil(), }; <ins> let input_tys = self_ty.into_iter().chain(arg_tys).collect(); debug!("ty_of_method_or_bare_fn: input_tys={:?}", input_tys); debug!("ty_of_method_or_bare_fn: output_ty={:?}", output_ty); </ins> (self.tcx().mk_bare_fn(ty::BareFnTy { unsafety: unsafety, abi: abi, sig: ty::Binder(ty::FnSig { <del> inputs: self_ty.into_iter().chain(arg_tys).collect(), </del> <ins> inputs: input_tys, </ins> output: output_ty, variadic: decl.variadic }),

let fn_sig = self.tcx.liberate_late_bound_regions( self.tcx.region_maps.call_site_extent(expr.id, body.id), &fn_ty.sig); <ins> let fn_sig = (**self).normalize_associated_types_in(body.span, body.id, &fn_sig); </ins> check_fn(self, hir::Unsafety::Normal, expr.id, &fn_sig, decl, expr.id, &body);

<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. // Previously the closure's argument would be inferred to // <S as ITrait<'a>>::Item, causing an error in MIR type // checking trait ITrait<'a> {type Item;} struct S {} impl<'a> ITrait<'a> for S { type Item = &'a mut usize; } fn m<T, I, F>(_: F) where I: for<'a> ITrait<'a>, F: for<'a> FnMut(<I as ITrait<'a>>::Item) { } fn main() { m::<usize,S,_>(|x| { *x += 1; }); } </ins>
Change:
From . This means we do not blanket turn on LLVM assertions on all of our bots, which we would ideally like to do. I'm going to try turning them off for just the cross bot though.
cc cc
Seems related to somewhat. We do not use the maxnum intrinsic (totally should!) but from the existence of bug for maxnum seems to suggest that a similar issue for some non-maxnum intrinsic is likely to exist (and libcore is kinda intrinsic-heavy).

Discussion:
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS <del> # FIXME(#36150) this will fail the bootstrap. Probably means something bad is #               happening! ENV NO_LLVM_ASSERTIONS 1 </del>