Skip to content

error printed twice for deref recursion limit exceeded #38940

@durka

Description

@durka

I wrote some code for a rustc test which intentionally hits the recursion limit while trying to autoderef from &Top to &Bottom.

In nightly the error when autoderef hits the recursion limit is printed twice. The second time it is printed without a real span.

Stable and beta:

rustc 1.14.0 (e8a012324 2016-12-16)
error[E0055]: reached the recursion limit while auto-dereferencing I
  --> <anon>:60:22
   |
60 |     let x: &Bottom = &t;
   |                      ^^ deref recursion limit reached

error[E0308]: mismatched types
  --> <anon>:60:22
   |
60 |     let x: &Bottom = &t;
   |                      ^^ expected struct `Bottom`, found struct `Top`
   |
   = note: expected type `&Bottom`
   = note:    found type `&Top`

error: aborting due to 2 previous errors

Nightly:

error[E0055]: reached the recursion limit while auto-dereferencing I
  --> xx.rs:60:22
   |
60 |     let x: &Bottom = &t;
   |                      ^^ deref recursion limit reached

error[E0055]: reached the recursion limit while auto-dereferencing I

error[E0308]: mismatched types
  --> xx.rs:60:22
   |
60 |     let x: &Bottom = &t;
   |                      ^^ expected struct `Bottom`, found struct `Top`
   |
   = note: expected type `&Bottom`
   = note:    found type `&Top`

error: aborting due to 3 previous errors

It's clearer to see with --error-format=json that the second error has a dummy span attached: https://gist.github.com/durka/04031f5701b5740f0f413267fc913e87

cc @jseyfried @jonathandturner

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions