-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std::str::Bytes
should implement Clone
#12677
Comments
This was referenced Dec 13, 2014
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Dec 17, 2014
closes rust-lang#12677 (cc @Valloric) cc rust-lang#15294 r? @aturon / @alexcrichton (Because of rust-lang#19358 I had to move the struct bounds from the `where` clause into the parameter list)
nikomatsakis
added a commit
to nikomatsakis/rust
that referenced
this issue
Dec 19, 2014
though it includes a `fn()`. This is really a more general problem but I wanted to ensures that `bytes` in particular remains working due to rust-lang#12677.
flip1995
pushed a commit
to flip1995/rust
that referenced
this issue
Jun 13, 2024
Let `qualify_min_const_fn` deal with drop terminators Fixes rust-lang#12677 The `method_accepts_droppable` check that was there seemed overly conservative. > Returns true if any of the method parameters is a type that implements `Drop`. > The method can't be made const then, because `drop` can't be const-evaluated. Accepting parameters that implement `Drop` should still be fine as long as the parameter isn't actually dropped, as is the case in the linked issue where the droppable is moved into the return place. This more accurate analysis ("is there a `drop` terminator") is already done by `qualify_min_const_fn` [here](https://github.com/rust-lang/rust-clippy/blob/f5e250180c342bb52808c9a934c962a8fe40afc7/clippy_utils/src/qualify_min_const_fn.rs#L298), so I don't think this additional check is really necessary? Fixing the other, second case in the linked issue was only slightly more involved, since `Vec::new()` is a function call that has the ability to panic, so there must be a `drop()` terminator for cleanup, however we should be able to freely ignore that. [Const checking ignores cleanup blocks](https://github.com/rust-lang/rust/blob/master/compiler/rustc_const_eval/src/transform/check_consts/check.rs#L382-L388), so we should, too? r? `@Jarcho` ---- changelog: [`missing_const_for_fn`]: continue linting on fns with parameters implementing `Drop` if they're not actually dropped
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Calling
chars()
on a&str
results in an iterator that can be cloned. Callingbytes()
doesn't. This makes it very difficult to port code that uses the first to use the second.The text was updated successfully, but these errors were encountered: