Skip to content
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

allow_internal_unstable silently ignores typos in feature names #77226

Open
bugadani opened this issue Sep 26, 2020 · 6 comments
Open

allow_internal_unstable silently ignores typos in feature names #77226

bugadani opened this issue Sep 26, 2020 · 6 comments
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) C-bug Category: This is a bug.

Comments

@bugadani
Copy link
Contributor

While working on #77088 I wasted a lot of time looking for a bug in my code, when the issue was that I made a typo in the feature name in my test case.

I think it would make sense to check that the feature to be allowed actually exists.

@jonas-schievink jonas-schievink added A-attributes Area: Attributes (`#[…]`, `#![…]`) C-bug Category: This is a bug. labels Sep 26, 2020
@bugadani
Copy link
Contributor Author

bugadani commented Sep 26, 2020

Soooo... I've tried doing this, but apparently, some features are not features 👀:

error: `allow_internal_unstable` expects feature names
    --> library/core/src/macros/mod.rs:1389:31
     |
1389 |     #[allow_internal_unstable(core_intrinsics, libstd_sys_internals)]
     |                               ^^^^^^^^^^^^^^^

error: `allow_internal_unstable` expects feature names
    --> library/core/src/macros/mod.rs:1389:48
     |
1389 |     #[allow_internal_unstable(core_intrinsics, libstd_sys_internals)]
     |                                                ^^^^^^^^^^^^^^^^^^^^

@est31
Copy link
Member

est31 commented Sep 26, 2020

@bugadani there are lib features and lang features. Only the second type is hardcoded in the compiler. For the first type, you need to check whether it's been declared in one of the upstream crates.

@bugadani
Copy link
Contributor Author

As far as I can tell, lib features aren't available at the point of macro expansion. At least I can't see a way to list those, but let me know if I missed something.

This means that fixing this issue is far from trivial.

@varkor varkor added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. and removed E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Sep 28, 2020
@varkor
Copy link
Member

varkor commented Sep 28, 2020

Somewhat related to #69399, as allow_internal_unstable doesn't currently accept library features anyway.

@bugadani
Copy link
Contributor Author

Somewhat related to #69399, as allow_internal_unstable doesn't currently accept library features anyway.

Technically, all the attribute does is plain string comparison. In fact, allow_internal_unstable IS used to gate library features - the error excerpt I pasted above is from compiling std IIRC. One feature I distinctly remember used is core_panic. If these shouldn't be accepted, then there are several such uses to be cleaned up.

@varkor
Copy link
Member

varkor commented Sep 29, 2020

Ah, it only doesn't accept library functions in certain places. So it's less relevant than I thought.

@jyn514 jyn514 changed the title allow_internal_unstable silently ingores typos in feature names allow_internal_unstable silently ignores typos in feature names Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

4 participants