Skip to content

Conversation

@nikomatsakis
Copy link
Contributor

Refactor trans_call to separate out the translation of the arguments, environment, and return pointer. Towards #3678. r? @brson

bors added a commit that referenced this pull request Mar 20, 2013
…l, r=graydon

Refactor trans_call to separate out the translation of the arguments, environment, and return pointer.  Towards #3678.  r? @brson
@bors bors closed this Mar 20, 2013
@bors bors merged commit e821671 into rust-lang:incoming Mar 20, 2013
@nikomatsakis nikomatsakis deleted the issue-3678-refactor-trans_call branch March 30, 2016 16:15
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.

3 participants