jiebi/CodeConvo huggingface dataset:
Change:
I would like to use them in the project for conditional compilation. So if there is no particular reason against including them, it would be nice to have them. This code currently does not work as intended: Related:
cc and
Seems plausible to me!

Discussion:
"ssse30", "tbm0", "lzcnt0", "popcnt0", "sse4a0", "rdrnd0", "rdseed0", "fma0", "xsave0", "xsaveopt0", "xsavec0", <del> "xsaves0", </del> <ins> "xsaves0", "aes0", </ins> "avx512bw0", "avx512cd0", "avx512dq0", "avx512er0", "avx512f0", "avx512ifma0",
Change:
This is an 8% regression with incremental enabled, 1% without it.
Interestingly if you you'll see: An 8% regression due to A 4% improvement due to A 7% improvement due to A 7% regression due to May be worth looking into as well?
Specifically before/after , -- I've only included the peak snapshot in the output there.
Looks like basically all of the memory , aka we have a bigger dep graph. Turns out adding more queries makes a bigger dep graph :)
I cashed in some easy savings in , but it doesn't actually fix the "regression", but we likely shouldn't call it a regression as it also fixed a number of would-be bugs!
Looks like we've and this particular peak may also , so closing.

Discussion:
pub fn new(nodes: &[DepNode], edges: &[(DepNode, DepNode)]) -> DepGraphQuery { <del> let mut graph = Graph::new(); </del> <ins> let mut graph = Graph::with_capacity(nodes.len(), edges.len()); </ins> let mut indices = FxHashMap(); for node in nodes { <del> indices.insert(node.clone(), graph.next_node_index()); graph.add_node(node.clone()); </del> <ins> indices.insert(node.clone(), graph.add_node(node.clone())); </ins> } for &(ref source, ref target) in edges {

} } <ins> pub fn with_capacity(nodes: usize, edges: usize) -> Graph<N, E> { Graph { nodes: SnapshotVec::with_capacity(nodes), edges: SnapshotVec::with_capacity(edges), } } </ins> // # Simple accessors #[inline]

} } <ins> pub fn with_capacity(n: usize) -> SnapshotVec<D> { SnapshotVec { values: Vec::with_capacity(n), undo_log: Vec::new(), } } </ins> fn in_snapshot(&self) -> bool { !self.undo_log.is_empty() }
Change:
IntoIterator has a complex set of associated types, and is commonly used as a bound on functions, but does not show its usage at all. I'd be happy to help anyone out to make this better! Fundamentally, we should show a function that takes a generic argument that has a bound with .
I'd like to have a go at this if that's OK. I'll open a pull request.
Should this be closed now that has been merged?
Indeed!

Discussion:
///     assert_eq!(i as i32, n); /// } /// ``` <ins> /// /// It is common to use `IntoIterator` as a trait bound. This allows /// the input collection type to change, so long as it is still an /// iterator. Additional bounds can be specified by restricting on /// `Item`: /// /// ```rust /// fn collect_as_strings<T>(collection: T) -> Vec<String> ///     where T: IntoIterator, ///           T::Item : std::fmt::Debug, /// { ///     collection ///         .into_iter() ///         .map(|item| format!("{:?}", item)) ///         .collect() /// } /// ``` </ins> #[stable(feature = "rust1", since = "1.0.0")] pub trait IntoIterator { /// The type of the elements being iterated over.
Change:
What I tried: on a laptop disconnected from wifi, running linux What I expected: tests pass What I got: tests pass except . Underlying error: . Should the test suite be assuming we are on some network?

Discussion:
#[test] fn connect_timeout_unroutable() { <del> // this IP is unroutable, so connections should always time out. </del> <ins> // this IP is unroutable, so connections should always time out, // provided the network is reachable to begin with. </ins> let addr = "10.255.255.1:80".parse().unwrap(); let e = TcpStream::connect_timeout(&addr, Duration::from_millis(250)).unwrap_err(); <del> assert_eq!(e.kind(), io::ErrorKind::TimedOut); </del> <ins> assert!(e.kind() == io::ErrorKind::TimedOut || e.kind() == io::ErrorKind::Other, "bad error: {} {:?}", e, e.kind()); </ins> } #[test]
Change:
Test case: Expected output: . Example output (changes on every run): . Output from Output with valgrind:
I found this in : That should probably be .
Fixed.

Discussion:
fn visit_f32() -> bool { self.write::<f32>() } fn visit_f64() -> bool { self.write::<f64>() } <del> fn visit_char() -> bool { self.write::<uint>() } </del> <ins> fn visit_char() -> bool { self.write::<u32>() } </ins> // Type no longer exists, vestigial function. fn visit_str() -> bool { fail; }
Change:
` rustc -V rustc 1.22.0-nightly ( 2017-09-18)
Similar cause as . Repro case for :

Discussion:
ast::TyKind::Ptr(ast::MutTy { ty: ref subty, .. }) | ast::TyKind::Rptr(_, ast::MutTy { ty: ref subty, .. }) | ast::TyKind::Paren(ref subty) => involves_impl_trait(subty), <del> ast::TyKind::Tup(ref tys) => tys.iter().any(|subty| involves_impl_trait(subty)), </del> <ins> ast::TyKind::Tup(ref tys) => any_involves_impl_trait(tys.iter()), ast::TyKind::Path(_, ref path) => path.segments.iter().any(|seg| { match seg.parameters.as_ref().map(|p| &**p) { None => false, Some(&ast::PathParameters::AngleBracketed(ref data)) => any_involves_impl_trait(data.types.iter()) || any_involves_impl_trait(data.bindings.iter().map(|b| &b.ty)), Some(&ast::PathParameters::Parenthesized(ref data)) => any_involves_impl_trait(data.inputs.iter()) || any_involves_impl_trait(data.output.iter()), } }), </ins> _ => false, } } <ins> fn any_involves_impl_trait<'a, I: Iterator<Item = &'a P<ast::Ty>>>(mut it: I) -> bool { it.any(|subty| involves_impl_trait(subty)) } </ins> involves_impl_trait(ty) } else { false

Some(1u8).into_iter() } <ins> pub fn k() -> [impl Clone; 2] { [123u32, 456u32] } pub fn l() -> (impl Clone, impl Default) { (789u32, -123i32) } pub fn m() -> &'static impl Clone { &1u8 } pub fn n() -> *const impl Clone { &1u8 } pub fn o() -> &'static [impl Clone] { b":)" } // issue #44731 pub fn test_44731_0() -> Box<impl Iterator<Item=u8>> { Box::new(g()) } pub fn test_44731_1() -> Result<Box<impl Clone>, ()> { Ok(Box::new(j())) } pub fn test_44731_2() -> Box<Fn(impl Clone)> { Box::new(|_: u32| {}) } pub fn test_44731_3() -> Box<Fn() -> impl Clone> { Box::new(|| 0u32) } pub fn test_44731_4() -> Box<Iterator<Item=impl Clone>> { Box::new(g()) } </ins> // @has issue_43869/fn.g.html // @has issue_43869/fn.h.html // @has issue_43869/fn.i.html // @has issue_43869/fn.j.html <ins> // @has issue_43869/fn.k.html // @has issue_43869/fn.l.html // @has issue_43869/fn.m.html // @has issue_43869/fn.n.html // @has issue_43869/fn.o.html // @has issue_43869/fn.test_44731_0.html // @has issue_43869/fn.test_44731_1.html // @has issue_43869/fn.test_44731_2.html // @has issue_43869/fn.test_44731_3.html // @has issue_43869/fn.test_44731_4.html </ins>
Change:
I've been seeing lots of bad behavior trying to use VecDeque. I've boiled it down to a relatively simple example which shows some of the bad behavior I was seeing and additionally seg faults. This was with: rustc 1.20.0 ( 2017-08-27) binary: rustc commit-hash: commit-date: 2017-08-27 host: x86_64-apple-darwin release: 1.20.0 LLVM version: 4.0 and also rust 1.19 The output I expect to see is: The output I get is: Note that the fourth from the last byte should be D9. Work around seems to be to use a large VecDeqeue capacity. Here's the code:
Valgrind output with the allocator switched over to alloc_system:
Here is what I believe is a minimal reproduction: Valgrind:
It looks like this was introduced two years ago in Specifically, mixes up its "raw" capacity and the user-visible capacity. These differ by one, so reserve can end up in a situation where it calls into without the capacity having actually increased. The implementation of that method assumes this doesn't happen, and as a result messes up the head and tail pointers so that the next push writes off the end of the buffer. Making a fix right now.
This bug is referenced in :

Discussion:
.and_then(|needed_cap| needed_cap.checked_next_power_of_two()) .expect("capacity overflow"); <del> if new_cap > self.capacity() { </del> <ins> if new_cap > old_cap { </ins> self.buf.reserve_exact(used_cap, new_cap - used_cap); unsafe { self.handle_cap_increase(old_cap);

<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. #![feature(global_allocator, alloc_system, allocator_api)] extern crate alloc_system; use std::collections::VecDeque; use alloc_system::System; #[global_allocator] static ALLOCATOR: System = System; fn main() { let mut deque = VecDeque::with_capacity(32); deque.push_front(0); deque.reserve(31); deque.push_back(0); } </ins>
Change:
"capture" makes it sound like the data is stored somewhere for later inspection. There is no field in . I did some looking into the implementation, and to me it seems that the child's stdin is simply closed before waiting. on IRC told me that it's made to be . In any case, this should be clarified. cc
Opened a pull request for this:

Discussion:
/// Executes the command as a child process, waiting for it to finish and /// collecting all of its output. /// <del> /// By default, stdin, stdout and stderr are captured (and used to /// provide the resulting output). </del> <ins> /// By default, stdout and stderr are captured (and used to provide the /// resulting output). Stdin is not inherited from the parent and any /// attempt by the child process to read from the stdin stream will result /// in the stream immediately closing. </ins> /// /// # Examples ///
Change:
Rust learner here, diving into logging, and using my incorrect code. Very helpful and specific error message (OMG, thank you Rust devs!); just has a typo. A two-minute find-and-correct situation. The error message reads: Note the . Should the perhaps be ? Steps to recreate: 1. 1.
Fixed in .

Discussion:
// while maintaining the invariant that all sysroot crates are unstable // by default and are unable to be used. if tcx.sess.opts.debugging_opts.force_unstable_if_unmarked { <del> let reason = "this crate is being loaded from the sysroot, and  </del> <ins> let reason = "this crate is being loaded from the sysroot, an  </ins> unstable location; did you mean to load this crate  from crates.io via `Cargo.toml` instead?"; let stability = tcx.intern_stability(Stability {
Change:
All (non-ignored) debuginfo tests fail when I run $ test src/test/debuginfo Below is the message for one of the tests. They all seem to be the same. Adding a print call to debug the Python traceback reveals that is called with as argument. I'm on the current master () running macOS 10.12.6 and is 2.7.10.
Repro-ed. Looks like an issue in newer version of LLDB when the output is empty (see snare/voltron). I'll just add an to fix it.

Discussion:
if res.Succeeded(): if res.HasResult(): <del> print(normalize_whitespace(res.GetOutput()), end='n') </del> <ins> print(normalize_whitespace(res.GetOutput() or ''), end='n') </ins> # If the command introduced any breakpoints, make sure to register # them with the breakpoint
Change:
This program succeeds on Linux, even though it shouldn't (assuming you don't have a listener on 1234). Trying to do anything with the socket produces .
Interestingly it does behave as expected on macOS.
Works under WSL as well. Native linux it fails spectacularly.
From an strace, it looks like Linux sets all of , , and at once. We treat as success, but it seems like we should be checking for instead:
Fix here:

Discussion:
} #[test] <ins> fn connect_timeout_unbound() { // bind and drop a socket to track down a "probably unassigned" port let socket = TcpListener::bind("127.0.0.1:0").unwrap(); let addr = socket.local_addr().unwrap(); drop(socket); let timeout = Duration::from_secs(1); let e = TcpStream::connect_timeout(&addr, timeout).unwrap_err(); assert!(e.kind() == io::ErrorKind::ConnectionRefused || e.kind() == io::ErrorKind::TimedOut || e.kind() == io::ErrorKind::Other, "bad error: {} {:?}", e, e.kind()); } #[test] </ins> fn connect_timeout_valid() { let listener = TcpListener::bind("127.0.0.1:0").unwrap(); let addr = listener.local_addr().unwrap();

} 0 => {} _ => { <del> if pollfd.revents & libc::POLLOUT == 0 { if let Some(e) = self.take_error()? { return Err(e); } </del> <ins> // linux returns POLLOUT|POLLERR|POLLHUP for refused connections (!), so look // for POLLHUP rather than read readiness if pollfd.revents & libc::POLLHUP != 0 { let e = self.take_error()? .unwrap_or_else(|| { io::Error::new(io::ErrorKind::Other, "no error set after POLLHUP") }); return Err(e); </ins> } return Ok(()); } }
Change:
Currently jemalloc is skipped if system library is specified. We should also do so when use_jemalloc is False.

Discussion:
if not ((module.endswith("llvm") and self.get_toml('llvm-config')) or (module.endswith("jemalloc") and <del> self.get_toml('jemalloc')))] </del> <ins> (self.get_toml('use-jemalloc') == "false" or self.get_toml('jemalloc'))))] </ins> run(["git", "submodule", "update", "--init", "--recursive"] + submodules, cwd=self.rust_root, verbose=self.verbose)
Change:
... but it uses point-free style, not closures. We should probably show both.
I'd like to take care of this one
that'd be great! Do you know what needs to be done, or do you need some help/advice?
If I understand, you want to change by , right?
It would be nice to have both so people still know they can use UFCS syntax (as long as it takes a char and returns a boolean) which is cleaner in trivial cases. Perhaps add an example that looks for a delimiter symbol ()
I'd say "add" rather than change, it's nice to show both. just so you know, it's not UFCS anymore, but .
TIL; Thank you steve!

Discussion:
/// assert_eq!(s.find("Léopard"), Some(13)); /// ``` /// <del> /// More complex patterns with closures: </del> <ins> /// More complex patterns using point-free style and closures: </ins> /// /// ``` /// let s = "Löwe 老虎 Léopard"; /// /// assert_eq!(s.find(char::is_whitespace), Some(5)); /// assert_eq!(s.find(char::is_lowercase), Some(1)); <ins> /// assert_eq!(s.find(|c: char| c.is_whitespace() || c.is_lowercase()), Some(1)); /// assert_eq!(s.find(|c: char| (c < 'o') && (c > 'a')), Some(4)); </ins> /// ``` /// /// Not finding the pattern:
Change:
When running the tests for 1.20.0 on aarch64-unknown-linux-gnu (compiled on Ubuntu 17.10), I get the following failure: Despite the comment in "The math library does not need to be loaded since it is already statically linked in", this does not appear to be the case: My build uses all of the default options (including the vendored llvm). I've not been able to verify whether this is an issue on master yet, because it fails during the build there.
NixOS has applied a patch to disable this test on aarch64 as well.
Now this test is in , but otherwise apparently unchanged. On Fedora, we get failures here on aarch64 and powerpc64le. On the rest of our platforms, shows that they are linked to , but not on aarch64 and powerpc64le. This is true of upstream rust binaries too. I suspect the test doesn't really care about cosine at all. Perhaps it should exercise something more general, like from libc?

Discussion:
use std::mem; #[test] <del> fn test_loading_cosine() { </del> <ins> fn test_loading_atoi() { </ins> if cfg!(windows) { return } <del> // The math library does not need to be loaded since it is already // statically linked in let libm = match DynamicLibrary::open(None) { </del> <ins> // The C library does not need to be loaded since it is already linked in let lib = match DynamicLibrary::open(None) { </ins> Err(error) => panic!("Could not load self as module: {}", error), <del> Ok(libm) => libm </del> <ins> Ok(lib) => lib </ins> }; <del> let cosine: extern fn(libc::c_double) -> libc::c_double = unsafe { match libm.symbol("cos") { Err(error) => panic!("Could not load function cos: {}", error), Ok(cosine) => mem::transmute::<*mut u8, _>(cosine) </del> <ins> let atoi: extern fn(*const libc::c_char) -> libc::c_int = unsafe { match lib.symbol("atoi") { Err(error) => panic!("Could not load function atoi: {}", error), Ok(atoi) => mem::transmute::<*mut u8, _>(atoi) </ins> } }; <del> let argument = 0.0; let expected_result = 1.0; let result = cosine(argument); </del> <ins> let argument = CString::new("1383428980").unwrap(); let expected_result = 0x52757374; let result = atoi(argument.as_ptr()); </ins> if result != expected_result { <del> panic!("cos({}) != {} but equaled {} instead", argument, </del> <ins> panic!("atoi({:?}) != {} but equaled {} instead", argument, </ins> expected_result, result) } }
Change:
Compiling v0.2.10 and v0.4.4 with , I get the following ICEs:
reproduction:

Discussion:
let substituted = self.erase_regions(&substituted); AssociatedTypeNormalizer::new(self).fold(&substituted) } <ins> pub fn trans_apply_param_substs_env<T>( self, param_substs: &Substs<'tcx>, param_env: ty::ParamEnv<'tcx>, value: &T, ) -> T where T: TransNormalize<'tcx>, { debug!( "apply_param_substs_env(param_substs={:?}, value={:?}, param_env={:?})", param_substs, value, param_env, ); let substituted = value.subst(self, param_substs); let substituted = self.erase_regions(&substituted); AssociatedTypeNormalizerEnv::new(self, param_env).fold(&substituted) } </ins> } struct AssociatedTypeNormalizer<'a, 'gcx: 'a> {

} } <ins> struct AssociatedTypeNormalizerEnv<'a, 'gcx: 'a> { tcx: TyCtxt<'a, 'gcx, 'gcx>, param_env: ty::ParamEnv<'gcx>, } impl<'a, 'gcx> AssociatedTypeNormalizerEnv<'a, 'gcx> { fn new(tcx: TyCtxt<'a, 'gcx, 'gcx>, param_env: ty::ParamEnv<'gcx>) -> Self { Self { tcx, param_env } } fn fold<T: TypeFoldable<'gcx>>(&mut self, value: &T) -> T { if !value.has_projections() { value.clone() } else { value.fold_with(self) } } } impl<'a, 'gcx> TypeFolder<'gcx, 'gcx> for AssociatedTypeNormalizerEnv<'a, 'gcx> { fn tcx<'c>(&'c self) -> TyCtxt<'c, 'gcx, 'gcx> { self.tcx } fn fold_ty(&mut self, ty: Ty<'gcx>) -> Ty<'gcx> { if !ty.has_projections() { ty } else { debug!("AssociatedTypeNormalizerEnv: ty={:?}", ty); self.tcx.normalize_associated_type_in_env(&ty, self.param_env) } } } </ins> // Implement DepTrackingMapConfig for `trait_cache` pub struct TraitSelectionCache<'tcx> { data: PhantomData<&'tcx ()>

resolve_associated_item(tcx, &item, param_env, trait_def_id, substs) } else { let ty = tcx.type_of(def_id); <del> let item_type = tcx.trans_apply_param_substs(substs, &ty); </del> <ins> let item_type = tcx.trans_apply_param_substs_env(substs, param_env, &ty); </ins> let def = match item_type.sty { ty::TyFnDef(..) if {

<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. // compile-flags:-Zmir-opt-level=2 trait Array { type Item; } fn foo<A: Array>() { let _: *mut A::Item = std::ptr::null_mut(); } struct Foo; impl Array for Foo { type Item = i32; } fn main() { foo::<Foo>(); } </ins>
Change:
Correct me if I'm wrong, but I don't think it's possible to find out from the currently available online documentation if the following code returns true or false: Is searching for a slice of chars the same as searching for the string of the contatenation? Or is this a set match? There is no information on this in the following places:
If no one is working on it I would be happy to update this.
did you make any progress on this or is it alright for others to work on it?
I think it'd be best if the explanation is put on the page of (and not on the respective impls) so that it is easy to lookup in a central position. A small table and some examples should do such as the ones I've written . I don't know how to do a sanity check compile. Apparently I need to compile all of rustc(?!) to get the docs, which is not feasible for me. If anybody would like to send the PR, they can use my branch as a base. Maybe improve the wording as well.

Discussion:
/// The trait itself acts as a builder for an associated /// `Searcher` type, which does the actual work of finding /// occurrences of the pattern in a string. <ins> /// /// Depending on the type of the pattern, the behaviour of methods like /// [`str::find`] and [`str::contains`] can change. The table below describes /// some of those behaviours. /// /// | Pattern type             | Match condition                           | /// |--------------------------|-------------------------------------------| /// | `&str`                   | is substring                              | /// | `char`                   | is contained in string                    | /// | `&[char]                 | any char in slice is contained in string  | /// | `F: FnMut(char) -> bool` | `F` returns `true` for a char in string   | /// | `&&str`                  | is substring                              | /// | `&String`                | is substring                              | /// /// # Examples /// ``` /// // &str /// assert_eq!("abaaa".find("ba"), Some(1)); /// assert_eq!("abaaa".find("bac"), None); /// /// // char /// assert_eq!("abaaa".find('a'), Some(0)); /// assert_eq!("abaaa".find('b'), Some(1)); /// assert_eq!("abaaa".find('c'), None); /// /// // &[char] /// assert_eq!("ab".find(&['b', 'a'][..]), Some(0)); /// assert_eq!("abaaa".find(&['a', 'z'][..]), Some(0)); /// assert_eq!("abaaa".find(&['c', 'd'][..]), None); /// /// // FnMut(char) -> bool /// assert_eq!("abcdef_z".find(|ch| ch > 'd' && ch < 'y'), Some(4)); /// assert_eq!("abcddd_z".find(|ch| ch > 'd' && ch < 'y'), None); /// ``` /// /// [`str::find`]: ../../../std/primitive.str.html#method.find /// [`str::contains`]: ../../../std/primitive.str.html#method.contains </ins> pub trait Pattern<'a>: Sized { /// Associated searcher for this pattern type Searcher: Searcher<'a>;
Change:
Currently has constructor functions including , , , and . As far as I understand, none of these allow constructing an by moving (rather than copying) all the values from a ~vec. Therefore, I think it would be good if gained a function like: and, for convenience, something like this too: Is this proposal something desirable? If so I will try and submit code/docs/tests.
I merged 's change in

Discussion:
} } <ins> /** * Creates and initializes an immutable managed vector by moving all the * elements from an owned vector. */ fn from_owned<T>(v: ~[T]) -> @[T] { let mut av = @[]; unsafe { raw::reserve(&mut av, v.len()); do vec::consume(v) |_i, x| { raw::push(&mut av, x); } transmute(av) } } /** * Creates and initializes an immutable managed vector by copying all the * elements of a slice. */ fn from_slice<T:Copy>(v: &[T]) -> @[T] { from_fn(v.len(), |i| v[i]) } </ins> #[cfg(notest)] pub mod traits { use at_vec::append;

pub fn append_test() { assert @[1,2,3] + @[4,5,6] == @[1,2,3,4,5,6]; } <ins> #[test] pub fn test_from_owned() { assert from_owned::<int>(~[]) == @[]; assert from_owned(~[true]) == @[true]; assert from_owned(~[1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]; assert from_owned(~[~"abc", ~"123"]) == @[~"abc", ~"123"]; assert from_owned(~[~[42]]) == @[~[42]]; } #[test] pub fn test_from_slice() { assert from_slice::<int>([]) == @[]; assert from_slice([true]) == @[true]; assert from_slice([1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]; assert from_slice([@"abc", @"123"]) == @[@"abc", @"123"]; assert from_slice([@[42]]) == @[@[42]]; } </ins>