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

auto: librustc: Make monomorphic newtype structs work cross-crate #4892

Closed
wants to merge 1 commit into from

Conversation

pcwalton
Copy link
Contributor

r? @brson

@bors bors closed this Feb 13, 2013
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 18, 2020
Changes:
````
Polished lint and tests
Added final lint and tests
Added basic lint and tests
fix redundant_pattern_matching lint
add lint futures_not_send
Integrate more idiomatic rust changes.
Fix issue rust-lang#4892.
cargo dev fmt
Cleanup: Rename 'db' variable to 'diag'
question_mark: don't add `as_ref()` for a call expression
unit_arg suggestion may be incorrect
readme: update to cargo clippy --fix command
CI: performing system upgrade fixes broken apt deps on ubuntu 32bit
Do not lint in macros for match lints
[fix] Minor typo in GH Actions 'clippy_dev'
Reenable rustfmt integration test
Add test to map_flatten with an Option
Lint map_flatten if caller is an Option
Apply suggestions from code review
manually fixing formatting at this point lol
fmt
rename field
revert the damn fmt changes
add some tests
split it up for testing but the merge broke tests
dogfood tasted bad
fix rustfmt issue
boycott manish
check for unstable options
Start work on clippy-fix as subcommand
````
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 18, 2020
submodules: update clippy from 6651c1b to 891e1a8

This PR gets `cargo clippy --fix -Zunstable-options` into nightly 🎉

Changes:
````
Polished lint and tests
Added final lint and tests
Added basic lint and tests
fix redundant_pattern_matching lint
add lint futures_not_send
Integrate more idiomatic rust changes.
Fix issue rust-lang#4892.
cargo dev fmt
Cleanup: Rename 'db' variable to 'diag'
question_mark: don't add `as_ref()` for a call expression
unit_arg suggestion may be incorrect
readme: update to cargo clippy --fix command
CI: performing system upgrade fixes broken apt deps on ubuntu 32bit
Do not lint in macros for match lints
[fix] Minor typo in GH Actions 'clippy_dev'
Reenable rustfmt integration test
Add test to map_flatten with an Option
Lint map_flatten if caller is an Option
Apply suggestions from code review
manually fixing formatting at this point lol
fmt
rename field
revert the damn fmt changes
add some tests
split it up for testing but the merge broke tests
dogfood tasted bad
fix rustfmt issue
boycott manish
check for unstable options
Start work on clippy-fix as subcommand
````

Should be save to rollup since we are in no-toolstate-break week (I also didn't see any breakage when testing the clippy with  28742a1)
oli-obk pushed a commit to oli-obk/rust that referenced this pull request May 2, 2020
oli-obk pushed a commit to oli-obk/rust that referenced this pull request May 2, 2020
Fixes issue rust-lang#4892.

First contribution here 😊 ! Do not hesitate to correct me.

This PR is related to issue rust-lang#4892 .

# Summary

```rust
-literal.method_call(args)
```
The main idea is to not trigger `clippy::precedence` when the method call is an odd function.

# Example

```rust
// should trigger lint
let _ = -1.0_f64.abs() //precedence of method call abs() and neg ('-') is ambiguous

// should not trigger lint
let _ = -1.0_f64.sin() // sin is an odd function => -sin(x) = sin(-x)
```

# Theory

Rust allows following literals:
- char
- string
- integers
- floats
- byte
- bool

Only integers/floats implements the relevant `std::ops::Neg`.
Following odd functions are implemented on i[8-128] and/or f[32-64]:
- `asin`
- `asinh`
- `atan`
- `atanh`
- `cbrt`
- `fract`
- `round`
- `signum`
- `sin`
- `sinh`
- `tan`
- `tanh `
- `to_degrees`
- `to_radians`

# Implementation

As suggested by `flip1995` in [comment](rust-lang/rust-clippy#4892 (comment)), this PR add a whitelist of odd functions and compare method call to the the whitelist before triggering lint.

changelog: Don't trigger [`clippy::precedence`] on odd functions.
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.

2 participants