Comments (8)
cc @xFrednet who has been handling expect
from rust.
Thank you for the ping. So my educated guess is that this issue comes from how rustc handles group imports. The import from the issue is internally desugared into three separate imports, like this (Playground "Show HIR"):
#[expect(unused_imports)]
use ::{};
#[expect(unused_imports)]
use std::io;
#[expect(unused_imports)]
use std::fs;
From the text output of HIR it looks like the attributes are duplicated. This in turn creates additional expectations which are not fulfilled.
The question is now, hot to figure out, that these items and attributes all originate from the same item.
@cjgillot do you maybe have an idea on this one?
from rust.
That's not the only place where we duplicate attributes. I had to partially work around it in #127313, but that's not a good solution in general.
Right now, the diagnostic infra stores the stable LintExpectationId
, we update unstable -> stable before emitting diagnostics, and we try to match the stable id.
What if we did the other way?
I mean:
- In the
DiagCtxtInner
, store keepfulfilled_expectations: Vec<LintExpectationId>
but stop stashing diagnostics to convert unstable->stable version, just emit them. Emitting an unstable id should only happen from pre-lowering code, which is not incremental, so we won't try to decode such a diagnostic to re-emit it. - In
lint_expectations(())
, stop computing the unstable -> stable mapping. - In
check_expectations(())
, make aFxHashSet<(AttrId, u16)>
from the global fulfilled expectations, and use it to check whatlint_expectations(())
returns.
Step 3 should be ok for incr comp, as check_expectations
is eval_always.
Does that make sense to you?
from rust.
I'm not sure, I fully understand you. Does this rephrasing sound reasonably close?
- The pre-lowering code, that can emit unstable
LintExpectationID
s is always executed. Instead of transforming these ID's we just don't store between compilations as they will be emitted again during the next run. lint_expectations()
returns all lint expectations defined by the user.check_expectations()
will take the stable IDs and map them to their unstable versions. These unstable ID's are then used to fulfill the expectations fromlint_expectations()
. And this should fix this issue since the AST hasn't duplicated any attributes yet.
from rust.
Yes.
from rust.
On what level does lint_expectations()
operate? Is it on the AST or HIR?
Because, if it's on the HIR, we still need to find a way to map from duplicated attributes back to their original single ones. Don't we?
from rust.
lint_expectations()
can operate on either, depending on what is easier to code. You could also have the early lint pass feed it.
check_expectations()
can always look at the attribute in HIR to do this mapping. Given id: LintExpectationId
, something like:
match id {
Unstable { attr_id, lint_index: Some(lint_index) } => (attr_id, lint_index),
Stable { hir_id, attr_index, lint_index: Some(lint_index) } => {
// We are an `eval_always` query, so looking at the attribute's `AttrId` is ok.
let attr_id = tcx.hir().attrs(hir_id)[attr_index].id;
(attr_id, lint_index)
}
_ => bug!(),
}
When we duplicate the attributes, we don't change the AttrId, so relying on it is ok.
from rust.
Interesting, yep, then this should work :D
Is this something that can/should be done with #127313?
If we want to make it a followup PR, we should probably ping the reviewer or reroll 🤔
from rust.
Related Issues (20)
- ICE: `adding a def'n for node-id NodeId(18) and def kind AnonConst but a previous def'n exists` HOT 1
- Doctests cannot recognize paths that lead to a type in the crate root HOT 2
- `./x check std` should not try to check `no_std` targets
- Tracking Issue for unsized const parameter types: `feature(unsized_const_params)`
- Some invalid cargo cache data leads to ICE
- Goofy suggestion when trying to use a raw ptr receiver and also the self keyword in the body HOT 1
- Tracking Issue for Contracts
- Vetting 3rd party crates for supply-chain-security issues
- Error when compiling `cdylib` using `JNI` HOT 13
- Did miri spot a concurrency bug taking RwLockWriteGuard? HOT 1
- dead-code false positive on named structs with a never field HOT 6
- compiletest: error if `-Cincremental` is passed in compile-flags in ui tests HOT 2
- compiletest: don't silently accept unsupported directives in test suites
- Type parameter captured inside closure may not live long enough HOT 2
- Error when running windows .exe compiled on linux HOT 6
- global_asm-implemented extern "C" functions are not exported from dylib crates HOT 5
- UdpSocket `recv()` fails after `send()` to a closed port HOT 3
- Compiler crash when trying to compile Zed HOT 5
- The `slice::chunks_exact` iterator does not optimize when the initial slice is non-empty
- Invalid cast error when trying to cast a closure to a function pointer should mention captured variables
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.