jiebi/CodeConvo huggingface dataset:
Change:
Hrm, yeah, the IR format changed from 3.6 to 3.7. In this case, it's just the extra result type in the instructions. Making that optional by changing to something like should help with that. If you still have a build using LLVM 3.6 around, it'd be great if you could create a patch for this. If not, let me know and I'll create one this evening.
I will give it a try. I am not planning to switch to 3.7 right now as there is no official release yet.
This is fixed.

Discussion:
// CHECK-LABEL: @borrow #[no_mangle] pub fn borrow(x: &i32) -> &i32 { <del> // CHECK: load i32*, i32** %x{{.*}}, !nonnull </del> <ins> // CHECK: load {{(i32*, )?}}i32** %x{{.*}}, !nonnull </ins> x } // CHECK-LABEL: @_box #[no_mangle] pub fn _box(x: Box<i32>) -> i32 { <del> // CHECK: load i32*, i32** %x{{.*}}, !nonnull </del> <ins> // CHECK: load {{(i32*, )?}}i32** %x{{.*}}, !nonnull </ins> *x }

// dependent alignment #[no_mangle] pub fn small_array_alignment(x: [i8; 4]) -> [i8; 4] { <del> // CHECK: [[VAR:%[0-9]+]] = load i32, i32* %{{.*}}, align 1 </del> <ins> // CHECK: [[VAR:%[0-9]+]] = load {{(i32, )?}}i32* %{{.*}}, align 1 </ins> // CHECK: ret i32 [[VAR]] x }

// dependent alignment #[no_mangle] pub fn small_struct_alignment(x: Bytes) -> Bytes { <del> // CHECK: [[VAR:%[0-9]+]] = load i32, i32* %{{.*}}, align 1 </del> <ins> // CHECK: [[VAR:%[0-9]+]] = load {{(i32, )?}}i32* %{{.*}}, align 1 </ins> // CHECK: ret i32 [[VAR]] x }

// dependent alignment #[no_mangle] pub fn small_array_alignment(x: &mut [i8; 4]) { <del> // CHECK: [[VAR:%[0-9]+]] = load [4 x i8]*, [4 x i8]** %x </del> <ins> // CHECK: [[VAR:%[0-9]+]] = load {{([4 x i8]*, )?}}[4 x i8]** %x </ins> // CHECK: [[VAR2:%[0-9]+]] = bitcast [4 x i8]* [[VAR]] to i32* // CHECK: store i32 %{{.*}}, i32* [[VAR2]], align 1 *x = [0; 4];

// dependent alignment #[no_mangle] pub fn small_struct_alignment(x: &mut Bytes) { <del> // CHECK: [[VAR:%[0-9]+]] = load %Bytes*, %Bytes** %x </del> <ins> // CHECK: [[VAR:%[0-9]+]] = load {{(%Bytes*, )?}}%Bytes** %x </ins> // CHECK: [[VAR2:%[0-9]+]] = bitcast %Bytes* [[VAR]] to i32* // CHECK: store i32 %{{.*}}, i32* [[VAR2]], align 1 *x = Bytes {
Change:
noticed this on IRC. and in fact on all other triples (except iOS, which is technically called ), a SSE2-capable microarchitecture is assumed. said that this was copied from Clang. Not doing so on MSVC might be an accident, and a rather costly one.
Specifically, in the target spec, we have: , unlike every other target which assumes (except for Mac, which assumes , which is newer, so that's fine).
cc who wrote that code. Is this an intentional quirk of the MSVC toolchain?
Oh dear no this was not intentional at all, I just assumed everything was ! Feel free to send a PR to update!

Discussion:
pub fn target() -> Target { let mut base = super::windows_msvc_base::opts(); <del> base.cpu = "i686".to_string(); </del> <ins> base.cpu = "pentium4".to_string(); </ins> Target { llvm_target: "i686-pc-windows-msvc".to_string(),
Change:
Now, run the following You get the following error: A simple fix to this is to add at the beginning of , but that should not be unnecessary. Reproduces on nightly.
This is currently working as intended, the flags only work for specifying the immediate set of dependencies (those listed in ), and transitive dependencies must be found through paths. You can use to make sure that only transitive dependencies are found in those paths.
If that is the intended behavior, then please reopen this issue and mark it as a documentation problem. I cannot find where this distinction is explained. This section of would imply that: / are for use with native libraries only, not even mentioning the KIND. by itself will not actually search for crates in that directory. should be used for telling rust where to locate any crate and is an intuitive solution to errors like For reference, how do you thus indicate to rust where to locate a crate whose filename does not follow the pattern?
Yeah seems reasonable to leave open as a docs issue. Not sure exhaustive documentation should go into the message but the man page could certainly be up. That... can't actually be done I don't think. The only way the compiler looks for transitive dependencies is via where is the name of the crate.

Discussion:
.RE .TP fB-lfR [fIKINDfR=]fINAMEfR <del> Link the generated crate(s) to the specified native library fINAMEfR. </del> <ins> Link the generated crate(s) to the specified library fINAMEfR. </ins> The optional fIKINDfR can be one of fIstaticfR, fIdylibfR, or fIframeworkfR. If omitted, fIdylibfR is assumed.

Use verbose output. .TP fB--externfR fINAMEfR=fIPATHfR <del> Specify where an external rust library is located. </del> <ins> Specify where an external rust library is located. These should match fIexternfR declarations in the crate's source code. </ins> .TP fB--sysrootfR fIPATHfR Override the system root.
Change:
From Code: If the Deref is removed, the code compiles. Presumably, the inclusion of the Deref implementation on the trait object causes the lifetime bounds to change on the do_something method.
Code:
For debugging, notice that is equivalent to .
Triage: still reproduces today.
Triage: still reproduces today.
This no longer reproduces. Tagging as E-needstest

Discussion:
<ins> // run-pass use std::ops::Deref; trait MyTrait { fn do_something(&self); fn as_str(&self) -> &str; } impl Deref for dyn MyTrait { type Target = str; fn deref(&self) -> &Self::Target { self.as_str() } } fn trait_object_does_something(t: &dyn MyTrait) { t.do_something() } fn main() {} </ins>
Change:
This issue is for adding the snapshots.
Snapshots inbound. See PR
Could you please look into taking care of NetBSD as well?
I've got a NetBSD builder set up on my VM host already but I've been unable to build it from source just yet. I've been using my cross-bootstrap scripts to get a rustc that runs on NetBSD. Just a couple issues left I think, but I'm busy with lots of things right now. It might be a little while, but I'm hoping to have it online ASAP.
great, thanks for the update!

Discussion:
S 2015-08-11 1af31d4 <del> bitrig-x86_64 0000000000000000000000000000000000000000 freebsd-i386 0000000000000000000000000000000000000000 freebsd-x86_64 0000000000000000000000000000000000000000 </del> <ins> bitrig-x86_64 739e0635cd5a1b3635f1457aae3ef6390ea9a7a8 freebsd-i386 3cd4a44fb97b3135be3d1b760bea604a381e85dc freebsd-x86_64 de1f36592bac0eeb90c049a8421246652c511b9e </ins> linux-i386 e2553bf399cd134a08ef3511a0a6ab0d7a667216 linux-x86_64 7df8ba9dec63ec77b857066109d4b6250f3d222f macos-i386 29750870c82a0347f8b8b735a4e2e0da26f5098d
Change:
When trying to (erroneously) access members of a tuple using square brackets, rather than a period, the compiler gives the message " error: cannot index a value of type .... ". Particularly as a new user, it would be nice if the compiler could suggest something like "try using the syntax rather than <tuple[idx]." This isn't by any means a big issue, but it would help eliminate yet another search through the documentation.

Discussion:
} None => { check_expr_has_type(fcx, &idx, fcx.tcx().types.err); <del> fcx.type_error_message( </del> <ins> let mut err = fcx.type_error_struct( </ins> expr.span, |actual| { format!("cannot index a value of type `{}`",

}, base_t, None); <ins> // Try to give some advice about indexing tuples. if let ty::TyTuple(_) = base_t.sty { let mut needs_note = true; // If the index is an integer, we can show the actual // fixed expression: if let hir::ExprLit(ref lit) = idx.node { if let ast::LitKind::Int(i, ast::LitIntType::Unsuffixed) = lit.node { let snip = fcx.tcx().sess.codemap().span_to_snippet(base.span); if let Ok(snip) = snip { err.span_suggestion(expr.span, "to access tuple elements, use tuple  indexing syntax as shown", format!("{}.{}", snip, i)); needs_note = false; } } } if needs_note { err.help("to access tuple elements, use tuple indexing  syntax (e.g. `tuple.0`)"); } } err.emit(); </ins> fcx.write_ty(id, fcx.tcx().types.err); } }

<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 tup = (0, 1, 2); // the case where we show a suggestion let _ = tup[0]; //~^ ERROR cannot index a value of type //~| HELP to access tuple elements, use tuple indexing syntax as shown //~| SUGGESTION let _ = tup.0 // the case where we show just a general hint let i = 0_usize; let _ = tup[i]; //~^ ERROR cannot index a value of type //~| HELP to access tuple elements, use tuple indexing syntax (e.g. `tuple.0`) } </ins>
Change:
After the new snapshots landed, test failures showed up.
failures: [run-pass] run-pass/allocator- [run-pass] run-pass/allocator-
it looks like the outstanding jemalloc issues are finally biting us.

Discussion:
// ignore-msvc everything is the system allocator on msvc // ignore-musl no dylibs on musl yet <ins> // ignore-bitrig no jemalloc on bitrig </ins> // aux-build:allocator-dylib.rs // no-prefer-dynamic // error-pattern: cannot link together two allocators

// ignore-msvc everything is the system allocator on msvc // ignore-musl no dylibs on musl right now <ins> // ignore-bitrig no jemalloc on bitrig </ins> // aux-build:allocator-dylib2.rs // error-pattern: cannot link together two allocators

#![feature(alloc_jemalloc, alloc_system)] <del> #[cfg(not(target_env = "msvc"))] </del> <ins> #[cfg(not(any(target_env = "msvc", target_os = "bitrig")))] </ins> extern crate alloc_jemalloc; <del> #[cfg(target_env = "msvc")] </del> <ins> #[cfg(any(target_env = "msvc", target_os = "bitrig"))] </ins> extern crate alloc_system; fn main() {

// no-prefer-dynamic // ignore-msvc no jemalloc on msvc <ins> // ignore-bitrig no jemalloc on bitrig either </ins> #![feature(alloc_jemalloc)]
Change:
After some discussing about static closures on IRC, I was messing around and found an ICE:
apparently the isn't inferred until regionck - or not at all. Maybe store the kind as part of the ClosureSubsts?

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:
"Prelude" doesn't seem to be a very common term outside of Haskell, yet it seems to only be explained in the Guessing Game section of the book. Even then, it only mentions it being the stuff imported by default, which doesn't explain .
I'm not sure where this actually belongs, do you have any thoughts? Can you elaborate on this? It does say the word 'prelude', and links to the module documentation for it, which covers it further.
Well, I guess what I'm getting at there is that in contrast to , isn't "a set of things that are imported by default"; rather it's "a set of things that are useful to import all at once". It's a similar meaning, but it's not quite the same thing. As for where it belongs in the book, I'm not entirely sure either; maybe a short section in the Syntax and Semantics chapter?
Also, I guess for some context, this issue arose because of .
Ahhhh I missed the io!

Discussion:
We’ll need to take user input, and then print the result as output. As such, we need the `io` library from the standard library. Rust only imports a few things by default into every program, [the ‘prelude’][prelude]. If it’s not in the <del> prelude, you’ll have to `use` it directly. </del> <ins> prelude, you’ll have to `use` it directly. There is also a second ‘prelude’, the [`io` prelude][ioprelude], which serves a similar function: you import it, and it imports a number of useful, `io`-related things. </ins> [prelude]: ../std/prelude/index.html <ins> [ioprelude]: ../std/io/prelude/index.html </ins> ```rust,ignore fn main() {
Change:
could be improved by mentioning for use in Windows. Perhaps an appendix for Windows?
I don't want to suggest that Windows people are second-class by putting it in an appendix, so this should just be in the regular docs. This is the return value of a program, yes? What's some good docs on what is? I don't use windows that much myself. /cc
I cannot find any direct msdn documentation on although I can find Microsoft blog posts that refer to it.
Honestly I got it from stackoverflow. is another good one retep ninja'd me on my others.
Official MS documentation: . Apparently Microsoft decided to delete all references to from the official documentation.

Discussion:
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured ``` <del> We also get a non-zero status code: </del> <ins> We also get a non-zero status code. We can use `$?` on OS X and Linux: </ins> ```bash $ echo $? 101 ``` <ins> On Windows, if you’re using `cmd`: ```bash > echo %ERRORLEVEL% ``` And if you’re using PowerShell: ```bash > echo $LASTEXITCODE # the code itself > echo $? # a boolean, fail or succeed ``` </ins> This is useful if you want to integrate `cargo test` into other tooling. We can invert our test's failure with another attribute: `should_panic`:
Change:
std::ptr::copy_nonoverlapping takes 3 arguments, but only 2 are provided. It also does not typecheck anymore either.
I think this example should just be removed, as requires its source and destination types to be the same. For a "real" manual transmute, someone could transmute the pointers to and and then pass the correct number of bytes as the third argument to that function.

Discussion:
It is also possible to manually transmute: ``` <del> let result: SomeType = mem::uninitialized(); unsafe { copy_nonoverlapping(&v, &result) }; result // `v` transmuted to type `SomeType` </del> <ins> ptr::read(&v as *const _ as *const SomeType) // `v` transmuted to `SomeType` </ins> ``` "##,
Change:
In the paragraph about the : Shouldn't the asref/asmut methods mentioned be infact downcastref/downcastmut methods? Can't find any asref/asmut method implementations for the Any trait anywhere.

Discussion:
//! //! `Any` itself can be used to get a `TypeId`, and has more features when used //! as a trait object. As `&Any` (a borrowed trait object), it has the `is` and <del> //! `as_ref` methods, to test if the contained value is of a given type, and to //! get a reference to the inner value as a type. As `&mut Any`, there is also //! the `as_mut` method, for getting a mutable reference to the inner value. //! `Box<Any>` adds the `move` method, which will unwrap a `Box<T>` from the //! object.  See the extension traits (`*Ext`) for the full details. </del> <ins> //! `downcast_ref` methods, to test if the contained value is of a given type, //! and to get a reference to the inner value as a type. As `&mut Any`, there //! is also the `downcast_mut` method, for getting a mutable reference to the //! inner value. `Box<Any>` adds the `move` method, which will unwrap a //! `Box<T>` from the object. See the extension traits (`*Ext`) for the full //! details. </ins> //! //! Note that &Any is limited to testing whether a value is of a specified //! concrete type, and cannot be used to test whether a type implements a trait.
Change:
I was writing a generic argument parse validator for my program, which involved matching errors from FromStr::parse. After constraining the error type to Error, I ran into an issue when creating a validator for parsing IP addresses:
Fixed in

Discussion:
use prelude::v1::*; <del> use str::FromStr; </del> <ins> use error::Error; use fmt; </ins> use net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}; <ins> use str::FromStr; </ins> struct Parser<'a> { // parsing as ASCII, so can use byte array

#[stable(feature = "rust1", since = "1.0.0")] #[derive(Debug, Clone, PartialEq)] pub struct AddrParseError(()); <ins> #[stable(feature = "addr_parse_error_error", since = "1.4.0")] impl fmt::Display for AddrParseError { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fmt.write_str(self.description()) } } #[stable(feature = "addr_parse_error_error", since = "1.4.0")] impl Error for AddrParseError { fn description(&self) -> &str { "invalid IP address syntax" } } </ins>
Change:
To be consistent with Vec and other collections, shouldn't these types also get the IntoIterator impls for and ?
Yeah this should be fine to implement, it's just an oversight.

Discussion:
} } <ins> #[stable(since = "1.4.0", feature = "option_iter")] impl<'a, T> IntoIterator for &'a Option<T> { type Item = &'a T; type IntoIter = Iter<'a, T>; fn into_iter(self) -> Iter<'a, T> { self.iter() } } #[stable(since = "1.4.0", feature = "option_iter")] impl<'a, T> IntoIterator for &'a mut Option<T> { type Item = &'a mut T; type IntoIter = IterMut<'a, T>; fn into_iter(mut self) -> IterMut<'a, T> { self.iter_mut() } } </ins> ///////////////////////////////////////////////////////////////////////////// // The Option Iterators /////////////////////////////////////////////////////////////////////////////

} } <ins> #[stable(since = "1.4.0", feature = "result_iter")] impl<'a, T, E> IntoIterator for &'a Result<T, E> { type Item = &'a T; type IntoIter = Iter<'a, T>; fn into_iter(self) -> Iter<'a, T> { self.iter() } } #[stable(since = "1.4.0", feature = "result_iter")] impl<'a, T, E> IntoIterator for &'a mut Result<T, E> { type Item = &'a mut T; type IntoIter = IterMut<'a, T>; fn into_iter(mut self) -> IterMut<'a, T> { self.iter_mut() } } </ins> ///////////////////////////////////////////////////////////////////////////// // The Result Iterators /////////////////////////////////////////////////////////////////////////////

assert_eq!(it.next(), Some(&val)); assert_eq!(it.size_hint(), (0, Some(0))); assert!(it.next().is_none()); <ins> let mut it = (&x).into_iter(); assert_eq!(it.next(), Some(&val)); </ins> } #[test] fn test_mut_iter() { <del> let val = 5; </del> <ins> let mut val = 5; </ins> let new_val = 11; let mut x = Some(val);

assert!(it.next().is_none()); } assert_eq!(x, Some(new_val)); <ins> let mut y = Some(val); let mut it = (&mut y).into_iter(); assert_eq!(it.next(), Some(&mut val)); </ins> } #[test]

let err: Result<isize, &'static str> = Err("All good"); err.expect("Got expected error"); } <ins> #[test] pub fn test_iter() { let ok: Result<isize, &'static str> = Ok(100); let mut it = ok.iter(); assert_eq!(it.size_hint(), (1, Some(1))); assert_eq!(it.next(), Some(&100)); assert_eq!(it.size_hint(), (0, Some(0))); assert!(it.next().is_none()); assert_eq!((&ok).into_iter().next(), Some(&100)); let err: Result<isize, &'static str> = Err("error"); assert_eq!(err.iter().next(), None); } #[test] pub fn test_iter_mut() { let mut ok: Result<isize, &'static str> = Ok(100); for loc in ok.iter_mut() { *loc = 200; } assert_eq!(ok, Ok(200)); for loc in &mut ok { *loc = 300; } assert_eq!(ok, Ok(300)); let mut err: Result<isize, &'static str> = Err("error"); for loc in err.iter_mut() { *loc = 200; } assert_eq!(err, Err("error")); } </ins>