Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #22282 from ChayimFriedman2/reserve-impl
fix: Catch `#[rustc_reservation_impl = "reason"]`
| -rw-r--r-- | crates/hir-def/src/attrs.rs | 1 | ||||
| -rw-r--r-- | crates/ide-diagnostics/src/handlers/type_must_be_known.rs | 22 |
2 files changed, 23 insertions, 0 deletions
diff --git a/crates/hir-def/src/attrs.rs b/crates/hir-def/src/attrs.rs index 43bbe99b13..90fae16ccd 100644 --- a/crates/hir-def/src/attrs.rs +++ b/crates/hir-def/src/attrs.rs @@ -140,6 +140,7 @@ fn match_attr_flags(attr_flags: &mut AttrFlags, attr: ast::Meta) -> ControlFlow< "must_use" => attr_flags.insert(AttrFlags::IS_MUST_USE), "path" => attr_flags.insert(AttrFlags::HAS_PATH), "unstable" => attr_flags.insert(AttrFlags::IS_UNSTABLE), + "rustc_reservation_impl" => attr_flags.insert(AttrFlags::RUSTC_RESERVATION_IMPL), "export_name" => { if let Some(value) = attr.value_string() && *value == *"main" diff --git a/crates/ide-diagnostics/src/handlers/type_must_be_known.rs b/crates/ide-diagnostics/src/handlers/type_must_be_known.rs index 1bae982079..a03352fe31 100644 --- a/crates/ide-diagnostics/src/handlers/type_must_be_known.rs +++ b/crates/ide-diagnostics/src/handlers/type_must_be_known.rs @@ -137,4 +137,26 @@ fn foo() { "#, ); } + + #[test] + fn regression_22263() { + check_diagnostics( + r#" +trait From<T> {} +impl<T> From<T> for T {} +#[rustc_reservation_impl = "blah blah"] +impl<T> From<!> for T {} + +fn any<T>() -> T { + loop {} +} +fn foo<T, U: From<T>>(_: T) -> U { + loop {} +} +fn bar() { + let _: () = foo(any()); +} + "#, + ); + } } |