rust/src/test/ui/issues/issue-66667-function-cmp-cycle.rs
Aaron Hill ff65bffe2b
Fix cycle error when emitting suggestion for mismatched fn type
Fixes #66667

Previously, we called `tcx.typeck_tables_of` when determining whether or
not to emit a suggestion for a type error. However, we might already be
type-checking the `DefId` we pass to `typeck_tables_of` (it could be
anywhere in the query stack).

Fortunately, we only need the function signature, not the entire
`TypeckTables`. By using `tcx.fn_sig`, we avoid the possibility of cycle
errors while retaining the ability to emit a suggestion.
2020-03-11 15:35:46 -04:00

16 lines
281 B
Rust

fn first() {
second == 1 //~ ERROR binary operation
//~^ ERROR mismatched types
}
fn second() {
first == 1 //~ ERROR binary operation
//~^ ERROR mismatched types
}
fn bar() {
bar == 1 //~ ERROR binary operation
//~^ ERROR mismatched types
}
fn main() {}