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

Provide structured suggestion for #![feature(..)] in more cases #134858

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

estebank
Copy link
Contributor

Fix #81370.

When encountering a call corresponding to an item marked as unstable behind a feature flag, provide a structured suggestion pointing at where in the crate the `#![feature(..)]` needs to be written.

```
error: `foobar` is not yet stable as a const fn
  --> $DIR/const-stability-attribute-implies-no-feature.rs:12:5
   |
LL |     foobar();
   |     ^^^^^^^^
   |
help: add `#![feature(const_foobar)]` to the crate attributes to enable
   |
LL + #![feature(const_foobar)]
   |
```

Fix rust-lang#81370.
@rustbot
Copy link
Collaborator

rustbot commented Dec 28, 2024

r? @Noratrieb

rustbot has assigned @Noratrieb.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 28, 2024
@rustbot
Copy link
Collaborator

rustbot commented Dec 28, 2024

Some changes occurred to the CTFE machinery

cc @rust-lang/wg-const-eval

@compiler-errors
Copy link
Member

Yeah, please revert the example that Ralf pointed out is redundant.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 30, 2024
@estebank estebank added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 30, 2024
@compiler-errors
Copy link
Member

plz squash rather than pushing a new commit xD

```
error: `size_of_val` is not yet stable as a const intrinsic
  --> $DIR/const-unstable-intrinsic.rs:17:9
   |
LL |         unstable_intrinsic::size_of_val(&x);
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: add `#![feature(unstable)]` to the crate attributes to enable
help: add `#![feature(unstable)]` to the crate attributes to enable
   |
LL + #![feature("unstable")]
   |
```
```
error[E0797]: base expression required after `..`
  --> $DIR/feature-gate-default-field-values.rs:62:21
   |
LL |     let x = Foo { .. };
   |                     ^
   |
help: add `#![feature(default_field_values)]` to the crate attributes to enable default values on `struct` fields
   |
LL + #![feature(default_field_values)]
   |
help: add a base expression here
   |
LL |     let x = Foo { ../* expr */ };
   |                     ++++++++++
```
@estebank
Copy link
Contributor Author

squashed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error reporting for #![feature(...)] in the wrong place
5 participants