jiebi/CodeConvo huggingface dataset:
Code change:
The method on iterators consumes the first falsy value, instead of leaving it in the iterator. This behavior seems unintuitive to me; and I could not find any documentation of this functionality. Due to this (I think) being a breaking change, it's probably not worth changing the functionality, but documenting this is probably a good idea. I tried code: I expected to see this output: Instead, this I saw this output: : I believe this also occurs on stable (tested in ).
Not only would it be a breaking change, but it is impossible for a general iterator: the only way to tell if needs to stop or not is to get the element out of the iterator with , and there's no way to uncall /push an element back on to the end. (E.g. consider something like : once the message has been received and yielded, it is gone.)
For people reaching here and seeking a way to do this currently, provides a that will leave the last element in the iterator, but at the cost of cloning the entire iterator every iteration.
Well, maybe we can put the first falsy value to inside and add an accessor to it...
The cost of cloning an iterator is totally depedent on which iterator it is. A slice iterator is implemented using two pointers, so the cloning amounts to storing two pointers during the iteration. When the whole iteration is inlined, and llvm breaking the structs down to their members, it should be able to remove the store of the pointer that doesn't change (the end), so the overhead is down to storing and restoring one pointer.
is a nice hack, but it should be complemented by either adaptors on Peekable and/or itertools' PutBack.

Related discussion:
text: /// // got a false, take_while() isn't used any more /// assert_eq!(iter.next(), None); /// ``` <ins> /// /// Because `take_while()` needs to look at the value in order to see if it /// should be included or not, consuming iterators will see that it is /// removed: /// /// ``` /// let a = [1, 2, 3, 4]; /// let mut iter = a.into_iter(); /// /// let result: Vec<i32> = iter.by_ref() ///                            .take_while(|n| **n != 3) ///                            .cloned() ///                            .collect(); /// /// assert_eq!(result, &[1, 2]); /// /// let result: Vec<i32> = iter.cloned().collect(); /// /// assert_eq!(result, &[4]); /// ``` /// /// The `3` is no longer there, because it was consumed in order to see if /// the iteration should stop, but wasn't placed back into the iterator or /// some similar thing. </ins> #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
Code change:
For clippy's lint, I made use of a so I could stop clippy from linting the same macro multiple times while being reasonably fast. However, this unfortunately means the lint ignores .. attributes below the crate level. To solve this and other related problems, I propose any of allow a lint to check anything from anywhere in the analysis by moving up the parent chain to check the level allow a lint to opt out of calls for the duration of a specific node including its child nodes add methods to the {Early, Late}LintPass trait, so lints can decide themselves The third option is probably the easiest to implement, yet the most flexible. This would bring the trait closer to other stream parser implementations like SAX.
Seeing that we already have a few, _post methods, I think adding some more will be an acceptable solution here. I'll have a PR shortly.

Related discussion:
text: run_lints!(cx, check_item, late_passes, it); cx.visit_ids(|v| v.visit_item(it)); hir_visit::walk_item(cx, it); <ins> run_lints!(cx, check_item_post, late_passes, it); </ins> }) }
Code change:
For clippy's lint, I made use of a so I could stop clippy from linting the same macro multiple times while being reasonably fast. However, this unfortunately means the lint ignores .. attributes below the crate level. To solve this and other related problems, I propose any of allow a lint to check anything from anywhere in the analysis by moving up the parent chain to check the level allow a lint to opt out of calls for the duration of a specific node including its child nodes add methods to the {Early, Late}LintPass trait, so lints can decide themselves The third option is probably the easiest to implement, yet the most flexible. This would bring the trait closer to other stream parser implementations like SAX.
Seeing that we already have a few, _post methods, I think adding some more will be an acceptable solution here. I'll have a PR shortly.

Related discussion:
text: fn visit_block(&mut self, b: &hir::Block) { run_lints!(self, check_block, late_passes, b); hir_visit::walk_block(self, b); <ins> run_lints!(self, check_block_post, late_passes, b); </ins> } fn visit_arm(&mut self, a: &hir::Arm) {
Code change:
For clippy's lint, I made use of a so I could stop clippy from linting the same macro multiple times while being reasonably fast. However, this unfortunately means the lint ignores .. attributes below the crate level. To solve this and other related problems, I propose any of allow a lint to check anything from anywhere in the analysis by moving up the parent chain to check the level allow a lint to opt out of calls for the duration of a specific node including its child nodes add methods to the {Early, Late}LintPass trait, so lints can decide themselves The third option is probably the easiest to implement, yet the most flexible. This would bring the trait closer to other stream parser implementations like SAX.
Seeing that we already have a few, _post methods, I think adding some more will be an acceptable solution here. I'll have a PR shortly.

Related discussion:
text: run_lints!(cx, check_item, early_passes, it); cx.visit_ids(|v| v.visit_item(it)); ast_visit::walk_item(cx, it); <ins> run_lints!(cx, check_item_post, early_passes, it); </ins> }) }
Code change:
For clippy's lint, I made use of a so I could stop clippy from linting the same macro multiple times while being reasonably fast. However, this unfortunately means the lint ignores .. attributes below the crate level. To solve this and other related problems, I propose any of allow a lint to check anything from anywhere in the analysis by moving up the parent chain to check the level allow a lint to opt out of calls for the duration of a specific node including its child nodes add methods to the {Early, Late}LintPass trait, so lints can decide themselves The third option is probably the easiest to implement, yet the most flexible. This would bring the trait closer to other stream parser implementations like SAX.
Seeing that we already have a few, _post methods, I think adding some more will be an acceptable solution here. I'll have a PR shortly.

Related discussion:
text: fn visit_block(&mut self, b: &ast::Block) { run_lints!(self, check_block, early_passes, b); ast_visit::walk_block(self, b); <ins> run_lints!(self, check_block_post, early_passes, b); </ins> } fn visit_arm(&mut self, a: &ast::Arm) {
Code change:
For clippy's lint, I made use of a so I could stop clippy from linting the same macro multiple times while being reasonably fast. However, this unfortunately means the lint ignores .. attributes below the crate level. To solve this and other related problems, I propose any of allow a lint to check anything from anywhere in the analysis by moving up the parent chain to check the level allow a lint to opt out of calls for the duration of a specific node including its child nodes add methods to the {Early, Late}LintPass trait, so lints can decide themselves The third option is probably the easiest to implement, yet the most flexible. This would bring the trait closer to other stream parser implementations like SAX.
Seeing that we already have a few, _post methods, I think adding some more will be an acceptable solution here. I'll have a PR shortly.

Related discussion:
text: run_lints!(cx, check_crate, late_passes, krate); hir_visit::walk_crate(cx, krate); <ins> run_lints!(cx, check_crate_post, late_passes, krate); </ins> }); // If we missed any lints added to the session, then there's a bug somewhere
Code change:
For clippy's lint, I made use of a so I could stop clippy from linting the same macro multiple times while being reasonably fast. However, this unfortunately means the lint ignores .. attributes below the crate level. To solve this and other related problems, I propose any of allow a lint to check anything from anywhere in the analysis by moving up the parent chain to check the level allow a lint to opt out of calls for the duration of a specific node including its child nodes add methods to the {Early, Late}LintPass trait, so lints can decide themselves The third option is probably the easiest to implement, yet the most flexible. This would bring the trait closer to other stream parser implementations like SAX.
Seeing that we already have a few, _post methods, I think adding some more will be an acceptable solution here. I'll have a PR shortly.

Related discussion:
text: run_lints!(cx, check_crate, early_passes, krate); ast_visit::walk_crate(cx, krate); <ins> run_lints!(cx, check_crate_post, early_passes, krate); </ins> }); // Put the lint store back in the session.
Code change:
For clippy's lint, I made use of a so I could stop clippy from linting the same macro multiple times while being reasonably fast. However, this unfortunately means the lint ignores .. attributes below the crate level. To solve this and other related problems, I propose any of allow a lint to check anything from anywhere in the analysis by moving up the parent chain to check the level allow a lint to opt out of calls for the duration of a specific node including its child nodes add methods to the {Early, Late}LintPass trait, so lints can decide themselves The third option is probably the easiest to implement, yet the most flexible. This would bring the trait closer to other stream parser implementations like SAX.
Seeing that we already have a few, _post methods, I think adding some more will be an acceptable solution here. I'll have a PR shortly.

Related discussion:
text: pub trait LateLintPass: LintPass { fn check_name(&mut self, _: &LateContext, _: Span, _: ast::Name) { } fn check_crate(&mut self, _: &LateContext, _: &hir::Crate) { } <ins> fn check_crate_post(&mut self, _: &LateContext, _: &hir::Crate) { } </ins> fn check_mod(&mut self, _: &LateContext, _: &hir::Mod, _: Span, _: ast::NodeId) { } fn check_foreign_item(&mut self, _: &LateContext, _: &hir::ForeignItem) { } fn check_item(&mut self, _: &LateContext, _: &hir::Item) { } <ins> fn check_item_post(&mut self, _: &LateContext, _: &hir::Item) { } </ins> fn check_local(&mut self, _: &LateContext, _: &hir::Local) { } fn check_block(&mut self, _: &LateContext, _: &hir::Block) { } <ins> fn check_block_post(&mut self, _: &LateContext, _: &hir::Block) { } </ins> fn check_stmt(&mut self, _: &LateContext, _: &hir::Stmt) { } fn check_arm(&mut self, _: &LateContext, _: &hir::Arm) { } fn check_pat(&mut self, _: &LateContext, _: &hir::Pat) { }
Code change:
For clippy's lint, I made use of a so I could stop clippy from linting the same macro multiple times while being reasonably fast. However, this unfortunately means the lint ignores .. attributes below the crate level. To solve this and other related problems, I propose any of allow a lint to check anything from anywhere in the analysis by moving up the parent chain to check the level allow a lint to opt out of calls for the duration of a specific node including its child nodes add methods to the {Early, Late}LintPass trait, so lints can decide themselves The third option is probably the easiest to implement, yet the most flexible. This would bring the trait closer to other stream parser implementations like SAX.
Seeing that we already have a few, _post methods, I think adding some more will be an acceptable solution here. I'll have a PR shortly.

Related discussion:
text: pub trait EarlyLintPass: LintPass { fn check_ident(&mut self, _: &EarlyContext, _: Span, _: ast::Ident) { } fn check_crate(&mut self, _: &EarlyContext, _: &ast::Crate) { } <ins> fn check_crate_post(&mut self, _: &EarlyContext, _: &ast::Crate) { } </ins> fn check_mod(&mut self, _: &EarlyContext, _: &ast::Mod, _: Span, _: ast::NodeId) { } fn check_foreign_item(&mut self, _: &EarlyContext, _: &ast::ForeignItem) { } fn check_item(&mut self, _: &EarlyContext, _: &ast::Item) { } <ins> fn check_item_post(&mut self, _: &EarlyContext, _: &ast::Item) { } </ins> fn check_local(&mut self, _: &EarlyContext, _: &ast::Local) { } fn check_block(&mut self, _: &EarlyContext, _: &ast::Block) { } <ins> fn check_block_post(&mut self, _: &EarlyContext, _: &ast::Block) { } </ins> fn check_stmt(&mut self, _: &EarlyContext, _: &ast::Stmt) { } fn check_arm(&mut self, _: &EarlyContext, _: &ast::Arm) { } fn check_pat(&mut self, _: &EarlyContext, _: &ast::Pat) { }
Code change:
The documentation of the unstable function makes a reference to , but this function does not exist (anymore?). Expressing the semantics of in terms of something that does not exist is unhelpful. The problem seems to be located . I imagine the fix would involve traveling back in time until before was removed and copying its documentation, after correcting for the differences between it and the function.
Filling drop is a temporary "feature" of rust, and in the long run this function will not be needed once the in-struct drop flags are gone. In anticipation of this improvement, it would be best to not write any code that relies on readanddrop. Edit: Well maybe that's exactly what to have in the docs..
I'm not using that function, I was merely browsing the docs and noticed the documentation was wrong. I would expect the documentation of functions to be correct even if they are unstable and scheduled for removal, unless the removal is scheduled for the immediate future.

Related discussion:
text: tmp } <del> /// Variant of read_and_zero that writes the specific drop-flag byte /// (which may be more appropriate than zero). </del> <ins> #[allow(missing_docs)] </ins> #[inline(always)] #[unstable(feature = "filling_drop", reason = "may play a larger role in std::ptr future extensions",
Code change:
In a few places in there are casts from to or for Windows APIs which causes breakage on 64-bit. Some examples I have found so far: () () (rust-lang-nursery/rand, ) There may be more.
Well I didn't find any more so I'll close this.

Related discussion:
text: use prelude::v1::*; <ins> use cmp; </ins> use ffi::{CStr, CString}; use fmt; use io::{self, Error, ErrorKind};
Code change:
In a few places in there are casts from to or for Windows APIs which causes breakage on 64-bit. Some examples I have found so far: () () (rust-lang-nursery/rand, ) There may be more.
Well I didn't find any more so I'll close this.

Related discussion:
text: } pub fn write(&self, buf: &[u8]) -> io::Result<usize> { <ins> let len = cmp::min(buf.len(), <wrlen_t>::max_value() as usize) as wrlen_t; </ins> let ret = try!(cvt(unsafe { c::send(*self.inner.as_inner(), buf.as_ptr() as *const c_void, <del> buf.len() as wrlen_t, </del> <ins> len, </ins> 0) })); Ok(ret as usize)
Code change:
In a few places in there are casts from to or for Windows APIs which causes breakage on 64-bit. Some examples I have found so far: () () (rust-lang-nursery/rand, ) There may be more.
Well I didn't find any more so I'll close this.

Related discussion:
text: pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> { let mut storage: c::sockaddr_storage = unsafe { mem::zeroed() }; let mut addrlen = mem::size_of_val(&storage) as c::socklen_t; <ins> let len = cmp::min(buf.len(), <wrlen_t>::max_value() as usize) as wrlen_t; </ins> let n = try!(cvt(unsafe { c::recvfrom(*self.inner.as_inner(), buf.as_mut_ptr() as *mut c_void, <del> buf.len() as wrlen_t, 0, </del> <ins> len, 0, </ins> &mut storage as *mut _ as *mut _, &mut addrlen) })); Ok((n as usize, try!(sockaddr_to_addr(&storage, addrlen as usize)))) } pub fn send_to(&self, buf: &[u8], dst: &SocketAddr) -> io::Result<usize> { <ins> let len = cmp::min(buf.len(), <wrlen_t>::max_value() as usize) as wrlen_t; </ins> let (dstp, dstlen) = dst.into_inner(); let ret = try!(cvt(unsafe { c::sendto(*self.inner.as_inner(), <del> buf.as_ptr() as *const c_void, buf.len() as wrlen_t, </del> <ins> buf.as_ptr() as *const c_void, len, </ins> 0, dstp, dstlen) })); Ok(ret as usize)
Code change:
In a few places in there are casts from to or for Windows APIs which causes breakage on 64-bit. Some examples I have found so far: () () (rust-lang-nursery/rand, ) There may be more.
Well I didn't find any more so I'll close this.

Related discussion:
text: // option. This file may not be copied, modified, or distributed // except according to those terms. <ins> use cmp; </ins> use io; use libc::{c_int, c_void}; use mem;
Code change:
In a few places in there are casts from to or for Windows APIs which causes breakage on 64-bit. Some examples I have found so far: () () (rust-lang-nursery/rand, ) There may be more.
Well I didn't find any more so I'll close this.

Related discussion:
text: pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> { // On unix when a socket is shut down all further reads return 0, so we // do the same on windows to map a shut down socket to returning EOF. <ins> let len = cmp::min(buf.len(), i32::max_value() as usize) as i32; </ins> unsafe { <del> match c::recv(self.0, buf.as_mut_ptr() as *mut c_void, buf.len() as i32, 0) { </del> <ins> match c::recv(self.0, buf.as_mut_ptr() as *mut c_void, len, 0) { </ins> -1 if c::WSAGetLastError() == c::WSAESHUTDOWN => Ok(0), -1 => Err(last_error()), n => Ok(n as usize)
Code change:
Travis-CI build failed, my local builds with a slightly older rustc nightly works just fine. This is the repository in question and the Travis-CI build log: Repo: Travis-CI Log: rustc only seems to fail when compiling my crate: Could be related to , a way older and closed issue. (rustc 0.13.0-dev) Backtrace:
cc
Related: arcnmx/cargo-clippy/issues/19

Related discussion:
text: // Define the name or return the existing binding if there is a collision. pub fn try_define_child(&self, name: Name, ns: Namespace, binding: NameBinding<'a>) -> Result<(), &'a NameBinding<'a>> { <del> if self.resolutions.borrow_state() != ::std::cell::BorrowState::Unused { return Ok(()); } </del> self.update_resolution(name, ns, |resolution| { resolution.try_define(self.arenas.alloc_name_binding(binding)) })
Code change:
Travis-CI build failed, my local builds with a slightly older rustc nightly works just fine. This is the repository in question and the Travis-CI build log: Repo: Travis-CI Log: rustc only seems to fail when compiling my crate: Could be related to , a way older and closed issue. (rustc 0.13.0-dev) Backtrace:
cc
Related: arcnmx/cargo-clippy/issues/19

Related discussion:
text: fn update_resolution<T, F>(&self, name: Name, ns: Namespace, update: F) -> T where F: FnOnce(&mut NameResolution<'a>) -> T { <del> let mut resolution = &mut *self.resolution(name, ns).borrow_mut(); let was_known = resolution.binding().is_some(); let t = update(resolution); if !was_known { if let Some(binding) = resolution.binding() { self.define_in_glob_importers(name, ns, binding); </del> <ins> // Ensure that `resolution` isn't borrowed during `define_in_glob_importers`, // where it might end up getting re-defined via a glob cycle. let (new_binding, t) = { let mut resolution = &mut *self.resolution(name, ns).borrow_mut(); let was_known = resolution.binding().is_some(); let t = update(resolution); if was_known { return t; } match resolution.binding() { Some(binding) => (binding, t), None => return t, </ins> } <del> } </del> <ins> }; self.define_in_glob_importers(name, ns, new_binding); </ins> t }
Code change:
Travis-CI build failed, my local builds with a slightly older rustc nightly works just fine. This is the repository in question and the Travis-CI build log: Repo: Travis-CI Log: rustc only seems to fail when compiling my crate: Could be related to , a way older and closed issue. (rustc 0.13.0-dev) Backtrace:
cc
Related: arcnmx/cargo-clippy/issues/19

Related discussion:
text: // Add to target_module's glob_importers target_module.glob_importers.borrow_mut().push((module_, directive)); <del> for (&(name, ns), resolution) in target_module.resolutions.borrow().iter() { if let Some(binding) = resolution.borrow().binding() { if binding.defined_with(DefModifiers::IMPORTABLE | DefModifiers::PUBLIC) { let _ = module_.try_define_child(name, ns, directive.import(binding, None)); } </del> <ins> // Ensure that `resolutions` isn't borrowed during `try_define_child`, // since it might get updated via a glob cycle. let bindings = target_module.resolutions.borrow().iter().filter_map(|(name, resolution)| { resolution.borrow().binding().map(|binding| (*name, binding)) }).collect::<Vec<_>>(); for ((name, ns), binding) in bindings { if binding.defined_with(DefModifiers::IMPORTABLE | DefModifiers::PUBLIC) { let _ = module_.try_define_child(name, ns, directive.import(binding, None)); </ins> } }
Code change:
Travis-CI build failed, my local builds with a slightly older rustc nightly works just fine. This is the repository in question and the Travis-CI build log: Repo: Travis-CI Log: rustc only seems to fail when compiling my crate: Could be related to , a way older and closed issue. (rustc 0.13.0-dev) Backtrace:
cc
Related: arcnmx/cargo-clippy/issues/19

Related discussion:
text: <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. mod foo { pub use bar::*; pub use main as f; //~ ERROR has already been imported } mod bar { pub use foo::*; } pub use foo::*; pub use baz::*; //~ ERROR has already been imported mod baz { pub use super::*; } pub fn main() {} </ins>
Code change:
Travis-CI build failed, my local builds with a slightly older rustc nightly works just fine. This is the repository in question and the Travis-CI build log: Repo: Travis-CI Log: rustc only seems to fail when compiling my crate: Could be related to , a way older and closed issue. (rustc 0.13.0-dev) Backtrace:
cc
Related: arcnmx/cargo-clippy/issues/19

Related discussion:
text: <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. pub use bar::*; mod bar { pub use super::*; } pub use baz::*; //~ ERROR already been imported mod baz { pub use main as f; } pub fn main() {} </ins>