-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #16222 - rosefromthedead:unresolved-assoc-item, r=Veykril
add unresolved-assoc-item assist I tried to copy from private-assoc-item for this
- Loading branch information
Showing
6 changed files
with
74 additions
and
1 deletion.
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
52 changes: 52 additions & 0 deletions
52
crates/ide-diagnostics/src/handlers/unresolved_assoc_item.rs
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,52 @@ | ||
use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext}; | ||
|
||
// Diagnostic: unresolved-assoc-item | ||
// | ||
// This diagnostic is triggered if the referenced associated item does not exist. | ||
pub(crate) fn unresolved_assoc_item( | ||
ctx: &DiagnosticsContext<'_>, | ||
d: &hir::UnresolvedAssocItem, | ||
) -> Diagnostic { | ||
Diagnostic::new_with_syntax_node_ptr( | ||
ctx, | ||
DiagnosticCode::RustcHardError("E0599"), | ||
"no such associated item", | ||
d.expr_or_pat.clone().map(Into::into), | ||
) | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::tests::check_diagnostics; | ||
|
||
#[test] | ||
fn bare() { | ||
check_diagnostics( | ||
r#" | ||
struct S; | ||
fn main() { | ||
let _ = S::Assoc; | ||
//^^^^^^^^ error: no such associated item | ||
} | ||
"#, | ||
); | ||
} | ||
|
||
#[test] | ||
fn unimplemented_trait() { | ||
check_diagnostics( | ||
r#" | ||
struct S; | ||
trait Foo { | ||
const X: u32; | ||
} | ||
fn main() { | ||
let _ = S::X; | ||
//^^^^ error: no such associated item | ||
} | ||
"#, | ||
); | ||
} | ||
} |
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