-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix incorrect instantiation in constraint solving (#998)
- Loading branch information
Showing
12 changed files
with
183 additions
and
22 deletions.
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
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
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,31 @@ | ||
trait Trait { | ||
fn f(self) -> i32 | ||
} | ||
|
||
struct S<T> { | ||
t: T | ||
} | ||
|
||
struct S2<T> { | ||
s: S<T> | ||
} | ||
|
||
impl Trait for S<i32> { | ||
fn f(self) -> i32 { | ||
self.t | ||
} | ||
} | ||
|
||
impl<T> Trait for S2<T> | ||
where S<T>: Trait { | ||
fn f(self) -> i32 { | ||
self.s.f() | ||
} | ||
} | ||
|
||
fn bar() { | ||
let t: i32 = 1 | ||
let s = S { t } | ||
let s2 = S2 { s } | ||
let _ = s2.f() | ||
} |
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,17 @@ | ||
mod test_db; | ||
use std::path::Path; | ||
|
||
use dir_test::{dir_test, Fixture}; | ||
use test_db::HirAnalysisTestDb; | ||
|
||
#[dir_test( | ||
dir: "$CARGO_MANIFEST_DIR/test_files/constraints", | ||
glob: "*.fe" | ||
)] | ||
fn test_standalone(fixture: Fixture<&str>) { | ||
let mut db = HirAnalysisTestDb::default(); | ||
let path = Path::new(fixture.path()); | ||
let file_name = path.file_name().and_then(|file| file.to_str()).unwrap(); | ||
let (top_mod, _) = db.new_stand_alone(file_name, fixture.content()); | ||
db.assert_no_diags(top_mod); | ||
} |
30 changes: 30 additions & 0 deletions
30
crates/uitest/fixtures/ty_check/method_bound/specialized.fe
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,30 @@ | ||
trait Trait { | ||
fn f(self) -> i32 | ||
} | ||
|
||
struct S<T> { | ||
t: T | ||
} | ||
|
||
struct S2<T> { | ||
s: S<T> | ||
} | ||
|
||
impl Trait for S<i32> { | ||
fn f(self) -> i32 { | ||
self.t | ||
} | ||
} | ||
|
||
impl<T> Trait for S2<T> | ||
where S<T>: Trait { | ||
fn f(self) -> i32 { | ||
self.s.f() | ||
} | ||
} | ||
|
||
fn bar() { | ||
let s = S { t: false } | ||
let s2 = S2 { s } | ||
let _ = s2.f() | ||
} |
12 changes: 12 additions & 0 deletions
12
crates/uitest/fixtures/ty_check/method_bound/specialized.snap
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,12 @@ | ||
--- | ||
source: crates/uitest/tests/ty_check.rs | ||
expression: diags | ||
input_file: crates/uitest/fixtures/ty_check/method_bound/specialized.fe | ||
--- | ||
error[6-0003]: trait bound is not satisfied | ||
┌─ specialized.fe:29:16 | ||
│ | ||
29 │ let _ = s2.f() | ||
│ ^ `S2<bool>` doesn't implement `Trait` | ||