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

Consider changing Span::unknown() and various instances of Span { start: 0, end: 0 } to something else #7308

Open
webbedspace opened this issue Dec 1, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@webbedspace
Copy link
Contributor

Related problem

No response

Describe the solution you'd like

In a recent PR of mine, I was told not to use Span { start: 0, end: 0 } or Span::unknown() because when displayed in errors, they show garbage arrows pointing to arbitrary code.

However, these are still used in various places in the code, so I'm opening an issue for having them replaced with something else.

"Something else" because I don't have enough familiarity with the codebase to say what this would be. A better Span variant whose error arrows are explicitly not printed, perhaps?

Describe alternatives you've considered

No response

Additional context and details

No response

@webbedspace webbedspace added the enhancement New feature or request label Dec 1, 2022
@fdncred
Copy link
Collaborator

fdncred commented Dec 1, 2022

There is Span::test_data() for the occasion when spans don't matter as much, like in tests. Maybe this isn't what you're talking about though since it's the same as the other ones you mentioned.

@sophiajt
Copy link
Contributor

sophiajt commented Dec 7, 2022

Yeah, I wonder if we can make a lint that allows test_data() in lints but other places requires you to use a real span.

@sophiajt
Copy link
Contributor

sophiajt commented Dec 7, 2022

I might have a way to clean this up... experimenting now

@sophiajt
Copy link
Contributor

sophiajt commented Dec 7, 2022

This should help: #7383

There are still other sources of Span::unknown() and Span::new(0, 0), so it's just a start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants