Stream: t-compiler/wg-incr-comp

Topic: implementing the expect RFC rust#87835


view this post on Zulip xFrednet (Aug 10 2021 at 10:43):

Hello, I've got a working implementation of the expect attribute in rust#87835. The implementation is currently based on an ID that is assigned to each lint expectation when it's discovered in the LintLevelsBuilder. The ID is then stored as part of the new Expect lint level and used to link the diagnostic to the expectation. This works well in test files.

The current implementation creates the expectation ID based on the AttrId of the attribute that the expectation originated from. However, that ID is not stable. I'm now struck on how to create an ID that's stable between compilation sessions. The LintLevelsBuilder is also used during the EarlyLintPass inside EarlyContext to track the current level for lints during that pass. It would also be a viable option to use the HirId of the item/statement that the attribute is on, but the HirId is not available in the early lint pass (to my knowledge).

Could somebody maybe take a look at the implementation and help me find a stable way to generate an expectation ID?


The PR description contains a more detailed explanation about the implementation and as well as reasoning why this ID has to be stable.

view this post on Zulip Notification Bot (Aug 10 2021 at 10:45):

xFrednet has marked this topic as resolved.

view this post on Zulip Notification Bot (Aug 10 2021 at 10:45):

xFrednet has marked this topic as unresolved.

view this post on Zulip Wesley Wiser (Oct 01 2021 at 17:20):

@xFrednet If you can use the HirId, that will be a lot more stable than just the attribute id. (https://rustc-dev-guide.rust-lang.org/identifiers.html#in-the-hir)

DefId is the most stable but I don't think you have access to those when EarlyLintPasses run.


Last updated: Oct 21 2021 at 20:33 UTC