mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-19 03:28:36 +00:00
Rename object_safety to dyn_compatibility
Up to a trait implemented by another package, linking to $CARGO_HOME/registry/cache/index.crates.io-6f17d22bba15001f/
This commit is contained in:
parent
01aaa53ef2
commit
4255cae1bb
12 changed files with 112 additions and 106 deletions
|
|
@ -3,9 +3,9 @@ use std::{mem, ops::Not};
|
|||
|
||||
use either::Either;
|
||||
use hir::{
|
||||
db::ExpandDatabase, Adt, AsAssocItem, AsExternAssocItem, CaptureKind, HasCrate, HasSource,
|
||||
HirDisplay, Layout, LayoutError, MethodViolationCode, Name, ObjectSafetyViolation, Semantics,
|
||||
Trait, Type, TypeInfo,
|
||||
db::ExpandDatabase, Adt, AsAssocItem, AsExternAssocItem, CaptureKind,
|
||||
DynCompatibilityViolation, HasCrate, HasSource, HirDisplay, Layout, LayoutError,
|
||||
MethodViolationCode, Name, Semantics, Trait, Type, TypeInfo,
|
||||
};
|
||||
use ide_db::{
|
||||
base_db::SourceDatabase,
|
||||
|
|
@ -529,10 +529,10 @@ pub(super) fn definition(
|
|||
_ => None,
|
||||
};
|
||||
|
||||
let object_safety_info = if let Definition::Trait(it) = def {
|
||||
let mut object_safety_info = String::new();
|
||||
render_object_safety(db, &mut object_safety_info, it.object_safety(db));
|
||||
Some(object_safety_info)
|
||||
let dyn_compatibility_info = if let Definition::Trait(it) = def {
|
||||
let mut dyn_compatibility_info = String::new();
|
||||
render_dyn_compatibility(db, &mut dyn_compatibility_info, it.dyn_compatibility(db));
|
||||
Some(dyn_compatibility_info)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
@ -546,8 +546,8 @@ pub(super) fn definition(
|
|||
desc.push_str(&layout_info);
|
||||
desc.push('\n');
|
||||
}
|
||||
if let Some(object_safety_info) = object_safety_info {
|
||||
desc.push_str(&object_safety_info);
|
||||
if let Some(dyn_compatibility_info) = dyn_compatibility_info {
|
||||
desc.push_str(&dyn_compatibility_info);
|
||||
desc.push('\n');
|
||||
}
|
||||
desc.push_str(&label);
|
||||
|
|
@ -980,24 +980,24 @@ fn keyword_hints(
|
|||
}
|
||||
}
|
||||
|
||||
fn render_object_safety(
|
||||
fn render_dyn_compatibility(
|
||||
db: &RootDatabase,
|
||||
buf: &mut String,
|
||||
safety: Option<ObjectSafetyViolation>,
|
||||
safety: Option<DynCompatibilityViolation>,
|
||||
) {
|
||||
let Some(osv) = safety else {
|
||||
buf.push_str("// Object Safety: Yes");
|
||||
buf.push_str("// Dyn Compatible: Yes");
|
||||
return;
|
||||
};
|
||||
buf.push_str("// Object Safety: No\n// - Reason: ");
|
||||
buf.push_str("// Dyn Compatible: No\n// - Reason: ");
|
||||
match osv {
|
||||
ObjectSafetyViolation::SizedSelf => {
|
||||
DynCompatibilityViolation::SizedSelf => {
|
||||
buf.push_str("has a `Self: Sized` bound");
|
||||
}
|
||||
ObjectSafetyViolation::SelfReferential => {
|
||||
DynCompatibilityViolation::SelfReferential => {
|
||||
buf.push_str("has a bound that references `Self`");
|
||||
}
|
||||
ObjectSafetyViolation::Method(func, mvc) => {
|
||||
DynCompatibilityViolation::Method(func, mvc) => {
|
||||
let name = hir::Function::from(func).name(db);
|
||||
format_to!(
|
||||
buf,
|
||||
|
|
@ -1020,7 +1020,7 @@ fn render_object_safety(
|
|||
};
|
||||
buf.push_str(desc);
|
||||
}
|
||||
ObjectSafetyViolation::AssocConst(const_) => {
|
||||
DynCompatibilityViolation::AssocConst(const_) => {
|
||||
let name = hir::Const::from(const_).name(db);
|
||||
if let Some(name) = name {
|
||||
format_to!(buf, "has an associated constant `{}`", name.as_str());
|
||||
|
|
@ -1028,11 +1028,11 @@ fn render_object_safety(
|
|||
buf.push_str("has an associated constant");
|
||||
}
|
||||
}
|
||||
ObjectSafetyViolation::GAT(alias) => {
|
||||
DynCompatibilityViolation::GAT(alias) => {
|
||||
let name = hir::TypeAlias::from(alias).name(db);
|
||||
format_to!(buf, "has a generic associated type `{}`", name.as_str());
|
||||
}
|
||||
ObjectSafetyViolation::HasNonSafeSuperTrait(super_trait) => {
|
||||
DynCompatibilityViolation::HasNonCompatibleSuperTrait(super_trait) => {
|
||||
let name = hir::Trait::from(super_trait).name(db);
|
||||
format_to!(buf, "has a object unsafe supertrait `{}`", name.as_str());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue