summaryrefslogtreecommitdiffstats
path: root/tests/ui-fulldeps
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui-fulldeps')
-rw-r--r--tests/ui-fulldeps/dropck-tarena-cycle-checked.rs2
-rw-r--r--tests/ui-fulldeps/dropck-tarena-cycle-checked.stderr4
-rw-r--r--tests/ui-fulldeps/dropck-tarena-unsound-drop.rs2
-rw-r--r--tests/ui-fulldeps/dropck-tarena-unsound-drop.stderr4
-rw-r--r--tests/ui-fulldeps/fluent-messages/test.rs43
-rw-r--r--tests/ui-fulldeps/fluent-messages/test.stderr78
-rw-r--r--tests/ui-fulldeps/internal-lints/diagnostics.rs23
-rw-r--r--tests/ui-fulldeps/internal-lints/diagnostics.stderr26
-rw-r--r--tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.rs3
-rw-r--r--tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.stderr6
-rw-r--r--tests/ui-fulldeps/pathless-extern-unstable.rs1
-rw-r--r--tests/ui-fulldeps/pathless-extern-unstable.stderr4
-rw-r--r--tests/ui-fulldeps/pprust-expr-roundtrip.rs4
-rw-r--r--tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs3
-rw-r--r--tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr4
-rw-r--r--tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs3
-rw-r--r--tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr182
-rw-r--r--tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.rs1
-rw-r--r--tests/ui-fulldeps/session-diagnostic/enforce_slug_naming.stderr4
-rw-r--r--tests/ui-fulldeps/session-diagnostic/invalid-variable.rs3
-rw-r--r--tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs3
-rw-r--r--tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr182
-rw-r--r--tests/ui-fulldeps/stable-mir/check_abi.rs143
-rw-r--r--tests/ui-fulldeps/stable-mir/check_allocation.rs277
-rw-r--r--tests/ui-fulldeps/stable-mir/check_defs.rs132
-rw-r--r--tests/ui-fulldeps/stable-mir/check_instance.rs21
-rw-r--r--tests/ui-fulldeps/stable-mir/check_item_kind.rs84
-rw-r--r--tests/ui-fulldeps/stable-mir/check_ty_fold.rs115
-rw-r--r--tests/ui-fulldeps/stable-mir/crate-info.rs12
-rw-r--r--tests/ui-fulldeps/stable-mir/projections.rs180
-rw-r--r--tests/ui-fulldeps/stable-mir/smir_visitor.rs5
31 files changed, 1241 insertions, 313 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/span_use_eq_ctxt.rs b/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.rs
index aeb68bf05..392199866 100644
--- a/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.rs
+++ b/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.rs
@@ -1,7 +1,6 @@
// Test the `rustc::span_use_eq_ctxt` internal lint
-// #[cfg(bootstrap)]
-// ignore-stage1
// compile-flags: -Z unstable-options
+// ignore-stage1
#![feature(rustc_private)]
#![deny(rustc::span_use_eq_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
index 3d8a7dd1e..fcf2565c8 100644
--- a/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.stderr
+++ b/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.stderr
@@ -1,14 +1,14 @@
error: use `.eq_ctxt()` instead of `.ctxt() == .ctxt()`
- --> $DIR/span_use_eq_ctxt.rs:14:5
+ --> $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:7:9
+ --> $DIR/span_use_eq_ctxt.rs:6:9
|
LL | #![deny(rustc::span_use_eq_ctxt)]
| ^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
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/pprust-expr-roundtrip.rs b/tests/ui-fulldeps/pprust-expr-roundtrip.rs
index 685a029dc..24c4543c2 100644
--- a/tests/ui-fulldeps/pprust-expr-roundtrip.rs
+++ b/tests/ui-fulldeps/pprust-expr-roundtrip.rs
@@ -32,7 +32,7 @@ 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;
@@ -132,7 +132,7 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) {
binder: ClosureBinder::NotPresent,
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,
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 283d87d3e..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
@@ -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 70d7b3225..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
diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs
index c30120e5c..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")]
diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr
index 014cd5a73..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,7 +13,7 @@ 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,
| ^^^
@@ -21,13 +21,13 @@ LL | Bar,
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
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 | |
@@ -39,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 | |
@@ -49,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 | |
@@ -66,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")]
| ^^^^^^^^
@@ -74,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 | |
@@ -85,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")]
| ^^^^^^^^
@@ -93,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 | |
@@ -104,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")]
| ^^^^
@@ -112,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 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -168,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 | |
@@ -178,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
@@ -211,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
@@ -220,19 +220,19 @@ 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")]
| ^^^^^^^^
@@ -240,13 +240,13 @@ LL | #[suggestion(nonsense = "bar")]
= 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")]
| ^^^
@@ -254,13 +254,13 @@ LL | #[suggestion(msg = "bar")]
= 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 | |
@@ -270,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: only `no_span` is a valid nested attribute
- --> $DIR/diagnostic-derive.rs:540:29
+ --> $DIR/diagnostic-derive.rs:539:29
|
LL | #[label(no_crate_label, foo = "...")]
| ^^^
error: only `no_span` is a valid nested attribute
- --> $DIR/diagnostic-derive.rs:548:29
+ --> $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]
| ^^^^^^^^^^^^^^^
@@ -350,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 | |
@@ -368,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 | |
@@ -386,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 | |
@@ -404,13 +404,13 @@ 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")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -418,7 +418,7 @@ 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 | |
@@ -431,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),
| ^^^^^
@@ -451,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,),
| ^^^^^^^
@@ -459,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)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -473,7 +473,7 @@ LL | #[multipart_suggestion(no_crate_suggestion)]
= help: consider creating a `Subdiagnostic` instead
error: `#[multipart_suggestion(...)]` is not a valid attribute
- --> $DIR/diagnostic-derive.rs:645:1
+ --> $DIR/diagnostic-derive.rs:644:1
|
LL | #[multipart_suggestion()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -481,7 +481,7 @@ LL | #[multipart_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:648:5
|
LL | #[multipart_suggestion(no_crate_suggestion)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -489,7 +489,7 @@ 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 = "...")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -497,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]
| ^^^^^^^^
@@ -505,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)]
| ^^^^^^^^^^^^^^^^^^^^^^^
@@ -537,19 +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: `#[suggestion(...)]` is not a valid attribute
- --> $DIR/diagnostic-derive.rs:822:5
+ --> $DIR/diagnostic-derive.rs:821:5
|
LL | #[suggestion(no_crate_suggestion, code = "")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -559,85 +559,85 @@ LL | #[suggestion(no_crate_suggestion, code = "")]
= 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:55:8
+ --> $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:798:23
+ --> $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:807:25
+ --> $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
@@ -645,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
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/invalid-variable.rs b/tests/ui-fulldeps/session-diagnostic/invalid-variable.rs
index 57798dda3..2ec07fa14 100644
--- a/tests/ui-fulldeps/session-diagnostic/invalid-variable.rs
+++ b/tests/ui-fulldeps/session-diagnostic/invalid-variable.rs
@@ -9,12 +9,11 @@ extern crate rustc_driver;
extern crate rustc_fluent_macro;
extern crate rustc_macros;
extern crate rustc_errors;
-use rustc_fluent_macro::fluent_messages;
use rustc_macros::Diagnostic;
use rustc_errors::{SubdiagnosticMessage, DiagnosticMessage};
extern crate rustc_session;
-fluent_messages! { "./example.ftl" }
+rustc_fluent_macro::fluent_messages! { "./example.ftl" }
#[derive(Diagnostic)]
#[diag(no_crate_bad_reference)]
diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs
index dd0f7a7ef..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)]
diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr
index 1f267aceb..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,127 +9,127 @@ 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: only `no_span` is a valid nested attribute
- --> $DIR/subdiagnostic-derive.rs:87:9
+ --> $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: only `no_span` is a valid nested attribute
- --> $DIR/subdiagnostic-derive.rs:107:9
+ --> $DIR/subdiagnostic-derive.rs:106:9
|
LL | #[label(slug = 4)]
| ^^^^
error: diagnostic slug must be first argument of a `#[label(...)]` attribute
- --> $DIR/subdiagnostic-derive.rs:107:1
+ --> $DIR/subdiagnostic-derive.rs:106:1
|
LL | #[label(slug = 4)]
| ^^^^^^^^^^^^^^^^^^
error: only `no_span` is a valid nested attribute
- --> $DIR/subdiagnostic-derive.rs:117:9
+ --> $DIR/subdiagnostic-derive.rs:116:9
|
LL | #[label(slug("..."))]
| ^^^^
error: diagnostic slug must be first argument of a `#[label(...)]` attribute
- --> $DIR/subdiagnostic-derive.rs:117:1
+ --> $DIR/subdiagnostic-derive.rs:116:1
|
LL | #[label(slug("..."))]
| ^^^^^^^^^^^^^^^^^^^^^
error: diagnostic slug must be first argument of a `#[label(...)]` attribute
- --> $DIR/subdiagnostic-derive.rs:137:1
+ --> $DIR/subdiagnostic-derive.rs:136:1
|
LL | #[label()]
| ^^^^^^^^^^
error: only `no_span` is a valid nested attribute
- --> $DIR/subdiagnostic-derive.rs:146:27
+ --> $DIR/subdiagnostic-derive.rs:145:27
|
LL | #[label(no_crate_example, code = "...")]
| ^^^^
error: only `no_span` is a valid nested attribute
- --> $DIR/subdiagnostic-derive.rs:155:27
+ --> $DIR/subdiagnostic-derive.rs:154:27
|
LL | #[label(no_crate_example, applicability = "machine-applicable")]
| ^^^^^^^^^^^^^
error: unsupported type attribute for subdiagnostic enum
- --> $DIR/subdiagnostic-derive.rs:164:1
+ --> $DIR/subdiagnostic-derive.rs:163:1
|
LL | #[foo]
| ^^^^^^
error: `#[bar]` is not a valid attribute
- --> $DIR/subdiagnostic-derive.rs:178:5
+ --> $DIR/subdiagnostic-derive.rs:177:5
|
LL | #[bar]
| ^^^^^^
error: `#[bar = ...]` is not a valid attribute
- --> $DIR/subdiagnostic-derive.rs:190:5
+ --> $DIR/subdiagnostic-derive.rs:189:5
|
LL | #[bar = "..."]
| ^^^^^^^^^^^^^^
error: `#[bar = ...]` is not a valid attribute
- --> $DIR/subdiagnostic-derive.rs:202:5
+ --> $DIR/subdiagnostic-derive.rs:201:5
|
LL | #[bar = 4]
| ^^^^^^^^^^
error: `#[bar(...)]` is not a valid attribute
- --> $DIR/subdiagnostic-derive.rs:214:5
+ --> $DIR/subdiagnostic-derive.rs:213:5
|
LL | #[bar("...")]
| ^^^^^^^^^^^^^
error: only `no_span` is a valid nested attribute
- --> $DIR/subdiagnostic-derive.rs:226:13
+ --> $DIR/subdiagnostic-derive.rs:225:13
|
LL | #[label(code = "...")]
| ^^^^
error: diagnostic slug must be first argument of a `#[label(...)]` attribute
- --> $DIR/subdiagnostic-derive.rs:226:5
+ --> $DIR/subdiagnostic-derive.rs:225:5
|
LL | #[label(code = "...")]
| ^^^^^^^^^^^^^^^^^^^^^^
error: the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan`
- --> $DIR/subdiagnostic-derive.rs:255:5
+ --> $DIR/subdiagnostic-derive.rs:254:5
|
LL | #[primary_span]
| ^^^^^^^^^^^^^^^
error: label without `#[primary_span]` field
- --> $DIR/subdiagnostic-derive.rs:252:1
+ --> $DIR/subdiagnostic-derive.rs:251:1
|
LL | / #[label(no_crate_example)]
LL | |
@@ -141,13 +141,13 @@ LL | | }
| |_^
error: `#[applicability]` is only valid on suggestions
- --> $DIR/subdiagnostic-derive.rs:265:5
+ --> $DIR/subdiagnostic-derive.rs:264:5
|
LL | #[applicability]
| ^^^^^^^^^^^^^^^^
error: `#[bar]` is not a valid attribute
- --> $DIR/subdiagnostic-derive.rs:275:5
+ --> $DIR/subdiagnostic-derive.rs:274:5
|
LL | #[bar]
| ^^^^^^
@@ -155,13 +155,13 @@ LL | #[bar]
= help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes
error: `#[bar = ...]` is not a valid attribute
- --> $DIR/subdiagnostic-derive.rs:286:5
+ --> $DIR/subdiagnostic-derive.rs:285:5
|
LL | #[bar = "..."]
| ^^^^^^^^^^^^^^
error: `#[bar(...)]` is not a valid attribute
- --> $DIR/subdiagnostic-derive.rs:297:5
+ --> $DIR/subdiagnostic-derive.rs:296:5
|
LL | #[bar("...")]
| ^^^^^^^^^^^^^
@@ -169,73 +169,73 @@ LL | #[bar("...")]
= help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes
error: a diagnostic slug must be the first argument to the attribute
- --> $DIR/subdiagnostic-derive.rs:329:44
+ --> $DIR/subdiagnostic-derive.rs:328:44
|
LL | #[label(no_crate_example, no_crate::example)]
| ^
error: specified multiple times
- --> $DIR/subdiagnostic-derive.rs:342:5
+ --> $DIR/subdiagnostic-derive.rs:341:5
|
LL | #[primary_span]
| ^^^^^^^^^^^^^^^
|
note: previously specified here
- --> $DIR/subdiagnostic-derive.rs:339:5
+ --> $DIR/subdiagnostic-derive.rs:338:5
|
LL | #[primary_span]
| ^^^^^^^^^^^^^^^
error: subdiagnostic kind not specified
- --> $DIR/subdiagnostic-derive.rs:348:8
+ --> $DIR/subdiagnostic-derive.rs:347:8
|
LL | struct AG {
| ^^
error: specified multiple times
- --> $DIR/subdiagnostic-derive.rs:385:46
+ --> $DIR/subdiagnostic-derive.rs:384:46
|
LL | #[suggestion(no_crate_example, code = "...", code = "...")]
| ^^^^
|
note: previously specified here
- --> $DIR/subdiagnostic-derive.rs:385:32
+ --> $DIR/subdiagnostic-derive.rs:384:32
|
LL | #[suggestion(no_crate_example, code = "...", code = "...")]
| ^^^^
error: specified multiple times
- --> $DIR/subdiagnostic-derive.rs:403:5
+ --> $DIR/subdiagnostic-derive.rs:402:5
|
LL | #[applicability]
| ^^^^^^^^^^^^^^^^
|
note: previously specified here
- --> $DIR/subdiagnostic-derive.rs:400: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:413:5
+ --> $DIR/subdiagnostic-derive.rs:412:5
|
LL | #[applicability]
| ^^^^^^^^^^^^^^^^
error: suggestion without `code = "..."`
- --> $DIR/subdiagnostic-derive.rs:426:1
+ --> $DIR/subdiagnostic-derive.rs:425:1
|
LL | #[suggestion(no_crate_example)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: invalid applicability
- --> $DIR/subdiagnostic-derive.rs:436: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:454:1
+ --> $DIR/subdiagnostic-derive.rs:453:1
|
LL | / #[suggestion(no_crate_example, code = "...")]
LL | |
@@ -245,25 +245,25 @@ LL | | }
| |_^
error: unsupported type attribute for subdiagnostic enum
- --> $DIR/subdiagnostic-derive.rs:468:1
+ --> $DIR/subdiagnostic-derive.rs:467:1
|
LL | #[label]
| ^^^^^^^^
error: `var` doesn't refer to a field on this type
- --> $DIR/subdiagnostic-derive.rs:488: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:507: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:530:5
+ --> $DIR/subdiagnostic-derive.rs:529:5
|
LL | #[suggestion_part]
| ^^^^^^^^^^^^^^^^^^
@@ -271,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:533:5
+ --> $DIR/subdiagnostic-derive.rs:532:5
|
LL | #[suggestion_part(code = "...")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -279,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:527:1
+ --> $DIR/subdiagnostic-derive.rs:526:1
|
LL | / #[suggestion(no_crate_example, code = "...")]
LL | |
@@ -291,7 +291,7 @@ LL | | }
| |_^
error: invalid nested attribute
- --> $DIR/subdiagnostic-derive.rs:542:42
+ --> $DIR/subdiagnostic-derive.rs:541:42
|
LL | #[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")]
| ^^^^
@@ -299,7 +299,7 @@ LL | #[multipart_suggestion(no_crate_example, code = "...", applicability = "mac
= help: only `no_span`, `style` and `applicability` are valid nested attributes
error: multipart suggestion without any `#[suggestion_part(...)]` fields
- --> $DIR/subdiagnostic-derive.rs:542:1
+ --> $DIR/subdiagnostic-derive.rs:541:1
|
LL | / #[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")]
LL | |
@@ -310,19 +310,19 @@ LL | | }
| |_^
error: `#[suggestion_part(...)]` attribute without `code = "..."`
- --> $DIR/subdiagnostic-derive.rs:552:5
+ --> $DIR/subdiagnostic-derive.rs:551:5
|
LL | #[suggestion_part]
| ^^^^^^^^^^^^^^^^^^
error: `#[suggestion_part(...)]` attribute without `code = "..."`
- --> $DIR/subdiagnostic-derive.rs:560:5
+ --> $DIR/subdiagnostic-derive.rs:559:5
|
LL | #[suggestion_part()]
| ^^^^^^^^^^^^^^^^^^^^
error: `#[primary_span]` is not a valid attribute
- --> $DIR/subdiagnostic-derive.rs:569:5
+ --> $DIR/subdiagnostic-derive.rs:568:5
|
LL | #[primary_span]
| ^^^^^^^^^^^^^^^
@@ -330,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:566:1
+ --> $DIR/subdiagnostic-derive.rs:565:1
|
LL | / #[multipart_suggestion(no_crate_example)]
LL | |
@@ -342,91 +342,91 @@ LL | | }
| |_^
error: `#[suggestion_part(...)]` attribute without `code = "..."`
- --> $DIR/subdiagnostic-derive.rs:577:5
+ --> $DIR/subdiagnostic-derive.rs:576:5
|
LL | #[suggestion_part]
| ^^^^^^^^^^^^^^^^^^
error: `#[suggestion_part(...)]` attribute without `code = "..."`
- --> $DIR/subdiagnostic-derive.rs:580:5
+ --> $DIR/subdiagnostic-derive.rs:579:5
|
LL | #[suggestion_part()]
| ^^^^^^^^^^^^^^^^^^^^
error: `code` is the only valid nested attribute
- --> $DIR/subdiagnostic-derive.rs:583: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:588: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:591:5
+ --> $DIR/subdiagnostic-derive.rs:590:5
|
LL | #[suggestion_part()]
| ^^^^^^^^^^^^^^^^^^^^
error: specified multiple times
- --> $DIR/subdiagnostic-derive.rs:599:37
+ --> $DIR/subdiagnostic-derive.rs:598:37
|
LL | #[suggestion_part(code = "...", code = ",,,")]
| ^^^^
|
note: previously specified here
- --> $DIR/subdiagnostic-derive.rs:599: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:628:5
+ --> $DIR/subdiagnostic-derive.rs:627:5
|
LL | #[applicability]
| ^^^^^^^^^^^^^^^^
error: expected exactly one string literal for `code = ...`
- --> $DIR/subdiagnostic-derive.rs:676:34
+ --> $DIR/subdiagnostic-derive.rs:675:34
|
LL | #[suggestion_part(code("foo"))]
| ^
error: expected exactly one string literal for `code = ...`
- --> $DIR/subdiagnostic-derive.rs:687:41
+ --> $DIR/subdiagnostic-derive.rs:686:41
|
LL | #[suggestion_part(code("foo", "bar"))]
| ^
error: expected exactly one string literal for `code = ...`
- --> $DIR/subdiagnostic-derive.rs:698:30
+ --> $DIR/subdiagnostic-derive.rs:697:30
|
LL | #[suggestion_part(code(3))]
| ^
error: expected exactly one string literal for `code = ...`
- --> $DIR/subdiagnostic-derive.rs:709:29
+ --> $DIR/subdiagnostic-derive.rs:708:29
|
LL | #[suggestion_part(code())]
| ^
error: specified multiple times
- --> $DIR/subdiagnostic-derive.rs:764: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:764: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:773:1
+ --> $DIR/subdiagnostic-derive.rs:772:1
|
LL | #[suggestion_hidden(no_crate_example, code = "")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -434,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:781:1
+ --> $DIR/subdiagnostic-derive.rs:780:1
|
LL | #[suggestion_hidden(no_crate_example, code = "", style = "normal")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -442,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:789:51
+ --> $DIR/subdiagnostic-derive.rs:788:51
|
LL | #[suggestion(no_crate_example, code = "", style = "foo")]
| ^^^^^
@@ -450,25 +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:797: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:805:48
+ --> $DIR/subdiagnostic-derive.rs:804:48
|
LL | #[suggestion(no_crate_example, code = "", style)]
| ^
error: expected `= "xxx"`
- --> $DIR/subdiagnostic-derive.rs:813: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:826:5
+ --> $DIR/subdiagnostic-derive.rs:825:5
|
LL | #[primary_span]
| ^^^^^^^^^^^^^^^
@@ -477,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:823:1
+ --> $DIR/subdiagnostic-derive.rs:822:1
|
LL | / #[suggestion(no_crate_example, code = "")]
LL | |
@@ -489,115 +489,115 @@ LL | | }
| |_^
error[E0433]: failed to resolve: maybe a missing crate `core`?
- --> $DIR/subdiagnostic-derive.rs:97:9
+ --> $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:313:1
+ --> $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:583:27
+ --> $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:676:28
+ --> $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:687:28
+ --> $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:698:28
+ --> $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:721:30
+ --> $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:813:48
+ --> $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]
| ^^^
error: cannot find attribute `foo` in this scope
- --> $DIR/subdiagnostic-derive.rs:164:3
+ --> $DIR/subdiagnostic-derive.rs:163:3
|
LL | #[foo]
| ^^^
error: cannot find attribute `bar` in this scope
- --> $DIR/subdiagnostic-derive.rs:178:7
+ --> $DIR/subdiagnostic-derive.rs:177:7
|
LL | #[bar]
| ^^^
error: cannot find attribute `bar` in this scope
- --> $DIR/subdiagnostic-derive.rs:190:7
+ --> $DIR/subdiagnostic-derive.rs:189:7
|
LL | #[bar = "..."]
| ^^^
error: cannot find attribute `bar` in this scope
- --> $DIR/subdiagnostic-derive.rs:202:7
+ --> $DIR/subdiagnostic-derive.rs:201:7
|
LL | #[bar = 4]
| ^^^
error: cannot find attribute `bar` in this scope
- --> $DIR/subdiagnostic-derive.rs:214:7
+ --> $DIR/subdiagnostic-derive.rs:213:7
|
LL | #[bar("...")]
| ^^^
error: cannot find attribute `bar` in this scope
- --> $DIR/subdiagnostic-derive.rs:275:7
+ --> $DIR/subdiagnostic-derive.rs:274:7
|
LL | #[bar]
| ^^^
error: cannot find attribute `bar` in this scope
- --> $DIR/subdiagnostic-derive.rs:286:7
+ --> $DIR/subdiagnostic-derive.rs:285:7
|
LL | #[bar = "..."]
| ^^^
error: cannot find attribute `bar` in this scope
- --> $DIR/subdiagnostic-derive.rs:297:7
+ --> $DIR/subdiagnostic-derive.rs:296:7
|
LL | #[bar("...")]
| ^^^
error[E0425]: cannot find value `slug` in module `crate::fluent_generated`
- --> $DIR/subdiagnostic-derive.rs:127:9
+ --> $DIR/subdiagnostic-derive.rs:126:9
|
LL | #[label(slug)]
| ^^^^ not found in `crate::fluent_generated`
error[E0425]: cannot find value `__code_29` in this scope
- --> $DIR/subdiagnostic-derive.rs:715:10
+ --> $DIR/subdiagnostic-derive.rs:714:10
|
LL | #[derive(Subdiagnostic)]
| ^^^^^^^^^^^^^ not found in this scope
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
index a34087775..5cb07eabf 100644
--- a/tests/ui-fulldeps/stable-mir/check_instance.rs
+++ b/tests/ui-fulldeps/stable-mir/check_instance.rs
@@ -49,7 +49,7 @@ fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> {
assert!(generic.iter().all(|item| mir::mono::Instance::try_from(*item).is_err()));
for instance in instances {
- test_body(instance.body())
+ test_body(instance.body().unwrap())
}
ControlFlow::Continue(())
}
@@ -59,10 +59,17 @@ 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()).kind() else { unreachable!() };
+ let TyKind::RigidTy(ty) = func.ty(body.locals()).unwrap().kind() else { unreachable!
+ () };
let RigidTy::FnDef(def, args) = ty else { unreachable!() };
- let result = Instance::resolve(def, &args);
- assert!(result.is_ok());
+ 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 */
@@ -105,10 +112,16 @@ fn generate_input(path: &str) -> std::io::Result<()> {
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 {{
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/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs
index ed6b786f5..c2035430a 100644
--- a/tests/ui-fulldeps/stable-mir/crate-info.rs
+++ b/tests/ui-fulldeps/stable-mir/crate-info.rs
@@ -22,6 +22,8 @@ extern crate stable_mir;
use rustc_hir::def::DefKind;
use rustc_middle::ty::TyCtxt;
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;
@@ -120,13 +122,14 @@ fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> {
let monomorphic = get_item(&items, (DefKind::Fn, "monomorphic")).unwrap();
let instance = Instance::try_from(monomorphic.clone()).unwrap();
- for block in instance.body().blocks {
+ 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()).kind() else { unreachable!() };
+ 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().locals()[1].ty.kind() {
+ match next_func.body().unwrap().locals()[1].ty.kind() {
TyKind::RigidTy(RigidTy::Uint(_)) | TyKind::RigidTy(RigidTy::Tuple(_)) => {}
other => panic!("{other:?}"),
}
@@ -172,7 +175,8 @@ fn get_item<'a>(
item: (DefKind, &str),
) -> Option<&'a stable_mir::CrateItem> {
items.iter().find(|crate_item| {
- crate_item.kind().to_string() == format!("{:?}", item.0) && crate_item.name() == item.1
+ matches!((item.0, crate_item.kind()), (DefKind::Fn, ItemKind::Fn) | (DefKind::Const,
+ ItemKind::Const)) && crate_item.name() == item.1
})
}
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_visitor.rs b/tests/ui-fulldeps/stable-mir/smir_visitor.rs
index de5148bb5..027b0e7d9 100644
--- a/tests/ui-fulldeps/stable-mir/smir_visitor.rs
+++ b/tests/ui-fulldeps/stable-mir/smir_visitor.rs
@@ -40,7 +40,7 @@ fn test_visitor(_tcx: TyCtxt<'_>) -> ControlFlow<()> {
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();
+ 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);
@@ -92,7 +92,8 @@ impl<'a> mir::MirVisitor for TestVisitor<'a> {
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()).kind() else { unreachable!
+ 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());