Use correct crate for trait env in render_const_scalar()
This commit is contained in:
@@ -680,10 +680,7 @@ fn render_const_scalar(
|
|||||||
memory_map: &MemoryMap,
|
memory_map: &MemoryMap,
|
||||||
ty: &Ty,
|
ty: &Ty,
|
||||||
) -> Result<(), HirDisplayError> {
|
) -> Result<(), HirDisplayError> {
|
||||||
// FIXME: We need to get krate from the final callers of the hir display
|
let trait_env = TraitEnvironment::empty(f.krate());
|
||||||
// infrastructure and have it here as a field on `f`.
|
|
||||||
let trait_env =
|
|
||||||
TraitEnvironment::empty(*f.db.crate_graph().crates_in_topological_order().last().unwrap());
|
|
||||||
let ty = normalize(f.db, trait_env.clone(), ty.clone());
|
let ty = normalize(f.db, trait_env.clone(), ty.clone());
|
||||||
match ty.kind(Interner) {
|
match ty.kind(Interner) {
|
||||||
TyKind::Scalar(s) => match s {
|
TyKind::Scalar(s) => match s {
|
||||||
|
|||||||
@@ -10950,8 +10950,12 @@ pub struct ManuallyDrop$0<T: ?Sized> {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn projection_const() {
|
fn projection_const() {
|
||||||
|
// This uses two crates, which have *no* relation between them, to test another thing:
|
||||||
|
// `render_const_scalar()` used to just use the last crate for the trait env, which will
|
||||||
|
// fail in this scenario.
|
||||||
check(
|
check(
|
||||||
r#"
|
r#"
|
||||||
|
//- /foo.rs crate:foo
|
||||||
pub trait PublicFlags {
|
pub trait PublicFlags {
|
||||||
type Internal;
|
type Internal;
|
||||||
}
|
}
|
||||||
@@ -10967,12 +10971,13 @@ pub struct InternalBitFlags;
|
|||||||
impl PublicFlags for NoteDialects {
|
impl PublicFlags for NoteDialects {
|
||||||
type Internal = InternalBitFlags;
|
type Internal = InternalBitFlags;
|
||||||
}
|
}
|
||||||
|
//- /bar.rs crate:bar
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
*CLAP*
|
*CLAP*
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
ra_test_fixture::NoteDialects
|
foo::NoteDialects
|
||||||
```
|
```
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
|||||||
Reference in New Issue
Block a user