-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Diagnostic namespace #111780
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
Merged
Merged
Diagnostic namespace #111780
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
tests/ui/diagnostic_namespace/auxiliary/proc-macro-helper.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// force-host | ||
// no-prefer-dynamic | ||
#![crate_type = "proc-macro"] | ||
|
||
extern crate proc_macro; | ||
|
||
use proc_macro::TokenStream; | ||
|
||
#[proc_macro_attribute] | ||
pub fn diagnostic(i: TokenStream, _: TokenStream) -> TokenStream { | ||
i | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/ui/diagnostic_namespace/can_use_the_diagnostic_name_in_other_places.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// check-pass | ||
|
||
mod diagnostic {} | ||
|
||
macro_rules! diagnostic{ | ||
() => {} | ||
} | ||
|
||
#[allow(non_upper_case_globals)] | ||
const diagnostic: () = (); | ||
|
||
fn main() { | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#![feature(diagnostic_namespace)] | ||
// check-pass | ||
// aux-build:proc-macro-helper.rs | ||
|
||
extern crate proc_macro_helper; | ||
|
||
mod test1 { | ||
use proc_macro_helper::diagnostic; | ||
|
||
#[diagnostic] | ||
struct Foo; | ||
|
||
} | ||
|
||
mod test2 { | ||
mod diagnostic { | ||
pub use proc_macro_helper::diagnostic as on_unimplemented; | ||
} | ||
|
||
#[diagnostic::on_unimplemented] | ||
trait Foo {} | ||
} | ||
|
||
fn main() {} |
13 changes: 13 additions & 0 deletions
13
tests/ui/diagnostic_namespace/feature-gate-diagnostic_namespace.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#[diagnostic::non_existing_attribute] | ||
//~^ERROR `#[diagnostic]` attribute name space is experimental [E0658] | ||
//~|WARNING unknown diagnostic attribute [unknown_diagnostic_attributes] | ||
pub trait Bar { | ||
} | ||
|
||
#[diagnostic::non_existing_attribute(with_option = "foo")] | ||
//~^ERROR `#[diagnostic]` attribute name space is experimental [E0658] | ||
//~|WARNING unknown diagnostic attribute [unknown_diagnostic_attributes] | ||
struct Foo; | ||
|
||
fn main() { | ||
} |
35 changes: 35 additions & 0 deletions
35
tests/ui/diagnostic_namespace/feature-gate-diagnostic_namespace.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
error[E0658]: `#[diagnostic]` attribute name space is experimental | ||
--> $DIR/feature-gate-diagnostic_namespace.rs:1:3 | ||
| | ||
LL | #[diagnostic::non_existing_attribute] | ||
| ^^^^^^^^^^ | ||
| | ||
= note: see issue #94785 <https://github.com/rust-lang/rust/issues/94785> for more information | ||
= help: add `#![feature(diagnostic_namespace)]` to the crate attributes to enable | ||
|
||
error[E0658]: `#[diagnostic]` attribute name space is experimental | ||
--> $DIR/feature-gate-diagnostic_namespace.rs:7:3 | ||
| | ||
LL | #[diagnostic::non_existing_attribute(with_option = "foo")] | ||
| ^^^^^^^^^^ | ||
| | ||
= note: see issue #94785 <https://github.com/rust-lang/rust/issues/94785> for more information | ||
= help: add `#![feature(diagnostic_namespace)]` to the crate attributes to enable | ||
|
||
warning: unknown diagnostic attribute | ||
--> $DIR/feature-gate-diagnostic_namespace.rs:1:15 | ||
| | ||
LL | #[diagnostic::non_existing_attribute] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(unknown_diagnostic_attributes)]` on by default | ||
|
||
warning: unknown diagnostic attribute | ||
--> $DIR/feature-gate-diagnostic_namespace.rs:7:15 | ||
| | ||
LL | #[diagnostic::non_existing_attribute(with_option = "foo")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors; 2 warnings emitted | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
13 changes: 13 additions & 0 deletions
13
tests/ui/diagnostic_namespace/non_existing_attributes_accepted.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![feature(diagnostic_namespace)] | ||
// check-pass | ||
#[diagnostic::non_existing_attribute] | ||
//~^WARN unknown diagnostic attribute | ||
pub trait Bar { | ||
} | ||
|
||
#[diagnostic::non_existing_attribute(with_option = "foo")] | ||
//~^WARN unknown diagnostic attribute | ||
struct Foo; | ||
|
||
fn main() { | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/ui/diagnostic_namespace/non_existing_attributes_accepted.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
warning: unknown diagnostic attribute | ||
--> $DIR/non_existing_attributes_accepted.rs:3:15 | ||
| | ||
LL | #[diagnostic::non_existing_attribute] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(unknown_diagnostic_attributes)]` on by default | ||
|
||
warning: unknown diagnostic attribute | ||
--> $DIR/non_existing_attributes_accepted.rs:8:15 | ||
| | ||
LL | #[diagnostic::non_existing_attribute(with_option = "foo")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
warning: 2 warnings emitted | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#![feature(diagnostic_namespace)] | ||
|
||
#[diagnostic] | ||
//~^ERROR cannot find attribute `diagnostic` in this scope | ||
pub struct Bar; | ||
|
||
|
||
fn main() { | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error: cannot find attribute `diagnostic` in this scope | ||
--> $DIR/requires_path.rs:3:3 | ||
| | ||
LL | #[diagnostic] | ||
| ^^^^^^^^^^ | ||
Comment on lines
+1
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before stabilization of the namespace, we'll want to customize this error to be something along the lines of " |
||
|
||
error: aborting due to previous error | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.