-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Allow static regions in type_name
.
#146310
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
Conversation
This comment has been minimized.
This comment has been minimized.
@lcnr: I don't know if this static region is expected or not, I just assumed it was ok. |
Another test case: struct Foo<T>(T);
impl Foo<&'static i32> {
fn bar() {
let f = || {};
dbg!(std::any::type_name_of_val(&f));
}
}
fn main() {
<Foo<_>>::bar();
} |
Another two test cases: trait Trait {
type Assoc;
}
impl<'a> dyn Trait<Assoc = &'static i32> + 'a {
fn bar() {
let f = || {};
dbg!(std::any::type_name_of_val(&f));
}
}
fn main() {
<dyn Trait<Assoc = &'static i32>>::bar();
} struct Thing<T, U>(T, U);
trait Trait {
type Assoc<T>;
}
impl Trait for () {
type Assoc<T> = ();
}
impl<T: Trait> Thing<T, T::Assoc<&'static i32>> {
fn bar() {
let f = || {};
dbg!(std::any::type_name_of_val(&f));
}
}
fn main() {
Thing::<(), ()>::bar();
} |
Thanks for the extra test cases. I checked; they are all fixed by this PR's change. |
2b8a395
to
9a52a83
Compare
|
@bors r+ rollup |
@@ -168,10 +168,11 @@ impl<'tcx> PrettyPrinter<'tcx> for TypeNamePrinter<'tcx> { | |||
// Bound regions are always printed (as `'_`), which gives some idea that they are special, | |||
// even though the `for` is omitted by the pretty printer. | |||
// E.g. `for<'a, 'b> fn(&'a u32, &'b u32)` is printed as "fn(&'_ u32, &'_ u32)". | |||
let kind = region.kind(); | |||
match region.kind() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since kind
now exists, maybe
match region.kind() { | |
match kind { |
could be good?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, yes, it was meant to be like that.
Rollup of 7 pull requests Successful merges: - #146111 (Migrate more things in the new solver to specific `DefId`s) - #146298 (GVN: Ensure indirect is first projection in try_as_place.) - #146299 (docs(std): add error docs for path canonicalize) - #146310 (Allow static regions in `type_name`.) - #146313 (Some `rustc_middle` cleanups) - #146319 (Fix typo in default.rs) - #146320 (rustc-dev-guide subtree update) r? `@ghost` `@rustbot` modify labels: rollup
Fixes #146249.
r? @lcnr