-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add trait obligation tracking to FulfillCtxt and expose FnCtxt in rus…
…tc_infer using callback. Pass each obligation to an fn callback with its respective inference context. This avoids needing to keep around copies of obligations or inference contexts.
- Loading branch information
1 parent
2457c02
commit 47d53cd
Showing
7 changed files
with
157 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// compile-flags: -Ztrack-trait-obligations | ||
// run-pass | ||
|
||
// Just making sure this flag is accepted and doesn't crash the compiler | ||
use traits::IntoString; | ||
|
||
fn does_impl_into_string<T: IntoString>(_: T) {} | ||
|
||
fn main() { | ||
let v = vec![(0, 1), (2, 3)]; | ||
|
||
does_impl_into_string(v); | ||
} | ||
|
||
mod traits { | ||
pub trait IntoString { | ||
fn to_string(&self) -> String; | ||
} | ||
|
||
impl IntoString for (i32, i32) { | ||
fn to_string(&self) -> String { | ||
format!("({}, {})", self.0, self.1) | ||
} | ||
} | ||
|
||
impl<T: IntoString> IntoString for Vec<T> { | ||
fn to_string(&self) -> String { | ||
let s = self.iter().map(|v| v.to_string()).collect::<Vec<_>>().join(", "); | ||
format!("[{s}]") | ||
} | ||
} | ||
} |