Skip to content

Commit bf00daa

Browse files
authored
Unrolled build for #141162
Rollup merge of #141162 - mejrs:gated, r=fee1-dead refactor `AttributeGate` and `rustc_attr!` to emit notes during feature checking First commit changes the following: - `AttributeGate ` from an enum with (four) tuple fields to (five) named fields - adds a `notes` fields that is emitted as notes in the `PostExpansionVisitor` pass - removes the `this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date` note if the feature gate is `rustc_attrs`. - various phrasing changes and touchups - and finally, the reason why I went down this path to begin with: tell people they can use the diagnostic namespace when they hit the rustc_on_unimplemented feature gate 🙈 Second commit removes unused machinery for deprecated attributes
2 parents ed44c0e + 81eb182 commit bf00daa

28 files changed

+256
-278
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ macro_rules! gate_alt {
3636
feature_err(&$visitor.sess, $name, $span, $explain).emit();
3737
}
3838
}};
39+
($visitor:expr, $has_feature:expr, $name:expr, $span:expr, $explain:expr, $notes: expr) => {{
40+
if !$has_feature && !$span.allows_unstable($name) {
41+
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
42+
let mut diag = feature_err(&$visitor.sess, $name, $span, $explain);
43+
for note in $notes {
44+
diag.note(*note);
45+
}
46+
diag.emit();
47+
}
48+
}};
3949
}
4050

4151
/// The case involving a multispan.
@@ -154,11 +164,11 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
154164
let attr_info = attr.ident().and_then(|ident| BUILTIN_ATTRIBUTE_MAP.get(&ident.name));
155165
// Check feature gates for built-in attributes.
156166
if let Some(BuiltinAttribute {
157-
gate: AttributeGate::Gated(_, name, descr, has_feature),
167+
gate: AttributeGate::Gated { feature, message, check, notes, .. },
158168
..
159169
}) = attr_info
160170
{
161-
gate_alt!(self, has_feature(self.features), *name, attr.span, *descr);
171+
gate_alt!(self, check(self.features), *feature, attr.span, *message, *notes);
162172
}
163173
// Check unstable flavors of the `#[doc]` attribute.
164174
if attr.has_name(sym::doc) {

0 commit comments

Comments
 (0)