1
Fork 0

middle: add implies_by to #[unstable]

If part of a feature is stabilized and a new feature is added for the
remaining parts, then the `implied_by` attribute can be used to indicate
which now-stable feature previously contained a item. If the now-stable
feature is still active (if the user has only just updated rustc, for
example) then there will not be an stability error for uses of the item
from the implied feature.

Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
David Wood 2022-07-13 13:10:37 +01:00
parent a1d5af24ec
commit 224aec213d
12 changed files with 150 additions and 4 deletions

View file

@ -796,9 +796,16 @@ impl<'a> Resolver<'a> {
) {
let span = path.span;
if let Some(stability) = &ext.stability {
if let StabilityLevel::Unstable { reason, issue, is_soft } = stability.level {
if let StabilityLevel::Unstable { reason, issue, is_soft, implied_by } = stability.level
{
let feature = stability.feature;
if !self.active_features.contains(&feature) && !span.allows_unstable(feature) {
let is_allowed = |feature| {
self.active_features.contains(&feature) || span.allows_unstable(feature)
};
let allowed_by_implication =
implied_by.map(|feature| is_allowed(feature)).unwrap_or(false);
if !is_allowed(feature) && !allowed_by_implication {
let lint_buffer = &mut self.lint_buffer;
let soft_handler =
|lint, span, msg: &_| lint_buffer.buffer_lint(lint, node_id, span, msg);