jiebi/CodeConvo huggingface dataset:
Change:
Windows 8.1 64-bit / MSYS2 / MinGW-w64 cc
Interesting! This is testing the property that the duration between two instants plus the first is the same as the second. Unfortunately this isn't true on Windows due to the +/- one problem on multiple cores. Have to think about what's the best course of action here.
This still fails, btw

Discussion:
mod tests { use super::{Instant, SystemTime, Duration, UNIX_EPOCH}; <ins> macro_rules! assert_almost_eq { ($a:expr, $b:expr) => ({ let (a, b) = ($a, $b); if a != b { let (a, b) = if a > b {(a, b)} else {(b, a)}; assert!(a - Duration::new(0, 1) <= b); } }) } </ins> #[test] fn instant_monotonic() { let a = Instant::now();

let a = Instant::now(); let b = Instant::now(); let dur = b.duration_from_earlier(a); <del> assert_eq!(b - dur, a); assert_eq!(a + dur, b); </del> <ins> assert_almost_eq!(b - dur, a); assert_almost_eq!(a + dur, b); </ins> let second = Duration::new(1, 0); <del> assert_eq!(a - second + second, a); </del> <ins> assert_almost_eq!(a - second + second, a); </ins> } #[test]

let b = SystemTime::now(); match b.duration_from_earlier(a) { Ok(dur) if dur == Duration::new(0, 0) => { <del> assert_eq!(a, b); </del> <ins> assert_almost_eq!(a, b); </ins> } Ok(dur) => { assert!(b > a); <del> assert_eq!(b - dur, a); assert_eq!(a + dur, b); </del> <ins> assert_almost_eq!(b - dur, a); assert_almost_eq!(a + dur, b); </ins> } Err(dur) => { let dur = dur.duration(); assert!(a > b); <del> assert_eq!(b + dur, a); assert_eq!(b - dur, a); </del> <ins> assert_almost_eq!(b + dur, a); assert_almost_eq!(b - dur, a); </ins> } } let second = Duration::new(1, 0); <del> assert_eq!(a.duration_from_earlier(a - second).unwrap(), second); assert_eq!(a.duration_from_earlier(a + second).unwrap_err().duration(), second); </del> <ins> assert_almost_eq!(a.duration_from_earlier(a - second).unwrap(), second); assert_almost_eq!(a.duration_from_earlier(a + second).unwrap_err() .duration(), second); </ins> <del> assert_eq!(a - second + second, a); </del> <ins> assert_almost_eq!(a - second + second, a); </ins> let eighty_years = second * 60 * 60 * 24 * 365 * 80; <del> assert_eq!(a - eighty_years + eighty_years, a); assert_eq!(a - (eighty_years * 10) + (eighty_years * 10), a); </del> <ins> assert_almost_eq!(a - eighty_years + eighty_years, a); assert_almost_eq!(a - (eighty_years * 10) + (eighty_years * 10), a); </ins> } #[test]
Change:
Windows 8.1 64-bit / MSYS2 / MinGW-w64 cc
Interesting! This is testing the property that the duration between two instants plus the first is the same as the second. Unfortunately this isn't true on Windows due to the +/- one problem on multiple cores. Have to think about what's the best course of action here.
This still fails, btw

Discussion:
let (a, b) = ($a, $b); if a != b { let (a, b) = if a > b {(a, b)} else {(b, a)}; <del> assert!(a - Duration::new(0, 1) <= b); </del> <ins> assert!(a - Duration::new(0, 100) <= b); </ins> } }) }
Change:
Hello. The following code gives an error message that could be improved: It gives the following error: This is because the compiler sees the right operand as a block expression, and is looking for the condition body, something like: while we most probably mean to write something like: So, it would be nice to improve this error message.
This… would be pretty non-trivial to improve. What really bugs me is being pretty useless, which for I’m going to fill another issue.
As of today, I still get the same issue:
FWIW, the originally reported output was:

Discussion:
let block = self.parse_block().map_err(|mut err| { if not_block { err.span_label(lo, "this `if` expression has a condition, but no block"); <ins> if let ExprKind::Binary(_, _, ref right) = cond.kind { if let ExprKind::Block(_, _) = right.kind { err.help("maybe you forgot the right operand of the condition?"); } } </ins> } err })?;

... LL | } | ^ expected `{` <ins> | = help: maybe you forgot the right operand of the condition? </ins> error: aborting due to previous error
Change:
There's an implementation of that allows the conversion of a to a , but it doesn't quite work when just using . The (perhaps subtle) error message is due to the compiler attempting to use the general implementation for . I was trying to return string errors from a function returning and ended up writing the following: This works well, but is really just boilerplate and not obviously suited to inclusion in any crate or library. Other solutions I thought of include: Adding to the standard library for cases like this. Altering the semantics for trait-resolution on types that parametrise over multiple traits. From what I've read, we don't yet have semantics for general additions of traits, only built-in ones. See .
This is somewhat intentional on the side of being conservative, but it seems pretty harmless to add.

Discussion:
} } <ins> #[stable(feature = "string_box_error", since = "1.7.0")] impl From<String> for Box<Error> { fn from(str_err: String) -> Box<Error> { let err1: Box<Error + Send + Sync> = From::from(str_err); let err2: Box<Error> = err1; err2 } } </ins> #[stable(feature = "rust1", since = "1.0.0")] impl<'a, 'b> From<&'b str> for Box<Error + Send + Sync + 'a> { fn from(err: &'b str) -> Box<Error + Send + Sync + 'a> {

} } <ins> #[stable(feature = "string_box_error", since = "1.7.0")] impl<'a> From<&'a str> for Box<Error> { fn from(err: &'a str) -> Box<Error> { From::from(String::from(err)) } } </ins> #[stable(feature = "rust1", since = "1.0.0")] impl Error for str::ParseBoolError { fn description(&self) -> &str { "failed to parse bool" }

<ins> // Copyright 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. // Ensure that both `Box<Error + Send + Sync>` and `Box<Error>` can be obtained from `String`. use std::error::Error; fn main() { let _err1: Box<Error + Send + Sync> = From::from("test".to_string()); let _err2: Box<Error> = From::from("test".to_string()); let _err3: Box<Error + Send + Sync + 'static> = From::from("test"); let _err4: Box<Error> = From::from("test"); } </ins>
Change:
The [src] link on these pages is broken: The links are also broken in the stable docs version of these pages.
I think this should be fixed by . The links wrongly point to instead of because the crate is linked in std like
I've built the docs locally and the issue somehow persists.

Discussion:
(tcx.lang_items.sync_trait().unwrap(), external_path(cx, "Sync", None, vec![], &empty)), }; <del> let fqn = tcx.sess.cstore.item_path(did); let fqn = fqn.into_iter().map(|i| i.to_string()).collect(); cx.external_paths.borrow_mut().as_mut().unwrap().insert(did, (fqn, TypeTrait)); </del> <ins> inline::record_extern_fqn(cx, did, TypeTrait); </ins> TraitBound(PolyTrait { trait_: ResolvedPath { path: path,

Some(tcx) => tcx, None => return RegionBound(Lifetime::statik()) }; <del> let fqn = tcx.sess.cstore.item_path(self.def_id); let fqn = fqn.into_iter().map(|i| i.to_string()) .collect::<Vec<String>>(); let path = external_path(cx, fqn.last().unwrap(), </del> <ins> inline::record_extern_fqn(cx, self.def_id, TypeTrait); let path = external_path(cx, &tcx.item_name(self.def_id).as_str(), </ins> Some(self.def_id), vec![], self.substs); <del> cx.external_paths.borrow_mut().as_mut().unwrap().insert(self.def_id, (fqn, TypeTrait)); </del> debug!("ty::TraitRefn  substs.types(TypeSpace): {:?}n", self.substs.types.get_slice(ParamSpace::TypeSpace));

ty::TyStruct(def, substs) | ty::TyEnum(def, substs) => { let did = def.did; <del> let fqn = cx.tcx().sess.cstore.item_path(did); let fqn: Vec<_> = fqn.into_iter().map(|i| i.to_string()).collect(); </del> let kind = match self.sty { ty::TyStruct(..) => TypeStruct, _ => TypeEnum, }; <del> let path = external_path(cx, &fqn.last().unwrap().to_string(), </del> <ins> inline::record_extern_fqn(cx, did, kind); let path = external_path(cx, &cx.tcx().item_name(did).as_str(), </ins> None, vec![], substs); <del> cx.external_paths.borrow_mut().as_mut().unwrap().insert(did, (fqn, kind)); </del> ResolvedPath { path: path, typarams: None,

} ty::TyTrait(box ty::TraitTy { ref principal, ref bounds }) => { let did = principal.def_id(); <del> let fqn = cx.tcx().sess.cstore.item_path(did); let fqn: Vec<_> = fqn.into_iter().map(|i| i.to_string()).collect(); </del> <ins> inline::record_extern_fqn(cx, did, TypeTrait); </ins> let (typarams, bindings) = bounds.clean(cx); <del> let path = external_path(cx, &fqn.last().unwrap().to_string(), </del> <ins> let path = external_path(cx, &cx.tcx().item_name(did).as_str(), </ins> Some(did), bindings, principal.substs()); <del> cx.external_paths.borrow_mut().as_mut().unwrap().insert(did, (fqn, TypeTrait)); </del> ResolvedPath { path: path, typarams: Some(typarams),

Some(did) => did, None => return fallback(box t.clean(cx)), }; <del> let fqn = cx.tcx().sess.cstore.item_path(did); let fqn: Vec<String> = fqn.into_iter().map(|i| { i.to_string() }).collect(); cx.external_paths.borrow_mut().as_mut().unwrap().insert(did, (fqn, TypeStruct)); </del> <ins> inline::record_extern_fqn(cx, did, TypeStruct); </ins> ResolvedPath { typarams: None, did: did,
Change:
If i switch branches and regenerate the doc: all the get duplicated ( is not affected it seems). I get new duplicates every time I repeat the process of checking out another branch, checking back and running .

Discussion:
try_err!(write!(&mut f, "{}", *implementor), &mydst); } <del> try_err!(write!(&mut f, r"implementors['{}'] = [", krate.name), &mydst); </del> <ins> try_err!(write!(&mut f, r#"implementors["{}"] = ["#, krate.name), &mydst); </ins> for imp in imps { // If the trait and implementation are in the same crate, then // there's no need to emit information about it (there's inlining
Change:
You can't create pure closures right now. This is sometimes helpful in writing functions that operate on const data. I think this will just be a matter of adjusting typeck to determine purity from the expected type.

Discussion:
// the merge has confused the heck out of josh in the past. // We pass `--no-verify` to avoid running git hooks like `./miri fmt` that could in turn // trigger auto-actions. <del> sh.write_file("rust-version", &commit)?; </del> <ins> sh.write_file("rust-version", format!("{commit}n"))?; </ins> const PREPARING_COMMIT_MESSAGE: &str = "Preparing for merge from rustc"; cmd!(sh, "git commit rust-version --no-verify -m {PREPARING_COMMIT_MESSAGE}") .run()

// interleaving, but wether UB happens can depend on whether a write occurs in the // future... let is_write = new_perm.initial_state.is_active() <del> || (new_perm.initial_state.is_resrved() && new_perm.protector.is_some()); </del> <ins> || (new_perm.initial_state.is_reserved() && new_perm.protector.is_some()); </ins> if is_write { // Need to get mutable access to alloc_extra. // (Cannot always do this as we can do read-only reborrowing on read-only allocations.)

matches!(self.inner, Active) } <del> pub fn is_resrved(self) -> bool { </del> <ins> pub fn is_reserved(self) -> bool { </ins> matches!(self.inner, Reserved { .. }) }

/// in an existing allocation, then returns Err containing the position /// where such allocation should be inserted fn find_offset(&self, offset: Size) -> Result<Position, Position> { <del> // We do a binary search. let mut left = 0usize; // inclusive let mut right = self.v.len(); // exclusive loop { if left == right { // No element contains the given offset. But the // position is where such element should be placed at. return Err(left); } let candidate = left.checked_add(right).unwrap() / 2; let elem = &self.v[candidate]; </del> <ins> self.v.binary_search_by(|elem| -> std::cmp::Ordering { </ins> if offset < elem.range.start { // We are too far right (offset is further left). <del> debug_assert!(candidate < right); // we are making progress right = candidate; </del> <ins> std::cmp::Ordering::Greater </ins> } else if offset >= elem.range.end() { // We are too far left (offset is further right). <del> debug_assert!(candidate >= left); // we are making progress left = candidate + 1; </del> <ins> std::cmp::Ordering::Less </ins> } else { // This is it! <del> return Ok(candidate); </del> <ins> std::cmp::Ordering::Equal </ins> } <del> } </del> <ins> }) </ins> } /// Determines whether a given access on `range` overlaps with
Change:
I noticed that has this code: I'm pretty sure that should be ("file control"), not : the call is consistent with the use of on other UNIXes, and as far as I can tell, the newlib git repo defines but not . This would need to be fixed in both libstd and liblibc. But there's an explicit mention of this code in the PR introducing it (), and I'm sort of surprised that this would link if it were misspelled, let alone work, so maybe I'm missing something? If this is correct, a comment would be nice. :) cc
You're right, oops (PNaCl isn't testable yet within Rust proper, so I didn't catch it!).

Discussion:
#[cfg(target_env = "newlib")] pub fn set_cloexec(&self) { unsafe { <del> let previous = libc::fnctl(self.fd, libc::F_GETFD); let ret = libc::fnctl(self.fd, libc::F_SETFD, previous | libc::FD_CLOEXEC); </del> <ins> let previous = libc::fcntl(self.fd, libc::F_GETFD); let ret = libc::fcntl(self.fd, libc::F_SETFD, previous | libc::FD_CLOEXEC); </ins> debug_assert_eq!(ret, 0); } }
Change:
E0063 doesn't specify which constructor the field is missing from, leading the user to guess in case of nested constructors. The printed output also fails to highlight the relevant constructor. On :

Discussion:
!remaining_fields.is_empty() { span_err!(tcx.sess, span, E0063, <del> "missing field{}: {}", </del> <ins> "missing field{} {} in initializer of `{}`", </ins> if remaining_fields.len() == 1 {""} else {"s"}, remaining_fields.keys() .map(|n| format!("`{}`", n)) .collect::<Vec<_>>() <del> .join(", ")); </del> <ins> .join(", "), adt_ty); </ins> } }

} fn main() { <del> let foo = BuildData { //~ ERROR missing field: `bar` </del> <ins> let foo = BuildData { //~ ERROR missing field `bar` in initializer of `BuildData` </ins> foo: 0 }; }
Change:
This piece of code fails compilation (): This is because the compiler expects inner comments only before the first item (something like ). It doesn't point this out however, instead, it gives the rather cryptic error message: It should say something like "Please place the inner comment to the top". From reading the code, an error message like would be sufficient. Can that be achieved by changing the if near line 38: to something like ? I haven't tested because I haven't set up a development setup of rustc (and don't know whether there is a better way to do it).
It was suggested on irc to cc about this because its a bad error.

Discussion:
self.span.hi ); if attr.node.style != ast::AttrStyle::Outer { <del> return Err(self.fatal("expected outer comment")); </del> <ins> let mut err = self.fatal("expected outer doc comment"); err.note("inner doc comments like this (starting with  `//!` or `/*!`) can only appear before items"); return Err(err); </ins> } attrs.push(attr); self.bump();

<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. // compile-flags: -Z parse-only fn foo() { } //! Misplaced comment... //~^ ERROR expected outer doc comment //~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items fn main() { } </ins>
Change:
has strange error text: this in , but I'm guessing it was placeholder text that got overlooked during review.
I'm happy to fix this, but not quite clear what it should say ^_^. Not sure if explaining or fixing it would be easier...
We should just remove that line. That's debugging code which should go away. Sorry about that :smiley_cat:
(fixed in )

Discussion:
} }, TypeError::Traits(ref exp_found) => { <del> self.tcx.sess.note("errrr0"); </del> report_path_match(exp_found.expected, exp_found.found); }, _ => () // FIXME(#22750) handle traits and stuff
Change:
There are times it's nice to be able to include a link in the description of a given item. At present, however, if you try to include a reference link, it fails. Rust: HTML for the item description: However, if you change the first line of the Rust to be an inline reference, the problem goes away. Rust: Generated HTML: It appears (I haven't had a chance to check the implementation yet) that rustdoc is only parsing the first Markdown block element, rather than only keeping the first block element. This probably slightly improves performance, but it produces unexpected results.

Discussion:
#[inline] fn plain_summary_line(s: Option<&str>) -> String { <del> let line = shorter(s).replace("n", " "); markdown::plain_summary_line(&line[..]) </del> <ins> let md = markdown::plain_summary_line(s.unwrap_or("")); shorter(Some(&md)).replace("n", " ") </ins> } fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result {

} else { String::new() }; <ins> let doc_value = myitem.doc_value().unwrap_or(""); </ins> try!(write!(w, " <tr class='{stab} module-item'> <td><a class='{class}' href='{href}'

", name = *myitem.name.as_ref().unwrap(), stab_docs = stab_docs, <del> docs = Markdown(&shorter(myitem.doc_value())), </del> <ins> docs = shorter(Some(&Markdown(doc_value).to_string())), </ins> class = shortty(myitem), stab = myitem.stability_class(), href = item_path(myitem),

<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. // @has issue_30366/index.html '//a/@href' 'http://www.rust-lang.org/' /// Describe it. [Link somewhere][1]. /// /// [1]: http://www.rust-lang.org/ pub fn here_is_a_fn() { } </ins>
Change:
Code: Warning: It probably has something to do with for loop desugaring.
I think this should be marked "E-Easy" Relevant code is in . Prefixing the variable name with an should probably be enough to fix this (and a testcase in )
E-easy‽ I'd like to try this one.

Discussion:
hir::MatchSource::ForLoopDesugar, None); <del> // `{ let result = ...; result }` let result_ident = lctx.str_to_ident("result"); </del> <ins> // `{ let _result = ...; _result }` // underscore prevents an unused_variables lint if the head diverges let result_ident = lctx.str_to_ident("_result"); </ins> let let_stmt = stmt_let(lctx, e.span, false, result_ident, match_expr, None); let result = expr_ident(lctx, e.span, result_ident, None); let block = block_all(lctx, e.span, vec![let_stmt], Some(result));

<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. #![deny(unused_variables)] fn main() { for _ in match return () { () => Some(0), } {} } </ins>
Change:
will fail to compile with an LLVM abort: Seems to be a mis-translation of indexing (trans/mir/lvalue at ).
This is not related to According to we might do something incorrectly with GEPs.
That was my first guess, but it seems that is an rvalue with the type , suggesting itself was loaded.
Oh, my first guess was right: all GEPs are but that's not enough. You see, GEP's first index is for the pointer itself. currently gets (mistakenly) translated as instead of the (correct) . All GEP calls should use as the first index and then the index of the array element/struct field.

Discussion:
mir::ProjectionElem::Index(ref index) => { let index = self.trans_operand(bcx, index); let llindex = self.prepare_index(bcx, index.immediate()); <del> (build::InBoundsGEP(bcx, tr_base.llval, &[llindex]), </del> <ins> let zero = common::C_uint(bcx.ccx(), 0u64); (build::InBoundsGEP(bcx, tr_base.llval, &[zero, llindex]), </ins> ptr::null_mut()) } mir::ProjectionElem::ConstantIndex { offset,

min_length: _ } => { let lloffset = common::C_u32(bcx.ccx(), offset); let llindex = self.prepare_index(bcx, lloffset); <del> (build::InBoundsGEP(bcx, tr_base.llval, &[llindex]), </del> <ins> let zero = common::C_uint(bcx.ccx(), 0u64); (build::InBoundsGEP(bcx, tr_base.llval, &[zero, llindex]), </ins> ptr::null_mut()) } mir::ProjectionElem::ConstantIndex { offset,

let lllen = self.lvalue_len(bcx, tr_base); let llindex = build::Sub(bcx, lllen, lloffset, DebugLoc::None); let llindex = self.prepare_index(bcx, llindex); <del> (build::InBoundsGEP(bcx, tr_base.llval, &[llindex]), </del> <ins> let zero = common::C_uint(bcx.ccx(), 0u64); (build::InBoundsGEP(bcx, tr_base.llval, &[zero, llindex]), </ins> ptr::null_mut()) } mir::ProjectionElem::Downcast(..) => {
Change:
If I take the following line from the Rust book and make a function out of it Meaning something like Then the compiler fails with However if I add the return statement, which should be optional. It works Shouldn't this be considered an expression by the compiler?
The crucial thing here is the semicolon after your statement. A block consists of a bunch of statements, terminated with semicolons, possibly followed by an expression, which is not terminated by a semicolon. Therefore, putting the semicolon after made the compiler view the expression as a statement, with no terminating expression on the block. If you leave off the semicolon, it should work: Note the lack of a semicolon. I hope that helps! This bug might still be useful as a documentation bug - the long explaination for does not mention this pitfall, while it seems like a common case that should be addressed.
There's usually a suggestion printed telling you to remove the trailing semicolon. It only works when the type of the last statement-expression is the same as the function return type, which isn't known in this case since the return type of is inferred. cc , which attempted to fix this
I see, still getting the hang of when semicolons are required. But maybe a clearer error message is required.
I updated the title to make it accurately reflect the issue. The compiler never considers the line to be unreachable either way, it just says that not all control paths return a value. Which is true, none of the 1 control paths return a value.

Discussion:
``` It is advisable to find out what the unhandled cases are and check for them, <del> returning an appropriate value or panicking if necessary. </del> <ins> returning an appropriate value or panicking if necessary. Check if you need to remove a semicolon from the last expression, like in this case: ```ignore fn foo(x: u8) -> u8 { inner(2*x + 1); } ``` The semicolon discards the return value of `inner`, instead of returning it from `foo`. </ins> "##, E0270: r##"