Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ impl AttributeParser for OnUnknownParser {
const ATTRIBUTES: AcceptMapping<Self> = &[(
&[sym::diagnostic, sym::on_unknown],
template!(List: &[r#"/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...""#]),
AttributeStability::Stable, // Unstable, stability checked manually below
AttributeStability::Stable,
|this, cx, args| {
gate_diagnostic_attr!(diagnostic_on_unknown);

let span = cx.attr_span;
this.span = Some(span);
let mode = Mode::DiagnosticOnUnknown;
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ declare_features! (
(accepted, destructuring_assignment, "1.59.0", Some(71126)),
/// Allows using the `#[diagnostic]` attribute tool namespace
(accepted, diagnostic_namespace, "1.78.0", Some(111996)),
/// Allows giving unresolved imports a custom diagnostic message
(accepted, diagnostic_on_unknown, "CURRENT_RUSTC_VERSION", Some(152900)),
/// Controls errors in trait implementations.
(accepted, do_not_recommend, "1.85.0", Some(51992)),
/// Allows `#[doc(alias = "...")]`.
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,6 @@ declare_features! (
(unstable, diagnostic_on_move, "1.96.0", Some(154181)),
/// Allows giving custom types diagnostic messages on type errors
(unstable, diagnostic_on_type_error, "1.98.0", Some(155382)),
/// Allows giving unresolved imports a custom diagnostic message
(unstable, diagnostic_on_unknown, "1.96.0", Some(152900)),
/// Allows macros to customize macro argument matcher diagnostics.
(unstable, diagnostic_on_unmatched_args, "1.97.0", Some(155642)),
/// Used by macros to not show their bodies in error messages. No-op with `-Z macro-backtrace`.
Expand Down
13 changes: 6 additions & 7 deletions compiler/rustc_resolve/src/diagnostics/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4395,13 +4395,12 @@ impl OnUnknownData {
r: &Resolver<'_, '_>,
attrs: &[ast::Attribute],
) -> Option<OnUnknownData> {
if r.features.diagnostic_on_unknown()
&& let Some(Attribute::Parsed(AttributeKind::OnUnknown { directive, .. })) =
AttributeParser::parse_limited_sym(
r.tcx.sess,
attrs,
&[sym::diagnostic, sym::on_unknown],
)
if let Some(Attribute::Parsed(AttributeKind::OnUnknown { directive, .. })) =
AttributeParser::parse_limited_sym(
r.tcx.sess,
attrs,
&[sym::diagnostic, sym::on_unknown],
)
{
Some(Self { directive: directive? })
} else {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

// tidy-alphabetical-start
#![allow(internal_features)]
#![cfg_attr(bootstrap, feature(diagnostic_on_unknown))]
#![cfg_attr(target_arch = "loongarch64", feature(stdarch_loongarch))]
#![feature(core_io_borrowed_buf)]
#![feature(decl_macro)]
#![feature(diagnostic_on_unknown)]
#![feature(map_try_insert)]
#![feature(negative_impls)]
#![feature(read_buf)]
Expand Down
196 changes: 0 additions & 196 deletions src/doc/unstable-book/src/language-features/diagnostic-on-unknown.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![crate_type = "lib"]
#![feature(diagnostic_on_unknown)]

#[diagnostic::on_unknown(message = "you silly, this module is empty")]
pub mod empty {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(custom_inner_attributes)]
#![feature(diagnostic_on_unknown)]
#![crate_type = "lib"]

#![diagnostic::on_unknown(message = "you silly, the crate `{This}` is empty")]
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![crate_type = "lib"]
#![feature(diagnostic_on_unknown)]

#[diagnostic::on_unknown(
message = "THIS MUST NEVER BE SHOWN",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0432]: the message
--> $DIR/combined_use_and_module.rs:22:9
--> $DIR/combined_use_and_module.rs:21:9
|
LL | pub use constants::THREE;
| ^^^^^^^^^^^-----
Expand Down
1 change: 0 additions & 1 deletion tests/ui/diagnostic_namespace/on_unknown/crate_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// See https://doc.rust-lang.org/nightly/reference/items/use-declarations.html#r-items.use.path.edition2018

#![feature(custom_inner_attributes)]
#![feature(diagnostic_on_unknown)]
#![crate_type = "lib"]

// Only applies to the root, not everything in the entire crate
Expand Down
10 changes: 5 additions & 5 deletions tests/ui/diagnostic_namespace/on_unknown/crate_level.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0432]: crate_level `crate_level_test`
--> $DIR/crate_level.rs:14:9
--> $DIR/crate_level.rs:13:9
|
LL | pub use crate::foo;
| ^^^^^^^---
Expand All @@ -9,29 +9,29 @@ LL | pub use crate::foo;
= note: unresolved import `crate::foo`

error[E0432]: unresolved import `bar`
--> $DIR/crate_level.rs:17:9
--> $DIR/crate_level.rs:16:9
|
LL | pub use ::bar;
| ^^---
| |
| no external crate `bar`

error[E0432]: unresolved import `baz`
--> $DIR/crate_level.rs:20:9
--> $DIR/crate_level.rs:19:9
|
LL | pub use baz;
| ^^^ no external crate `baz`

error[E0432]: unresolved import `crate::module::waz`
--> $DIR/crate_level.rs:23:9
--> $DIR/crate_level.rs:22:9
|
LL | pub use crate::module::waz;
| ^^^^^^^^^^^^^^^---
| |
| no `waz` in `module`

error[E0432]: unresolved import `module::bluz`
--> $DIR/crate_level.rs:26:9
--> $DIR/crate_level.rs:25:9
|
LL | pub use module::bluz;
| ^^^^^^^^----
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(diagnostic_on_unknown)]

#[diagnostic::on_unknown(message = "foo {}")]
//~^ WARN: positional arguments are not permitted in diagnostic attributes
use std::does_not_exist;
Expand Down
Loading
Loading