Migrate a slew of metadata methods to queries by alexcrichton · Pull Request #44142 · rust-lang/rust (original) (raw)

@eddyb

The thing is that there's a handful of methods that were never required, all they do is they read the crate attributes and IMO having the extra method in between muddles that.

It appears I never responded to this. I know I started one... anyway, I actually think the queries do serve (potentially) a purpose. First off, they are clearly (to me) better documentation of the intent than "open-coding" some logic that trawls through the attributes on the crate. That is, I'd prefer that most of the compiler doesn't directly deal in attributes, but uses a helper method to encapsulate that logic (that doesn't necessarily have to be a query).

Second, in terms of incremental logic, having queries does serve a real purpose since it allows us to control change propagation. This is what I was trying to say: having a query means that, once red-green is working, if the user changes the crate attributes, we will be able to avoid recompiling everything (since many things consult these crate attributes, e.g. symbol creation), unless they happen to have changed the result of one of those queries.

Now, it may be that we could just have helper methods instead of the queries: I wouldn't be opposed to that, but it will result in coarser grained incremental support.