-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This operation does not do what people usually want. Also check against other comparison operators since they are just as sketchy. Allow the `ty_eq_operator` lint for now until the next bootstrap bump
- Loading branch information
Showing
7 changed files
with
165 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// compile-flags: -Z unstable-options | ||
|
||
#![feature(rustc_attrs)] | ||
#![forbid(rustc::ty_compare_operator)] | ||
|
||
mod ty1 { | ||
#[derive(PartialEq, PartialOrd)] | ||
#[rustc_diagnostic_item = "Ty"] | ||
pub struct Ty; | ||
} | ||
|
||
mod ty2 { | ||
#[derive(PartialEq, PartialOrd)] | ||
pub struct Ty; | ||
} | ||
|
||
fn main() { | ||
let _ = ty1::Ty == ty1::Ty; | ||
//~^ ERROR using the a comparison operator on `Ty` | ||
let _ = ty1::Ty != ty1::Ty; | ||
//~^ ERROR using the a comparison operator on `Ty` | ||
let _ = ty1::Ty < ty1::Ty; | ||
//~^ ERROR using the a comparison operator on `Ty` | ||
let _ = ty1::Ty <= ty1::Ty; | ||
//~^ ERROR using the a comparison operator on `Ty` | ||
let _ = ty1::Ty > ty1::Ty; | ||
//~^ ERROR using the a comparison operator on `Ty` | ||
let _ = ty1::Ty >= ty1::Ty; | ||
//~^ ERROR using the a comparison operator on `Ty` | ||
|
||
let _ = ty2::Ty == ty2::Ty; | ||
let _ = ty2::Ty != ty2::Ty; | ||
let _ = ty2::Ty < ty2::Ty; | ||
let _ = ty2::Ty <= ty2::Ty; | ||
let _ = ty2::Ty > ty2::Ty; | ||
let _ = ty2::Ty >= ty2::Ty; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
error: using the a comparison operator on `Ty` | ||
--> $DIR/ty_compare_operator.rs:18:21 | ||
| | ||
LL | let _ = ty1::Ty == ty1::Ty; | ||
| ^^ | ||
| | ||
= note: this does probably not what you want as it does not handle inference variables and more | ||
= note: it's also not recommended to use it for diagnostics | ||
= help: for more information, see https://rustc-dev-guide.rust-lang.org/ty.html#comparing-types | ||
note: the lint level is defined here | ||
--> $DIR/ty_compare_operator.rs:4:11 | ||
| | ||
LL | #![forbid(rustc::ty_compare_operator)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: using the a comparison operator on `Ty` | ||
--> $DIR/ty_compare_operator.rs:20:21 | ||
| | ||
LL | let _ = ty1::Ty != ty1::Ty; | ||
| ^^ | ||
| | ||
= note: this does probably not what you want as it does not handle inference variables and more | ||
= note: it's also not recommended to use it for diagnostics | ||
= help: for more information, see https://rustc-dev-guide.rust-lang.org/ty.html#comparing-types | ||
|
||
error: using the a comparison operator on `Ty` | ||
--> $DIR/ty_compare_operator.rs:22:21 | ||
| | ||
LL | let _ = ty1::Ty < ty1::Ty; | ||
| ^ | ||
| | ||
= note: this does probably not what you want as it does not handle inference variables and more | ||
= note: it's also not recommended to use it for diagnostics | ||
= help: for more information, see https://rustc-dev-guide.rust-lang.org/ty.html#comparing-types | ||
|
||
error: using the a comparison operator on `Ty` | ||
--> $DIR/ty_compare_operator.rs:24:21 | ||
| | ||
LL | let _ = ty1::Ty <= ty1::Ty; | ||
| ^^ | ||
| | ||
= note: this does probably not what you want as it does not handle inference variables and more | ||
= note: it's also not recommended to use it for diagnostics | ||
= help: for more information, see https://rustc-dev-guide.rust-lang.org/ty.html#comparing-types | ||
|
||
error: using the a comparison operator on `Ty` | ||
--> $DIR/ty_compare_operator.rs:26:21 | ||
| | ||
LL | let _ = ty1::Ty > ty1::Ty; | ||
| ^ | ||
| | ||
= note: this does probably not what you want as it does not handle inference variables and more | ||
= note: it's also not recommended to use it for diagnostics | ||
= help: for more information, see https://rustc-dev-guide.rust-lang.org/ty.html#comparing-types | ||
|
||
error: using the a comparison operator on `Ty` | ||
--> $DIR/ty_compare_operator.rs:28:21 | ||
| | ||
LL | let _ = ty1::Ty >= ty1::Ty; | ||
| ^^ | ||
| | ||
= note: this does probably not what you want as it does not handle inference variables and more | ||
= note: it's also not recommended to use it for diagnostics | ||
= help: for more information, see https://rustc-dev-guide.rust-lang.org/ty.html#comparing-types | ||
|
||
error: aborting due to 6 previous errors | ||
|