Skip to content
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

Add test for #5239 #8800

Closed
wants to merge 1 commit into from
Closed

Add test for #5239 #8800

wants to merge 1 commit into from

Conversation

fhahn
Copy link
Contributor

@fhahn fhahn commented Aug 27, 2013

I've added a test for the second example mentioned in #5239. The first example does not compile with a reasonable error message. Should I add a compile-fail test for that example as well?

/rust/src/test/run-pass/issue-5239.rs:15:45: 15:51 error: binary operation + cannot be applied to type `&int`
rust/src/test/run-pass/issue-5239.rs:15     let _f = |ref x: int| { x += 1};
                                                                                     ^~~~~~

error: aborting due to previous error

@alexcrichton
Copy link
Member

Could you add Closes #5239 into the commit message? That way it'll be conveniently closed when the commit is merged into master.

Also, I think you can remove the comment about it being a "bogus ref" because it's a legitimate way to write a pattern binding.

I think that it'd also be a good idea to add a test for the original code as well as compile-fail, thanks!

@fhahn
Copy link
Contributor Author

fhahn commented Aug 28, 2013

I've added a compile-fail test and updated the commit message.

@catamorphism
Copy link
Contributor

Looks like the same problem as #8458

bors added a commit that referenced this pull request Aug 29, 2013
I've added a test for the second example mentioned in #5239. The first example does not compile with a reasonable error message. Should I add a compile-fail test for that example as well?

    /rust/src/test/run-pass/issue-5239.rs:15:45: 15:51 error: binary operation + cannot be applied to type `&int`
    rust/src/test/run-pass/issue-5239.rs:15     let _f = |ref x: int| { x += 1};
                                                                                         ^~~~~~

    error: aborting due to previous error
@bors bors closed this Aug 29, 2013
@fhahn fhahn deleted the ticket_5239 branch January 7, 2014 17:35
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jun 30, 2022
…, r=Manishearth

add vec.capacity() to [`slow_vec_initialization`] detection

fix rust-lang#8800

for example
```rust
let mut vec1 = Vec::with_capacity(len);
vec1.resize(vec1.capacity(), 0);

let mut vec2 = Vec::with_capacity(len);
vec2.extend(repeat(0).take(vec2.capacity()));
```
will trigger the lint

---

changelog: add `vec.capacity()` to [`slow_vec_initialization`] detection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants