-
Notifications
You must be signed in to change notification settings - Fork 13.3k
#[inline] attributes should be validated before translation. #45738
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
Comments
Here are some mentoring instructions: Currently, the (Actually, a good first task is to make a failing test. We should be able to create one based on the changes from #45575.) Probably the best place to handle this would be in the I think what I would do is the following. These changes also have the drive-by effect of a fixing a few other shortcomings.
OK, that's a bit rough, but hopefully good to get started, please feel free to ask questions -- though asking on gitter will likely yield faster responses. |
I'd like to have a go at fixing this. |
(This is also #40792, and will likely surface some error-index doctest failures.) |
@zackmdavis thanks, I closed that bug in favor of this one since this one seems to have more |
Trying to create a test case for the various issues here:
I've been extending check_inline ( rust/src/librustc/hir/check_attr.rs Line 61 in 200c4d0
Line 532 in 9f3b091
This currently diagnoses the first 3 errors, but the last one gives:
@nikomatsakis is that warning ok for the last one, or do you want to actually diagnose it as 'error[E0518]: attribute should be applied to function'. |
I pushed some progress to: jgouly@9a8927b One of the issues I'm seeing with asserting that the inline attribute is used after hir validation is this:
But that line doesn't have an inline attribute: https://github.com/jgouly/rust/blob/gh45738/src/libstd/sync/mpsc/mod.rs#L1838 Any ideas? |
I think that warning is OK. In particular, we can't really make this a hard-error without going through a big warning period and so forth -- it would break existing code! -- which means we would need a warning anyhow. Let's start with just the warning, and decide late if we ever want it to be a hard error. (The main problem I see is that if we ever wanted |
Ah, I suspect that the problem is that the attribute is actually on the |
Been very busy and unable to make progress the last few days. Hoping to get this near finished at the weekend. |
@nikomatsakis I have two problems now. One is that the signature for check_attribute was changed to take an ast::Item, in my code I added visit_trait_item and visit_impl_item, so I have ast::TraitItem and ast::ImplItem, what's the best way to abstract over those items? jgouly@a3fcbad The other problem is the LOCAL_CRATE bit, that seems to come from hir::def_id, which I don't have yet as this is at the AST stage. How can I check at this point? |
After talking with @arielb1 and @nikomatsakis on IRC, I'm going to remove the assert, it seems more hassle than it's worth. For the check_attribute I'm just going to pass the item's span, than the item itself. |
If it wasn't obvious, someone else should take this over! My code is here as a starting point: https://github.com/jgouly/rust/tree/gh45738 |
@wesleywiser Is it possible that you fixed this a while ago? I remember you did some work around querifying attributes. |
Closing as it looks like this has been fixed. |
At the moment
#[inline]
attributes are validated by the compiler during translation because that's the first time they are actually used. However, as the compiler gets more lazy, an inline function might be exported without the#[inline]
attribute ever being validate. This can lead to the case of getting an error message only when the function is used in a downstream crate.To solve this issue, modify the compiler so that compile-fail/E0534.rs passes if the inline function is not called from anywhere.
The text was updated successfully, but these errors were encountered: