Skip to content

Don't allow overwriting SESSION_GLOBALS #84954

Closed
@Aaron1011

Description

@Aaron1011

Since rustc_span::SESSION_GLOBALS uses scoped-tls, it can be overwritten by calling SESSION_GLOBALS.set from within the closure passed to the original call to SESSION_GLOBALS.set. Any Spans created in the 'outer' SessionGlobals may become unusable within the inner SessionGlobals, since they will be pointing to the wrong interner. See #84953 for an example of this happening.

There is no reason to modify SESSION_GLOBALs once it's set for the first time. We should make it private to the rustc_span crate, and only expose setters which assert that it is currently unset.

Metadata

Metadata

Labels

C-enhancementCategory: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions