summaryrefslogtreecommitdiffstats
path: root/tests/ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.rs
blob: 7f6758f47f8fe4cf1c89f6f27011af67b7d720b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// ignore-tidy-linelength

// Regression test for #107745.
// Previously need_type_info::update_infer_source will consider expressions originating from
// macro expressions as candiate "previous sources". This unfortunately can mean that
// for macros expansions such as `format!()` internal implementation details can leak, such as:
//
// ```
// error[E0282]: type annotations needed
// --> src/main.rs:2:22
//  |
//2 |     println!("{:?}", []);
//  |                      ^^ cannot infer type of the type parameter `T` declared on the associated function `new_debug`
// ```

fn main() {
    println!("{:?}", []);
    //~^ ERROR type annotations needed
}