diff options
Diffstat (limited to 'tests/ui-fulldeps')
93 files changed, 1956 insertions, 1550 deletions
diff --git a/tests/ui-fulldeps/dropck-tarena-cycle-checked.rs b/tests/ui-fulldeps/dropck-tarena-cycle-checked.rs index cc97971a0..188da6729 100644 --- a/tests/ui-fulldeps/dropck-tarena-cycle-checked.rs +++ b/tests/ui-fulldeps/dropck-tarena-cycle-checked.rs @@ -1,3 +1,5 @@ +// ignore-stage1 + // Reject mixing cyclic structure and Drop when using TypedArena. // // (Compare against dropck-vec-cycle-checked.rs) diff --git a/tests/ui-fulldeps/dropck-tarena-cycle-checked.stderr b/tests/ui-fulldeps/dropck-tarena-cycle-checked.stderr index 47897dc00..2f5be3f7f 100644 --- a/tests/ui-fulldeps/dropck-tarena-cycle-checked.stderr +++ b/tests/ui-fulldeps/dropck-tarena-cycle-checked.stderr @@ -1,5 +1,5 @@ error[E0597]: `arena` does not live long enough - --> $DIR/dropck-tarena-cycle-checked.rs:116:7 + --> $DIR/dropck-tarena-cycle-checked.rs:118:7 | LL | let arena = TypedArena::default(); | ----- binding `arena` declared here @@ -11,6 +11,6 @@ LL | } | `arena` dropped here while still borrowed | borrow might be used here, when `arena` is dropped and runs the `Drop` code for type `TypedArena` -error: aborting due to previous error +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui-fulldeps/dropck-tarena-unsound-drop.rs b/tests/ui-fulldeps/dropck-tarena-unsound-drop.rs index 86485a988..5f9a5fb76 100644 --- a/tests/ui-fulldeps/dropck-tarena-unsound-drop.rs +++ b/tests/ui-fulldeps/dropck-tarena-unsound-drop.rs @@ -1,3 +1,5 @@ +// ignore-stage1 + // Check that an arena (TypedArena) cannot carry elements whose drop // methods might access borrowed data of lifetime that does not // strictly outlive the arena itself. diff --git a/tests/ui-fulldeps/dropck-tarena-unsound-drop.stderr b/tests/ui-fulldeps/dropck-tarena-unsound-drop.stderr index 493d74b0b..8bb391124 100644 --- a/tests/ui-fulldeps/dropck-tarena-unsound-drop.stderr +++ b/tests/ui-fulldeps/dropck-tarena-unsound-drop.stderr @@ -1,5 +1,5 @@ error[E0597]: `arena` does not live long enough - --> $DIR/dropck-tarena-unsound-drop.rs:41:7 + --> $DIR/dropck-tarena-unsound-drop.rs:43:7 | LL | let arena: TypedArena<C> = TypedArena::default(); | ----- binding `arena` declared here @@ -11,6 +11,6 @@ LL | } | `arena` dropped here while still borrowed | borrow might be used here, when `arena` is dropped and runs the `Drop` code for type `TypedArena` -error: aborting due to previous error +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui-fulldeps/fluent-messages/test.rs b/tests/ui-fulldeps/fluent-messages/test.rs index 1dd6d211b..89ac48f36 100644 --- a/tests/ui-fulldeps/fluent-messages/test.rs +++ b/tests/ui-fulldeps/fluent-messages/test.rs @@ -2,9 +2,8 @@ #![feature(rustc_private)] #![crate_type = "lib"] - +extern crate rustc_errors; extern crate rustc_fluent_macro; -use rustc_fluent_macro::fluent_messages; /// Copy of the relevant `DiagnosticMessage` variant constructed by `fluent_messages` as it /// expects `crate::DiagnosticMessage` to exist. @@ -19,51 +18,37 @@ pub enum SubdiagnosticMessage { } mod missing_absolute { - use super::fluent_messages; - - fluent_messages! { "/definitely_does_not_exist.ftl" } + rustc_fluent_macro::fluent_messages! { "/definitely_does_not_exist.ftl" } //~^ ERROR could not open Fluent resource } mod missing_relative { - use super::fluent_messages; - - fluent_messages! { "../definitely_does_not_exist.ftl" } + rustc_fluent_macro::fluent_messages! { "../definitely_does_not_exist.ftl" } //~^ ERROR could not open Fluent resource } mod missing_message { - use super::fluent_messages; - - fluent_messages! { "./missing-message.ftl" } + rustc_fluent_macro::fluent_messages! { "./missing-message.ftl" } //~^ ERROR could not parse Fluent resource } mod duplicate { - use super::fluent_messages; - - fluent_messages! { "./duplicate.ftl" } + rustc_fluent_macro::fluent_messages! { "./duplicate.ftl" } //~^ ERROR overrides existing message: `no_crate_a_b_key` } mod slug_with_hyphens { - use super::fluent_messages; - - fluent_messages! { "./slug-with-hyphens.ftl" } + rustc_fluent_macro::fluent_messages! { "./slug-with-hyphens.ftl" } //~^ ERROR name `no_crate_this-slug-has-hyphens` contains a '-' character } mod label_with_hyphens { - use super::fluent_messages; - - fluent_messages! { "./label-with-hyphens.ftl" } + rustc_fluent_macro::fluent_messages! { "./label-with-hyphens.ftl" } //~^ ERROR attribute `label-has-hyphens` contains a '-' character } mod valid { - use super::fluent_messages; - - fluent_messages! { "./valid.ftl" } + rustc_fluent_macro::fluent_messages! { "./valid.ftl" } mod test_generated { use super::{fluent_generated::no_crate_key, DEFAULT_LOCALE_RESOURCE}; @@ -71,9 +56,7 @@ mod valid { } mod missing_crate_name { - use super::fluent_messages; - - fluent_messages! { "./missing-crate-name.ftl" } + rustc_fluent_macro::fluent_messages! { "./missing-crate-name.ftl" } //~^ ERROR name `no-crate_foo` contains a '-' character //~| ERROR name `with-hyphens` contains a '-' character //~| ERROR name `with-hyphens` does not start with the crate name @@ -87,16 +70,12 @@ mod missing_crate_name { } mod missing_message_ref { - use super::fluent_messages; - - fluent_messages! { "./missing-message-ref.ftl" } + rustc_fluent_macro::fluent_messages! { "./missing-message-ref.ftl" } //~^ ERROR referenced message `message` does not exist } mod bad_escape { - use super::fluent_messages; - - fluent_messages! { "./invalid-escape.ftl" } + rustc_fluent_macro::fluent_messages! { "./invalid-escape.ftl" } //~^ ERROR invalid escape `\n` //~| ERROR invalid escape `\"` //~| ERROR invalid escape `\'` diff --git a/tests/ui-fulldeps/fluent-messages/test.stderr b/tests/ui-fulldeps/fluent-messages/test.stderr index 2affe621c..09d4a3847 100644 --- a/tests/ui-fulldeps/fluent-messages/test.stderr +++ b/tests/ui-fulldeps/fluent-messages/test.stderr @@ -1,20 +1,20 @@ error: could not open Fluent resource: os-specific message - --> $DIR/test.rs:24:24 + --> $DIR/test.rs:21:44 | -LL | fluent_messages! { "/definitely_does_not_exist.ftl" } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | rustc_fluent_macro::fluent_messages! { "/definitely_does_not_exist.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: could not open Fluent resource: os-specific message - --> $DIR/test.rs:31:24 + --> $DIR/test.rs:26:44 | -LL | fluent_messages! { "../definitely_does_not_exist.ftl" } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | rustc_fluent_macro::fluent_messages! { "../definitely_does_not_exist.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: could not parse Fluent resource - --> $DIR/test.rs:38:24 + --> $DIR/test.rs:31:44 | -LL | fluent_messages! { "./missing-message.ftl" } - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | rustc_fluent_macro::fluent_messages! { "./missing-message.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: see additional errors emitted @@ -26,80 +26,80 @@ error: expected a message field for "no_crate_missing_message" | error: overrides existing message: `no_crate_a_b_key` - --> $DIR/test.rs:45:24 + --> $DIR/test.rs:36:44 | -LL | fluent_messages! { "./duplicate.ftl" } - | ^^^^^^^^^^^^^^^^^ +LL | rustc_fluent_macro::fluent_messages! { "./duplicate.ftl" } + | ^^^^^^^^^^^^^^^^^ error: name `no_crate_this-slug-has-hyphens` contains a '-' character - --> $DIR/test.rs:52:24 + --> $DIR/test.rs:41:44 | -LL | fluent_messages! { "./slug-with-hyphens.ftl" } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | rustc_fluent_macro::fluent_messages! { "./slug-with-hyphens.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: replace any '-'s with '_'s error: attribute `label-has-hyphens` contains a '-' character - --> $DIR/test.rs:59:24 + --> $DIR/test.rs:46:44 | -LL | fluent_messages! { "./label-with-hyphens.ftl" } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | rustc_fluent_macro::fluent_messages! { "./label-with-hyphens.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: replace any '-'s with '_'s error: name `with-hyphens` contains a '-' character - --> $DIR/test.rs:76:24 + --> $DIR/test.rs:59:44 | -LL | fluent_messages! { "./missing-crate-name.ftl" } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | rustc_fluent_macro::fluent_messages! { "./missing-crate-name.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: replace any '-'s with '_'s error: name `with-hyphens` does not start with the crate name - --> $DIR/test.rs:76:24 + --> $DIR/test.rs:59:44 | -LL | fluent_messages! { "./missing-crate-name.ftl" } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | rustc_fluent_macro::fluent_messages! { "./missing-crate-name.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: prepend `no_crate_` to the slug name: `no_crate_with_hyphens` error: name `no-crate_foo` contains a '-' character - --> $DIR/test.rs:76:24 + --> $DIR/test.rs:59:44 | -LL | fluent_messages! { "./missing-crate-name.ftl" } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | rustc_fluent_macro::fluent_messages! { "./missing-crate-name.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: replace any '-'s with '_'s error: referenced message `message` does not exist (in message `no_crate_missing_message_ref`) - --> $DIR/test.rs:92:24 + --> $DIR/test.rs:73:44 | -LL | fluent_messages! { "./missing-message-ref.ftl" } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | rustc_fluent_macro::fluent_messages! { "./missing-message-ref.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: you may have meant to use a variable reference (`{$message}`) error: invalid escape `\n` in Fluent resource - --> $DIR/test.rs:99:24 + --> $DIR/test.rs:78:44 | -LL | fluent_messages! { "./invalid-escape.ftl" } - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | rustc_fluent_macro::fluent_messages! { "./invalid-escape.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^ | = note: Fluent does not interpret these escape sequences (<https://projectfluent.org/fluent/guide/special.html>) error: invalid escape `\"` in Fluent resource - --> $DIR/test.rs:99:24 + --> $DIR/test.rs:78:44 | -LL | fluent_messages! { "./invalid-escape.ftl" } - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | rustc_fluent_macro::fluent_messages! { "./invalid-escape.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^ | = note: Fluent does not interpret these escape sequences (<https://projectfluent.org/fluent/guide/special.html>) error: invalid escape `\'` in Fluent resource - --> $DIR/test.rs:99:24 + --> $DIR/test.rs:78:44 | -LL | fluent_messages! { "./invalid-escape.ftl" } - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | rustc_fluent_macro::fluent_messages! { "./invalid-escape.ftl" } + | ^^^^^^^^^^^^^^^^^^^^^^ | = note: Fluent does not interpret these escape sequences (<https://projectfluent.org/fluent/guide/special.html>) diff --git a/tests/ui-fulldeps/internal-lints/diagnostics.rs b/tests/ui-fulldeps/internal-lints/diagnostics.rs index 994fc26ba..4b006151c 100644 --- a/tests/ui-fulldeps/internal-lints/diagnostics.rs +++ b/tests/ui-fulldeps/internal-lints/diagnostics.rs @@ -13,14 +13,13 @@ extern crate rustc_session; extern crate rustc_span; use rustc_errors::{ - AddToDiagnostic, Diagnostic, DiagnosticBuilder, DiagnosticMessage, ErrorGuaranteed, Handler, + AddToDiagnostic, DiagCtxt, Diagnostic, DiagnosticBuilder, DiagnosticMessage, ErrorGuaranteed, IntoDiagnostic, SubdiagnosticMessage, }; -use rustc_fluent_macro::fluent_messages; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::Span; -fluent_messages! { "./diagnostics.ftl" } +rustc_fluent_macro::fluent_messages! { "./diagnostics.ftl" } #[derive(Diagnostic)] #[diag(no_crate_example)] @@ -39,8 +38,8 @@ struct Note { pub struct UntranslatableInIntoDiagnostic; impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for UntranslatableInIntoDiagnostic { - fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> { - handler.struct_err("untranslatable diagnostic") + fn into_diagnostic(self, dcx: &'a DiagCtxt) -> DiagnosticBuilder<'a, ErrorGuaranteed> { + dcx.struct_err("untranslatable diagnostic") //~^ ERROR diagnostics should be created using translatable messages } } @@ -48,8 +47,8 @@ impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for UntranslatableInIntoDiagnostic pub struct TranslatableInIntoDiagnostic; impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for TranslatableInIntoDiagnostic { - fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> { - handler.struct_err(crate::fluent_generated::no_crate_example) + fn into_diagnostic(self, dcx: &'a DiagCtxt) -> DiagnosticBuilder<'a, ErrorGuaranteed> { + dcx.struct_err(crate::fluent_generated::no_crate_example) } } @@ -76,11 +75,11 @@ impl AddToDiagnostic for TranslatableInAddToDiagnostic { } } -pub fn make_diagnostics<'a>(handler: &'a Handler) { - let _diag = handler.struct_err(crate::fluent_generated::no_crate_example); +pub fn make_diagnostics<'a>(dcx: &'a DiagCtxt) { + let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example); //~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls - let _diag = handler.struct_err("untranslatable diagnostic"); + let _diag = dcx.struct_err("untranslatable diagnostic"); //~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls //~^^ ERROR diagnostics should be created using translatable messages } @@ -88,6 +87,6 @@ pub fn make_diagnostics<'a>(handler: &'a Handler) { // Check that `rustc_lint_diagnostics`-annotated functions aren't themselves linted. #[rustc_lint_diagnostics] -pub fn skipped_because_of_annotation<'a>(handler: &'a Handler) { - let _diag = handler.struct_err("untranslatable diagnostic"); // okay! +pub fn skipped_because_of_annotation<'a>(dcx: &'a DiagCtxt) { + let _diag = dcx.struct_err("untranslatable diagnostic"); // okay! } diff --git a/tests/ui-fulldeps/internal-lints/diagnostics.stderr b/tests/ui-fulldeps/internal-lints/diagnostics.stderr index 6e670c018..d18db3cbb 100644 --- a/tests/ui-fulldeps/internal-lints/diagnostics.stderr +++ b/tests/ui-fulldeps/internal-lints/diagnostics.stderr @@ -1,8 +1,8 @@ error: diagnostics should be created using translatable messages - --> $DIR/diagnostics.rs:43:17 + --> $DIR/diagnostics.rs:42:13 | -LL | handler.struct_err("untranslatable diagnostic") - | ^^^^^^^^^^ +LL | dcx.struct_err("untranslatable diagnostic") + | ^^^^^^^^^^ | note: the lint level is defined here --> $DIR/diagnostics.rs:6:9 @@ -11,16 +11,16 @@ LL | #![deny(rustc::untranslatable_diagnostic)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostics should be created using translatable messages - --> $DIR/diagnostics.rs:63:14 + --> $DIR/diagnostics.rs:62:14 | LL | diag.note("untranslatable diagnostic"); | ^^^^ error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls - --> $DIR/diagnostics.rs:80:25 + --> $DIR/diagnostics.rs:79:21 | -LL | let _diag = handler.struct_err(crate::fluent_generated::no_crate_example); - | ^^^^^^^^^^ +LL | let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example); + | ^^^^^^^^^^ | note: the lint level is defined here --> $DIR/diagnostics.rs:7:9 @@ -29,16 +29,16 @@ LL | #![deny(rustc::diagnostic_outside_of_impl)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls - --> $DIR/diagnostics.rs:83:25 + --> $DIR/diagnostics.rs:82:21 | -LL | let _diag = handler.struct_err("untranslatable diagnostic"); - | ^^^^^^^^^^ +LL | let _diag = dcx.struct_err("untranslatable diagnostic"); + | ^^^^^^^^^^ error: diagnostics should be created using translatable messages - --> $DIR/diagnostics.rs:83:25 + --> $DIR/diagnostics.rs:82:21 | -LL | let _diag = handler.struct_err("untranslatable diagnostic"); - | ^^^^^^^^^^ +LL | let _diag = dcx.struct_err("untranslatable diagnostic"); + | ^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui-fulldeps/internal-lints/lint_pass_impl_without_macro.rs b/tests/ui-fulldeps/internal-lints/lint_pass_impl_without_macro.rs index f6f0c0385..fa6734b6c 100644 --- a/tests/ui-fulldeps/internal-lints/lint_pass_impl_without_macro.rs +++ b/tests/ui-fulldeps/internal-lints/lint_pass_impl_without_macro.rs @@ -6,7 +6,7 @@ extern crate rustc_middle; extern crate rustc_session; -use rustc_session::lint::{LintArray, LintPass}; +use rustc_session::lint::{LintPass, LintVec}; use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass}; declare_lint! { diff --git a/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.rs b/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.rs new file mode 100644 index 000000000..392199866 --- /dev/null +++ b/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.rs @@ -0,0 +1,14 @@ +// Test the `rustc::span_use_eq_ctxt` internal lint +// compile-flags: -Z unstable-options +// ignore-stage1 + +#![feature(rustc_private)] +#![deny(rustc::span_use_eq_ctxt)] +#![crate_type = "lib"] + +extern crate rustc_span; +use rustc_span::Span; + +pub fn f(s: Span, t: Span) -> bool { + s.ctxt() == t.ctxt() //~ ERROR use `.eq_ctxt()` instead of `.ctxt() == .ctxt()` +} diff --git a/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.stderr b/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.stderr new file mode 100644 index 000000000..fcf2565c8 --- /dev/null +++ b/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.stderr @@ -0,0 +1,14 @@ +error: use `.eq_ctxt()` instead of `.ctxt() == .ctxt()` + --> $DIR/span_use_eq_ctxt.rs:13:5 + | +LL | s.ctxt() == t.ctxt() + | ^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/span_use_eq_ctxt.rs:6:9 + | +LL | #![deny(rustc::span_use_eq_ctxt)] + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs b/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs index bf655510a..ae7f341fe 100644 --- a/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs +++ b/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs @@ -29,9 +29,8 @@ fn main() { TyKind::FnPtr(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Dynamic(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Closure(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Generator(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::GeneratorWitness(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::GeneratorWitnessMIR(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Coroutine(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::CoroutineWitness(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Never => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Tuple(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Alias(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` diff --git a/tests/ui-fulldeps/internal-lints/ty_tykind_usage.stderr b/tests/ui-fulldeps/internal-lints/ty_tykind_usage.stderr index 9f8c0bea0..45b7c26fa 100644 --- a/tests/ui-fulldeps/internal-lints/ty_tykind_usage.stderr +++ b/tests/ui-fulldeps/internal-lints/ty_tykind_usage.stderr @@ -109,77 +109,71 @@ LL | TyKind::Closure(..) => (), error: usage of `ty::TyKind::<kind>` --> $DIR/ty_tykind_usage.rs:32:9 | -LL | TyKind::Generator(..) => (), +LL | TyKind::Coroutine(..) => (), | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` --> $DIR/ty_tykind_usage.rs:33:9 | -LL | TyKind::GeneratorWitness(..) => (), +LL | TyKind::CoroutineWitness(..) => (), | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` --> $DIR/ty_tykind_usage.rs:34:9 | -LL | TyKind::GeneratorWitnessMIR(..) => (), - | ^^^^^^ help: try using `ty::<kind>` directly: `ty` - -error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:35:9 - | LL | TyKind::Never => (), | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:36:9 + --> $DIR/ty_tykind_usage.rs:35:9 | LL | TyKind::Tuple(..) => (), | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:37:9 + --> $DIR/ty_tykind_usage.rs:36:9 | LL | TyKind::Alias(..) => (), | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:38:9 + --> $DIR/ty_tykind_usage.rs:37:9 | LL | TyKind::Param(..) => (), | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:39:9 + --> $DIR/ty_tykind_usage.rs:38:9 | LL | TyKind::Bound(..) => (), | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:40:9 + --> $DIR/ty_tykind_usage.rs:39:9 | LL | TyKind::Placeholder(..) => (), | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:41:9 + --> $DIR/ty_tykind_usage.rs:40:9 | LL | TyKind::Infer(..) => (), | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:42:9 + --> $DIR/ty_tykind_usage.rs:41:9 | LL | TyKind::Error(_) => (), | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:47:12 + --> $DIR/ty_tykind_usage.rs:46:12 | LL | if let TyKind::Int(int_ty) = kind {} | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind` - --> $DIR/ty_tykind_usage.rs:49:24 + --> $DIR/ty_tykind_usage.rs:48:24 | LL | fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {} | ^^^^^^^^^^ @@ -187,7 +181,7 @@ LL | fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {} = help: try using `Ty` instead error: usage of `ty::TyKind` - --> $DIR/ty_tykind_usage.rs:51:37 + --> $DIR/ty_tykind_usage.rs:50:37 | LL | fn ir_ty_kind<I: Interner>(bad: IrTyKind<I>) -> IrTyKind<I> { | ^^^^^^^^^^^ @@ -195,7 +189,7 @@ LL | fn ir_ty_kind<I: Interner>(bad: IrTyKind<I>) -> IrTyKind<I> { = help: try using `Ty` instead error: usage of `ty::TyKind` - --> $DIR/ty_tykind_usage.rs:51:53 + --> $DIR/ty_tykind_usage.rs:50:53 | LL | fn ir_ty_kind<I: Interner>(bad: IrTyKind<I>) -> IrTyKind<I> { | ^^^^^^^^^^^ @@ -203,12 +197,12 @@ LL | fn ir_ty_kind<I: Interner>(bad: IrTyKind<I>) -> IrTyKind<I> { = help: try using `Ty` instead error: usage of `ty::TyKind::<kind>` - --> $DIR/ty_tykind_usage.rs:54:9 + --> $DIR/ty_tykind_usage.rs:53:9 | LL | IrTyKind::Bool | --------^^^^^^ | | | help: try using `ty::<kind>` directly: `ty` -error: aborting due to 33 previous errors +error: aborting due to 32 previous errors diff --git a/tests/ui-fulldeps/lint-pass-macros.rs b/tests/ui-fulldeps/lint-pass-macros.rs index b3c2a5427..4c6178341 100644 --- a/tests/ui-fulldeps/lint-pass-macros.rs +++ b/tests/ui-fulldeps/lint-pass-macros.rs @@ -5,7 +5,7 @@ extern crate rustc_session; -use rustc_session::lint::{LintArray, LintPass}; +use rustc_session::lint::{LintPass, LintVec}; use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass}; declare_lint! { diff --git a/tests/ui-fulldeps/missing-rustc-driver-error.rs b/tests/ui-fulldeps/missing-rustc-driver-error.rs index 654cd6f6d..b627a207c 100644 --- a/tests/ui-fulldeps/missing-rustc-driver-error.rs +++ b/tests/ui-fulldeps/missing-rustc-driver-error.rs @@ -1,8 +1,8 @@ // Test that we get the following hint when trying to use a compiler crate without rustc_driver. // error-pattern: try adding `extern crate rustc_driver;` at the top level of this crate // compile-flags: --emit link -// The exactly list of required crates depends on the target. as such only test Unix targets. -// only-unix +// normalize-stderr-test ".*crate .* required.*\n\n" -> "" +// normalize-stderr-test: "aborting due to [0-9]+" -> "aborting due to NUMBER" #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/missing-rustc-driver-error.stderr b/tests/ui-fulldeps/missing-rustc-driver-error.stderr index ad03ba010..d7bf27d63 100644 --- a/tests/ui-fulldeps/missing-rustc-driver-error.stderr +++ b/tests/ui-fulldeps/missing-rustc-driver-error.stderr @@ -2,23 +2,5 @@ error: crate `rustc_serialize` required to be available in rlib format, but was | = help: try adding `extern crate rustc_driver;` at the top level of this crate -error: crate `smallvec` required to be available in rlib format, but was not found in this form - -error: crate `thin_vec` required to be available in rlib format, but was not found in this form - -error: crate `indexmap` required to be available in rlib format, but was not found in this form - -error: crate `hashbrown` required to be available in rlib format, but was not found in this form - -error: crate `ahash` required to be available in rlib format, but was not found in this form - -error: crate `once_cell` required to be available in rlib format, but was not found in this form - -error: crate `getrandom` required to be available in rlib format, but was not found in this form - -error: crate `cfg_if` required to be available in rlib format, but was not found in this form - -error: crate `libc` required to be available in rlib format, but was not found in this form - -error: aborting due to 10 previous errors +error: aborting due to NUMBER previous errors diff --git a/tests/ui-fulldeps/pathless-extern-unstable.rs b/tests/ui-fulldeps/pathless-extern-unstable.rs index 7fba8343b..50d157c57 100644 --- a/tests/ui-fulldeps/pathless-extern-unstable.rs +++ b/tests/ui-fulldeps/pathless-extern-unstable.rs @@ -1,5 +1,6 @@ // edition:2018 // compile-flags:--extern rustc_middle +// ignore-stage1 // Test that `--extern rustc_middle` fails with `rustc_private`. diff --git a/tests/ui-fulldeps/pathless-extern-unstable.stderr b/tests/ui-fulldeps/pathless-extern-unstable.stderr index 174cd3c28..840b95d75 100644 --- a/tests/ui-fulldeps/pathless-extern-unstable.stderr +++ b/tests/ui-fulldeps/pathless-extern-unstable.stderr @@ -1,5 +1,5 @@ error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? - --> $DIR/pathless-extern-unstable.rs:6:9 + --> $DIR/pathless-extern-unstable.rs:7:9 | LL | pub use rustc_middle; | ^^^^^^^^^^^^ @@ -7,6 +7,6 @@ LL | pub use rustc_middle; = note: see issue #27812 <https://github.com/rust-lang/rust/issues/27812> for more information = help: add `#![feature(rustc_private)]` to the crate attributes to enable -error: aborting due to previous error +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui-fulldeps/plugin/auxiliary/empty-plugin.rs b/tests/ui-fulldeps/plugin/auxiliary/empty-plugin.rs deleted file mode 100644 index c24cdc97a..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/empty-plugin.rs +++ /dev/null @@ -1,9 +0,0 @@ -// force-host - -#![feature(rustc_private)] - -extern crate rustc_driver; -use rustc_driver::plugin::Registry; - -#[no_mangle] -fn __rustc_plugin_registrar(_: &mut Registry) {} diff --git a/tests/ui-fulldeps/plugin/auxiliary/issue-40001-plugin.rs b/tests/ui-fulldeps/plugin/auxiliary/issue-40001-plugin.rs deleted file mode 100644 index 3f6caecaa..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/issue-40001-plugin.rs +++ /dev/null @@ -1,61 +0,0 @@ -#![feature(plugin, rustc_private)] -#![crate_type = "dylib"] - -extern crate rustc_ast_pretty; -extern crate rustc_driver; -extern crate rustc_hir; -extern crate rustc_lint; -#[macro_use] -extern crate rustc_session; -extern crate rustc_ast; -extern crate rustc_span; - -use rustc_ast_pretty::pprust; -use rustc_driver::plugin::Registry; -use rustc_hir as hir; -use rustc_hir::intravisit; -use rustc_hir::Node; -use rustc_lint::{LateContext, LateLintPass, LintContext}; -use rustc_span::def_id::LocalDefId; -use rustc_span::source_map; - -#[no_mangle] -fn __rustc_plugin_registrar(reg: &mut Registry) { - reg.lint_store.register_lints(&[&MISSING_ALLOWED_ATTR]); - reg.lint_store.register_late_pass(|_| Box::new(MissingAllowedAttrPass)); -} - -declare_lint! { - MISSING_ALLOWED_ATTR, - Deny, - "Checks for missing `allowed_attr` attribute" -} - -declare_lint_pass!(MissingAllowedAttrPass => [MISSING_ALLOWED_ATTR]); - -impl<'tcx> LateLintPass<'tcx> for MissingAllowedAttrPass { - fn check_fn( - &mut self, - cx: &LateContext<'tcx>, - _: intravisit::FnKind<'tcx>, - _: &'tcx hir::FnDecl, - _: &'tcx hir::Body, - span: source_map::Span, - def_id: LocalDefId, - ) { - let id = cx.tcx.hir().local_def_id_to_hir_id(def_id); - let item = match cx.tcx.hir().get(id) { - Node::Item(item) => item, - _ => cx.tcx.hir().expect_item(cx.tcx.hir().get_parent_item(id).def_id), - }; - - let allowed = |attr| pprust::attribute_to_string(attr).contains("allowed_attr"); - if !cx.tcx.hir().attrs(item.hir_id()).iter().any(allowed) { - cx.lint( - MISSING_ALLOWED_ATTR, - "Missing 'allowed_attr' attribute", - |lint| lint.set_span(span) - ); - } - } -} diff --git a/tests/ui-fulldeps/plugin/auxiliary/lint-for-crate.rs b/tests/ui-fulldeps/plugin/auxiliary/lint-for-crate.rs deleted file mode 100644 index 6304c07d2..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/lint-for-crate.rs +++ /dev/null @@ -1,43 +0,0 @@ -// force-host - -#![feature(rustc_private)] - -extern crate rustc_driver; -extern crate rustc_hir; -extern crate rustc_lint; -#[macro_use] -extern crate rustc_session; -extern crate rustc_ast; -extern crate rustc_span; - -use rustc_ast::attr; -use rustc_driver::plugin::Registry; -use rustc_lint::{LateContext, LateLintPass, LintContext}; -use rustc_span::def_id::CRATE_DEF_ID; -use rustc_span::symbol::Symbol; - -declare_lint! { - CRATE_NOT_OKAY, - Warn, - "crate not marked with #![crate_okay]" -} - -declare_lint_pass!(Pass => [CRATE_NOT_OKAY]); - -impl<'tcx> LateLintPass<'tcx> for Pass { - fn check_crate(&mut self, cx: &LateContext) { - let attrs = cx.tcx.hir().attrs(rustc_hir::CRATE_HIR_ID); - let span = cx.tcx.def_span(CRATE_DEF_ID); - if !attr::contains_name(attrs, Symbol::intern("crate_okay")) { - cx.lint(CRATE_NOT_OKAY, "crate is not marked with #![crate_okay]", |lint| { - lint.set_span(span) - }); - } - } -} - -#[no_mangle] -fn __rustc_plugin_registrar(reg: &mut Registry) { - reg.lint_store.register_lints(&[&CRATE_NOT_OKAY]); - reg.lint_store.register_late_pass(|_| Box::new(Pass)); -} diff --git a/tests/ui-fulldeps/plugin/auxiliary/lint-group-plugin-test.rs b/tests/ui-fulldeps/plugin/auxiliary/lint-group-plugin-test.rs deleted file mode 100644 index 4a41e7fbb..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/lint-group-plugin-test.rs +++ /dev/null @@ -1,44 +0,0 @@ -// force-host - -#![feature(rustc_private)] - -// Load rustc as a plugin to get macros. -extern crate rustc_driver; -extern crate rustc_hir; -#[macro_use] -extern crate rustc_lint; -#[macro_use] -extern crate rustc_session; - -use rustc_driver::plugin::Registry; -use rustc_lint::{LateContext, LateLintPass, LintArray, LintContext, LintId, LintPass}; - -declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'"); - -declare_lint!(PLEASE_LINT, Warn, "Warn about items named 'pleaselintme'"); - -declare_lint_pass!(Pass => [TEST_LINT, PLEASE_LINT]); - -impl<'tcx> LateLintPass<'tcx> for Pass { - fn check_item(&mut self, cx: &LateContext, it: &rustc_hir::Item) { - match it.ident.as_str() { - "lintme" => cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span)), - "pleaselintme" => { - cx.lint(PLEASE_LINT, "item is named 'pleaselintme'", |lint| lint.set_span(it.span)) - } - _ => {} - } - } -} - -#[no_mangle] -fn __rustc_plugin_registrar(reg: &mut Registry) { - reg.lint_store.register_lints(&[&TEST_LINT, &PLEASE_LINT]); - reg.lint_store.register_late_pass(|_| Box::new(Pass)); - reg.lint_store.register_group( - true, - "lint_me", - None, - vec![LintId::of(&TEST_LINT), LintId::of(&PLEASE_LINT)], - ); -} diff --git a/tests/ui-fulldeps/plugin/auxiliary/lint-plugin-test.rs b/tests/ui-fulldeps/plugin/auxiliary/lint-plugin-test.rs deleted file mode 100644 index 30956deb7..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/lint-plugin-test.rs +++ /dev/null @@ -1,33 +0,0 @@ -// force-host - -#![feature(rustc_private)] - -extern crate rustc_ast; - -// Load rustc as a plugin to get macros -extern crate rustc_driver; -#[macro_use] -extern crate rustc_lint; -#[macro_use] -extern crate rustc_session; - -use rustc_driver::plugin::Registry; -use rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass}; -use rustc_ast as ast; -declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'"); - -declare_lint_pass!(Pass => [TEST_LINT]); - -impl EarlyLintPass for Pass { - fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) { - if it.ident.name.as_str() == "lintme" { - cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span)); - } - } -} - -#[no_mangle] -fn __rustc_plugin_registrar(reg: &mut Registry) { - reg.lint_store.register_lints(&[&TEST_LINT]); - reg.lint_store.register_early_pass(|| Box::new(Pass)); -} diff --git a/tests/ui-fulldeps/plugin/auxiliary/lint-tool-test.rs b/tests/ui-fulldeps/plugin/auxiliary/lint-tool-test.rs deleted file mode 100644 index c2c024865..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/lint-tool-test.rs +++ /dev/null @@ -1,52 +0,0 @@ -#![feature(rustc_private)] - -extern crate rustc_ast; - -// Load rustc as a plugin to get macros -extern crate rustc_driver; -#[macro_use] -extern crate rustc_lint; -#[macro_use] -extern crate rustc_session; - -use rustc_driver::plugin::Registry; -use rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintId, LintPass}; -use rustc_ast as ast; -declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff"); -declare_tool_lint!( - /// Some docs - pub clippy::TEST_GROUP, - Warn, "Warn about other stuff" -); - -declare_tool_lint!( - /// Some docs - pub rustc::TEST_RUSTC_TOOL_LINT, - Deny, - "Deny internal stuff" -); - -declare_lint_pass!(Pass => [TEST_LINT, TEST_GROUP, TEST_RUSTC_TOOL_LINT]); - -impl EarlyLintPass for Pass { - fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) { - if it.ident.name.as_str() == "lintme" { - cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span)); - } - if it.ident.name.as_str() == "lintmetoo" { - cx.lint(TEST_GROUP, "item is named 'lintmetoo'", |lint| lint.set_span(it.span)); - } - } -} - -#[no_mangle] -fn __rustc_plugin_registrar(reg: &mut Registry) { - reg.lint_store.register_lints(&[&TEST_RUSTC_TOOL_LINT, &TEST_LINT, &TEST_GROUP]); - reg.lint_store.register_early_pass(|| Box::new(Pass)); - reg.lint_store.register_group( - true, - "clippy::group", - Some("clippy_group"), - vec![LintId::of(&TEST_LINT), LintId::of(&TEST_GROUP)], - ); -} diff --git a/tests/ui-fulldeps/plugin/auxiliary/lto-syntax-extension-lib.rs b/tests/ui-fulldeps/plugin/auxiliary/lto-syntax-extension-lib.rs deleted file mode 100644 index 954a1e554..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/lto-syntax-extension-lib.rs +++ /dev/null @@ -1,5 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "rlib"] - -pub fn foo() {} diff --git a/tests/ui-fulldeps/plugin/auxiliary/lto-syntax-extension-plugin.rs b/tests/ui-fulldeps/plugin/auxiliary/lto-syntax-extension-plugin.rs deleted file mode 100644 index 9b075c1a5..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/lto-syntax-extension-plugin.rs +++ /dev/null @@ -1,11 +0,0 @@ -// force-host - -#![feature(rustc_private)] - -extern crate rustc_middle; -extern crate rustc_driver; - -use rustc_driver::plugin::Registry; - -#[no_mangle] -fn __rustc_plugin_registrar(_reg: &mut Registry) {} diff --git a/tests/ui-fulldeps/plugin/auxiliary/multiple-plugins-1.rs b/tests/ui-fulldeps/plugin/auxiliary/multiple-plugins-1.rs deleted file mode 100644 index fd6e9e20f..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/multiple-plugins-1.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![crate_type = "dylib"] -#![feature(rustc_private)] - -extern crate rustc_middle; -extern crate rustc_driver; - -use rustc_driver::plugin::Registry; - -#[no_mangle] -fn __rustc_plugin_registrar(_: &mut Registry) {} diff --git a/tests/ui-fulldeps/plugin/auxiliary/multiple-plugins-2.rs b/tests/ui-fulldeps/plugin/auxiliary/multiple-plugins-2.rs deleted file mode 100644 index fd6e9e20f..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/multiple-plugins-2.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![crate_type = "dylib"] -#![feature(rustc_private)] - -extern crate rustc_middle; -extern crate rustc_driver; - -use rustc_driver::plugin::Registry; - -#[no_mangle] -fn __rustc_plugin_registrar(_: &mut Registry) {} diff --git a/tests/ui-fulldeps/plugin/auxiliary/outlive-expansion-phase.rs b/tests/ui-fulldeps/plugin/auxiliary/outlive-expansion-phase.rs deleted file mode 100644 index e83dfe804..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/outlive-expansion-phase.rs +++ /dev/null @@ -1,24 +0,0 @@ -// force-host - -#![feature(rustc_private)] - -extern crate rustc_middle; -extern crate rustc_driver; - -use std::any::Any; -use std::cell::RefCell; -use rustc_driver::plugin::Registry; - -struct Foo { - foo: isize -} - -impl Drop for Foo { - fn drop(&mut self) {} -} - -#[no_mangle] -fn __rustc_plugin_registrar(_: &mut Registry) { - thread_local!(static FOO: RefCell<Option<Box<Any+Send>>> = RefCell::new(None)); - FOO.with(|s| *s.borrow_mut() = Some(Box::new(Foo { foo: 10 }) as Box<Any+Send>)); -} diff --git a/tests/ui-fulldeps/plugin/auxiliary/rlib-crate-test.rs b/tests/ui-fulldeps/plugin/auxiliary/rlib-crate-test.rs deleted file mode 100644 index 3ba73538e..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/rlib-crate-test.rs +++ /dev/null @@ -1,12 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "rlib"] -#![feature(rustc_private)] - -extern crate rustc_middle; -extern crate rustc_driver; - -use rustc_driver::plugin::Registry; - -#[no_mangle] -fn __rustc_plugin_registrar(_: &mut Registry) {} diff --git a/tests/ui-fulldeps/plugin/feature-gate-plugin.rs b/tests/ui-fulldeps/plugin/feature-gate-plugin.rs deleted file mode 100644 index 85eaf5336..000000000 --- a/tests/ui-fulldeps/plugin/feature-gate-plugin.rs +++ /dev/null @@ -1,8 +0,0 @@ -// aux-build:empty-plugin.rs -// ignore-stage1 - -#![plugin(empty_plugin)] -//~^ ERROR compiler plugins are deprecated -//~| WARN use of deprecated attribute `plugin`: compiler plugins are deprecated - -fn main() {} diff --git a/tests/ui-fulldeps/plugin/feature-gate-plugin.stderr b/tests/ui-fulldeps/plugin/feature-gate-plugin.stderr deleted file mode 100644 index 5e40561c7..000000000 --- a/tests/ui-fulldeps/plugin/feature-gate-plugin.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0658]: compiler plugins are deprecated - --> $DIR/feature-gate-plugin.rs:4:1 - | -LL | #![plugin(empty_plugin)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #29597 <https://github.com/rust-lang/rust/issues/29597> for more information - = help: add `#![feature(plugin)]` to the crate attributes to enable - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/feature-gate-plugin.rs:4:1 - | -LL | #![plugin(empty_plugin)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui-fulldeps/plugin/gated-plugin.rs b/tests/ui-fulldeps/plugin/gated-plugin.rs deleted file mode 100644 index 85eaf5336..000000000 --- a/tests/ui-fulldeps/plugin/gated-plugin.rs +++ /dev/null @@ -1,8 +0,0 @@ -// aux-build:empty-plugin.rs -// ignore-stage1 - -#![plugin(empty_plugin)] -//~^ ERROR compiler plugins are deprecated -//~| WARN use of deprecated attribute `plugin`: compiler plugins are deprecated - -fn main() {} diff --git a/tests/ui-fulldeps/plugin/gated-plugin.stderr b/tests/ui-fulldeps/plugin/gated-plugin.stderr deleted file mode 100644 index f48f1eab6..000000000 --- a/tests/ui-fulldeps/plugin/gated-plugin.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0658]: compiler plugins are deprecated - --> $DIR/gated-plugin.rs:4:1 - | -LL | #![plugin(empty_plugin)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #29597 <https://github.com/rust-lang/rust/issues/29597> for more information - = help: add `#![feature(plugin)]` to the crate attributes to enable - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/gated-plugin.rs:4:1 - | -LL | #![plugin(empty_plugin)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui-fulldeps/plugin/issue-15778-fail.rs b/tests/ui-fulldeps/plugin/issue-15778-fail.rs deleted file mode 100644 index beecaadf9..000000000 --- a/tests/ui-fulldeps/plugin/issue-15778-fail.rs +++ /dev/null @@ -1,9 +0,0 @@ -// aux-build:lint-for-crate.rs -// ignore-stage1 -// compile-flags: -D crate-not-okay - -#![feature(plugin)] //~ ERROR crate is not marked with #![crate_okay] -#![plugin(lint_for_crate)] -//~^ WARN use of deprecated attribute `plugin` - -pub fn main() { } diff --git a/tests/ui-fulldeps/plugin/issue-15778-fail.stderr b/tests/ui-fulldeps/plugin/issue-15778-fail.stderr deleted file mode 100644 index a37893e12..000000000 --- a/tests/ui-fulldeps/plugin/issue-15778-fail.stderr +++ /dev/null @@ -1,22 +0,0 @@ -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/issue-15778-fail.rs:6:1 - | -LL | #![plugin(lint_for_crate)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -error: crate is not marked with #![crate_okay] - --> $DIR/issue-15778-fail.rs:5:1 - | -LL | / #![feature(plugin)] -LL | | #![plugin(lint_for_crate)] -LL | | -LL | | -LL | | pub fn main() { } - | |_________________^ - | - = note: requested on the command line with `-D crate-not-okay` - -error: aborting due to previous error; 1 warning emitted - diff --git a/tests/ui-fulldeps/plugin/issue-40001.rs b/tests/ui-fulldeps/plugin/issue-40001.rs deleted file mode 100644 index e14338fdb..000000000 --- a/tests/ui-fulldeps/plugin/issue-40001.rs +++ /dev/null @@ -1,10 +0,0 @@ -// run-pass -// aux-build:issue-40001-plugin.rs -// ignore-stage1 - -#![feature(plugin, register_tool)] -#![plugin(issue_40001_plugin)] //~ WARNING compiler plugins are deprecated -#![register_tool(plugin)] - -#[plugin::allowed_attr] -fn main() {} diff --git a/tests/ui-fulldeps/plugin/issue-40001.stderr b/tests/ui-fulldeps/plugin/issue-40001.stderr deleted file mode 100644 index 73ec06924..000000000 --- a/tests/ui-fulldeps/plugin/issue-40001.stderr +++ /dev/null @@ -1,10 +0,0 @@ -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/issue-40001.rs:6:1 - | -LL | #![plugin(issue_40001_plugin)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.rs b/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.rs deleted file mode 100644 index 9f8a87960..000000000 --- a/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.rs +++ /dev/null @@ -1,17 +0,0 @@ -// aux-build:lint-group-plugin-test.rs -// ignore-stage1 -// compile-flags: -D lint-me - -#![feature(plugin)] - -#![plugin(lint_group_plugin_test)] -//~^ WARN use of deprecated attribute `plugin` - -fn lintme() { } //~ ERROR item is named 'lintme' - -fn pleaselintme() { } //~ ERROR item is named 'pleaselintme' - -pub fn main() { - lintme(); - pleaselintme(); -} diff --git a/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.stderr b/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.stderr deleted file mode 100644 index 20486d596..000000000 --- a/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.stderr +++ /dev/null @@ -1,26 +0,0 @@ -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-group-plugin-deny-cmdline.rs:7:1 - | -LL | #![plugin(lint_group_plugin_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -error: item is named 'lintme' - --> $DIR/lint-group-plugin-deny-cmdline.rs:10:1 - | -LL | fn lintme() { } - | ^^^^^^^^^^^^^^^ - | - = note: `-D test-lint` implied by `-D lint-me` - -error: item is named 'pleaselintme' - --> $DIR/lint-group-plugin-deny-cmdline.rs:12:1 - | -LL | fn pleaselintme() { } - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: `-D please-lint` implied by `-D lint-me` - -error: aborting due to 2 previous errors; 1 warning emitted - diff --git a/tests/ui-fulldeps/plugin/lint-group-plugin.rs b/tests/ui-fulldeps/plugin/lint-group-plugin.rs deleted file mode 100644 index 7b74be7a9..000000000 --- a/tests/ui-fulldeps/plugin/lint-group-plugin.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass -// aux-build:lint-group-plugin-test.rs -// ignore-stage1 - -#![feature(plugin)] -#![plugin(lint_group_plugin_test)] //~ WARNING use of deprecated attribute -#![allow(dead_code)] - -fn lintme() { } //~ WARNING item is named 'lintme' -fn pleaselintme() { } //~ WARNING item is named 'pleaselintme' - -#[allow(lint_me)] -pub fn main() { - fn lintme() { } - - fn pleaselintme() { } -} diff --git a/tests/ui-fulldeps/plugin/lint-group-plugin.stderr b/tests/ui-fulldeps/plugin/lint-group-plugin.stderr deleted file mode 100644 index 6f429dad0..000000000 --- a/tests/ui-fulldeps/plugin/lint-group-plugin.stderr +++ /dev/null @@ -1,26 +0,0 @@ -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-group-plugin.rs:6:1 - | -LL | #![plugin(lint_group_plugin_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: item is named 'lintme' - --> $DIR/lint-group-plugin.rs:9:1 - | -LL | fn lintme() { } - | ^^^^^^^^^^^^^^^ - | - = note: `#[warn(test_lint)]` on by default - -warning: item is named 'pleaselintme' - --> $DIR/lint-group-plugin.rs:10:1 - | -LL | fn pleaselintme() { } - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(please_lint)]` on by default - -warning: 3 warnings emitted - diff --git a/tests/ui-fulldeps/plugin/lint-plugin-cmdline-allow.rs b/tests/ui-fulldeps/plugin/lint-plugin-cmdline-allow.rs deleted file mode 100644 index 1cc16e2fd..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-cmdline-allow.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check-pass -// aux-build:lint-plugin-test.rs -// ignore-stage1 -// compile-flags: -A test-lint - -#![feature(plugin)] -#![plugin(lint_plugin_test)] //~ WARNING compiler plugins are deprecated - -fn lintme() { } - -pub fn main() { -} diff --git a/tests/ui-fulldeps/plugin/lint-plugin-cmdline-allow.stderr b/tests/ui-fulldeps/plugin/lint-plugin-cmdline-allow.stderr deleted file mode 100644 index f06703a27..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-cmdline-allow.stderr +++ /dev/null @@ -1,10 +0,0 @@ -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-plugin-cmdline-allow.rs:7:1 - | -LL | #![plugin(lint_plugin_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui-fulldeps/plugin/lint-plugin-cmdline-load.rs b/tests/ui-fulldeps/plugin/lint-plugin-cmdline-load.rs deleted file mode 100644 index 0bd95dfbd..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-cmdline-load.rs +++ /dev/null @@ -1,13 +0,0 @@ -// check-pass -// aux-build:lint-plugin-test.rs -// ignore-stage1 -// compile-flags: -Z crate-attr=plugin(lint_plugin_test) - -#![feature(plugin)] - -fn lintme() { } //~ WARNING item is named 'lintme' - -#[allow(test_lint)] -pub fn main() { - fn lintme() { } -} diff --git a/tests/ui-fulldeps/plugin/lint-plugin-cmdline-load.stderr b/tests/ui-fulldeps/plugin/lint-plugin-cmdline-load.stderr deleted file mode 100644 index 82679c9e1..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-cmdline-load.stderr +++ /dev/null @@ -1,18 +0,0 @@ -warning: item is named 'lintme' - --> $DIR/lint-plugin-cmdline-load.rs:8:1 - | -LL | fn lintme() { } - | ^^^^^^^^^^^^^^^ - | - = note: `#[warn(test_lint)]` on by default - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> <crate attribute>:1:1 - | -LL | plugin(lint_plugin_test) - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: 2 warnings emitted - diff --git a/tests/ui-fulldeps/plugin/lint-plugin-deny-attr.rs b/tests/ui-fulldeps/plugin/lint-plugin-deny-attr.rs deleted file mode 100644 index 04230a8e8..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-deny-attr.rs +++ /dev/null @@ -1,13 +0,0 @@ -// aux-build:lint-plugin-test.rs -// ignore-stage1 - -#![feature(plugin)] -#![plugin(lint_plugin_test)] -//~^ WARN use of deprecated attribute `plugin` -#![deny(test_lint)] - -fn lintme() { } //~ ERROR item is named 'lintme' - -pub fn main() { - lintme(); -} diff --git a/tests/ui-fulldeps/plugin/lint-plugin-deny-attr.stderr b/tests/ui-fulldeps/plugin/lint-plugin-deny-attr.stderr deleted file mode 100644 index 5e8891bf1..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-deny-attr.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error: item is named 'lintme' - --> $DIR/lint-plugin-deny-attr.rs:9:1 - | -LL | fn lintme() { } - | ^^^^^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/lint-plugin-deny-attr.rs:7:9 - | -LL | #![deny(test_lint)] - | ^^^^^^^^^ - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-plugin-deny-attr.rs:5:1 - | -LL | #![plugin(lint_plugin_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -error: aborting due to previous error; 1 warning emitted - diff --git a/tests/ui-fulldeps/plugin/lint-plugin-deny-cmdline.rs b/tests/ui-fulldeps/plugin/lint-plugin-deny-cmdline.rs deleted file mode 100644 index c460cfd5f..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-deny-cmdline.rs +++ /dev/null @@ -1,13 +0,0 @@ -// aux-build:lint-plugin-test.rs -// ignore-stage1 -// compile-flags: -D test-lint - -#![feature(plugin)] -#![plugin(lint_plugin_test)] -//~^ WARN use of deprecated attribute `plugin` - -fn lintme() { } //~ ERROR item is named 'lintme' - -pub fn main() { - lintme(); -} diff --git a/tests/ui-fulldeps/plugin/lint-plugin-deny-cmdline.stderr b/tests/ui-fulldeps/plugin/lint-plugin-deny-cmdline.stderr deleted file mode 100644 index d5d6b5352..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-deny-cmdline.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: item is named 'lintme' - --> $DIR/lint-plugin-deny-cmdline.rs:9:1 - | -LL | fn lintme() { } - | ^^^^^^^^^^^^^^^ - | - = note: requested on the command line with `-D test-lint` - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-plugin-deny-cmdline.rs:6:1 - | -LL | #![plugin(lint_plugin_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -error: aborting due to previous error; 1 warning emitted - diff --git a/tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.rs b/tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.rs deleted file mode 100644 index cf31b3ec1..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.rs +++ /dev/null @@ -1,16 +0,0 @@ -// aux-build:lint-plugin-test.rs -// ignore-stage1 - -#![feature(plugin)] -#![plugin(lint_plugin_test)] -//~^ WARN use of deprecated attribute `plugin` -#![forbid(test_lint)] - -fn lintme() {} //~ ERROR item is named 'lintme' - -#[allow(test_lint)] -//~^ ERROR allow(test_lint) incompatible -//~| ERROR allow(test_lint) incompatible -pub fn main() { - lintme(); -} diff --git a/tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.stderr b/tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.stderr deleted file mode 100644 index ae34b25cc..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.stderr +++ /dev/null @@ -1,41 +0,0 @@ -error[E0453]: allow(test_lint) incompatible with previous forbid - --> $DIR/lint-plugin-forbid-attrs.rs:11:9 - | -LL | #![forbid(test_lint)] - | --------- `forbid` level set here -... -LL | #[allow(test_lint)] - | ^^^^^^^^^ overruled by previous forbid - -error: item is named 'lintme' - --> $DIR/lint-plugin-forbid-attrs.rs:9:1 - | -LL | fn lintme() {} - | ^^^^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/lint-plugin-forbid-attrs.rs:7:11 - | -LL | #![forbid(test_lint)] - | ^^^^^^^^^ - -error[E0453]: allow(test_lint) incompatible with previous forbid - --> $DIR/lint-plugin-forbid-attrs.rs:11:9 - | -LL | #![forbid(test_lint)] - | --------- `forbid` level set here -... -LL | #[allow(test_lint)] - | ^^^^^^^^^ overruled by previous forbid - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-plugin-forbid-attrs.rs:5:1 - | -LL | #![plugin(lint_plugin_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -error: aborting due to 3 previous errors; 1 warning emitted - -For more information about this error, try `rustc --explain E0453`. diff --git a/tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.rs b/tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.rs deleted file mode 100644 index b9d1aa85a..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.rs +++ /dev/null @@ -1,15 +0,0 @@ -// aux-build:lint-plugin-test.rs -// ignore-stage1 -// compile-flags: -F test-lint - -#![feature(plugin)] -#![plugin(lint_plugin_test)] -//~^ WARN use of deprecated attribute `plugin` -fn lintme() { } //~ ERROR item is named 'lintme' - -#[allow(test_lint)] //~ ERROR allow(test_lint) incompatible - //~| ERROR allow(test_lint) incompatible - -pub fn main() { - lintme(); -} diff --git a/tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.stderr b/tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.stderr deleted file mode 100644 index 491c4d206..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0453]: allow(test_lint) incompatible with previous forbid - --> $DIR/lint-plugin-forbid-cmdline.rs:10:9 - | -LL | #[allow(test_lint)] - | ^^^^^^^^^ overruled by previous forbid - | - = note: `forbid` lint level was set on command line - -error: item is named 'lintme' - --> $DIR/lint-plugin-forbid-cmdline.rs:8:1 - | -LL | fn lintme() { } - | ^^^^^^^^^^^^^^^ - | - = note: requested on the command line with `-F test-lint` - -error[E0453]: allow(test_lint) incompatible with previous forbid - --> $DIR/lint-plugin-forbid-cmdline.rs:10:9 - | -LL | #[allow(test_lint)] - | ^^^^^^^^^ overruled by previous forbid - | - = note: `forbid` lint level was set on command line - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-plugin-forbid-cmdline.rs:6:1 - | -LL | #![plugin(lint_plugin_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -error: aborting due to 3 previous errors; 1 warning emitted - -For more information about this error, try `rustc --explain E0453`. diff --git a/tests/ui-fulldeps/plugin/lint-plugin.rs b/tests/ui-fulldeps/plugin/lint-plugin.rs deleted file mode 100644 index 66057eea6..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin.rs +++ /dev/null @@ -1,13 +0,0 @@ -// run-pass -// aux-build:lint-plugin-test.rs -// ignore-stage1 -#![feature(plugin)] -#![plugin(lint_plugin_test)] //~ WARNING use of deprecated attribute -#![allow(dead_code)] - -fn lintme() { } //~ WARNING item is named 'lintme' - -#[allow(test_lint)] -pub fn main() { - fn lintme() { } -} diff --git a/tests/ui-fulldeps/plugin/lint-plugin.stderr b/tests/ui-fulldeps/plugin/lint-plugin.stderr deleted file mode 100644 index dd5d3d72e..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin.stderr +++ /dev/null @@ -1,18 +0,0 @@ -warning: item is named 'lintme' - --> $DIR/lint-plugin.rs:8:1 - | -LL | fn lintme() { } - | ^^^^^^^^^^^^^^^ - | - = note: `#[warn(test_lint)]` on by default - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-plugin.rs:5:1 - | -LL | #![plugin(lint_plugin_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: 2 warnings emitted - diff --git a/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.rs b/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.rs deleted file mode 100644 index 83a8b3e1a..000000000 --- a/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check-pass -// aux-build:lint-tool-test.rs -// ignore-stage1 -// compile-flags: -A test-lint - -#![feature(plugin)] -#![plugin(lint_tool_test)] //~ WARNING compiler plugins are deprecated - -fn lintme() {} -//~^ WARNING item is named 'lintme' [clippy::test_lint] - -pub fn main() {} diff --git a/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.stderr b/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.stderr deleted file mode 100644 index b060e3a3e..000000000 --- a/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.stderr +++ /dev/null @@ -1,30 +0,0 @@ -warning: lint name `test_lint` is deprecated and does not have an effect anymore. Use: clippy::test_lint - | - = note: requested on the command line with `-A test_lint` - -warning: lint name `test_lint` is deprecated and does not have an effect anymore. Use: clippy::test_lint - | - = note: requested on the command line with `-A test_lint` - -warning: item is named 'lintme' - --> $DIR/lint-tool-cmdline-allow.rs:9:1 - | -LL | fn lintme() {} - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(clippy::test_lint)]` on by default - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-tool-cmdline-allow.rs:7:1 - | -LL | #![plugin(lint_tool_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: lint name `test_lint` is deprecated and does not have an effect anymore. Use: clippy::test_lint - | - = note: requested on the command line with `-A test_lint` - -warning: 5 warnings emitted - diff --git a/tests/ui-fulldeps/plugin/lint-tool-test.rs b/tests/ui-fulldeps/plugin/lint-tool-test.rs deleted file mode 100644 index f92bcd213..000000000 --- a/tests/ui-fulldeps/plugin/lint-tool-test.rs +++ /dev/null @@ -1,36 +0,0 @@ -// aux-build:lint-tool-test.rs -// ignore-stage1 -// compile-flags: --cfg foo - -#![feature(plugin)] -#![plugin(lint_tool_test)] -//~^ WARN use of deprecated attribute `plugin` -#![allow(dead_code)] -#![cfg_attr(foo, warn(test_lint))] -//~^ WARNING lint name `test_lint` is deprecated and may not have an effect in the future -//~| WARNING lint name `test_lint` is deprecated and may not have an effect in the future -//~| WARNING lint name `test_lint` is deprecated and may not have an effect in the future -#![deny(clippy_group)] -//~^ WARNING lint name `clippy_group` is deprecated and may not have an effect in the future -//~| WARNING lint name `clippy_group` is deprecated and may not have an effect in the future -//~| WARNING lint name `clippy_group` is deprecated and may not have an effect in the future - -fn lintme() { } //~ ERROR item is named 'lintme' - -#[allow(clippy::group)] -fn lintmetoo() {} - -#[allow(clippy::test_lint)] -pub fn main() { - fn lintme() { } - fn lintmetoo() { } //~ ERROR item is named 'lintmetoo' -} - -#[allow(test_group)] -//~^ WARNING lint name `test_group` is deprecated and may not have an effect in the future -//~| WARNING lint name `test_group` is deprecated and may not have an effect in the future -//~| WARNING lint name `test_group` is deprecated and may not have an effect in the future -#[deny(this_lint_does_not_exist)] //~ WARNING unknown lint: `this_lint_does_not_exist` -fn hello() { - fn lintmetoo() { } -} diff --git a/tests/ui-fulldeps/plugin/lint-tool-test.stderr b/tests/ui-fulldeps/plugin/lint-tool-test.stderr deleted file mode 100644 index 027cf8f80..000000000 --- a/tests/ui-fulldeps/plugin/lint-tool-test.stderr +++ /dev/null @@ -1,95 +0,0 @@ -warning: lint name `test_lint` is deprecated and may not have an effect in the future. - --> $DIR/lint-tool-test.rs:9:23 - | -LL | #![cfg_attr(foo, warn(test_lint))] - | ^^^^^^^^^ help: change it to: `clippy::test_lint` - | - = note: `#[warn(renamed_and_removed_lints)]` on by default - -warning: lint name `clippy_group` is deprecated and may not have an effect in the future. - --> $DIR/lint-tool-test.rs:13:9 - | -LL | #![deny(clippy_group)] - | ^^^^^^^^^^^^ help: change it to: `clippy::group` - -warning: lint name `test_group` is deprecated and may not have an effect in the future. - --> $DIR/lint-tool-test.rs:29:9 - | -LL | #[allow(test_group)] - | ^^^^^^^^^^ help: change it to: `clippy::test_group` - -warning: lint name `test_lint` is deprecated and may not have an effect in the future. - --> $DIR/lint-tool-test.rs:9:23 - | -LL | #![cfg_attr(foo, warn(test_lint))] - | ^^^^^^^^^ help: change it to: `clippy::test_lint` - -warning: lint name `clippy_group` is deprecated and may not have an effect in the future. - --> $DIR/lint-tool-test.rs:13:9 - | -LL | #![deny(clippy_group)] - | ^^^^^^^^^^^^ help: change it to: `clippy::group` - -error: item is named 'lintme' - --> $DIR/lint-tool-test.rs:18:1 - | -LL | fn lintme() { } - | ^^^^^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/lint-tool-test.rs:13:9 - | -LL | #![deny(clippy_group)] - | ^^^^^^^^^^^^ - = note: `#[deny(clippy::test_lint)]` implied by `#[deny(clippy::group)]` - -error: item is named 'lintmetoo' - --> $DIR/lint-tool-test.rs:26:5 - | -LL | fn lintmetoo() { } - | ^^^^^^^^^^^^^^^^^^ - | - = note: `#[deny(clippy::test_group)]` implied by `#[deny(clippy::group)]` - -warning: lint name `test_group` is deprecated and may not have an effect in the future. - --> $DIR/lint-tool-test.rs:29:9 - | -LL | #[allow(test_group)] - | ^^^^^^^^^^ help: change it to: `clippy::test_group` - -warning: unknown lint: `this_lint_does_not_exist` - --> $DIR/lint-tool-test.rs:33:8 - | -LL | #[deny(this_lint_does_not_exist)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(unknown_lints)]` on by default - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-tool-test.rs:6:1 - | -LL | #![plugin(lint_tool_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: lint name `test_lint` is deprecated and may not have an effect in the future. - --> $DIR/lint-tool-test.rs:9:23 - | -LL | #![cfg_attr(foo, warn(test_lint))] - | ^^^^^^^^^ help: change it to: `clippy::test_lint` - -warning: lint name `clippy_group` is deprecated and may not have an effect in the future. - --> $DIR/lint-tool-test.rs:13:9 - | -LL | #![deny(clippy_group)] - | ^^^^^^^^^^^^ help: change it to: `clippy::group` - -warning: lint name `test_group` is deprecated and may not have an effect in the future. - --> $DIR/lint-tool-test.rs:29:9 - | -LL | #[allow(test_group)] - | ^^^^^^^^^^ help: change it to: `clippy::test_group` - -error: aborting due to 2 previous errors; 11 warnings emitted - diff --git a/tests/ui-fulldeps/plugin/lto-syntax-extension.rs b/tests/ui-fulldeps/plugin/lto-syntax-extension.rs deleted file mode 100644 index 5964e70f1..000000000 --- a/tests/ui-fulldeps/plugin/lto-syntax-extension.rs +++ /dev/null @@ -1,15 +0,0 @@ -// run-pass -// aux-build:lto-syntax-extension-lib.rs -// aux-build:lto-syntax-extension-plugin.rs -// compile-flags:-C lto -// ignore-stage1 -// no-prefer-dynamic - -#![feature(plugin)] -#![plugin(lto_syntax_extension_plugin)] //~ WARNING compiler plugins are deprecated - -extern crate lto_syntax_extension_lib; - -fn main() { - lto_syntax_extension_lib::foo(); -} diff --git a/tests/ui-fulldeps/plugin/lto-syntax-extension.stderr b/tests/ui-fulldeps/plugin/lto-syntax-extension.stderr deleted file mode 100644 index 555493f32..000000000 --- a/tests/ui-fulldeps/plugin/lto-syntax-extension.stderr +++ /dev/null @@ -1,10 +0,0 @@ -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lto-syntax-extension.rs:9:1 - | -LL | #![plugin(lto_syntax_extension_plugin)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui-fulldeps/plugin/macro-crate-rlib.rs b/tests/ui-fulldeps/plugin/macro-crate-rlib.rs deleted file mode 100644 index 38bd34053..000000000 --- a/tests/ui-fulldeps/plugin/macro-crate-rlib.rs +++ /dev/null @@ -1,9 +0,0 @@ -// aux-build:rlib-crate-test.rs -// ignore-stage1 -// ignore-cross-compile gives a different error message - -#![feature(plugin)] -#![plugin(rlib_crate_test)] -//~^ ERROR: plugin `rlib_crate_test` only found in rlib format, but must be available in dylib - -fn main() {} diff --git a/tests/ui-fulldeps/plugin/macro-crate-rlib.stderr b/tests/ui-fulldeps/plugin/macro-crate-rlib.stderr deleted file mode 100644 index 0651cee56..000000000 --- a/tests/ui-fulldeps/plugin/macro-crate-rlib.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0457]: plugin `rlib_crate_test` only found in rlib format, but must be available in dylib format - --> $DIR/macro-crate-rlib.rs:6:11 - | -LL | #![plugin(rlib_crate_test)] - | ^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0457`. diff --git a/tests/ui-fulldeps/plugin/multiple-plugins.rs b/tests/ui-fulldeps/plugin/multiple-plugins.rs deleted file mode 100644 index 9af3ebd57..000000000 --- a/tests/ui-fulldeps/plugin/multiple-plugins.rs +++ /dev/null @@ -1,12 +0,0 @@ -// run-pass -// aux-build:multiple-plugins-1.rs -// aux-build:multiple-plugins-2.rs -// ignore-stage1 - -// Check that the plugin registrar of multiple plugins doesn't conflict - -#![feature(plugin)] -#![plugin(multiple_plugins_1)] //~ WARN use of deprecated attribute `plugin` -#![plugin(multiple_plugins_2)] //~ WARN use of deprecated attribute `plugin` - -fn main() {} diff --git a/tests/ui-fulldeps/plugin/multiple-plugins.stderr b/tests/ui-fulldeps/plugin/multiple-plugins.stderr deleted file mode 100644 index 878ffabfc..000000000 --- a/tests/ui-fulldeps/plugin/multiple-plugins.stderr +++ /dev/null @@ -1,16 +0,0 @@ -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/multiple-plugins.rs:9:1 - | -LL | #![plugin(multiple_plugins_1)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/multiple-plugins.rs:10:1 - | -LL | #![plugin(multiple_plugins_2)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - -warning: 2 warnings emitted - diff --git a/tests/ui-fulldeps/plugin/outlive-expansion-phase.rs b/tests/ui-fulldeps/plugin/outlive-expansion-phase.rs deleted file mode 100644 index fb22888d9..000000000 --- a/tests/ui-fulldeps/plugin/outlive-expansion-phase.rs +++ /dev/null @@ -1,8 +0,0 @@ -// run-pass -// aux-build:outlive-expansion-phase.rs -// ignore-stage1 - -#![feature(plugin)] -#![plugin(outlive_expansion_phase)] //~ WARNING compiler plugins are deprecated - -pub fn main() {} diff --git a/tests/ui-fulldeps/plugin/outlive-expansion-phase.stderr b/tests/ui-fulldeps/plugin/outlive-expansion-phase.stderr deleted file mode 100644 index e40a08ae7..000000000 --- a/tests/ui-fulldeps/plugin/outlive-expansion-phase.stderr +++ /dev/null @@ -1,10 +0,0 @@ -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/outlive-expansion-phase.rs:6:1 - | -LL | #![plugin(outlive_expansion_phase)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui-fulldeps/plugin/plugin-args.rs b/tests/ui-fulldeps/plugin/plugin-args.rs deleted file mode 100644 index 488f2b775..000000000 --- a/tests/ui-fulldeps/plugin/plugin-args.rs +++ /dev/null @@ -1,9 +0,0 @@ -// aux-build:empty-plugin.rs -// ignore-stage1 - -#![feature(plugin)] -#![plugin(empty_plugin(args))] -//~^ ERROR malformed `plugin` attribute -//~| WARNING compiler plugins are deprecated - -fn main() {} diff --git a/tests/ui-fulldeps/plugin/plugin-args.stderr b/tests/ui-fulldeps/plugin/plugin-args.stderr deleted file mode 100644 index 177f33005..000000000 --- a/tests/ui-fulldeps/plugin/plugin-args.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0498]: malformed `plugin` attribute - --> $DIR/plugin-args.rs:5:11 - | -LL | #![plugin(empty_plugin(args))] - | ^^^^^^^^^^^^^^^^^^ malformed attribute - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/plugin-args.rs:5:1 - | -LL | #![plugin(empty_plugin(args))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0498`. diff --git a/tests/ui-fulldeps/plugin/plugin-as-extern-crate.rs b/tests/ui-fulldeps/plugin/plugin-as-extern-crate.rs deleted file mode 100644 index 4d26e08d8..000000000 --- a/tests/ui-fulldeps/plugin/plugin-as-extern-crate.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass -// aux-build:empty-plugin.rs -// ignore-cross-compile -// -// empty_plugin will not compile on a cross-compiled target because -// librustc_ast is not compiled for it. - -extern crate empty_plugin; // OK, plugin crates are still crates - -fn main() {} diff --git a/tests/ui-fulldeps/pprust-expr-roundtrip.rs b/tests/ui-fulldeps/pprust-expr-roundtrip.rs index ae375dfab..24c4543c2 100644 --- a/tests/ui-fulldeps/pprust-expr-roundtrip.rs +++ b/tests/ui-fulldeps/pprust-expr-roundtrip.rs @@ -32,15 +32,15 @@ extern crate thin_vec; #[allow(unused_extern_crates)] extern crate rustc_driver; -use rustc_ast::mut_visit::{self, visit_clobber, MutVisitor}; +use rustc_ast::mut_visit::{visit_clobber, MutVisitor}; use rustc_ast::ptr::P; use rustc_ast::*; use rustc_ast_pretty::pprust; use rustc_parse::new_parser_from_source_str; use rustc_session::parse::ParseSess; -use rustc_span::source_map::FilePathMapping; -use rustc_span::source_map::{FileName, Spanned, DUMMY_SP}; +use rustc_span::source_map::{FilePathMapping, Spanned}; use rustc_span::symbol::Ident; +use rustc_span::{FileName, DUMMY_SP}; use thin_vec::{thin_vec, ThinVec}; fn parse_expr(ps: &ParseSess, src: &str) -> Option<P<Expr>> { @@ -80,14 +80,20 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) { let seg = PathSegment::from_ident(Ident::from_str("x")); iter_exprs(depth - 1, &mut |e| { g(ExprKind::MethodCall(Box::new(MethodCall { - seg: seg.clone(), receiver: e, args: thin_vec![make_x()], span: DUMMY_SP - })) - )}); + seg: seg.clone(), + receiver: e, + args: thin_vec![make_x()], + span: DUMMY_SP, + }))) + }); iter_exprs(depth - 1, &mut |e| { g(ExprKind::MethodCall(Box::new(MethodCall { - seg: seg.clone(), receiver: make_x(), args: thin_vec![e], span: DUMMY_SP - })) - )}); + seg: seg.clone(), + receiver: make_x(), + args: thin_vec![e], + span: DUMMY_SP, + }))) + }); } 2..=7 => { let op = Spanned { @@ -124,9 +130,9 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) { iter_exprs(depth - 1, &mut |e| { g(ExprKind::Closure(Box::new(Closure { binder: ClosureBinder::NotPresent, - capture_clause: CaptureBy::Value, + capture_clause: CaptureBy::Value { move_kw: DUMMY_SP }, constness: Const::No, - asyncness: Async::No, + coroutine_kind: None, movability: Movability::Movable, fn_decl: decl.clone(), body: e, @@ -174,7 +180,7 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) { 18 => { let pat = P(Pat { id: DUMMY_NODE_ID, kind: PatKind::Wild, span: DUMMY_SP, tokens: None }); - iter_exprs(depth - 1, &mut |e| g(ExprKind::Let(pat.clone(), e, DUMMY_SP))) + iter_exprs(depth - 1, &mut |e| g(ExprKind::Let(pat.clone(), e, DUMMY_SP, None))) } _ => panic!("bad counter value in iter_exprs"), } diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs index 642b58b07..221f26f8e 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs @@ -1,7 +1,7 @@ // check-fail // Tests that a doc comment will not preclude a field from being considered a diagnostic argument // normalize-stderr-test "the following other types implement trait `IntoDiagnosticArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr" -// normalize-stderr-test "diagnostic_builder\.rs:[0-9]+:[0-9]+" -> "diagnostic_builder.rs:LL:CC" +// normalize-stderr-test "(COMPILER_DIR/.*\.rs):[0-9]+:[0-9]+" -> "$1:LL:CC" // The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly, // changing the output of this test. Since Subdiagnostic is strictly internal to the compiler @@ -20,11 +20,10 @@ extern crate rustc_session; extern crate rustc_span; use rustc_errors::{Applicability, DiagnosticMessage, SubdiagnosticMessage}; -use rustc_fluent_macro::fluent_messages; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::Span; -fluent_messages! { "./example.ftl" } +rustc_fluent_macro::fluent_messages! { "./example.ftl" } struct NotIntoDiagnosticArg; diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr index e4b8958b4..bdcf54bd1 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied - --> $DIR/diagnostic-derive-doc-comment-field.rs:37:10 + --> $DIR/diagnostic-derive-doc-comment-field.rs:36:10 | LL | #[derive(Diagnostic)] | ---------- required by a bound introduced by this call @@ -13,7 +13,7 @@ note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg` = note: this error originates in the macro `forward` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied - --> $DIR/diagnostic-derive-doc-comment-field.rs:47:10 + --> $DIR/diagnostic-derive-doc-comment-field.rs:46:10 | LL | #[derive(Subdiagnostic)] | ------------- required by a bound introduced by this call @@ -23,7 +23,7 @@ LL | arg: NotIntoDiagnosticArg, | = help: normalized in stderr note: required by a bound in `Diagnostic::set_arg` - --> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:964:5 + --> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC error: aborting due to 2 previous errors diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs index 39e34d73f..63fb78ee9 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs @@ -19,7 +19,6 @@ use rustc_span::Span; extern crate rustc_fluent_macro; extern crate rustc_macros; -use rustc_fluent_macro::fluent_messages; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; extern crate rustc_middle; @@ -30,7 +29,7 @@ use rustc_errors::{Applicability, DiagnosticMessage, MultiSpan, SubdiagnosticMes extern crate rustc_session; -fluent_messages! { "./example.ftl" } +rustc_fluent_macro::fluent_messages! { "./example.ftl" } #[derive(Diagnostic)] #[diag(no_crate_example, code = "E0123")] @@ -53,7 +52,7 @@ enum DiagnosticOnEnum { #[derive(Diagnostic)] #[diag(no_crate_example, code = "E0123")] #[diag = "E0123"] -//~^ ERROR expected parentheses: #[diag(...)] +//~^ ERROR failed to resolve: maybe a missing crate `core` struct WrongStructAttrStyle {} #[derive(Diagnostic)] @@ -538,7 +537,7 @@ struct LabelWithTrailingPath { #[diag(no_crate_example, code = "E0123")] struct LabelWithTrailingNameValue { #[label(no_crate_label, foo = "...")] - //~^ ERROR invalid nested attribute + //~^ ERROR only `no_span` is a valid nested attribute span: Span, } @@ -546,7 +545,7 @@ struct LabelWithTrailingNameValue { #[diag(no_crate_example, code = "E0123")] struct LabelWithTrailingList { #[label(no_crate_label, foo("..."))] - //~^ ERROR invalid nested attribute + //~^ ERROR only `no_span` is a valid nested attribute span: Span, } @@ -644,7 +643,7 @@ struct MissingCodeInSuggestion { //~| ERROR cannot find attribute `multipart_suggestion` in this scope #[multipart_suggestion()] //~^ ERROR cannot find attribute `multipart_suggestion` in this scope -//~| ERROR unexpected end of input, unexpected token in nested attribute, expected ident +//~| ERROR `#[multipart_suggestion(...)]` is not a valid attribute struct MultipartSuggestion { #[multipart_suggestion(no_crate_suggestion)] //~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute @@ -797,7 +796,7 @@ struct SuggestionsNoItem { struct SuggestionsInvalidItem { #[suggestion(code(foo))] //~^ ERROR `code(...)` must contain only string literals - //~| ERROR unexpected token + //~| ERROR failed to resolve: maybe a missing crate `core` sub: Span, } @@ -805,7 +804,7 @@ struct SuggestionsInvalidItem { #[diag(no_crate_example)] struct SuggestionsInvalidLiteral { #[suggestion(code = 3)] - //~^ ERROR expected string literal + //~^ ERROR failed to resolve: maybe a missing crate `core` sub: Span, } diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr index 801e4b579..d8ba65d29 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -1,11 +1,11 @@ error: unsupported type attribute for diagnostic derive enum - --> $DIR/diagnostic-derive.rs:44:1 + --> $DIR/diagnostic-derive.rs:43:1 | LL | #[diag(no_crate_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:47:5 + --> $DIR/diagnostic-derive.rs:46:5 | LL | Foo, | ^^^ @@ -13,27 +13,21 @@ LL | Foo, = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:49:5 + --> $DIR/diagnostic-derive.rs:48:5 | LL | Bar, | ^^^ | = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` -error: expected parentheses: #[diag(...)] - --> $DIR/diagnostic-derive.rs:55:8 - | -LL | #[diag = "E0123"] - | ^ - error: `#[nonsense(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:60:1 + --> $DIR/diagnostic-derive.rs:59:1 | LL | #[nonsense(no_crate_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:60:1 + --> $DIR/diagnostic-derive.rs:59:1 | LL | / #[nonsense(no_crate_example, code = "E0123")] LL | | @@ -45,7 +39,7 @@ LL | | struct InvalidStructAttr {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:67:1 + --> $DIR/diagnostic-derive.rs:66:1 | LL | / #[diag("E0123")] LL | | @@ -55,13 +49,13 @@ LL | | struct InvalidLitNestedAttr {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: diagnostic slug must be the first argument - --> $DIR/diagnostic-derive.rs:77:16 + --> $DIR/diagnostic-derive.rs:76:16 | LL | #[diag(nonsense("foo"), code = "E0123", slug = "foo")] | ^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:77:1 + --> $DIR/diagnostic-derive.rs:76:1 | LL | / #[diag(nonsense("foo"), code = "E0123", slug = "foo")] LL | | @@ -72,7 +66,7 @@ LL | | struct InvalidNestedStructAttr1 {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: unknown argument - --> $DIR/diagnostic-derive.rs:83:8 + --> $DIR/diagnostic-derive.rs:82:8 | LL | #[diag(nonsense = "...", code = "E0123", slug = "foo")] | ^^^^^^^^ @@ -80,7 +74,7 @@ LL | #[diag(nonsense = "...", code = "E0123", slug = "foo")] = note: only the `code` parameter is valid after the slug error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:83:1 + --> $DIR/diagnostic-derive.rs:82:1 | LL | / #[diag(nonsense = "...", code = "E0123", slug = "foo")] LL | | @@ -91,7 +85,7 @@ LL | | struct InvalidNestedStructAttr2 {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: unknown argument - --> $DIR/diagnostic-derive.rs:89:8 + --> $DIR/diagnostic-derive.rs:88:8 | LL | #[diag(nonsense = 4, code = "E0123", slug = "foo")] | ^^^^^^^^ @@ -99,7 +93,7 @@ LL | #[diag(nonsense = 4, code = "E0123", slug = "foo")] = note: only the `code` parameter is valid after the slug error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:89:1 + --> $DIR/diagnostic-derive.rs:88:1 | LL | / #[diag(nonsense = 4, code = "E0123", slug = "foo")] LL | | @@ -110,7 +104,7 @@ LL | | struct InvalidNestedStructAttr3 {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: unknown argument - --> $DIR/diagnostic-derive.rs:95:42 + --> $DIR/diagnostic-derive.rs:94:42 | LL | #[diag(no_crate_example, code = "E0123", slug = "foo")] | ^^^^ @@ -118,55 +112,55 @@ LL | #[diag(no_crate_example, code = "E0123", slug = "foo")] = note: only the `code` parameter is valid after the slug error: `#[suggestion = ...]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:102:5 + --> $DIR/diagnostic-derive.rs:101:5 | LL | #[suggestion = "bar"] | ^^^^^^^^^^^^^^^^^^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:109:8 + --> $DIR/diagnostic-derive.rs:108:8 | LL | #[diag(no_crate_example, code = "E0456")] | ^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:108:8 + --> $DIR/diagnostic-derive.rs:107:8 | LL | #[diag(no_crate_example, code = "E0123")] | ^^^^^^^^^^^^^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:109:26 + --> $DIR/diagnostic-derive.rs:108:26 | LL | #[diag(no_crate_example, code = "E0456")] | ^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:108:26 + --> $DIR/diagnostic-derive.rs:107:26 | LL | #[diag(no_crate_example, code = "E0123")] | ^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:115:42 + --> $DIR/diagnostic-derive.rs:114:42 | LL | #[diag(no_crate_example, code = "E0456", code = "E0457")] | ^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:115:26 + --> $DIR/diagnostic-derive.rs:114:26 | LL | #[diag(no_crate_example, code = "E0456", code = "E0457")] | ^^^^ error: diagnostic slug must be the first argument - --> $DIR/diagnostic-derive.rs:120:43 + --> $DIR/diagnostic-derive.rs:119:43 | LL | #[diag(no_crate_example, no_crate::example, code = "E0456")] | ^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:125:1 + --> $DIR/diagnostic-derive.rs:124:1 | LL | struct KindNotProvided {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -174,7 +168,7 @@ LL | struct KindNotProvided {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:128:1 + --> $DIR/diagnostic-derive.rs:127:1 | LL | / #[diag(code = "E0456")] LL | | @@ -184,31 +178,31 @@ LL | | struct SlugNotProvided {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/diagnostic-derive.rs:139:5 + --> $DIR/diagnostic-derive.rs:138:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ error: `#[nonsense]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:147:5 + --> $DIR/diagnostic-derive.rs:146:5 | LL | #[nonsense] | ^^^^^^^^^^^ error: the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/diagnostic-derive.rs:164:5 + --> $DIR/diagnostic-derive.rs:163:5 | LL | #[label(no_crate_label)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: `name` doesn't refer to a field on this type - --> $DIR/diagnostic-derive.rs:172:46 + --> $DIR/diagnostic-derive.rs:171:46 | LL | #[suggestion(no_crate_suggestion, code = "{name}")] | ^^^^^^^^ error: invalid format string: expected `'}'` but string was terminated - --> $DIR/diagnostic-derive.rs:177:10 + --> $DIR/diagnostic-derive.rs:176:10 | LL | #[derive(Diagnostic)] | ^^^^^^^^^^ expected `'}'` in format string @@ -217,7 +211,7 @@ LL | #[derive(Diagnostic)] = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) error: invalid format string: unmatched `}` found - --> $DIR/diagnostic-derive.rs:187:10 + --> $DIR/diagnostic-derive.rs:186:10 | LL | #[derive(Diagnostic)] | ^^^^^^^^^^ unmatched `}` in format string @@ -226,47 +220,47 @@ LL | #[derive(Diagnostic)] = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) error: the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/diagnostic-derive.rs:207:5 + --> $DIR/diagnostic-derive.rs:206:5 | LL | #[label(no_crate_label)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: suggestion without `code = "..."` - --> $DIR/diagnostic-derive.rs:226:5 + --> $DIR/diagnostic-derive.rs:225:5 | LL | #[suggestion(no_crate_suggestion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid nested attribute - --> $DIR/diagnostic-derive.rs:234:18 + --> $DIR/diagnostic-derive.rs:233:18 | LL | #[suggestion(nonsense = "bar")] | ^^^^^^^^ | - = help: only `style`, `code` and `applicability` are valid nested attributes + = help: only `no_span`, `style`, `code` and `applicability` are valid nested attributes error: suggestion without `code = "..."` - --> $DIR/diagnostic-derive.rs:234:5 + --> $DIR/diagnostic-derive.rs:233:5 | LL | #[suggestion(nonsense = "bar")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid nested attribute - --> $DIR/diagnostic-derive.rs:243:18 + --> $DIR/diagnostic-derive.rs:242:18 | LL | #[suggestion(msg = "bar")] | ^^^ | - = help: only `style`, `code` and `applicability` are valid nested attributes + = help: only `no_span`, `style`, `code` and `applicability` are valid nested attributes error: suggestion without `code = "..."` - --> $DIR/diagnostic-derive.rs:243:5 + --> $DIR/diagnostic-derive.rs:242:5 | LL | #[suggestion(msg = "bar")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: wrong field type for suggestion - --> $DIR/diagnostic-derive.rs:266:5 + --> $DIR/diagnostic-derive.rs:265:5 | LL | / #[suggestion(no_crate_suggestion, code = "This is suggested code")] LL | | @@ -276,79 +270,79 @@ LL | | suggestion: Applicability, = help: `#[suggestion(...)]` should be applied to fields of type `Span` or `(Span, Applicability)` error: specified multiple times - --> $DIR/diagnostic-derive.rs:282:24 + --> $DIR/diagnostic-derive.rs:281:24 | LL | suggestion: (Span, Span, Applicability), | ^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:282:18 + --> $DIR/diagnostic-derive.rs:281:18 | LL | suggestion: (Span, Span, Applicability), | ^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:290:33 + --> $DIR/diagnostic-derive.rs:289:33 | LL | suggestion: (Applicability, Applicability, Span), | ^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:290:18 + --> $DIR/diagnostic-derive.rs:289:18 | LL | suggestion: (Applicability, Applicability, Span), | ^^^^^^^^^^^^^ error: `#[label = ...]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:297:5 + --> $DIR/diagnostic-derive.rs:296:5 | LL | #[label = "bar"] | ^^^^^^^^^^^^^^^^ error: specified multiple times - --> $DIR/diagnostic-derive.rs:448:5 + --> $DIR/diagnostic-derive.rs:447:5 | LL | #[suggestion(no_crate_suggestion, code = "...", applicability = "maybe-incorrect")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:450:24 + --> $DIR/diagnostic-derive.rs:449:24 | LL | suggestion: (Span, Applicability), | ^^^^^^^^^^^^^ error: invalid applicability - --> $DIR/diagnostic-derive.rs:456:69 + --> $DIR/diagnostic-derive.rs:455:69 | LL | #[suggestion(no_crate_suggestion, code = "...", applicability = "batman")] | ^^^^^^^^ error: the `#[help(...)]` attribute can only be applied to fields of type `Span`, `MultiSpan`, `bool` or `()` - --> $DIR/diagnostic-derive.rs:523:5 + --> $DIR/diagnostic-derive.rs:522:5 | LL | #[help(no_crate_help)] | ^^^^^^^^^^^^^^^^^^^^^^ error: a diagnostic slug must be the first argument to the attribute - --> $DIR/diagnostic-derive.rs:532:32 + --> $DIR/diagnostic-derive.rs:531:32 | LL | #[label(no_crate_label, foo)] | ^ -error: invalid nested attribute - --> $DIR/diagnostic-derive.rs:540:29 +error: only `no_span` is a valid nested attribute + --> $DIR/diagnostic-derive.rs:539:29 | LL | #[label(no_crate_label, foo = "...")] | ^^^ -error: invalid nested attribute - --> $DIR/diagnostic-derive.rs:548:29 +error: only `no_span` is a valid nested attribute + --> $DIR/diagnostic-derive.rs:547:29 | LL | #[label(no_crate_label, foo("..."))] | ^^^ error: `#[primary_span]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:560:5 + --> $DIR/diagnostic-derive.rs:559:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ @@ -356,13 +350,13 @@ LL | #[primary_span] = help: the `primary_span` field attribute is not valid for lint diagnostics error: `#[error(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:580:1 + --> $DIR/diagnostic-derive.rs:579:1 | LL | #[error(no_crate_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:580:1 + --> $DIR/diagnostic-derive.rs:579:1 | LL | / #[error(no_crate_example, code = "E0123")] LL | | @@ -374,13 +368,13 @@ LL | | struct ErrorAttribute {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[warn_(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:587:1 + --> $DIR/diagnostic-derive.rs:586:1 | LL | #[warn_(no_crate_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:587:1 + --> $DIR/diagnostic-derive.rs:586:1 | LL | / #[warn_(no_crate_example, code = "E0123")] LL | | @@ -392,13 +386,13 @@ LL | | struct WarnAttribute {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[lint(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:594:1 + --> $DIR/diagnostic-derive.rs:593:1 | LL | #[lint(no_crate_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:594:1 + --> $DIR/diagnostic-derive.rs:593:1 | LL | / #[lint(no_crate_example, code = "E0123")] LL | | @@ -410,19 +404,21 @@ LL | | struct LintAttributeOnSessionDiag {} = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: `#[lint(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:601:1 + --> $DIR/diagnostic-derive.rs:600:1 | LL | #[lint(no_crate_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[lint(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:601:1 + --> $DIR/diagnostic-derive.rs:600:1 | LL | #[lint(no_crate_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: diagnostic slug not specified - --> $DIR/diagnostic-derive.rs:601:1 + --> $DIR/diagnostic-derive.rs:600:1 | LL | / #[lint(no_crate_example, code = "E0123")] LL | | @@ -435,19 +431,19 @@ LL | | struct LintAttributeOnLintDiag {} = help: specify the slug as the first argument to the attribute, such as `#[diag(compiletest_example)]` error: specified multiple times - --> $DIR/diagnostic-derive.rs:611:53 + --> $DIR/diagnostic-derive.rs:610:53 | LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")] | ^^^^ | note: previously specified here - --> $DIR/diagnostic-derive.rs:611:39 + --> $DIR/diagnostic-derive.rs:610:39 | LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")] | ^^^^ error: wrong types for suggestion - --> $DIR/diagnostic-derive.rs:620:24 + --> $DIR/diagnostic-derive.rs:619:24 | LL | suggestion: (Span, usize), | ^^^^^ @@ -455,7 +451,7 @@ LL | suggestion: (Span, usize), = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)` error: wrong types for suggestion - --> $DIR/diagnostic-derive.rs:628:17 + --> $DIR/diagnostic-derive.rs:627:17 | LL | suggestion: (Span,), | ^^^^^^^ @@ -463,13 +459,13 @@ LL | suggestion: (Span,), = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)` error: suggestion without `code = "..."` - --> $DIR/diagnostic-derive.rs:635:5 + --> $DIR/diagnostic-derive.rs:634:5 | LL | #[suggestion(no_crate_suggestion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[multipart_suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:642:1 + --> $DIR/diagnostic-derive.rs:641:1 | LL | #[multipart_suggestion(no_crate_suggestion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -477,21 +473,23 @@ LL | #[multipart_suggestion(no_crate_suggestion)] = help: consider creating a `Subdiagnostic` instead error: `#[multipart_suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:649:5 + --> $DIR/diagnostic-derive.rs:644:1 | -LL | #[multipart_suggestion(no_crate_suggestion)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[multipart_suggestion()] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider creating a `Subdiagnostic` instead -error: unexpected end of input, unexpected token in nested attribute, expected ident - --> $DIR/diagnostic-derive.rs:645:24 +error: `#[multipart_suggestion(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:648:5 | -LL | #[multipart_suggestion()] - | ^ +LL | #[multipart_suggestion(no_crate_suggestion)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider creating a `Subdiagnostic` instead error: `#[suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:657:1 + --> $DIR/diagnostic-derive.rs:656:1 | LL | #[suggestion(no_crate_suggestion, code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -499,7 +497,7 @@ LL | #[suggestion(no_crate_suggestion, code = "...")] = help: `#[label]` and `#[suggestion]` can only be applied to fields error: `#[label]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:666:1 + --> $DIR/diagnostic-derive.rs:665:1 | LL | #[label] | ^^^^^^^^ @@ -507,31 +505,31 @@ LL | #[label] = help: `#[label]` and `#[suggestion]` can only be applied to fields error: `eager` is the only supported nested attribute for `subdiagnostic` - --> $DIR/diagnostic-derive.rs:700:7 + --> $DIR/diagnostic-derive.rs:699:7 | LL | #[subdiagnostic(bad)] | ^^^^^^^^^^^^^^^^^^ error: `#[subdiagnostic = ...]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:708:5 + --> $DIR/diagnostic-derive.rs:707:5 | LL | #[subdiagnostic = "bad"] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: `eager` is the only supported nested attribute for `subdiagnostic` - --> $DIR/diagnostic-derive.rs:716:7 + --> $DIR/diagnostic-derive.rs:715:7 | LL | #[subdiagnostic(bad, bad)] | ^^^^^^^^^^^^^^^^^^^^^^^ error: `eager` is the only supported nested attribute for `subdiagnostic` - --> $DIR/diagnostic-derive.rs:724:7 + --> $DIR/diagnostic-derive.rs:723:7 | LL | #[subdiagnostic("bad")] | ^^^^^^^^^^^^^^^^^^^^ error: `#[subdiagnostic(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:732:5 + --> $DIR/diagnostic-derive.rs:731:5 | LL | #[subdiagnostic(eager)] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -539,31 +537,19 @@ LL | #[subdiagnostic(eager)] = help: eager subdiagnostics are not supported on lints error: expected at least one string literal for `code(...)` - --> $DIR/diagnostic-derive.rs:790:23 + --> $DIR/diagnostic-derive.rs:789:23 | LL | #[suggestion(code())] | ^ error: `code(...)` must contain only string literals - --> $DIR/diagnostic-derive.rs:798:23 + --> $DIR/diagnostic-derive.rs:797:23 | LL | #[suggestion(code(foo))] | ^^^ -error: unexpected token - --> $DIR/diagnostic-derive.rs:798:23 - | -LL | #[suggestion(code(foo))] - | ^^^ - -error: expected string literal - --> $DIR/diagnostic-derive.rs:807:25 - | -LL | #[suggestion(code = 3)] - | ^ - error: `#[suggestion(...)]` is not a valid attribute - --> $DIR/diagnostic-derive.rs:822:5 + --> $DIR/diagnostic-derive.rs:821:5 | LL | #[suggestion(no_crate_suggestion, code = "")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -572,68 +558,86 @@ LL | #[suggestion(no_crate_suggestion, code = "")] = help: to show a suggestion consisting of multiple parts, use a `Subdiagnostic` annotated with `#[multipart_suggestion(...)]` = help: to show a variable set of suggestions, use a `Vec` of `Subdiagnostic`s annotated with `#[suggestion(...)]` +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/diagnostic-derive.rs:54:8 + | +LL | #[diag = "E0123"] + | ^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/diagnostic-derive.rs:797:23 + | +LL | #[suggestion(code(foo))] + | ^^^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/diagnostic-derive.rs:806:25 + | +LL | #[suggestion(code = 3)] + | ^ maybe a missing crate `core`? + error: cannot find attribute `nonsense` in this scope - --> $DIR/diagnostic-derive.rs:60:3 + --> $DIR/diagnostic-derive.rs:59:3 | LL | #[nonsense(no_crate_example, code = "E0123")] | ^^^^^^^^ error: cannot find attribute `nonsense` in this scope - --> $DIR/diagnostic-derive.rs:147:7 + --> $DIR/diagnostic-derive.rs:146:7 | LL | #[nonsense] | ^^^^^^^^ error: cannot find attribute `error` in this scope - --> $DIR/diagnostic-derive.rs:580:3 + --> $DIR/diagnostic-derive.rs:579:3 | LL | #[error(no_crate_example, code = "E0123")] | ^^^^^ error: cannot find attribute `warn_` in this scope - --> $DIR/diagnostic-derive.rs:587:3 + --> $DIR/diagnostic-derive.rs:586:3 | LL | #[warn_(no_crate_example, code = "E0123")] | ^^^^^ help: a built-in attribute with a similar name exists: `warn` error: cannot find attribute `lint` in this scope - --> $DIR/diagnostic-derive.rs:594:3 + --> $DIR/diagnostic-derive.rs:593:3 | LL | #[lint(no_crate_example, code = "E0123")] | ^^^^ help: a built-in attribute with a similar name exists: `link` error: cannot find attribute `lint` in this scope - --> $DIR/diagnostic-derive.rs:601:3 + --> $DIR/diagnostic-derive.rs:600:3 | LL | #[lint(no_crate_example, code = "E0123")] | ^^^^ help: a built-in attribute with a similar name exists: `link` error: cannot find attribute `multipart_suggestion` in this scope - --> $DIR/diagnostic-derive.rs:642:3 + --> $DIR/diagnostic-derive.rs:641:3 | LL | #[multipart_suggestion(no_crate_suggestion)] | ^^^^^^^^^^^^^^^^^^^^ error: cannot find attribute `multipart_suggestion` in this scope - --> $DIR/diagnostic-derive.rs:645:3 + --> $DIR/diagnostic-derive.rs:644:3 | LL | #[multipart_suggestion()] | ^^^^^^^^^^^^^^^^^^^^ error: cannot find attribute `multipart_suggestion` in this scope - --> $DIR/diagnostic-derive.rs:649:7 + --> $DIR/diagnostic-derive.rs:648:7 | LL | #[multipart_suggestion(no_crate_suggestion)] | ^^^^^^^^^^^^^^^^^^^^ error[E0425]: cannot find value `nonsense` in module `crate::fluent_generated` - --> $DIR/diagnostic-derive.rs:72:8 + --> $DIR/diagnostic-derive.rs:71:8 | LL | #[diag(nonsense, code = "E0123")] | ^^^^^^^^ not found in `crate::fluent_generated` error[E0425]: cannot find value `__code_34` in this scope - --> $DIR/diagnostic-derive.rs:804:10 + --> $DIR/diagnostic-derive.rs:803:10 | LL | #[derive(Diagnostic)] | ^^^^^^^^^^ not found in this scope @@ -641,7 +645,7 @@ LL | #[derive(Diagnostic)] = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Hello: IntoDiagnosticArg` is not satisfied - --> $DIR/diagnostic-derive.rs:346:12 + --> $DIR/diagnostic-derive.rs:345:12 | LL | #[derive(Diagnostic)] | ---------- required by a bound introduced by this call @@ -656,5 +660,5 @@ note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg` error: aborting due to 84 previous errors -Some errors have detailed explanations: E0277, E0425. +Some errors have detailed explanations: E0277, E0425, E0433. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.rs b/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.rs index a0a8114e0..331483112 100644 --- a/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.rs +++ b/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.rs @@ -1,4 +1,5 @@ // rustc-env:CARGO_CRATE_NAME=rustc_dummy +// ignore-stage1 #![feature(rustc_private)] #![crate_type = "lib"] diff --git a/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.stderr b/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.stderr index dcf4af5df..c752a5ee0 100644 --- a/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.stderr +++ b/tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.stderr @@ -1,5 +1,5 @@ error: diagnostic slug and crate name do not match - --> $DIR/enforce_slug_naming.rs:22:8 + --> $DIR/enforce_slug_naming.rs:23:8 | LL | #[diag(compiletest_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^ @@ -7,5 +7,5 @@ LL | #[diag(compiletest_example, code = "E0123")] = note: slug is `compiletest_example` but the crate name is `rustc_dummy` = help: expected a slug starting with `dummy_...` -error: aborting due to previous error +error: aborting due to 1 previous error diff --git a/tests/ui-fulldeps/session-diagnostic/example.ftl b/tests/ui-fulldeps/session-diagnostic/example.ftl index cb2d476d8..1d1ba8e1b 100644 --- a/tests/ui-fulldeps/session-diagnostic/example.ftl +++ b/tests/ui-fulldeps/session-diagnostic/example.ftl @@ -3,3 +3,5 @@ no_crate_example = this is an example message used in testing .help = with a help .suggestion = with a suggestion .label = with a label + +no_crate_bad_reference = {$r} does not exist diff --git a/tests/ui-fulldeps/session-diagnostic/invalid-variable.rs b/tests/ui-fulldeps/session-diagnostic/invalid-variable.rs new file mode 100644 index 000000000..2ec07fa14 --- /dev/null +++ b/tests/ui-fulldeps/session-diagnostic/invalid-variable.rs @@ -0,0 +1,20 @@ +// run-fail +// compile-flags: --test +// test that messages referencing non-existent fields cause test failures + +#![feature(rustc_private)] +#![crate_type = "lib"] + +extern crate rustc_driver; +extern crate rustc_fluent_macro; +extern crate rustc_macros; +extern crate rustc_errors; +use rustc_macros::Diagnostic; +use rustc_errors::{SubdiagnosticMessage, DiagnosticMessage}; +extern crate rustc_session; + +rustc_fluent_macro::fluent_messages! { "./example.ftl" } + +#[derive(Diagnostic)] +#[diag(no_crate_bad_reference)] +struct BadRef; diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs index 1bfbb6001..74cf91db7 100644 --- a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs @@ -18,11 +18,10 @@ extern crate rustc_session; extern crate rustc_span; use rustc_errors::{Applicability, DiagnosticMessage, SubdiagnosticMessage}; -use rustc_fluent_macro::fluent_messages; use rustc_macros::Subdiagnostic; use rustc_span::Span; -fluent_messages! { "./example.ftl" } +rustc_fluent_macro::fluent_messages! { "./example.ftl" } #[derive(Subdiagnostic)] #[label(no_crate_example)] @@ -85,7 +84,7 @@ struct F { #[derive(Subdiagnostic)] #[label(bug = "...")] -//~^ ERROR invalid nested attribute +//~^ ERROR only `no_span` is a valid nested attribute //~| ERROR diagnostic slug must be first argument struct G { #[primary_span] @@ -95,7 +94,8 @@ struct G { #[derive(Subdiagnostic)] #[label("...")] -//~^ ERROR unexpected literal in nested attribute, expected ident +//~^ ERROR failed to resolve: maybe a missing crate `core`? +//~| NOTE maybe a missing crate `core`? struct H { #[primary_span] span: Span, @@ -104,7 +104,7 @@ struct H { #[derive(Subdiagnostic)] #[label(slug = 4)] -//~^ ERROR invalid nested attribute +//~^ ERROR only `no_span` is a valid nested attribute //~| ERROR diagnostic slug must be first argument struct J { #[primary_span] @@ -114,7 +114,7 @@ struct J { #[derive(Subdiagnostic)] #[label(slug("..."))] -//~^ ERROR invalid nested attribute +//~^ ERROR only `no_span` is a valid nested attribute //~| ERROR diagnostic slug must be first argument struct K { #[primary_span] @@ -134,7 +134,7 @@ struct L { #[derive(Subdiagnostic)] #[label()] -//~^ ERROR unexpected end of input, unexpected token in nested attribute, expected ident +//~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute struct M { #[primary_span] span: Span, @@ -143,7 +143,7 @@ struct M { #[derive(Subdiagnostic)] #[label(no_crate_example, code = "...")] -//~^ ERROR invalid nested attribute +//~^ ERROR only `no_span` is a valid nested attribute struct N { #[primary_span] span: Span, @@ -152,7 +152,7 @@ struct N { #[derive(Subdiagnostic)] #[label(no_crate_example, applicability = "machine-applicable")] -//~^ ERROR invalid nested attribute +//~^ ERROR only `no_span` is a valid nested attribute struct O { #[primary_span] span: Span, @@ -224,7 +224,7 @@ enum T { enum U { #[label(code = "...")] //~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute - //~| ERROR invalid nested attribute + //~| ERROR only `no_span` is a valid nested attribute A { #[primary_span] span: Span, @@ -310,7 +310,8 @@ struct AB { #[derive(Subdiagnostic)] union AC { - //~^ ERROR unexpected unsupported untagged union + //~^ ERROR failed to resolve: maybe a missing crate `core`? + //~| NOTE maybe a missing crate `core`? span: u32, b: u64, } @@ -556,7 +557,7 @@ struct BBb { #[multipart_suggestion(no_crate_example, applicability = "machine-applicable")] struct BBc { #[suggestion_part()] - //~^ ERROR unexpected end of input, unexpected token in nested attribute, expected ident + //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` span1: Span, } @@ -576,11 +577,12 @@ struct BD { //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` span1: Span, #[suggestion_part()] - //~^ ERROR unexpected end of input, unexpected token in nested attribute, expected ident + //~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."` span2: Span, #[suggestion_part(foo = "bar")] //~^ ERROR `code` is the only valid nested attribute - //~| ERROR expected `,` + //~| ERROR failed to resolve: maybe a missing crate `core`? + //~| NOTE maybe a missing crate `core`? span4: Span, #[suggestion_part(code = "...")] //~^ ERROR the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` @@ -672,7 +674,8 @@ enum BL { struct BM { #[suggestion_part(code("foo"))] //~^ ERROR expected exactly one string literal for `code = ...` - //~| ERROR unexpected token + //~| ERROR failed to resolve: maybe a missing crate `core`? + //~| NOTE maybe a missing crate `core`? span: Span, r#type: String, } @@ -682,7 +685,8 @@ struct BM { struct BN { #[suggestion_part(code("foo", "bar"))] //~^ ERROR expected exactly one string literal for `code = ...` - //~| ERROR unexpected token + //~| ERROR failed to resolve: maybe a missing crate `core`? + //~| NOTE maybe a missing crate `core`? span: Span, r#type: String, } @@ -692,7 +696,8 @@ struct BN { struct BO { #[suggestion_part(code(3))] //~^ ERROR expected exactly one string literal for `code = ...` - //~| ERROR unexpected token + //~| ERROR failed to resolve: maybe a missing crate `core`? + //~| NOTE maybe a missing crate `core`? span: Span, r#type: String, } @@ -713,7 +718,8 @@ struct BP { #[multipart_suggestion(no_crate_example)] struct BQ { #[suggestion_part(code = 3)] - //~^ ERROR expected string literal + //~^ ERROR failed to resolve: maybe a missing crate `core`? + //~| NOTE maybe a missing crate `core`? span: Span, r#type: String, } @@ -805,7 +811,8 @@ struct SuggestionStyleInvalid3 { #[derive(Subdiagnostic)] #[suggestion(no_crate_example, code = "", style("foo"))] //~^ ERROR expected `= "xxx"` -//~| ERROr expected `,` +//~| ERROR failed to resolve: maybe a missing crate `core`? +//~| NOTE maybe a missing crate `core`? struct SuggestionStyleInvalid4 { #[primary_span] sub: Span, diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr index fca4f5068..80bee3bd6 100644 --- a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr @@ -1,5 +1,5 @@ error: label without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:52:1 + --> $DIR/subdiagnostic-derive.rs:51:1 | LL | / #[label(no_crate_example)] LL | | @@ -9,42 +9,36 @@ LL | | } | |_^ error: diagnostic slug must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive.rs:59:1 + --> $DIR/subdiagnostic-derive.rs:58:1 | LL | #[label] | ^^^^^^^^ error: `#[foo]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:68:1 + --> $DIR/subdiagnostic-derive.rs:67:1 | LL | #[foo] | ^^^^^^ error: `#[label = ...]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:78:1 + --> $DIR/subdiagnostic-derive.rs:77:1 | LL | #[label = "..."] | ^^^^^^^^^^^^^^^^ -error: invalid nested attribute - --> $DIR/subdiagnostic-derive.rs:87:9 +error: only `no_span` is a valid nested attribute + --> $DIR/subdiagnostic-derive.rs:86:9 | LL | #[label(bug = "...")] | ^^^ error: diagnostic slug must be first argument of a `#[label(...)]` attribute - --> $DIR/subdiagnostic-derive.rs:87:1 + --> $DIR/subdiagnostic-derive.rs:86:1 | LL | #[label(bug = "...")] | ^^^^^^^^^^^^^^^^^^^^^ -error: unexpected literal in nested attribute, expected ident - --> $DIR/subdiagnostic-derive.rs:97:9 - | -LL | #[label("...")] - | ^^^^^ - -error: invalid nested attribute +error: only `no_span` is a valid nested attribute --> $DIR/subdiagnostic-derive.rs:106:9 | LL | #[label(slug = 4)] @@ -56,7 +50,7 @@ error: diagnostic slug must be first argument of a `#[label(...)]` attribute LL | #[label(slug = 4)] | ^^^^^^^^^^^^^^^^^^ -error: invalid nested attribute +error: only `no_span` is a valid nested attribute --> $DIR/subdiagnostic-derive.rs:116:9 | LL | #[label(slug("..."))] @@ -68,19 +62,19 @@ error: diagnostic slug must be first argument of a `#[label(...)]` attribute LL | #[label(slug("..."))] | ^^^^^^^^^^^^^^^^^^^^^ -error: unexpected end of input, unexpected token in nested attribute, expected ident - --> $DIR/subdiagnostic-derive.rs:136:9 +error: diagnostic slug must be first argument of a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:136:1 | LL | #[label()] - | ^ + | ^^^^^^^^^^ -error: invalid nested attribute +error: only `no_span` is a valid nested attribute --> $DIR/subdiagnostic-derive.rs:145:27 | LL | #[label(no_crate_example, code = "...")] | ^^^^ -error: invalid nested attribute +error: only `no_span` is a valid nested attribute --> $DIR/subdiagnostic-derive.rs:154:27 | LL | #[label(no_crate_example, applicability = "machine-applicable")] @@ -116,7 +110,7 @@ error: `#[bar(...)]` is not a valid attribute LL | #[bar("...")] | ^^^^^^^^^^^^^ -error: invalid nested attribute +error: only `no_span` is a valid nested attribute --> $DIR/subdiagnostic-derive.rs:225:13 | LL | #[label(code = "...")] @@ -174,84 +168,74 @@ LL | #[bar("...")] | = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes -error: unexpected unsupported untagged union - --> $DIR/subdiagnostic-derive.rs:312:1 - | -LL | / union AC { -LL | | -LL | | span: u32, -LL | | b: u64, -LL | | } - | |_^ - error: a diagnostic slug must be the first argument to the attribute - --> $DIR/subdiagnostic-derive.rs:327:44 + --> $DIR/subdiagnostic-derive.rs:328:44 | LL | #[label(no_crate_example, no_crate::example)] | ^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:340:5 + --> $DIR/subdiagnostic-derive.rs:341:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:337:5 + --> $DIR/subdiagnostic-derive.rs:338:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ error: subdiagnostic kind not specified - --> $DIR/subdiagnostic-derive.rs:346:8 + --> $DIR/subdiagnostic-derive.rs:347:8 | LL | struct AG { | ^^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:383:46 + --> $DIR/subdiagnostic-derive.rs:384:46 | LL | #[suggestion(no_crate_example, code = "...", code = "...")] | ^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:383:32 + --> $DIR/subdiagnostic-derive.rs:384:32 | LL | #[suggestion(no_crate_example, code = "...", code = "...")] | ^^^^ error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:401:5 + --> $DIR/subdiagnostic-derive.rs:402:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:398:5 + --> $DIR/subdiagnostic-derive.rs:399:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: the `#[applicability]` attribute can only be applied to fields of type `Applicability` - --> $DIR/subdiagnostic-derive.rs:411:5 + --> $DIR/subdiagnostic-derive.rs:412:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: suggestion without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:424:1 + --> $DIR/subdiagnostic-derive.rs:425:1 | LL | #[suggestion(no_crate_example)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid applicability - --> $DIR/subdiagnostic-derive.rs:434:62 + --> $DIR/subdiagnostic-derive.rs:435:62 | LL | #[suggestion(no_crate_example, code = "...", applicability = "foo")] | ^^^^^ error: suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:452:1 + --> $DIR/subdiagnostic-derive.rs:453:1 | LL | / #[suggestion(no_crate_example, code = "...")] LL | | @@ -261,25 +245,25 @@ LL | | } | |_^ error: unsupported type attribute for subdiagnostic enum - --> $DIR/subdiagnostic-derive.rs:466:1 + --> $DIR/subdiagnostic-derive.rs:467:1 | LL | #[label] | ^^^^^^^^ error: `var` doesn't refer to a field on this type - --> $DIR/subdiagnostic-derive.rs:486:39 + --> $DIR/subdiagnostic-derive.rs:487:39 | LL | #[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")] | ^^^^^^^ error: `var` doesn't refer to a field on this type - --> $DIR/subdiagnostic-derive.rs:505:43 + --> $DIR/subdiagnostic-derive.rs:506:43 | LL | #[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")] | ^^^^^^^ error: `#[suggestion_part]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:528:5 + --> $DIR/subdiagnostic-derive.rs:529:5 | LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ @@ -287,7 +271,7 @@ LL | #[suggestion_part] = help: `#[suggestion_part(...)]` is only valid in multipart suggestions, use `#[primary_span]` instead error: `#[suggestion_part(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:531:5 + --> $DIR/subdiagnostic-derive.rs:532:5 | LL | #[suggestion_part(code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -295,7 +279,7 @@ LL | #[suggestion_part(code = "...")] = help: `#[suggestion_part(...)]` is only valid in multipart suggestions error: suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:525:1 + --> $DIR/subdiagnostic-derive.rs:526:1 | LL | / #[suggestion(no_crate_example, code = "...")] LL | | @@ -307,15 +291,15 @@ LL | | } | |_^ error: invalid nested attribute - --> $DIR/subdiagnostic-derive.rs:540:42 + --> $DIR/subdiagnostic-derive.rs:541:42 | LL | #[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")] | ^^^^ | - = help: only `style` and `applicability` are valid nested attributes + = help: only `no_span`, `style` and `applicability` are valid nested attributes error: multipart suggestion without any `#[suggestion_part(...)]` fields - --> $DIR/subdiagnostic-derive.rs:540:1 + --> $DIR/subdiagnostic-derive.rs:541:1 | LL | / #[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")] LL | | @@ -326,19 +310,19 @@ LL | | } | |_^ error: `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:550:5 + --> $DIR/subdiagnostic-derive.rs:551:5 | LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ -error: unexpected end of input, unexpected token in nested attribute, expected ident - --> $DIR/subdiagnostic-derive.rs:558:23 +error: `#[suggestion_part(...)]` attribute without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:559:5 | LL | #[suggestion_part()] - | ^ + | ^^^^^^^^^^^^^^^^^^^^ error: `#[primary_span]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:567:5 + --> $DIR/subdiagnostic-derive.rs:568:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ @@ -346,7 +330,7 @@ LL | #[primary_span] = help: multipart suggestions use one or more `#[suggestion_part]`s rather than one `#[primary_span]` error: multipart suggestion without any `#[suggestion_part(...)]` fields - --> $DIR/subdiagnostic-derive.rs:564:1 + --> $DIR/subdiagnostic-derive.rs:565:1 | LL | / #[multipart_suggestion(no_crate_example)] LL | | @@ -358,121 +342,91 @@ LL | | } | |_^ error: `#[suggestion_part(...)]` attribute without `code = "..."` - --> $DIR/subdiagnostic-derive.rs:575:5 + --> $DIR/subdiagnostic-derive.rs:576:5 | LL | #[suggestion_part] | ^^^^^^^^^^^^^^^^^^ +error: `#[suggestion_part(...)]` attribute without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:579:5 + | +LL | #[suggestion_part()] + | ^^^^^^^^^^^^^^^^^^^^ + error: `code` is the only valid nested attribute - --> $DIR/subdiagnostic-derive.rs:581:23 + --> $DIR/subdiagnostic-derive.rs:582:23 | LL | #[suggestion_part(foo = "bar")] | ^^^ error: the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/subdiagnostic-derive.rs:585:5 + --> $DIR/subdiagnostic-derive.rs:587:5 | LL | #[suggestion_part(code = "...")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` - --> $DIR/subdiagnostic-derive.rs:588:5 + --> $DIR/subdiagnostic-derive.rs:590:5 | LL | #[suggestion_part()] | ^^^^^^^^^^^^^^^^^^^^ -error: unexpected end of input, unexpected token in nested attribute, expected ident - --> $DIR/subdiagnostic-derive.rs:578:23 - | -LL | #[suggestion_part()] - | ^ - -error: expected `,` - --> $DIR/subdiagnostic-derive.rs:581:27 - | -LL | #[suggestion_part(foo = "bar")] - | ^ - error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:596:37 + --> $DIR/subdiagnostic-derive.rs:598:37 | LL | #[suggestion_part(code = "...", code = ",,,")] | ^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:596:23 + --> $DIR/subdiagnostic-derive.rs:598:23 | LL | #[suggestion_part(code = "...", code = ",,,")] | ^^^^ error: `#[applicability]` has no effect if all `#[suggestion]`/`#[multipart_suggestion]` attributes have a static `applicability = "..."` - --> $DIR/subdiagnostic-derive.rs:625:5 + --> $DIR/subdiagnostic-derive.rs:627:5 | LL | #[applicability] | ^^^^^^^^^^^^^^^^ error: expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive.rs:673:34 + --> $DIR/subdiagnostic-derive.rs:675:34 | LL | #[suggestion_part(code("foo"))] | ^ -error: unexpected token - --> $DIR/subdiagnostic-derive.rs:673:28 - | -LL | #[suggestion_part(code("foo"))] - | ^^^^^ - error: expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive.rs:683:41 + --> $DIR/subdiagnostic-derive.rs:686:41 | LL | #[suggestion_part(code("foo", "bar"))] | ^ -error: unexpected token - --> $DIR/subdiagnostic-derive.rs:683:28 - | -LL | #[suggestion_part(code("foo", "bar"))] - | ^^^^^ - error: expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive.rs:693:30 + --> $DIR/subdiagnostic-derive.rs:697:30 | LL | #[suggestion_part(code(3))] | ^ -error: unexpected token - --> $DIR/subdiagnostic-derive.rs:693:28 - | -LL | #[suggestion_part(code(3))] - | ^ - error: expected exactly one string literal for `code = ...` - --> $DIR/subdiagnostic-derive.rs:703:29 + --> $DIR/subdiagnostic-derive.rs:708:29 | LL | #[suggestion_part(code())] | ^ -error: expected string literal - --> $DIR/subdiagnostic-derive.rs:715:30 - | -LL | #[suggestion_part(code = 3)] - | ^ - error: specified multiple times - --> $DIR/subdiagnostic-derive.rs:757:1 + --> $DIR/subdiagnostic-derive.rs:763:1 | LL | #[suggestion(no_crate_example, code = "", style = "hidden", style = "normal")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/subdiagnostic-derive.rs:757:1 + --> $DIR/subdiagnostic-derive.rs:763:1 | LL | #[suggestion(no_crate_example, code = "", style = "hidden", style = "normal")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[suggestion_hidden(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:766:1 + --> $DIR/subdiagnostic-derive.rs:772:1 | LL | #[suggestion_hidden(no_crate_example, code = "")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -480,7 +434,7 @@ LL | #[suggestion_hidden(no_crate_example, code = "")] = help: Use `#[suggestion(..., style = "hidden")]` instead error: `#[suggestion_hidden(...)]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:774:1 + --> $DIR/subdiagnostic-derive.rs:780:1 | LL | #[suggestion_hidden(no_crate_example, code = "", style = "normal")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -488,7 +442,7 @@ LL | #[suggestion_hidden(no_crate_example, code = "", style = "normal")] = help: Use `#[suggestion(..., style = "hidden")]` instead error: invalid suggestion style - --> $DIR/subdiagnostic-derive.rs:782:51 + --> $DIR/subdiagnostic-derive.rs:788:51 | LL | #[suggestion(no_crate_example, code = "", style = "foo")] | ^^^^^ @@ -496,31 +450,25 @@ LL | #[suggestion(no_crate_example, code = "", style = "foo")] = help: valid styles are `normal`, `short`, `hidden`, `verbose` and `tool-only` error: expected `= "xxx"` - --> $DIR/subdiagnostic-derive.rs:790:49 + --> $DIR/subdiagnostic-derive.rs:796:49 | LL | #[suggestion(no_crate_example, code = "", style = 42)] | ^ error: a diagnostic slug must be the first argument to the attribute - --> $DIR/subdiagnostic-derive.rs:798:48 + --> $DIR/subdiagnostic-derive.rs:804:48 | LL | #[suggestion(no_crate_example, code = "", style)] | ^ error: expected `= "xxx"` - --> $DIR/subdiagnostic-derive.rs:806:48 - | -LL | #[suggestion(no_crate_example, code = "", style("foo"))] - | ^ - -error: expected `,` - --> $DIR/subdiagnostic-derive.rs:806:48 + --> $DIR/subdiagnostic-derive.rs:812:48 | LL | #[suggestion(no_crate_example, code = "", style("foo"))] | ^ error: `#[primary_span]` is not a valid attribute - --> $DIR/subdiagnostic-derive.rs:818:5 + --> $DIR/subdiagnostic-derive.rs:825:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ @@ -529,7 +477,7 @@ LL | #[primary_span] = help: to create a suggestion with multiple spans, use `#[multipart_suggestion]` instead error: suggestion without `#[primary_span]` field - --> $DIR/subdiagnostic-derive.rs:815:1 + --> $DIR/subdiagnostic-derive.rs:822:1 | LL | / #[suggestion(no_crate_example, code = "")] LL | | @@ -540,8 +488,56 @@ LL | | sub: Vec<Span>, LL | | } | |_^ +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:96:9 + | +LL | #[label("...")] + | ^^^^^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:312:1 + | +LL | union AC { + | ^^^^^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:582:27 + | +LL | #[suggestion_part(foo = "bar")] + | ^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:675:28 + | +LL | #[suggestion_part(code("foo"))] + | ^^^^^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:686:28 + | +LL | #[suggestion_part(code("foo", "bar"))] + | ^^^^^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:697:28 + | +LL | #[suggestion_part(code(3))] + | ^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:720:30 + | +LL | #[suggestion_part(code = 3)] + | ^ maybe a missing crate `core`? + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/subdiagnostic-derive.rs:812:48 + | +LL | #[suggestion(no_crate_example, code = "", style("foo"))] + | ^ maybe a missing crate `core`? + error: cannot find attribute `foo` in this scope - --> $DIR/subdiagnostic-derive.rs:68:3 + --> $DIR/subdiagnostic-derive.rs:67:3 | LL | #[foo] | ^^^ @@ -601,7 +597,7 @@ LL | #[label(slug)] | ^^^^ not found in `crate::fluent_generated` error[E0425]: cannot find value `__code_29` in this scope - --> $DIR/subdiagnostic-derive.rs:709:10 + --> $DIR/subdiagnostic-derive.rs:714:10 | LL | #[derive(Subdiagnostic)] | ^^^^^^^^^^^^^ not found in this scope @@ -610,4 +606,5 @@ LL | #[derive(Subdiagnostic)] error: aborting due to 86 previous errors -For more information about this error, try `rustc --explain E0425`. +Some errors have detailed explanations: E0425, E0433. +For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui-fulldeps/stable-mir/check_abi.rs b/tests/ui-fulldeps/stable-mir/check_abi.rs new file mode 100644 index 000000000..30b42bc3b --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/check_abi.rs @@ -0,0 +1,143 @@ +// run-pass +//! Test information regarding type layout. + +// ignore-stage1 +// ignore-cross-compile +// ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 + +#![feature(rustc_private)] +#![feature(assert_matches)] +#![feature(control_flow_enum)] +#![feature(ascii_char, ascii_char_variants)] + +extern crate rustc_hir; +extern crate rustc_middle; +#[macro_use] +extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate stable_mir; + +use rustc_middle::ty::TyCtxt; +use rustc_smir::rustc_internal; +use stable_mir::abi::{ArgAbi, CallConvention, FieldsShape, PassMode, VariantsShape}; +use stable_mir::mir::mono::Instance; +use stable_mir::{CrateDef, CrateItem, CrateItems, ItemKind}; +use std::assert_matches::assert_matches; +use std::convert::TryFrom; +use std::io::Write; +use std::ops::ControlFlow; + +const CRATE_NAME: &str = "input"; + +/// This function uses the Stable MIR APIs to get information about the test crate. +fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { + // Find items in the local crate. + let items = stable_mir::all_local_items(); + + // Test fn_abi + let target_fn = *get_item(&items, (ItemKind::Fn, "fn_abi")).unwrap(); + let instance = Instance::try_from(target_fn).unwrap(); + let fn_abi = instance.fn_abi().unwrap(); + assert_eq!(fn_abi.conv, CallConvention::Rust); + assert_eq!(fn_abi.args.len(), 2); + + check_ignore(&fn_abi.args[0]); + check_primitive(&fn_abi.args[1]); + check_result(fn_abi.ret); + + // Test variadic function. + let variadic_fn = *get_item(&items, (ItemKind::Fn, "variadic_fn")).unwrap(); + check_variadic(variadic_fn); + + ControlFlow::Continue(()) +} + +/// Check the variadic function ABI: +/// ```no_run +/// pub unsafe extern "C" fn variadic_fn(n: usize, mut args: ...) -> usize { +/// 0 +/// } +/// ``` +fn check_variadic(variadic_fn: CrateItem) { + let instance = Instance::try_from(variadic_fn).unwrap(); + let abi = instance.fn_abi().unwrap(); + assert!(abi.c_variadic); + assert_eq!(abi.args.len(), 1); +} + +/// Check the argument to be ignored: `ignore: [u8; 0]`. +fn check_ignore(abi: &ArgAbi) { + assert!(abi.ty.kind().is_array()); + assert_eq!(abi.mode, PassMode::Ignore); + let layout = abi.layout.shape(); + assert!(layout.is_sized()); + assert!(layout.is_1zst()); +} + +/// Check the primitive argument: `primitive: char`. +fn check_primitive(abi: &ArgAbi) { + assert!(abi.ty.kind().is_char()); + assert_matches!(abi.mode, PassMode::Direct(_)); + let layout = abi.layout.shape(); + assert!(layout.is_sized()); + assert!(!layout.is_1zst()); + assert_matches!(layout.fields, FieldsShape::Primitive); +} + +/// Check the return value: `Result<usize, &str>`. +fn check_result(abi: ArgAbi) { + assert!(abi.ty.kind().is_enum()); + assert_matches!(abi.mode, PassMode::Indirect { .. }); + let layout = abi.layout.shape(); + assert!(layout.is_sized()); + assert_matches!(layout.fields, FieldsShape::Arbitrary { .. }); + assert_matches!(layout.variants, VariantsShape::Multiple { .. }) +} + +fn get_item<'a>( + items: &'a CrateItems, + item: (ItemKind, &str), +) -> Option<&'a stable_mir::CrateItem> { + items.iter().find(|crate_item| (item.0 == crate_item.kind()) && crate_item.name() == item.1) +} + +/// This test will generate and analyze a dummy crate using the stable mir. +/// For that, it will first write the dummy crate into a file. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. +fn main() { + let path = "alloc_input.rs"; + generate_input(&path).unwrap(); + let args = vec![ + "rustc".to_string(), + "--crate-type=lib".to_string(), + "--crate-name".to_string(), + CRATE_NAME.to_string(), + path.to_string(), + ]; + run!(args, tcx, test_stable_mir(tcx)).unwrap(); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + #![feature(c_variadic)] + #![allow(unused_variables)] + + pub fn fn_abi(ignore: [u8; 0], primitive: char) -> Result<usize, &'static str> {{ + // We only care about the signature. + todo!() + }} + + + pub unsafe extern "C" fn variadic_fn(n: usize, mut args: ...) -> usize {{ + 0 + }} + "# + )?; + Ok(()) +} diff --git a/tests/ui-fulldeps/stable-mir/check_allocation.rs b/tests/ui-fulldeps/stable-mir/check_allocation.rs new file mode 100644 index 000000000..b13f76452 --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/check_allocation.rs @@ -0,0 +1,277 @@ +// run-pass +//! Test that users are able to use stable mir APIs to retrieve information of global allocations +//! such as `vtable_allocation`. + +// ignore-stage1 +// ignore-cross-compile +// ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 +// edition: 2021 + +#![feature(rustc_private)] +#![feature(assert_matches)] +#![feature(control_flow_enum)] +#![feature(ascii_char, ascii_char_variants)] +#![feature(c_str_literals)] + +extern crate rustc_hir; +extern crate rustc_middle; +#[macro_use] +extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate stable_mir; + +use rustc_middle::ty::TyCtxt; +use rustc_smir::rustc_internal; +use stable_mir::crate_def::CrateDef; +use stable_mir::mir::alloc::GlobalAlloc; +use stable_mir::mir::mono::{Instance, InstanceKind, StaticDef}; +use stable_mir::mir::{Body, TerminatorKind}; +use stable_mir::ty::{Allocation, ConstantKind, RigidTy, TyKind}; +use stable_mir::{CrateItem, CrateItems, ItemKind}; +use std::ascii::Char; +use std::assert_matches::assert_matches; +use std::cmp::{max, min}; +use std::collections::HashMap; +use std::ffi::CStr; +use std::io::Write; +use std::ops::ControlFlow; + +const CRATE_NAME: &str = "input"; + +/// This function uses the Stable MIR APIs to get information about the test crate. +fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { + // Find items in the local crate. + let items = stable_mir::all_local_items(); + check_foo(*get_item(&items, (ItemKind::Static, "FOO")).unwrap()); + check_bar(*get_item(&items, (ItemKind::Static, "BAR")).unwrap()); + check_len(*get_item(&items, (ItemKind::Static, "LEN")).unwrap()); + check_cstr(*get_item(&items, (ItemKind::Static, "C_STR")).unwrap()); + check_other_consts(*get_item(&items, (ItemKind::Fn, "other_consts")).unwrap()); + check_type_id(*get_item(&items, (ItemKind::Fn, "check_type_id")).unwrap()); + ControlFlow::Continue(()) +} + +/// Check the allocation data for static `FOO`. +/// +/// ```no_run +/// static FOO: [&str; 2] = ["hi", "there"]; +/// ``` +fn check_foo(item: CrateItem) { + let def = StaticDef::try_from(item).unwrap(); + let alloc = def.eval_initializer().unwrap(); + assert_eq!(alloc.provenance.ptrs.len(), 2); + + let alloc_id_0 = alloc.provenance.ptrs[0].1.0; + assert_matches!(GlobalAlloc::from(alloc_id_0), GlobalAlloc::Memory(..)); + + let alloc_id_1 = alloc.provenance.ptrs[1].1.0; + assert_matches!(GlobalAlloc::from(alloc_id_1), GlobalAlloc::Memory(..)); +} + +/// Check the allocation data for static `BAR`. +/// +/// ```no_run +/// static BAR: &str = "Bar"; +/// ``` +fn check_bar(item: CrateItem) { + let def = StaticDef::try_from(item).unwrap(); + let alloc = def.eval_initializer().unwrap(); + assert_eq!(alloc.provenance.ptrs.len(), 1); + + let alloc_id_0 = alloc.provenance.ptrs[0].1.0; + let GlobalAlloc::Memory(allocation) = GlobalAlloc::from(alloc_id_0) else { unreachable!() }; + assert_eq!(allocation.bytes.len(), 3); + assert_eq!(allocation.bytes[0].unwrap(), Char::CapitalB.to_u8()); + assert_eq!(allocation.bytes[1].unwrap(), Char::SmallA.to_u8()); + assert_eq!(allocation.bytes[2].unwrap(), Char::SmallR.to_u8()); + assert_eq!(std::str::from_utf8(&allocation.raw_bytes().unwrap()), Ok("Bar")); +} + +/// Check the allocation data for static `C_STR`. +/// +/// ```no_run +/// static C_STR: &core::ffi::cstr = c"cstr"; +/// ``` +fn check_cstr(item: CrateItem) { + let def = StaticDef::try_from(item).unwrap(); + let alloc = def.eval_initializer().unwrap(); + assert_eq!(alloc.provenance.ptrs.len(), 1); + let deref = item.ty().kind().builtin_deref(true).unwrap(); + assert!(deref.ty.kind().is_cstr(), "Expected CStr, but got: {:?}", item.ty()); + + let alloc_id_0 = alloc.provenance.ptrs[0].1.0; + let GlobalAlloc::Memory(allocation) = GlobalAlloc::from(alloc_id_0) else { unreachable!() }; + assert_eq!(allocation.bytes.len(), 5); + assert_eq!(CStr::from_bytes_until_nul(&allocation.raw_bytes().unwrap()), Ok(c"cstr")); +} + +/// Check the allocation data for constants used in `other_consts` function. +fn check_other_consts(item: CrateItem) { + // Instance body will force constant evaluation. + let body = Instance::try_from(item).unwrap().body().unwrap(); + let assigns = collect_consts(&body); + assert_eq!(assigns.len(), 9); + for (name, alloc) in assigns { + match name.as_str() { + "_max_u128" => { + assert_eq!(alloc.read_uint(), Ok(u128::MAX), "Failed parsing allocation: {alloc:?}") + } + "_min_i128" => { + assert_eq!(alloc.read_int(), Ok(i128::MIN), "Failed parsing allocation: {alloc:?}") + } + "_max_i8" => { + assert_eq!( + alloc.read_int().unwrap() as i8, + i8::MAX, + "Failed parsing allocation: {alloc:?}" + ) + } + "_char" => { + assert_eq!( + char::from_u32(alloc.read_uint().unwrap() as u32), + Some('x'), + "Failed parsing allocation: {alloc:?}" + ) + } + "_false" => { + assert_eq!(alloc.read_bool(), Ok(false), "Failed parsing allocation: {alloc:?}") + } + "_true" => { + assert_eq!(alloc.read_bool(), Ok(true), "Failed parsing allocation: {alloc:?}") + } + "_ptr" => { + assert_eq!(alloc.is_null(), Ok(false), "Failed parsing allocation: {alloc:?}") + } + "_null_ptr" => { + assert_eq!(alloc.is_null(), Ok(true), "Failed parsing allocation: {alloc:?}") + } + "_tuple" => { + // The order of fields is not guaranteed. + let first = alloc.read_partial_uint(0..4).unwrap(); + let second = alloc.read_partial_uint(4..8).unwrap(); + assert_eq!(max(first, second) as u32, u32::MAX); + assert_eq!(min(first, second), 10); + } + _ => { + unreachable!("{name} -- {alloc:?}") + } + } + } +} + +/// Check that we can retrieve the type id of char and bool, and that they have different values. +fn check_type_id(item: CrateItem) { + let body = Instance::try_from(item).unwrap().body().unwrap(); + let mut ids: Vec<u128> = vec![]; + for term in body.blocks.iter().map(|bb| &bb.terminator) { + match &term.kind { + TerminatorKind::Call { func, destination, .. } => { + let TyKind::RigidTy(ty) = func.ty(body.locals()).unwrap().kind() else { + unreachable!() + }; + let RigidTy::FnDef(def, args) = ty else { unreachable!() }; + let instance = Instance::resolve(def, &args).unwrap(); + assert_eq!(instance.kind, InstanceKind::Intrinsic); + let dest_ty = destination.ty(body.locals()).unwrap(); + let alloc = instance.try_const_eval(dest_ty).unwrap(); + ids.push(alloc.read_uint().unwrap()); + } + _ => { /* Do nothing */ } + } + } + assert_eq!(ids.len(), 2); + assert_ne!(ids[0], ids[1]); +} + +/// Collects all the constant assignments. +pub fn collect_consts(body: &Body) -> HashMap<String, &Allocation> { + body.var_debug_info + .iter() + .filter_map(|info| { + info.constant().map(|const_op| { + let ConstantKind::Allocated(alloc) = const_op.const_.kind() else { unreachable!() }; + (info.name.clone(), alloc) + }) + }) + .collect::<HashMap<_, _>>() +} + +/// Check the allocation data for `LEN`. +/// +/// ```no_run +/// static LEN: usize = 2; +/// ``` +fn check_len(item: CrateItem) { + let def = StaticDef::try_from(item).unwrap(); + let alloc = def.eval_initializer().unwrap(); + assert!(alloc.provenance.ptrs.is_empty()); + assert_eq!(alloc.read_uint(), Ok(2)); +} + +fn get_item<'a>( + items: &'a CrateItems, + item: (ItemKind, &str), +) -> Option<&'a stable_mir::CrateItem> { + items.iter().find(|crate_item| (item.0 == crate_item.kind()) && crate_item.name() == item.1) +} + +/// This test will generate and analyze a dummy crate using the stable mir. +/// For that, it will first write the dummy crate into a file. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. +fn main() { + let path = "alloc_input.rs"; + generate_input(&path).unwrap(); + let args = vec![ + "rustc".to_string(), + "--edition=2021".to_string(), + "--crate-name".to_string(), + CRATE_NAME.to_string(), + path.to_string(), + ]; + run!(args, tcx, test_stable_mir(tcx)).unwrap(); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + #![feature(core_intrinsics)] + #![feature(c_str_literals)] + use std::intrinsics::type_id; + + static LEN: usize = 2; + static FOO: [&str; 2] = ["hi", "there"]; + static BAR: &str = "Bar"; + static C_STR: &std::ffi::CStr = c"cstr"; + const NULL: *const u8 = std::ptr::null(); + const TUPLE: (u32, u32) = (10, u32::MAX); + + fn other_consts() {{ + let _max_u128 = u128::MAX; + let _min_i128 = i128::MIN; + let _max_i8 = i8::MAX; + let _char = 'x'; + let _false = false; + let _true = true; + let _ptr = &BAR; + let _null_ptr: *const u8 = NULL; + let _tuple = TUPLE; + }} + + fn check_type_id() {{ + let _char_id = type_id::<char>(); + let _bool_id = type_id::<bool>(); + }} + + pub fn main() {{ + println!("{{FOO:?}}! {{BAR}}"); + assert_eq!(FOO.len(), LEN); + other_consts(); + }}"# + )?; + Ok(()) +} diff --git a/tests/ui-fulldeps/stable-mir/check_defs.rs b/tests/ui-fulldeps/stable-mir/check_defs.rs new file mode 100644 index 000000000..e9a2599d8 --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/check_defs.rs @@ -0,0 +1,132 @@ +// run-pass +//! Test that users are able to use stable mir APIs to retrieve information about crate definitions. + +// ignore-stage1 +// ignore-cross-compile +// ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 +// edition: 2021 + +#![feature(rustc_private)] +#![feature(assert_matches)] +#![feature(control_flow_enum)] + +extern crate rustc_middle; +#[macro_use] +extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate stable_mir; + +use std::assert_matches::assert_matches; +use mir::{mono::Instance, TerminatorKind::*}; +use rustc_middle::ty::TyCtxt; +use rustc_smir::rustc_internal; +use stable_mir::ty::{RigidTy, TyKind, Ty, UintTy}; +use stable_mir::*; +use std::io::Write; +use std::ops::ControlFlow; + +const CRATE_NAME: &str = "input"; + +/// This function uses the Stable MIR APIs to get information about the test crate. +fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { + let entry = stable_mir::entry_fn().unwrap(); + let main_fn = Instance::try_from(entry).unwrap(); + assert_eq!(main_fn.name(), "main"); + assert_eq!(main_fn.trimmed_name(), "main"); + + let instances = get_instances(main_fn.body().unwrap()); + assert_eq!(instances.len(), 2); + test_fn(instances[0], "from_u32", "std::char::from_u32", "core"); + test_fn(instances[1], "Vec::<u8>::new", "std::vec::Vec::<u8>::new", "alloc"); + test_vec_new(instances[1]); + ControlFlow::Continue(()) +} + +fn test_fn(instance: Instance, expected_trimmed: &str, expected_qualified: &str, krate: &str) { + let trimmed = instance.trimmed_name(); + let qualified = instance.name(); + assert_eq!(&trimmed, expected_trimmed); + assert_eq!(&qualified, expected_qualified); + + let item = CrateItem::try_from(instance).unwrap(); + let trimmed = item.trimmed_name(); + let qualified = item.name(); + assert_eq!(trimmed, expected_trimmed.replace("u8", "T")); + assert_eq!(qualified, expected_qualified.replace("u8", "T")); + assert_eq!(&item.krate().name, krate); +} + +fn extract_elem_ty(ty: Ty) -> Ty { + match ty.kind() { + TyKind::RigidTy(RigidTy::Adt(_, args)) => { + *args.0[0].expect_ty() + } + _ => unreachable!("Expected Vec ADT, but found: {ty:?}") + } +} + +/// Check signature and type of `Vec::<u8>::new` and its generic version. +fn test_vec_new(instance: mir::mono::Instance) { + let sig = instance.fn_abi().unwrap(); + assert_eq!(&sig.args, &[]); + let elem_ty = extract_elem_ty(sig.ret.ty); + assert_matches!(elem_ty.kind(), TyKind::RigidTy(RigidTy::Uint(UintTy::U8))); + + // Get the signature for Vec::<T>::new. + let item = CrateItem::try_from(instance).unwrap(); + let ty = item.ty(); + let gen_sig = ty.kind().fn_sig().unwrap().skip_binder(); + let gen_ty = extract_elem_ty(gen_sig.output()); + assert_matches!(gen_ty.kind(), TyKind::Param(_)); +} + +/// Inspect the instance body +fn get_instances(body: mir::Body) -> Vec<Instance> { + body.blocks.iter().filter_map(|bb| { + match &bb.terminator.kind { + Call { func, .. } => { + let TyKind::RigidTy(ty) = func.ty(body.locals()).unwrap().kind() else { unreachable! + () }; + let RigidTy::FnDef(def, args) = ty else { unreachable!() }; + Instance::resolve(def, &args).ok() + } + _ => { + None + } + } + }).collect::<Vec<_>>() +} + +/// This test will generate and analyze a dummy crate using the stable mir. +/// For that, it will first write the dummy crate into a file. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. +fn main() { + let path = "defs_input.rs"; + generate_input(&path).unwrap(); + let args = vec![ + "rustc".to_string(), + "-Cpanic=abort".to_string(), + "--crate-name".to_string(), + CRATE_NAME.to_string(), + path.to_string(), + ]; + run!(args, tcx, test_stable_mir(tcx)).unwrap(); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + + fn main() {{ + let _c = core::char::from_u32(99); + let _v = Vec::<u8>::new(); + }} + "# + )?; + Ok(()) +} diff --git a/tests/ui-fulldeps/stable-mir/check_instance.rs b/tests/ui-fulldeps/stable-mir/check_instance.rs new file mode 100644 index 000000000..5cb07eabf --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/check_instance.rs @@ -0,0 +1,135 @@ +// run-pass +//! Test that users are able to use stable mir APIs to retrieve monomorphized instances + +// ignore-stage1 +// ignore-cross-compile +// ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 +// edition: 2021 + +#![feature(rustc_private)] +#![feature(assert_matches)] +#![feature(control_flow_enum)] + +extern crate rustc_middle; +#[macro_use] +extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate stable_mir; + +use mir::{mono::Instance, TerminatorKind::*}; +use rustc_middle::ty::TyCtxt; +use rustc_smir::rustc_internal; +use stable_mir::ty::{RigidTy, TyKind}; +use stable_mir::*; +use std::io::Write; +use std::ops::ControlFlow; + +const CRATE_NAME: &str = "input"; + +/// This function uses the Stable MIR APIs to get information about the test crate. +fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { + let items = stable_mir::all_local_items(); + + // Get all items and split generic vs monomorphic items. + let (generic, mono): (Vec<_>, Vec<_>) = + items.into_iter().partition(|item| item.requires_monomorphization()); + assert_eq!(mono.len(), 3, "Expected 2 mono functions and one constant"); + assert_eq!(generic.len(), 2, "Expected 2 generic functions"); + + // For all monomorphic items, get the correspondent instances. + let instances = mono + .iter() + .filter_map(|item| mir::mono::Instance::try_from(*item).ok()) + .collect::<Vec<mir::mono::Instance>>(); + assert_eq!(instances.len(), mono.len()); + + // For all generic items, try_from should fail. + assert!(generic.iter().all(|item| mir::mono::Instance::try_from(*item).is_err())); + + for instance in instances { + test_body(instance.body().unwrap()) + } + ControlFlow::Continue(()) +} + +/// Inspect the instance body +fn test_body(body: mir::Body) { + for term in body.blocks.iter().map(|bb| &bb.terminator) { + match &term.kind { + Call { func, .. } => { + let TyKind::RigidTy(ty) = func.ty(body.locals()).unwrap().kind() else { unreachable! + () }; + let RigidTy::FnDef(def, args) = ty else { unreachable!() }; + let instance = Instance::resolve(def, &args).unwrap(); + let mangled_name = instance.mangled_name(); + assert!(instance.has_body() || (mangled_name == "setpwent"), "Failed: {func:?}"); + assert!(instance.has_body() ^ instance.is_foreign_item()); + if instance.has_body() { + let body = instance.body().unwrap(); + assert!(!body.locals().is_empty(), "Body must at least have a return local"); + } + } + Goto { .. } | Assert { .. } | SwitchInt { .. } | Return | Drop { .. } => { + /* Do nothing */ + } + _ => { + unreachable!("Unexpected terminator {term:?}") + } + } + } +} + +/// This test will generate and analyze a dummy crate using the stable mir. +/// For that, it will first write the dummy crate into a file. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. +fn main() { + let path = "instance_input.rs"; + generate_input(&path).unwrap(); + let args = vec![ + "rustc".to_string(), + "-Cpanic=abort".to_string(), + "--crate-type=lib".to_string(), + "--crate-name".to_string(), + CRATE_NAME.to_string(), + path.to_string(), + ]; + run!(args, tcx, test_stable_mir(tcx)).unwrap(); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + pub fn ty_param<T>(t: &T) -> T where T: Clone {{ + t.clone() + }} + + pub fn const_param<const LEN: usize>(a: [bool; LEN]) -> bool {{ + LEN > 0 && a[0] + }} + + extern "C" {{ + // Body should not be available. + fn setpwent(); + }} + + pub fn monomorphic() {{ + let v = vec![10]; + let dup = ty_param(&v); + assert_eq!(v, dup); + unsafe {{ setpwent() }}; + }} + + pub mod foo {{ + pub fn bar_mono(i: i32) -> i64 {{ + i as i64 + }} + }} + "# + )?; + Ok(()) +} diff --git a/tests/ui-fulldeps/stable-mir/check_item_kind.rs b/tests/ui-fulldeps/stable-mir/check_item_kind.rs new file mode 100644 index 000000000..72e0e09e6 --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/check_item_kind.rs @@ -0,0 +1,84 @@ +// run-pass +//! Test that item kind works as expected. + +// ignore-stage1 +// ignore-cross-compile +// ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 +// edition: 2021 + +#![feature(rustc_private)] +#![feature(assert_matches)] +#![feature(control_flow_enum)] + +extern crate rustc_middle; +#[macro_use] +extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate stable_mir; + +use rustc_middle::ty::TyCtxt; +use rustc_smir::rustc_internal; +use stable_mir::*; +use std::io::Write; +use std::ops::ControlFlow; + +const CRATE_NAME: &str = "input"; + +/// This function uses the Stable MIR APIs to get information about the test crate. +fn test_item_kind(_tcx: TyCtxt<'_>) -> ControlFlow<()> { + let items = stable_mir::all_local_items(); + assert_eq!(items.len(), 4); + // Constructor item. + for item in items { + let expected_kind = match item.name().as_str() { + "Dummy" => ItemKind::Ctor(CtorKind::Fn), + "dummy" => ItemKind::Fn, + "unit" => ItemKind::Fn, + "DUMMY_CONST" => ItemKind::Const, + name => unreachable!("Unexpected item {name}"), + }; + assert_eq!(item.kind(), expected_kind, "Mismatched type for {}", item.name()); + } + ControlFlow::Continue(()) +} + +/// This test will generate and analyze a dummy crate using the stable mir. +/// For that, it will first write the dummy crate into a file. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. +fn main() { + let path = "item_kind_input.rs"; + generate_input(&path).unwrap(); + let args = vec![ + "rustc".to_string(), + "-Cpanic=abort".to_string(), + "--crate-type=lib".to_string(), + "--crate-name".to_string(), + CRATE_NAME.to_string(), + path.to_string(), + ]; + run!(args, tcx, test_item_kind(tcx)).unwrap(); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + pub struct Dummy(u32); + pub const DUMMY_CONST: Dummy = Dummy(0); + pub struct DummyUnit; + + pub fn dummy() -> Dummy {{ + Dummy(5) + }} + + pub fn unit() -> DummyUnit {{ + DummyUnit + }} + "# + )?; + Ok(()) +} diff --git a/tests/ui-fulldeps/stable-mir/check_ty_fold.rs b/tests/ui-fulldeps/stable-mir/check_ty_fold.rs new file mode 100644 index 000000000..b90d47d45 --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/check_ty_fold.rs @@ -0,0 +1,115 @@ +// run-pass +//! Test that users are able to use stable mir APIs to retrieve monomorphized types, and that +//! we have an error handling for trying to instantiate types with incorrect arguments. + +// ignore-stage1 +// ignore-cross-compile +// ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 +// edition: 2021 + +#![feature(rustc_private)] +#![feature(assert_matches)] +#![feature(control_flow_enum)] + +extern crate rustc_middle; +#[macro_use] +extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate stable_mir; + +use rustc_middle::ty::TyCtxt; +use rustc_smir::rustc_internal; +use stable_mir::ty::{RigidTy, TyKind, Ty, }; +use stable_mir::mir::{Body, MirVisitor, FieldIdx, Place, ProjectionElem, visit::{Location, + PlaceContext}}; +use std::io::Write; +use std::ops::ControlFlow; + +const CRATE_NAME: &str = "input"; + +/// This function uses the Stable MIR APIs to get information about the test crate. +fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { + let main_fn = stable_mir::entry_fn(); + let body = main_fn.unwrap().body(); + let mut visitor = PlaceVisitor{ body: &body, tested: false}; + visitor.visit_body(&body); + assert!(visitor.tested); + ControlFlow::Continue(()) +} + +struct PlaceVisitor<'a> { + body: &'a Body, + /// Used to ensure that the test was reachable. Otherwise this test would vacuously succeed. + tested: bool, +} + +/// Check that `wrapper.inner` place projection can be correctly interpreted. +/// Ensure that instantiation is correct. +fn check_tys(local_ty: Ty, idx: FieldIdx, expected_ty: Ty) { + let TyKind::RigidTy(RigidTy::Adt(def, args)) = local_ty.kind() else { unreachable!() }; + assert_eq!(def.ty_with_args(&args), local_ty); + + let field_def = &def.variants_iter().next().unwrap().fields()[idx]; + let field_ty = field_def.ty_with_args(&args); + assert_eq!(field_ty, expected_ty); + + // Check that the generic version is different than the instantiated one. + let field_ty_gen = field_def.ty(); + assert_ne!(field_ty_gen, field_ty); +} + +impl<'a> MirVisitor for PlaceVisitor<'a> { + fn visit_place(&mut self, place: &Place, _ptx: PlaceContext, _loc: Location) { + let start_ty = self.body.locals()[place.local].ty; + match place.projection.as_slice() { + [ProjectionElem::Field(idx, ty)] => { + check_tys(start_ty, *idx, *ty); + self.tested = true; + } + _ => {} + } + } +} + +/// This test will generate and analyze a dummy crate using the stable mir. +/// For that, it will first write the dummy crate into a file. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. +fn main() { + let path = "ty_fold_input.rs"; + generate_input(&path).unwrap(); + let args = vec![ + "rustc".to_string(), + "-Cpanic=abort".to_string(), + "--crate-name".to_string(), + CRATE_NAME.to_string(), + path.to_string(), + ]; + run!(args, tcx, test_stable_mir(tcx)).unwrap(); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + struct Wrapper<T: Default> {{ + pub inner: T + }} + + impl<T: Default> Wrapper<T> {{ + pub fn new() -> Wrapper<T> {{ + Wrapper {{ inner: T::default() }} + }} + }} + + fn main() {{ + let wrapper = Wrapper::<u8>::new(); + let _inner = wrapper.inner; + }} + "# + )?; + Ok(()) +} diff --git a/tests/ui-fulldeps/stable-mir/compilation-result.rs b/tests/ui-fulldeps/stable-mir/compilation-result.rs new file mode 100644 index 000000000..fc56e2481 --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/compilation-result.rs @@ -0,0 +1,79 @@ +// run-pass +// Test StableMIR behavior when different results are given + +// ignore-stage1 +// ignore-cross-compile +// ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 +// edition: 2021 + +#![feature(rustc_private)] +#![feature(assert_matches)] + +extern crate rustc_middle; +#[macro_use] +extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate stable_mir; + +use rustc_middle::ty::TyCtxt; +use rustc_smir::rustc_internal; +use std::io::Write; + +/// This test will generate and analyze a dummy crate using the stable mir. +/// For that, it will first write the dummy crate into a file. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. +fn main() { + let path = "input_compilation_result_test.rs"; + generate_input(&path).unwrap(); + let args = vec!["rustc".to_string(), path.to_string()]; + test_continue(args.clone()); + test_break(args.clone()); + test_failed(args.clone()); + test_skipped(args); +} + +fn test_continue(args: Vec<String>) { + let result = run!(args, ControlFlow::Continue::<(), bool>(true)); + assert_eq!(result, Ok(true)); +} + +fn test_break(args: Vec<String>) { + let result = run!(args, ControlFlow::Break::<bool, i32>(false)); + assert_eq!(result, Err(stable_mir::CompilerError::Interrupted(false))); +} + +#[allow(unreachable_code)] +fn test_skipped(mut args: Vec<String>) { + args.push("--version".to_string()); + let result = run!(args, unreachable!() as ControlFlow<()>); + assert_eq!(result, Err(stable_mir::CompilerError::Skipped)); +} + +#[allow(unreachable_code)] +fn test_failed(mut args: Vec<String>) { + args.push("--cfg=broken".to_string()); + let result = run!(args, unreachable!() as ControlFlow<()>); + assert_eq!(result, Err(stable_mir::CompilerError::CompilationFailed)); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + // This should trigger a compilation failure when enabled. + #[cfg(broken)] + mod broken_mod {{ + fn call_invalid() {{ + invalid_fn(); + }} + }} + + fn main() {{}} + "# + )?; + Ok(()) +} diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index a3db2e9ef..c2035430a 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -4,27 +4,36 @@ // ignore-stage1 // ignore-cross-compile // ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 // edition: 2021 #![feature(rustc_private)] +#![feature(assert_matches)] +#![feature(control_flow_enum)] -extern crate rustc_driver; extern crate rustc_hir; -extern crate rustc_interface; extern crate rustc_middle; +#[macro_use] extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate stable_mir; -use rustc_driver::{Callbacks, Compilation, RunCompiler}; use rustc_hir::def::DefKind; -use rustc_interface::{interface, Queries}; use rustc_middle::ty::TyCtxt; -use rustc_smir::{rustc_internal, stable_mir}; +use rustc_smir::rustc_internal; +use stable_mir::ItemKind; +use stable_mir::crate_def::CrateDef; +use stable_mir::mir::mono::Instance; +use stable_mir::ty::{RigidTy, TyKind}; +use std::assert_matches::assert_matches; use std::io::Write; +use std::ops::ControlFlow; const CRATE_NAME: &str = "input"; /// This function uses the Stable MIR APIs to get information about the test crate. -fn test_stable_mir(tcx: TyCtxt<'_>) { +fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { // Get the local crate using stable_mir API. let local = stable_mir::local_crate(); assert_eq!(&local.name, CRATE_NAME); @@ -33,71 +42,148 @@ fn test_stable_mir(tcx: TyCtxt<'_>) { // Find items in the local crate. let items = stable_mir::all_local_items(); - assert!(get_item(tcx, &items, (DefKind::Fn, "foo::bar")).is_some()); + assert!(get_item(&items, (DefKind::Fn, "foo::bar")).is_some()); - // Find the `std` crate. - assert!(stable_mir::find_crate("std").is_some()); + // Find the `std` crate and assert that there is only one of it. + assert!(stable_mir::find_crates("std").len() == 1); - let bar = get_item(tcx, &items, (DefKind::Fn, "bar")).unwrap(); + let bar = get_item(&items, (DefKind::Fn, "bar")).unwrap(); let body = bar.body(); - assert_eq!(body.locals.len(), 2); + assert_eq!(body.locals().len(), 2); assert_eq!(body.blocks.len(), 1); let block = &body.blocks[0]; assert_eq!(block.statements.len(), 1); - match &block.statements[0] { - stable_mir::mir::Statement::Assign(..) => {} + match &block.statements[0].kind { + stable_mir::mir::StatementKind::Assign(..) => {} other => panic!("{other:?}"), } - match &block.terminator { - stable_mir::mir::Terminator::Return => {} + match &block.terminator.kind { + stable_mir::mir::TerminatorKind::Return => {} other => panic!("{other:?}"), } - let foo_bar = get_item(tcx, &items, (DefKind::Fn, "foo_bar")).unwrap(); + let foo_bar = get_item(&items, (DefKind::Fn, "foo_bar")).unwrap(); let body = foo_bar.body(); - assert_eq!(body.locals.len(), 7); + assert_eq!(body.locals().len(), 5); assert_eq!(body.blocks.len(), 4); let block = &body.blocks[0]; - match &block.terminator { - stable_mir::mir::Terminator::Call { .. } => {} + match &block.terminator.kind { + stable_mir::mir::TerminatorKind::Call { .. } => {} other => panic!("{other:?}"), } - let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap(); + let types = get_item(&items, (DefKind::Fn, "types")).unwrap(); + let body = types.body(); + assert_eq!(body.locals().len(), 6); + assert_matches!( + body.locals()[0].ty.kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool) + ); + assert_matches!( + body.locals()[1].ty.kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool) + ); + assert_matches!( + body.locals()[2].ty.kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Char) + ); + assert_matches!( + body.locals()[3].ty.kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Int(stable_mir::ty::IntTy::I32)) + ); + assert_matches!( + body.locals()[4].ty.kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Uint(stable_mir::ty::UintTy::U64)) + ); + assert_matches!( + body.locals()[5].ty.kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Float( + stable_mir::ty::FloatTy::F64 + )) + ); + + let drop = get_item(&items, (DefKind::Fn, "drop")).unwrap(); let body = drop.body(); assert_eq!(body.blocks.len(), 2); let block = &body.blocks[0]; - match &block.terminator { - stable_mir::mir::Terminator::Drop { .. } => {} + match &block.terminator.kind { + stable_mir::mir::TerminatorKind::Drop { .. } => {} other => panic!("{other:?}"), } - let assert = get_item(tcx, &items, (DefKind::Fn, "assert")).unwrap(); + let assert = get_item(&items, (DefKind::Fn, "assert")).unwrap(); let body = assert.body(); assert_eq!(body.blocks.len(), 2); let block = &body.blocks[0]; - match &block.terminator { - stable_mir::mir::Terminator::Assert { .. } => {} + match &block.terminator.kind { + stable_mir::mir::TerminatorKind::Assert { .. } => {} other => panic!("{other:?}"), } + + let monomorphic = get_item(&items, (DefKind::Fn, "monomorphic")).unwrap(); + let instance = Instance::try_from(monomorphic.clone()).unwrap(); + for block in instance.body().unwrap().blocks { + match &block.terminator.kind { + stable_mir::mir::TerminatorKind::Call { func, .. } => { + let TyKind::RigidTy(ty) = func.ty(&body.locals()).unwrap().kind() else { + unreachable!() }; + let RigidTy::FnDef(def, args) = ty else { unreachable!() }; + let next_func = Instance::resolve(def, &args).unwrap(); + match next_func.body().unwrap().locals()[1].ty.kind() { + TyKind::RigidTy(RigidTy::Uint(_)) | TyKind::RigidTy(RigidTy::Tuple(_)) => {} + other => panic!("{other:?}"), + } + } + stable_mir::mir::TerminatorKind::Return => {} + other => panic!("{other:?}"), + } + } + + let foo_const = get_item(&items, (DefKind::Const, "FOO")).unwrap(); + // Ensure we don't panic trying to get the body of a constant. + foo_const.body(); + + let locals_fn = get_item(&items, (DefKind::Fn, "locals")).unwrap(); + let body = locals_fn.body(); + assert_eq!(body.locals().len(), 4); + assert_matches!( + body.ret_local().ty.kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Char) + ); + assert_eq!(body.arg_locals().len(), 2); + assert_matches!( + body.arg_locals()[0].ty.kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Int(stable_mir::ty::IntTy::I32)) + ); + assert_matches!( + body.arg_locals()[1].ty.kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Uint(stable_mir::ty::UintTy::U64)) + ); + assert_eq!(body.inner_locals().len(), 1); + // If conditions have an extra inner local to hold their results + assert_matches!( + body.inner_locals()[0].ty.kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool) + ); + + ControlFlow::Continue(()) } // Use internal API to find a function in a crate. fn get_item<'a>( - tcx: TyCtxt, items: &'a stable_mir::CrateItems, item: (DefKind, &str), ) -> Option<&'a stable_mir::CrateItem> { items.iter().find(|crate_item| { - let def_id = rustc_internal::item_def_id(crate_item); - tcx.def_kind(def_id) == item.0 && tcx.def_path_str(def_id) == item.1 + matches!((item.0, crate_item.kind()), (DefKind::Fn, ItemKind::Fn) | (DefKind::Const, + ItemKind::Const)) && crate_item.name() == item.1 }) } /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. -/// It will invoke the compiler using a custom Callback implementation, which will -/// invoke Stable MIR APIs after the compiler has finished its analysis. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. fn main() { let path = "input.rs"; generate_input(&path).unwrap(); @@ -108,28 +194,7 @@ fn main() { CRATE_NAME.to_string(), path.to_string(), ]; - rustc_driver::catch_fatal_errors(|| { - RunCompiler::new(&args, &mut SMirCalls {}).run().unwrap(); - }) - .unwrap(); -} - -struct SMirCalls {} - -impl Callbacks for SMirCalls { - /// Called after analysis. Return value instructs the compiler whether to - /// continue the compilation afterwards (defaults to `Compilation::Continue`) - fn after_analysis<'tcx>( - &mut self, - _compiler: &interface::Compiler, - queries: &'tcx Queries<'tcx>, - ) -> Compilation { - queries.global_ctxt().unwrap().enter(|tcx| { - rustc_smir::rustc_internal::run(tcx, || test_stable_mir(tcx)); - }); - // No need to keep going. - Compilation::Stop - } + run!(args, tcx, test_stable_mir(tcx)).unwrap(); } fn generate_input(path: &str) -> std::io::Result<()> { @@ -137,6 +202,18 @@ fn generate_input(path: &str) -> std::io::Result<()> { write!( file, r#" + pub const FOO: u32 = 1 + 2; + + fn generic<T, const U: usize>(t: T) -> [(); U] {{ + _ = t; + [(); U] + }} + + pub fn monomorphic() {{ + generic::<(), 5>(()); + generic::<u32, 0>(45); + }} + mod foo {{ pub fn bar(i: i32) -> i64 {{ i as i64 @@ -153,10 +230,22 @@ fn generate_input(path: &str) -> std::io::Result<()> { x_64.wrapping_add(y_64) }} + pub fn types(b: bool, _: char, _: i32, _: u64, _: f64) -> bool {{ + b + }} + pub fn drop(_: String) {{}} pub fn assert(x: i32) -> i32 {{ x + 1 + }} + + pub fn locals(a: i32, _: u64) -> char {{ + if a > 5 {{ + 'a' + }} else {{ + 'b' + }} }}"# )?; Ok(()) diff --git a/tests/ui-fulldeps/stable-mir/projections.rs b/tests/ui-fulldeps/stable-mir/projections.rs new file mode 100644 index 000000000..8c3fda7b6 --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/projections.rs @@ -0,0 +1,180 @@ +// run-pass +// Tests the Stable MIR projections API + +// ignore-stage1 +// ignore-cross-compile +// ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 +// edition: 2021 + +#![feature(rustc_private)] +#![feature(assert_matches)] +#![feature(control_flow_enum)] + +extern crate rustc_hir; +extern crate rustc_middle; +#[macro_use] +extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate stable_mir; + +use rustc_middle::ty::TyCtxt; +use rustc_smir::rustc_internal; +use stable_mir::crate_def::CrateDef; +use stable_mir::mir::{ProjectionElem, Rvalue, StatementKind}; +use stable_mir::ty::{RigidTy, TyKind, UintTy}; +use stable_mir::ItemKind; +use std::assert_matches::assert_matches; +use std::io::Write; +use std::ops::ControlFlow; + +const CRATE_NAME: &str = "input"; + +/// Tests projections within Place objects +fn test_place_projections(_tcx: TyCtxt<'_>) -> ControlFlow<()> { + let items = stable_mir::all_local_items(); + let body = get_item(&items, (ItemKind::Fn, "projections")).unwrap().body(); + assert_eq!(body.blocks.len(), 4); + // The first statement assigns `&s.c` to a local. The projections include a deref for `s`, since + // `s` is passed as a reference argument, and a field access for field `c`. + match &body.blocks[0].statements[0].kind { + StatementKind::Assign( + place @ stable_mir::mir::Place { local: _, projection: local_proj }, + Rvalue::Ref(_, _, stable_mir::mir::Place { local: _, projection: r_proj }), + ) => { + // We can't match on vecs, only on slices. Comparing statements for equality wouldn't be + // any easier since we'd then have to add in the expected local and region values + // instead of matching on wildcards. + assert!(local_proj.is_empty()); + match &r_proj[..] { + // Similarly we can't match against a type, only against its kind. + [ProjectionElem::Deref, ProjectionElem::Field(2, ty)] => { + assert_matches!( + ty.kind(), + TyKind::RigidTy(RigidTy::Uint(stable_mir::ty::UintTy::U8)) + ); + let ty = place.ty(body.locals()).unwrap(); + assert_matches!(ty.kind().rigid(), Some(RigidTy::Ref(..))); + }, + other => panic!( + "Unable to match against expected rvalue projection. Expected the projection \ + for `s.c`, which is a Deref and u8 Field. Got: {:?}", + other + ), + }; + } + other => panic!( + "Unable to match against expected Assign statement with a Ref rvalue. Expected the \ + statement to assign `&s.c` to a local. Got: {:?}", + other + ), + }; + // This statement assigns `slice[1]` to a local. The projections include a deref for `slice`, + // since `slice` is a reference, and an index. + match &body.blocks[2].statements[0].kind { + StatementKind::Assign( + place @ stable_mir::mir::Place { local: _, projection: local_proj }, + Rvalue::Use(stable_mir::mir::Operand::Copy(stable_mir::mir::Place { + local: _, + projection: r_proj, + })), + ) => { + // We can't match on vecs, only on slices. Comparing for equality wouldn't be any easier + // since we'd then have to add in the expected local values instead of matching on + // wildcards. + assert!(local_proj.is_empty()); + assert_matches!(r_proj[..], [ProjectionElem::Deref, ProjectionElem::Index(_)]); + let ty = place.ty(body.locals()).unwrap(); + assert_matches!(ty.kind().rigid(), Some(RigidTy::Uint(UintTy::U8))); + } + other => panic!( + "Unable to match against expected Assign statement with a Use rvalue. Expected the \ + statement to assign `slice[1]` to a local. Got: {:?}", + other + ), + }; + // The first terminator gets a slice of an array via the Index operation. Specifically it + // performs `&vals[1..3]`. There are no projections in this case, the arguments are just locals. + match &body.blocks[0].terminator.kind { + stable_mir::mir::TerminatorKind::Call { args, .. } => + // We can't match on vecs, only on slices. Comparing for equality wouldn't be any easier + // since we'd then have to add in the expected local values instead of matching on + // wildcards. + { + match &args[..] { + [ + stable_mir::mir::Operand::Move(stable_mir::mir::Place { + local: _, + projection: arg1_proj, + }), + stable_mir::mir::Operand::Move(stable_mir::mir::Place { + local: _, + projection: arg2_proj, + }), + ] => { + assert!(arg1_proj.is_empty()); + assert!(arg2_proj.is_empty()); + } + other => { + panic!( + "Unable to match against expected arguments to Index call. Expected two \ + move operands. Got: {:?}", + other + ) + } + } + } + other => panic!( + "Unable to match against expected Call terminator. Expected a terminator that calls \ + the Index operation. Got: {:?}", + other + ), + }; + + ControlFlow::Continue(()) +} + +// Use internal API to find a function in a crate. +fn get_item<'a>( + items: &'a stable_mir::CrateItems, + item: (ItemKind, &str), +) -> Option<&'a stable_mir::CrateItem> { + items.iter().find(|crate_item| { + crate_item.kind() == item.0 && crate_item.name() == item.1 + }) +} + +/// This test will generate and analyze a dummy crate using the stable mir. +/// For that, it will first write the dummy crate into a file. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. +fn main() { + let path = "input.rs"; + generate_input(&path).unwrap(); + let args = vec![ + "rustc".to_string(), + "--crate-type=lib".to_string(), + "--crate-name".to_string(), + CRATE_NAME.to_string(), + path.to_string(), + ]; + run!(args, tcx, test_place_projections(tcx)).unwrap(); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + pub struct Struct1 {{ _a: u8, _b: u16, c: u8 }} + + pub fn projections(s: &Struct1) -> u8 {{ + let v = &s.c; + let vals = [1, 2, 3, 4]; + let slice = &vals[1..3]; + v + slice[1] + }}"# + )?; + Ok(()) +} diff --git a/tests/ui-fulldeps/stable-mir/smir_internal.rs b/tests/ui-fulldeps/stable-mir/smir_internal.rs new file mode 100644 index 000000000..b0596b188 --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/smir_internal.rs @@ -0,0 +1,64 @@ +// run-pass +//! Test that users are able to use retrieve internal constructs from stable ones to help with +//! the migration. + +// ignore-stage1 +// ignore-cross-compile +// ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 +// edition: 2021 + +#![feature(rustc_private)] +#![feature(assert_matches)] +#![feature(control_flow_enum)] + +#[macro_use] +extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate rustc_middle; +extern crate stable_mir; + +use rustc_middle::ty::TyCtxt; +use rustc_smir::rustc_internal; +use std::io::Write; +use std::ops::ControlFlow; + +const CRATE_NAME: &str = "input"; + +fn test_translation(_tcx: TyCtxt<'_>) -> ControlFlow<()> { + let main_fn = stable_mir::entry_fn().unwrap(); + let body = main_fn.body(); + let orig_ty = body.locals()[0].ty; + let rustc_ty = rustc_internal::internal(&orig_ty); + assert!(rustc_ty.is_unit()); + ControlFlow::Continue(()) +} + +/// This test will generate and analyze a dummy crate using the stable mir. +/// For that, it will first write the dummy crate into a file. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. +fn main() { + let path = "internal_input.rs"; + generate_input(&path).unwrap(); + let args = vec![ + "rustc".to_string(), + "--crate-name".to_string(), + CRATE_NAME.to_string(), + path.to_string(), + ]; + run!(args, tcx, test_translation(tcx)).unwrap(); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + pub fn main() {{ + }} + "# + )?; + Ok(()) +} diff --git a/tests/ui-fulldeps/stable-mir/smir_visitor.rs b/tests/ui-fulldeps/stable-mir/smir_visitor.rs new file mode 100644 index 000000000..027b0e7d9 --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/smir_visitor.rs @@ -0,0 +1,149 @@ +// run-pass +//! Sanity check Stable MIR Visitor + +// ignore-stage1 +// ignore-cross-compile +// ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 +// edition: 2021 + +#![feature(rustc_private)] +#![feature(assert_matches)] +#![feature(control_flow_enum)] + +extern crate rustc_middle; +#[macro_use] +extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate stable_mir; + +use std::collections::HashSet; +use rustc_middle::ty::TyCtxt; +use rustc_smir::rustc_internal; +use stable_mir::*; +use stable_mir::mir::MirVisitor; +use std::io::Write; +use std::ops::ControlFlow; + +const CRATE_NAME: &str = "input"; + +fn test_visitor(_tcx: TyCtxt<'_>) -> ControlFlow<()> { + let main_fn = stable_mir::entry_fn(); + let main_body = main_fn.unwrap().body(); + let main_visitor = TestVisitor::collect(&main_body); + assert!(main_visitor.ret_val.is_some()); + assert!(main_visitor.args.is_empty()); + assert!(main_visitor.tys.contains(&main_visitor.ret_val.unwrap().ty)); + assert!(!main_visitor.calls.is_empty()); + + let exit_fn = main_visitor.calls.last().unwrap(); + assert!(exit_fn.mangled_name().contains("exit_fn"), "Unexpected last function: {exit_fn:?}"); + + let exit_body = exit_fn.body().unwrap(); + let exit_visitor = TestVisitor::collect(&exit_body); + assert!(exit_visitor.ret_val.is_some()); + assert_eq!(exit_visitor.args.len(), 1); + assert!(exit_visitor.tys.contains(&exit_visitor.ret_val.unwrap().ty)); + assert!(exit_visitor.tys.contains(&exit_visitor.args[0].ty)); + ControlFlow::Continue(()) +} + +struct TestVisitor<'a> { + pub body: &'a mir::Body, + pub tys: HashSet<ty::Ty>, + pub ret_val: Option<mir::LocalDecl>, + pub args: Vec<mir::LocalDecl>, + pub calls: Vec<mir::mono::Instance> +} + +impl<'a> TestVisitor<'a> { + fn collect(body: &'a mir::Body) -> TestVisitor<'a> { + let mut visitor = TestVisitor { + body: &body, + tys: Default::default(), + ret_val: None, + args: vec![], + calls: vec![], + }; + visitor.visit_body(&body); + visitor + } +} + +impl<'a> mir::MirVisitor for TestVisitor<'a> { + fn visit_ty(&mut self, ty: &ty::Ty, _location: mir::visit::Location) { + self.tys.insert(*ty); + self.super_ty(ty) + } + + fn visit_ret_decl(&mut self, local: mir::Local, decl: &mir::LocalDecl) { + assert!(local == mir::RETURN_LOCAL); + assert!(self.ret_val.is_none()); + self.ret_val = Some(decl.clone()); + self.super_ret_decl(local, decl); + } + + fn visit_arg_decl(&mut self, local: mir::Local, decl: &mir::LocalDecl) { + self.args.push(decl.clone()); + assert_eq!(local, self.args.len()); + self.super_arg_decl(local, decl); + } + + fn visit_terminator(&mut self, term: &mir::Terminator, location: mir::visit::Location) { + if let mir::TerminatorKind::Call { func, .. } = &term.kind { + let ty::TyKind::RigidTy(ty) = func.ty(self.body.locals()).unwrap().kind() else { + unreachable! + () }; + let ty::RigidTy::FnDef(def, args) = ty else { unreachable!() }; + self.calls.push(mir::mono::Instance::resolve(def, &args).unwrap()); + } + self.super_terminator(term, location); + } +} + +/// This test will generate and analyze a dummy crate using the stable mir. +/// For that, it will first write the dummy crate into a file. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. +fn main() { + let path = "sim_visitor_input.rs"; + generate_input(&path).unwrap(); + let args = vec![ + "rustc".to_string(), + "-Cpanic=abort".to_string(), + "--crate-name".to_string(), + CRATE_NAME.to_string(), + path.to_string(), + ]; + run!(args, tcx, test_visitor(tcx)).unwrap(); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + fn main() -> std::process::ExitCode {{ + let inputs = Inputs::new(); + let total = inputs.values.iter().sum(); + exit_fn(total) + }} + + fn exit_fn(code: u8) -> std::process::ExitCode {{ + std::process::ExitCode::from(code) + }} + + struct Inputs {{ + values: [u8; 3], + }} + + impl Inputs {{ + fn new() -> Inputs {{ + Inputs {{ values: [0, 1, 2] }} + }} + }} + "# + )?; + Ok(()) +} |