mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-17 18:57:04 +00:00
Ignore Destruct bounds again
This commit is contained in:
parent
b398bc6af7
commit
afee0710e1
2 changed files with 41 additions and 2 deletions
|
|
@ -590,9 +590,14 @@ impl<'a> TyLoweringContext<'a> {
|
||||||
.resolve_trait(ctx.ty_ctx().db, ctx.ty_ctx().resolver.krate());
|
.resolve_trait(ctx.ty_ctx().db, ctx.ty_ctx().resolver.krate());
|
||||||
let pointee_sized = LangItem::PointeeSized
|
let pointee_sized = LangItem::PointeeSized
|
||||||
.resolve_trait(ctx.ty_ctx().db, ctx.ty_ctx().resolver.krate());
|
.resolve_trait(ctx.ty_ctx().db, ctx.ty_ctx().resolver.krate());
|
||||||
if meta_sized.is_some_and(|it| it == trait_ref.hir_trait_id()) {
|
let destruct = LangItem::Destruct
|
||||||
|
.resolve_trait(ctx.ty_ctx().db, ctx.ty_ctx().resolver.krate());
|
||||||
|
let hir_trait_id = trait_ref.hir_trait_id();
|
||||||
|
if meta_sized.is_some_and(|it| it == hir_trait_id)
|
||||||
|
|| destruct.is_some_and(|it| it == hir_trait_id)
|
||||||
|
{
|
||||||
// Ignore this bound
|
// Ignore this bound
|
||||||
} else if pointee_sized.is_some_and(|it| it == trait_ref.hir_trait_id()) {
|
} else if pointee_sized.is_some_and(|it| it == hir_trait_id) {
|
||||||
// Regard this as `?Sized` bound
|
// Regard this as `?Sized` bound
|
||||||
ctx.ty_ctx().unsized_types.insert(self_ty);
|
ctx.ty_ctx().unsized_types.insert(self_ty);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -2349,3 +2349,37 @@ fn test() {
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn rust_destruct_option_clone() {
|
||||||
|
check_types(
|
||||||
|
r#"
|
||||||
|
//- minicore: option, drop
|
||||||
|
fn test(o: &Option<i32>) {
|
||||||
|
o.my_clone();
|
||||||
|
//^^^^^^^^^^^^ Option<i32>
|
||||||
|
}
|
||||||
|
pub trait MyClone: Sized {
|
||||||
|
fn my_clone(&self) -> Self;
|
||||||
|
}
|
||||||
|
impl<T> const MyClone for Option<T>
|
||||||
|
where
|
||||||
|
T: ~const MyClone + ~const Destruct,
|
||||||
|
{
|
||||||
|
fn my_clone(&self) -> Self {
|
||||||
|
match self {
|
||||||
|
Some(x) => Some(x.my_clone()),
|
||||||
|
None => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl const MyClone for i32 {
|
||||||
|
fn my_clone(&self) -> Self {
|
||||||
|
*self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[lang = "destruct"]
|
||||||
|
pub trait Destruct {}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue