jiebi/CodeConvo huggingface dataset:
Change:
/u/DroidLogician on reddit that the syntax is undocumeted, at least in the crates and module chapter of TRPL. this seems like your territory :)
Also the syntax.
As mentioned later in that reddit thread, is now without quotes. hasn't worked since the addition of turning into in crate names.
I think this can be closed.

Discussion:
mentioned earlier, you can use double colons to refer to sub-modules and the functions inside of them. <ins> (Note: when importing a crate that has dashes in its name "like-this", which is not a valid Rust identifier, it will be converted by changing the dashes to underscores, so you would write `extern crate like_this;`.) </ins> Also, Cargo assumes that `src/main.rs` is the crate root of a binary crate, rather than a library crate. Our package now has two crates: `src/lib.rs` and `src/main.rs`. This pattern is quite common for executable crates: most

Hello in Japanese: こんにちは Goodbye in Japanese: さようなら ``` <ins> ## Complex imports Rust offers several advanced options that can add compactness and convenience to your `extern crate` and `use` statements. Here is an example: ```rust,ignore extern crate phrases as sayings; use sayings::japanese::greetings as ja_greetings; use sayings::japanese::farewells::*; use sayings::english::{self, greetings as en_greetings, farewells as en_farewells}; fn main() { println!("Hello in English; {}", en_greetings::hello()); println!("And in Japanese: {}", ja_greetings::hello()); println!("Goodbye in English: {}", english::farewells::goodbye()); println!("Again: {}", en_farewells::goodbye()); println!("And in Japanese: {}", goodbye()); } ``` What's going on here? First, both `extern crate` and `use` allow renaming the thing that is being imported. So the crate is still called "phrases", but here we will refer to it as "sayings". Similarly, the first `use` statement pulls in the `japanese::farewells` module from the crate, but makes it available as `jp_farewells` as opposed to simply `farewells`. This can help to avoid ambiguity when importing similarly-named items from different places. The second `use` statement uses a star glob to bring in _all_ symbols from the `sayings::japanese::farewells` module. As you can see we can later refer to the Japanese `goodbye` function with no module qualifiers. This kind of glob should be used sparingly. The third `use` statement bears more explanation. It's using "brace expansion" globbing to compress three `use` statements into one (this sort of syntax may be familiar if you've written Linux shell scripts before). The uncompressed form of this statement would be: ```rust,ignore use sayings::english; use sayings::english::greetings as en_greetings; use sayings::english::farewells as en_farewells; ``` As you can see, the curly brackets compress `use` statements for several items under the same path, and in this context `self` just refers back to that path. Note: The curly brackets cannot be nested or mixed with star globbing. </ins>
Change:
On my computer, this takes about 0.011s to run. If you comment out the line to create the BufReader, the code still compiles... but it takes roughly 0m0.209s to run. It seems like Rust should try to prevent people from shooting themselves in the foot, although I'm not exactly sure what could be done short of deprecating it.
Do you think it's a trap even with the BufReader? It's surprisingly good.
The performance with BufReader seems fine... the problem is really the performance without BufReader. Actually, hmm... maybe the implementation of bytes() for File should build a BufReader? That seems a little awkward, but I guess it's potentially workable.
I can see where several impls could be performance traps with this method. Since essentially reads one byte for each call to , it can interact poorly with any impl that isn't tolerant of small, extremely frequent reads--basically exactly what is meant to help with. The easiest fix would be to document this on the method to let users know they should use a buffer for some cases. But without any way to warn them directly, a lot of users could still be bitten in the butt by this. can inherently use , and then can override to return itself in instead of constructing a new . But this will be unnecessary for other impls that don't need buffering, like . Another solution could be to let be dynamically buffered or raw: Then the impl can return by default, or be overridden to return . The drawback here is that the enum would have to be matched on with each call to , which would be a bit of a performance hit, though likely not nearly as bad as the performance problem it fixes, and should be ironed out by branch prediction after a few iterations.
BytesInner sounds good, but I'm not sure if we can actually do it. The problem is that it's a hidden buffer that the user can't recover -- think of the case , after iterating only a few bytes, then stopping, the rest of the buffered data is unreachable. It's not just about , it's about non-buffered I/O in general. We need to make it clear to users that files and network streams opened are unbuffered by default. Stdin is buffered. But you have less overhead if you it for multiple operations or for access access to the buffer methods.
The best solution with the least commitment is to educate the user better about buffers and when to use them.
Filing as a doc bug. We talk about this in BufReader, but not Read. Seems bad.

Discussion:
/// throughout `std::io` take and provide types which implement the `Read` /// trait. /// <ins> /// Please note that each call to `read` may involve a system call, and /// therefore, using something that implements [`BufRead`][bufread], such as /// [`BufReader`][bufreader], will be more efficient. /// /// [bufread]: trait.BufRead.html /// [bufreader]: struct.BufReader.html /// </ins> /// # Examples /// /// [`File`][file]s implement `Read`:
Change:
It's not clear from the documentation how to use external crates in doc tests. This should be documented in the testing section of the book. This is related to rust-lang/cargo.
Now I see that this is actually described in the documentation chapter . However, I was looking at the testing chapter . So the bug report should now be changed to "cross-referece the doctest part of the documentation chapter from the doctest part of the testing chapter" since I completely missed the relevant section despite looking for it rather extensively.

Discussion:
for the function test. These will auto increment with names like `add_two_1` as you add more examples. <ins> We haven’t covered all of the details with writing documentation tests. For more, please see the [Documentation chapter](documentation.html) </ins>
Change:
It seems that is not only a case for duplicate error messages as shown by Which print the error 3 times. It is the same as the other case about map originally spot at I think implementing so that you can collect only the different items could be a good way to start solving this in the board way (all across scala error reporting).
Minimal examples: Interestingly enough, when put in the same program, the total number of errors is 4, not 5 (due to some global cache?). cc

Discussion:
use middle::infer::InferCtxt; use middle::ty::{self, ToPredicate, HasTypeFlags, ToPolyTraitRef, TraitRef, Ty}; use middle::ty::fold::TypeFoldable; <del> use std::collections::HashMap; </del> <ins> use util::nodemap::{FnvHashMap, FnvHashSet}; </ins> use std::fmt; use syntax::codemap::Span; use syntax::attr::{AttributeMethods, AttrMetaMethods};

(gen.name.as_str().to_string(), trait_ref.substs.types.get(param, i) .to_string()) <del> }).collect::<HashMap<String, String>>(); </del> <ins> }).collect::<FnvHashMap<String, String>>(); </ins> generic_map.insert("Self".to_string(), trait_ref.self_ty().to_string()); let parser = Parser::new(&istring);

"the trait `{}` cannot be made into an object", tcx.item_path_str(trait_def_id)); <ins> let mut reported_violations = FnvHashSet(); </ins> for violation in violations { <ins> if !reported_violations.insert(violation.clone()) { continue; } </ins> match violation { ObjectSafetyViolation::SizedSelf => { tcx.sess.fileline_note(

use std::rc::Rc; use syntax::ast; <del> #[derive(Debug)] </del> <ins> #[derive(Clone, Debug, PartialEq, Eq, Hash)] </ins> pub enum ObjectSafetyViolation<'tcx> { /// Self : Sized declared on the trait SizedSelf,

} } <ins> impl<'tcx> PartialEq for Method<'tcx> { #[inline] fn eq(&self, other: &Self) -> bool { self.def_id == other.def_id } } impl<'tcx> Eq for Method<'tcx> {} impl<'tcx> Hash for Method<'tcx> { #[inline] fn hash<H: Hasher>(&self, s: &mut H) { self.def_id.hash(s) } } </ins> #[derive(Clone, Copy, Debug)] pub struct AssociatedConst<'tcx> { pub name: Name,

<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. trait Array: Sized {} fn f<T: Array>(x: &T) { let _ = x //~^ ERROR `Array` cannot be made into an object //~| NOTE the trait cannot require that `Self : Sized` as &Array; //~^ ERROR `Array` cannot be made into an object //~| NOTE the trait cannot require that `Self : Sized` } fn main() {} </ins>
Change:
I tried this code: I expected it to compile cleanly or give me a helpful error. Instead, it gave me a helpful error and then an ICE: Version: stack backtrace:

Discussion:
check_expr_with_hint(fcx, e, declty); demand::coerce(fcx, e.span, declty, e); <del> fcx.select_all_obligations_or_error(); </del> <ins> fcx.select_all_obligations_and_apply_defaults(); upvar::closure_analyze_const(&fcx, e); fcx.select_obligations_where_possible(); </ins> fcx.check_casts(); <ins> fcx.select_all_obligations_or_error(); </ins> regionck::regionck_expr(fcx, e); writeback::resolve_type_vars_in_expr(fcx, e); }

assert!(fcx.inh.deferred_call_resolutions.borrow().is_empty()); } <ins> pub fn closure_analyze_const(fcx: &FnCtxt, body: &hir::Expr) { let mut seed = SeedBorrowKind::new(fcx); seed.visit_expr(body); let closures_with_inferred_kinds = seed.closures_with_inferred_kinds; let mut adjust = AdjustBorrowKind::new(fcx, &closures_with_inferred_kinds); adjust.visit_expr(body); // it's our job to process these. assert!(fcx.inh.deferred_call_resolutions.borrow().is_empty()); } </ins> /////////////////////////////////////////////////////////////////////////// // SEED BORROW KIND

<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. // check that borrowck looks inside consts/statics static FN : &'static (Fn() -> (Box<Fn()->Box<i32>>) + Sync) = &|| { let x = Box::new(0); Box::new(|| x) //~ ERROR cannot move out of captured outer variable }; fn main() { let f = (FN)(); f(); f(); } </ins>

<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. const X: u8 = || -> u8 { 5 }() //~ ERROR function calls in constants are limited ; fn main() {} </ins>

<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. static PLUS_ONE: &'static (Fn(i32) -> i32 + Sync) = (&|x: i32| { x + 1 }) as &'static (Fn(i32) -> i32 + Sync); fn main() { assert_eq!(PLUS_ONE(2), 3); } </ins>
Change:
I tried this code: I expected to see this happen: Either a compilation error, or to be equivalent to const X: u8 = 5. Instead, this happened: Internal compiler error : Backtrace:

Discussion:
check_expr_with_hint(fcx, e, declty); demand::coerce(fcx, e.span, declty, e); <del> fcx.select_all_obligations_or_error(); </del> <ins> fcx.select_all_obligations_and_apply_defaults(); upvar::closure_analyze_const(&fcx, e); fcx.select_obligations_where_possible(); </ins> fcx.check_casts(); <ins> fcx.select_all_obligations_or_error(); </ins> regionck::regionck_expr(fcx, e); writeback::resolve_type_vars_in_expr(fcx, e); }

assert!(fcx.inh.deferred_call_resolutions.borrow().is_empty()); } <ins> pub fn closure_analyze_const(fcx: &FnCtxt, body: &hir::Expr) { let mut seed = SeedBorrowKind::new(fcx); seed.visit_expr(body); let closures_with_inferred_kinds = seed.closures_with_inferred_kinds; let mut adjust = AdjustBorrowKind::new(fcx, &closures_with_inferred_kinds); adjust.visit_expr(body); // it's our job to process these. assert!(fcx.inh.deferred_call_resolutions.borrow().is_empty()); } </ins> /////////////////////////////////////////////////////////////////////////// // SEED BORROW KIND

<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. // check that borrowck looks inside consts/statics static FN : &'static (Fn() -> (Box<Fn()->Box<i32>>) + Sync) = &|| { let x = Box::new(0); Box::new(|| x) //~ ERROR cannot move out of captured outer variable }; fn main() { let f = (FN)(); f(); f(); } </ins>

<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. const X: u8 = || -> u8 { 5 }() //~ ERROR function calls in constants are limited ; fn main() {} </ins>

<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. static PLUS_ONE: &'static (Fn(i32) -> i32 + Sync) = (&|x: i32| { x + 1 }) as &'static (Fn(i32) -> i32 + Sync); fn main() { assert_eq!(PLUS_ONE(2), 3); } </ins>
Change:
This appears to now be fixed.
Neat! Just needs a test if there isn't one already.
There's , but I'm not sure if that qualifies as testing this in particular. If not, I can add one.
Marking as E-needstest. I don't think the test I linked previously really fits this case.

Discussion:
<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 trait DictLike<'a> { type ItemsIterator: Iterator<Item=u8>; fn get(c: Self::ItemsIterator) { c.into_iter(); } } trait DictLike2<'a> { type ItemsIterator: Iterator<Item=u8>; fn items(&self) -> Self::ItemsIterator; fn get(&self)  { for _ in self.items() {} } } fn main() {} </ins>

<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: --test #![test] //~ ERROR only functions may be used as tests </ins>

<ins> error: only functions may be used as tests --> $DIR/issue-28134.rs:13:1 | LL | #![test] //~ ERROR only functions may be used as tests | ^^^^^^^^ error: aborting due to previous error </ins>

<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 fn main() { let mut i = [1, 2, 3]; i[i[0]] = 0; i[i[0] - 1] = 0; } </ins>
Change:
If I run the following code : I get the following error : I don't see any reason for the trait Debug not to be implemented for BinaryHeap. If seeing the nodes of it is a problem, at least a could be enough.
Should be fine to display the elements -- probably an oversight?
Probably an oversight. Implementing the solution shouldn't take more than a line (few at most) and it is annoying that you can't easily implement debug for struct owning one BinaryHeap.

Discussion:
use core::iter::{FromIterator}; use core::mem::swap; use core::ptr; <ins> use core::fmt; </ins> use slice; use vec::{self, Vec};

fn default() -> BinaryHeap<T> { BinaryHeap::new() } } <ins> #[stable(feature = "binaryheap_debug", since = "1.4.0")] impl<T: fmt::Debug + Ord> fmt::Debug for BinaryHeap<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list().entries(self.iter()).finish() } } </ins> impl<T: Ord> BinaryHeap<T> { /// Creates an empty `BinaryHeap` as a max-heap. ///
Change:
The documentation for states that "if then and vice versa", but the "vice versa" is somewhat misleading here since doesn't imply if e.g. either of the values is a NaN float. The author probably wanted to say that also implies .

Discussion:
/// /// The comparison must satisfy, for all `a`, `b` and `c`: /// <del> /// - antisymmetry: if `a < b` then `!(a > b)` and vice versa; and </del> <ins> /// - antisymmetry: if `a < b` then `!(a > b)`, as well as `a > b` implying `!(a < b)`; and </ins> /// - transitivity: `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`. /// /// Note that these requirements mean that the trait itself must be implemented symmetrically and
Change:
Backtraces on windows are generated using the function. This will generate incorrect backtraces if any of the frame pointers are omitted due to FPO. This would normally be fine, as debug builds are compiled without FPO enabled. However, even in debug builds, the code will be linked to an optimised build of , so if any frames from libstd are on the top of the stack when the backtrace is generated (which will always be the case for obvious reasons) there's the potential for one or more of those frames to have been optimised out, breaking the backtrace. On , this turns out to always be the case, as triggers FPO. On , it currently works, but I'm unsure if that's just luck, or whether FPO is not used for that target. This was not caught by tests because has been (accidentally?) disabled on all windows targets.
It is due to the Windowx 64-bit calling convention being designed in such a way that FPO can always be done and stack walking always work, unlike 32-bit.

Discussion:
let mut base = super::windows_base::opts(); base.cpu = "pentium4".to_string(); base.max_atomic_width = Some(64); <ins> base.eliminate_frame_pointer = false; // Required for backtraces </ins> // Mark all dynamic libraries and executables as compatible with the larger 4GiB address // space available to x86 Windows binaries on x86_64.

target_os = "ios", target_os = "android", all(target_os = "linux", target_arch = "arm"), <del> all(target_os = "windows", target_pointer_width = "32"), </del> target_os = "freebsd", target_os = "dragonfly", target_os = "bitrig",

} fn main() { <del> if cfg!(windows) && cfg!(target_env = "gnu") && cfg!(target_pointer_width = "32") { return } </del> let args: Vec<String> = env::args().collect(); if args.len() >= 2 && args[1] == "fail" { foo();
Change:
Pages like Wikipedia/Wikidata need to prove that a given information is correct. The announcement blog posts seem to be the only obvious place to look up the the exact release dates. Blog post URLs are not necessarily stable over time. It would be simpler to just refer to
They already contain the month and the year, is the day that important? (that said, I don't see the harm, I was just like "I thought we did this already")
That probably depends on the context. Most software on Wikidata has the complete date defined along the versions. Does it hurt? If the days where given, what could be reasons to remove them? I would add the days in a PR myself, just wanted to make sure there is no opposition. I suggest we use ISO-format. The dates are currently defined in Wikdata as

Discussion:
<del> Version 1.2.0 (August 2015) </del> <ins> Version 1.2.0 (2015-08-07) </ins> =========================== * ~1200 changes, numerous bugfixes

[ad]: https://github.com/rust-lang/rust/pull/27382 [win]: https://github.com/rust-lang/rust/pull/25350 <del> Version 1.1.0 (June 2015) </del> <ins> Version 1.1.0 (2015-06-25) </ins> ========================= * ~850 changes, numerous bugfixes

[`split_off`]: https://doc.rust-lang.org/nightly/collections/linked_list/struct.LinkedList.html#method.split_off [drop]: https://github.com/rust-lang/rust/pull/24935 <del> Version 1.0.0 (May 2015) </del> <ins> Version 1.0.0 (2015-05-15) </ins> ======================== * ~1500 changes, numerous bugfixes