Skip to content

Conversation

@nilotpal-n7
Copy link
Contributor

@nilotpal-n7 nilotpal-n7 commented Sep 9, 2025

Add Removed Library Features API and tests (unstable_removed)

Summary

This PR introduces explicit test coverage for removed library features,
ensuring that rustc reports the correct diagnostic (E0557) when such a
feature is used.

A dummy feature unstable_removed was added to exercise the mechanism.
The error message now includes both the version in which the feature was
removed (1.89.0) and the removal reason (test_reason).

Changes

1. Compiler Internals

  • Extended rustc_session::Session to carry a removed_features: Vec<RemovedFeature>.
  • Integrated removed feature handling so diagnostics include extra details (since + reason).

2. Diagnostics

  • When a removed feature is encountered, rustc now emits:
E0557: feature has been removed

with additional notes for the removal version and reason.

3. New UI Test

  • Added tests/ui/stability-attribute/removed-library-feature.rs:
// check-fail
// compile-flags: -Z unstable-options

#![feature(unstable_removed)] //~ ERROR feature has been removed

fn main() {}
  • Added corresponding .stderr file to assert:
error[E0557]: feature has been removed
  --> $DIR/removed-library-feature.rs:4:12
   |
LL | #![feature(unstable_removed)]
   |            ^^^^^^^^^^^^^^^^ feature has been removed
   |
   = note: removed in 1.89.0
   = note: test_reason

Motivation

  • Ensures removed feature diagnostics are tested and stable, preventing regressions in future compiler changes.
  • Improves clarity by surfacing both the removal version and the reason.

Testing

  • Ran the UI test suite with:
./x test tests/ui/stability-attribute/removed-library-feature.rs -- --bless
  • Verified that diagnostics match expected output exactly.
  • Confirmed no regressions in other tests.

Future Work

  • Extend coverage to other removed features if necessary.
  • Ensure all removed feature diagnostics include metadata consistently.

Issue: #141617

@rustbot
Copy link
Collaborator

rustbot commented Sep 9, 2025

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

Some changes occurred to constck

cc @fee1-dead

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

Some changes occurred in compiler/rustc_hir/src/attrs

cc @jdonszelmann

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Sep 9, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 9, 2025

r? @petrochenkov

rustbot has assigned @petrochenkov.
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

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 9, 2025
@rust-log-analyzer

This comment has been minimized.

@jdonszelmann
Copy link
Contributor

r? jdonszelmann

@rustbot rustbot assigned jdonszelmann and unassigned petrochenkov Sep 9, 2025
@jdonszelmann
Copy link
Contributor

(btw, we usually rebase onto master, not merge master into feature branches. we can't merge like this)

@rustbot
Copy link
Collaborator

rustbot commented Sep 9, 2025

Some changes occurred in src/tools/cargo

cc @ehuss

@rustbot

This comment has been minimized.

} else if let Some(v) = super::util::parse_version(s) {
since_opt = Some(StableSince::Version(v));
} else {
let err = cx.emit_err(session_diagnostics::InvalidSince {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just error out in this case instead of putting a magic symbol in. If you do want to continue, return None but using sym::err doesn't seem like a great idea

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is not yet addressed

@rustbot
Copy link
Collaborator

rustbot commented Sep 9, 2025

⚠️ Warning ⚠️

@rustbot rustbot removed has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 9, 2025
@jdonszelmann
Copy link
Contributor

@rustbot author (I'll review more when CI passes)

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Sep 9, 2025

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@rustbot

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Sep 9, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

This comment has been minimized.

@fee1-dead fee1-dead self-assigned this Sep 9, 2025
@fee1-dead
Copy link
Member

I would recommend using the concat_idents feature to test the #![unstable_removed] once that gets actually implemented

@nilotpal-n7 nilotpal-n7 changed the title Add UI Test for Removed Library Features (unstable_removed) Add Removed Library Features API and tests (unstable_removed) Sep 10, 2025
@nilotpal-n7

This comment was marked as spam.

@rustbot rustbot 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 Sep 10, 2025
@jdonszelmann
Copy link
Contributor

Adding a logging system is not a fix for an ICE, and we don't just print things in the middle of the compiler. (In response to your latest commit). It seems, though I might be wrong, that you use a lot of AI generated code, or at the very least submit code that is not ready to be part of the compiler. There are many things I could comment on but in the current state I don't want to spend any more time on it since there are still many very obvious problems. I recommend you review your own diff by yourself and make another pass on it yourself. However, if after that it's still like this I'm going to close this PR

@jdonszelmann
Copy link
Contributor

@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 Sep 10, 2025
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 10, 2025
@RalfJung
Copy link
Member

I also see no reason why we would even need a new StabilityLevel to deal with the remaining part of #141617. Renamed language features also don't have that I think?

@nilotpal-n7 nilotpal-n7 deleted the remove-lib-feature branch September 10, 2025 07:11
@nilotpal-n7 nilotpal-n7 restored the remove-lib-feature branch September 10, 2025 07:12
@nilotpal-n7 nilotpal-n7 deleted the remove-lib-feature branch October 18, 2025 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants