Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal: Support Pointee trait #14693

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 29 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions crates/hir-ty/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ either = "1.7.0"
tracing = "0.1.35"
rustc-hash = "1.1.0"
scoped-tls = "1.0.0"
chalk-solve = { version = "0.89.0", default-features = false }
chalk-ir = "0.89.0"
chalk-recursive = { version = "0.89.0", default-features = false }
chalk-derive = "0.89.0"
chalk-solve = { version = "0.91.0", default-features = false }
chalk-ir = "0.91.0"
chalk-recursive = { version = "0.91.0", default-features = false }
chalk-derive = "0.91.0"
la-arena = { version = "0.3.0", path = "../../lib/la-arena" }
once_cell = "1.17.0"
triomphe.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions crates/hir-ty/src/chalk_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ fn well_known_trait_from_lang_item(item: LangItem) -> Option<WellKnownTrait> {
LangItem::Unpin => WellKnownTrait::Unpin,
LangItem::Unsize => WellKnownTrait::Unsize,
LangItem::Tuple => WellKnownTrait::Tuple,
LangItem::PointeeTrait => WellKnownTrait::Pointee,
_ => return None,
})
}
Expand All @@ -612,6 +613,7 @@ fn lang_item_from_well_known_trait(trait_: WellKnownTrait) -> LangItem {
WellKnownTrait::Tuple => LangItem::Tuple,
WellKnownTrait::Unpin => LangItem::Unpin,
WellKnownTrait::Unsize => LangItem::Unsize,
WellKnownTrait::Pointee => LangItem::PointeeTrait,
}
}

Expand Down
16 changes: 16 additions & 0 deletions crates/hir-ty/src/tests/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3497,6 +3497,22 @@ fn func() {
);
}

#[test]
fn pointee_trait() {
check_types(
r#"
//- minicore: pointee
use core::ptr::Pointee;
fn func() {
let x: <u8 as Pointee>::Metadata;
//^ ()
let x: <[u8] as Pointee>::Metadata;
//^ usize
}
"#,
);
}

// FIXME
#[test]
fn castable_to() {
Expand Down
12 changes: 6 additions & 6 deletions crates/ide/src/inlay_hints/chaining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ fn main() {
file_id: FileId(
1,
),
range: 9286..9294,
range: 9287..9295,
},
),
tooltip: "",
Expand All @@ -487,7 +487,7 @@ fn main() {
file_id: FileId(
1,
),
range: 9318..9322,
range: 9319..9323,
},
),
tooltip: "",
Expand All @@ -511,7 +511,7 @@ fn main() {
file_id: FileId(
1,
),
range: 9286..9294,
range: 9287..9295,
},
),
tooltip: "",
Expand All @@ -524,7 +524,7 @@ fn main() {
file_id: FileId(
1,
),
range: 9318..9322,
range: 9319..9323,
},
),
tooltip: "",
Expand All @@ -548,7 +548,7 @@ fn main() {
file_id: FileId(
1,
),
range: 9286..9294,
range: 9287..9295,
},
),
tooltip: "",
Expand All @@ -561,7 +561,7 @@ fn main() {
file_id: FileId(
1,
),
range: 9318..9322,
range: 9319..9323,
},
),
tooltip: "",
Expand Down
4 changes: 4 additions & 0 deletions crates/test-utils/src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,10 @@ impl MiniCore {
}
}

if !active_regions.is_empty() {
panic!("unclosed regions: {:?} Add an `endregion` comment", active_regions);
}

for flag in &self.valid_flags {
if !seen_regions.iter().any(|it| it == flag) {
panic!("unused minicore flag: {flag:?}");
Expand Down
9 changes: 9 additions & 0 deletions crates/test-utils/src/minicore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
//! panic: fmt
//! phantom_data:
//! pin:
//! pointee:
//! range:
//! result:
//! send: sized
Expand Down Expand Up @@ -368,6 +369,14 @@ pub mod ptr {
*dst = src;
}
// endregion:drop

// region:pointee
#[lang = "pointee_trait"]
pub trait Pointee {
#[lang = "metadata_type"]
type Metadata;
}
// endregion:pointee
}

pub mod ops {
Expand Down