jiebi/CodeConvo huggingface dataset:
Change:
has saying that the column info is provided in characters, not in bytes. However, the error emitter doesn't care about that at all and uses these like byte offsets all over the place. This leads to bugs like and . As an example, look how span printing varies with varying characters used: Correct case: Now add an emoji character: Note how its off by one char now. This can stack up: If I didn't use any spaces at all, I'd run into . Now this can be fixed by going through the emitter code and looking for all places where the pos is used in a byte position fashion. A much more proper fix instead is to stop trusting that people read comments and encode this via the type system. There is already a mechanism for that inside the compiler, its ! Just convert the types of , members of the and structs to , or maybe to if that's preferred.
cc

Discussion:
if line.annotations.len() == 1 { if let Some(ref ann) = line.annotations.get(0) { if let AnnotationType::MultilineStart(depth) = ann.annotation_type { <del> if source_string[0..ann.start_col].trim() == "" { </del> <ins> if source_string.chars() .take(ann.start_col) .all(|c| c.is_whitespace()) { </ins> let style = if ann.is_primary { Style::UnderlinePrimary } else {

<ins> // Copyright 2017 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. #![feature(non_ascii_idents)] pub fn main () {} fn საჭმელად_გემრიელი_სადილი ( ) -> isize { } </ins>

<ins> error[E0308]: mismatched types --> $DIR/issue-44023.rs:15:42 | 15 |   fn საჭმელად_გემრიელი_სადილი ( ) -> isize { |  __________________________________________^ 16 | | } | |_^ expected isize, found () | = note: expected type `isize` found type `()` error: aborting due to previous error </ins>

<ins> // Copyright 2017 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. fn main() { "😊""; } </ins>

<ins> error: unterminated double quote string --> $DIR/issue-44078.rs:12:8 | 12 |       "😊""; |  ________^ 13 | | } | |__^ error: aborting due to previous error </ins>
Change:
RC module documentation should clarify mutable references can be obtained, under certain conditions. Rc module documentation sates: "Shared references in Rust disallow mutation by default, and Rc is no exception: you cannot obtain a mutable reference to something inside an Rc." Rc's getmut method states: "Returns a mutable reference to the inner value, if there are no other Rc or Weak pointers to the same value.".

Discussion:
/// also destroyed. /// /// Shared references in Rust disallow mutation by default, and `Arc` is no <del> /// exception. If you need to mutate through an `Arc`, use [`Mutex`][mutex], /// [`RwLock`][rwlock], or one of the [`Atomic`][atomic] types. </del> <ins> /// exception: you cannot generally obtain a mutable reference to something /// inside an `Arc`. If you need to mutate through an `Arc`, use /// [`Mutex`][mutex], [`RwLock`][rwlock], or one of the [`Atomic`][atomic] /// types. </ins> /// /// ## Thread Safety ///

//! given value is destroyed, the pointed-to value is also destroyed. //! //! Shared references in Rust disallow mutation by default, and [`Rc`] <del> //! is no exception: you cannot obtain a mutable reference to </del> <ins> //! is no exception: you cannot generally obtain a mutable reference to </ins> //! something inside an [`Rc`]. If you need mutability, put a [`Cell`] //! or [`RefCell`] inside the [`Rc`]; see [an example of mutability //! inside an Rc][mutability].
Change:
Implementing traits doesn't seem to work either in declarative macros. looks like it should compile: But it does this instead:
Looks like this has been fixed.

Discussion:
<ins> // Copyright 2017 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. #![feature(decl_macro)] pub macro create_struct($a:ident) { struct $a; impl Clone for $a { fn clone(&self) -> Self { $a } } } fn main() { create_struct!(Test); Test.clone(); } </ins>
Change:
This is what rust-central-station does when making a release, it shouldn't need to build anything other than libstd!
cc

Discussion:
Linkchecker, "src/tools/linkchecker", "linkchecker", Mode::Libstd; CargoTest, "src/tools/cargotest", "cargotest", Mode::Libstd; Compiletest, "src/tools/compiletest", "compiletest", Mode::Libtest; <del> BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::Librustc; </del> <ins> BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::Libstd; </ins> RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::Libstd; RustInstaller, "src/tools/rust-installer", "rust-installer", Mode::Libstd; );
Change:
On linux, , then run: This changes the permissions of to . Is this expected? masks away everything other than the lower 3 triads when it calls out to this code: Then sends these mode bits into into chmod which considers four triads, not three. Possibly useful references: and Should we change Metadata.permissions to preserve that triad, maybe by masking with instead of ?
I guess the solution depends on whether Unix's std::fs::Permissions is supposed to care about 9 bits or 12 (this is not an implementation detail since it's exposed to the programmer via of PermissionsExt). any thoughts on this?
It seems to me like we should extend the mask to the full 12 bits.
Seems reasonable to me to avoid masking where it makes sense!

Discussion:
} #[test] <ins> #[cfg(unix)] fn set_get_unix_permissions() { use os::unix::fs::PermissionsExt; let tmpdir = tmpdir(); let filename = &tmpdir.join("set_get_unix_permissions"); check!(fs::create_dir(filename)); let mask = 0o7777; check!(fs::set_permissions(filename, fs::Permissions::from_mode(0))); let metadata0 = check!(fs::metadata(filename)); assert_eq!(mask & metadata0.permissions().mode(), 0); check!(fs::set_permissions(filename, fs::Permissions::from_mode(0o1777))); let metadata1 = check!(fs::metadata(filename)); assert_eq!(mask & metadata1.permissions().mode(), 0o1777); } #[test] </ins> #[cfg(windows)] fn file_test_io_seek_read_write() { use os::windows::fs::FileExt;

/// Unix-specific extensions to `Permissions` #[stable(feature = "fs_ext", since = "1.1.0")] pub trait PermissionsExt { <del> /// Returns the underlying raw `mode_t` bits that are the standard Unix /// permissions for this file. </del> <ins> /// Returns the underlying raw `st_mode` bits that contain the standard /// Unix permissions for this file. </ins> /// /// # Examples ///

impl FileAttr { pub fn size(&self) -> u64 { self.stat.st_size as u64 } pub fn perm(&self) -> FilePermissions { <del> FilePermissions { mode: (self.stat.st_mode as mode_t) & 0o777 } </del> <ins> FilePermissions { mode: (self.stat.st_mode as mode_t) } </ins> } pub fn file_type(&self) -> FileType {
Change:
I've hit an ICE with the new generator support that has just landed (nightly 2017-08-29). I've reduced it to the following : This is essentially the same issue as . I can't reproduce the original ICE with closures as described there, but I run into it with generators.
I believe this ICE is more related to "impl Trait" rather than generators, but we'll find out!
I think also needs to be adapted for generators.
looks like ! Thanks for the pointer!

Discussion:
ty::TyProjection(ref proj) => Some(proj.item_def_id), ty::TyFnDef(def_id, ..) | ty::TyClosure(def_id, ..) | <ins> ty::TyGenerator(def_id, ..) | </ins> ty::TyAnon(def_id, _) => Some(def_id), _ => None };

<ins> // Copyright 2017 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. #![feature(conservative_impl_trait, generators, generator_trait)] use std::ops::Generator; fn msg() -> u32 { 0 } pub fn foo() -> impl Generator<Yield=(), Return=u32> { || { yield; return msg(); } } </ins>

<ins> // Copyright 2017 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. // aux-build:xcrate-reachable.rs #![feature(conservative_impl_trait, generator_trait)] extern crate xcrate_reachable as foo; use std::ops::Generator; fn main() { foo::foo().resume(); } </ins>
Change:
This function still takes its argument by explicit .
also,
I'm doing this, just waiting for tests.
Done, pending
Fixed in

Discussion:
} } <del> fn frame_address(f: &fn(++x: *u8)) { </del> <ins> fn frame_address(f: &fn(x: *u8)) { </ins> unsafe { rusti::frame_address(f) }

pub mod rusti { #[abi = "rust-intrinsic"] pub extern { <del> pub fn frame_address(f: &once fn(++x: *u8)); </del> <ins> pub fn frame_address(f: &once fn(x: *u8)); </ins> } }

extern fn on_tcp_read_cb(stream: *uv::ll::uv_stream_t, nread: libc::ssize_t, <del> ++buf: uv::ll::uv_buf_t) { </del> <ins> buf: uv::ll::uv_buf_t) { </ins> unsafe { debug!("entering on_tcp_read_cb stream: %? nread: %?", stream, nread);
Change:
Playground: This includes the error: Whereas it could be much better suggesting the user to type instead of supplying .
Clippy has for this exact problem.

Discussion:
expected: Ty<'tcx>) -> Option<String> { match (&expected.sty, &checked_ty.sty) { <del> (&ty::TyRef(_, _), &ty::TyRef(_, _)) => None, </del> <ins> (&ty::TyRef(_, exp), &ty::TyRef(_, check)) => match (&exp.ty.sty, &check.ty.sty) { (&ty::TyStr, &ty::TyArray(arr, _)) | (&ty::TyStr, &ty::TySlice(arr)) if arr == self.tcx.types.u8 => { if let hir::ExprLit(_) = expr.node { let sp = self.sess().codemap().call_span_if_macro(expr.span); if let Ok(src) = self.tcx.sess.codemap().span_to_snippet(sp) { return Some(format!("try `{}`", &src[1..])); } } None }, (&ty::TyArray(arr, _), &ty::TyStr) | (&ty::TySlice(arr), &ty::TyStr) if arr == self.tcx.types.u8 => { if let hir::ExprLit(_) = expr.node { let sp = self.sess().codemap().call_span_if_macro(expr.span); if let Ok(src) = self.tcx.sess.codemap().span_to_snippet(sp) { return Some(format!("try `b{}`", src)); } } None } _ => None, }, </ins> (&ty::TyRef(_, mutability), _) => { // Check if it can work when put into a ref. For example: //

<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. fn main() { let x: &[u8] = "foo"; let y: &[u8; 4] = "baaa"; let z: &str = b"foo"; } </ins>

<ins> error[E0308]: mismatched types --> $DIR/str-lit-type-mismatch.rs:13:20 | 13 |     let x: &[u8] = "foo"; |                    ^^^^^ expected slice, found str | = note: expected type `&[u8]` found type `&'static str` = help: try `b"foo"` error[E0308]: mismatched types --> $DIR/str-lit-type-mismatch.rs:14:23 | 14 |     let y: &[u8; 4] = "baaa"; |                       ^^^^^^ expected array of 4 elements, found str | = note: expected type `&[u8; 4]` found type `&'static str` = help: try `b"baaa"` error[E0308]: mismatched types --> $DIR/str-lit-type-mismatch.rs:15:19 | 15 |     let z: &str = b"foo"; |                   ^^^^^^ expected str, found array of 3 elements | = note: expected type `&str` found type `&'static [u8; 3]` = help: try `"foo"` error: aborting due to 3 previous errors </ins>
Change:
Hi all Following code produces always the same output in console and emits ... in compilation. Tested in Rust playground in nightly. Any comments?
In your code, , in match patterns are treated as variable names. Try pattern guards: Note that the return value of ranges from to , because accepts an argument of type . You will rarely see and , because most of the case the control flow will fall into the placeholder arm and print . Pattern matching is different from comparing with . You can implement your custom logic of by implementing [][partial-eq], but it lacks ability of destructuring structs, enums, and tuples. On the other hand, pattern matching can match against literals or destructure values, but you can't define your own pattern matching logic. They just have different purposes. in your code () implements to compare function pointers. However, functions are not literals, so they can't be matched directly. [partial-eq]:
Yes with guards it works, but I suspect it changes the semantics of match (less optimizations I guess). Is it possible to make "minus" and "plus" constants instead? I mean it's just pointers under the hood, right? And yes "rng" is just to give an idea.
You can normally use constants, but these currently fail: I guess noone thought that functions would be used in patterns:
That's much getter, imho. Thanks for hint. Functions as values? Never heard of heresy like that :)
Reduced the testcase.
The test cases here no longer ICE on beta or nightly.
Needs a regression test

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. type Func = fn(usize, usize) -> usize; fn foo(a: usize, b: usize) -> usize { a + b } fn bar(a: usize, b: usize) -> usize { a * b } fn test(x: usize) -> Func { if x % 2 == 0 { foo } else { bar } } const FOO: Func = foo; const BAR: Func = bar; fn main() { match test(std::env::consts::ARCH.len()) { FOO => println!("foo"), BAR => println!("bar"), _ => unreachable!(), } } </ins>
Change:
Should this be happening? I'm not surprised ping would affect the backtrace, but a segmentation fault feels like a bug. Tested on:
Thanks for the report and definitely a bug! Should be fixed in
For others tracking, should be fixed in

Discussion:
{ unsafe { let mut info: Dl_info = intrinsics::init(); <del> let symname = if dladdr(frame.exact_position, &mut info) == 0 { </del> <ins> let symname = if dladdr(frame.exact_position, &mut info) == 0 || info.dli_sname.is_null() { </ins> None } else { CStr::from_ptr(info.dli_sname).to_str().ok()
Change:
During the write of an embedded library I needed to make a pause of 10 microseconds. Looking over the I understood that I had to use the following construction: The sad part is that this is less clear to me than . Currently the and functions are implemented but not which could help write cleaner code IMO. The fix seems pretty easy, maybe if you judge this useful I can try to write my first pull request to the Rust project!
In general, this is how works; small additions can just be a PR, larger additions need an RFC. So, I'd suggest that you send in a PR implementing this.
Adding sounds okay to me.
Yeah, I'd be on board with a PR.
This is now a tracking issue for the function in the previously referenced PR.
Looks good to me to stabilize. fcp merge
Team member has proposed to merge this. The next step is review by the rest of the tagged teams: [x] [x] [x] [x] [x] [x] [ ] No concerns currently listed. Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See for info about what commands tagged team members can give me.
:bell: This is now entering its final comment period, as per the . :bell:
The final comment period is now complete.

Discussion:
const NANOS_PER_SEC: u32 = 1_000_000_000; const NANOS_PER_MILLI: u32 = 1_000_000; <ins> const NANOS_PER_MICRO: u32 = 1_000; </ins> const MILLIS_PER_SEC: u64 = 1_000; <ins> const MICROS_PER_SEC: u64 = 1_000_000; </ins> /// A `Duration` type to represent a span of time, typically used for system /// timeouts.

Duration { secs: secs, nanos: nanos } } <ins> /// Creates a new `Duration` from the specified number of microseconds. /// /// # Examples /// /// ``` /// #![feature(duration_from_micros)] /// use std::time::Duration; /// /// let duration = Duration::from_micros(1_000_002); /// /// assert_eq!(1, duration.as_secs()); /// assert_eq!(2000, duration.subsec_nanos()); /// ``` #[unstable(feature = "duration_from_micros", issue = "44400")] #[inline] pub fn from_micros(micros: u64) -> Duration { let secs = micros / MICROS_PER_SEC; let nanos = ((micros % MICROS_PER_SEC) as u32) * NANOS_PER_MICRO; Duration { secs: secs, nanos: nanos } } </ins> /// Returns the number of _whole_ seconds contained by this `Duration`. /// /// The returned value does not include the fractional (nanosecond) part of the
Change:
If anyone anyone wants to work on this, just mention it in a comment to prevent duplicate work. If you need any help or have any questions, don't hesitate to ping me :)
This seems easy, I'd like to give it a shot.
Will something like this be okay? I assumed the most obvious difference between utf8 and utf16 is the length of a non-Ascii string (hence the assertion). Technically I could assert for exact values, but that sounds like an overkill to me.
Agreed! Same, this sounds good to me!

Discussion:
} /// Returns an iterator of `u16` over the string encoded as UTF-16. <ins> /// /// # Examples /// /// Basic usage: /// /// ``` /// let text = "Zażółć gęślą jaźń"; /// /// let utf8_len = text.len(); /// let utf16_len = text.encode_utf16().count(); /// /// assert!(utf16_len <= utf8_len); /// ``` </ins> #[stable(feature = "encode_utf16", since = "1.8.0")] pub fn encode_utf16(&self) -> EncodeUtf16 { EncodeUtf16 { encoder: Utf16Encoder::new(self[..].chars()) }
Change:
I compared the performance of three equivalent functions: This is results (release mode):
IIRC zip is specialized for slices which is why the last case is so much faster.
Try also to compile with
A question could be: is it possible for to return something similar to ?
It makes the two times faster, the speed of the and the has stayed the same as before.
You've discovered the "untweaked speed" of zip :frowning_face:, which is what has. can implement the same way slice iterators do, in fact is just a newtype around an iterator that already implements that trait.

Discussion:
{} #[doc(hidden)] <del> unsafe impl<'a, I, T: 'a> TrustedRandomAccess for Cloned<I> </del> <ins> default unsafe impl<'a, I, T: 'a> TrustedRandomAccess for Cloned<I> </ins> where I: TrustedRandomAccess<Item=&'a T>, T: Clone { unsafe fn get_unchecked(&mut self, i: usize) -> Self::Item {

fn may_have_side_effect() -> bool { true } } <ins> #[doc(hidden)] unsafe impl<'a, I, T: 'a> TrustedRandomAccess for Cloned<I> where I: TrustedRandomAccess<Item=&'a T>, T: Copy { unsafe fn get_unchecked(&mut self, i: usize) -> Self::Item { *self.it.get_unchecked(i) } #[inline] fn may_have_side_effect() -> bool { false } } </ins> #[unstable(feature = "trusted_len", issue = "37572")] unsafe impl<'a, I, T: 'a> TrustedLen for Cloned<I> where I: TrustedLen<Item=&'a T>,

use char; use convert::TryFrom; use fmt; <del> use iter::{Map, Cloned, FusedIterator}; </del> <ins> use iter::{Map, Cloned, FusedIterator, TrustedLen}; use iter_private::TrustedRandomAccess; </ins> use slice::{self, SliceIndex}; use mem;

#[unstable(feature = "fused", issue = "35602")] impl<'a> FusedIterator for Bytes<'a> {} <ins> #[unstable(feature = "trusted_len", issue = "37572")] unsafe impl<'a> TrustedLen for Bytes<'a> {} #[doc(hidden)] unsafe impl<'a> TrustedRandomAccess for Bytes<'a> { unsafe fn get_unchecked(&mut self, i: usize) -> u8 { self.0.get_unchecked(i) } fn may_have_side_effect() -> bool { false } } </ins> /// This macro generates a Clone impl for string pattern API /// wrapper types of the form X<'a, P> macro_rules! derive_pattern_clone {
Change:
If anyone anyone wants to work on this, just mention it in a comment to prevent duplicate work. If you need any help or have any questions, don't hesitate to ping me :)
I will work on this.

Discussion:
} /// Extracts a string slice containing the entire string. <ins> /// /// # Examples /// /// Basic usage: /// /// ``` /// let s = String::from("foo"); /// /// assert_eq!("foo", s.as_str()); /// ``` </ins> #[inline] #[stable(feature = "string_as_str", since = "1.7.0")] pub fn as_str(&self) -> &str {
Change:
For this one, ideally the example would demonstrate mutation. If anyone anyone wants to work on this, just mention it in a comment to prevent duplicate work. If you need any help or have any questions, don't hesitate to ping me :)
I will work on this.

Discussion:
self } <del> /// Extracts a string slice containing the entire string. </del> <ins> /// Converts a `String` into a mutable string slice. /// /// # Examples /// /// Basic usage: /// /// ``` /// use std::ascii::AsciiExt; /// /// let mut s = String::from("foobar"); /// let s_mut_str = s.as_mut_str(); /// /// s_mut_str.make_ascii_uppercase(); /// /// assert_eq!("FOOBAR", s_mut_str); /// ``` </ins> #[inline] #[stable(feature = "string_as_str", since = "1.7.0")] pub fn as_mut_str(&mut self) -> &mut str {
Change:
Cargo doc runs on nightly-2017-09-11 without displaying any errors or warnings, yet, it doesn't produce any outputs. I am on nightly-unknown-linux-gnu on Linux Mint. I tried with different nightly toolchains to see if it was a problem of my code, or if it was a problem of the toolchain. [OK] nightly-2017-09-08-x8664-unknown-linux-gnu [OK] nightly-2017-09-09-x8664-unknown-linux-gnu [OK] nightly-2017-09-10-x8664-unknown-linux-gnu [Broken] nightly-2017-09-11-x8664-unknown-linux-gnu I also tried on different machines and the result is the same. I tried: but I cannot find any pointer to the problem. Example output when running cargo doc --open The browser window doesn't open, the target/doc folder is empty and the usual xdg-open command is missing. Does anybody else have the same problem?
Looks like this is because as distributed is an empty file... investigating
Likely caused by
On Appveyor I was getting a much more frustrating error: Upon updating to the latest nightly locally I got a more helpful error: And as it turns out, is empty here as well: 
Oh that's why my builds were failing attempting to commit an empty folder full of 'docs'...
Thank you guys! That fixed it :)

Discussion:
fn install(src: &Path, dstdir: &Path, perms: u32) { let dst = dstdir.join(src.file_name().unwrap()); t!(fs::create_dir_all(dstdir)); <ins> drop(fs::remove_file(&dst)); </ins> { let mut s = t!(fs::File::open(&src)); let mut d = t!(fs::File::create(&dst));