Unnamed repository; edit this file 'description' to name the repository.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};

// Diagnostic: infer-vars-not-allowed
//
// This diagnostic is triggered when `_` is used where type
// inference is not allowed.
pub(crate) fn infer_vars_not_allowed(
    ctx: &DiagnosticsContext<'_, '_>,
    d: &hir::InferVarsNotAllowed,
) -> Diagnostic {
    Diagnostic::new_with_syntax_node_ptr(
        ctx,
        DiagnosticCode::RustcHardError("E0121"),
        "the type placeholder `_` is not allowed within types on item signatures",
        d.node,
    )
}
#[cfg(test)]
mod tests {
    use crate::tests::check_diagnostics;
    #[test]
    fn type_alias() {
        check_diagnostics(
            r#"
type Foo = _;
        // ^ error: the type placeholder `_` is not allowed within types on item signatures
        "#,
        );
    }
    #[test]
    fn const_item() {
        check_diagnostics(
            r#"
const X: _ = 0;
      // ^ error: the type placeholder `_` is not allowed within types on item signatures
        "#,
        );
    }

    #[test]
    fn static_item() {
        check_diagnostics(
            r#"
static Y: _ = 0;
       // ^ error: the type placeholder `_` is not allowed within types on item signatures
        "#,
        );
    }
}