Skip to content

Provide more context on type errors in const context#153881

Merged
rust-bors[bot] merged 6 commits intorust-lang:mainfrom
estebank:const-e0308
Mar 15, 2026
Merged

Provide more context on type errors in const context#153881
rust-bors[bot] merged 6 commits intorust-lang:mainfrom
estebank:const-e0308

Conversation

@estebank
Copy link
Copy Markdown
Contributor

@estebank estebank commented Mar 14, 2026

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 14, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 14, 2026

r? @fee1-dead

rustbot has assigned @fee1-dead.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 69 candidates
  • Random selection from 15 candidates

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 14, 2026
@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_hir_typeck/src/lib.rs
Copy link
Copy Markdown
Member

@Kivooeo Kivooeo left a comment

Choose a reason for hiding this comment

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

looks like a big improvement to me, impl also seems fine

View changes since this review

@Kivooeo Kivooeo assigned Kivooeo and unassigned fee1-dead Mar 14, 2026
@rust-log-analyzer

This comment has been minimized.

- On `const` and `static` point at the type (like we do for let bindings)
- On fn calls, point at const parameter in fn definition
- On type, point at const parameter in type definition
- On array type lengths, explain that array length is always `usize`
- On enum variant discriminant, mention `repr`
…ers unless going through the type parameter

```
error[E0308]: mismatched types
  --> $DIR/struct-type-parameter-with-default.rs:5:12
   |
LL | struct Foo<T = String> {
   |            ---------- expected this type parameter
LL |     x: T = String::new(),
   |            ^^^^^^^^^^^^^ expected type parameter `T`, found `String`
   |
   = note: expected type parameter `T`
                      found struct `String`
   = note: the type of default fields referencing type parameters can't be assumed inside the struct defining them
```
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 14, 2026

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Mar 14, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 14, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

This comment has been minimized.

@Kivooeo
Copy link
Copy Markdown
Member

Kivooeo commented Mar 15, 2026

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Mar 15, 2026

📌 Commit 249f52c has been approved by Kivooeo

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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-review Status: Awaiting review from the assignee but also interested parties. labels Mar 15, 2026
rust-bors Bot pushed a commit that referenced this pull request Mar 15, 2026
Rollup of 6 pull requests

Successful merges:

 - #153870 (docs: remove stale reference to `check_let_chain`)
 - #153881 (Provide more context on type errors in const context)
 - #153887 (Turn label into structured suggestion for `.as_ref()` and `.as_mut()`)
 - #153897 (Use less `#[macro_use]` in the query system)
 - #153914 (add test for param-env shadowing)
 - #153917 (compiletest: show rustdoc logs when `--no-capture`)
@rust-bors rust-bors Bot merged commit 81549a3 into rust-lang:main Mar 15, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 15, 2026
github-actions Bot pushed a commit to rust-lang/miri that referenced this pull request Mar 16, 2026
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#153870 (docs: remove stale reference to `check_let_chain`)
 - rust-lang/rust#153881 (Provide more context on type errors in const context)
 - rust-lang/rust#153887 (Turn label into structured suggestion for `.as_ref()` and `.as_mut()`)
 - rust-lang/rust#153897 (Use less `#[macro_use]` in the query system)
 - rust-lang/rust#153914 (add test for param-env shadowing)
 - rust-lang/rust#153917 (compiletest: show rustdoc logs when `--no-capture`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide hint when field default is of a concrete type and the field type is or contains a rigid generic param that has a default

5 participants