Auto merge of #139154 - jhpratt:rollup-rv8f915, r=jhpratt
Rollup of 5 pull requests Successful merges: - #139044 (bootstrap: Avoid cloning `change-id` list) - #139111 (Properly document FakeReads) - #139122 (Remove attribute `#[rustc_error]`) - #139132 (Improve hir_pretty for struct expressions.) - #139141 (Switch some rustc_on_unimplemented uses to diagnostic::on_unimplemented) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
3c0f72271b
57 changed files with 228 additions and 302 deletions
|
@ -1087,9 +1087,9 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
WarnFollowing, EncodeCrossCrate::No
|
||||
),
|
||||
rustc_attr!(
|
||||
TEST, rustc_error, Normal,
|
||||
template!(Word, List: "delayed_bug_from_inside_query"),
|
||||
WarnFollowingWordOnly, EncodeCrossCrate::Yes
|
||||
TEST, rustc_delayed_bug_from_inside_query, Normal,
|
||||
template!(Word),
|
||||
WarnFollowing, EncodeCrossCrate::No
|
||||
),
|
||||
rustc_attr!(
|
||||
TEST, rustc_dump_user_args, Normal, template!(Word),
|
||||
|
|
|
@ -1193,7 +1193,8 @@ impl<'a> State<'a> {
|
|||
wth: hir::StructTailExpr<'_>,
|
||||
) {
|
||||
self.print_qpath(qpath, true);
|
||||
self.word("{");
|
||||
self.nbsp();
|
||||
self.word_space("{");
|
||||
self.commasep_cmnt(Consistent, fields, |s, field| s.print_expr_field(field), |f| f.span);
|
||||
match wth {
|
||||
hir::StructTailExpr::Base(expr) => {
|
||||
|
@ -1215,20 +1216,13 @@ impl<'a> State<'a> {
|
|||
self.word("..");
|
||||
self.end();
|
||||
}
|
||||
hir::StructTailExpr::None => {
|
||||
if !fields.is_empty() {
|
||||
self.word(",");
|
||||
hir::StructTailExpr::None => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.space();
|
||||
self.word("}");
|
||||
}
|
||||
|
||||
fn print_expr_field(&mut self, field: &hir::ExprField<'_>) {
|
||||
if self.attrs(field.hir_id).is_empty() {
|
||||
self.space();
|
||||
}
|
||||
self.cbox(INDENT_UNIT);
|
||||
self.print_attrs_as_outer(self.attrs(field.hir_id));
|
||||
if !field.is_shorthand {
|
||||
|
|
|
@ -50,11 +50,5 @@ interface_out_dir_error =
|
|||
interface_proc_macro_crate_panic_abort =
|
||||
building proc macro crate with `panic=abort` may crash the compiler should the proc-macro panic
|
||||
|
||||
interface_rustc_error_fatal =
|
||||
fatal error triggered by #[rustc_error]
|
||||
|
||||
interface_rustc_error_unexpected_annotation =
|
||||
unexpected annotation used with `#[rustc_error(...)]`!
|
||||
|
||||
interface_temps_dir_error =
|
||||
failed to find or create the directory specified by `--temps-dir`
|
||||
|
|
|
@ -73,20 +73,6 @@ pub struct TempsDirError;
|
|||
#[diag(interface_out_dir_error)]
|
||||
pub struct OutDirError;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_rustc_error_fatal)]
|
||||
pub struct RustcErrorFatal {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_rustc_error_unexpected_annotation)]
|
||||
pub struct RustcErrorUnexpectedAnnotation {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_failed_writing_file)]
|
||||
pub struct FailedWritingFile<'a> {
|
||||
|
|
|
@ -1067,48 +1067,18 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) {
|
|||
});
|
||||
}
|
||||
|
||||
/// Check for the `#[rustc_error]` annotation, which forces an error in codegen. This is used
|
||||
/// to write UI tests that actually test that compilation succeeds without reporting
|
||||
/// an error.
|
||||
fn check_for_rustc_errors_attr(tcx: TyCtxt<'_>) {
|
||||
let Some((def_id, _)) = tcx.entry_fn(()) else { return };
|
||||
for attr in tcx.get_attrs(def_id, sym::rustc_error) {
|
||||
match attr.meta_item_list() {
|
||||
// Check if there is a `#[rustc_error(delayed_bug_from_inside_query)]`.
|
||||
Some(list)
|
||||
if list.iter().any(|list_item| {
|
||||
matches!(
|
||||
list_item.ident().map(|i| i.name),
|
||||
Some(sym::delayed_bug_from_inside_query)
|
||||
)
|
||||
}) =>
|
||||
{
|
||||
tcx.ensure_ok().trigger_delayed_bug(def_id);
|
||||
}
|
||||
|
||||
// Bare `#[rustc_error]`.
|
||||
None => {
|
||||
tcx.dcx().emit_fatal(errors::RustcErrorFatal { span: tcx.def_span(def_id) });
|
||||
}
|
||||
|
||||
// Some other attribute.
|
||||
Some(_) => {
|
||||
tcx.dcx().emit_warn(errors::RustcErrorUnexpectedAnnotation {
|
||||
span: tcx.def_span(def_id),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Runs the codegen backend, after which the AST and analysis can
|
||||
/// be discarded.
|
||||
pub(crate) fn start_codegen<'tcx>(
|
||||
codegen_backend: &dyn CodegenBackend,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> Box<dyn Any> {
|
||||
// Hook for UI tests.
|
||||
check_for_rustc_errors_attr(tcx);
|
||||
// Hook for tests.
|
||||
if let Some((def_id, _)) = tcx.entry_fn(())
|
||||
&& tcx.has_attr(def_id, sym::rustc_delayed_bug_from_inside_query)
|
||||
{
|
||||
tcx.ensure_ok().trigger_delayed_bug(def_id);
|
||||
}
|
||||
|
||||
// Don't run this test assertions when not doing codegen. Compiletest tries to build
|
||||
// build-fail tests in check mode first and expects it to not give an error in that case.
|
||||
|
|
|
@ -334,14 +334,19 @@ pub enum StatementKind<'tcx> {
|
|||
/// See [`Rvalue`] documentation for details on each of those.
|
||||
Assign(Box<(Place<'tcx>, Rvalue<'tcx>)>),
|
||||
|
||||
/// This represents all the reading that a pattern match may do (e.g., inspecting constants and
|
||||
/// discriminant values), and the kind of pattern it comes from. This is in order to adapt
|
||||
/// potential error messages to these specific patterns.
|
||||
/// When executed at runtime, this is a nop.
|
||||
///
|
||||
/// Note that this also is emitted for regular `let` bindings to ensure that locals that are
|
||||
/// never accessed still get some sanity checks for, e.g., `let x: ! = ..;`
|
||||
/// During static analysis, a fake read:
|
||||
/// - requires that the value being read is initialized (or, in the case
|
||||
/// of closures, that it was fully initialized at some point in the past)
|
||||
/// - constitutes a use of a value for the purposes of NLL (i.e. if the
|
||||
/// value being fake-read is a reference, the lifetime of that reference
|
||||
/// will be extended to cover the `FakeRead`)
|
||||
/// - but, unlike an actual read, does *not* invalidate any exclusive
|
||||
/// borrows.
|
||||
///
|
||||
/// When executed at runtime this is a nop.
|
||||
/// See [`FakeReadCause`] for more details on the situations in which a
|
||||
/// `FakeRead` is emitted.
|
||||
///
|
||||
/// Disallowed after drop elaboration.
|
||||
FakeRead(Box<(FakeReadCause, Place<'tcx>)>),
|
||||
|
@ -518,28 +523,59 @@ pub enum RetagKind {
|
|||
/// The `FakeReadCause` describes the type of pattern why a FakeRead statement exists.
|
||||
#[derive(Copy, Clone, TyEncodable, TyDecodable, Debug, Hash, HashStable, PartialEq)]
|
||||
pub enum FakeReadCause {
|
||||
/// Inject a fake read of the borrowed input at the end of each guards
|
||||
/// code.
|
||||
/// A fake read injected into a match guard to ensure that the discriminants
|
||||
/// that are being matched on aren't modified while the match guard is being
|
||||
/// evaluated.
|
||||
///
|
||||
/// At the beginning of each match guard, a [fake borrow][FakeBorrowKind] is
|
||||
/// inserted for each discriminant accessed in the entire `match` statement.
|
||||
///
|
||||
/// Then, at the end of the match guard, a `FakeRead(ForMatchGuard)` is
|
||||
/// inserted to keep the fake borrows alive until that point.
|
||||
///
|
||||
/// This should ensure that you cannot change the variant for an enum while
|
||||
/// you are in the midst of matching on it.
|
||||
ForMatchGuard,
|
||||
|
||||
/// `let x: !; match x {}` doesn't generate any read of x so we need to
|
||||
/// generate a read of x to check that it is initialized and safe.
|
||||
/// Fake read of the scrutinee of a `match` or destructuring `let`
|
||||
/// (i.e. `let` with non-trivial pattern).
|
||||
///
|
||||
/// If a closure pattern matches a Place starting with an Upvar, then we introduce a
|
||||
/// FakeRead for that Place outside the closure, in such a case this option would be
|
||||
/// Some(closure_def_id).
|
||||
/// Otherwise, the value of the optional LocalDefId will be None.
|
||||
/// In `match x { ... }`, we generate a `FakeRead(ForMatchedPlace, x)`
|
||||
/// and insert it into the `otherwise_block` (which is supposed to be
|
||||
/// unreachable for irrefutable pattern-matches like `match` or `let`).
|
||||
///
|
||||
/// This is necessary because `let x: !; match x {}` doesn't generate any
|
||||
/// actual read of x, so we need to generate a `FakeRead` to check that it
|
||||
/// is initialized.
|
||||
///
|
||||
/// If the `FakeRead(ForMatchedPlace)` is being performed with a closure
|
||||
/// that doesn't capture the required upvars, the `FakeRead` within the
|
||||
/// closure is omitted entirely.
|
||||
///
|
||||
/// To make sure that this is still sound, if a closure matches against
|
||||
/// a Place starting with an Upvar, we hoist the `FakeRead` to the
|
||||
/// definition point of the closure.
|
||||
///
|
||||
/// If the `FakeRead` comes from being hoisted out of a closure like this,
|
||||
/// we record the `LocalDefId` of the closure. Otherwise, the `Option` will be `None`.
|
||||
//
|
||||
// We can use LocalDefId here since fake read statements are removed
|
||||
// before codegen in the `CleanupNonCodegenStatements` pass.
|
||||
ForMatchedPlace(Option<LocalDefId>),
|
||||
|
||||
/// A fake read of the RefWithinGuard version of a bind-by-value variable
|
||||
/// in a match guard to ensure that its value hasn't change by the time
|
||||
/// we create the OutsideGuard version.
|
||||
/// A fake read injected into a match guard to ensure that the places
|
||||
/// bound by the pattern are immutable for the duration of the match guard.
|
||||
///
|
||||
/// Within a match guard, references are created for each place that the
|
||||
/// pattern creates a binding for — this is known as the `RefWithinGuard`
|
||||
/// version of the variables. To make sure that the references stay
|
||||
/// alive until the end of the match guard, and properly prevent the
|
||||
/// places in question from being modified, a `FakeRead(ForGuardBinding)`
|
||||
/// is inserted at the end of the match guard.
|
||||
///
|
||||
/// For details on how these references are created, see the extensive
|
||||
/// documentation on `bind_matched_candidate_for_guard` in
|
||||
/// `rustc_mir_build`.
|
||||
ForGuardBinding,
|
||||
|
||||
/// Officially, the semantics of
|
||||
|
@ -552,22 +588,42 @@ pub enum FakeReadCause {
|
|||
/// However, if we see the simple pattern `let var = <expr>`, we optimize this to
|
||||
/// evaluate `<expr>` directly into the variable `var`. This is mostly unobservable,
|
||||
/// but in some cases it can affect the borrow checker, as in #53695.
|
||||
/// Therefore, we insert a "fake read" here to ensure that we get
|
||||
/// appropriate errors.
|
||||
///
|
||||
/// If a closure pattern matches a Place starting with an Upvar, then we introduce a
|
||||
/// FakeRead for that Place outside the closure, in such a case this option would be
|
||||
/// Some(closure_def_id).
|
||||
/// Otherwise, the value of the optional DefId will be None.
|
||||
/// Therefore, we insert a `FakeRead(ForLet)` immediately after each `let`
|
||||
/// with a trivial pattern.
|
||||
///
|
||||
/// FIXME: `ExprUseVisitor` has an entirely different opinion on what `FakeRead(ForLet)`
|
||||
/// is supposed to mean. If it was accurate to what MIR lowering does,
|
||||
/// would it even make sense to hoist these out of closures like
|
||||
/// `ForMatchedPlace`?
|
||||
ForLet(Option<LocalDefId>),
|
||||
|
||||
/// If we have an index expression like
|
||||
/// Currently, index expressions overloaded through the `Index` trait
|
||||
/// get lowered differently than index expressions with builtin semantics
|
||||
/// for arrays and slices — the latter will emit code to perform
|
||||
/// bound checks, and then return a MIR place that will only perform the
|
||||
/// indexing "for real" when it gets incorporated into an instruction.
|
||||
///
|
||||
/// (*x)[1][{ x = y; 4}]
|
||||
/// This is observable in the fact that the following compiles:
|
||||
///
|
||||
/// then the first bounds check is invalidated when we evaluate the second
|
||||
/// index expression. Thus we create a fake borrow of `x` across the second
|
||||
/// indexer, which will cause a borrow check error.
|
||||
/// ```
|
||||
/// fn f(x: &mut [&mut [u32]], i: usize) {
|
||||
/// x[i][x[i].len() - 1] += 1;
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// However, we need to be careful to not let the user invalidate the
|
||||
/// bound check with an expression like
|
||||
///
|
||||
/// `(*x)[1][{ x = y; 4}]`
|
||||
///
|
||||
/// Here, the first bounds check would be invalidated when we evaluate the
|
||||
/// second index expression. To make sure that this doesn't happen, we
|
||||
/// create a fake borrow of `x` and hold it while we evaluate the second
|
||||
/// index.
|
||||
///
|
||||
/// This borrow is kept alive by a `FakeRead(ForIndex)` at the end of its
|
||||
/// scope.
|
||||
ForIndex,
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ fn opt_span_bug_fmt<S: Into<MultiSpan>>(
|
|||
pub fn trigger_delayed_bug(tcx: TyCtxt<'_>, key: rustc_hir::def_id::DefId) {
|
||||
tcx.dcx().span_delayed_bug(
|
||||
tcx.def_span(key),
|
||||
"delayed bug triggered by #[rustc_error(delayed_bug_from_inside_query)]",
|
||||
"delayed bug triggered by #[rustc_delayed_bug_from_inside_query]",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1774,6 +1774,7 @@ symbols! {
|
|||
rustc_deallocator,
|
||||
rustc_def_path,
|
||||
rustc_default_body_unstable,
|
||||
rustc_delayed_bug_from_inside_query,
|
||||
rustc_deny_explicit_impl,
|
||||
rustc_deprecated_safe_2024,
|
||||
rustc_diagnostic_item,
|
||||
|
@ -1790,7 +1791,6 @@ symbols! {
|
|||
rustc_dump_user_args,
|
||||
rustc_dump_vtable,
|
||||
rustc_effective_visibility,
|
||||
rustc_error,
|
||||
rustc_evaluate_where_clauses,
|
||||
rustc_expected_cgu_reuse,
|
||||
rustc_force_inline,
|
||||
|
|
|
@ -3360,10 +3360,6 @@ impl<T: Hash, A: Allocator> Hash for Vec<T, A> {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_on_unimplemented(
|
||||
message = "vector indices are of type `usize` or ranges of `usize`",
|
||||
label = "vector indices are of type `usize` or ranges of `usize`"
|
||||
)]
|
||||
impl<T, I: SliceIndex<[T]>, A: Allocator> Index<I> for Vec<T, A> {
|
||||
type Output = I::Output;
|
||||
|
||||
|
@ -3374,10 +3370,6 @@ impl<T, I: SliceIndex<[T]>, A: Allocator> Index<I> for Vec<T, A> {
|
|||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_on_unimplemented(
|
||||
message = "vector indices are of type `usize` or ranges of `usize`",
|
||||
label = "vector indices are of type `usize` or ranges of `usize`"
|
||||
)]
|
||||
impl<T, I: SliceIndex<[T]>, A: Allocator> IndexMut<I> for Vec<T, A> {
|
||||
#[inline]
|
||||
fn index_mut(&mut self, index: I) -> &mut Self::Output {
|
||||
|
|
|
@ -10,7 +10,7 @@ use crate::num::Wrapping;
|
|||
/// [`sum()`]: Iterator::sum
|
||||
/// [`FromIterator`]: iter::FromIterator
|
||||
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
|
||||
#[rustc_on_unimplemented(
|
||||
#[diagnostic::on_unimplemented(
|
||||
message = "a value of type `{Self}` cannot be made by summing an iterator over elements of type `{A}`",
|
||||
label = "value of type `{Self}` cannot be made by summing a `std::iter::Iterator<Item={A}>`"
|
||||
)]
|
||||
|
@ -31,7 +31,7 @@ pub trait Sum<A = Self>: Sized {
|
|||
/// [`product()`]: Iterator::product
|
||||
/// [`FromIterator`]: iter::FromIterator
|
||||
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
|
||||
#[rustc_on_unimplemented(
|
||||
#[diagnostic::on_unimplemented(
|
||||
message = "a value of type `{Self}` cannot be made by multiplying all elements of type `{A}` from an iterator",
|
||||
label = "value of type `{Self}` cannot be made by multiplying all elements from a `std::iter::Iterator<Item={A}>`"
|
||||
)]
|
||||
|
|
|
@ -191,7 +191,7 @@ fn check_version(config: &Config) -> Option<String> {
|
|||
}
|
||||
|
||||
msg.push_str("There have been changes to x.py since you last updated:\n");
|
||||
msg.push_str(&human_readable_changes(&changes));
|
||||
msg.push_str(&human_readable_changes(changes));
|
||||
|
||||
msg.push_str("NOTE: to silence this warning, ");
|
||||
msg.push_str(&format!(
|
||||
|
|
|
@ -1381,7 +1381,7 @@ impl Config {
|
|||
if !changes.is_empty() {
|
||||
println!(
|
||||
"WARNING: There have been changes to x.py since you last updated:\n{}",
|
||||
crate::human_readable_changes(&changes)
|
||||
crate::human_readable_changes(changes)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,29 +35,25 @@ impl Display for ChangeSeverity {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn find_recent_config_change_ids(current_id: usize) -> Vec<ChangeInfo> {
|
||||
if !CONFIG_CHANGE_HISTORY.iter().any(|config| config.change_id == current_id) {
|
||||
pub fn find_recent_config_change_ids(current_id: usize) -> &'static [ChangeInfo] {
|
||||
if let Some(index) =
|
||||
CONFIG_CHANGE_HISTORY.iter().position(|config| config.change_id == current_id)
|
||||
{
|
||||
// Skip the current_id and IDs before it
|
||||
&CONFIG_CHANGE_HISTORY[index + 1..]
|
||||
} else {
|
||||
// If the current change-id is greater than the most recent one, return
|
||||
// an empty list (it may be due to switching from a recent branch to an
|
||||
// older one); otherwise, return the full list (assuming the user provided
|
||||
// the incorrect change-id by accident).
|
||||
if let Some(config) = CONFIG_CHANGE_HISTORY.iter().max_by_key(|config| config.change_id) {
|
||||
if current_id > config.change_id {
|
||||
return Vec::new();
|
||||
return &[];
|
||||
}
|
||||
}
|
||||
|
||||
return CONFIG_CHANGE_HISTORY.to_vec();
|
||||
}
|
||||
|
||||
let index =
|
||||
CONFIG_CHANGE_HISTORY.iter().position(|config| config.change_id == current_id).unwrap();
|
||||
|
||||
CONFIG_CHANGE_HISTORY
|
||||
.iter()
|
||||
.skip(index + 1) // Skip the current_id and IDs before it
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn human_readable_changes(changes: &[ChangeInfo]) -> String {
|
||||
|
|
|
@ -665,10 +665,6 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
rustc_attr!(TEST, rustc_layout, Normal, template!(List: "field1, field2, ..."), WarnFollowing),
|
||||
rustc_attr!(TEST, rustc_abi, Normal, template!(List: "field1, field2, ..."), WarnFollowing),
|
||||
rustc_attr!(TEST, rustc_regions, Normal, template!(Word), WarnFollowing),
|
||||
rustc_attr!(
|
||||
TEST, rustc_error, Normal,
|
||||
template!(Word, List: "delayed_bug_from_inside_query"), WarnFollowingWordOnly
|
||||
),
|
||||
rustc_attr!(TEST, rustc_dump_user_args, Normal, template!(Word), WarnFollowing),
|
||||
rustc_attr!(TEST, rustc_evaluate_where_clauses, Normal, template!(Word), WarnFollowing),
|
||||
rustc_attr!(
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//@ revisions: cfail1 cfail2
|
||||
//@ should-ice
|
||||
//@ error-pattern: delayed bug triggered by #[rustc_error(delayed_bug_from_inside_query)]
|
||||
//@ error-pattern: delayed bug triggered by #[rustc_delayed_bug_from_inside_query]
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_error(delayed_bug_from_inside_query)]
|
||||
#[rustc_delayed_bug_from_inside_query]
|
||||
fn main() {}
|
||||
|
|
|
@ -30,10 +30,10 @@ impl Foo<'_> {
|
|||
|
||||
// FIXME: impl Traits printed as just `/*impl Trait*/`, ugh
|
||||
fn iter1<'a>(&self)
|
||||
-> /*impl Trait*/ { #[lang = "Range"]{ start: 0, end: 1,} }
|
||||
-> /*impl Trait*/ { #[lang = "Range"] { start: 0, end: 1 } }
|
||||
|
||||
fn iter2(&self)
|
||||
-> /*impl Trait*/ { #[lang = "Range"]{ start: 0, end: 1,} }
|
||||
-> /*impl Trait*/ { #[lang = "Range"] { start: 0, end: 1 } }
|
||||
}
|
||||
|
||||
fn a(x: Foo<'_>) { }
|
||||
|
@ -82,7 +82,7 @@ struct St<'a> {
|
|||
x: &'a u32,
|
||||
}
|
||||
|
||||
fn f() { { let _ = St{ x: &0,}; }; { let _ = St{ x: &0,}; }; }
|
||||
fn f() { { let _ = St { x: &0 }; }; { let _ = St { x: &0 }; }; }
|
||||
|
||||
struct Name<'a>(&'a str);
|
||||
|
||||
|
|
28
tests/pretty/hir-struct-expr.pp
Normal file
28
tests/pretty/hir-struct-expr.pp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#[prelude_import]
|
||||
use ::std::prelude::rust_2015::*;
|
||||
#[macro_use]
|
||||
extern crate std;
|
||||
//@ pretty-compare-only
|
||||
//@ pretty-mode:hir
|
||||
//@ pp-exact:hir-struct-expr.pp
|
||||
|
||||
struct StructWithSomeFields {
|
||||
field_1: i32,
|
||||
field_2: i32,
|
||||
field_3: i32,
|
||||
field_4: i32,
|
||||
field_5: i32,
|
||||
field_6: i32,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let a =
|
||||
StructWithSomeFields {
|
||||
field_1: 1,
|
||||
field_2: 2,
|
||||
field_3: 3,
|
||||
field_4: 4,
|
||||
field_5: 5,
|
||||
field_6: 6 };
|
||||
let a = StructWithSomeFields { field_1: 1, field_2: 2, ..a };
|
||||
}
|
24
tests/pretty/hir-struct-expr.rs
Normal file
24
tests/pretty/hir-struct-expr.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
//@ pretty-compare-only
|
||||
//@ pretty-mode:hir
|
||||
//@ pp-exact:hir-struct-expr.pp
|
||||
|
||||
struct StructWithSomeFields {
|
||||
field_1: i32,
|
||||
field_2: i32,
|
||||
field_3: i32,
|
||||
field_4: i32,
|
||||
field_5: i32,
|
||||
field_6: i32,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let a = StructWithSomeFields {
|
||||
field_1: 1,
|
||||
field_2: 2,
|
||||
field_3: 3,
|
||||
field_4: 4,
|
||||
field_5: 5,
|
||||
field_6: 6,
|
||||
};
|
||||
let a = StructWithSomeFields { field_1: 1, field_2: 2, ..a };
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
error: fatal error triggered by #[rustc_error]
|
||||
--> $DIR/bound-lifetime-constrained.rs:48:1
|
||||
|
|
||||
LL | fn main() { }
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
//@ revisions: func object clause ok
|
||||
//@[ok] check-pass
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
trait Foo<'a> {
|
||||
type Item;
|
||||
|
@ -44,5 +44,4 @@ fn clause2<T>() where T: for<'a> Fn() -> <() as Foo<'a>>::Item {
|
|||
//[clause]~^ ERROR `Output` references lifetime `'a`
|
||||
}
|
||||
|
||||
#[rustc_error]
|
||||
fn main() { } //[ok]~ ERROR fatal error triggered by #[rustc_error]
|
||||
fn main() { }
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
error: fatal error triggered by #[rustc_error]
|
||||
--> $DIR/bound-lifetime-in-binding-only.rs:71:1
|
||||
|
|
||||
LL | fn main() { }
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
//@ revisions: angle paren ok elision
|
||||
//@[ok] check-pass
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(unboxed_closures)]
|
||||
|
||||
trait Foo {
|
||||
|
@ -67,5 +67,4 @@ fn ok2<T: for<'a,'b> Fn<(&'b Parameterized<'a>,), Output=&'a i32>>() {
|
|||
fn ok3<T>() where for<'a> Parameterized<'a>: Foo<Item=&'a i32> {
|
||||
}
|
||||
|
||||
#[rustc_error]
|
||||
fn main() { } //[ok]~ ERROR fatal error triggered by #[rustc_error]
|
||||
fn main() { }
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
error: fatal error triggered by #[rustc_error]
|
||||
--> $DIR/bound-lifetime-in-return-only.rs:49:1
|
||||
|
|
||||
LL | fn main() { }
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
//@ revisions: sig local structure ok elision
|
||||
//@[ok] check-pass
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(unboxed_closures)]
|
||||
|
||||
trait Foo {
|
||||
|
@ -45,5 +45,4 @@ fn ok1(_: &dyn for<'a> Fn(&Parameterized<'a>) -> &'a i32) {
|
|||
fn ok2(_: &dyn for<'a,'b> Fn<(&'b Parameterized<'a>,), Output=&'a i32>) {
|
||||
}
|
||||
|
||||
#[rustc_error]
|
||||
fn main() { } //[ok]~ ERROR fatal error triggered by #[rustc_error]
|
||||
fn main() { }
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#![feature(rustc_attrs)]
|
||||
#![allow(dead_code)]
|
||||
fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
fn main() {
|
||||
// Original borrow ends at end of function
|
||||
let mut x = 1;
|
||||
let y = &mut x;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-report-with-custom-diagnostic.rs:8:13
|
||||
--> $DIR/borrowck-report-with-custom-diagnostic.rs:7:13
|
||||
|
|
||||
LL | let y = &mut x;
|
||||
| ------ mutable borrow occurs here
|
||||
|
@ -11,7 +11,7 @@ LL | y.use_mut();
|
|||
| - mutable borrow later used here
|
||||
|
||||
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-report-with-custom-diagnostic.rs:21:21
|
||||
--> $DIR/borrowck-report-with-custom-diagnostic.rs:20:21
|
||||
|
|
||||
LL | let y = &x;
|
||||
| -- immutable borrow occurs here
|
||||
|
@ -23,7 +23,7 @@ LL | y.use_ref();
|
|||
| - immutable borrow later used here
|
||||
|
||||
error[E0499]: cannot borrow `x` as mutable more than once at a time
|
||||
--> $DIR/borrowck-report-with-custom-diagnostic.rs:36:17
|
||||
--> $DIR/borrowck-report-with-custom-diagnostic.rs:35:17
|
||||
|
|
||||
LL | let y = &mut x;
|
||||
| ------ first mutable borrow occurs here
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// ensure borrowck messages are correct outside special case
|
||||
#![feature(rustc_attrs)]
|
||||
fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
|
||||
fn main() {
|
||||
let mut void = ();
|
||||
|
||||
let first = &mut void;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#![feature(rustc_attrs)]
|
||||
fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
fn main() {
|
||||
let mut x = "foo";
|
||||
let y = &mut x;
|
||||
let z = &mut x; //~ ERROR cannot borrow
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0499]: cannot borrow `x` as mutable more than once at a time
|
||||
--> $DIR/issue-11715.rs:5:13
|
||||
--> $DIR/issue-11715.rs:4:13
|
||||
|
|
||||
LL | let y = &mut x;
|
||||
| ------ first mutable borrow occurs here
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
//@ edition:2018
|
||||
//@ revisions: with_feature without_feature
|
||||
//@[with_feature] check-pass
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
#![cfg_attr(with_feature, feature(const_async_blocks))]
|
||||
|
||||
use std::future::Future;
|
||||
|
@ -15,5 +15,4 @@ const _: i32 = { core::mem::ManuallyDrop::new(async { 0 }); 4 };
|
|||
static _FUT: &(dyn Future<Output = ()> + Sync) = &async {};
|
||||
//[without_feature]~^ `async` block
|
||||
|
||||
#[rustc_error]
|
||||
fn main() {} //[with_feature]~ fatal error triggered by #[rustc_error]
|
||||
fn main() {}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
error: fatal error triggered by #[rustc_error]
|
||||
--> $DIR/async-block.rs:19:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
@ -13,14 +13,16 @@
|
|||
//! - Original impl PR: <https://github.com/rust-lang/rust/pull/21248>.
|
||||
//! - RFC 507 "Release channels":
|
||||
//! <https://github.com/rust-lang/rfcs/blob/c017755b9bfa0421570d92ba38082302e0f3ad4f/text/0507-release-channels.md>.
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
//@ revisions: without_flag with_flag
|
||||
|
||||
//@ check-pass
|
||||
//@ compile-flags: -Zunleash-the-miri-inside-of-you
|
||||
//@[with_flag] compile-flags: -Awarnings
|
||||
|
||||
//@ check-pass
|
||||
fn non_constant() {}
|
||||
const fn constant() { non_constant() }
|
||||
|
||||
#[rustc_error(warn)]
|
||||
fn main() {}
|
||||
//[without_flag]~^ WARN unexpected annotation used with `#[rustc_error(...)]`!
|
||||
|
||||
//[without_flag]~? WARN skipping const checks
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
warning: unexpected annotation used with `#[rustc_error(...)]`!
|
||||
--> $DIR/allow-non-lint-warnings.rs:25:1
|
||||
warning: skipping const checks
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/allow-non-lint-warnings.rs:24:23
|
||||
|
|
||||
LL | const fn constant() { non_constant() }
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Test that `#[rustc_*]` attributes are gated by `rustc_attrs` feature gate.
|
||||
|
||||
#[rustc_variance] //~ ERROR the `#[rustc_variance]` attribute is just used for rustc unit tests and will never be stable
|
||||
#[rustc_error] //~ ERROR the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable
|
||||
#[rustc_nonnull_optimization_guaranteed] //~ ERROR the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to document guaranteed niche optimizations in libcore and libstd and will never be stable
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -7,18 +7,9 @@ LL | #[rustc_variance]
|
|||
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable
|
||||
--> $DIR/feature-gate-rustc-attrs-1.rs:4:1
|
||||
|
|
||||
LL | #[rustc_error]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to document guaranteed niche optimizations in libcore and libstd and will never be stable
|
||||
(note that the compiler does not even check whether the type indeed is being non-null-optimized; it is your responsibility to ensure that the attribute is only used on types that are optimized)
|
||||
--> $DIR/feature-gate-rustc-attrs-1.rs:5:1
|
||||
--> $DIR/feature-gate-rustc-attrs-1.rs:4:1
|
||||
|
|
||||
LL | #[rustc_nonnull_optimization_guaranteed]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -26,6 +17,6 @@ LL | #[rustc_nonnull_optimization_guaranteed]
|
|||
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//@ check-pass
|
||||
//@ compile-flags: -Z mir-opt-level=3
|
||||
|
||||
#![feature(type_alias_impl_trait, rustc_attrs)]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
|
@ -43,8 +44,6 @@ impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<Phantom1<T>> for Scope<U> {
|
|||
}
|
||||
}
|
||||
|
||||
#[rustc_error]
|
||||
fn main() {
|
||||
//~^ ERROR
|
||||
let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
error: fatal error triggered by #[rustc_error]
|
||||
--> $DIR/issue-75053.rs:47:1
|
||||
|
|
||||
LL | fn main() {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
//@ check-pass
|
||||
//@ proc-macro: test-macros.rs
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
#![warn(unused_extern_crates)]
|
||||
|
||||
extern crate test_macros;
|
||||
//~^ WARN unused extern crate
|
||||
|
||||
#[rustc_error]
|
||||
fn main() {} //~ ERROR fatal error triggered by #[rustc_error]
|
||||
fn main() {}
|
||||
|
|
|
@ -10,11 +10,5 @@ note: the lint level is defined here
|
|||
LL | #![warn(unused_extern_crates)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: fatal error triggered by #[rustc_error]
|
||||
--> $DIR/no-macro-use-attr.rs:10:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error; 1 warning emitted
|
||||
warning: 1 warning emitted
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0658]: use of unstable library feature `structural_match`
|
||||
--> $DIR/feature-gate.rs:29:6
|
||||
--> $DIR/feature-gate.rs:27:6
|
||||
|
|
||||
LL | impl std::marker::StructuralPartialEq for Foo { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
// used in a match.
|
||||
|
||||
//@ revisions: with_gate no_gate
|
||||
|
||||
//@[with_gate] check-pass
|
||||
// gate-test-structural_match
|
||||
|
||||
#![allow(unused)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![cfg_attr(with_gate, feature(structural_match))]
|
||||
|
||||
|
||||
|
@ -17,8 +16,7 @@ struct Foo {
|
|||
|
||||
const FOO: Foo = Foo { x: 0 };
|
||||
|
||||
#[rustc_error]
|
||||
fn main() { //[with_gate]~ ERROR fatal error triggered by #[rustc_error]
|
||||
fn main() {
|
||||
let y = Foo { x: 1 };
|
||||
match y {
|
||||
FOO => { }
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
error: fatal error triggered by #[rustc_error]
|
||||
--> $DIR/feature-gate.rs:21:1
|
||||
|
|
||||
LL | fn main() {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_error]
|
||||
fn main() {
|
||||
//~^ ERROR fatal error triggered by #[rustc_error]
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
error: fatal error triggered by #[rustc_error]
|
||||
--> $DIR/rustc-error.rs:4:1
|
||||
|
|
||||
LL | fn main() {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// Test range syntax - borrow errors.
|
||||
#![feature(rustc_attrs)]
|
||||
pub fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
|
||||
pub fn main() {
|
||||
let r = {
|
||||
let a = 42;
|
||||
let b = 42;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#![feature(rustc_attrs)]
|
||||
use std::ops::FnMut;
|
||||
|
||||
fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
fn main() {
|
||||
let mut f;
|
||||
{
|
||||
let c = 1;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0597]: `c` does not live long enough
|
||||
--> $DIR/regionck-unboxed-closure-lifetimes.rs:8:21
|
||||
--> $DIR/regionck-unboxed-closure-lifetimes.rs:7:21
|
||||
|
|
||||
LL | let c = 1;
|
||||
| - binding `c` declared here
|
||||
|
|
|
@ -4,8 +4,8 @@ fn foo() {}
|
|||
#[tests] //~ ERROR cannot find attribute `tests` in this scope
|
||||
fn bar() {}
|
||||
|
||||
#[rustc_err]
|
||||
//~^ ERROR cannot find attribute `rustc_err` in this scope
|
||||
#[rustc_dumm]
|
||||
//~^ ERROR cannot find attribute `rustc_dumm` in this scope
|
||||
//~| ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
error: attributes starting with `rustc` are reserved for use by the `rustc` compiler
|
||||
--> $DIR/attribute-typos.rs:7:3
|
||||
|
|
||||
LL | #[rustc_err]
|
||||
| ^^^^^^^^^
|
||||
LL | #[rustc_dumm]
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: cannot find attribute `rustc_err` in this scope
|
||||
error: cannot find attribute `rustc_dumm` in this scope
|
||||
--> $DIR/attribute-typos.rs:7:3
|
||||
|
|
||||
LL | #[rustc_err]
|
||||
| ^^^^^^^^^ help: a built-in attribute with a similar name exists: `rustc_error`
|
||||
LL | #[rustc_dumm]
|
||||
| ^^^^^^^^^^ help: a built-in attribute with a similar name exists: `rustc_dummy`
|
||||
|
||||
error: cannot find attribute `tests` in this scope
|
||||
--> $DIR/attribute-typos.rs:4:3
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
error: fatal error triggered by #[rustc_error]
|
||||
--> $DIR/feature-gate.rs:22:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
//@ revisions: stock gated
|
||||
//@[gated] check-pass
|
||||
// gate-test-const_trait_impl
|
||||
|
||||
#![cfg_attr(gated, feature(const_trait_impl))]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
struct S;
|
||||
#[const_trait] //[stock]~ ERROR `const_trait` is a temporary placeholder
|
||||
|
@ -18,5 +18,4 @@ macro_rules! discard { ($ty:ty) => {} }
|
|||
discard! { impl ~const T } //[stock]~ ERROR const trait impls are experimental
|
||||
discard! { impl const T } //[stock]~ ERROR const trait impls are experimental
|
||||
|
||||
#[rustc_error]
|
||||
fn main() {} //[gated]~ ERROR fatal error triggered by #[rustc_error]
|
||||
fn main() {}
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_error(delayed_bug_from_inside_query)]
|
||||
#[rustc_delayed_bug_from_inside_query]
|
||||
fn main() {}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error: internal compiler error: delayed bug triggered by #[rustc_error(delayed_bug_from_inside_query)]
|
||||
error: internal compiler error: delayed bug triggered by #[rustc_delayed_bug_from_inside_query]
|
||||
--> $DIR/span_delayed_bug.rs:12:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#![feature(rustc_attrs)]
|
||||
//@ check-pass
|
||||
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
pub type Foo = impl Fn() -> usize;
|
||||
|
@ -8,5 +9,4 @@ pub const fn bar() -> Foo {
|
|||
}
|
||||
const BAZR: Foo = bar();
|
||||
|
||||
#[rustc_error]
|
||||
fn main() {} //~ ERROR
|
||||
fn main() {}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
error: fatal error triggered by #[rustc_error]
|
||||
--> $DIR/issue-53096.rs:12:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
#![feature(type_alias_impl_trait, rustc_attrs)]
|
||||
//@ check-pass
|
||||
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
pub type Debuggable = impl core::fmt::Debug;
|
||||
|
||||
|
@ -9,8 +11,6 @@ pub fn foo() -> Debuggable {
|
|||
|
||||
static mut TEST: Option<Debuggable> = None;
|
||||
|
||||
#[rustc_error]
|
||||
fn main() {
|
||||
//~^ ERROR
|
||||
unsafe { TEST = Some(foo()) }
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
error: fatal error triggered by #[rustc_error]
|
||||
--> $DIR/issue-60407.rs:13:1
|
||||
|
|
||||
LL | fn main() {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue