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

Add TyAlias into rustc_type_ir TyKind enum #97974

Closed

Conversation

GuillaumeGomez
Copy link
Member

Fixes rust-lang/compiler-team#504.

This is still WIP but I think we're getting close to the end of the implementation. Thanks a lot to both @compiler-errors and @oli-obk for their great guidance and help!

cc @compiler-errors

r? @oli-obk

@rust-highfive
Copy link
Collaborator

Some changes occured to the CTFE / Miri engine

cc @rust-lang/miri

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jun 10, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 10, 2022
@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just left my first impressions, sorry if anything I said made absolutely no sense. I just wanted to point out areas that made me go "hmm" so a more thorough code-review will not miss them and/or so we can circle back on questions.

compiler/rustc_typeck/src/check/check.rs Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/check/wfcheck.rs Outdated Show resolved Hide resolved
compiler/rustc_lint/src/types.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/flags.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/layout.rs Outdated Show resolved Hide resolved
compiler/rustc_privacy/src/lib.rs Outdated Show resolved Hide resolved
compiler/rustc_trait_selection/src/traits/coherence.rs Outdated Show resolved Hide resolved
@@ -304,6 +304,10 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
self.add_constraints_from_invariant_substs(current, substs, variance);
}

ty::TyAlias(_, substs) => {
self.add_constraints_from_invariant_substs(current, substs, variance);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can skip this (and/or we need to recurse onto the aliased type), since ty aliases shouldn't participate in variance, though I don't really know much about variance calculation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let it as is for the time being then until we have a better understanding.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will cause subtle bugs if actually reachable. Change to bug! instead and only add logic if we actually find code that hits it.

@bors
Copy link
Contributor

bors commented Jun 11, 2022

☔ The latest upstream changes (presumably #97905) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member Author

Only two UI tests are failing now and it's about mangling. I'll wait for the rest to be approved to update them.

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some more type_of calls that need to be squashed

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs Outdated Show resolved Hide resolved
compiler/rustc_const_eval/src/interpret/intrinsics.rs Outdated Show resolved Hide resolved
compiler/rustc_infer/src/infer/outlives/components.rs Outdated Show resolved Hide resolved
compiler/rustc_lint/src/types.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/layout.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/util.rs Outdated Show resolved Hide resolved
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member Author

Replaced the type_of calls and applied the comments.

@rust-log-analyzer

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Jun 13, 2022

@bors try @rust-timer queue

won't get to this before next week

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 13, 2022
@bors
Copy link
Contributor

bors commented Jun 13, 2022

⌛ Trying commit c9f5d4e227127e9c11e6b0a19b534abcbad6be7a with merge a2a309290e7901fd85bbba6cc69b2f368162312d...

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-13 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling itoa v1.0.2
   Compiling lazy_static v1.4.0
   Compiling odht v0.3.1
   Compiling termcolor v1.1.2
error[E0277]: cannot add `bit::B1` to `<U as type_operators::Len>::Output`
   --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:258:1
    |
258 | impl<U: Unsigned, B: Bit> Len for UInt<U, B>
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `<U as type_operators::Len>::Output + bit::B1`
    |
    = help: the trait `Add<bit::B1>` is not implemented for `<U as type_operators::Len>::Output`
    |
    |
262 |     Add1<Length<U>>: Unsigned, <U as type_operators::Len>::Output: Add<bit::B1>


error[E0277]: cannot add `bit::B1` to `<U as type_operators::Len>::Output`
   --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:258:1
    |
258 | / impl<U: Unsigned, B: Bit> Len for UInt<U, B>
260 | |     U: Len,
260 | |     U: Len,
261 | |     Length<U>: Add<B1>,
268 | |     }
269 | | }
269 | | }
    | |_^ no implementation for `<U as type_operators::Len>::Output + bit::B1`
    |
    = help: the trait `Add<bit::B1>` is not implemented for `<U as type_operators::Len>::Output`
    |
    |
262 |     Add1<Length<U>>: Unsigned, <U as type_operators::Len>::Output: Add<bit::B1>


error[E0277]: the trait bound `Xp: marker_traits::Unsigned` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1428:1
     |
1428 | impl<Xp, Yp> Gcd<Odd<Yp>> for Odd<Xp>
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `marker_traits::Unsigned` is not implemented for `Xp`
     |
note: required for `UInt<Xp, bit::B1>` to implement `type_operators::Max<UInt<Yp, bit::B1>>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:2203:16
     |
2203 | impl<U, B, Ur> Max<Ur> for UInt<U, B>
help: consider further restricting type parameter `Xp`
     |
     |
1433 |     Diff<Maximum<Odd<Xp>, Odd<Yp>>, Minimum<Odd<Xp>, Odd<Yp>>>: Gcd<Minimum<Odd<Xp>, Odd<Yp>>>, Xp: marker_traits::Unsigned


error[E0277]: the trait bound `Yp: marker_traits::Unsigned` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1428:1
     |
1428 | impl<Xp, Yp> Gcd<Odd<Yp>> for Odd<Xp>
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `marker_traits::Unsigned` is not implemented for `Yp`
     |
note: required for `UInt<Xp, bit::B1>` to implement `type_operators::Cmp<UInt<Yp, bit::B1>>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1133:34
     |
1133 | impl<Ul: Unsigned, Ur: Unsigned> Cmp<UInt<Ur, B1>> for UInt<Ul, B1>
     |                                  ^^^^^^^^^^^^^^^^^     ^^^^^^^^^^^^
note: required for `UInt<Xp, bit::B1>` to implement `type_operators::Max<UInt<Yp, bit::B1>>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:2203:16
     |
2203 | impl<U, B, Ur> Max<Ur> for UInt<U, B>
help: consider further restricting type parameter `Yp`
     |
     |
1433 |     Diff<Maximum<Odd<Xp>, Odd<Yp>>, Minimum<Odd<Xp>, Odd<Yp>>>: Gcd<Minimum<Odd<Xp>, Odd<Yp>>>, Yp: marker_traits::Unsigned


error[E0277]: the trait bound `Xp: PrivateCmp<Yp, Equal>` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1428:1
     |
1428 | impl<Xp, Yp> Gcd<Odd<Yp>> for Odd<Xp>
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `PrivateCmp<Yp, Equal>` is not implemented for `Xp`
     |
note: required for `UInt<Xp, bit::B1>` to implement `type_operators::Cmp<UInt<Yp, bit::B1>>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1133:34
     |
1133 | impl<Ul: Unsigned, Ur: Unsigned> Cmp<UInt<Ur, B1>> for UInt<Ul, B1>
     |                                  ^^^^^^^^^^^^^^^^^     ^^^^^^^^^^^^
note: required for `UInt<Xp, bit::B1>` to implement `type_operators::Max<UInt<Yp, bit::B1>>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:2203:16
     |
2203 | impl<U, B, Ur> Max<Ur> for UInt<U, B>
help: consider further restricting type parameter `Xp`
     |
     |
1433 |     Diff<Maximum<Odd<Xp>, Odd<Yp>>, Minimum<Odd<Xp>, Odd<Yp>>>: Gcd<Minimum<Odd<Xp>, Odd<Yp>>>, Xp: private::PrivateCmp<Yp, Equal>


error[E0277]: the trait bound `UInt<Xp, bit::B1>: PrivateMax<UInt<Yp, bit::B1>, _>` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1428:1
     |
1428 | impl<Xp, Yp> Gcd<Odd<Yp>> for Odd<Xp>
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `PrivateMax<UInt<Yp, bit::B1>, _>` is not implemented for `UInt<Xp, bit::B1>`
     |
     = help: the following other types implement trait `PrivateMax<Rhs, CmpResult>`:
               <UInt<U, B> as PrivateMax<Ur, Equal>>
               <UInt<U, B> as PrivateMax<Ur, Greater>>
               <UInt<U, B> as PrivateMax<Ur, Less>>
note: required for `UInt<Xp, bit::B1>` to implement `type_operators::Max<UInt<Yp, bit::B1>>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:2203:16
     |
2203 | impl<U, B, Ur> Max<Ur> for UInt<U, B>


error[E0277]: the trait bound `UInt<Xp, bit::B1>: PrivateMin<UInt<Yp, bit::B1>, _>` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1428:1
     |
1428 | impl<Xp, Yp> Gcd<Odd<Yp>> for Odd<Xp>
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `PrivateMin<UInt<Yp, bit::B1>, _>` is not implemented for `UInt<Xp, bit::B1>`
     |
     = help: the following other types implement trait `PrivateMin<Rhs, CmpResult>`:
               <UInt<U, B> as PrivateMin<Ur, Equal>>
               <UInt<U, B> as PrivateMin<Ur, Greater>>
               <UInt<U, B> as PrivateMin<Ur, Less>>
note: required for `UInt<Xp, bit::B1>` to implement `type_operators::Min<UInt<Yp, bit::B1>>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:2131:16
     |
2131 | impl<U, B, Ur> Min<Ur> for UInt<U, B>


error[E0277]: the trait bound `Xp: marker_traits::Unsigned` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1428:1
     |
1428 | / impl<Xp, Yp> Gcd<Odd<Yp>> for Odd<Xp>
1429 | | where
1430 | |     Odd<Xp>: Max<Odd<Yp>> + Min<Odd<Yp>>,
1431 | |     Odd<Yp>: Max<Odd<Xp>> + Min<Odd<Xp>>,
...    |
1436 | |         Gcf<Diff<Maximum<Odd<Xp>, Odd<Yp>>, Minimum<Odd<Xp>, Odd<Yp>>>, Minimum<Odd<Xp>, Odd<Yp>>>;
1437 | | }
     | |_^ the trait `marker_traits::Unsigned` is not implemented for `Xp`
     |
note: required for `UInt<Xp, bit::B1>` to implement `type_operators::Max<UInt<Yp, bit::B1>>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:2203:16
     |
2203 | impl<U, B, Ur> Max<Ur> for UInt<U, B>
help: consider further restricting type parameter `Xp`
     |
     |
1433 |     Diff<Maximum<Odd<Xp>, Odd<Yp>>, Minimum<Odd<Xp>, Odd<Yp>>>: Gcd<Minimum<Odd<Xp>, Odd<Yp>>>, Xp: marker_traits::Unsigned


error[E0277]: the trait bound `Yp: marker_traits::Unsigned` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1428:1
     |
1428 | / impl<Xp, Yp> Gcd<Odd<Yp>> for Odd<Xp>
1429 | | where
1430 | |     Odd<Xp>: Max<Odd<Yp>> + Min<Odd<Yp>>,
1431 | |     Odd<Yp>: Max<Odd<Xp>> + Min<Odd<Xp>>,
...    |
1436 | |         Gcf<Diff<Maximum<Odd<Xp>, Odd<Yp>>, Minimum<Odd<Xp>, Odd<Yp>>>, Minimum<Odd<Xp>, Odd<Yp>>>;
1437 | | }
     | |_^ the trait `marker_traits::Unsigned` is not implemented for `Yp`
     |
note: required for `UInt<Xp, bit::B1>` to implement `type_operators::Cmp<UInt<Yp, bit::B1>>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1133:34
     |
1133 | impl<Ul: Unsigned, Ur: Unsigned> Cmp<UInt<Ur, B1>> for UInt<Ul, B1>
     |                                  ^^^^^^^^^^^^^^^^^     ^^^^^^^^^^^^
note: required for `UInt<Xp, bit::B1>` to implement `type_operators::Max<UInt<Yp, bit::B1>>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:2203:16
     |
2203 | impl<U, B, Ur> Max<Ur> for UInt<U, B>
help: consider further restricting type parameter `Yp`
     |
     |
1433 |     Diff<Maximum<Odd<Xp>, Odd<Yp>>, Minimum<Odd<Xp>, Odd<Yp>>>: Gcd<Minimum<Odd<Xp>, Odd<Yp>>>, Yp: marker_traits::Unsigned


error[E0277]: the trait bound `Xp: PrivateCmp<Yp, Equal>` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1428:1
     |
1428 | / impl<Xp, Yp> Gcd<Odd<Yp>> for Odd<Xp>
1429 | | where
1430 | |     Odd<Xp>: Max<Odd<Yp>> + Min<Odd<Yp>>,
1431 | |     Odd<Yp>: Max<Odd<Xp>> + Min<Odd<Xp>>,
...    |
1436 | |         Gcf<Diff<Maximum<Odd<Xp>, Odd<Yp>>, Minimum<Odd<Xp>, Odd<Yp>>>, Minimum<Odd<Xp>, Odd<Yp>>>;
1437 | | }
     | |_^ the trait `PrivateCmp<Yp, Equal>` is not implemented for `Xp`
     |
note: required for `UInt<Xp, bit::B1>` to implement `type_operators::Cmp<UInt<Yp, bit::B1>>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1133:34
     |
1133 | impl<Ul: Unsigned, Ur: Unsigned> Cmp<UInt<Ur, B1>> for UInt<Ul, B1>
     |                                  ^^^^^^^^^^^^^^^^^     ^^^^^^^^^^^^
note: required for `UInt<Xp, bit::B1>` to implement `type_operators::Max<UInt<Yp, bit::B1>>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:2203:16
     |
2203 | impl<U, B, Ur> Max<Ur> for UInt<U, B>
help: consider further restricting type parameter `Xp`
     |
     |
1433 |     Diff<Maximum<Odd<Xp>, Odd<Yp>>, Minimum<Odd<Xp>, Odd<Yp>>>: Gcd<Minimum<Odd<Xp>, Odd<Yp>>>, Xp: private::PrivateCmp<Yp, Equal>


error[E0277]: the trait bound `UInt<Xp, bit::B1>: PrivateMax<UInt<Yp, bit::B1>, _>` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1428:1
     |
1428 | / impl<Xp, Yp> Gcd<Odd<Yp>> for Odd<Xp>
1429 | | where
1430 | |     Odd<Xp>: Max<Odd<Yp>> + Min<Odd<Yp>>,
1431 | |     Odd<Yp>: Max<Odd<Xp>> + Min<Odd<Xp>>,
...    |
1436 | |         Gcf<Diff<Maximum<Odd<Xp>, Odd<Yp>>, Minimum<Odd<Xp>, Odd<Yp>>>, Minimum<Odd<Xp>, Odd<Yp>>>;
1437 | | }
     | |_^ the trait `PrivateMax<UInt<Yp, bit::B1>, _>` is not implemented for `UInt<Xp, bit::B1>`
     |
     = help: the following other types implement trait `PrivateMax<Rhs, CmpResult>`:
               <UInt<U, B> as PrivateMax<Ur, Equal>>
               <UInt<U, B> as PrivateMax<Ur, Greater>>
               <UInt<U, B> as PrivateMax<Ur, Less>>
note: required for `UInt<Xp, bit::B1>` to implement `type_operators::Max<UInt<Yp, bit::B1>>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:2203:16
     |
2203 | impl<U, B, Ur> Max<Ur> for UInt<U, B>


error[E0277]: the trait bound `UInt<Xp, bit::B1>: PrivateMin<UInt<Yp, bit::B1>, _>` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1428:1
     |
1428 | / impl<Xp, Yp> Gcd<Odd<Yp>> for Odd<Xp>
1429 | | where
1430 | |     Odd<Xp>: Max<Odd<Yp>> + Min<Odd<Yp>>,
1431 | |     Odd<Yp>: Max<Odd<Xp>> + Min<Odd<Xp>>,
...    |
1436 | |         Gcf<Diff<Maximum<Odd<Xp>, Odd<Yp>>, Minimum<Odd<Xp>, Odd<Yp>>>, Minimum<Odd<Xp>, Odd<Yp>>>;
1437 | | }
     | |_^ the trait `PrivateMin<UInt<Yp, bit::B1>, _>` is not implemented for `UInt<Xp, bit::B1>`
     |
     = help: the following other types implement trait `PrivateMin<Rhs, CmpResult>`:
               <UInt<U, B> as PrivateMin<Ur, Equal>>
               <UInt<U, B> as PrivateMin<Ur, Greater>>
               <UInt<U, B> as PrivateMin<Ur, Less>>
note: required for `UInt<Xp, bit::B1>` to implement `type_operators::Min<UInt<Yp, bit::B1>>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:2131:16
     |
2131 | impl<U, B, Ur> Min<Ur> for UInt<U, B>


error[E0277]: the trait bound `Yp: PrivateCmp<Xp, Equal>` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1431:14
     |
1431 |     Odd<Yp>: Max<Odd<Xp>> + Min<Odd<Xp>>,
     |              ^^^^^^^^^^^^ the trait `PrivateCmp<Xp, Equal>` is not implemented for `Yp`
     |
note: required for `UInt<Yp, bit::B1>` to implement `type_operators::Cmp<UInt<Xp, bit::B1>>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1133:34
     |
1133 | impl<Ul: Unsigned, Ur: Unsigned> Cmp<UInt<Ur, B1>> for UInt<Ul, B1>
     |                                  ^^^^^^^^^^^^^^^^^     ^^^^^^^^^^^^
note: required for `UInt<Yp, bit::B1>` to implement `type_operators::Max<UInt<Xp, bit::B1>>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:2203:16
     |
2203 | impl<U, B, Ur> Max<Ur> for UInt<U, B>
help: consider further restricting type parameter `Yp`
     |
     |
1433 |     Diff<Maximum<Odd<Xp>, Odd<Yp>>, Minimum<Odd<Xp>, Odd<Yp>>>: Gcd<Minimum<Odd<Xp>, Odd<Yp>>>, Yp: private::PrivateCmp<Xp, Equal>


error[E0277]: the trait bound `UInt<Yp, bit::B1>: PrivateMax<UInt<Xp, bit::B1>, _>` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1431:14
     |
1431 |     Odd<Yp>: Max<Odd<Xp>> + Min<Odd<Xp>>,
     |              ^^^^^^^^^^^^ the trait `PrivateMax<UInt<Xp, bit::B1>, _>` is not implemented for `UInt<Yp, bit::B1>`
     |
     = help: the following other types implement trait `PrivateMax<Rhs, CmpResult>`:
               <UInt<U, B> as PrivateMax<Ur, Equal>>
               <UInt<U, B> as PrivateMax<Ur, Greater>>
               <UInt<U, B> as PrivateMax<Ur, Less>>
note: required for `UInt<Yp, bit::B1>` to implement `type_operators::Max<UInt<Xp, bit::B1>>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:2203:16
     |
2203 | impl<U, B, Ur> Max<Ur> for UInt<U, B>


error[E0277]: the trait bound `UInt<Yp, bit::B1>: PrivateMin<UInt<Xp, bit::B1>, _>` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1431:29
     |
1431 |     Odd<Yp>: Max<Odd<Xp>> + Min<Odd<Xp>>,
     |                             ^^^^^^^^^^^^ the trait `PrivateMin<UInt<Xp, bit::B1>, _>` is not implemented for `UInt<Yp, bit::B1>`
     |
     = help: the following other types implement trait `PrivateMin<Rhs, CmpResult>`:
               <UInt<U, B> as PrivateMin<Ur, Equal>>
               <UInt<U, B> as PrivateMin<Ur, Greater>>
               <UInt<U, B> as PrivateMin<Ur, Less>>
note: required for `UInt<Yp, bit::B1>` to implement `type_operators::Min<UInt<Xp, bit::B1>>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:2131:16
     |
2131 | impl<U, B, Ur> Min<Ur> for UInt<U, B>

   Compiling rustc_lexer v0.1.0 (/checkout/compiler/rustc_lexer)
   Compiling rustc_lexer v0.1.0 (/checkout/compiler/rustc_lexer)
error[E0277]: cannot subtract `bit::B1` from `<UInt<Ul, Bl> as type_operators::Len>::Output`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1707:1
     |
1707 | impl<Ul: Unsigned, Bl: Bit, Ur: Unsigned, Br: Bit> Div<UInt<Ur, Br>> for UInt<Ul, Bl>
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `<UInt<Ul, Bl> as type_operators::Len>::Output - bit::B1`
     |
     = help: the trait `Sub<bit::B1>` is not implemented for `<UInt<Ul, Bl> as type_operators::Len>::Output`

error[E0277]: cannot subtract `bit::B1` from `<UInt<Ul, Bl> as type_operators::Len>::Output`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1707:1
     |
1707 | / impl<Ul: Unsigned, Bl: Bit, Ur: Unsigned, Br: Bit> Div<UInt<Ur, Br>> for UInt<Ul, Bl>
1708 | | where
1709 | |     UInt<Ul, Bl>: Len,
1710 | |     Length<UInt<Ul, Bl>>: Sub<B1>,
1718 | |     }
1719 | | }
1719 | | }
     | |_^ no implementation for `<UInt<Ul, Bl> as type_operators::Len>::Output - bit::B1`
     |
     = help: the trait `Sub<bit::B1>` is not implemented for `<UInt<Ul, Bl> as type_operators::Len>::Output`

error[E0277]: the trait bound `InvertedUInt<InvertedUTerm, Bl>: TrimTrailingZeros` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1711:9
     |
1711 |     (): PrivateDiv<UInt<Ul, Bl>, UInt<Ur, Br>, U0, U0, Sub1<Length<UInt<Ul, Bl>>>>,
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TrimTrailingZeros` is not implemented for `InvertedUInt<InvertedUTerm, Bl>`
     |
note: required for `UInt<uint::UTerm, Bl>` to implement `Trim`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/private.rs:304:19
     |
304  | impl<U: Unsigned> Trim for U
     |                   ^^^^     ^
note: required for `()` to implement `PrivateDiv<UInt<Ul, Bl>, UInt<Ur, Br>, uint::UTerm, uint::UTerm, uint::UTerm>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1754:18
     |
1754 | impl<N, D, Q, I> PrivateDiv<N, D, Q, U0, I> for ()
     |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^     ^^
help: consider extending the `where` clause, but there might be an alternative better way to express this requirement
     |
1711 |     (): PrivateDiv<UInt<Ul, Bl>, UInt<Ur, Br>, U0, U0, Sub1<Length<UInt<Ul, Bl>>>>, InvertedUInt<InvertedUTerm, Bl>: TrimTrailingZeros


error[E0277]: cannot subtract `bit::B1` from `<UInt<Ul, Bl> as type_operators::Len>::Output`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1735:1
     |
1735 | impl<Ul: Unsigned, Bl: Bit, Ur: Unsigned, Br: Bit> Rem<UInt<Ur, Br>> for UInt<Ul, Bl>
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `<UInt<Ul, Bl> as type_operators::Len>::Output - bit::B1`
     |
     = help: the trait `Sub<bit::B1>` is not implemented for `<UInt<Ul, Bl> as type_operators::Len>::Output`

error[E0277]: cannot subtract `bit::B1` from `<UInt<Ul, Bl> as type_operators::Len>::Output`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1735:1
     |
1735 | / impl<Ul: Unsigned, Bl: Bit, Ur: Unsigned, Br: Bit> Rem<UInt<Ur, Br>> for UInt<Ul, Bl>
1736 | | where
1737 | |     UInt<Ul, Bl>: Len,
1738 | |     Length<UInt<Ul, Bl>>: Sub<B1>,
1745 | |     }
1746 | | }
1746 | | }
     | |_^ no implementation for `<UInt<Ul, Bl> as type_operators::Len>::Output - bit::B1`
     |
     = help: the trait `Sub<bit::B1>` is not implemented for `<UInt<Ul, Bl> as type_operators::Len>::Output`

error[E0277]: the trait bound `InvertedUInt<InvertedUTerm, Bl>: TrimTrailingZeros` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1739:9
     |
1739 |     (): PrivateDiv<UInt<Ul, Bl>, UInt<Ur, Br>, U0, U0, Sub1<Length<UInt<Ul, Bl>>>>,
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TrimTrailingZeros` is not implemented for `InvertedUInt<InvertedUTerm, Bl>`
     |
note: required for `UInt<uint::UTerm, Bl>` to implement `Trim`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/private.rs:304:19
     |
304  | impl<U: Unsigned> Trim for U
     |                   ^^^^     ^
note: required for `()` to implement `PrivateDiv<UInt<Ul, Bl>, UInt<Ur, Br>, uint::UTerm, uint::UTerm, uint::UTerm>`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1754:18
     |
1754 | impl<N, D, Q, I> PrivateDiv<N, D, Q, U0, I> for ()
     |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^     ^^
help: consider extending the `where` clause, but there might be an alternative better way to express this requirement
     |
1739 |     (): PrivateDiv<UInt<Ul, Bl>, UInt<Ur, Br>, U0, U0, Sub1<Length<UInt<Ul, Bl>>>>, InvertedUInt<InvertedUTerm, Bl>: TrimTrailingZeros


error[E0277]: the trait bound `<N as GetBit<I>>::Output: marker_traits::Bit` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1754:1
     |
1754 | impl<N, D, Q, I> PrivateDiv<N, D, Q, U0, I> for ()
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `marker_traits::Bit` is not implemented for `<N as GetBit<I>>::Output`
     |
note: required for `UInt<uint::UTerm, <N as GetBit<I>>::Output>` to implement `Invert`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/private.rs:161:27
     |
161  | impl<U: Unsigned, B: Bit> Invert for UInt<U, B>
     |                           ^^^^^^     ^^^^^^^^^^
note: required for `UInt<uint::UTerm, <N as GetBit<I>>::Output>` to implement `Trim`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/private.rs:304:19
     |
304  | impl<U: Unsigned> Trim for U
help: consider further restricting the associated type
     |
     |
1766 |     >, <N as GetBit<I>>::Output: marker_traits::Bit


error[E0277]: the trait bound `InvertedUInt<InvertedUTerm, <N as GetBit<I>>::Output>: TrimTrailingZeros` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1754:1
     |
1754 | impl<N, D, Q, I> PrivateDiv<N, D, Q, U0, I> for ()
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TrimTrailingZeros` is not implemented for `InvertedUInt<InvertedUTerm, <N as GetBit<I>>::Output>`
     |
note: required for `UInt<uint::UTerm, <N as GetBit<I>>::Output>` to implement `Trim`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/private.rs:304:19
     |
304  | impl<U: Unsigned> Trim for U
     |                   ^^^^     ^
help: consider extending the `where` clause, but there might be an alternative better way to express this requirement
     |
1766 |     >, InvertedUInt<InvertedUTerm, <N as GetBit<I>>::Output>: TrimTrailingZeros


error[E0277]: the trait bound `<N as GetBit<I>>::Output: marker_traits::Bit` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1754:1
     |
1754 | / impl<N, D, Q, I> PrivateDiv<N, D, Q, U0, I> for ()
1755 | | where
1756 | |     N: GetBit<I>,
1757 | |     UInt<UTerm, GetBitOut<N, I>>: Trim,
1806 | |     }
1807 | | }
1807 | | }
     | |_^ the trait `marker_traits::Bit` is not implemented for `<N as GetBit<I>>::Output`
     |
note: required for `UInt<uint::UTerm, <N as GetBit<I>>::Output>` to implement `Invert`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/private.rs:161:27
     |
161  | impl<U: Unsigned, B: Bit> Invert for UInt<U, B>
     |                           ^^^^^^     ^^^^^^^^^^
note: required for `UInt<uint::UTerm, <N as GetBit<I>>::Output>` to implement `Trim`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/private.rs:304:19
     |
304  | impl<U: Unsigned> Trim for U
help: consider further restricting the associated type
     |
     |
1766 |     >, <N as GetBit<I>>::Output: marker_traits::Bit


error[E0277]: the trait bound `InvertedUInt<InvertedUTerm, <N as GetBit<I>>::Output>: TrimTrailingZeros` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1754:1
     |
1754 | / impl<N, D, Q, I> PrivateDiv<N, D, Q, U0, I> for ()
1755 | | where
1756 | |     N: GetBit<I>,
1757 | |     UInt<UTerm, GetBitOut<N, I>>: Trim,
1806 | |     }
1807 | | }
1807 | | }
     | |_^ the trait `TrimTrailingZeros` is not implemented for `InvertedUInt<InvertedUTerm, <N as GetBit<I>>::Output>`
     |
note: required for `UInt<uint::UTerm, <N as GetBit<I>>::Output>` to implement `Trim`
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/private.rs:304:19
     |
304  | impl<U: Unsigned> Trim for U
     |                   ^^^^     ^
help: consider extending the `where` clause, but there might be an alternative better way to express this requirement
     |
1766 |     >, InvertedUInt<InvertedUTerm, <N as GetBit<I>>::Output>: TrimTrailingZeros


error[E0277]: the trait bound `(): PrivateDivIf<N, D, Q, _, I, _>` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1759:9
     |
1759 |       (): PrivateDivIf<
1760 | |         N,
1761 | |         D,
1762 | |         Q,
...    |
...    |
1765 | |         Compare<TrimOut<UInt<UTerm, GetBitOut<N, I>>>, D>,
1766 | |     >,
     | |_____^ the trait `PrivateDivIf<N, D, Q, _, I, _>` is not implemented for `()`
     |
     = help: the following other types implement trait `PrivateDivIf<N, D, Q, R, I, RcmpD>`:
               <() as PrivateDivIf<N, D, Q, R, UInt<Ui, Bi>, Equal>>
               <() as PrivateDivIf<N, D, Q, R, UInt<Ui, Bi>, Greater>>
               <() as PrivateDivIf<N, D, Q, R, UInt<Ui, Bi>, Less>>
               <() as PrivateDivIf<N, D, Q, R, uint::UTerm, Equal>>
               <() as PrivateDivIf<N, D, Q, R, uint::UTerm, Greater>>
               <() as PrivateDivIf<N, D, Q, R, uint::UTerm, Less>>

error[E0277]: the trait bound `(): PrivateDivIf<N, D, Q, _, I, _>` is not satisfied
    --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/typenum-1.12.0/src/uint.rs:1754:18
     |
1754 | impl<N, D, Q, I> PrivateDiv<N, D, Q, U0, I> for ()
     |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `PrivateDivIf<N, D, Q, _, I, _>` is not implemented for `()`
     |
     = help: the following other types implement trait `PrivateDivIf<N, D, Q, R, I, RcmpD>`:
               <() as PrivateDivIf<N, D, Q, R, UInt<Ui, Bi>, Equal>>
               <() as PrivateDivIf<N, D, Q, R, UInt<Ui, Bi>, Greater>>

@clarfonthey
Copy link
Contributor

So, I know that the main purpose of this change is to aid rustdoc, but after noticing this PR I also mentioned it on rust-lang/rfcs#3296 as something that could also help that RFC as well. Just in case that sways you one way or another in terms of what implementation is best to solve this problem -- I noticed #103985 as well as an alternative, which I would be less in favour of for this reason.

@GuillaumeGomez
Copy link
Member Author

#103985 is less an alternative than an experiment (that couldn't be finished unfortunately).

As for this feature, it would also help for some compiler errors (although it'd be a very small improvement concerning very few errors).

But in any case, it's currently blocked on a few things, so we're not in a hurry. :)

As for your RFC, good luck!

@fmease
Copy link
Member

fmease commented Oct 5, 2023

Hasn't this been superseded by weak projections (#108860) and lazy type aliases (#112853, #112792)?

@GuillaumeGomez
Copy link
Member Author

It completely was. Completely forgot to close it.

@GuillaumeGomez GuillaumeGomez deleted the rustc-middle-ty-alias branch October 5, 2023 15:27
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 17, 2024
Properly deal with weak alias types as self types of impls

Fixes rust-lang#114216.
Fixes rust-lang#116100.

Not super happy about the two ad hoc “normalization” implementations for weak alias types:

1. In `inherent_impls`: The “peeling”, normalization to [“WHNF”][whnf]: Semantically that's exactly what we want (neither proper normalization nor shallow normalization would be correct here). Basically a weak alias type is “nominal” (well...^^) if the WHNF is nominal. [rust-lang#97974](rust-lang#97974) followed the same approach.
2. In `constrained_generic_params`: Generic parameters are constrained by a weak alias type if the corresp. “normalized” type constrains them (where we only normalize *weak* alias types not arbitrary ones). Weak alias types are injective if the corresp. “normalized” type is injective.

Both have ad hoc overflow detection mechanisms.

**Coherence** is handled in rust-lang#117164.

r? `@oli-obk` or types

[whnf]: https://en.wikipedia.org/wiki/Lambda_calculus_definition#Weak_head_normal_form
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 18, 2024
Properly deal with weak alias types as self types of impls

Fixes rust-lang#114216.
Fixes rust-lang#116100.

Not super happy about the two ad hoc “normalization” implementations for weak alias types:

1. In `inherent_impls`: The “peeling”, normalization to [“WHNF”][whnf]: Semantically that's exactly what we want (neither proper normalization nor shallow normalization would be correct here). Basically a weak alias type is “nominal” (well...^^) if the WHNF is nominal. [rust-lang#97974](rust-lang#97974) followed the same approach.
2. In `constrained_generic_params`: Generic parameters are constrained by a weak alias type if the corresp. “normalized” type constrains them (where we only normalize *weak* alias types not arbitrary ones). Weak alias types are injective if the corresp. “normalized” type is injective.

Both have ad hoc overflow detection mechanisms.

**Coherence** is handled in rust-lang#117164.

r? `@oli-obk` or types

[whnf]: https://en.wikipedia.org/wiki/Lambda_calculus_definition#Weak_head_normal_form
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Feb 19, 2024
Properly deal with weak alias types as self types of impls

Fixes #114216.
Fixes #116100.

Not super happy about the two ad hoc “normalization” implementations for weak alias types:

1. In `inherent_impls`: The “peeling”, normalization to [“WHNF”][whnf]: Semantically that's exactly what we want (neither proper normalization nor shallow normalization would be correct here). Basically a weak alias type is “nominal” (well...^^) if the WHNF is nominal. [#97974](rust-lang/rust#97974) followed the same approach.
2. In `constrained_generic_params`: Generic parameters are constrained by a weak alias type if the corresp. “normalized” type constrains them (where we only normalize *weak* alias types not arbitrary ones). Weak alias types are injective if the corresp. “normalized” type is injective.

Both have ad hoc overflow detection mechanisms.

**Coherence** is handled in #117164.

r? `@oli-obk` or types

[whnf]: https://en.wikipedia.org/wiki/Lambda_calculus_definition#Weak_head_normal_form
lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request Apr 7, 2024
Properly deal with weak alias types as self types of impls

Fixes #114216.
Fixes #116100.

Not super happy about the two ad hoc “normalization” implementations for weak alias types:

1. In `inherent_impls`: The “peeling”, normalization to [“WHNF”][whnf]: Semantically that's exactly what we want (neither proper normalization nor shallow normalization would be correct here). Basically a weak alias type is “nominal” (well...^^) if the WHNF is nominal. [#97974](rust-lang/rust#97974) followed the same approach.
2. In `constrained_generic_params`: Generic parameters are constrained by a weak alias type if the corresp. “normalized” type constrains them (where we only normalize *weak* alias types not arbitrary ones). Weak alias types are injective if the corresp. “normalized” type is injective.

Both have ad hoc overflow detection mechanisms.

**Coherence** is handled in #117164.

r? `@oli-obk` or types

[whnf]: https://en.wikipedia.org/wiki/Lambda_calculus_definition#Weak_head_normal_form
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this pull request Apr 27, 2024
Properly deal with weak alias types as self types of impls

Fixes #114216.
Fixes #116100.

Not super happy about the two ad hoc “normalization” implementations for weak alias types:

1. In `inherent_impls`: The “peeling”, normalization to [“WHNF”][whnf]: Semantically that's exactly what we want (neither proper normalization nor shallow normalization would be correct here). Basically a weak alias type is “nominal” (well...^^) if the WHNF is nominal. [#97974](rust-lang/rust#97974) followed the same approach.
2. In `constrained_generic_params`: Generic parameters are constrained by a weak alias type if the corresp. “normalized” type constrains them (where we only normalize *weak* alias types not arbitrary ones). Weak alias types are injective if the corresp. “normalized” type is injective.

Both have ad hoc overflow detection mechanisms.

**Coherence** is handled in #117164.

r? `@oli-obk` or types

[whnf]: https://en.wikipedia.org/wiki/Lambda_calculus_definition#Weak_head_normal_form
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add TyKind::Alias to keep type alias information