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

Check the number of generic lifetime and const parameters of intrinsics #86148

Merged
merged 2 commits into from
Jul 2, 2021

Conversation

FabianWolff
Copy link
Contributor

This pull request fixes #85855. The current code for type checking intrinsics only checks the number of generic type parameters, but does not check for an incorrect number of lifetime or const parameters, which can cause problems later on, such as the ICE in #85855, where the code thought that it was looking at a type parameter but found a lifetime parameter:

error: internal compiler error: compiler/rustc_middle/src/ty/generics.rs:188:18:
    expected type parameter, but found another generic parameter

The changes in this PR add checks for the number of lifetime and const parameters, expand the scope of E0094 to also apply to these cases, and improve the error message by properly pluralizing the number of expected generic parameters.

@rust-highfive
Copy link
Collaborator

r? @varkor

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 8, 2021
@crlf0710 crlf0710 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 26, 2021
Copy link
Member

@varkor varkor left a comment

Choose a reason for hiding this comment

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

Code mostly looks good. I just had a couple of comments. Apologies for taking so long.

compiler/rustc_error_codes/src/error_codes/E0094.md Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/check/intrinsic.rs Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/check/intrinsic.rs Outdated Show resolved Hide resolved
@varkor varkor added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 30, 2021
compiler/rustc_typeck/src/check/intrinsic.rs Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/check/intrinsic.rs Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/check/intrinsic.rs Outdated Show resolved Hide resolved
@varkor
Copy link
Member

varkor commented Jul 1, 2021

Thanks, this all looks good to me now!

@bors r+

@bors
Copy link
Contributor

bors commented Jul 1, 2021

📌 Commit fe93349 has been approved by varkor

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 1, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 1, 2021
Rollup of 7 pull requests

Successful merges:

 - rust-lang#86148 (Check the number of generic lifetime and const parameters of intrinsics)
 - rust-lang#86659 (fix(rustdoc): generics search)
 - rust-lang#86768 (Add myself to mailmap)
 - rust-lang#86775 (Test for const trait impls behind feature gates)
 - rust-lang#86779 (Allow anyone to add or remove any label starting with perf-)
 - rust-lang#86783 (Move Mutex::unlock to T: ?Sized)
 - rust-lang#86785 (proc_macro/bridge: Remove dead code Slice type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ab4d16f into rust-lang:master Jul 2, 2021
@rustbot rustbot added this to the 1.55.0 milestone Jul 2, 2021
@lcnr lcnr added the A-const-generics Area: const generics (parameters and arguments) label Dec 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
7 participants