diff --git a/Cargo.lock b/Cargo.lock index f99957ae9ce7e..d7806b5daa63a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3250,6 +3250,7 @@ dependencies = [ "tempfile", "thorin-dwp", "tracing", + "windows 0.46.0", ] [[package]] @@ -3641,6 +3642,7 @@ dependencies = [ "rustc_plugin_impl", "rustc_privacy", "rustc_query_impl", + "rustc_query_system", "rustc_resolve", "rustc_session", "rustc_span", @@ -3770,6 +3772,7 @@ dependencies = [ "derive_more", "either", "gsgdt", + "measureme", "polonius-engine", "rustc-rayon", "rustc-rayon-core", diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 3ed342ce48b43..ea04ba4f66e46 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1430,8 +1430,8 @@ pub enum ExprKind { /// The async block used to have a `NodeId`, which was removed in favor of /// using the parent `NodeId` of the parent `Expr`. Async(CaptureBy, P<Block>), - /// An await expression (`my_future.await`). - Await(P<Expr>), + /// An await expression (`my_future.await`). Span is of await keyword. + Await(P<Expr>, Span), /// A try block (`try { ... }`). TryBlock(P<Block>), diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 99f1f4bd9685f..68a4d522993c1 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -1415,7 +1415,10 @@ pub fn noop_visit_expr<T: MutVisitor>( ExprKind::Async(_capture_by, body) => { vis.visit_block(body); } - ExprKind::Await(expr) => vis.visit_expr(expr), + ExprKind::Await(expr, await_kw_span) => { + vis.visit_expr(expr); + vis.visit_span(await_kw_span); + } ExprKind::Assign(el, er, _) => { vis.visit_expr(el); vis.visit_expr(er); diff --git a/compiler/rustc_ast/src/util/parser.rs b/compiler/rustc_ast/src/util/parser.rs index 24b4bd8623f04..64ae904513cb3 100644 --- a/compiler/rustc_ast/src/util/parser.rs +++ b/compiler/rustc_ast/src/util/parser.rs @@ -388,7 +388,7 @@ pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool { // X { y: 1 } + X { y: 2 } contains_exterior_struct_lit(lhs) || contains_exterior_struct_lit(rhs) } - ast::ExprKind::Await(x) + ast::ExprKind::Await(x, _) | ast::ExprKind::Unary(_, x) | ast::ExprKind::Cast(x, _) | ast::ExprKind::Type(x, _) diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index 8a6b5d5c9052d..1526ffa0b0306 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -864,7 +864,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) { ExprKind::Async(_, body) => { visitor.visit_block(body); } - ExprKind::Await(expr) => visitor.visit_expr(expr), + ExprKind::Await(expr, _) => visitor.visit_expr(expr), ExprKind::Assign(lhs, rhs, _) => { visitor.visit_expr(lhs); visitor.visit_expr(rhs); diff --git a/compiler/rustc_ast_lowering/src/errors.rs b/compiler/rustc_ast_lowering/src/errors.rs index 3e9f9b43623f8..72dc52a632992 100644 --- a/compiler/rustc_ast_lowering/src/errors.rs +++ b/compiler/rustc_ast_lowering/src/errors.rs @@ -108,7 +108,7 @@ pub struct BaseExpressionDoubleDot { pub struct AwaitOnlyInAsyncFnAndBlocks { #[primary_span] #[label] - pub dot_await_span: Span, + pub await_kw_span: Span, #[label(ast_lowering_this_not_async)] pub item_span: Option<Span>, } diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 7a0a7da969572..5e0ab80c6ac9f 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -185,21 +185,7 @@ impl<'hir> LoweringContext<'_, 'hir> { hir::AsyncGeneratorKind::Block, |this| this.with_new_scopes(|this| this.lower_block_expr(block)), ), - ExprKind::Await(expr) => { - let dot_await_span = if expr.span.hi() < e.span.hi() { - let span_with_whitespace = self - .tcx - .sess - .source_map() - .span_extend_while(expr.span, char::is_whitespace) - .unwrap_or(expr.span); - span_with_whitespace.shrink_to_hi().with_hi(e.span.hi()) - } else { - // this is a recovered `await expr` - e.span - }; - self.lower_expr_await(dot_await_span, expr) - } + ExprKind::Await(expr, await_kw_span) => self.lower_expr_await(*await_kw_span, expr), ExprKind::Closure(box Closure { binder, capture_clause, @@ -710,18 +696,18 @@ impl<'hir> LoweringContext<'_, 'hir> { /// } /// } /// ``` - fn lower_expr_await(&mut self, dot_await_span: Span, expr: &Expr) -> hir::ExprKind<'hir> { - let full_span = expr.span.to(dot_await_span); + fn lower_expr_await(&mut self, await_kw_span: Span, expr: &Expr) -> hir::ExprKind<'hir> { + let full_span = expr.span.to(await_kw_span); match self.generator_kind { Some(hir::GeneratorKind::Async(_)) => {} Some(hir::GeneratorKind::Gen) | None => { self.tcx.sess.emit_err(AwaitOnlyInAsyncFnAndBlocks { - dot_await_span, + await_kw_span, item_span: self.current_item, }); } } - let span = self.mark_span_with_reason(DesugaringKind::Await, dot_await_span, None); + let span = self.mark_span_with_reason(DesugaringKind::Await, await_kw_span, None); let gen_future_span = self.mark_span_with_reason( DesugaringKind::Await, full_span, diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index c081162ea1467..9b295339d9450 100644 --- a/compiler/rustc_ast_lowering/src/format.rs +++ b/compiler/rustc_ast_lowering/src/format.rs @@ -583,7 +583,7 @@ fn may_contain_yield_point(e: &ast::Expr) -> bool { impl Visitor<'_> for MayContainYieldPoint { fn visit_expr(&mut self, e: &ast::Expr) { - if let ast::ExprKind::Await(_) | ast::ExprKind::Yield(_) = e.kind { + if let ast::ExprKind::Await(_, _) | ast::ExprKind::Yield(_) = e.kind { self.0 = true; } else { visit::walk_expr(self, e); diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index aeb0c76202041..5511cf851b185 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -447,7 +447,7 @@ impl<'a> State<'a> { self.ibox(0); self.print_block_with_attrs(blk, attrs); } - ast::ExprKind::Await(expr) => { + ast::ExprKind::Await(expr, _) => { self.print_expr_maybe_paren(expr, parser::PREC_POSTFIX); self.word(".await"); } @@ -566,7 +566,7 @@ impl<'a> State<'a> { self.print_ident(field); } } - + self.pclose(); self.end(); } ast::ExprKind::MacCall(m) => self.print_mac(m), diff --git a/compiler/rustc_borrowck/messages.ftl b/compiler/rustc_borrowck/messages.ftl index 0b8123c970360..4a616dc24641a 100644 --- a/compiler/rustc_borrowck/messages.ftl +++ b/compiler/rustc_borrowck/messages.ftl @@ -203,6 +203,15 @@ borrowck_moved_due_to_method_call = *[false] call } +borrowck_moved_due_to_await = + {$place_name} {$is_partial -> + [true] partially moved + *[false] moved + } due to this {$is_loop_message -> + [true] await, in previous iteration of loop + *[false] await + } + borrowck_value_moved_here = value {$is_partial -> [true] partially moved diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index 4243ec214b098..a780255725e71 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -1085,12 +1085,21 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } } } else { - err.subdiagnostic(CaptureReasonLabel::MethodCall { - fn_call_span, - place_name: &place_name, - is_partial, - is_loop_message, - }); + if let Some((CallDesugaringKind::Await, _)) = desugaring { + err.subdiagnostic(CaptureReasonLabel::Await { + fn_call_span, + place_name: &place_name, + is_partial, + is_loop_message, + }); + } else { + err.subdiagnostic(CaptureReasonLabel::MethodCall { + fn_call_span, + place_name: &place_name, + is_partial, + is_loop_message, + }); + } // Erase and shadow everything that could be passed to the new infcx. let ty = moved_place.ty(self.body, tcx).ty; diff --git a/compiler/rustc_borrowck/src/session_diagnostics.rs b/compiler/rustc_borrowck/src/session_diagnostics.rs index bb95101845f3e..fceae5bb3ffe0 100644 --- a/compiler/rustc_borrowck/src/session_diagnostics.rs +++ b/compiler/rustc_borrowck/src/session_diagnostics.rs @@ -338,6 +338,14 @@ pub(crate) enum CaptureReasonLabel<'a> { is_partial: bool, is_loop_message: bool, }, + #[label(borrowck_moved_due_to_await)] + Await { + #[primary_span] + fn_call_span: Span, + place_name: &'a str, + is_partial: bool, + is_loop_message: bool, + }, #[label(borrowck_value_moved_here)] MovedHere { #[primary_span] diff --git a/compiler/rustc_builtin_macros/messages.ftl b/compiler/rustc_builtin_macros/messages.ftl index 74049406426ed..0d7cf7cdb267c 100644 --- a/compiler/rustc_builtin_macros/messages.ftl +++ b/compiler/rustc_builtin_macros/messages.ftl @@ -169,5 +169,40 @@ builtin_macros_asm_pure_no_output = asm with the `pure` option must have at leas builtin_macros_asm_modifier_invalid = asm template modifier must be a single character +builtin_macros_asm_requires_template = requires at least a template string argument + +builtin_macros_asm_expected_comma = expected token: `,` + .label = expected `,` + +builtin_macros_asm_underscore_input = _ cannot be used for input operands + +builtin_macros_asm_sym_no_path = expected a path for argument to `sym` + +builtin_macros_asm_expected_other = expected operand, {$is_global_asm -> + [true] options + *[false] clobber_abi, options + }, or additional template string + +builtin_macros_asm_duplicate_arg = duplicate argument named `{$name}` + .label = previously here + .arg = duplicate argument + +builtin_macros_asm_pos_after = positional arguments cannot follow named arguments or explicit register arguments + .pos = positional argument + .named = named argument + .explicit = explicit register argument + +builtin_macros_asm_noreturn = asm outputs are not allowed with the `noreturn` option + +builtin_macros_global_asm_clobber_abi = `clobber_abi` cannot be used with `global_asm!` + +builtin_macros_asm_clobber_no_reg = asm with `clobber_abi` must specify explicit registers for outputs +builtin_macros_asm_clobber_abi = clobber_abi +builtin_macros_asm_clobber_outputs = generic outputs + +builtin_macros_asm_opt_already_provided = the `{$symbol}` option was already provided + .label = this option was already provided + .suggestion = remove this option + builtin_macros_test_runner_invalid = `test_runner` argument must be a path builtin_macros_test_runner_nargs = `#![test_runner(..)]` accepts exactly 1 argument diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs index bcdd58a090162..c066512b09ee3 100644 --- a/compiler/rustc_builtin_macros/src/asm.rs +++ b/compiler/rustc_builtin_macros/src/asm.rs @@ -3,7 +3,7 @@ use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter}; use rustc_ast::tokenstream::TokenStream; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_errors::{Applicability, PResult}; +use rustc_errors::PResult; use rustc_expand::base::{self, *}; use rustc_parse::parser::Parser; use rustc_parse_format as parse; @@ -49,7 +49,7 @@ pub fn parse_asm_args<'a>( let diag = &sess.span_diagnostic; if p.token == token::Eof { - return Err(diag.struct_span_err(sp, "requires at least a template string argument")); + return Err(diag.create_err(errors::AsmRequiresTemplate { span: sp })); } let first_template = p.parse_expr()?; @@ -68,8 +68,7 @@ pub fn parse_asm_args<'a>( if !p.eat(&token::Comma) { if allow_templates { // After a template string, we always expect *only* a comma... - let mut err = diag.struct_span_err(p.token.span, "expected token: `,`"); - err.span_label(p.token.span, "expected `,`"); + let mut err = diag.create_err(errors::AsmExpectedComma { span: p.token.span }); p.maybe_annotate_with_ascription(&mut err, false); return Err(err); } else { @@ -112,7 +111,7 @@ pub fn parse_asm_args<'a>( let op = if !is_global_asm && p.eat_keyword(kw::In) { let reg = parse_reg(p, &mut explicit_reg)?; if p.eat_keyword(kw::Underscore) { - let err = diag.struct_span_err(p.token.span, "_ cannot be used for input operands"); + let err = diag.create_err(errors::AsmUnderscoreInput { span: p.token.span }); return Err(err); } let expr = p.parse_expr()?; @@ -128,7 +127,7 @@ pub fn parse_asm_args<'a>( } else if !is_global_asm && p.eat_keyword(sym::inout) { let reg = parse_reg(p, &mut explicit_reg)?; if p.eat_keyword(kw::Underscore) { - let err = diag.struct_span_err(p.token.span, "_ cannot be used for input operands"); + let err = diag.create_err(errors::AsmUnderscoreInput { span: p.token.span }); return Err(err); } let expr = p.parse_expr()?; @@ -142,7 +141,7 @@ pub fn parse_asm_args<'a>( } else if !is_global_asm && p.eat_keyword(sym::inlateout) { let reg = parse_reg(p, &mut explicit_reg)?; if p.eat_keyword(kw::Underscore) { - let err = diag.struct_span_err(p.token.span, "_ cannot be used for input operands"); + let err = diag.create_err(errors::AsmUnderscoreInput { span: p.token.span }); return Err(err); } let expr = p.parse_expr()?; @@ -160,7 +159,7 @@ pub fn parse_asm_args<'a>( let expr = p.parse_expr()?; let ast::ExprKind::Path(qself, path) = &expr.kind else { let err = diag - .struct_span_err(expr.span, "expected a path for argument to `sym`"); + .create_err(errors::AsmSymNoPath { span: expr.span }); return Err(err); }; let sym = ast::InlineAsmSym { @@ -181,13 +180,10 @@ pub fn parse_asm_args<'a>( ) => {} ast::ExprKind::MacCall(..) => {} _ => { - let errstr = if is_global_asm { - "expected operand, options, or additional template string" - } else { - "expected operand, clobber_abi, options, or additional template string" - }; - let mut err = diag.struct_span_err(template.span, errstr); - err.span_label(template.span, errstr); + let err = diag.create_err(errors::AsmExpectedOther { + span: template.span, + is_global_asm, + }); return Err(err); } } @@ -212,28 +208,16 @@ pub fn parse_asm_args<'a>( args.reg_args.insert(slot); } else if let Some(name) = name { if let Some(&prev) = args.named_args.get(&name) { - diag.struct_span_err(span, &format!("duplicate argument named `{}`", name)) - .span_label(args.operands[prev].1, "previously here") - .span_label(span, "duplicate argument") - .emit(); + diag.emit_err(errors::AsmDuplicateArg { span, name, prev: args.operands[prev].1 }); continue; } args.named_args.insert(name, slot); } else { if !args.named_args.is_empty() || !args.reg_args.is_empty() { - let mut err = diag.struct_span_err( - span, - "positional arguments cannot follow named arguments \ - or explicit register arguments", - ); - err.span_label(span, "positional argument"); - for pos in args.named_args.values() { - err.span_label(args.operands[*pos].1, "named argument"); - } - for pos in &args.reg_args { - err.span_label(args.operands[*pos].1, "explicit register argument"); - } - err.emit(); + let named = args.named_args.values().map(|p| args.operands[*p].1).collect(); + let explicit = args.reg_args.iter().map(|p| args.operands[*p].1).collect(); + + diag.emit_err(errors::AsmPositionalAfter { span, named, explicit }); } } } @@ -284,34 +268,25 @@ pub fn parse_asm_args<'a>( diag.emit_err(errors::AsmPureNoOutput { spans: args.options_spans.clone() }); } if args.options.contains(ast::InlineAsmOptions::NORETURN) && !outputs_sp.is_empty() { - let err = diag - .struct_span_err(outputs_sp, "asm outputs are not allowed with the `noreturn` option"); - + let err = diag.create_err(errors::AsmNoReturn { outputs_sp }); // Bail out now since this is likely to confuse MIR return Err(err); } if args.clobber_abis.len() > 0 { if is_global_asm { - let err = diag.struct_span_err( - args.clobber_abis.iter().map(|(_, span)| *span).collect::<Vec<Span>>(), - "`clobber_abi` cannot be used with `global_asm!`", - ); + let err = diag.create_err(errors::GlobalAsmClobberAbi { + spans: args.clobber_abis.iter().map(|(_, span)| *span).collect(), + }); // Bail out now since this is likely to confuse later stages return Err(err); } if !regclass_outputs.is_empty() { - diag.struct_span_err( - regclass_outputs.clone(), - "asm with `clobber_abi` must specify explicit registers for outputs", - ) - .span_labels( - args.clobber_abis.iter().map(|(_, span)| *span).collect::<Vec<Span>>(), - "clobber_abi", - ) - .span_labels(regclass_outputs, "generic outputs") - .emit(); + diag.emit_err(errors::AsmClobberNoReg { + spans: regclass_outputs, + clobbers: args.clobber_abis.iter().map(|(_, span)| *span).collect(), + }); } } @@ -323,25 +298,9 @@ pub fn parse_asm_args<'a>( /// This function must be called immediately after the option token is parsed. /// Otherwise, the suggestion will be incorrect. fn err_duplicate_option(p: &mut Parser<'_>, symbol: Symbol, span: Span) { - let mut err = p - .sess - .span_diagnostic - .struct_span_err(span, &format!("the `{}` option was already provided", symbol)); - err.span_label(span, "this option was already provided"); - // Tool-only output - let mut full_span = span; - if p.token.kind == token::Comma { - full_span = full_span.to(p.token.span); - } - err.tool_only_span_suggestion( - full_span, - "remove this option", - "", - Applicability::MachineApplicable, - ); - - err.emit(); + let full_span = if p.token.kind == token::Comma { span.to(p.token.span) } else { span }; + p.sess.span_diagnostic.emit_err(errors::AsmOptAlreadyprovided { span, symbol, full_span }); } /// Try to set the provided option in the provided `AsmArgs`. diff --git a/compiler/rustc_builtin_macros/src/assert/context.rs b/compiler/rustc_builtin_macros/src/assert/context.rs index 090e00616fb48..bd3f148c9a79c 100644 --- a/compiler/rustc_builtin_macros/src/assert/context.rs +++ b/compiler/rustc_builtin_macros/src/assert/context.rs @@ -288,7 +288,7 @@ impl<'cx, 'a> Context<'cx, 'a> { ExprKind::Assign(_, _, _) | ExprKind::AssignOp(_, _, _) | ExprKind::Async(_, _) - | ExprKind::Await(_) + | ExprKind::Await(_, _) | ExprKind::Block(_, _) | ExprKind::Break(_, _) | ExprKind::Closure(_) diff --git a/compiler/rustc_builtin_macros/src/errors.rs b/compiler/rustc_builtin_macros/src/errors.rs index b146988a3c235..d0d78646009e1 100644 --- a/compiler/rustc_builtin_macros/src/errors.rs +++ b/compiler/rustc_builtin_macros/src/errors.rs @@ -1,5 +1,6 @@ use rustc_errors::{ - AddToDiagnostic, EmissionGuarantee, IntoDiagnostic, MultiSpan, SingleLabelManySpans, + AddToDiagnostic, DiagnosticBuilder, EmissionGuarantee, Handler, IntoDiagnostic, MultiSpan, + SingleLabelManySpans, }; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{symbol::Ident, Span, Symbol}; @@ -370,11 +371,12 @@ pub(crate) struct EnvNotDefined { // Hand-written implementation to support custom user messages impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for EnvNotDefined { #[track_caller] - fn into_diagnostic( - self, - handler: &'a rustc_errors::Handler, - ) -> rustc_errors::DiagnosticBuilder<'a, G> { + fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, G> { let mut diag = if let Some(msg) = self.msg { + #[expect( + rustc::untranslatable_diagnostic, + reason = "cannot translate user-provided messages" + )] handler.struct_diagnostic(msg.as_str()) } else { handler.struct_diagnostic(crate::fluent_generated::builtin_macros_env_not_defined) @@ -606,6 +608,117 @@ pub(crate) struct AsmModifierInvalid { pub(crate) span: Span, } +#[derive(Diagnostic)] +#[diag(builtin_macros_asm_requires_template)] +pub(crate) struct AsmRequiresTemplate { + #[primary_span] + pub(crate) span: Span, +} + +#[derive(Diagnostic)] +#[diag(builtin_macros_asm_expected_comma)] +pub(crate) struct AsmExpectedComma { + #[primary_span] + #[label] + pub(crate) span: Span, +} + +#[derive(Diagnostic)] +#[diag(builtin_macros_asm_underscore_input)] +pub(crate) struct AsmUnderscoreInput { + #[primary_span] + pub(crate) span: Span, +} + +#[derive(Diagnostic)] +#[diag(builtin_macros_asm_sym_no_path)] +pub(crate) struct AsmSymNoPath { + #[primary_span] + pub(crate) span: Span, +} + +#[derive(Diagnostic)] +#[diag(builtin_macros_asm_expected_other)] +pub(crate) struct AsmExpectedOther { + #[primary_span] + #[label(builtin_macros_asm_expected_other)] + pub(crate) span: Span, + pub(crate) is_global_asm: bool, +} + +#[derive(Diagnostic)] +#[diag(builtin_macros_asm_duplicate_arg)] +pub(crate) struct AsmDuplicateArg { + #[primary_span] + #[label(builtin_macros_arg)] + pub(crate) span: Span, + #[label] + pub(crate) prev: Span, + pub(crate) name: Symbol, +} + +#[derive(Diagnostic)] +#[diag(builtin_macros_asm_pos_after)] +pub(crate) struct AsmPositionalAfter { + #[primary_span] + #[label(builtin_macros_pos)] + pub(crate) span: Span, + #[label(builtin_macros_named)] + pub(crate) named: Vec<Span>, + #[label(builtin_macros_explicit)] + pub(crate) explicit: Vec<Span>, +} + +#[derive(Diagnostic)] +#[diag(builtin_macros_asm_noreturn)] +pub(crate) struct AsmNoReturn { + #[primary_span] + pub(crate) outputs_sp: Vec<Span>, +} + +#[derive(Diagnostic)] +#[diag(builtin_macros_global_asm_clobber_abi)] +pub(crate) struct GlobalAsmClobberAbi { + #[primary_span] + pub(crate) spans: Vec<Span>, +} + +pub(crate) struct AsmClobberNoReg { + pub(crate) spans: Vec<Span>, + pub(crate) clobbers: Vec<Span>, +} + +impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for AsmClobberNoReg { + fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, G> { + let mut diag = + handler.struct_diagnostic(crate::fluent_generated::builtin_macros_asm_clobber_no_reg); + diag.set_span(self.spans.clone()); + // eager translation as `span_labels` takes `AsRef<str>` + let lbl1 = handler.eagerly_translate_to_string( + crate::fluent_generated::builtin_macros_asm_clobber_abi, + [].into_iter(), + ); + diag.span_labels(self.clobbers, &lbl1); + let lbl2 = handler.eagerly_translate_to_string( + crate::fluent_generated::builtin_macros_asm_clobber_outputs, + [].into_iter(), + ); + diag.span_labels(self.spans, &lbl2); + diag + } +} + +#[derive(Diagnostic)] +#[diag(builtin_macros_asm_opt_already_provided)] +pub(crate) struct AsmOptAlreadyprovided { + #[primary_span] + #[label] + pub(crate) span: Span, + pub(crate) symbol: Symbol, + #[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")] + pub(crate) full_span: Span, +} + #[derive(Diagnostic)] #[diag(builtin_macros_test_runner_invalid)] pub(crate) struct TestRunnerInvalid { diff --git a/compiler/rustc_builtin_macros/src/test_harness.rs b/compiler/rustc_builtin_macros/src/test_harness.rs index be4ba66c082aa..9bc1e27b4ec74 100644 --- a/compiler/rustc_builtin_macros/src/test_harness.rs +++ b/compiler/rustc_builtin_macros/src/test_harness.rs @@ -232,7 +232,7 @@ fn generate_test_harness( let expn_id = ext_cx.resolver.expansion_for_ast_pass( DUMMY_SP, AstPass::TestHarness, - &[sym::test, sym::rustc_attrs], + &[sym::test, sym::rustc_attrs, sym::no_coverage], None, ); let def_site = DUMMY_SP.with_def_site_ctxt(expn_id.to_expn_id()); @@ -313,6 +313,8 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> { // #[rustc_main] let main_attr = ecx.attr_word(sym::rustc_main, sp); + // #[no_coverage] + let no_coverage_attr = ecx.attr_word(sym::no_coverage, sp); // pub fn main() { ... } let main_ret_ty = ecx.ty(sp, ast::TyKind::Tup(ThinVec::new())); @@ -342,7 +344,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> { let main = P(ast::Item { ident: main_id, - attrs: thin_vec![main_attr], + attrs: thin_vec![main_attr, no_coverage_attr], id: ast::DUMMY_NODE_ID, kind: main, vis: ast::Visibility { span: sp, kind: ast::VisibilityKind::Public, tokens: None }, diff --git a/compiler/rustc_codegen_ssa/Cargo.toml b/compiler/rustc_codegen_ssa/Cargo.toml index a421535c9b46f..4f73b731f5a2a 100644 --- a/compiler/rustc_codegen_ssa/Cargo.toml +++ b/compiler/rustc_codegen_ssa/Cargo.toml @@ -49,3 +49,7 @@ libc = "0.2.50" version = "0.30.1" default-features = false features = ["read_core", "elf", "macho", "pe", "unaligned", "archive", "write"] + +[target.'cfg(windows)'.dependencies.windows] +version = "0.46.0" +features = ["Win32_Globalization"] diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index eecfe13bb3eef..c63e156beae7b 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -860,7 +860,7 @@ fn link_natively<'a>( if !prog.status.success() { let mut output = prog.stderr.clone(); output.extend_from_slice(&prog.stdout); - let escaped_output = escape_string(&output); + let escaped_output = escape_linker_output(&output, flavor); // FIXME: Add UI tests for this error. let err = errors::LinkingFailed { linker_path: &linker_path, @@ -1052,6 +1052,83 @@ fn escape_string(s: &[u8]) -> String { } } +#[cfg(not(windows))] +fn escape_linker_output(s: &[u8], _flavour: LinkerFlavor) -> String { + escape_string(s) +} + +/// If the output of the msvc linker is not UTF-8 and the host is Windows, +/// then try to convert the string from the OEM encoding. +#[cfg(windows)] +fn escape_linker_output(s: &[u8], flavour: LinkerFlavor) -> String { + // This only applies to the actual MSVC linker. + if flavour != LinkerFlavor::Msvc(Lld::No) { + return escape_string(s); + } + match str::from_utf8(s) { + Ok(s) => return s.to_owned(), + Err(_) => match win::locale_byte_str_to_string(s, win::oem_code_page()) { + Some(s) => s, + // The string is not UTF-8 and isn't valid for the OEM code page + None => format!("Non-UTF-8 output: {}", s.escape_ascii()), + }, + } +} + +/// Wrappers around the Windows API. +#[cfg(windows)] +mod win { + use windows::Win32::Globalization::{ + GetLocaleInfoEx, MultiByteToWideChar, CP_OEMCP, LOCALE_IUSEUTF8LEGACYOEMCP, + LOCALE_NAME_SYSTEM_DEFAULT, LOCALE_RETURN_NUMBER, MB_ERR_INVALID_CHARS, + }; + + /// Get the Windows system OEM code page. This is most notably the code page + /// used for link.exe's output. + pub fn oem_code_page() -> u32 { + unsafe { + let mut cp: u32 = 0; + // We're using the `LOCALE_RETURN_NUMBER` flag to return a u32. + // But the API requires us to pass the data as though it's a [u16] string. + let len = std::mem::size_of::<u32>() / std::mem::size_of::<u16>(); + let data = std::slice::from_raw_parts_mut(&mut cp as *mut u32 as *mut u16, len); + let len_written = GetLocaleInfoEx( + LOCALE_NAME_SYSTEM_DEFAULT, + LOCALE_IUSEUTF8LEGACYOEMCP | LOCALE_RETURN_NUMBER, + Some(data), + ); + if len_written as usize == len { cp } else { CP_OEMCP } + } + } + /// Try to convert a multi-byte string to a UTF-8 string using the given code page + /// The string does not need to be null terminated. + /// + /// This is implemented as a wrapper around `MultiByteToWideChar`. + /// See <https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar> + /// + /// It will fail if the multi-byte string is longer than `i32::MAX` or if it contains + /// any invalid bytes for the expected encoding. + pub fn locale_byte_str_to_string(s: &[u8], code_page: u32) -> Option<String> { + // `MultiByteToWideChar` requires a length to be a "positive integer". + if s.len() > isize::MAX as usize { + return None; + } + // Error if the string is not valid for the expected code page. + let flags = MB_ERR_INVALID_CHARS; + // Call MultiByteToWideChar twice. + // First to calculate the length then to convert the string. + let mut len = unsafe { MultiByteToWideChar(code_page, flags, s, None) }; + if len > 0 { + let mut utf16 = vec![0; len as usize]; + len = unsafe { MultiByteToWideChar(code_page, flags, s, Some(&mut utf16)) }; + if len > 0 { + return utf16.get(..len as usize).map(String::from_utf16_lossy); + } + } + None + } +} + fn add_sanitizer_libraries(sess: &Session, crate_type: CrateType, linker: &mut dyn Linker) { // On macOS the runtimes are distributed as dylibs which should be linked to // both executables and dynamic shared objects. Everywhere else the runtimes diff --git a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs index 4fb668545712e..e3d39091a745d 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs @@ -184,6 +184,9 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> { CallDesugaringKind::TryBlockFromOutput => { error!("`try` block cannot convert `{}` to the result in {}s") } + CallDesugaringKind::Await => { + error!("cannot convert `{}` into a future in {}s") + } }; diag_trait(&mut err, self_ty, kind.trait_def_id(tcx)); diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 052d312d9a0d5..bafb83740ca85 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -310,8 +310,8 @@ declare_features! ( /// Allows `async || body` closures. (active, async_closure, "1.37.0", Some(62290), None), /// Allows async functions to be declared, implemented, and used in traits. - (incomplete, async_fn_in_trait, "1.66.0", Some(91611), None), - /// Allows `extern "C-unwind" fn` to enable unwinding across ABI boundaries. + (active, async_fn_in_trait, "1.66.0", Some(91611), None), + /// Treat `extern "C"` function as nounwind. (active, c_unwind, "1.52.0", Some(74990), None), /// Allows using C-variadics. (active, c_variadic, "1.34.0", Some(44930), None), @@ -496,7 +496,7 @@ declare_features! ( /// Allows `repr(simd)` and importing the various simd intrinsics. (active, repr_simd, "1.4.0", Some(27731), None), /// Allows return-position `impl Trait` in traits. - (incomplete, return_position_impl_trait_in_trait, "1.65.0", Some(91611), None), + (active, return_position_impl_trait_in_trait, "1.65.0", Some(91611), None), /// Allows bounding the return type of AFIT/RPITIT. (incomplete, return_type_notation, "1.70.0", Some(109417), None), /// Allows `extern "rust-cold"`. diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 103e0f344070d..c77292fdd1647 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -344,7 +344,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ ), ungated!(link_name, Normal, template!(NameValueStr: "name"), FutureWarnPreceding), ungated!(no_link, Normal, template!(Word), WarnFollowing), - ungated!(repr, Normal, template!(List: "C"), DuplicatesOk), + ungated!(repr, Normal, template!(List: "C"), DuplicatesOk, @only_local: true), ungated!(export_name, Normal, template!(NameValueStr: "name"), FutureWarnPreceding), ungated!(link_section, Normal, template!(NameValueStr: "name"), FutureWarnPreceding), ungated!(no_mangle, Normal, template!(Word), WarnFollowing, @only_local: true), diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index d505d8b8e0b30..6a10b50aa16ea 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -381,6 +381,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) { sym::unlikely => (0, vec![tcx.types.bool], tcx.types.bool), sym::read_via_copy => (1, vec![tcx.mk_imm_ptr(param(0))], param(0)), + sym::write_via_move => (1, vec![tcx.mk_mut_ptr(param(0)), param(0)], tcx.mk_unit()), sym::discriminant_value => { let assoc_items = tcx.associated_item_def_ids( diff --git a/compiler/rustc_incremental/src/persist/load.rs b/compiler/rustc_incremental/src/persist/load.rs index d5097065dda2e..ec7fcbdf8848c 100644 --- a/compiler/rustc_incremental/src/persist/load.rs +++ b/compiler/rustc_incremental/src/persist/load.rs @@ -4,7 +4,7 @@ use crate::errors; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::memmap::Mmap; use rustc_middle::dep_graph::{SerializedDepGraph, WorkProduct, WorkProductId}; -use rustc_middle::ty::OnDiskCache; +use rustc_middle::query::on_disk_cache::OnDiskCache; use rustc_serialize::opaque::MemDecoder; use rustc_serialize::Decodable; use rustc_session::config::IncrementalStateAssertion; @@ -211,7 +211,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture { /// If we are not in incremental compilation mode, returns `None`. /// Otherwise, tries to load the query result cache from disk, /// creating an empty cache if it could not be loaded. -pub fn load_query_result_cache<'a, C: OnDiskCache<'a>>(sess: &'a Session) -> Option<C> { +pub fn load_query_result_cache(sess: &Session) -> Option<OnDiskCache<'_>> { if sess.opts.incremental.is_none() { return None; } @@ -223,7 +223,9 @@ pub fn load_query_result_cache<'a, C: OnDiskCache<'a>>(sess: &'a Session) -> Opt &query_cache_path(sess), sess.is_nightly_build(), ) { - LoadResult::Ok { data: (bytes, start_pos) } => Some(C::new(sess, bytes, start_pos)), - _ => Some(C::new_empty(sess.source_map())), + LoadResult::Ok { data: (bytes, start_pos) } => { + Some(OnDiskCache::new(sess, bytes, start_pos)) + } + _ => Some(OnDiskCache::new_empty(sess.source_map())), } } diff --git a/compiler/rustc_incremental/src/persist/save.rs b/compiler/rustc_incremental/src/persist/save.rs index 27be56eac6f99..1441e64e41f32 100644 --- a/compiler/rustc_incremental/src/persist/save.rs +++ b/compiler/rustc_incremental/src/persist/save.rs @@ -48,7 +48,7 @@ pub fn save_dep_graph(tcx: TyCtxt<'_>) { move || { sess.time("incr_comp_persist_result_cache", || { // Drop the memory map so that we can remove the file and write to it. - if let Some(odc) = &tcx.on_disk_cache { + if let Some(odc) = &tcx.query_system.on_disk_cache { odc.drop_serialized_data(tcx); } diff --git a/compiler/rustc_interface/Cargo.toml b/compiler/rustc_interface/Cargo.toml index 41a0254df182c..2c7438ed9db43 100644 --- a/compiler/rustc_interface/Cargo.toml +++ b/compiler/rustc_interface/Cargo.toml @@ -44,6 +44,7 @@ rustc_lint = { path = "../rustc_lint" } rustc_errors = { path = "../rustc_errors" } rustc_plugin_impl = { path = "../rustc_plugin_impl" } rustc_privacy = { path = "../rustc_privacy" } +rustc_query_system = { path = "../rustc_query_system" } rustc_query_impl = { path = "../rustc_query_impl" } rustc_resolve = { path = "../rustc_resolve" } rustc_target = { path = "../rustc_target" } diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index be7fa9378ca66..8e9150ba8ad3d 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -12,6 +12,7 @@ use rustc_lint::LintStore; use rustc_middle::ty; use rustc_parse::maybe_new_parser_from_source_str; use rustc_query_impl::QueryCtxt; +use rustc_query_system::query::print_query_stack; use rustc_session::config::{self, CheckCfg, ErrorOutputType, Input, OutputFilenames}; use rustc_session::lint; use rustc_session::parse::{CrateConfig, ParseSess}; @@ -317,7 +318,7 @@ pub fn try_print_query_stack(handler: &Handler, num_frames: Option<usize>) { // state if it was responsible for triggering the panic. let i = ty::tls::with_context_opt(|icx| { if let Some(icx) = icx { - QueryCtxt::from_tcx(icx.tcx).try_print_query_stack(icx.query, handler, num_frames) + print_query_stack(QueryCtxt { tcx: icx.tcx }, icx.query, handler, num_frames) } else { 0 } diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 61923db9623ba..48401eabd1ed1 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -23,7 +23,6 @@ use rustc_mir_build as mir_build; use rustc_parse::{parse_crate_from_file, parse_crate_from_source_str, validate_attr}; use rustc_passes::{self, hir_stats, layout_test}; use rustc_plugin_impl as plugin; -use rustc_query_impl::{OnDiskCache, Queries as TcxQueries}; use rustc_resolve::Resolver; use rustc_session::config::{CrateType, Input, OutputFilenames, OutputType}; use rustc_session::cstore::{MetadataLoader, Untracked}; @@ -669,7 +668,6 @@ pub fn create_global_ctxt<'tcx>( lint_store: Lrc<LintStore>, dep_graph: DepGraph, untracked: Untracked, - queries: &'tcx OnceCell<TcxQueries<'tcx>>, gcx_cell: &'tcx OnceCell<GlobalCtxt<'tcx>>, arena: &'tcx WorkerLocal<Arena<'tcx>>, hir_arena: &'tcx WorkerLocal<rustc_hir::Arena<'tcx>>, @@ -693,10 +691,6 @@ pub fn create_global_ctxt<'tcx>( callback(sess, &mut local_providers, &mut extern_providers); } - let queries = queries.get_or_init(|| { - TcxQueries::new(local_providers, extern_providers, query_result_on_disk_cache) - }); - sess.time("setup_global_ctxt", || { gcx_cell.get_or_init(move || { TyCtxt::create_global_ctxt( @@ -706,9 +700,9 @@ pub fn create_global_ctxt<'tcx>( hir_arena, untracked, dep_graph, - queries.on_disk_cache.as_ref().map(OnDiskCache::as_dyn), - queries.as_dyn(), + query_result_on_disk_cache, rustc_query_impl::query_callbacks(arena), + rustc_query_impl::query_system_fns(local_providers, extern_providers), ) }) }) diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index 818f450a58c16..77fbbf64a0ad2 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -16,7 +16,6 @@ use rustc_metadata::creader::CStore; use rustc_middle::arena::Arena; use rustc_middle::dep_graph::DepGraph; use rustc_middle::ty::{GlobalCtxt, TyCtxt}; -use rustc_query_impl::Queries as TcxQueries; use rustc_session::config::{self, OutputFilenames, OutputType}; use rustc_session::cstore::Untracked; use rustc_session::{output::find_crate_name, Session}; @@ -81,7 +80,6 @@ impl<T> Default for Query<T> { pub struct Queries<'tcx> { compiler: &'tcx Compiler, gcx_cell: OnceCell<GlobalCtxt<'tcx>>, - queries: OnceCell<TcxQueries<'tcx>>, arena: WorkerLocal<Arena<'tcx>>, hir_arena: WorkerLocal<rustc_hir::Arena<'tcx>>, @@ -102,7 +100,6 @@ impl<'tcx> Queries<'tcx> { Queries { compiler, gcx_cell: OnceCell::new(), - queries: OnceCell::new(), arena: WorkerLocal::new(|_| Arena::default()), hir_arena: WorkerLocal::new(|_| rustc_hir::Arena::default()), dep_graph_future: Default::default(), @@ -225,7 +222,6 @@ impl<'tcx> Queries<'tcx> { lint_store, self.dep_graph()?.steal(), untracked, - &self.queries, &self.gcx_cell, &self.arena, &self.hir_arena, diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index a27a1e2978a36..8d37b1053d800 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -170,7 +170,8 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>( ) -> R { use rustc_data_structures::jobserver; use rustc_middle::ty::tls; - use rustc_query_impl::{deadlock, QueryContext, QueryCtxt}; + use rustc_query_impl::QueryCtxt; + use rustc_query_system::query::{deadlock, QueryContext}; let registry = sync::Registry::new(threads); let mut builder = rayon::ThreadPoolBuilder::new() @@ -182,7 +183,7 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>( // On deadlock, creates a new thread and forwards information in thread // locals to it. The new thread runs the deadlock handler. let query_map = tls::with(|tcx| { - QueryCtxt::from_tcx(tcx) + QueryCtxt::new(tcx) .try_collect_active_jobs() .expect("active jobs shouldn't be locked in deadlock handler") }); diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index a3d7bd3ef59a3..6fe15e21d948d 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -4014,7 +4014,6 @@ declare_lint! { /// ### Example /// /// ```rust - /// #![feature(c_unwind)] /// #![warn(ffi_unwind_calls)] /// /// extern "C-unwind" { @@ -4037,8 +4036,7 @@ declare_lint! { /// that desire this ability it is therefore necessary to avoid such calls. pub FFI_UNWIND_CALLS, Allow, - "call to foreign functions or function pointers with FFI-unwind ABI", - @feature_gate = sym::c_unwind; + "call to foreign functions or function pointers with FFI-unwind ABI" } declare_lint! { diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index dfbe8ac0ba3dc..a7d97bd3cf5ee 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -11,6 +11,7 @@ chalk-ir = "0.87.0" derive_more = "0.99.17" either = "1.5.0" gsgdt = "0.1.2" +measureme = "10.0.0" polonius-engine = "0.13.0" rustc_apfloat = { path = "../rustc_apfloat" } rustc_arena = { path = "../rustc_arena" } diff --git a/compiler/rustc_middle/src/mir/interpret/mod.rs b/compiler/rustc_middle/src/mir/interpret/mod.rs index 1f8b650e34cfc..e5a9766c84dc8 100644 --- a/compiler/rustc_middle/src/mir/interpret/mod.rs +++ b/compiler/rustc_middle/src/mir/interpret/mod.rs @@ -227,7 +227,9 @@ pub fn specialized_encode_alloc_id<'tcx, E: TyEncoder<I = TyCtxt<'tcx>>>( // References to statics doesn't need to know about their allocations, // just about its `DefId`. AllocDiscriminant::Static.encode(encoder); - did.encode(encoder); + // Cannot use `did.encode(encoder)` because of a bug around + // specializations and method calls. + Encodable::<E>::encode(&did, encoder); } } } diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 84b5d6b0d0fa1..111993ec7a880 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -9,6 +9,7 @@ use rustc_span::def_id::LOCAL_CRATE; pub mod erase; mod keys; +pub mod on_disk_cache; pub use keys::{AsLocalKey, Key, LocalCrate}; // Each of these queries corresponds to a function pointer field in the @@ -874,7 +875,7 @@ rustc_queries! { query typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> { desc { |tcx| "type-checking `{}`", tcx.def_path_str(key) } - cache_on_disk_if { true } + cache_on_disk_if(tcx) { !tcx.is_typeck_child(key.to_def_id()) } } query diagnostic_only_typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> { desc { |tcx| "type-checking `{}`", tcx.def_path_str(key) } diff --git a/compiler/rustc_query_impl/src/on_disk_cache.rs b/compiler/rustc_middle/src/query/on_disk_cache.rs similarity index 95% rename from compiler/rustc_query_impl/src/on_disk_cache.rs rename to compiler/rustc_middle/src/query/on_disk_cache.rs index c0f2d7803d492..e56faff5ed47c 100644 --- a/compiler/rustc_query_impl/src/on_disk_cache.rs +++ b/compiler/rustc_middle/src/query/on_disk_cache.rs @@ -1,4 +1,3 @@ -use crate::QueryCtxt; use rustc_data_structures::fx::{FxHashMap, FxIndexSet}; use rustc_data_structures::memmap::Mmap; use rustc_data_structures::stable_hasher::Hash64; @@ -13,8 +12,7 @@ use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState}; use rustc_middle::mir::{self, interpret}; use rustc_middle::ty::codec::{RefDecodable, TyDecoder, TyEncoder}; use rustc_middle::ty::{self, Ty, TyCtxt}; -use rustc_query_system::dep_graph::DepContext; -use rustc_query_system::query::{QueryCache, QuerySideEffects}; +use rustc_query_system::query::QuerySideEffects; use rustc_serialize::{ opaque::{FileEncodeResult, FileEncoder, IntEncodedWithFixedSize, MemDecoder}, Decodable, Decoder, Encodable, Encoder, @@ -123,10 +121,12 @@ struct SourceFileIndex(u32); pub struct AbsoluteBytePos(u64); impl AbsoluteBytePos { - fn new(pos: usize) -> AbsoluteBytePos { + #[inline] + pub fn new(pos: usize) -> AbsoluteBytePos { AbsoluteBytePos(pos.try_into().expect("Incremental cache file size overflowed u64.")) } + #[inline] fn to_usize(self) -> usize { self.0 as usize } @@ -144,11 +144,13 @@ struct EncodedSourceFileId { } impl EncodedSourceFileId { + #[inline] fn translate(&self, tcx: TyCtxt<'_>) -> StableSourceFileId { let cnum = tcx.stable_crate_id_to_crate_num(self.stable_crate_id); StableSourceFileId { file_name_hash: self.file_name_hash, cnum } } + #[inline] fn new(tcx: TyCtxt<'_>, file: &SourceFile) -> EncodedSourceFileId { let source_file_id = StableSourceFileId::new(file); EncodedSourceFileId { @@ -158,9 +160,9 @@ impl EncodedSourceFileId { } } -impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> { +impl<'sess> OnDiskCache<'sess> { /// Creates a new `OnDiskCache` instance from the serialized data in `data`. - fn new(sess: &'sess Session, data: Mmap, start_pos: usize) -> Self { + pub fn new(sess: &'sess Session, data: Mmap, start_pos: usize) -> Self { debug_assert!(sess.opts.incremental.is_some()); // Wrap in a scope so we can borrow `data`. @@ -193,7 +195,7 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> { } } - fn new_empty(source_map: &'sess SourceMap) -> Self { + pub fn new_empty(source_map: &'sess SourceMap) -> Self { Self { serialized_data: RwLock::new(None), file_index_to_stable_id: Default::default(), @@ -215,7 +217,7 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> { /// Cache promotions require invoking queries, which needs to read the serialized data. /// In order to serialize the new on-disk cache, the former on-disk cache file needs to be /// deleted, hence we won't be able to refer to its memmapped data. - fn drop_serialized_data(&self, tcx: TyCtxt<'_>) { + pub fn drop_serialized_data(&self, tcx: TyCtxt<'_>) { // Load everything into memory so we can write it out to the on-disk // cache. The vast majority of cacheable query results should already // be in memory, so this should be a cheap operation. @@ -227,7 +229,7 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> { *self.serialized_data.write() = None; } - fn serialize(&self, tcx: TyCtxt<'_>, encoder: FileEncoder) -> FileEncodeResult { + pub fn serialize(&self, tcx: TyCtxt<'_>, encoder: FileEncoder) -> FileEncodeResult { // Serializing the `DepGraph` should not modify it. tcx.dep_graph.with_ignore(|| { // Allocate `SourceFileIndex`es. @@ -269,7 +271,7 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> { tcx.sess.time("encode_query_results", || { let enc = &mut encoder; let qri = &mut query_result_index; - QueryCtxt::from_tcx(tcx).encode_query_results(enc, qri); + (tcx.query_system.fns.encode_query_results)(tcx, enc, qri); }); // Encode side effects. @@ -358,12 +360,6 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> { encoder.finish() }) } -} - -impl<'sess> OnDiskCache<'sess> { - pub fn as_dyn(&self) -> &dyn rustc_middle::ty::OnDiskCache<'sess> { - self as _ - } /// Loads a `QuerySideEffects` created during the previous compilation session. pub fn load_side_effects( @@ -380,8 +376,6 @@ impl<'sess> OnDiskCache<'sess> { /// Stores a `QuerySideEffects` emitted during the current compilation session. /// Anything stored like this will be available via `load_side_effects` in /// the next compilation session. - #[inline(never)] - #[cold] pub fn store_side_effects(&self, dep_node_index: DepNodeIndex, side_effects: QuerySideEffects) { let mut current_side_effects = self.current_side_effects.borrow_mut(); let prev = current_side_effects.insert(dep_node_index, side_effects); @@ -389,6 +383,7 @@ impl<'sess> OnDiskCache<'sess> { } /// Return whether the cached query result can be decoded. + #[inline] pub fn loadable_from_disk(&self, dep_node_index: SerializedDepNodeIndex) -> bool { self.query_result_index.contains_key(&dep_node_index) // with_decoder is infallible, so we can stop here @@ -413,8 +408,6 @@ impl<'sess> OnDiskCache<'sess> { /// Since many anonymous queries can share the same `DepNode`, we aggregate /// them -- as opposed to regular queries where we assume that there is a /// 1:1 relationship between query-key and `DepNode`. - #[inline(never)] - #[cold] pub fn store_side_effects_for_anon_node( &self, dep_node_index: DepNodeIndex, @@ -485,6 +478,7 @@ pub struct CacheDecoder<'a, 'tcx> { } impl<'a, 'tcx> CacheDecoder<'a, 'tcx> { + #[inline] fn file_index_to_file(&self, index: SourceFileIndex) -> Lrc<SourceFile> { let CacheDecoder { tcx, @@ -705,6 +699,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for Span { // copy&paste impl from rustc_metadata impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for Symbol { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { let tag = d.read_u8(); @@ -733,6 +728,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for Symbol { } impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for CrateNum { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { let stable_id = StableCrateId::decode(d); let cnum = d.tcx.stable_crate_id_to_crate_num(stable_id); @@ -754,6 +750,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for DefIndex { // compilation sessions. We use the `DefPathHash`, which is stable across // sessions, to map the old `DefId` to the new one. impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for DefId { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { // Load the `DefPathHash` which is was we encoded the `DefId` as. let def_path_hash = DefPathHash::decode(d); @@ -770,6 +767,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for DefId { } impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx UnordSet<LocalDefId> { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { RefDecodable::decode(d) } @@ -778,6 +776,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx UnordSet<LocalDefId> impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx FxHashMap<DefId, ty::EarlyBinder<Ty<'tcx>>> { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { RefDecodable::decode(d) } @@ -786,24 +785,28 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx IndexVec<mir::Promoted, mir::Body<'tcx>> { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { RefDecodable::decode(d) } } impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [(ty::Predicate<'tcx>, Span)] { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { RefDecodable::decode(d) } } impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [(ty::Clause<'tcx>, Span)] { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { RefDecodable::decode(d) } } impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [rustc_ast::InlineAsmTemplatePiece] { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { RefDecodable::decode(d) } @@ -812,6 +815,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [rustc_ast::InlineAsm macro_rules! impl_ref_decoder { (<$tcx:tt> $($ty:ty,)*) => { $(impl<'a, $tcx> Decodable<CacheDecoder<'a, $tcx>> for &$tcx [$ty] { + #[inline] fn decode(d: &mut CacheDecoder<'a, $tcx>) -> Self { RefDecodable::decode(d) } @@ -846,6 +850,7 @@ pub struct CacheEncoder<'a, 'tcx> { } impl<'a, 'tcx> CacheEncoder<'a, 'tcx> { + #[inline] fn source_file_index(&mut self, source_file: Lrc<SourceFile>) -> SourceFileIndex { self.file_to_file_index[&(&*source_file as *const SourceFile)] } @@ -855,7 +860,7 @@ impl<'a, 'tcx> CacheEncoder<'a, 'tcx> { /// encode the specified tag, then the given value, then the number of /// bytes taken up by tag and value. On decoding, we can then verify that /// we get the expected tag and read the expected number of bytes. - fn encode_tagged<T: Encodable<Self>, V: Encodable<Self>>(&mut self, tag: T, value: &V) { + pub fn encode_tagged<T: Encodable<Self>, V: Encodable<Self>>(&mut self, tag: T, value: &V) { let start_pos = self.position(); tag.encode(self); @@ -865,6 +870,7 @@ impl<'a, 'tcx> CacheEncoder<'a, 'tcx> { ((end_pos - start_pos) as u64).encode(self); } + #[inline] fn finish(self) -> Result<usize, io::Error> { self.encoder.finish() } @@ -957,15 +963,19 @@ impl<'a, 'tcx> TyEncoder for CacheEncoder<'a, 'tcx> { type I = TyCtxt<'tcx>; const CLEAR_CROSS_CRATE: bool = false; + #[inline] fn position(&self) -> usize { self.encoder.position() } + #[inline] fn type_shorthands(&mut self) -> &mut FxHashMap<Ty<'tcx>, usize> { &mut self.type_shorthands } + #[inline] fn predicate_shorthands(&mut self) -> &mut FxHashMap<ty::PredicateKind<'tcx>, usize> { &mut self.predicate_shorthands } + #[inline] fn encode_alloc_id(&mut self, alloc_id: &interpret::AllocId) { let (index, _) = self.interpret_allocs.insert_full(*alloc_id); @@ -974,12 +984,14 @@ impl<'a, 'tcx> TyEncoder for CacheEncoder<'a, 'tcx> { } impl<'a, 'tcx> Encodable<CacheEncoder<'a, 'tcx>> for CrateNum { + #[inline] fn encode(&self, s: &mut CacheEncoder<'a, 'tcx>) { s.tcx.stable_crate_id(*self).encode(s); } } impl<'a, 'tcx> Encodable<CacheEncoder<'a, 'tcx>> for DefId { + #[inline] fn encode(&self, s: &mut CacheEncoder<'a, 'tcx>) { s.tcx.def_path_hash(*self).encode(s); } @@ -1032,33 +1044,3 @@ impl<'a, 'tcx> Encodable<CacheEncoder<'a, 'tcx>> for [u8] { self.encode(&mut e.encoder); } } - -pub(crate) fn encode_query_results<'a, 'tcx, Q>( - query: Q, - qcx: QueryCtxt<'tcx>, - encoder: &mut CacheEncoder<'a, 'tcx>, - query_result_index: &mut EncodedDepNodeIndex, -) where - Q: super::QueryConfigRestored<'tcx>, - Q::RestoredValue: Encodable<CacheEncoder<'a, 'tcx>>, -{ - let _timer = qcx - .tcx - .profiler() - .verbose_generic_activity_with_arg("encode_query_results_for", query.name()); - - assert!(query.query_state(qcx).all_inactive()); - let cache = query.query_cache(qcx); - cache.iter(&mut |key, value, dep_node| { - if query.cache_on_disk(qcx.tcx, &key) { - let dep_node = SerializedDepNodeIndex::new(dep_node.index()); - - // Record position of the cache entry. - query_result_index.push((dep_node, AbsoluteBytePos::new(encoder.encoder.position()))); - - // Encode the type check tables with the `SerializedDepNodeIndex` - // as tag. - encoder.encode_tagged(dep_node, &Q::restore(*value)); - } - }); -} diff --git a/compiler/rustc_middle/src/ty/codec.rs b/compiler/rustc_middle/src/ty/codec.rs index 3793d85c85a41..7536903ef96fc 100644 --- a/compiler/rustc_middle/src/ty/codec.rs +++ b/compiler/rustc_middle/src/ty/codec.rs @@ -500,7 +500,6 @@ impl_arena_copy_decoder! {<'tcx> macro_rules! implement_ty_decoder { ($DecoderName:ident <$($typaram:tt),*>) => { mod __ty_decoder_impl { - use std::borrow::Cow; use rustc_serialize::Decoder; use super::$DecoderName; diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 830231646c659..a309eaf048d2a 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -14,11 +14,14 @@ use crate::middle::resolve_bound_vars; use crate::middle::stability; use crate::mir::interpret::{self, Allocation, ConstAllocation}; use crate::mir::{Body, Local, Place, PlaceElem, ProjectionKind, Promoted}; +use crate::query::on_disk_cache::OnDiskCache; use crate::query::LocalCrate; use crate::thir::Thir; use crate::traits; use crate::traits::solve; use crate::traits::solve::{ExternalConstraints, ExternalConstraintsData}; +use crate::ty::query::QuerySystem; +use crate::ty::query::QuerySystemFns; use crate::ty::query::{self, TyCtxtAt}; use crate::ty::{ self, AdtDef, AdtDefData, AdtKind, Binder, Const, ConstData, FloatTy, FloatVar, FloatVid, @@ -31,7 +34,6 @@ use rustc_ast::{self as ast, attr}; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::intern::Interned; -use rustc_data_structures::memmap::Mmap; use rustc_data_structures::profiling::SelfProfilerRef; use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; @@ -61,7 +63,6 @@ use rustc_session::lint::Lint; use rustc_session::Limit; use rustc_session::Session; use rustc_span::def_id::{DefPathHash, StableCrateId}; -use rustc_span::source_map::SourceMap; use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{Span, DUMMY_SP}; use rustc_target::abi::{FieldIdx, Layout, LayoutS, TargetDataLayout, VariantIdx}; @@ -84,21 +85,6 @@ use super::query::IntoQueryParam; const TINY_CONST_EVAL_LIMIT: Limit = Limit(20); -pub trait OnDiskCache<'tcx>: rustc_data_structures::sync::Sync { - /// Creates a new `OnDiskCache` instance from the serialized data in `data`. - fn new(sess: &'tcx Session, data: Mmap, start_pos: usize) -> Self - where - Self: Sized; - - fn new_empty(source_map: &'tcx SourceMap) -> Self - where - Self: Sized; - - fn drop_serialized_data(&self, tcx: TyCtxt<'tcx>); - - fn serialize(&self, tcx: TyCtxt<'tcx>, encoder: FileEncoder) -> FileEncodeResult; -} - #[allow(rustc::usage_of_ty_tykind)] impl<'tcx> Interner for TyCtxt<'tcx> { type AdtDef = ty::AdtDef<'tcx>; @@ -527,13 +513,6 @@ pub struct GlobalCtxt<'tcx> { untracked: Untracked, - /// This provides access to the incremental compilation on-disk cache for query results. - /// Do not access this directly. It is only meant to be used by - /// `DepGraph::try_mark_green()` and the query infrastructure. - /// This is `None` if we are not incremental compilation mode - pub on_disk_cache: Option<&'tcx dyn OnDiskCache<'tcx>>, - - pub queries: &'tcx dyn query::QueryEngine<'tcx>, pub query_system: query::QuerySystem<'tcx>, pub(crate) query_kinds: &'tcx [DepKindStruct<'tcx>], @@ -674,9 +653,9 @@ impl<'tcx> TyCtxt<'tcx> { hir_arena: &'tcx WorkerLocal<hir::Arena<'tcx>>, untracked: Untracked, dep_graph: DepGraph, - on_disk_cache: Option<&'tcx dyn OnDiskCache<'tcx>>, - queries: &'tcx dyn query::QueryEngine<'tcx>, + on_disk_cache: Option<OnDiskCache<'tcx>>, query_kinds: &'tcx [DepKindStruct<'tcx>], + query_system_fns: QuerySystemFns<'tcx>, ) -> GlobalCtxt<'tcx> { let data_layout = s.target.parse_data_layout().unwrap_or_else(|err| { s.emit_fatal(err); @@ -698,9 +677,7 @@ impl<'tcx> TyCtxt<'tcx> { lifetimes: common_lifetimes, consts: common_consts, untracked, - on_disk_cache, - queries, - query_system: Default::default(), + query_system: QuerySystem::new(query_system_fns, on_disk_cache), query_kinds, ty_rcache: Default::default(), pred_rcache: Default::default(), @@ -1039,7 +1016,7 @@ impl<'tcx> TyCtxt<'tcx> { } pub fn serialize_query_result_cache(self, encoder: FileEncoder) -> FileEncodeResult { - self.on_disk_cache.as_ref().map_or(Ok(0), |c| c.serialize(self, encoder)) + self.query_system.on_disk_cache.as_ref().map_or(Ok(0), |c| c.serialize(self, encoder)) } /// If `true`, we should use lazy normalization for constants, otherwise diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 8e4e708b73c45..db6b35026a8e7 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -84,8 +84,7 @@ pub use self::consts::{ Const, ConstData, ConstInt, ConstKind, Expr, InferConst, ScalarInt, UnevaluatedConst, ValTree, }; pub use self::context::{ - tls, CtxtInterners, DeducedParamAttrs, FreeRegionInfo, GlobalCtxt, Lift, OnDiskCache, TyCtxt, - TyCtxtFeed, + tls, CtxtInterners, DeducedParamAttrs, FreeRegionInfo, GlobalCtxt, Lift, TyCtxt, TyCtxtFeed, }; pub use self::instance::{Instance, InstanceDef, ShortInstance, UnusedGenericParams}; pub use self::list::List; diff --git a/compiler/rustc_middle/src/ty/query.rs b/compiler/rustc_middle/src/ty/query.rs index f44566284571c..07d47cae5ee93 100644 --- a/compiler/rustc_middle/src/ty/query.rs +++ b/compiler/rustc_middle/src/ty/query.rs @@ -1,6 +1,7 @@ #![allow(unused_parens)] use crate::dep_graph; +use crate::dep_graph::DepKind; use crate::infer::canonical::{self, Canonical}; use crate::lint::LintExpectation; use crate::metadata::ModChild; @@ -17,7 +18,11 @@ use crate::mir::interpret::{ }; use crate::mir::interpret::{LitToConstError, LitToConstInput}; use crate::mir::mono::CodegenUnit; + use crate::query::erase::{erase, restore, Erase}; +use crate::query::on_disk_cache::CacheEncoder; +use crate::query::on_disk_cache::EncodedDepNodeIndex; +use crate::query::on_disk_cache::OnDiskCache; use crate::query::{AsLocalKey, Key}; use crate::thir; use crate::traits::query::{ @@ -38,13 +43,16 @@ use crate::ty::subst::{GenericArg, SubstsRef}; use crate::ty::util::AlwaysRequiresDrop; use crate::ty::GeneratorDiagnosticData; use crate::ty::{self, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt, UnusedGenericParams}; +use measureme::StringId; use rustc_arena::TypedArena; use rustc_ast as ast; use rustc_ast::expand::allocator::AllocatorKind; use rustc_attr as attr; +use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; use rustc_data_structures::steal::Steal; use rustc_data_structures::svh::Svh; +use rustc_data_structures::sync::AtomicU64; use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::WorkerLocal; use rustc_data_structures::unord::UnordSet; @@ -58,6 +66,7 @@ use rustc_hir::hir_id::OwnerId; use rustc_hir::lang_items::{LangItem, LanguageItems}; use rustc_hir::{Crate, ItemLocalId, TraitCandidate}; use rustc_index::IndexVec; +use rustc_query_system::ich::StableHashingContext; pub(crate) use rustc_query_system::query::QueryJobId; use rustc_query_system::query::*; use rustc_session::config::{EntryFnType, OptLevel, OutputFilenames, SymbolManglingVersion}; @@ -76,17 +85,70 @@ use std::ops::Deref; use std::path::PathBuf; use std::sync::Arc; -use rustc_data_structures::fingerprint::Fingerprint; -use rustc_query_system::ich::StableHashingContext; +pub struct QueryKeyStringCache { + pub def_id_cache: FxHashMap<DefId, StringId>, +} + +impl QueryKeyStringCache { + pub fn new() -> QueryKeyStringCache { + QueryKeyStringCache { def_id_cache: Default::default() } + } +} + +#[derive(Clone, Copy)] +pub struct QueryStruct<'tcx> { + pub try_collect_active_jobs: fn(TyCtxt<'tcx>, &mut QueryMap<DepKind>) -> Option<()>, + pub alloc_self_profile_query_strings: fn(TyCtxt<'tcx>, &mut QueryKeyStringCache), + pub encode_query_results: + Option<fn(TyCtxt<'tcx>, &mut CacheEncoder<'_, 'tcx>, &mut EncodedDepNodeIndex)>, +} + +pub struct QuerySystemFns<'tcx> { + pub engine: QueryEngine, + pub local_providers: Providers, + pub extern_providers: ExternProviders, + pub query_structs: Vec<QueryStruct<'tcx>>, + pub encode_query_results: fn( + tcx: TyCtxt<'tcx>, + encoder: &mut CacheEncoder<'_, 'tcx>, + query_result_index: &mut EncodedDepNodeIndex, + ), + pub try_mark_green: fn(tcx: TyCtxt<'tcx>, dep_node: &dep_graph::DepNode) -> bool, +} -#[derive(Default)] pub struct QuerySystem<'tcx> { + pub states: QueryStates<'tcx>, pub arenas: QueryArenas<'tcx>, pub caches: QueryCaches<'tcx>, + + /// This provides access to the incremental compilation on-disk cache for query results. + /// Do not access this directly. It is only meant to be used by + /// `DepGraph::try_mark_green()` and the query infrastructure. + /// This is `None` if we are not incremental compilation mode + pub on_disk_cache: Option<OnDiskCache<'tcx>>, + + pub fns: QuerySystemFns<'tcx>, + + pub jobs: AtomicU64, + // Since we erase query value types we tell the typesystem about them with `PhantomData`. _phantom_values: QueryPhantomValues<'tcx>, } +impl<'tcx> QuerySystem<'tcx> { + pub fn new(fns: QuerySystemFns<'tcx>, on_disk_cache: Option<OnDiskCache<'tcx>>) -> Self { + QuerySystem { + states: Default::default(), + arenas: Default::default(), + caches: Default::default(), + on_disk_cache, + fns, + jobs: AtomicU64::new(1), + _phantom_values: Default::default(), + } + } +} + #[derive(Copy, Clone)] pub struct TyCtxtAt<'tcx> { pub tcx: TyCtxt<'tcx>, @@ -136,7 +198,41 @@ impl<'tcx> TyCtxt<'tcx> { } pub fn try_mark_green(self, dep_node: &dep_graph::DepNode) -> bool { - self.queries.try_mark_green(self, dep_node) + (self.query_system.fns.try_mark_green)(self, dep_node) + } +} + +#[inline] +fn query_get_at<'tcx, Cache>( + tcx: TyCtxt<'tcx>, + execute_query: fn(TyCtxt<'tcx>, Span, Cache::Key, QueryMode) -> Option<Cache::Value>, + query_cache: &Cache, + span: Span, + key: Cache::Key, +) -> Cache::Value +where + Cache: QueryCache, +{ + let key = key.into_query_param(); + match try_get_cached(tcx, query_cache, &key) { + Some(value) => value, + None => execute_query(tcx, span, key, QueryMode::Get).unwrap(), + } +} + +#[inline] +fn query_ensure<'tcx, Cache>( + tcx: TyCtxt<'tcx>, + execute_query: fn(TyCtxt<'tcx>, Span, Cache::Key, QueryMode) -> Option<Cache::Value>, + query_cache: &Cache, + key: Cache::Key, + check_cache: bool, +) where + Cache: QueryCache, +{ + let key = key.into_query_param(); + if try_get_cached(tcx, query_cache, &key).is_none() { + execute_query(tcx, DUMMY_SP, key, QueryMode::Ensure { check_cache }); } } @@ -345,17 +441,13 @@ macro_rules! define_callbacks { $($(#[$attr])* #[inline(always)] pub fn $name(self, key: query_helper_param_ty!($($K)*)) { - let key = key.into_query_param(); - - match try_get_cached(self.tcx, &self.tcx.query_system.caches.$name, &key) { - Some(_) => return, - None => self.tcx.queries.$name( - self.tcx, - DUMMY_SP, - key, - QueryMode::Ensure { check_cache: false }, - ), - }; + query_ensure( + self.tcx, + self.tcx.query_system.fns.engine.$name, + &self.tcx.query_system.caches.$name, + key.into_query_param(), + false, + ); })* } @@ -363,17 +455,13 @@ macro_rules! define_callbacks { $($(#[$attr])* #[inline(always)] pub fn $name(self, key: query_helper_param_ty!($($K)*)) { - let key = key.into_query_param(); - - match try_get_cached(self.tcx, &self.tcx.query_system.caches.$name, &key) { - Some(_) => return, - None => self.tcx.queries.$name( - self.tcx, - DUMMY_SP, - key, - QueryMode::Ensure { check_cache: true }, - ), - }; + query_ensure( + self.tcx, + self.tcx.query_system.fns.engine.$name, + &self.tcx.query_system.caches.$name, + key.into_query_param(), + true, + ); })* } @@ -392,15 +480,23 @@ macro_rules! define_callbacks { #[inline(always)] pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> $V { - let key = key.into_query_param(); - - restore::<$V>(match try_get_cached(self.tcx, &self.tcx.query_system.caches.$name, &key) { - Some(value) => value, - None => self.tcx.queries.$name(self.tcx, self.span, key, QueryMode::Get).unwrap(), - }) + restore::<$V>(query_get_at( + self.tcx, + self.tcx.query_system.fns.engine.$name, + &self.tcx.query_system.caches.$name, + self.span, + key.into_query_param(), + )) })* } + #[derive(Default)] + pub struct QueryStates<'tcx> { + $( + pub $name: QueryState<$($K)*, DepKind>, + )* + } + pub struct Providers { $(pub $name: for<'tcx> fn( TyCtxt<'tcx>, @@ -446,19 +542,13 @@ macro_rules! define_callbacks { fn clone(&self) -> Self { *self } } - pub trait QueryEngine<'tcx>: rustc_data_structures::sync::Sync { - fn as_any(&'tcx self) -> &'tcx dyn std::any::Any; - - fn try_mark_green(&'tcx self, tcx: TyCtxt<'tcx>, dep_node: &dep_graph::DepNode) -> bool; - - $($(#[$attr])* - fn $name( - &'tcx self, - tcx: TyCtxt<'tcx>, - span: Span, - key: query_keys::$name<'tcx>, - mode: QueryMode, - ) -> Option<Erase<$V>>;)* + pub struct QueryEngine { + $(pub $name: for<'tcx> fn( + TyCtxt<'tcx>, + Span, + query_keys::$name<'tcx>, + QueryMode, + ) -> Option<Erase<$V>>,)* } }; } diff --git a/compiler/rustc_middle/src/util/call_kind.rs b/compiler/rustc_middle/src/util/call_kind.rs index 627c84c388c04..98d55ea6d4025 100644 --- a/compiler/rustc_middle/src/util/call_kind.rs +++ b/compiler/rustc_middle/src/util/call_kind.rs @@ -19,6 +19,8 @@ pub enum CallDesugaringKind { QuestionFromResidual, /// try { ..; x } calls type_of(x)::from_output(x) TryBlockFromOutput, + /// `.await` calls `IntoFuture::into_future` + Await, } impl CallDesugaringKind { @@ -29,6 +31,7 @@ impl CallDesugaringKind { tcx.require_lang_item(LangItem::Try, None) } Self::QuestionFromResidual => tcx.get_diagnostic_item(sym::FromResidual).unwrap(), + Self::Await => tcx.get_diagnostic_item(sym::IntoFuture).unwrap(), } } } @@ -129,6 +132,8 @@ pub fn call_kind<'tcx>( && fn_call_span.desugaring_kind() == Some(DesugaringKind::TryBlock) { Some((CallDesugaringKind::TryBlockFromOutput, method_substs.type_at(0))) + } else if fn_call_span.is_desugaring(DesugaringKind::Await) { + Some((CallDesugaringKind::Await, method_substs.type_at(0))) } else { None }; diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index 2b52d70af2a44..66d29931400f1 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -334,9 +334,6 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> { let refutable = !is_let_irrefutable(&mut ncx, local_lint_level, tpat); Some((expr.span, refutable)) } - ExprKind::LogicalOp { op: LogicalOp::And, .. } => { - bug!() - } _ => None, } }; diff --git a/compiler/rustc_mir_transform/src/check_packed_ref.rs b/compiler/rustc_mir_transform/src/check_packed_ref.rs index f5f1c1010e155..b9bc89fcf8fa4 100644 --- a/compiler/rustc_mir_transform/src/check_packed_ref.rs +++ b/compiler/rustc_mir_transform/src/check_packed_ref.rs @@ -56,8 +56,11 @@ impl<'tcx> Visitor<'tcx> for PackedRefChecker<'_, 'tcx> { "reference to packed field is unaligned" ) .note( - "fields of packed structs are not properly aligned, and creating \ - a misaligned reference is undefined behavior (even if that \ + "packed structs are only aligned by one byte, and many modern architectures \ + penalize unaligned field accesses" + ) + .note( + "creating a misaligned reference is undefined behavior (even if that \ reference is never dereferenced)", ).help( "copy the field contents to a local variable, or replace the \ diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 25d7db0ee605a..8d9a22ea30ddf 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -616,13 +616,10 @@ fn promoted_mir(tcx: TyCtxt<'_>, def: LocalDefId) -> &IndexVec<Promoted, Body<'_ return tcx.arena.alloc(IndexVec::new()); } - let tainted_by_errors = tcx.mir_borrowck(def).tainted_by_errors; + tcx.ensure_with_value().mir_borrowck(def); let mut promoted = tcx.mir_promoted(def).1.steal(); for body in &mut promoted { - if let Some(error_reported) = tainted_by_errors { - body.tainted_by_errors = Some(error_reported); - } run_analysis_to_runtime_passes(tcx, body); } diff --git a/compiler/rustc_mir_transform/src/lower_intrinsics.rs b/compiler/rustc_mir_transform/src/lower_intrinsics.rs index 62b727674c5d1..69ba4840146ea 100644 --- a/compiler/rustc_mir_transform/src/lower_intrinsics.rs +++ b/compiler/rustc_mir_transform/src/lower_intrinsics.rs @@ -179,6 +179,29 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics { } } } + sym::write_via_move => { + let target = target.unwrap(); + let Ok([ptr, val]) = <[_; 2]>::try_from(std::mem::take(args)) else { + span_bug!( + terminator.source_info.span, + "Wrong number of arguments for write_via_move intrinsic", + ); + }; + let derefed_place = + if let Some(place) = ptr.place() && let Some(local) = place.as_local() { + tcx.mk_place_deref(local.into()) + } else { + span_bug!(terminator.source_info.span, "Only passing a local is supported"); + }; + block.statements.push(Statement { + source_info: terminator.source_info, + kind: StatementKind::Assign(Box::new(( + derefed_place, + Rvalue::Use(val), + ))), + }); + terminator.kind = TerminatorKind::Goto { target }; + } sym::discriminant_value => { if let (Some(target), Some(arg)) = (*target, args[0].place()) { let arg = tcx.mk_place_deref(arg); diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index c14c7f2fa0dcc..0e041df898cac 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -1646,7 +1646,7 @@ impl<'a> Parser<'a> { // Avoid knock-down errors as we don't know whether to interpret this as `foo().await?` // or `foo()?.await` (the very reason we went with postfix syntax 😅). ExprKind::Try(_) => ExprKind::Err, - _ => ExprKind::Await(expr), + _ => ExprKind::Await(expr, await_sp), }; let expr = self.mk_expr(lo.to(sp), kind); self.maybe_recover_from_bad_qpath(expr) diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 27de9bd72685f..bff9de5c652f9 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -859,7 +859,7 @@ impl<'a> Parser<'a> { ExprKind::Field(_, _) => "a field access", ExprKind::MethodCall(_) => "a method call", ExprKind::Call(_, _) => "a function call", - ExprKind::Await(_) => "`.await`", + ExprKind::Await(_, _) => "`.await`", ExprKind::Err => return Ok(with_postfix), _ => unreachable!("parse_dot_or_call_expr_with_ shouldn't produce this"), } @@ -3252,7 +3252,7 @@ impl<'a> Parser<'a> { fn mk_await_expr(&mut self, self_arg: P<Expr>, lo: Span) -> P<Expr> { let span = lo.to(self.prev_token.span); - let await_expr = self.mk_expr(span, ExprKind::Await(self_arg)); + let await_expr = self.mk_expr(span, ExprKind::Await(self_arg, self.prev_token.span)); self.recover_from_await_method_call(); await_expr } diff --git a/compiler/rustc_query_impl/src/lib.rs b/compiler/rustc_query_impl/src/lib.rs index 7001a1eed57e7..82b335f4b4b57 100644 --- a/compiler/rustc_query_impl/src/lib.rs +++ b/compiler/rustc_query_impl/src/lib.rs @@ -11,12 +11,10 @@ #![deny(rustc::untranslatable_diagnostic)] #![deny(rustc::diagnostic_outside_of_impl)] -#[macro_use] -extern crate rustc_macros; #[macro_use] extern crate rustc_middle; -use rustc_data_structures::sync::AtomicU64; +use crate::plumbing::{encode_all_query_results, try_mark_green}; use rustc_middle::arena::Arena; use rustc_middle::dep_graph::{self, DepKind, DepKindStruct}; use rustc_middle::query::erase::{erase, restore, Erase}; @@ -24,7 +22,7 @@ use rustc_middle::query::AsLocalKey; use rustc_middle::ty::query::{ query_keys, query_provided, query_provided_to_value, query_storage, query_values, }; -use rustc_middle::ty::query::{ExternProviders, Providers, QueryEngine}; +use rustc_middle::ty::query::{ExternProviders, Providers, QueryEngine, QuerySystemFns}; use rustc_middle::ty::TyCtxt; use rustc_query_system::dep_graph::SerializedDepNodeIndex; use rustc_query_system::Value; @@ -32,15 +30,10 @@ use rustc_span::Span; #[macro_use] mod plumbing; -pub use plumbing::QueryCtxt; -use rustc_query_system::query::*; -#[cfg(parallel_compiler)] -pub use rustc_query_system::query::{deadlock, QueryContext}; +pub use crate::plumbing::QueryCtxt; pub use rustc_query_system::query::QueryConfig; - -mod on_disk_cache; -pub use on_disk_cache::OnDiskCache; +use rustc_query_system::query::*; mod profiling_support; pub use self::profiling_support::alloc_self_profile_query_strings; @@ -54,9 +47,16 @@ trait QueryConfigRestored<'tcx>: QueryConfig<QueryCtxt<'tcx>> + Default { rustc_query_append! { define_queries! } -impl<'tcx> Queries<'tcx> { - // Force codegen in the dyn-trait transformation in this crate. - pub fn as_dyn(&'tcx self) -> &'tcx dyn QueryEngine<'tcx> { - self +pub fn query_system_fns<'tcx>( + local_providers: Providers, + extern_providers: ExternProviders, +) -> QuerySystemFns<'tcx> { + QuerySystemFns { + engine: engine(), + local_providers, + extern_providers, + query_structs: make_dep_kind_array!(query_structs).to_vec(), + encode_query_results: encode_all_query_results, + try_mark_green: try_mark_green, } } diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index 32222df25d496..9f8ac7ccd0b8e 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -2,35 +2,44 @@ //! generate the actual methods on tcx which find and execute the provider, //! manage the caches, and so forth. -use crate::on_disk_cache::{CacheDecoder, CacheEncoder, EncodedDepNodeIndex}; -use crate::profiling_support::QueryKeyStringCache; -use crate::{on_disk_cache, Queries}; +use crate::rustc_middle::dep_graph::DepContext; +use crate::rustc_middle::ty::TyEncoder; use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher}; -use rustc_data_structures::sync::{AtomicU64, Lock}; -use rustc_errors::{Diagnostic, Handler}; +use rustc_data_structures::sync::Lock; +use rustc_errors::Diagnostic; +use rustc_index::Idx; use rustc_middle::dep_graph::{ self, DepKind, DepKindStruct, DepNode, DepNodeIndex, SerializedDepNodeIndex, }; +use rustc_middle::query::on_disk_cache::AbsoluteBytePos; +use rustc_middle::query::on_disk_cache::{CacheDecoder, CacheEncoder, EncodedDepNodeIndex}; use rustc_middle::query::Key; use rustc_middle::ty::tls::{self, ImplicitCtxt}; use rustc_middle::ty::{self, TyCtxt}; use rustc_query_system::dep_graph::{DepNodeParams, HasDepContext}; use rustc_query_system::ich::StableHashingContext; use rustc_query_system::query::{ - force_query, QueryConfig, QueryContext, QueryJobId, QueryMap, QuerySideEffects, QueryStackFrame, + force_query, QueryCache, QueryConfig, QueryContext, QueryJobId, QueryMap, QuerySideEffects, + QueryStackFrame, }; use rustc_query_system::{LayoutOfDepth, QueryOverflow}; use rustc_serialize::Decodable; +use rustc_serialize::Encodable; use rustc_session::Limit; use rustc_span::def_id::LOCAL_CRATE; -use std::any::Any; use std::num::NonZeroU64; use thin_vec::ThinVec; #[derive(Copy, Clone)] pub struct QueryCtxt<'tcx> { pub tcx: TyCtxt<'tcx>, - pub queries: &'tcx Queries<'tcx>, +} + +impl<'tcx> QueryCtxt<'tcx> { + #[inline] + pub fn new(tcx: TyCtxt<'tcx>) -> Self { + QueryCtxt { tcx } + } } impl<'tcx> std::ops::Deref for QueryCtxt<'tcx> { @@ -53,44 +62,56 @@ impl<'tcx> HasDepContext for QueryCtxt<'tcx> { } impl QueryContext for QueryCtxt<'_> { + #[inline] fn next_job_id(self) -> QueryJobId { QueryJobId( NonZeroU64::new( - self.queries.jobs.fetch_add(1, rustc_data_structures::sync::Ordering::Relaxed), + self.query_system.jobs.fetch_add(1, rustc_data_structures::sync::Ordering::Relaxed), ) .unwrap(), ) } + #[inline] fn current_query_job(self) -> Option<QueryJobId> { - tls::with_related_context(*self, |icx| icx.query) + tls::with_related_context(self.tcx, |icx| icx.query) } fn try_collect_active_jobs(self) -> Option<QueryMap<DepKind>> { - self.queries.try_collect_active_jobs(*self) + let mut jobs = QueryMap::default(); + + for query in &self.query_system.fns.query_structs { + (query.try_collect_active_jobs)(self.tcx, &mut jobs); + } + + Some(jobs) } // Interactions with on_disk_cache fn load_side_effects(self, prev_dep_node_index: SerializedDepNodeIndex) -> QuerySideEffects { - self.queries + self.query_system .on_disk_cache .as_ref() - .map(|c| c.load_side_effects(*self, prev_dep_node_index)) + .map(|c| c.load_side_effects(self.tcx, prev_dep_node_index)) .unwrap_or_default() } + #[inline(never)] + #[cold] fn store_side_effects(self, dep_node_index: DepNodeIndex, side_effects: QuerySideEffects) { - if let Some(c) = self.queries.on_disk_cache.as_ref() { + if let Some(c) = self.query_system.on_disk_cache.as_ref() { c.store_side_effects(dep_node_index, side_effects) } } + #[inline(never)] + #[cold] fn store_side_effects_for_anon_node( self, dep_node_index: DepNodeIndex, side_effects: QuerySideEffects, ) { - if let Some(c) = self.queries.on_disk_cache.as_ref() { + if let Some(c) = self.query_system.on_disk_cache.as_ref() { c.store_side_effects_for_anon_node(dep_node_index, side_effects) } } @@ -109,14 +130,14 @@ impl QueryContext for QueryCtxt<'_> { // The `TyCtxt` stored in TLS has the same global interner lifetime // as `self`, so we use `with_related_context` to relate the 'tcx lifetimes // when accessing the `ImplicitCtxt`. - tls::with_related_context(*self, move |current_icx| { + tls::with_related_context(self.tcx, move |current_icx| { if depth_limit && !self.recursion_limit().value_within_limit(current_icx.query_depth) { self.depth_limit_error(token); } // Update the `ImplicitCtxt` to point to our new query job. let new_icx = ImplicitCtxt { - tcx: *self, + tcx: self.tcx, query: Some(token), diagnostics, query_depth: current_icx.query_depth + depth_limit as usize, @@ -152,51 +173,20 @@ impl QueryContext for QueryCtxt<'_> { } } -impl<'tcx> QueryCtxt<'tcx> { - #[inline] - pub fn from_tcx(tcx: TyCtxt<'tcx>) -> Self { - let queries = tcx.queries.as_any(); - let queries = unsafe { - let queries = std::mem::transmute::<&dyn Any, &dyn Any>(queries); - let queries = queries.downcast_ref().unwrap(); - let queries = std::mem::transmute::<&Queries<'_>, &Queries<'_>>(queries); - queries - }; - QueryCtxt { tcx, queries } - } - - pub(crate) fn on_disk_cache(self) -> Option<&'tcx on_disk_cache::OnDiskCache<'tcx>> { - self.queries.on_disk_cache.as_ref() - } +pub(super) fn try_mark_green<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &dep_graph::DepNode) -> bool { + tcx.dep_graph.try_mark_green(QueryCtxt::new(tcx), dep_node).is_some() +} - pub(super) fn encode_query_results( - self, - encoder: &mut CacheEncoder<'_, 'tcx>, - query_result_index: &mut EncodedDepNodeIndex, - ) { - for query in &self.queries.query_structs { - if let Some(encode) = query.encode_query_results { - encode(self, encoder, query_result_index); - } +pub(super) fn encode_all_query_results<'tcx>( + tcx: TyCtxt<'tcx>, + encoder: &mut CacheEncoder<'_, 'tcx>, + query_result_index: &mut EncodedDepNodeIndex, +) { + for query in &tcx.query_system.fns.query_structs { + if let Some(encode) = query.encode_query_results { + encode(tcx, encoder, query_result_index); } } - - pub fn try_print_query_stack( - self, - query: Option<QueryJobId>, - handler: &Handler, - num_frames: Option<usize>, - ) -> usize { - rustc_query_system::query::print_query_stack(self, query, handler, num_frames) - } -} - -#[derive(Clone, Copy)] -pub(crate) struct QueryStruct<'tcx> { - pub try_collect_active_jobs: fn(QueryCtxt<'tcx>, &mut QueryMap<DepKind>) -> Option<()>, - pub alloc_self_profile_query_strings: fn(TyCtxt<'tcx>, &mut QueryKeyStringCache), - pub encode_query_results: - Option<fn(QueryCtxt<'tcx>, &mut CacheEncoder<'_, 'tcx>, &mut EncodedDepNodeIndex)>, } macro_rules! handle_cycle_error { @@ -276,13 +266,13 @@ macro_rules! hash_result { macro_rules! call_provider { ([][$qcx:expr, $name:ident, $key:expr]) => {{ - ($qcx.queries.local_providers.$name)($qcx.tcx, $key) + ($qcx.query_system.fns.local_providers.$name)($qcx, $key) }}; ([(separate_provide_extern) $($rest:tt)*][$qcx:expr, $name:ident, $key:expr]) => {{ if let Some(key) = $key.as_local_key() { - ($qcx.queries.local_providers.$name)($qcx.tcx, key) + ($qcx.query_system.fns.local_providers.$name)($qcx, key) } else { - ($qcx.queries.extern_providers.$name)($qcx.tcx, $key) + ($qcx.query_system.fns.extern_providers.$name)($qcx, $key) } }}; ([$other:tt $($modifiers:tt)*][$($args:tt)*]) => { @@ -306,7 +296,7 @@ pub(crate) fn create_query_frame< 'tcx, K: Copy + Key + for<'a> HashStable<StableHashingContext<'a>>, >( - tcx: QueryCtxt<'tcx>, + tcx: TyCtxt<'tcx>, do_describe: fn(TyCtxt<'tcx>, K) -> String, key: K, kind: DepKind, @@ -318,7 +308,7 @@ pub(crate) fn create_query_frame< // Showing visible path instead of any path is not that important in production. ty::print::with_no_visible_paths!( // Force filename-line mode to avoid invoking `type_of` query. - ty::print::with_forced_impl_filename_line!(do_describe(tcx.tcx, key)) + ty::print::with_forced_impl_filename_line!(do_describe(tcx, key)) ) ); let description = @@ -328,7 +318,7 @@ pub(crate) fn create_query_frame< // so exit to avoid infinite recursion. None } else { - Some(key.default_span(*tcx)) + Some(key.default_span(tcx)) }; let def_id = key.key_as_def_id(); let def_kind = if kind == dep_graph::DepKind::opt_def_kind { @@ -350,6 +340,34 @@ pub(crate) fn create_query_frame< QueryStackFrame::new(description, span, def_id, def_kind, kind, ty_adt_id, hash) } +pub(crate) fn encode_query_results<'a, 'tcx, Q>( + query: Q, + qcx: QueryCtxt<'tcx>, + encoder: &mut CacheEncoder<'a, 'tcx>, + query_result_index: &mut EncodedDepNodeIndex, +) where + Q: super::QueryConfigRestored<'tcx>, + Q::RestoredValue: Encodable<CacheEncoder<'a, 'tcx>>, +{ + let _timer = + qcx.profiler().verbose_generic_activity_with_arg("encode_query_results_for", query.name()); + + assert!(query.query_state(qcx).all_inactive()); + let cache = query.query_cache(qcx); + cache.iter(&mut |key, value, dep_node| { + if query.cache_on_disk(qcx.tcx, &key) { + let dep_node = SerializedDepNodeIndex::new(dep_node.index()); + + // Record position of the cache entry. + query_result_index.push((dep_node, AbsoluteBytePos::new(encoder.position()))); + + // Encode the type check tables with the `SerializedDepNodeIndex` + // as tag. + encoder.encode_tagged(dep_node, &Q::restore(*value)); + } + }); +} + fn try_load_from_on_disk_cache<'tcx, Q>(query: Q, tcx: TyCtxt<'tcx>, dep_node: DepNode) where Q: QueryConfig<QueryCtxt<'tcx>>, @@ -364,8 +382,8 @@ where } } -pub(crate) fn loadable_from_disk<'tcx>(tcx: QueryCtxt<'tcx>, id: SerializedDepNodeIndex) -> bool { - if let Some(cache) = tcx.on_disk_cache().as_ref() { +pub(crate) fn loadable_from_disk<'tcx>(tcx: TyCtxt<'tcx>, id: SerializedDepNodeIndex) -> bool { + if let Some(cache) = tcx.query_system.on_disk_cache.as_ref() { cache.loadable_from_disk(id) } else { false @@ -373,13 +391,13 @@ pub(crate) fn loadable_from_disk<'tcx>(tcx: QueryCtxt<'tcx>, id: SerializedDepNo } pub(crate) fn try_load_from_disk<'tcx, V>( - tcx: QueryCtxt<'tcx>, + tcx: TyCtxt<'tcx>, id: SerializedDepNodeIndex, ) -> Option<V> where V: for<'a> Decodable<CacheDecoder<'a, 'tcx>>, { - tcx.on_disk_cache().as_ref()?.try_load_query_result(*tcx, id) + tcx.query_system.on_disk_cache.as_ref()?.try_load_query_result(tcx, id) } fn force_from_dep_node<'tcx, Q>(query: Q, tcx: TyCtxt<'tcx>, dep_node: DepNode) -> bool @@ -407,8 +425,7 @@ where if let Some(key) = Q::Key::recover(tcx, &dep_node) { #[cfg(debug_assertions)] let _guard = tracing::span!(tracing::Level::TRACE, stringify!($name), ?key).entered(); - let tcx = QueryCtxt::from_tcx(tcx); - force_query(query, tcx, key, dep_node); + force_query(query, QueryCtxt::new(tcx), key, dep_node); true } else { false @@ -461,8 +478,33 @@ macro_rules! define_queries { ( $($(#[$attr:meta])* [$($modifiers:tt)*] fn $name:ident($($K:tt)*) -> $V:ty,)*) => { - define_queries_struct! { - input: ($(([$($modifiers)*] [$($attr)*] [$name]))*) + mod get_query { + use super::*; + + $( + #[inline(always)] + #[tracing::instrument(level = "trace", skip(tcx))] + pub(super) fn $name<'tcx>( + tcx: TyCtxt<'tcx>, + span: Span, + key: query_keys::$name<'tcx>, + mode: QueryMode, + ) -> Option<Erase<query_values::$name<'tcx>>> { + get_query( + queries::$name::default(), + QueryCtxt::new(tcx), + span, + key, + mode + ) + } + )* + } + + pub(crate) fn engine() -> QueryEngine { + QueryEngine { + $($name: get_query::$name,)* + } } #[allow(nonstandard_style)] @@ -502,7 +544,7 @@ macro_rules! define_queries { fn query_state<'a>(self, tcx: QueryCtxt<'tcx>) -> &'a QueryState<Self::Key, crate::dep_graph::DepKind> where QueryCtxt<'tcx>: 'a { - &tcx.queries.$name + &tcx.query_system.states.$name } #[inline(always)] @@ -521,7 +563,7 @@ macro_rules! define_queries { fn compute(self, qcx: QueryCtxt<'tcx>, key: Self::Key) -> Self::Value { query_provided_to_value::$name( qcx.tcx, - call_provider!([$($modifiers)*][qcx, $name, key]) + call_provider!([$($modifiers)*][qcx.tcx, $name, key]) ) } @@ -535,7 +577,7 @@ macro_rules! define_queries { if ::rustc_middle::query::cached::$name(_qcx.tcx, _key) { Some(|qcx: QueryCtxt<'tcx>, dep_node| { let value = $crate::plumbing::try_load_from_disk::<query_provided::$name<'tcx>>( - qcx, + qcx.tcx, dep_node ); value.map(|value| query_provided_to_value::$name(qcx.tcx, value)) @@ -557,7 +599,7 @@ macro_rules! define_queries { ) -> bool { should_ever_cache_on_disk!([$($modifiers)*] { self.cache_on_disk(_qcx.tcx, _key) && - $crate::plumbing::loadable_from_disk(_qcx, _index) + $crate::plumbing::loadable_from_disk(_qcx.tcx, _index) } { false }) @@ -684,14 +726,13 @@ macro_rules! define_queries { } mod query_structs { - use rustc_middle::ty::TyCtxt; - use $crate::plumbing::{QueryStruct, QueryCtxt}; - use $crate::profiling_support::QueryKeyStringCache; - use rustc_query_system::query::QueryMap; + use super::*; + use rustc_middle::ty::query::QueryStruct; + use rustc_middle::ty::query::QueryKeyStringCache; use rustc_middle::dep_graph::DepKind; pub(super) const fn dummy_query_struct<'tcx>() -> QueryStruct<'tcx> { - fn noop_try_collect_active_jobs(_: QueryCtxt<'_>, _: &mut QueryMap<DepKind>) -> Option<()> { + fn noop_try_collect_active_jobs(_: TyCtxt<'_>, _: &mut QueryMap<DepKind>) -> Option<()> { None } fn noop_alloc_self_profile_query_strings(_: TyCtxt<'_>, _: &mut QueryKeyStringCache) {} @@ -717,7 +758,7 @@ macro_rules! define_queries { let name = stringify!($name); $crate::plumbing::create_query_frame(tcx, rustc_middle::query::descs::$name, key, kind, name) }; - tcx.queries.$name.try_collect_active_jobs( + tcx.query_system.states.$name.try_collect_active_jobs( tcx, make_query, qmap, @@ -731,10 +772,10 @@ macro_rules! define_queries { string_cache, ) }, - encode_query_results: expand_if_cached!([$($modifiers)*], |qcx, encoder, query_result_index| - $crate::on_disk_cache::encode_query_results::<super::queries::$name<'tcx>>( + encode_query_results: expand_if_cached!([$($modifiers)*], |tcx, encoder, query_result_index| + $crate::plumbing::encode_query_results::<super::queries::$name<'tcx>>( super::queries::$name::default(), - qcx, + QueryCtxt::new(tcx), encoder, query_result_index, ) @@ -747,93 +788,3 @@ macro_rules! define_queries { } } } - -use crate::{ExternProviders, OnDiskCache, Providers}; - -impl<'tcx> Queries<'tcx> { - pub fn new( - local_providers: Providers, - extern_providers: ExternProviders, - on_disk_cache: Option<OnDiskCache<'tcx>>, - ) -> Self { - use crate::query_structs; - Queries { - local_providers: Box::new(local_providers), - extern_providers: Box::new(extern_providers), - query_structs: make_dep_kind_array!(query_structs).to_vec(), - on_disk_cache, - jobs: AtomicU64::new(1), - ..Queries::default() - } - } -} - -macro_rules! define_queries_struct { - ( - input: ($(([$($modifiers:tt)*] [$($attr:tt)*] [$name:ident]))*)) => { - #[derive(Default)] - pub struct Queries<'tcx> { - local_providers: Box<Providers>, - extern_providers: Box<ExternProviders>, - query_structs: Vec<$crate::plumbing::QueryStruct<'tcx>>, - pub on_disk_cache: Option<OnDiskCache<'tcx>>, - jobs: AtomicU64, - - $( - $(#[$attr])* - $name: QueryState< - <queries::$name<'tcx> as QueryConfig<QueryCtxt<'tcx>>>::Key, - rustc_middle::dep_graph::DepKind, - >, - )* - } - - impl<'tcx> Queries<'tcx> { - pub(crate) fn try_collect_active_jobs( - &'tcx self, - tcx: TyCtxt<'tcx>, - ) -> Option<QueryMap<rustc_middle::dep_graph::DepKind>> { - let tcx = QueryCtxt { tcx, queries: self }; - let mut jobs = QueryMap::default(); - - for query in &self.query_structs { - (query.try_collect_active_jobs)(tcx, &mut jobs); - } - - Some(jobs) - } - } - - impl<'tcx> QueryEngine<'tcx> for Queries<'tcx> { - fn as_any(&'tcx self) -> &'tcx dyn std::any::Any { - let this = unsafe { std::mem::transmute::<&Queries<'_>, &Queries<'_>>(self) }; - this as _ - } - - fn try_mark_green(&'tcx self, tcx: TyCtxt<'tcx>, dep_node: &dep_graph::DepNode) -> bool { - let qcx = QueryCtxt { tcx, queries: self }; - tcx.dep_graph.try_mark_green(qcx, dep_node).is_some() - } - - $($(#[$attr])* - #[inline(always)] - #[tracing::instrument(level = "trace", skip(self, tcx))] - fn $name( - &'tcx self, - tcx: TyCtxt<'tcx>, - span: Span, - key: query_keys::$name<'tcx>, - mode: QueryMode, - ) -> Option<Erase<query_values::$name<'tcx>>> { - let qcx = QueryCtxt { tcx, queries: self }; - get_query( - queries::$name::default(), - qcx, - span, - key, - mode - ) - })* - } - }; -} diff --git a/compiler/rustc_query_impl/src/profiling_support.rs b/compiler/rustc_query_impl/src/profiling_support.rs index 08b588a8c94a4..7d9306f8087ed 100644 --- a/compiler/rustc_query_impl/src/profiling_support.rs +++ b/compiler/rustc_query_impl/src/profiling_support.rs @@ -1,24 +1,13 @@ -use crate::QueryCtxt; use measureme::{StringComponent, StringId}; -use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::profiling::SelfProfiler; use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, LOCAL_CRATE}; use rustc_hir::definitions::DefPathData; +use rustc_middle::ty::query::QueryKeyStringCache; use rustc_middle::ty::TyCtxt; use rustc_query_system::query::QueryCache; use std::fmt::Debug; use std::io::Write; -pub(crate) struct QueryKeyStringCache { - def_id_cache: FxHashMap<DefId, StringId>, -} - -impl QueryKeyStringCache { - fn new() -> QueryKeyStringCache { - QueryKeyStringCache { def_id_cache: Default::default() } - } -} - struct QueryKeyStringBuilder<'p, 'tcx> { profiler: &'p SelfProfiler, tcx: TyCtxt<'tcx>, @@ -253,9 +242,8 @@ pub fn alloc_self_profile_query_strings(tcx: TyCtxt<'_>) { } let mut string_cache = QueryKeyStringCache::new(); - let queries = QueryCtxt::from_tcx(tcx); - for query in &queries.queries.query_structs { + for query in &tcx.query_system.fns.query_structs { (query.alloc_self_profile_query_strings)(tcx, &mut string_cache); } } diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index bce01debc53b0..3b17c665fb7e9 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -236,7 +236,7 @@ pub(crate) struct CycleError<D: DepKind> { /// It returns the shard index and a lock guard to the shard, /// which will be used if the query is not in the cache and we need /// to compute it. -#[inline] +#[inline(always)] pub fn try_get_cached<Tcx, C>(tcx: Tcx, cache: &C, key: &C::Key) -> Option<C::Value> where C: QueryCache, diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 5c02e7193a216..511ae8516a866 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -656,7 +656,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast, fn visit_anon_const(&mut self, constant: &'ast AnonConst) { // We deal with repeat expressions explicitly in `resolve_expr`. self.with_lifetime_rib(LifetimeRibKind::AnonConst, |this| { - this.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Static), |this| { + this.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| { this.resolve_anon_const(constant, IsRepeatExpr::No); }) }) @@ -4126,7 +4126,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> { ExprKind::Repeat(ref elem, ref ct) => { self.visit_expr(elem); self.with_lifetime_rib(LifetimeRibKind::AnonConst, |this| { - this.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Static), |this| { + this.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| { this.resolve_anon_const(ct, IsRepeatExpr::Yes) }) }); diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 14a8e8ff7271c..aa22140c99d52 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1190,6 +1190,7 @@ impl Session { /// Returns the number of query threads that should be used for this /// compilation + #[inline] pub fn threads(&self) -> usize { self.opts.unstable_opts.threads } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index c261995621988..31bbdb2a3bc65 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -207,6 +207,7 @@ symbols! { Input, Into, IntoDiagnostic, + IntoFuture, IntoIterator, IoRead, IoWrite, @@ -1635,6 +1636,7 @@ symbols! { write_bytes, write_macro, write_str, + write_via_move, writeln_macro, x87_reg, xer, diff --git a/compiler/rustc_target/src/spec/abi.rs b/compiler/rustc_target/src/spec/abi.rs index 5582d909f6b10..eb3f66ac308dd 100644 --- a/compiler/rustc_target/src/spec/abi.rs +++ b/compiler/rustc_target/src/spec/abi.rs @@ -148,8 +148,9 @@ pub fn is_enabled( pub fn is_stable(name: &str) -> Result<(), AbiDisabled> { match name { // Stable - "Rust" | "C" | "cdecl" | "stdcall" | "fastcall" | "aapcs" | "win64" | "sysv64" - | "system" | "efiapi" => Ok(()), + "Rust" | "C" | "C-unwind" | "cdecl" | "cdecl-unwind" | "stdcall" | "stdcall-unwind" + | "fastcall" | "fastcall-unwind" | "aapcs" | "aapcs-unwind" | "win64" | "win64-unwind" + | "sysv64" | "sysv64-unwind" | "system" | "system-unwind" | "efiapi" => Ok(()), "rust-intrinsic" => Err(AbiDisabled::Unstable { feature: sym::intrinsics, explain: "intrinsics are subject to change", @@ -162,10 +163,18 @@ pub fn is_stable(name: &str) -> Result<(), AbiDisabled> { feature: sym::abi_vectorcall, explain: "vectorcall is experimental and subject to change", }), + "vectorcall-unwind" => Err(AbiDisabled::Unstable { + feature: sym::abi_vectorcall, + explain: "vectorcall-unwind ABI is experimental and subject to change", + }), "thiscall" => Err(AbiDisabled::Unstable { feature: sym::abi_thiscall, explain: "thiscall is experimental and subject to change", }), + "thiscall-unwind" => Err(AbiDisabled::Unstable { + feature: sym::abi_thiscall, + explain: "thiscall-unwind ABI is experimental and subject to change", + }), "rust-call" => Err(AbiDisabled::Unstable { feature: sym::unboxed_closures, explain: "rust-call ABI is subject to change", @@ -202,46 +211,6 @@ pub fn is_stable(name: &str) -> Result<(), AbiDisabled> { feature: sym::abi_c_cmse_nonsecure_call, explain: "C-cmse-nonsecure-call ABI is experimental and subject to change", }), - "C-unwind" => Err(AbiDisabled::Unstable { - feature: sym::c_unwind, - explain: "C-unwind ABI is experimental and subject to change", - }), - "stdcall-unwind" => Err(AbiDisabled::Unstable { - feature: sym::c_unwind, - explain: "stdcall-unwind ABI is experimental and subject to change", - }), - "system-unwind" => Err(AbiDisabled::Unstable { - feature: sym::c_unwind, - explain: "system-unwind ABI is experimental and subject to change", - }), - "thiscall-unwind" => Err(AbiDisabled::Unstable { - feature: sym::c_unwind, - explain: "thiscall-unwind ABI is experimental and subject to change", - }), - "cdecl-unwind" => Err(AbiDisabled::Unstable { - feature: sym::c_unwind, - explain: "cdecl-unwind ABI is experimental and subject to change", - }), - "fastcall-unwind" => Err(AbiDisabled::Unstable { - feature: sym::c_unwind, - explain: "fastcall-unwind ABI is experimental and subject to change", - }), - "vectorcall-unwind" => Err(AbiDisabled::Unstable { - feature: sym::c_unwind, - explain: "vectorcall-unwind ABI is experimental and subject to change", - }), - "aapcs-unwind" => Err(AbiDisabled::Unstable { - feature: sym::c_unwind, - explain: "aapcs-unwind ABI is experimental and subject to change", - }), - "win64-unwind" => Err(AbiDisabled::Unstable { - feature: sym::c_unwind, - explain: "win64-unwind ABI is experimental and subject to change", - }), - "sysv64-unwind" => Err(AbiDisabled::Unstable { - feature: sym::c_unwind, - explain: "sysv64-unwind ABI is experimental and subject to change", - }), "wasm" => Err(AbiDisabled::Unstable { feature: sym::wasm_abi, explain: "wasm ABI is experimental and subject to change", diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index c969e5d4975fc..595f6e0b9271b 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -1583,55 +1583,68 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { } fn suggest_remove_await(&self, obligation: &PredicateObligation<'tcx>, err: &mut Diagnostic) { - let span = obligation.cause.span; - - if let ObligationCauseCode::AwaitableExpr(hir_id) = obligation.cause.code().peel_derives() { - let hir = self.tcx.hir(); - if let Some(hir::Node::Expr(expr)) = hir_id.and_then(|hir_id| hir.find(hir_id)) { - // FIXME: use `obligation.predicate.kind()...trait_ref.self_ty()` to see if we have `()` - // and if not maybe suggest doing something else? If we kept the expression around we - // could also check if it is an fn call (very likely) and suggest changing *that*, if - // it is from the local crate. + let hir = self.tcx.hir(); + if let ObligationCauseCode::AwaitableExpr(Some(hir_id)) = obligation.cause.code().peel_derives() + && let hir::Node::Expr(expr) = hir.get(*hir_id) + { + // FIXME: use `obligation.predicate.kind()...trait_ref.self_ty()` to see if we have `()` + // and if not maybe suggest doing something else? If we kept the expression around we + // could also check if it is an fn call (very likely) and suggest changing *that*, if + // it is from the local crate. + + // use nth(1) to skip one layer of desugaring from `IntoIter::into_iter` + if let Some((_, hir::Node::Expr(await_expr))) = hir.parent_iter(*hir_id).nth(1) + && let Some(expr_span) = expr.span.find_ancestor_inside(await_expr.span) + { + let removal_span = self.tcx + .sess + .source_map() + .span_extend_while(expr_span, char::is_whitespace) + .unwrap_or(expr_span) + .shrink_to_hi() + .to(await_expr.span.shrink_to_hi()); err.span_suggestion( - span, + removal_span, "remove the `.await`", "", Applicability::MachineApplicable, ); - // FIXME: account for associated `async fn`s. - if let hir::Expr { span, kind: hir::ExprKind::Call(base, _), .. } = expr { - if let ty::PredicateKind::Clause(ty::Clause::Trait(pred)) = - obligation.predicate.kind().skip_binder() + } else { + err.span_label(obligation.cause.span, "remove the `.await`"); + } + // FIXME: account for associated `async fn`s. + if let hir::Expr { span, kind: hir::ExprKind::Call(base, _), .. } = expr { + if let ty::PredicateKind::Clause(ty::Clause::Trait(pred)) = + obligation.predicate.kind().skip_binder() + { + err.span_label(*span, &format!("this call returns `{}`", pred.self_ty())); + } + if let Some(typeck_results) = &self.typeck_results + && let ty = typeck_results.expr_ty_adjusted(base) + && let ty::FnDef(def_id, _substs) = ty.kind() + && let Some(hir::Node::Item(hir::Item { ident, span, vis_span, .. })) = + hir.get_if_local(*def_id) { - err.span_label(*span, &format!("this call returns `{}`", pred.self_ty())); - } - if let Some(typeck_results) = &self.typeck_results - && let ty = typeck_results.expr_ty_adjusted(base) - && let ty::FnDef(def_id, _substs) = ty.kind() - && let Some(hir::Node::Item(hir::Item { ident, span, vis_span, .. })) = - hir.get_if_local(*def_id) - { - let msg = format!( - "alternatively, consider making `fn {}` asynchronous", - ident + let msg = format!( + "alternatively, consider making `fn {}` asynchronous", + ident + ); + if vis_span.is_empty() { + err.span_suggestion_verbose( + span.shrink_to_lo(), + &msg, + "async ", + Applicability::MaybeIncorrect, + ); + } else { + err.span_suggestion_verbose( + vis_span.shrink_to_hi(), + &msg, + " async", + Applicability::MaybeIncorrect, ); - if vis_span.is_empty() { - err.span_suggestion_verbose( - span.shrink_to_lo(), - &msg, - "async ", - Applicability::MaybeIncorrect, - ); - } else { - err.span_suggestion_verbose( - vis_span.shrink_to_hi(), - &msg, - " async", - Applicability::MaybeIncorrect, - ); - } } - } + } } } } diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index ad86c19309831..1768687e8cd02 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -1455,9 +1455,36 @@ where } } +/// Specialization trait used for `From<&[T]>`. +#[cfg(not(no_global_oom_handling))] +trait BoxFromSlice<T> { + fn from_slice(slice: &[T]) -> Self; +} + +#[cfg(not(no_global_oom_handling))] +impl<T: Clone> BoxFromSlice<T> for Box<[T]> { + #[inline] + default fn from_slice(slice: &[T]) -> Self { + slice.to_vec().into_boxed_slice() + } +} + +#[cfg(not(no_global_oom_handling))] +impl<T: Copy> BoxFromSlice<T> for Box<[T]> { + #[inline] + fn from_slice(slice: &[T]) -> Self { + let len = slice.len(); + let buf = RawVec::with_capacity(len); + unsafe { + ptr::copy_nonoverlapping(slice.as_ptr(), buf.ptr(), len); + buf.into_box(slice.len()).assume_init() + } + } +} + #[cfg(not(no_global_oom_handling))] #[stable(feature = "box_from_slice", since = "1.17.0")] -impl<T: Copy> From<&[T]> for Box<[T]> { +impl<T: Clone> From<&[T]> for Box<[T]> { /// Converts a `&[T]` into a `Box<[T]>` /// /// This conversion allocates on the heap @@ -1471,19 +1498,15 @@ impl<T: Copy> From<&[T]> for Box<[T]> { /// /// println!("{boxed_slice:?}"); /// ``` + #[inline] fn from(slice: &[T]) -> Box<[T]> { - let len = slice.len(); - let buf = RawVec::with_capacity(len); - unsafe { - ptr::copy_nonoverlapping(slice.as_ptr(), buf.ptr(), len); - buf.into_box(slice.len()).assume_init() - } + <Self as BoxFromSlice<T>>::from_slice(slice) } } #[cfg(not(no_global_oom_handling))] #[stable(feature = "box_from_cow", since = "1.45.0")] -impl<T: Copy> From<Cow<'_, [T]>> for Box<[T]> { +impl<T: Clone> From<Cow<'_, [T]>> for Box<[T]> { /// Converts a `Cow<'_, [T]>` into a `Box<[T]>` /// /// When `cow` is the `Cow::Borrowed` variant, this diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs index 87ec35c040fbf..48b127716f50d 100644 --- a/library/core/src/cmp.rs +++ b/library/core/src/cmp.rs @@ -1321,13 +1321,13 @@ mod impls { (true, true) => Some(Equal), } } - #[inline] + #[inline(always)] fn lt(&self, other: &$t) -> bool { (*self) < (*other) } - #[inline] + #[inline(always)] fn le(&self, other: &$t) -> bool { (*self) <= (*other) } - #[inline] + #[inline(always)] fn ge(&self, other: &$t) -> bool { (*self) >= (*other) } - #[inline] + #[inline(always)] fn gt(&self, other: &$t) -> bool { (*self) > (*other) } } )*) @@ -1359,13 +1359,13 @@ mod impls { fn partial_cmp(&self, other: &$t) -> Option<Ordering> { Some(self.cmp(other)) } - #[inline] + #[inline(always)] fn lt(&self, other: &$t) -> bool { (*self) < (*other) } - #[inline] + #[inline(always)] fn le(&self, other: &$t) -> bool { (*self) <= (*other) } - #[inline] + #[inline(always)] fn ge(&self, other: &$t) -> bool { (*self) >= (*other) } - #[inline] + #[inline(always)] fn gt(&self, other: &$t) -> bool { (*self) > (*other) } } diff --git a/library/core/src/future/into_future.rs b/library/core/src/future/into_future.rs index 649b433877222..38c654e76b46c 100644 --- a/library/core/src/future/into_future.rs +++ b/library/core/src/future/into_future.rs @@ -99,6 +99,7 @@ use crate::future::Future; /// } /// ``` #[stable(feature = "into_future", since = "1.64.0")] +#[rustc_diagnostic_item = "IntoFuture"] pub trait IntoFuture { /// The output that the future will produce on completion. #[stable(feature = "into_future", since = "1.64.0")] diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 79bd0bbb0c19d..077c0fdc380bc 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2257,12 +2257,23 @@ extern "rust-intrinsic" { /// This is an implementation detail of [`crate::ptr::read`] and should /// not be used anywhere else. See its comments for why this exists. /// - /// This intrinsic can *only* be called where the argument is a local without - /// projections (`read_via_copy(p)`, not `read_via_copy(*p)`) so that it + /// This intrinsic can *only* be called where the pointer is a local without + /// projections (`read_via_copy(ptr)`, not `read_via_copy(*ptr)`) so that it /// trivially obeys runtime-MIR rules about derefs in operands. #[rustc_const_unstable(feature = "const_ptr_read", issue = "80377")] #[rustc_nounwind] - pub fn read_via_copy<T>(p: *const T) -> T; + pub fn read_via_copy<T>(ptr: *const T) -> T; + + /// This is an implementation detail of [`crate::ptr::write`] and should + /// not be used anywhere else. See its comments for why this exists. + /// + /// This intrinsic can *only* be called where the pointer is a local without + /// projections (`write_via_move(ptr, x)`, not `write_via_move(*ptr, x)`) so + /// that it trivially obeys runtime-MIR rules about derefs in operands. + #[cfg(not(bootstrap))] + #[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")] + #[rustc_nounwind] + pub fn write_via_move<T>(ptr: *mut T, value: T); /// Returns the value of the discriminant for the variant in 'v'; /// if `T` has no discriminant, returns `0`. @@ -2828,3 +2839,16 @@ pub const unsafe fn transmute_unchecked<Src, Dst>(src: Src) -> Dst { // SAFETY: It's a transmute -- the caller promised it's fine. unsafe { transmute_copy(&ManuallyDrop::new(src)) } } + +/// Polyfill for bootstrap +#[cfg(bootstrap)] +pub const unsafe fn write_via_move<T>(ptr: *mut T, value: T) { + use crate::mem::*; + // SAFETY: the caller must guarantee that `dst` is valid for writes. + // `dst` cannot overlap `src` because the caller has mutable access + // to `dst` while `src` is owned by this function. + unsafe { + copy_nonoverlapping::<T>(&value, ptr, 1); + forget(value); + } +} diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs index 40789cb3049de..82e4c6489745d 100644 --- a/library/core/src/marker.rs +++ b/library/core/src/marker.rs @@ -24,7 +24,7 @@ use crate::hash::Hasher; /// operations. Its cousin [`sync::Arc`][arc] does use atomic operations (incurring /// some overhead) and thus is `Send`. /// -/// See [the Nomicon](../../nomicon/send-and-sync.html) for more details. +/// See [the Nomicon](../../nomicon/send-and-sync.html) and the [`Sync`] trait for more details. /// /// [`Rc`]: ../../std/rc/struct.Rc.html /// [arc]: ../../std/sync/struct.Arc.html @@ -426,6 +426,11 @@ pub macro Copy($item:item) { /// becomes read-only, as if it were a `& &T`. Hence there is no risk /// of a data race. /// +/// A shorter overview of how [`Sync`] and [`Send`] relate to referencing: +/// * `&T` is [`Send`] if and only if `T` is [`Sync`] +/// * `&mut T` is [`Send`] if and only if `T` is [`Send`] +/// * `&T` and `&mut T` are [`Sync`] if and only if `T` is [`Sync`] +/// /// Types that are not `Sync` are those that have "interior /// mutability" in a non-thread-safe form, such as [`Cell`][cell] /// and [`RefCell`][refcell]. These types allow for mutation of diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 73ffc3f36ca75..c38c68e1d5867 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -1007,7 +1007,7 @@ impl<T> Option<T> { { match self { Some(x) => x, - None => Default::default(), + None => T::default(), } } @@ -1615,11 +1615,7 @@ impl<T> Option<T> { where T: Default, { - fn default<T: Default>() -> T { - T::default() - } - - self.get_or_insert_with(default) + self.get_or_insert_with(T::default) } /// Inserts a value computed from `f` into the option if it is [`None`], diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index 13e546497f27d..5f55f762ad555 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -1349,13 +1349,13 @@ pub const unsafe fn read_unaligned<T>(src: *const T) -> T { #[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn write<T>(dst: *mut T, src: T) { - // We are calling the intrinsics directly to avoid function calls in the generated code - // as `intrinsics::copy_nonoverlapping` is a wrapper function. - extern "rust-intrinsic" { - #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] - #[rustc_nounwind] - fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize); - } + // Semantically, it would be fine for this to be implemented as a + // `copy_nonoverlapping` and appropriate drop suppression of `src`. + + // However, implementing via that currently produces more MIR than is ideal. + // Using an intrinsic keeps it down to just the simple `*dst = move src` in + // MIR (11 statements shorter, at the time of writing), and also allows + // `src` to stay an SSA value in codegen_ssa, rather than a memory one. // SAFETY: the caller must guarantee that `dst` is valid for writes. // `dst` cannot overlap `src` because the caller has mutable access @@ -1365,8 +1365,7 @@ pub const unsafe fn write<T>(dst: *mut T, src: T) { "ptr::write requires that the pointer argument is aligned and non-null", [T](dst: *mut T) => is_aligned_and_not_null(dst) ); - copy_nonoverlapping(&src as *const T, dst, 1); - intrinsics::forget(src); + intrinsics::write_via_move(dst, src) } } diff --git a/library/core/src/slice/iter.rs b/library/core/src/slice/iter.rs index b2dd92a2379a8..8629aab007046 100644 --- a/library/core/src/slice/iter.rs +++ b/library/core/src/slice/iter.rs @@ -60,10 +60,17 @@ impl<'a, T> IntoIterator for &'a mut [T] { #[stable(feature = "rust1", since = "1.0.0")] #[must_use = "iterators are lazy and do nothing unless consumed"] pub struct Iter<'a, T: 'a> { + /// The pointer to the next element to return, or the past-the-end location + /// if the iterator is empty. + /// + /// This address will be used for all ZST elements, never changed. ptr: NonNull<T>, - end: *const T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that - // ptr == end is a quick test for the Iterator being empty, that works - // for both ZST and non-ZST. + /// For non-ZSTs, the non-null pointer to the past-the-end element. + /// + /// For ZSTs, this is `ptr.wrapping_byte_add(len)`. + /// + /// For all types, `ptr == end` tests whether the iterator is empty. + end: *const T, _marker: PhantomData<&'a T>, } @@ -179,10 +186,17 @@ impl<T> AsRef<[T]> for Iter<'_, T> { #[stable(feature = "rust1", since = "1.0.0")] #[must_use = "iterators are lazy and do nothing unless consumed"] pub struct IterMut<'a, T: 'a> { + /// The pointer to the next element to return, or the past-the-end location + /// if the iterator is empty. + /// + /// This address will be used for all ZST elements, never changed. ptr: NonNull<T>, - end: *mut T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that - // ptr == end is a quick test for the Iterator being empty, that works - // for both ZST and non-ZST. + /// For non-ZSTs, the non-null pointer to the past-the-end element. + /// + /// For ZSTs, this is `ptr.wrapping_byte_add(len)`. + /// + /// For all types, `ptr == end` tests whether the iterator is empty. + end: *mut T, _marker: PhantomData<&'a mut T>, } diff --git a/library/panic_unwind/src/emcc.rs b/library/panic_unwind/src/emcc.rs index c6d42308596cb..af18e19337c7a 100644 --- a/library/panic_unwind/src/emcc.rs +++ b/library/panic_unwind/src/emcc.rs @@ -47,7 +47,7 @@ static EXCEPTION_TYPE_INFO: TypeInfo = TypeInfo { name: b"rust_panic\0".as_ptr(), }; -// NOTE(nbdd0121): The `canary` field will be part of stable ABI after `c_unwind` stabilization. +// NOTE(nbdd0121): The `canary` field is part of stable ABI. #[repr(C)] struct Exception { // See `gcc.rs` on why this is present. We already have a static here so just use it. diff --git a/library/panic_unwind/src/gcc.rs b/library/panic_unwind/src/gcc.rs index 0b7a873a691cc..08858dd92be09 100644 --- a/library/panic_unwind/src/gcc.rs +++ b/library/panic_unwind/src/gcc.rs @@ -48,8 +48,8 @@ use unwind as uw; static CANARY: u8 = 0; // NOTE(nbdd0121) -// Once `c_unwind` feature is stabilized, there will be ABI stability requirement -// on this struct. The first two field must be `_Unwind_Exception` and `canary`, +// There is an ABI stability requirement on this struct. +// The first two field must be `_Unwind_Exception` and `canary`, // as it may be accessed by a different version of the std with a different compiler. #[repr(C)] struct Exception { diff --git a/library/panic_unwind/src/seh.rs b/library/panic_unwind/src/seh.rs index 651115a8248ac..99db00e549066 100644 --- a/library/panic_unwind/src/seh.rs +++ b/library/panic_unwind/src/seh.rs @@ -52,7 +52,7 @@ use core::mem::{self, ManuallyDrop}; use core::ptr; use libc::{c_int, c_uint, c_void}; -// NOTE(nbdd0121): The `canary` field will be part of stable ABI after `c_unwind` stabilization. +// NOTE(nbdd0121): The `canary` field is part of stable ABI. #[repr(C)] struct Exception { // See `gcc.rs` on why this is present. We already have a static here so just use it. diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 30e553f285b98..6640c7fb16214 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -709,6 +709,7 @@ impl File { // `AsRawHandle`/`IntoRawHandle`/`FromRawHandle` on Windows. impl AsInner<fs_imp::File> for File { + #[inline] fn as_inner(&self) -> &fs_imp::File { &self.inner } @@ -1087,12 +1088,14 @@ impl OpenOptions { } impl AsInner<fs_imp::OpenOptions> for OpenOptions { + #[inline] fn as_inner(&self) -> &fs_imp::OpenOptions { &self.0 } } impl AsInnerMut<fs_imp::OpenOptions> for OpenOptions { + #[inline] fn as_inner_mut(&mut self) -> &mut fs_imp::OpenOptions { &mut self.0 } @@ -1352,6 +1355,7 @@ impl fmt::Debug for Metadata { } impl AsInner<fs_imp::FileAttr> for Metadata { + #[inline] fn as_inner(&self) -> &fs_imp::FileAttr { &self.0 } @@ -1604,6 +1608,7 @@ impl FileType { } impl AsInner<fs_imp::FileType> for FileType { + #[inline] fn as_inner(&self) -> &fs_imp::FileType { &self.0 } @@ -1616,6 +1621,7 @@ impl FromInner<fs_imp::FilePermissions> for Permissions { } impl AsInner<fs_imp::FilePermissions> for Permissions { + #[inline] fn as_inner(&self) -> &fs_imp::FilePermissions { &self.0 } @@ -1770,6 +1776,7 @@ impl fmt::Debug for DirEntry { } impl AsInner<fs_imp::DirEntry> for DirEntry { + #[inline] fn as_inner(&self) -> &fs_imp::DirEntry { &self.0 } @@ -2510,6 +2517,7 @@ impl DirBuilder { } impl AsInnerMut<fs_imp::DirBuilder> for DirBuilder { + #[inline] fn as_inner_mut(&mut self) -> &mut fs_imp::DirBuilder { &mut self.inner } diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs index 4b42ad65ee6bf..541e95d229b62 100644 --- a/library/std/src/net/tcp.rs +++ b/library/std/src/net/tcp.rs @@ -691,6 +691,7 @@ impl Write for &TcpStream { } impl AsInner<net_imp::TcpStream> for TcpStream { + #[inline] fn as_inner(&self) -> &net_imp::TcpStream { &self.0 } @@ -1033,6 +1034,7 @@ impl Iterator for IntoIncoming { impl FusedIterator for IntoIncoming {} impl AsInner<net_imp::TcpListener> for TcpListener { + #[inline] fn as_inner(&self) -> &net_imp::TcpListener { &self.0 } diff --git a/library/std/src/net/udp.rs b/library/std/src/net/udp.rs index 864e1b0f3450a..9628bcc51083d 100644 --- a/library/std/src/net/udp.rs +++ b/library/std/src/net/udp.rs @@ -788,6 +788,7 @@ impl UdpSocket { // `AsRawSocket`/`IntoRawSocket`/`FromRawSocket` on Windows. impl AsInner<net_imp::UdpSocket> for UdpSocket { + #[inline] fn as_inner(&self) -> &net_imp::UdpSocket { &self.0 } diff --git a/library/std/src/os/linux/process.rs b/library/std/src/os/linux/process.rs index 540363c03494e..2b3ff76d7a4a7 100644 --- a/library/std/src/os/linux/process.rs +++ b/library/std/src/os/linux/process.rs @@ -52,6 +52,7 @@ pub struct PidFd { } impl AsInner<FileDesc> for PidFd { + #[inline] fn as_inner(&self) -> &FileDesc { &self.inner } @@ -70,6 +71,7 @@ impl IntoInner<FileDesc> for PidFd { } impl AsRawFd for PidFd { + #[inline] fn as_raw_fd(&self) -> RawFd { self.as_inner().as_raw_fd() } diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 5b22333cc354f..198996c5f707f 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -1395,11 +1395,16 @@ impl PathBuf { /// /// let mut buf = PathBuf::from("/"); /// assert!(buf.file_name() == None); - /// buf.set_file_name("bar"); - /// assert!(buf == PathBuf::from("/bar")); + /// + /// buf.set_file_name("foo.txt"); + /// assert!(buf == PathBuf::from("/foo.txt")); /// assert!(buf.file_name().is_some()); - /// buf.set_file_name("baz.txt"); - /// assert!(buf == PathBuf::from("/baz.txt")); + /// + /// buf.set_file_name("bar.txt"); + /// assert!(buf == PathBuf::from("/bar.txt")); + /// + /// buf.set_file_name("baz"); + /// assert!(buf == PathBuf::from("/baz")); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn set_file_name<S: AsRef<OsStr>>(&mut self, file_name: S) { @@ -2562,7 +2567,8 @@ impl Path { /// ``` /// use std::path::{Path, PathBuf}; /// - /// let path = Path::new("/tmp/foo.txt"); + /// let path = Path::new("/tmp/foo.png"); + /// assert_eq!(path.with_file_name("bar"), PathBuf::from("/tmp/bar")); /// assert_eq!(path.with_file_name("bar.txt"), PathBuf::from("/tmp/bar.txt")); /// /// let path = Path::new("/tmp"); diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 0ab72f7ea7a6d..bf22c2d46c9e0 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -211,6 +211,7 @@ pub struct Child { impl crate::sealed::Sealed for Child {} impl AsInner<imp::Process> for Child { + #[inline] fn as_inner(&self) -> &imp::Process { &self.handle } @@ -304,6 +305,7 @@ impl Write for &ChildStdin { } impl AsInner<AnonPipe> for ChildStdin { + #[inline] fn as_inner(&self) -> &AnonPipe { &self.inner } @@ -373,6 +375,7 @@ impl Read for ChildStdout { } impl AsInner<AnonPipe> for ChildStdout { + #[inline] fn as_inner(&self) -> &AnonPipe { &self.inner } @@ -438,6 +441,7 @@ impl Read for ChildStderr { } impl AsInner<AnonPipe> for ChildStderr { + #[inline] fn as_inner(&self) -> &AnonPipe { &self.inner } @@ -1107,12 +1111,14 @@ impl fmt::Debug for Command { } impl AsInner<imp::Command> for Command { + #[inline] fn as_inner(&self) -> &imp::Command { &self.inner } } impl AsInnerMut<imp::Command> for Command { + #[inline] fn as_inner_mut(&mut self) -> &mut imp::Command { &mut self.inner } @@ -1605,6 +1611,7 @@ impl ExitStatus { } impl AsInner<imp::ExitStatus> for ExitStatus { + #[inline] fn as_inner(&self) -> &imp::ExitStatus { &self.0 } @@ -1884,6 +1891,7 @@ impl From<u8> for ExitCode { } impl AsInner<imp::ExitCode> for ExitCode { + #[inline] fn as_inner(&self) -> &imp::ExitCode { &self.0 } diff --git a/library/std/src/sys/hermit/fd.rs b/library/std/src/sys/hermit/fd.rs index 3a2cdd301ea45..ccde05aa1d7db 100644 --- a/library/std/src/sys/hermit/fd.rs +++ b/library/std/src/sys/hermit/fd.rs @@ -75,6 +75,7 @@ impl FromRawFd for FileDesc { } impl AsInner<OwnedFd> for FileDesc { + #[inline] fn as_inner(&self) -> &OwnedFd { &self.fd } diff --git a/library/std/src/sys/hermit/fs.rs b/library/std/src/sys/hermit/fs.rs index cf0b271761feb..4bb735668d24c 100644 --- a/library/std/src/sys/hermit/fs.rs +++ b/library/std/src/sys/hermit/fs.rs @@ -367,12 +367,14 @@ impl DirBuilder { } impl AsInner<FileDesc> for File { + #[inline] fn as_inner(&self) -> &FileDesc { &self.0 } } impl AsInnerMut<FileDesc> for File { + #[inline] fn as_inner_mut(&mut self) -> &mut FileDesc { &mut self.0 } @@ -397,6 +399,7 @@ impl AsFd for File { } impl AsRawFd for File { + #[inline] fn as_raw_fd(&self) -> RawFd { self.0.as_raw_fd() } diff --git a/library/std/src/sys/hermit/net.rs b/library/std/src/sys/hermit/net.rs index d6f64a2971902..8c2d489d6a362 100644 --- a/library/std/src/sys/hermit/net.rs +++ b/library/std/src/sys/hermit/net.rs @@ -340,6 +340,7 @@ impl Socket { } impl AsInner<FileDesc> for Socket { + #[inline] fn as_inner(&self) -> &FileDesc { &self.0 } @@ -364,6 +365,7 @@ impl AsFd for Socket { } impl AsRawFd for Socket { + #[inline] fn as_raw_fd(&self) -> RawFd { self.0.as_raw_fd() } diff --git a/library/std/src/sys/sgx/fd.rs b/library/std/src/sys/sgx/fd.rs index 0c02a107691c8..b3686d0e28328 100644 --- a/library/std/src/sys/sgx/fd.rs +++ b/library/std/src/sys/sgx/fd.rs @@ -62,6 +62,7 @@ impl FileDesc { } impl AsInner<Fd> for FileDesc { + #[inline] fn as_inner(&self) -> &Fd { &self.fd } diff --git a/library/std/src/sys/sgx/net.rs b/library/std/src/sys/sgx/net.rs index 923be5eb944ec..03620a08f2c03 100644 --- a/library/std/src/sys/sgx/net.rs +++ b/library/std/src/sys/sgx/net.rs @@ -24,6 +24,7 @@ impl Socket { } impl AsInner<FileDesc> for Socket { + #[inline] fn as_inner(&self) -> &FileDesc { &self.inner } @@ -220,6 +221,7 @@ impl TcpStream { } impl AsInner<Socket> for TcpStream { + #[inline] fn as_inner(&self) -> &Socket { &self.inner } @@ -304,6 +306,7 @@ impl TcpListener { } impl AsInner<Socket> for TcpListener { + #[inline] fn as_inner(&self) -> &Socket { &self.inner } diff --git a/library/std/src/sys/solid/net.rs b/library/std/src/sys/solid/net.rs index 7d7bfae14329a..0bd2bc3b96199 100644 --- a/library/std/src/sys/solid/net.rs +++ b/library/std/src/sys/solid/net.rs @@ -112,6 +112,7 @@ impl FileDesc { } impl AsInner<c_int> for FileDesc { + #[inline] fn as_inner(&self) -> &c_int { &self.fd } @@ -462,6 +463,7 @@ impl Socket { } impl AsInner<c_int> for Socket { + #[inline] fn as_inner(&self) -> &c_int { self.0.as_inner() } diff --git a/library/std/src/sys/unix/fd.rs b/library/std/src/sys/unix/fd.rs index ce5c048f252a1..45f96478fc373 100644 --- a/library/std/src/sys/unix/fd.rs +++ b/library/std/src/sys/unix/fd.rs @@ -481,6 +481,7 @@ impl<'a> Read for &'a FileDesc { } impl AsInner<OwnedFd> for FileDesc { + #[inline] fn as_inner(&self) -> &OwnedFd { &self.0 } @@ -505,6 +506,7 @@ impl AsFd for FileDesc { } impl AsRawFd for FileDesc { + #[inline] fn as_raw_fd(&self) -> RawFd { self.0.as_raw_fd() } diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index abef170dd5a64..b398fd5eb24bf 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -547,6 +547,7 @@ impl FileAttr { } impl AsInner<stat64> for FileAttr { + #[inline] fn as_inner(&self) -> &stat64 { &self.stat } @@ -1193,8 +1194,6 @@ impl File { None => Ok(libc::timespec { tv_sec: 0, tv_nsec: libc::UTIME_OMIT as _ }), } }; - #[cfg(not(any(target_os = "redox", target_os = "espidf", target_os = "horizon")))] - let times = [to_timespec(times.accessed)?, to_timespec(times.modified)?]; cfg_if::cfg_if! { if #[cfg(any(target_os = "redox", target_os = "espidf", target_os = "horizon"))] { // Redox doesn't appear to support `UTIME_OMIT`. @@ -1206,6 +1205,7 @@ impl File { "setting file times not supported", )) } else if #[cfg(any(target_os = "android", target_os = "macos"))] { + let times = [to_timespec(times.accessed)?, to_timespec(times.modified)?]; // futimens requires macOS 10.13, and Android API level 19 cvt(unsafe { weak!(fn futimens(c_int, *const libc::timespec) -> c_int); @@ -1232,6 +1232,22 @@ impl File { })?; Ok(()) } else { + #[cfg(all(target_os = "linux", target_env = "gnu", target_pointer_width = "32", not(target_arch = "riscv32")))] + { + use crate::sys::{time::__timespec64, weak::weak}; + + // Added in glibc 2.34 + weak!(fn __futimens64(libc::c_int, *const __timespec64) -> libc::c_int); + + if let Some(futimens64) = __futimens64.get() { + let to_timespec = |time: Option<SystemTime>| time.map(|time| time.t.to_timespec64()) + .unwrap_or(__timespec64::new(0, libc::UTIME_OMIT as _)); + let times = [to_timespec(times.accessed), to_timespec(times.modified)]; + cvt(unsafe { futimens64(self.as_raw_fd(), times.as_ptr()) })?; + return Ok(()); + } + } + let times = [to_timespec(times.accessed)?, to_timespec(times.modified)?]; cvt(unsafe { libc::futimens(self.as_raw_fd(), times.as_ptr()) })?; Ok(()) } @@ -1254,12 +1270,14 @@ impl DirBuilder { } impl AsInner<FileDesc> for File { + #[inline] fn as_inner(&self) -> &FileDesc { &self.0 } } impl AsInnerMut<FileDesc> for File { + #[inline] fn as_inner_mut(&mut self) -> &mut FileDesc { &mut self.0 } @@ -1284,6 +1302,7 @@ impl AsFd for File { } impl AsRawFd for File { + #[inline] fn as_raw_fd(&self) -> RawFd { self.0.as_raw_fd() } diff --git a/library/std/src/sys/unix/l4re.rs b/library/std/src/sys/unix/l4re.rs index 9967588939ac9..ee016887e7021 100644 --- a/library/std/src/sys/unix/l4re.rs +++ b/library/std/src/sys/unix/l4re.rs @@ -129,6 +129,7 @@ pub mod net { } impl AsInner<FileDesc> for Socket { + #[inline] fn as_inner(&self) -> &FileDesc { &self.0 } @@ -153,6 +154,7 @@ pub mod net { } impl AsRawFd for Socket { + #[inline] fn as_raw_fd(&self) -> RawFd { self.0.as_raw_fd() } @@ -183,6 +185,7 @@ pub mod net { unimpl!(); } + #[inline] pub fn socket(&self) -> &Socket { &self.inner } @@ -305,6 +308,7 @@ pub mod net { unimpl!(); } + #[inline] pub fn socket(&self) -> &Socket { &self.inner } @@ -371,6 +375,7 @@ pub mod net { unimpl!(); } + #[inline] pub fn socket(&self) -> &Socket { &self.inner } diff --git a/library/std/src/sys/unix/net.rs b/library/std/src/sys/unix/net.rs index 573bfa6587e81..39edb136c24fd 100644 --- a/library/std/src/sys/unix/net.rs +++ b/library/std/src/sys/unix/net.rs @@ -490,6 +490,7 @@ impl Socket { } impl AsInner<FileDesc> for Socket { + #[inline] fn as_inner(&self) -> &FileDesc { &self.0 } @@ -514,6 +515,7 @@ impl AsFd for Socket { } impl AsRawFd for Socket { + #[inline] fn as_raw_fd(&self) -> RawFd { self.0.as_raw_fd() } diff --git a/library/std/src/sys/unix/os_str.rs b/library/std/src/sys/unix/os_str.rs index 017e2af29d4f4..488217f39413f 100644 --- a/library/std/src/sys/unix/os_str.rs +++ b/library/std/src/sys/unix/os_str.rs @@ -89,6 +89,7 @@ impl IntoInner<Vec<u8>> for Buf { } impl AsInner<[u8]> for Buf { + #[inline] fn as_inner(&self) -> &[u8] { &self.inner } diff --git a/library/std/src/sys/unix/pipe.rs b/library/std/src/sys/unix/pipe.rs index dc17c9fac460a..938a46bfdd833 100644 --- a/library/std/src/sys/unix/pipe.rs +++ b/library/std/src/sys/unix/pipe.rs @@ -135,6 +135,7 @@ pub fn read2(p1: AnonPipe, v1: &mut Vec<u8>, p2: AnonPipe, v2: &mut Vec<u8>) -> } impl AsRawFd for AnonPipe { + #[inline] fn as_raw_fd(&self) -> RawFd { self.0.as_raw_fd() } diff --git a/library/std/src/sys/unix/time.rs b/library/std/src/sys/unix/time.rs index 6f53583409db2..a61d926ca8b3a 100644 --- a/library/std/src/sys/unix/time.rs +++ b/library/std/src/sys/unix/time.rs @@ -166,6 +166,16 @@ impl Timespec { } self.to_timespec() } + + #[cfg(all( + target_os = "linux", + target_env = "gnu", + target_pointer_width = "32", + not(target_arch = "riscv32") + ))] + pub fn to_timespec64(&self) -> __timespec64 { + __timespec64::new(self.tv_sec, self.tv_nsec.0 as _) + } } impl From<libc::timespec> for Timespec { @@ -190,6 +200,18 @@ pub(in crate::sys::unix) struct __timespec64 { _padding: i32, } +#[cfg(all( + target_os = "linux", + target_env = "gnu", + target_pointer_width = "32", + not(target_arch = "riscv32") +))] +impl __timespec64 { + pub(in crate::sys::unix) fn new(tv_sec: i64, tv_nsec: i32) -> Self { + Self { tv_sec, tv_nsec, _padding: 0 } + } +} + #[cfg(all( target_os = "linux", target_env = "gnu", diff --git a/library/std/src/sys/wasi/fd.rs b/library/std/src/sys/wasi/fd.rs index 191db4b60f72a..9a8b2a0be5b00 100644 --- a/library/std/src/sys/wasi/fd.rs +++ b/library/std/src/sys/wasi/fd.rs @@ -275,12 +275,14 @@ impl WasiFd { } impl AsInner<OwnedFd> for WasiFd { + #[inline] fn as_inner(&self) -> &OwnedFd { &self.fd } } impl AsInnerMut<OwnedFd> for WasiFd { + #[inline] fn as_inner_mut(&mut self) -> &mut OwnedFd { &mut self.fd } @@ -305,6 +307,7 @@ impl AsFd for WasiFd { } impl AsRawFd for WasiFd { + #[inline] fn as_raw_fd(&self) -> RawFd { self.fd.as_raw_fd() } diff --git a/library/std/src/sys/wasi/fs.rs b/library/std/src/sys/wasi/fs.rs index 3a205267e3468..8d1dbf59155a4 100644 --- a/library/std/src/sys/wasi/fs.rs +++ b/library/std/src/sys/wasi/fs.rs @@ -498,6 +498,7 @@ impl File { } impl AsInner<WasiFd> for File { + #[inline] fn as_inner(&self) -> &WasiFd { &self.fd } @@ -522,6 +523,7 @@ impl AsFd for File { } impl AsRawFd for File { + #[inline] fn as_raw_fd(&self) -> RawFd { self.fd.as_raw_fd() } diff --git a/library/std/src/sys/wasi/net.rs b/library/std/src/sys/wasi/net.rs index 59d94a3686dc5..2239880ffbef4 100644 --- a/library/std/src/sys/wasi/net.rs +++ b/library/std/src/sys/wasi/net.rs @@ -17,6 +17,7 @@ pub struct TcpStream { } impl AsInner<WasiFd> for Socket { + #[inline] fn as_inner(&self) -> &WasiFd { &self.0 } @@ -41,6 +42,7 @@ impl AsFd for Socket { } impl AsRawFd for Socket { + #[inline] fn as_raw_fd(&self) -> RawFd { self.0.as_raw_fd() } @@ -184,6 +186,7 @@ impl TcpStream { } } + #[inline] pub fn socket(&self) -> &Socket { &self.inner } @@ -274,6 +277,7 @@ impl TcpListener { } } + #[inline] pub fn socket(&self) -> &Socket { &self.inner } @@ -284,6 +288,7 @@ impl TcpListener { } impl AsInner<Socket> for TcpListener { + #[inline] fn as_inner(&self) -> &Socket { &self.inner } @@ -436,6 +441,7 @@ impl UdpSocket { unsupported() } + #[inline] pub fn socket(&self) -> &Socket { &self.inner } @@ -446,6 +452,7 @@ impl UdpSocket { } impl AsInner<Socket> for UdpSocket { + #[inline] fn as_inner(&self) -> &Socket { &self.inner } diff --git a/library/std/src/sys/windows/fs.rs b/library/std/src/sys/windows/fs.rs index 8ed62cdddcd9c..f99cdfbecfb69 100644 --- a/library/std/src/sys/windows/fs.rs +++ b/library/std/src/sys/windows/fs.rs @@ -832,6 +832,7 @@ fn open_link_no_reparse(parent: &File, name: &[u16], access: u32) -> io::Result< } impl AsInner<Handle> for File { + #[inline] fn as_inner(&self) -> &Handle { &self.handle } diff --git a/library/std/src/sys/windows/handle.rs b/library/std/src/sys/windows/handle.rs index b290f4070e8fd..c7677d1c13abb 100644 --- a/library/std/src/sys/windows/handle.rs +++ b/library/std/src/sys/windows/handle.rs @@ -34,6 +34,7 @@ impl Handle { } impl AsInner<OwnedHandle> for Handle { + #[inline] fn as_inner(&self) -> &OwnedHandle { &self.0 } diff --git a/library/std/src/sys/windows/net.rs b/library/std/src/sys/windows/net.rs index ee1f5482b47ee..8158713fa84a8 100644 --- a/library/std/src/sys/windows/net.rs +++ b/library/std/src/sys/windows/net.rs @@ -446,6 +446,7 @@ impl<'a> Read for &'a Socket { } impl AsInner<OwnedSocket> for Socket { + #[inline] fn as_inner(&self) -> &OwnedSocket { &self.0 } diff --git a/library/std/src/sys/windows/os_str.rs b/library/std/src/sys/windows/os_str.rs index 4bdd8c505ff25..2f2b0e56e0889 100644 --- a/library/std/src/sys/windows/os_str.rs +++ b/library/std/src/sys/windows/os_str.rs @@ -27,6 +27,7 @@ impl FromInner<Wtf8Buf> for Buf { } impl AsInner<Wtf8> for Buf { + #[inline] fn as_inner(&self) -> &Wtf8 { &self.inner } diff --git a/library/std/src/sys_common/net.rs b/library/std/src/sys_common/net.rs index cb24caa1e8a60..652c695fc57b0 100644 --- a/library/std/src/sys_common/net.rs +++ b/library/std/src/sys_common/net.rs @@ -239,6 +239,7 @@ impl TcpStream { Ok(TcpStream { inner: sock }) } + #[inline] pub fn socket(&self) -> &Socket { &self.inner } @@ -352,6 +353,7 @@ impl TcpStream { } impl AsInner<Socket> for TcpStream { + #[inline] fn as_inner(&self) -> &Socket { &self.inner } @@ -427,6 +429,7 @@ impl TcpListener { Ok(TcpListener { inner: sock }) } + #[inline] pub fn socket(&self) -> &Socket { &self.inner } @@ -517,6 +520,7 @@ impl UdpSocket { Ok(UdpSocket { inner: sock }) } + #[inline] pub fn socket(&self) -> &Socket { &self.inner } diff --git a/library/std/src/sys_common/wtf8.rs b/library/std/src/sys_common/wtf8.rs index bc588bdbb3ce6..ff96c35fb0ba6 100644 --- a/library/std/src/sys_common/wtf8.rs +++ b/library/std/src/sys_common/wtf8.rs @@ -501,6 +501,7 @@ pub struct Wtf8 { } impl AsInner<[u8]> for Wtf8 { + #[inline] fn as_inner(&self) -> &[u8] { &self.bytes } diff --git a/library/std/src/time.rs b/library/std/src/time.rs index 5c2e9da70fb21..00e2857a13759 100644 --- a/library/std/src/time.rs +++ b/library/std/src/time.rs @@ -119,7 +119,7 @@ pub use core::time::TryFromFloatSecsError; /// [QueryPerformanceCounter]: https://docs.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancecounter /// [`insecure_time` usercall]: https://edp.fortanix.com/docs/api/fortanix_sgx_abi/struct.Usercalls.html#method.insecure_time /// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode -/// [__wasi_clock_time_get (Monotonic Clock)]: https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/docs.md#clock_time_get +/// [__wasi_clock_time_get (Monotonic Clock)]: https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#clock_time_get /// [clock_gettime (Monotonic Clock)]: https://linux.die.net/man/3/clock_gettime /// [mach_absolute_time]: https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/services/services.html /// @@ -224,7 +224,7 @@ pub struct Instant(time::Instant); /// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode /// [gettimeofday]: https://man7.org/linux/man-pages/man2/gettimeofday.2.html /// [clock_gettime (Realtime Clock)]: https://linux.die.net/man/3/clock_gettime -/// [__wasi_clock_time_get (Realtime Clock)]: https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/docs.md#clock_time_get +/// [__wasi_clock_time_get (Realtime Clock)]: https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#clock_time_get /// [GetSystemTimePreciseAsFileTime]: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime /// [GetSystemTimeAsFileTime]: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimeasfiletime /// diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index ff261ab983273..f22cdad7df411 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -13,6 +13,7 @@ import tempfile from time import time +from multiprocessing import Pool, cpu_count try: import lzma @@ -27,6 +28,20 @@ def platform_is_win32(): else: EXE_SUFFIX = "" +def get_cpus(): + if hasattr(os, "sched_getaffinity"): + return len(os.sched_getaffinity(0)) + if hasattr(os, "cpu_count"): + cpus = os.cpu_count() + if cpus is not None: + return cpus + try: + return cpu_count() + except NotImplementedError: + return 1 + + + def get(base, url, path, checksums, verbose=False): with tempfile.NamedTemporaryFile(delete=False) as temp_file: temp_path = temp_file.name @@ -42,23 +57,23 @@ def get(base, url, path, checksums, verbose=False): if os.path.exists(path): if verify(path, sha256, False): if verbose: - print("using already-download file", path) + print("using already-download file", path, file=sys.stderr) return else: if verbose: print("ignoring already-download file", - path, "due to failed verification") + path, "due to failed verification", file=sys.stderr) os.unlink(path) download(temp_path, "{}/{}".format(base, url), True, verbose) if not verify(temp_path, sha256, verbose): raise RuntimeError("failed verification") if verbose: - print("moving {} to {}".format(temp_path, path)) + print("moving {} to {}".format(temp_path, path), file=sys.stderr) shutil.move(temp_path, path) finally: if os.path.isfile(temp_path): if verbose: - print("removing", temp_path) + print("removing", temp_path, file=sys.stderr) os.unlink(temp_path) @@ -68,7 +83,7 @@ def download(path, url, probably_big, verbose): _download(path, url, probably_big, verbose, True) return except RuntimeError: - print("\nspurious failure, trying again") + print("\nspurious failure, trying again", file=sys.stderr) _download(path, url, probably_big, verbose, False) @@ -79,7 +94,7 @@ def _download(path, url, probably_big, verbose, exception): # - If we are on win32 fallback to powershell # - Otherwise raise the error if appropriate if probably_big or verbose: - print("downloading {}".format(url)) + print("downloading {}".format(url), file=sys.stderr) try: if probably_big or verbose: @@ -115,20 +130,20 @@ def _download(path, url, probably_big, verbose, exception): def verify(path, expected, verbose): """Check if the sha256 sum of the given path is valid""" if verbose: - print("verifying", path) + print("verifying", path, file=sys.stderr) with open(path, "rb") as source: found = hashlib.sha256(source.read()).hexdigest() verified = found == expected if not verified: print("invalid checksum:\n" " found: {}\n" - " expected: {}".format(found, expected)) + " expected: {}".format(found, expected), file=sys.stderr) return verified def unpack(tarball, tarball_suffix, dst, verbose=False, match=None): """Unpack the given tarball file""" - print("extracting", tarball) + print("extracting", tarball, file=sys.stderr) fname = os.path.basename(tarball).replace(tarball_suffix, "") with contextlib.closing(tarfile.open(tarball)) as tar: for member in tar.getnames(): @@ -141,7 +156,7 @@ def unpack(tarball, tarball_suffix, dst, verbose=False, match=None): dst_path = os.path.join(dst, name) if verbose: - print(" extracting", member) + print(" extracting", member, file=sys.stderr) tar.extract(member, dst) src_path = os.path.join(dst, member) if os.path.isdir(src_path) and os.path.exists(dst_path): @@ -153,7 +168,7 @@ def unpack(tarball, tarball_suffix, dst, verbose=False, match=None): def run(args, verbose=False, exception=False, is_bootstrap=False, **kwargs): """Run a child program in a new process""" if verbose: - print("running: " + ' '.join(args)) + print("running: " + ' '.join(args), file=sys.stderr) sys.stdout.flush() # Ensure that the .exe is used on Windows just in case a Linux ELF has been # compiled in the same directory. @@ -193,8 +208,8 @@ def require(cmd, exit=True, exception=False): if exception: raise elif exit: - print("error: unable to run `{}`: {}".format(' '.join(cmd), exc)) - print("Please make sure it's installed and in the path.") + print("error: unable to run `{}`: {}".format(' '.join(cmd), exc), file=sys.stderr) + print("Please make sure it's installed and in the path.", file=sys.stderr) sys.exit(1) return None @@ -218,8 +233,8 @@ def default_build_triple(verbose): if sys.platform == 'darwin': if verbose: - print("not using rustc detection as it is unreliable on macOS") - print("falling back to auto-detect") + print("not using rustc detection as it is unreliable on macOS", file=sys.stderr) + print("falling back to auto-detect", file=sys.stderr) else: try: version = subprocess.check_output(["rustc", "--version", "--verbose"], @@ -228,12 +243,14 @@ def default_build_triple(verbose): host = next(x for x in version.split('\n') if x.startswith("host: ")) triple = host.split("host: ")[1] if verbose: - print("detected default triple {} from pre-installed rustc".format(triple)) + print("detected default triple {} from pre-installed rustc".format(triple), + file=sys.stderr) return triple except Exception as e: if verbose: - print("pre-installed rustc not detected: {}".format(e)) - print("falling back to auto-detect") + print("pre-installed rustc not detected: {}".format(e), + file=sys.stderr) + print("falling back to auto-detect", file=sys.stderr) required = not platform_is_win32() ostype = require(["uname", "-s"], exit=required) @@ -404,6 +421,48 @@ def channel(self): return self.version + "-" + self.date +class DownloadInfo: + """A helper class that can be pickled into a parallel subprocess""" + + def __init__( + self, + base_download_url, + download_path, + bin_root, + tarball_path, + tarball_suffix, + checksums_sha256, + pattern, + verbose, + ): + self.base_download_url = base_download_url + self.download_path = download_path + self.bin_root = bin_root + self.tarball_path = tarball_path + self.tarball_suffix = tarball_suffix + self.checksums_sha256 = checksums_sha256 + self.pattern = pattern + self.verbose = verbose + +def download_component(download_info): + if not os.path.exists(download_info.tarball_path): + get( + download_info.base_download_url, + download_info.download_path, + download_info.tarball_path, + download_info.checksums_sha256, + verbose=download_info.verbose, + ) + +def unpack_component(download_info): + unpack( + download_info.tarball_path, + download_info.tarball_suffix, + download_info.bin_root, + match=download_info.pattern, + verbose=download_info.verbose, + ) + class RustBuild(object): """Provide all the methods required to build Rust""" def __init__(self): @@ -458,17 +517,53 @@ def download_toolchain(self): ) run_powershell([script]) shutil.rmtree(bin_root) + + key = self.stage0_compiler.date + cache_dst = os.path.join(self.build_dir, "cache") + rustc_cache = os.path.join(cache_dst, key) + if not os.path.exists(rustc_cache): + os.makedirs(rustc_cache) + tarball_suffix = '.tar.gz' if lzma is None else '.tar.xz' - filename = "rust-std-{}-{}{}".format( - rustc_channel, self.build, tarball_suffix) - pattern = "rust-std-{}".format(self.build) - self._download_component_helper(filename, pattern, tarball_suffix) - filename = "rustc-{}-{}{}".format(rustc_channel, self.build, - tarball_suffix) - self._download_component_helper(filename, "rustc", tarball_suffix) - filename = "cargo-{}-{}{}".format(rustc_channel, self.build, - tarball_suffix) - self._download_component_helper(filename, "cargo", tarball_suffix) + + toolchain_suffix = "{}-{}{}".format(rustc_channel, self.build, tarball_suffix) + + tarballs_to_download = [ + ("rust-std-{}".format(toolchain_suffix), "rust-std-{}".format(self.build)), + ("rustc-{}".format(toolchain_suffix), "rustc"), + ("cargo-{}".format(toolchain_suffix), "cargo"), + ] + + tarballs_download_info = [ + DownloadInfo( + base_download_url=self.download_url, + download_path="dist/{}/{}".format(self.stage0_compiler.date, filename), + bin_root=self.bin_root(), + tarball_path=os.path.join(rustc_cache, filename), + tarball_suffix=tarball_suffix, + checksums_sha256=self.checksums_sha256, + pattern=pattern, + verbose=self.verbose, + ) + for filename, pattern in tarballs_to_download + ] + + # Download the components serially to show the progress bars properly. + for download_info in tarballs_download_info: + download_component(download_info) + + # Unpack the tarballs in parallle. + # In Python 2.7, Pool cannot be used as a context manager. + pool_size = min(len(tarballs_download_info), get_cpus()) + if self.verbose: + print('Choosing a pool size of', pool_size, 'for the unpacking of the tarballs') + p = Pool(pool_size) + try: + p.map(unpack_component, tarballs_download_info) + finally: + p.close() + p.join() + if self.should_fix_bins_and_dylibs(): self.fix_bin_or_dylib("{}/bin/cargo".format(bin_root)) @@ -484,13 +579,9 @@ def download_toolchain(self): rust_stamp.write(key) def _download_component_helper( - self, filename, pattern, tarball_suffix, + self, filename, pattern, tarball_suffix, rustc_cache, ): key = self.stage0_compiler.date - cache_dst = os.path.join(self.build_dir, "cache") - rustc_cache = os.path.join(cache_dst, key) - if not os.path.exists(rustc_cache): - os.makedirs(rustc_cache) tarball = os.path.join(rustc_cache, filename) if not os.path.exists(tarball): @@ -545,7 +636,7 @@ def get_answer(): answer = self._should_fix_bins_and_dylibs = get_answer() if answer: - print("info: You seem to be using Nix.") + print("info: You seem to be using Nix.", file=sys.stderr) return answer def fix_bin_or_dylib(self, fname): @@ -558,7 +649,7 @@ def fix_bin_or_dylib(self, fname): Please see https://nixos.org/patchelf.html for more information """ assert self._should_fix_bins_and_dylibs is True - print("attempting to patch", fname) + print("attempting to patch", fname, file=sys.stderr) # Only build `.nix-deps` once. nix_deps_dir = self.nix_deps_dir @@ -591,7 +682,7 @@ def fix_bin_or_dylib(self, fname): "nix-build", "-E", nix_expr, "-o", nix_deps_dir, ]) except subprocess.CalledProcessError as reason: - print("warning: failed to call nix-build:", reason) + print("warning: failed to call nix-build:", reason, file=sys.stderr) return self.nix_deps_dir = nix_deps_dir @@ -611,7 +702,7 @@ def fix_bin_or_dylib(self, fname): try: subprocess.check_output([patchelf] + patchelf_args + [fname]) except subprocess.CalledProcessError as reason: - print("warning: failed to call patchelf:", reason) + print("warning: failed to call patchelf:", reason, file=sys.stderr) return def rustc_stamp(self): @@ -755,7 +846,7 @@ def build_bootstrap(self, color, verbose_count): if "GITHUB_ACTIONS" in env: print("::group::Building bootstrap") else: - print("Building bootstrap") + print("Building bootstrap", file=sys.stderr) build_dir = os.path.join(self.build_dir, "bootstrap") if self.clean and os.path.exists(build_dir): shutil.rmtree(build_dir) @@ -849,9 +940,12 @@ def check_vendored_status(self): if 'SUDO_USER' in os.environ and not self.use_vendored_sources: if os.getuid() == 0: self.use_vendored_sources = True - print('info: looks like you\'re trying to run this command as root') - print(' and so in order to preserve your $HOME this will now') - print(' use vendored sources by default.') + print('info: looks like you\'re trying to run this command as root', + file=sys.stderr) + print(' and so in order to preserve your $HOME this will now', + file=sys.stderr) + print(' use vendored sources by default.', + file=sys.stderr) cargo_dir = os.path.join(self.rust_root, '.cargo') if self.use_vendored_sources: @@ -861,14 +955,18 @@ def check_vendored_status(self): "--sync ./src/tools/rust-analyzer/Cargo.toml " \ "--sync ./compiler/rustc_codegen_cranelift/Cargo.toml " \ "--sync ./src/bootstrap/Cargo.toml " - print('error: vendoring required, but vendor directory does not exist.') + print('error: vendoring required, but vendor directory does not exist.', + file=sys.stderr) print(' Run `cargo vendor {}` to initialize the ' - 'vendor directory.'.format(sync_dirs)) - print('Alternatively, use the pre-vendored `rustc-src` dist component.') + 'vendor directory.'.format(sync_dirs), + file=sys.stderr) + print('Alternatively, use the pre-vendored `rustc-src` dist component.', + file=sys.stderr) raise Exception("{} not found".format(vendor_dir)) if not os.path.exists(cargo_dir): - print('error: vendoring required, but .cargo/config does not exist.') + print('error: vendoring required, but .cargo/config does not exist.', + file=sys.stderr) raise Exception("{} not found".format(cargo_dir)) else: if os.path.exists(cargo_dir): @@ -978,7 +1076,7 @@ def main(): print( "info: Downloading and building bootstrap before processing --help command.\n" " See src/bootstrap/README.md for help with common commands." - ) + , file=sys.stderr) exit_code = 0 success_word = "successfully" @@ -989,11 +1087,12 @@ def main(): exit_code = error.code else: exit_code = 1 - print(error) + print(error, file=sys.stderr) success_word = "unsuccessfully" if not help_triggered: - print("Build completed", success_word, "in", format_build_time(time() - start_time)) + print("Build completed", success_word, "in", format_build_time(time() - start_time), + file=sys.stderr) sys.exit(exit_code) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 0d2d512b4b2ae..d9d4685dfc790 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -634,6 +634,14 @@ impl Kind { Kind::Suggest => "suggest", } } + + pub fn test_description(&self) -> &'static str { + match self { + Kind::Test => "Testing", + Kind::Bench => "Benchmarking", + _ => panic!("not a test command: {}!", self.as_str()), + } + } } impl<'a> Builder<'a> { @@ -695,7 +703,6 @@ impl<'a> Builder<'a> { crate::toolstate::ToolStateCheck, test::ExpandYamlAnchors, test::Tidy, - test::TidySelfTest, test::Ui, test::RunPassValgrind, test::MirOpt, @@ -711,11 +718,9 @@ impl<'a> Builder<'a> { test::CrateLibrustc, test::CrateRustdoc, test::CrateRustdocJsonTypes, - test::CrateJsonDocLint, - test::SuggestTestsCrate, + test::CrateBootstrap, test::Linkcheck, test::TierCheck, - test::ReplacePlaceholderTest, test::Cargotest, test::Cargo, test::RustAnalyzer, diff --git a/src/bootstrap/builder/tests.rs b/src/bootstrap/builder/tests.rs index 3574f11189ee9..72ac46b6bfddd 100644 --- a/src/bootstrap/builder/tests.rs +++ b/src/bootstrap/builder/tests.rs @@ -578,7 +578,6 @@ mod dist { compiler: Compiler { host, stage: 0 }, target: host, mode: Mode::Std, - test_kind: test::TestKind::Test, crates: vec![INTERNER.intern_str("std")], },] ); diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index ca6dcaf495743..4ef95b3370ff8 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -1309,7 +1309,7 @@ impl Config { if config.llvm_from_ci { let triple = &config.build.triple; let ci_llvm_bin = config.ci_llvm_root().join("bin"); - let mut build_target = config + let build_target = config .target_config .entry(config.build) .or_insert_with(|| Target::from_triple(&triple)); diff --git a/src/bootstrap/download.rs b/src/bootstrap/download.rs index 133cda639d976..c1cf9b93fb356 100644 --- a/src/bootstrap/download.rs +++ b/src/bootstrap/download.rs @@ -112,7 +112,7 @@ impl Config { is_nixos && !Path::new("/lib").exists() }); if val { - println!("info: You seem to be using Nix."); + eprintln!("info: You seem to be using Nix."); } val } @@ -226,7 +226,7 @@ impl Config { curl.stdout(Stdio::from(f)); if !self.check_run(&mut curl) { if self.build.contains("windows-msvc") { - println!("Fallback to PowerShell"); + eprintln!("Fallback to PowerShell"); for _ in 0..3 { if self.try_run(Command::new("PowerShell.exe").args(&[ "/nologo", @@ -239,7 +239,7 @@ impl Config { ])) { return; } - println!("\nspurious failure, trying again"); + eprintln!("\nspurious failure, trying again"); } } if !help_on_error.is_empty() { @@ -250,7 +250,7 @@ impl Config { } fn unpack(&self, tarball: &Path, dst: &Path, pattern: &str) { - println!("extracting {} to {}", tarball.display(), dst.display()); + eprintln!("extracting {} to {}", tarball.display(), dst.display()); if !dst.exists() { t!(fs::create_dir_all(dst)); } @@ -541,7 +541,18 @@ impl Config { None }; - self.download_file(&format!("{base_url}/{url}"), &tarball, ""); + let mut help_on_error = ""; + if destination == "ci-rustc" { + help_on_error = "error: failed to download pre-built rustc from CI + +note: old builds get deleted after a certain time +help: if trying to compile an old commit of rustc, disable `download-rustc` in config.toml: + +[rust] +download-rustc = false +"; + } + self.download_file(&format!("{base_url}/{url}"), &tarball, help_on_error); if let Some(sha256) = checksum { if !self.verify(&tarball, sha256) { panic!("failed to verify {}", tarball.display()); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 14e1328171b9a..59d2e9cc69e79 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -246,6 +246,7 @@ struct Crate { name: Interned<String>, deps: HashSet<Interned<String>>, path: PathBuf, + has_lib: bool, } impl Crate { diff --git a/src/bootstrap/metadata.rs b/src/bootstrap/metadata.rs index 597aefadcfe4c..8f2c3faca3a48 100644 --- a/src/bootstrap/metadata.rs +++ b/src/bootstrap/metadata.rs @@ -5,7 +5,7 @@ use serde_derive::Deserialize; use crate::cache::INTERNER; use crate::util::output; -use crate::{Build, Crate}; +use crate::{t, Build, Crate}; /// For more information, see the output of /// <https://doc.rust-lang.org/nightly/cargo/commands/cargo-metadata.html> @@ -22,6 +22,7 @@ struct Package { source: Option<String>, manifest_path: String, dependencies: Vec<Dependency>, + targets: Vec<Target>, } /// For more information, see the output of @@ -32,6 +33,11 @@ struct Dependency { source: Option<String>, } +#[derive(Debug, Deserialize)] +struct Target { + kind: Vec<String>, +} + /// Collects and stores package metadata of each workspace members into `build`, /// by executing `cargo metadata` commands. pub fn build(build: &mut Build) { @@ -46,11 +52,16 @@ pub fn build(build: &mut Build) { .filter(|dep| dep.source.is_none()) .map(|dep| INTERNER.intern_string(dep.name)) .collect(); - let krate = Crate { name, deps, path }; + let has_lib = package.targets.iter().any(|t| t.kind.iter().any(|k| k == "lib")); + let krate = Crate { name, deps, path, has_lib }; let relative_path = krate.local_path(build); build.crates.insert(name, krate); let existing_path = build.crate_paths.insert(relative_path, name); - assert!(existing_path.is_none(), "multiple crates with the same path"); + assert!( + existing_path.is_none(), + "multiple crates with the same path: {}", + existing_path.unwrap() + ); } } } @@ -60,7 +71,7 @@ pub fn build(build: &mut Build) { /// Note that `src/tools/cargo` is no longer a workspace member but we still /// treat it as one here, by invoking an additional `cargo metadata` command. fn workspace_members(build: &Build) -> impl Iterator<Item = Package> { - let cmd_metadata = |manifest_path| { + let collect_metadata = |manifest_path| { let mut cargo = Command::new(&build.initial_cargo); cargo .arg("metadata") @@ -68,21 +79,20 @@ fn workspace_members(build: &Build) -> impl Iterator<Item = Package> { .arg("1") .arg("--no-deps") .arg("--manifest-path") - .arg(manifest_path); - cargo + .arg(build.src.join(manifest_path)); + let metadata_output = output(&mut cargo); + let Output { packages, .. } = t!(serde_json::from_str(&metadata_output)); + packages }; - // Collects `metadata.packages` from the root workspace. - let root_manifest_path = build.src.join("Cargo.toml"); - let root_output = output(&mut cmd_metadata(&root_manifest_path)); - let Output { packages, .. } = serde_json::from_str(&root_output).unwrap(); - - // Collects `metadata.packages` from src/tools/cargo separately. - let cargo_manifest_path = build.src.join("src/tools/cargo/Cargo.toml"); - let cargo_output = output(&mut cmd_metadata(&cargo_manifest_path)); - let Output { packages: cargo_packages, .. } = serde_json::from_str(&cargo_output).unwrap(); + // Collects `metadata.packages` from all workspaces. + let packages = collect_metadata("Cargo.toml"); + let cargo_packages = collect_metadata("src/tools/cargo/Cargo.toml"); + let ra_packages = collect_metadata("src/tools/rust-analyzer/Cargo.toml"); + let bootstrap_packages = collect_metadata("src/bootstrap/Cargo.toml"); // We only care about the root package from `src/tool/cargo` workspace. let cargo_package = cargo_packages.into_iter().find(|pkg| pkg.name == "cargo").into_iter(); - packages.into_iter().chain(cargo_package) + + packages.into_iter().chain(cargo_package).chain(ra_packages).chain(bootstrap_packages) } diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 601351ea8e3c0..aee84e9c9beb9 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -13,6 +13,7 @@ use std::process::{Command, Stdio}; use crate::builder::crate_description; use crate::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step}; use crate::cache::Interned; +use crate::cache::INTERNER; use crate::compile; use crate::config::TargetSelection; use crate::dist; @@ -27,44 +28,6 @@ use crate::{envify, CLang, DocTests, GitRepo, Mode}; const ADB_TEST_DIR: &str = "/data/local/tmp/work"; -/// The two modes of the test runner; tests or benchmarks. -#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, PartialOrd, Ord)] -pub enum TestKind { - /// Run `cargo test`. - Test, - /// Run `cargo bench`. - Bench, -} - -impl From<Kind> for TestKind { - fn from(kind: Kind) -> Self { - match kind { - Kind::Test => TestKind::Test, - Kind::Bench => TestKind::Bench, - _ => panic!("unexpected kind in crate: {:?}", kind), - } - } -} - -impl TestKind { - // Return the cargo subcommand for this test kind - fn subcommand(self) -> &'static str { - match self { - TestKind::Test => "test", - TestKind::Bench => "bench", - } - } -} - -impl Into<Kind> for TestKind { - fn into(self) -> Kind { - match self { - TestKind::Test => Kind::Test, - TestKind::Bench => Kind::Bench, - } - } -} - fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool { if !builder.fail_fast { if !builder.try_run(cmd) { @@ -92,26 +55,37 @@ fn try_run_quiet(builder: &Builder<'_>, cmd: &mut Command) -> bool { } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub struct CrateJsonDocLint { +pub struct CrateBootstrap { + path: Interned<PathBuf>, host: TargetSelection, } -impl Step for CrateJsonDocLint { +impl Step for CrateBootstrap { type Output = (); const ONLY_HOSTS: bool = true; const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/jsondoclint") + .path("src/tools/suggest-tests") + .path("src/tools/replace-version-placeholder") + .alias("tidyselftest") } fn make_run(run: RunConfig<'_>) { - run.builder.ensure(CrateJsonDocLint { host: run.target }); + for path in run.paths { + let path = INTERNER.intern_path(path.assert_single_path().path.clone()); + run.builder.ensure(CrateBootstrap { host: run.target, path }); + } } fn run(self, builder: &Builder<'_>) { let bootstrap_host = builder.config.build; let compiler = builder.compiler(0, bootstrap_host); + let mut path = self.path.to_str().unwrap(); + if path == "tidyselftest" { + path = "src/tools/tidy"; + } let cargo = tool::prepare_tool_cargo( builder, @@ -119,47 +93,18 @@ impl Step for CrateJsonDocLint { Mode::ToolBootstrap, bootstrap_host, "test", - "src/tools/jsondoclint", + path, SourceType::InTree, &[], ); - add_flags_and_try_run_tests(builder, &mut cargo.into()); - } -} - -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub struct SuggestTestsCrate { - host: TargetSelection, -} - -impl Step for SuggestTestsCrate { - type Output = (); - const ONLY_HOSTS: bool = true; - const DEFAULT: bool = true; - - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.path("src/tools/suggest-tests") - } - - fn make_run(run: RunConfig<'_>) { - run.builder.ensure(SuggestTestsCrate { host: run.target }); - } - - fn run(self, builder: &Builder<'_>) { - let bootstrap_host = builder.config.build; - let compiler = builder.compiler(0, bootstrap_host); - - let suggest_tests = tool::prepare_tool_cargo( - builder, - compiler, - Mode::ToolBootstrap, + builder.info(&format!( + "{} {} stage0 ({})", + builder.kind.test_description(), + path, bootstrap_host, - "test", - "src/tools/suggest-tests", - SourceType::InTree, - &[], - ); - add_flags_and_try_run_tests(builder, &mut suggest_tests.into()); + )); + let crate_name = path.rsplit_once('/').unwrap().1; + run_cargo_test(cargo, &[], &[], crate_name, compiler, bootstrap_host, builder); } } @@ -208,7 +153,11 @@ You can skip linkcheck with --exclude src/tools/linkchecker" SourceType::InTree, &[], ); - add_flags_and_try_run_tests(builder, &mut cargo.into()); + run_cargo_test(cargo, &[], &[], "linkchecker", compiler, bootstrap_host, builder); + + if builder.doc_tests == DocTests::No { + return; + } // Build all the default documentation. builder.default_doc(&[]); @@ -344,7 +293,7 @@ impl Step for Cargo { let compiler = builder.compiler(self.stage, self.host); builder.ensure(tool::Cargo { compiler, target: self.host }); - let mut cargo = tool::prepare_tool_cargo( + let cargo = tool::prepare_tool_cargo( builder, compiler, Mode::ToolRustc, @@ -355,10 +304,8 @@ impl Step for Cargo { &[], ); - if !builder.fail_fast { - cargo.arg("--no-fail-fast"); - } - cargo.arg("--").args(builder.config.cmd.test_args()); + // NOTE: can't use `run_cargo_test` because we need to overwrite `PATH` + let mut cargo = prepare_cargo_test(cargo, &[], &[], "cargo", compiler, self.host, builder); // Don't run cross-compile tests, we may not have cross-compiled libstd libs // available. @@ -366,10 +313,10 @@ impl Step for Cargo { // Forcibly disable tests using nightly features since any changes to // those features won't be able to land. cargo.env("CARGO_TEST_DISABLE_NIGHTLY", "1"); - cargo.env("PATH", &path_for_cargo(builder, compiler)); - add_flags_and_try_run_tests(builder, &mut cargo.into()); + let _time = util::timeit(&builder); + add_flags_and_try_run_tests(builder, &mut cargo); } } @@ -426,9 +373,7 @@ impl Step for RustAnalyzer { cargo.env("SKIP_SLOW_TESTS", "1"); cargo.add_rustc_lib_path(builder, compiler); - cargo.arg("--").args(builder.config.cmd.test_args()); - - add_flags_and_try_run_tests(builder, &mut cargo.into()); + run_cargo_test(cargo, &[], &[], "rust-analyzer", compiler, host, builder); } } @@ -471,17 +416,13 @@ impl Step for Rustfmt { &[], ); - if !builder.fail_fast { - cargo.arg("--no-fail-fast"); - } - let dir = testdir(builder, compiler.host); t!(fs::create_dir_all(&dir)); cargo.env("RUSTFMT_TEST_DIR", dir); cargo.add_rustc_lib_path(builder, compiler); - add_flags_and_try_run_tests(builder, &mut cargo.into()); + run_cargo_test(cargo, &[], &[], "rustfmt", compiler, host, builder); } } @@ -527,12 +468,9 @@ impl Step for RustDemangler { t!(fs::create_dir_all(&dir)); cargo.env("RUST_DEMANGLER_DRIVER_PATH", rust_demangler); - - cargo.arg("--").args(builder.config.cmd.test_args()); - cargo.add_rustc_lib_path(builder, compiler); - add_flags_and_try_run_tests(builder, &mut cargo.into()); + run_cargo_test(cargo, &[], &[], "rust-demangler", compiler, host, builder); } } @@ -655,10 +593,6 @@ impl Step for Miri { ); cargo.add_rustc_lib_path(builder, compiler); - if !builder.fail_fast { - cargo.arg("--no-fail-fast"); - } - // miri tests need to know about the stage sysroot cargo.env("MIRI_SYSROOT", &miri_sysroot); cargo.env("MIRI_HOST_SYSROOT", sysroot); @@ -670,13 +604,14 @@ impl Step for Miri { // Set the target. cargo.env("MIRI_TEST_TARGET", target.rustc_target_arg()); - // Forward test filters. - cargo.arg("--").args(builder.config.cmd.test_args()); - // This can NOT be `add_flags_and_try_run_tests` since the Miri test runner - // does not understand those flags! - let mut cargo = Command::from(cargo); - builder.run(&mut cargo); + // This can NOT be `run_cargo_test` since the Miri test runner + // does not understand the flags added by `add_flags_and_try_run_test`. + let mut cargo = prepare_cargo_test(cargo, &[], &[], "miri", compiler, target, builder); + { + let _time = util::timeit(&builder); + builder.run(&mut cargo); + } // # Run `cargo miri test`. // This is just a smoke test (Miri's own CI invokes this in a bunch of different ways and ensures @@ -709,6 +644,7 @@ impl Step for Miri { cargo.env("RUST_BACKTRACE", "1"); let mut cargo = Command::from(cargo); + let _time = util::timeit(&builder); builder.run(&mut cargo); } } @@ -748,8 +684,7 @@ impl Step for CompiletestTest { &[], ); cargo.allow_features("test"); - - add_flags_and_try_run_tests(builder, &mut cargo.into()); + run_cargo_test(cargo, &[], &[], "compiletest", compiler, host, builder); } } @@ -792,20 +727,15 @@ impl Step for Clippy { &[], ); - if !builder.fail_fast { - cargo.arg("--no-fail-fast"); - } - cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler)); cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler)); let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir()); cargo.env("HOST_LIBS", host_libs); - cargo.arg("--").args(builder.config.cmd.test_args()); - cargo.add_rustc_lib_path(builder, compiler); + let mut cargo = prepare_cargo_test(cargo, &[], &[], "clippy", compiler, host, builder); - if builder.try_run(&mut cargo.into()) { + if builder.try_run(&mut cargo) { // The tests succeeded; nothing to do. return; } @@ -1203,40 +1133,6 @@ help: to skip test's attempt to check tidiness, pass `--exclude src/tools/tidy` } } -/// Runs tidy's own tests. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub struct TidySelfTest; - -impl Step for TidySelfTest { - type Output = (); - const DEFAULT: bool = true; - const ONLY_HOSTS: bool = true; - - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.alias("tidyselftest") - } - - fn make_run(run: RunConfig<'_>) { - run.builder.ensure(TidySelfTest); - } - - fn run(self, builder: &Builder<'_>) { - let bootstrap_host = builder.config.build; - let compiler = builder.compiler(0, bootstrap_host); - let cargo = tool::prepare_tool_cargo( - builder, - compiler, - Mode::ToolBootstrap, - bootstrap_host, - "test", - "src/tools/tidy", - SourceType::InTree, - &[], - ); - add_flags_and_try_run_tests(builder, &mut cargo.into()); - } -} - #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct ExpandYamlAnchors; @@ -2111,7 +2007,6 @@ impl Step for RustcGuide { pub struct CrateLibrustc { compiler: Compiler, target: TargetSelection, - test_kind: TestKind, crates: Vec<Interned<String>>, } @@ -2133,9 +2028,8 @@ impl Step for CrateLibrustc { .iter() .map(|p| builder.crate_paths[&p.assert_single_path().path].clone()) .collect(); - let test_kind = builder.kind.into(); - builder.ensure(CrateLibrustc { compiler, target: run.target, test_kind, crates }); + builder.ensure(CrateLibrustc { compiler, target: run.target, crates }); } fn run(self, builder: &Builder<'_>) { @@ -2143,18 +2037,106 @@ impl Step for CrateLibrustc { compiler: self.compiler, target: self.target, mode: Mode::Rustc, - test_kind: self.test_kind, crates: self.crates, }); } } +/// Given a `cargo test` subcommand, add the appropriate flags and run it. +/// +/// Returns whether the test succeeded. +fn run_cargo_test( + cargo: impl Into<Command>, + libtest_args: &[&str], + crates: &[Interned<String>], + primary_crate: &str, + compiler: Compiler, + target: TargetSelection, + builder: &Builder<'_>, +) -> bool { + let mut cargo = + prepare_cargo_test(cargo, libtest_args, crates, primary_crate, compiler, target, builder); + let _time = util::timeit(&builder); + add_flags_and_try_run_tests(builder, &mut cargo) +} + +/// Given a `cargo test` subcommand, pass it the appropriate test flags given a `builder`. +fn prepare_cargo_test( + cargo: impl Into<Command>, + libtest_args: &[&str], + crates: &[Interned<String>], + primary_crate: &str, + compiler: Compiler, + target: TargetSelection, + builder: &Builder<'_>, +) -> Command { + let mut cargo = cargo.into(); + + // Pass in some standard flags then iterate over the graph we've discovered + // in `cargo metadata` with the maps above and figure out what `-p` + // arguments need to get passed. + if builder.kind == Kind::Test && !builder.fail_fast { + cargo.arg("--no-fail-fast"); + } + match builder.doc_tests { + DocTests::Only => { + cargo.arg("--doc"); + } + DocTests::No => { + let krate = &builder + .crates + .get(&INTERNER.intern_str(primary_crate)) + .unwrap_or_else(|| panic!("missing crate {primary_crate}")); + if krate.has_lib { + cargo.arg("--lib"); + } + cargo.args(&["--bins", "--examples", "--tests", "--benches"]); + } + DocTests::Yes => {} + } + + for &krate in crates { + cargo.arg("-p").arg(krate); + } + + cargo.arg("--").args(&builder.config.cmd.test_args()).args(libtest_args); + if !builder.config.verbose_tests { + cargo.arg("--quiet"); + } + + // The tests are going to run with the *target* libraries, so we need to + // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent. + // + // Note that to run the compiler we need to run with the *host* libraries, + // but our wrapper scripts arrange for that to be the case anyway. + let mut dylib_path = dylib_path(); + dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target))); + cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap()); + + if target.contains("emscripten") { + cargo.env( + format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), + builder.config.nodejs.as_ref().expect("nodejs not configured"), + ); + } else if target.starts_with("wasm32") { + let node = builder.config.nodejs.as_ref().expect("nodejs not configured"); + let runner = format!("{} {}/src/etc/wasm32-shim.js", node.display(), builder.src.display()); + cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), &runner); + } else if builder.remote_tested(target) { + cargo.env( + format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), + format!("{} run 0", builder.tool_exe(Tool::RemoteTestClient).display()), + ); + } + + cargo +} + #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Crate { pub compiler: Compiler, pub target: TargetSelection, pub mode: Mode, - pub test_kind: TestKind, pub crates: Vec<Interned<String>>, } @@ -2170,14 +2152,13 @@ impl Step for Crate { let builder = run.builder; let host = run.build_triple(); let compiler = builder.compiler_for(builder.top_stage, host, host); - let test_kind = builder.kind.into(); let crates = run .paths .iter() .map(|p| builder.crate_paths[&p.assert_single_path().path].clone()) .collect(); - builder.ensure(Crate { compiler, target: run.target, mode: Mode::Std, test_kind, crates }); + builder.ensure(Crate { compiler, target: run.target, mode: Mode::Std, crates }); } /// Runs all unit tests plus documentation tests for a given crate defined @@ -2192,7 +2173,6 @@ impl Step for Crate { let compiler = self.compiler; let target = self.target; let mode = self.mode; - let test_kind = self.test_kind; builder.ensure(compile::Std::new(compiler, target)); builder.ensure(RemoteCopyLibs { compiler, target }); @@ -2204,7 +2184,7 @@ impl Step for Crate { let compiler = builder.compiler_for(compiler.stage, compiler.host, target); let mut cargo = - builder.cargo(compiler, mode, SourceType::InTree, target, test_kind.subcommand()); + builder.cargo(compiler, mode, SourceType::InTree, target, builder.kind.as_str()); match mode { Mode::Std => { compile::std_cargo(builder, target, compiler.stage, &mut cargo); @@ -2215,69 +2195,14 @@ impl Step for Crate { _ => panic!("can only test libraries"), }; - // Build up the base `cargo test` command. - // - // Pass in some standard flags then iterate over the graph we've discovered - // in `cargo metadata` with the maps above and figure out what `-p` - // arguments need to get passed. - if test_kind.subcommand() == "test" && !builder.fail_fast { - cargo.arg("--no-fail-fast"); - } - match builder.doc_tests { - DocTests::Only => { - cargo.arg("--doc"); - } - DocTests::No => { - cargo.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]); - } - DocTests::Yes => {} - } - - for krate in &self.crates { - cargo.arg("-p").arg(krate); - } - - // The tests are going to run with the *target* libraries, so we need to - // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent. - // - // Note that to run the compiler we need to run with the *host* libraries, - // but our wrapper scripts arrange for that to be the case anyway. - let mut dylib_path = dylib_path(); - dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target))); - cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap()); - - cargo.arg("--"); - cargo.args(&builder.config.cmd.test_args()); - - cargo.arg("-Z").arg("unstable-options"); - cargo.arg("--format").arg("json"); - - if target.contains("emscripten") { - cargo.env( - format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), - builder.config.nodejs.as_ref().expect("nodejs not configured"), - ); - } else if target.starts_with("wasm32") { - let node = builder.config.nodejs.as_ref().expect("nodejs not configured"); - let runner = - format!("{} {}/src/etc/wasm32-shim.js", node.display(), builder.src.display()); - cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), &runner); - } else if builder.remote_tested(target) { - cargo.env( - format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), - format!("{} run 0", builder.tool_exe(Tool::RemoteTestClient).display()), - ); - } - let _guard = builder.msg( - test_kind, + builder.kind, compiler.stage, crate_description(&self.crates), compiler.host, target, ); - let _time = util::timeit(&builder); - crate::render_tests::try_run_tests(builder, &mut cargo.into()); + run_cargo_test(cargo, &[], &self.crates, &self.crates[0], compiler, target, builder); } } @@ -2285,7 +2210,6 @@ impl Step for Crate { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct CrateRustdoc { host: TargetSelection, - test_kind: TestKind, } impl Step for CrateRustdoc { @@ -2300,13 +2224,10 @@ impl Step for CrateRustdoc { fn make_run(run: RunConfig<'_>) { let builder = run.builder; - let test_kind = builder.kind.into(); - - builder.ensure(CrateRustdoc { host: run.target, test_kind }); + builder.ensure(CrateRustdoc { host: run.target }); } fn run(self, builder: &Builder<'_>) { - let test_kind = self.test_kind; let target = self.host; let compiler = if builder.download_rustc() { @@ -2325,29 +2246,11 @@ impl Step for CrateRustdoc { compiler, Mode::ToolRustc, target, - test_kind.subcommand(), + builder.kind.as_str(), "src/tools/rustdoc", SourceType::InTree, &[], ); - if test_kind.subcommand() == "test" && !builder.fail_fast { - cargo.arg("--no-fail-fast"); - } - match builder.doc_tests { - DocTests::Only => { - cargo.arg("--doc"); - } - DocTests::No => { - cargo.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]); - } - DocTests::Yes => {} - } - - cargo.arg("-p").arg("rustdoc:0.0.0"); - - cargo.arg("--"); - cargo.args(&builder.config.cmd.test_args()); - if self.host.contains("musl") { cargo.arg("'-Ctarget-feature=-crt-static'"); } @@ -2387,22 +2290,22 @@ impl Step for CrateRustdoc { dylib_path.insert(0, PathBuf::from(&*libdir)); cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap()); - if !builder.config.verbose_tests { - cargo.arg("--quiet"); - } - - let _guard = builder.msg(test_kind, compiler.stage, "rustdoc", compiler.host, target); - - let _time = util::timeit(&builder); - - add_flags_and_try_run_tests(builder, &mut cargo.into()); + let _guard = builder.msg(builder.kind, compiler.stage, "rustdoc", compiler.host, target); + run_cargo_test( + cargo, + &[], + &[INTERNER.intern_str("rustdoc:0.0.0")], + "rustdoc", + compiler, + target, + builder, + ); } } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct CrateRustdocJsonTypes { host: TargetSelection, - test_kind: TestKind, } impl Step for CrateRustdocJsonTypes { @@ -2417,13 +2320,10 @@ impl Step for CrateRustdocJsonTypes { fn make_run(run: RunConfig<'_>) { let builder = run.builder; - let test_kind = builder.kind.into(); - - builder.ensure(CrateRustdocJsonTypes { host: run.target, test_kind }); + builder.ensure(CrateRustdocJsonTypes { host: run.target }); } fn run(self, builder: &Builder<'_>) { - let test_kind = self.test_kind; let target = self.host; // Use the previous stage compiler to reuse the artifacts that are @@ -2433,34 +2333,35 @@ impl Step for CrateRustdocJsonTypes { let compiler = builder.compiler_for(builder.top_stage, target, target); builder.ensure(compile::Rustc::new(compiler, target)); - let mut cargo = tool::prepare_tool_cargo( + let cargo = tool::prepare_tool_cargo( builder, compiler, Mode::ToolRustc, target, - test_kind.subcommand(), + builder.kind.as_str(), "src/rustdoc-json-types", SourceType::InTree, &[], ); - if test_kind.subcommand() == "test" && !builder.fail_fast { - cargo.arg("--no-fail-fast"); - } - - cargo.arg("-p").arg("rustdoc-json-types"); - - cargo.arg("--"); - cargo.args(&builder.config.cmd.test_args()); - if self.host.contains("musl") { - cargo.arg("'-Ctarget-feature=-crt-static'"); - } + // FIXME: this looks very wrong, libtest doesn't accept `-C` arguments and the quotes are fishy. + let libtest_args = if self.host.contains("musl") { + ["'-Ctarget-feature=-crt-static'"].as_slice() + } else { + &[] + }; let _guard = - builder.msg(test_kind, compiler.stage, "rustdoc-json-types", compiler.host, target); - let _time = util::timeit(&builder); - - add_flags_and_try_run_tests(builder, &mut cargo.into()); + builder.msg(builder.kind, compiler.stage, "rustdoc-json-types", compiler.host, target); + run_cargo_test( + cargo, + libtest_args, + &[INTERNER.intern_str("rustdoc-json-types")], + "rustdoc-json-types", + compiler, + target, + builder, + ); } } @@ -2598,13 +2499,15 @@ impl Step for Bootstrap { check_bootstrap.arg("bootstrap_test.py").current_dir(builder.src.join("src/bootstrap/")); try_run(builder, &mut check_bootstrap); + let host = builder.config.build; + let compiler = builder.compiler(0, host); let mut cmd = Command::new(&builder.initial_cargo); cmd.arg("test") .current_dir(builder.src.join("src/bootstrap")) .env("RUSTFLAGS", "-Cdebuginfo=2") .env("CARGO_TARGET_DIR", builder.out.join("bootstrap")) .env("RUSTC_BOOTSTRAP", "1") - .env("RUSTDOC", builder.rustdoc(builder.compiler(0, builder.build.build))) + .env("RUSTDOC", builder.rustdoc(compiler)) .env("RUSTC", &builder.initial_rustc); if let Some(flags) = option_env!("RUSTFLAGS") { // Use the same rustc flags for testing as for "normal" compilation, @@ -2612,24 +2515,9 @@ impl Step for Bootstrap { // https://github.com/rust-lang/rust/issues/49215 cmd.env("RUSTFLAGS", flags); } - if !builder.fail_fast { - cmd.arg("--no-fail-fast"); - } - match builder.doc_tests { - DocTests::Only => { - cmd.arg("--doc"); - } - DocTests::No => { - cmd.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]); - } - DocTests::Yes => {} - } - - cmd.arg("--").args(&builder.config.cmd.test_args()); // rustbuild tests are racy on directory creation so just run them one at a time. // Since there's not many this shouldn't be a problem. - cmd.arg("--test-threads=1"); - add_flags_and_try_run_tests(builder, &mut cmd); + run_cargo_test(cmd, &["--test-threads=1"], &[], "bootstrap", compiler, host, builder); } fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -2685,43 +2573,6 @@ impl Step for TierCheck { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub struct ReplacePlaceholderTest; - -impl Step for ReplacePlaceholderTest { - type Output = (); - const ONLY_HOSTS: bool = true; - const DEFAULT: bool = true; - - /// Ensure the version placeholder replacement tool builds - fn run(self, builder: &Builder<'_>) { - builder.info("build check for version replacement placeholder"); - - // Test the version placeholder replacement tool itself. - let bootstrap_host = builder.config.build; - let compiler = builder.compiler(0, bootstrap_host); - let cargo = tool::prepare_tool_cargo( - builder, - compiler, - Mode::ToolBootstrap, - bootstrap_host, - "test", - "src/tools/replace-version-placeholder", - SourceType::InTree, - &[], - ); - add_flags_and_try_run_tests(builder, &mut cargo.into()); - } - - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.path("src/tools/replace-version-placeholder") - } - - fn make_run(run: RunConfig<'_>) { - run.builder.ensure(Self); - } -} - #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct LintDocs { pub compiler: Compiler, @@ -2779,7 +2630,7 @@ impl Step for RustInstaller { SourceType::InTree, &[], ); - try_run(builder, &mut cargo.into()); + run_cargo_test(cargo, &[], &[], "installer", compiler, bootstrap_host, builder); // We currently don't support running the test.sh script outside linux(?) environments. // Eventually this should likely migrate to #[test]s in rust-installer proper rather than a diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 9418cf0a7ed1e..39f6369b4d3f5 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -141,7 +141,7 @@ pub fn prepare_tool_cargo( mode: Mode, target: TargetSelection, command: &'static str, - path: &'static str, + path: &str, source_type: SourceType, extra_features: &[String], ) -> CargoCommand { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 8ccdb16b784ef..1531e7fc7b91d 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1529,7 +1529,9 @@ fn maybe_expand_private_type_alias<'tcx>( let Res::Def(DefKind::TyAlias, def_id) = path.res else { return None }; // Substitute private type aliases let def_id = def_id.as_local()?; - let alias = if !cx.cache.effective_visibilities.is_exported(cx.tcx, def_id.to_def_id()) { + let alias = if !cx.cache.effective_visibilities.is_exported(cx.tcx, def_id.to_def_id()) + && !cx.current_type_aliases.contains_key(&def_id.to_def_id()) + { &cx.tcx.hir().expect_item(def_id).kind } else { return None; @@ -1609,7 +1611,7 @@ fn maybe_expand_private_type_alias<'tcx>( } } - Some(cx.enter_alias(substs, |cx| clean_ty(ty, cx))) + Some(cx.enter_alias(substs, def_id.to_def_id(), |cx| clean_ty(ty, cx))) } pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type { @@ -1700,7 +1702,7 @@ fn normalize<'tcx>( pub(crate) fn clean_middle_ty<'tcx>( bound_ty: ty::Binder<'tcx, Ty<'tcx>>, cx: &mut DocContext<'tcx>, - def_id: Option<DefId>, + parent_def_id: Option<DefId>, ) -> Type { let bound_ty = normalize(cx, bound_ty).unwrap_or(bound_ty); match *bound_ty.skip_binder().kind() { @@ -1830,7 +1832,9 @@ pub(crate) fn clean_middle_ty<'tcx>( Tuple(t.iter().map(|t| clean_middle_ty(bound_ty.rebind(t), cx, None)).collect()) } - ty::Alias(ty::Projection, ref data) => clean_projection(bound_ty.rebind(*data), cx, def_id), + ty::Alias(ty::Projection, ref data) => { + clean_projection(bound_ty.rebind(*data), cx, parent_def_id) + } ty::Param(ref p) => { if let Some(bounds) = cx.impl_trait_bounds.remove(&p.index.into()) { @@ -1841,15 +1845,30 @@ pub(crate) fn clean_middle_ty<'tcx>( } ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => { - // Grab the "TraitA + TraitB" from `impl TraitA + TraitB`, - // by looking up the bounds associated with the def_id. - let bounds = cx - .tcx - .explicit_item_bounds(def_id) - .subst_iter_copied(cx.tcx, substs) - .map(|(bound, _)| bound) - .collect::<Vec<_>>(); - clean_middle_opaque_bounds(cx, bounds) + // If it's already in the same alias, don't get an infinite loop. + if cx.current_type_aliases.contains_key(&def_id) { + let path = + external_path(cx, def_id, false, ThinVec::new(), bound_ty.rebind(substs)); + Type::Path { path } + } else { + *cx.current_type_aliases.entry(def_id).or_insert(0) += 1; + // Grab the "TraitA + TraitB" from `impl TraitA + TraitB`, + // by looking up the bounds associated with the def_id. + let bounds = cx + .tcx + .explicit_item_bounds(def_id) + .subst_iter_copied(cx.tcx, substs) + .map(|(bound, _)| bound) + .collect::<Vec<_>>(); + let ty = clean_middle_opaque_bounds(cx, bounds); + if let Some(count) = cx.current_type_aliases.get_mut(&def_id) { + *count -= 1; + if *count == 0 { + cx.current_type_aliases.remove(&def_id); + } + } + ty + } } ty::Closure(..) => panic!("Closure"), @@ -2229,13 +2248,17 @@ fn clean_maybe_renamed_item<'tcx>( generics: clean_generics(ty.generics, cx), }), ItemKind::TyAlias(hir_ty, generics) => { + *cx.current_type_aliases.entry(def_id).or_insert(0) += 1; let rustdoc_ty = clean_ty(hir_ty, cx); let ty = clean_middle_ty(ty::Binder::dummy(hir_ty_to_ty(cx.tcx, hir_ty)), cx, None); - TypedefItem(Box::new(Typedef { - type_: rustdoc_ty, - generics: clean_generics(generics, cx), - item_type: Some(ty), - })) + let generics = clean_generics(generics, cx); + if let Some(count) = cx.current_type_aliases.get_mut(&def_id) { + *count -= 1; + if *count == 0 { + cx.current_type_aliases.remove(&def_id); + } + } + TypedefItem(Box::new(Typedef { type_: rustdoc_ty, generics, item_type: Some(ty) })) } ItemKind::Enum(ref def, generics) => EnumItem(Enum { variants: def.variants.iter().map(|v| clean_variant(v, cx)).collect(), diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 74f330b76217b..7371b44465bab 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -11,6 +11,7 @@ use arrayvec::ArrayVec; use thin_vec::ThinVec; use rustc_ast as ast; +use rustc_ast_pretty::pprust; use rustc_attr::{ConstStability, Deprecation, Stability, StabilityLevel}; use rustc_const_eval::const_eval::is_unstable_const_fn; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; @@ -711,6 +712,78 @@ impl Item { }; Some(tcx.visibility(def_id)) } + + pub(crate) fn attributes(&self, tcx: TyCtxt<'_>, keep_as_is: bool) -> Vec<String> { + const ALLOWED_ATTRIBUTES: &[Symbol] = + &[sym::export_name, sym::link_section, sym::no_mangle, sym::repr, sym::non_exhaustive]; + + use rustc_abi::IntegerType; + use rustc_middle::ty::ReprFlags; + + let mut attrs: Vec<String> = self + .attrs + .other_attrs + .iter() + .filter_map(|attr| { + if keep_as_is { + Some(pprust::attribute_to_string(attr)) + } else if ALLOWED_ATTRIBUTES.contains(&attr.name_or_empty()) { + Some( + pprust::attribute_to_string(attr) + .replace("\\\n", "") + .replace('\n', "") + .replace(" ", " "), + ) + } else { + None + } + }) + .collect(); + if let Some(def_id) = self.item_id.as_def_id() && + !def_id.is_local() && + // This check is needed because `adt_def` will panic if not a compatible type otherwise... + matches!(self.type_(), ItemType::Struct | ItemType::Enum | ItemType::Union) + { + let repr = tcx.adt_def(def_id).repr(); + let mut out = Vec::new(); + if repr.flags.contains(ReprFlags::IS_C) { + out.push("C"); + } + if repr.flags.contains(ReprFlags::IS_TRANSPARENT) { + out.push("transparent"); + } + if repr.flags.contains(ReprFlags::IS_SIMD) { + out.push("simd"); + } + let pack_s; + if let Some(pack) = repr.pack { + pack_s = format!("packed({})", pack.bytes()); + out.push(&pack_s); + } + let align_s; + if let Some(align) = repr.align { + align_s = format!("align({})", align.bytes()); + out.push(&align_s); + } + let int_s; + if let Some(int) = repr.int { + int_s = match int { + IntegerType::Pointer(is_signed) => { + format!("{}size", if is_signed { 'i' } else { 'u' }) + } + IntegerType::Fixed(size, is_signed) => { + format!("{}{}", if is_signed { 'i' } else { 'u' }, size.size().bytes() * 8) + } + }; + out.push(&int_s); + } + if out.is_empty() { + return Vec::new(); + } + attrs.push(format!("#[repr({})]", out.join(", "))); + } + attrs + } } #[derive(Clone, Debug)] diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 46834a1d7f4e9..3a0c2ab02975a 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -46,6 +46,7 @@ pub(crate) struct DocContext<'tcx> { // for expanding type aliases at the HIR level: /// Table `DefId` of type, lifetime, or const parameter -> substituted type, lifetime, or const pub(crate) substs: DefIdMap<clean::SubstParam>, + pub(crate) current_type_aliases: DefIdMap<usize>, /// Table synthetic type parameter for `impl Trait` in argument position -> bounds pub(crate) impl_trait_bounds: FxHashMap<ImplTraitParam, Vec<clean::GenericBound>>, /// Auto-trait or blanket impls processed so far, as `(self_ty, trait_def_id)`. @@ -82,13 +83,25 @@ impl<'tcx> DocContext<'tcx> { /// Call the closure with the given parameters set as /// the substitutions for a type alias' RHS. - pub(crate) fn enter_alias<F, R>(&mut self, substs: DefIdMap<clean::SubstParam>, f: F) -> R + pub(crate) fn enter_alias<F, R>( + &mut self, + substs: DefIdMap<clean::SubstParam>, + def_id: DefId, + f: F, + ) -> R where F: FnOnce(&mut Self) -> R, { let old_substs = mem::replace(&mut self.substs, substs); + *self.current_type_aliases.entry(def_id).or_insert(0) += 1; let r = f(self); self.substs = old_substs; + if let Some(count) = self.current_type_aliases.get_mut(&def_id) { + *count -= 1; + if *count == 0 { + self.current_type_aliases.remove(&def_id); + } + } r } @@ -327,6 +340,7 @@ pub(crate) fn run_global_ctxt( external_traits: Default::default(), active_extern_traits: Default::default(), substs: Default::default(), + current_type_aliases: Default::default(), impl_trait_bounds: Default::default(), generated_synthetics: Default::default(), auto_traits, diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index d90d0aecb93ad..73bf27c9d3449 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -48,7 +48,6 @@ use std::str; use std::string::ToString; use askama::Template; -use rustc_ast_pretty::pprust; use rustc_attr::{ConstStability, Deprecation, StabilityLevel}; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; @@ -849,10 +848,10 @@ fn assoc_method( let (indent, indent_str, end_newline) = if parent == ItemType::Trait { header_len += 4; let indent_str = " "; - write!(w, "{}", render_attributes_in_pre(meth, indent_str)); + write!(w, "{}", render_attributes_in_pre(meth, indent_str, tcx)); (4, indent_str, Ending::NoNewline) } else { - render_attributes_in_code(w, meth); + render_attributes_in_code(w, meth, tcx); (0, "", Ending::Newline) }; w.reserve(header_len + "<a href=\"\" class=\"fn\">{".len() + "</a>".len()); @@ -1021,36 +1020,15 @@ fn render_assoc_item( } } -const ALLOWED_ATTRIBUTES: &[Symbol] = - &[sym::export_name, sym::link_section, sym::no_mangle, sym::repr, sym::non_exhaustive]; - -fn attributes(it: &clean::Item) -> Vec<String> { - it.attrs - .other_attrs - .iter() - .filter_map(|attr| { - if ALLOWED_ATTRIBUTES.contains(&attr.name_or_empty()) { - Some( - pprust::attribute_to_string(attr) - .replace("\\\n", "") - .replace('\n', "") - .replace(" ", " "), - ) - } else { - None - } - }) - .collect() -} - // When an attribute is rendered inside a `<pre>` tag, it is formatted using // a whitespace prefix and newline. -fn render_attributes_in_pre<'a>( +fn render_attributes_in_pre<'a, 'b: 'a>( it: &'a clean::Item, prefix: &'a str, -) -> impl fmt::Display + Captures<'a> { + tcx: TyCtxt<'b>, +) -> impl fmt::Display + Captures<'a> + Captures<'b> { crate::html::format::display_fn(move |f| { - for a in attributes(it) { + for a in it.attributes(tcx, false) { writeln!(f, "{}{}", prefix, a)?; } Ok(()) @@ -1059,8 +1037,8 @@ fn render_attributes_in_pre<'a>( // When an attribute is rendered inside a <code> tag, it is formatted using // a div to produce a newline after it. -fn render_attributes_in_code(w: &mut Buffer, it: &clean::Item) { - for a in attributes(it) { +fn render_attributes_in_code(w: &mut Buffer, it: &clean::Item, tcx: TyCtxt<'_>) { + for a in it.attributes(tcx, false) { write!(w, "<div class=\"code-attribute\">{}</div>", a); } } diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 3e71d41ec96f1..4cc81e860f09a 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -548,7 +548,7 @@ fn item_function(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, f: &cle w, "{attrs}{vis}{constness}{asyncness}{unsafety}{abi}fn \ {name}{generics}{decl}{notable_traits}{where_clause}", - attrs = render_attributes_in_pre(it, ""), + attrs = render_attributes_in_pre(it, "", tcx), vis = visibility, constness = constness, asyncness = asyncness, @@ -589,7 +589,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean: it.name.unwrap(), t.generics.print(cx), bounds, - attrs = render_attributes_in_pre(it, ""), + attrs = render_attributes_in_pre(it, "", tcx), ); if !t.generics.where_predicates.is_empty() { @@ -1063,7 +1063,7 @@ fn item_trait_alias(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: & t.generics.print(cx), print_where_clause(&t.generics, cx, 0, Ending::Newline), bounds(&t.bounds, true, cx), - attrs = render_attributes_in_pre(it, ""), + attrs = render_attributes_in_pre(it, "", cx.tcx()), ); }); @@ -1085,7 +1085,7 @@ fn item_opaque_ty(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &cl t.generics.print(cx), where_clause = print_where_clause(&t.generics, cx, 0, Ending::Newline), bounds = bounds(&t.bounds, false, cx), - attrs = render_attributes_in_pre(it, ""), + attrs = render_attributes_in_pre(it, "", cx.tcx()), ); }); @@ -1109,7 +1109,7 @@ fn item_typedef(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clea t.generics.print(cx), where_clause = print_where_clause(&t.generics, cx, 0, Ending::Newline), type_ = t.type_.print(cx), - attrs = render_attributes_in_pre(it, ""), + attrs = render_attributes_in_pre(it, "", cx.tcx()), ); }); } @@ -1168,7 +1168,8 @@ fn item_union(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean: &'b self, ) -> impl fmt::Display + Captures<'a> + 'b + Captures<'cx> { display_fn(move |f| { - let v = render_attributes_in_pre(self.it, ""); + let tcx = self.cx.borrow().tcx(); + let v = render_attributes_in_pre(self.it, "", tcx); write!(f, "{v}") }) } @@ -1244,13 +1245,13 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean:: let tcx = cx.tcx(); let count_variants = e.variants().count(); wrap_item(w, |mut w| { + render_attributes_in_code(w, it, tcx); write!( w, - "{attrs}{}enum {}{}", + "{}enum {}{}", visibility_print_with_space(it.visibility(tcx), it.item_id, cx), it.name.unwrap(), e.generics.print(cx), - attrs = render_attributes_in_pre(it, ""), ); if !print_where_clause_and_check(w, &e.generics, cx) { // If there wasn't a `where` clause, we add a whitespace. @@ -1445,7 +1446,7 @@ fn item_primitive(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item) { fn item_constant(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, c: &clean::Constant) { wrap_item(w, |w| { let tcx = cx.tcx(); - render_attributes_in_code(w, it); + render_attributes_in_code(w, it, tcx); write!( w, @@ -1492,7 +1493,7 @@ fn item_constant(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, c: &cle fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean::Struct) { wrap_item(w, |w| { - render_attributes_in_code(w, it); + render_attributes_in_code(w, it, cx.tcx()); render_struct(w, it, Some(&s.generics), s.ctor_kind, &s.fields, "", true, cx); }); @@ -1542,7 +1543,7 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean fn item_static(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean::Static) { wrap_item(w, |w| { - render_attributes_in_code(w, it); + render_attributes_in_code(w, it, cx.tcx()); write!( w, "{vis}static {mutability}{name}: {typ}", @@ -1558,7 +1559,7 @@ fn item_static(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean fn item_foreign_type(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item) { wrap_item(w, |w| { w.write_str("extern {\n"); - render_attributes_in_code(w, it); + render_attributes_in_code(w, it, cx.tcx()); write!( w, " {}type {};\n}}", diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index edd046ab77233..62aab46fa7e8b 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -41,12 +41,7 @@ impl JsonRenderer<'_> { }) .collect(); let docs = item.attrs.collapsed_doc_value(); - let attrs = item - .attrs - .other_attrs - .iter() - .map(rustc_ast_pretty::pprust::attribute_to_string) - .collect(); + let attrs = item.attributes(self.tcx, true); let span = item.span(self.tcx); let visibility = item.visibility(self.tcx); let clean::Item { name, item_id, .. } = item; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 60754130d997c..66080f64b9c21 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -34,6 +34,7 @@ extern crate tracing; // Dependencies listed in Cargo.toml do not need `extern crate`. extern crate pulldown_cmark; +extern crate rustc_abi; extern crate rustc_ast; extern crate rustc_ast_pretty; extern crate rustc_attr; diff --git a/src/tools/clippy/clippy_lints/src/suspicious_operation_groupings.rs b/src/tools/clippy/clippy_lints/src/suspicious_operation_groupings.rs index fab8e9c2ec1c1..e2cdc48b583c8 100644 --- a/src/tools/clippy/clippy_lints/src/suspicious_operation_groupings.rs +++ b/src/tools/clippy/clippy_lints/src/suspicious_operation_groupings.rs @@ -577,7 +577,7 @@ fn ident_difference_expr_with_base_location( | (AssignOp(_, _, _), AssignOp(_, _, _)) | (Assign(_, _, _), Assign(_, _, _)) | (TryBlock(_), TryBlock(_)) - | (Await(_), Await(_)) + | (Await(_, _), Await(_, _)) | (Async(_, _), Async(_, _)) | (Block(_, _), Block(_, _)) | (Closure(_), Closure(_)) diff --git a/src/tools/clippy/clippy_utils/src/ast_utils.rs b/src/tools/clippy/clippy_utils/src/ast_utils.rs index 1f15598db36d9..8cc01f1ef9740 100644 --- a/src/tools/clippy/clippy_utils/src/ast_utils.rs +++ b/src/tools/clippy/clippy_utils/src/ast_utils.rs @@ -143,7 +143,7 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool { (Paren(l), _) => eq_expr(l, r), (_, Paren(r)) => eq_expr(l, r), (Err, Err) => true, - (Try(l), Try(r)) | (Await(l), Await(r)) => eq_expr(l, r), + (Try(l), Try(r)) | (Await(l, _), Await(r, _)) => eq_expr(l, r), (Array(l), Array(r)) => over(l, r, |l, r| eq_expr(l, r)), (Tup(l), Tup(r)) => over(l, r, |l, r| eq_expr(l, r)), (Repeat(le, ls), Repeat(re, rs)) => eq_expr(le, re) && eq_expr(&ls.value, &rs.value), diff --git a/src/tools/clippy/tests/ui/future_not_send.stderr b/src/tools/clippy/tests/ui/future_not_send.stderr index 5b6858e4568b5..5c6348962a5eb 100644 --- a/src/tools/clippy/tests/ui/future_not_send.stderr +++ b/src/tools/clippy/tests/ui/future_not_send.stderr @@ -5,22 +5,22 @@ LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell<usize>) -> bool { | ^^^^ future returned by `private_future` is not `Send` | note: future is not `Send` as this value is used across an await - --> $DIR/future_not_send.rs:8:19 + --> $DIR/future_not_send.rs:8:20 | LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell<usize>) -> bool { | -- has type `std::rc::Rc<[u8]>` which is not `Send` LL | async { true }.await - | ^^^^^^ await occurs here, with `rc` maybe used later + | ^^^^^ await occurs here, with `rc` maybe used later LL | } | - `rc` is later dropped here = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send` note: future is not `Send` as this value is used across an await - --> $DIR/future_not_send.rs:8:19 + --> $DIR/future_not_send.rs:8:20 | LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell<usize>) -> bool { | ---- has type `&std::cell::Cell<usize>` which is not `Send` LL | async { true }.await - | ^^^^^^ await occurs here, with `cell` maybe used later + | ^^^^^ await occurs here, with `cell` maybe used later LL | } | - `cell` is later dropped here = note: `std::cell::Cell<usize>` doesn't implement `std::marker::Sync` @@ -33,12 +33,12 @@ LL | pub async fn public_future(rc: Rc<[u8]>) { | ^ future returned by `public_future` is not `Send` | note: future is not `Send` as this value is used across an await - --> $DIR/future_not_send.rs:12:19 + --> $DIR/future_not_send.rs:12:20 | LL | pub async fn public_future(rc: Rc<[u8]>) { | -- has type `std::rc::Rc<[u8]>` which is not `Send` LL | async { true }.await; - | ^^^^^^ await occurs here, with `rc` maybe used later + | ^^^^^ await occurs here, with `rc` maybe used later LL | } | - `rc` is later dropped here = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send` @@ -82,12 +82,12 @@ LL | async fn private_future(&self) -> usize { | ^^^^^ future returned by `private_future` is not `Send` | note: future is not `Send` as this value is used across an await - --> $DIR/future_not_send.rs:35:23 + --> $DIR/future_not_send.rs:35:24 | LL | async fn private_future(&self) -> usize { | ----- has type `&Dummy` which is not `Send` LL | async { true }.await; - | ^^^^^^ await occurs here, with `&self` maybe used later + | ^^^^^ await occurs here, with `&self` maybe used later LL | self.rc.len() LL | } | - `&self` is later dropped here @@ -100,12 +100,12 @@ LL | pub async fn public_future(&self) { | ^ future returned by `public_future` is not `Send` | note: future is not `Send` as this value is used across an await - --> $DIR/future_not_send.rs:40:30 + --> $DIR/future_not_send.rs:40:31 | LL | pub async fn public_future(&self) { | ----- has type `&Dummy` which is not `Send` LL | self.private_future().await; - | ^^^^^^ await occurs here, with `&self` maybe used later + | ^^^^^ await occurs here, with `&self` maybe used later LL | } | - `&self` is later dropped here = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Sync` @@ -117,12 +117,12 @@ LL | async fn generic_future<T>(t: T) -> T | ^ future returned by `generic_future` is not `Send` | note: future is not `Send` as this value is used across an await - --> $DIR/future_not_send.rs:54:19 + --> $DIR/future_not_send.rs:54:20 | LL | let rt = &t; | -- has type `&T` which is not `Send` LL | async { true }.await; - | ^^^^^^ await occurs here, with `rt` maybe used later + | ^^^^^ await occurs here, with `rt` maybe used later LL | t LL | } | - `rt` is later dropped here diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index d4bffe5f9454f..73f922b317480 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -eb62877597000ccf8bb99ab131b5977344afdfa3 +1cb63572d271855a5ccef79a3e10a8015d00f6ad diff --git a/src/tools/miri/tests/fail/dangling_pointers/null_pointer_write_zst.rs b/src/tools/miri/tests/fail/dangling_pointers/null_pointer_write_zst.rs index c00344b6de23a..21344208130ea 100644 --- a/src/tools/miri/tests/fail/dangling_pointers/null_pointer_write_zst.rs +++ b/src/tools/miri/tests/fail/dangling_pointers/null_pointer_write_zst.rs @@ -7,5 +7,5 @@ fn main() { // Also not assigning directly as that's array initialization, not assignment. let zst_val = [1u8; 0]; unsafe { std::ptr::null_mut::<[u8; 0]>().write(zst_val) }; - //~^ERROR: memory access failed: null pointer is a dangling pointer + //~^ERROR: dereferencing pointer failed: null pointer is a dangling pointer } diff --git a/src/tools/miri/tests/fail/dangling_pointers/null_pointer_write_zst.stderr b/src/tools/miri/tests/fail/dangling_pointers/null_pointer_write_zst.stderr index 2953d85c25f3f..a4e0ebe38f6a9 100644 --- a/src/tools/miri/tests/fail/dangling_pointers/null_pointer_write_zst.stderr +++ b/src/tools/miri/tests/fail/dangling_pointers/null_pointer_write_zst.stderr @@ -1,8 +1,8 @@ -error: Undefined Behavior: memory access failed: null pointer is a dangling pointer (it has no provenance) +error: Undefined Behavior: dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance) --> $DIR/null_pointer_write_zst.rs:LL:CC | LL | unsafe { std::ptr::null_mut::<[u8; 0]>().write(zst_val) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance) | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information diff --git a/src/tools/rustfmt/src/chains.rs b/src/tools/rustfmt/src/chains.rs index cbe523c6c3ca9..0afce7cf65962 100644 --- a/src/tools/rustfmt/src/chains.rs +++ b/src/tools/rustfmt/src/chains.rs @@ -232,7 +232,7 @@ impl ChainItemKind { let span = mk_sp(nested.span.hi(), field.span.hi()); (kind, span) } - ast::ExprKind::Await(ref nested) => { + ast::ExprKind::Await(ref nested, _) => { let span = mk_sp(nested.span.hi(), expr.span.hi()); (ChainItemKind::Await, span) } @@ -459,7 +459,7 @@ impl Chain { ast::ExprKind::MethodCall(ref call) => Some(Self::convert_try(&call.receiver, context)), ast::ExprKind::Field(ref subexpr, _) | ast::ExprKind::Try(ref subexpr) - | ast::ExprKind::Await(ref subexpr) => Some(Self::convert_try(subexpr, context)), + | ast::ExprKind::Await(ref subexpr, _) => Some(Self::convert_try(subexpr, context)), _ => None, } } diff --git a/src/tools/rustfmt/src/expr.rs b/src/tools/rustfmt/src/expr.rs index 824e42191364f..5dc628adb0c6f 100644 --- a/src/tools/rustfmt/src/expr.rs +++ b/src/tools/rustfmt/src/expr.rs @@ -218,7 +218,7 @@ pub(crate) fn format_expr( ast::ExprKind::Try(..) | ast::ExprKind::Field(..) | ast::ExprKind::MethodCall(..) - | ast::ExprKind::Await(_) => rewrite_chain(expr, context, shape), + | ast::ExprKind::Await(_, _) => rewrite_chain(expr, context, shape), ast::ExprKind::MacCall(ref mac) => { rewrite_macro(mac, None, context, shape, MacroPosition::Expression).or_else(|| { wrap_str( @@ -1889,7 +1889,7 @@ impl<'ast> RhsAssignKind<'ast> { ast::ExprKind::Try(..) | ast::ExprKind::Field(..) | ast::ExprKind::MethodCall(..) - | ast::ExprKind::Await(_) + | ast::ExprKind::Await(_, _) ) } _ => false, diff --git a/tests/codegen/mem-replace-big-type.rs b/tests/codegen/mem-replace-big-type.rs index f6898e2f75814..81e56b5490d64 100644 --- a/tests/codegen/mem-replace-big-type.rs +++ b/tests/codegen/mem-replace-big-type.rs @@ -11,7 +11,9 @@ #[repr(C, align(8))] pub struct Big([u64; 7]); pub fn replace_big(dst: &mut Big, src: Big) -> Big { - // Before the `read_via_copy` intrinsic, this emitted six `memcpy`s. + // Back in 1.68, this emitted six `memcpy`s. + // `read_via_copy` in 1.69 got that down to three. + // `write_via_move` has it down to just the two essential ones. std::mem::replace(dst, src) } @@ -20,17 +22,13 @@ pub fn replace_big(dst: &mut Big, src: Big) -> Big { // CHECK-NOT: call void @llvm.memcpy -// For a large type, we expect exactly three `memcpy`s +// For a large type, we expect exactly two `memcpy`s // CHECK-LABEL: define internal void @{{.+}}mem{{.+}}replace{{.+}}sret(%Big) // CHECK-NOT: alloca - // CHECK: alloca %Big - // CHECK-NOT: alloca - // CHECK-NOT: call void @llvm.memcpy - // CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %{{.*}}, {{i8\*|ptr}} align 8 %{{.*}}, i{{.*}} 56, i1 false) // CHECK-NOT: call void @llvm.memcpy - // CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %{{.*}}, {{i8\*|ptr}} align 8 %{{.*}}, i{{.*}} 56, i1 false) + // CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %0, {{i8\*|ptr}} align 8 %dest, i{{.*}} 56, i1 false) // CHECK-NOT: call void @llvm.memcpy - // CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %{{.*}}, {{i8\*|ptr}} align 8 %{{.*}}, i{{.*}} 56, i1 false) + // CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 8 %dest, {{i8\*|ptr}} align 8 %src, i{{.*}} 56, i1 false) // CHECK-NOT: call void @llvm.memcpy // CHECK-NOT: call void @llvm.memcpy diff --git a/tests/codegen/mem-replace-direct-memcpy.rs b/tests/codegen/mem-replace-direct-memcpy.rs deleted file mode 100644 index 83babab4f847b..0000000000000 --- a/tests/codegen/mem-replace-direct-memcpy.rs +++ /dev/null @@ -1,33 +0,0 @@ -// This test ensures that `mem::replace::<T>` only ever calls `@llvm.memcpy` -// with `size_of::<T>()` as the size, and never goes through any wrapper that -// may e.g. multiply `size_of::<T>()` with a variable "count" (which is only -// known to be `1` after inlining). - -// compile-flags: -C no-prepopulate-passes -Zinline-mir=no -// ignore-debug: the debug assertions get in the way - -#![crate_type = "lib"] - -pub fn replace_byte(dst: &mut u8, src: u8) -> u8 { - std::mem::replace(dst, src) -} - -// NOTE(eddyb) the `CHECK-NOT`s ensure that the only calls of `@llvm.memcpy` in -// the entire output, are the direct calls we want, from `ptr::replace`. - -// CHECK-NOT: call void @llvm.memcpy - -// For a small type, we expect one each of `load`/`store`/`memcpy` instead -// CHECK-LABEL: define internal noundef i8 @{{.+}}mem{{.+}}replace - // CHECK-NOT: alloca - // CHECK: alloca i8 - // CHECK-NOT: alloca - // CHECK-NOT: call void @llvm.memcpy - // CHECK: load i8 - // CHECK-NOT: call void @llvm.memcpy - // CHECK: store i8 - // CHECK-NOT: call void @llvm.memcpy - // CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 1 %{{.*}}, i{{.*}} 1, i1 false) - // CHECK-NOT: call void @llvm.memcpy - -// CHECK-NOT: call void @llvm.memcpy diff --git a/tests/codegen/mem-replace-simple-type.rs b/tests/codegen/mem-replace-simple-type.rs new file mode 100644 index 0000000000000..4253ef1366604 --- /dev/null +++ b/tests/codegen/mem-replace-simple-type.rs @@ -0,0 +1,34 @@ +// compile-flags: -O -C no-prepopulate-passes +// min-llvm-version: 15.0 (for opaque pointers) +// only-x86_64 (to not worry about usize differing) +// ignore-debug (the debug assertions get in the way) + +#![crate_type = "lib"] + +#[no_mangle] +// CHECK-LABEL: @replace_usize( +pub fn replace_usize(r: &mut usize, v: usize) -> usize { + // CHECK-NOT: alloca + // CHECK: %[[R:.+]] = load i64, ptr %r + // CHECK: store i64 %v, ptr %r + // CHECK: ret i64 %[[R]] + std::mem::replace(r, v) +} + +#[no_mangle] +// CHECK-LABEL: @replace_ref_str( +pub fn replace_ref_str<'a>(r: &mut &'a str, v: &'a str) -> &'a str { + // CHECK-NOT: alloca + // CHECK: %[[A:.+]] = load ptr + // CHECK: %[[B:.+]] = load i64 + // CHECK-NOT: store + // CHECK-NOT: load + // CHECK: store ptr + // CHECK: store i64 + // CHECK-NOT: load + // CHECK-NOT: store + // CHECK: %[[P1:.+]] = insertvalue { ptr, i64 } poison, ptr %[[A]], 0 + // CHECK: %[[P2:.+]] = insertvalue { ptr, i64 } %[[P1]], i64 %[[B]], 1 + // CHECK: ret { ptr, i64 } %[[P2]] + std::mem::replace(r, v) +} diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir index 9bced25a5957d..a9d1477b9fe5d 100644 --- a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir @@ -4,7 +4,7 @@ _0: GeneratorSavedTy { ty: impl std::future::Future<Output = ()>, source_info: SourceInfo { - span: $DIR/async_await.rs:15:8: 15:14 (#8), + span: $DIR/async_await.rs:15:9: 15:14 (#8), scope: scope[0], }, ignore_for_traits: false, @@ -12,7 +12,7 @@ _1: GeneratorSavedTy { ty: impl std::future::Future<Output = ()>, source_info: SourceInfo { - span: $DIR/async_await.rs:16:8: 16:14 (#10), + span: $DIR/async_await.rs:16:9: 16:14 (#10), scope: scope[0], }, ignore_for_traits: false, @@ -35,42 +35,42 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, debug _task_context => _38; // in scope 0 at $DIR/async_await.rs:+0:18: +3:2 let mut _0: std::task::Poll<()>; // return place in scope 0 at $DIR/async_await.rs:+0:18: +3:2 let _3: (); // in scope 0 at $DIR/async_await.rs:+1:5: +1:14 - let mut _4: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 + let mut _4: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 let mut _5: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:5: +1:8 - let mut _6: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 + let mut _6: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 let mut _7: (); // in scope 0 at $DIR/async_await.rs:+0:18: +3:2 - let _8: (); // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 - let mut _9: std::task::Poll<()>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 - let mut _10: std::pin::Pin<&mut impl std::future::Future<Output = ()>>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 - let mut _11: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 - let mut _12: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 + let _8: (); // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 + let mut _9: std::task::Poll<()>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 + let mut _10: std::pin::Pin<&mut impl std::future::Future<Output = ()>>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 + let mut _11: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 + let mut _12: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 let mut _13: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+1:5: +1:14 let mut _14: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+1:5: +1:14 - let mut _15: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 - let mut _16: isize; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 + let mut _15: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 + let mut _16: isize; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 let mut _18: !; // in scope 0 at $DIR/async_await.rs:+1:5: +1:14 - let mut _19: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 - let mut _20: (); // in scope 0 at $DIR/async_await.rs:+1:8: +1:14 - let mut _21: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 + let mut _19: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 + let mut _20: (); // in scope 0 at $DIR/async_await.rs:+1:9: +1:14 + let mut _21: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 let mut _22: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:5: +2:8 - let mut _23: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 - let _24: (); // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 - let mut _25: std::task::Poll<()>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 - let mut _26: std::pin::Pin<&mut impl std::future::Future<Output = ()>>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 - let mut _27: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 - let mut _28: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 + let mut _23: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 + let _24: (); // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 + let mut _25: std::task::Poll<()>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 + let mut _26: std::pin::Pin<&mut impl std::future::Future<Output = ()>>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 + let mut _27: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 + let mut _28: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 let mut _29: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+2:5: +2:14 let mut _30: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+2:5: +2:14 - let mut _31: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 - let mut _32: isize; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 + let mut _31: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 + let mut _32: isize; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 let mut _34: !; // in scope 0 at $DIR/async_await.rs:+2:5: +2:14 - let mut _35: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 - let mut _36: (); // in scope 0 at $DIR/async_await.rs:+2:8: +2:14 + let mut _35: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 + let mut _36: (); // in scope 0 at $DIR/async_await.rs:+2:9: +2:14 let mut _37: (); // in scope 0 at $DIR/async_await.rs:+0:18: +3:2 let mut _38: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+0:18: +3:2 let mut _39: u32; // in scope 0 at $DIR/async_await.rs:+0:18: +3:2 scope 1 { - debug __awaitee => (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#3).0: impl std::future::Future<Output = ()>); // in scope 1 at $DIR/async_await.rs:+1:8: +1:14 + debug __awaitee => (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#3).0: impl std::future::Future<Output = ()>); // in scope 1 at $DIR/async_await.rs:+1:9: +1:14 let _17: (); // in scope 1 at $DIR/async_await.rs:+1:5: +1:14 scope 2 { } @@ -79,7 +79,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, } } scope 4 { - debug __awaitee => (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#4).0: impl std::future::Future<Output = ()>); // in scope 4 at $DIR/async_await.rs:+2:8: +2:14 + debug __awaitee => (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#4).0: impl std::future::Future<Output = ()>); // in scope 4 at $DIR/async_await.rs:+2:9: +2:14 let _33: (); // in scope 4 at $DIR/async_await.rs:+2:5: +2:14 scope 5 { } @@ -96,7 +96,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, bb1: { _38 = move _2; // scope 0 at $DIR/async_await.rs:+0:18: +3:2 StorageLive(_3); // scope 0 at $DIR/async_await.rs:+1:5: +1:14 - StorageLive(_4); // scope 0 at $DIR/async_await.rs:+1:8: +1:14 + StorageLive(_4); // scope 0 at $DIR/async_await.rs:+1:9: +1:14 StorageLive(_5); // scope 0 at $DIR/async_await.rs:+1:5: +1:8 _5 = a() -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+1:5: +1:8 // mir::Constant @@ -105,30 +105,30 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, } bb2: { - _4 = <impl Future<Output = ()> as IntoFuture>::into_future(move _5) -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+1:8: +1:14 + _4 = <impl Future<Output = ()> as IntoFuture>::into_future(move _5) -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+1:9: +1:14 // mir::Constant - // + span: $DIR/async_await.rs:15:8: 15:14 + // + span: $DIR/async_await.rs:15:9: 15:14 // + literal: Const { ty: fn(impl Future<Output = ()>) -> <impl Future<Output = ()> as IntoFuture>::IntoFuture {<impl Future<Output = ()> as IntoFuture>::into_future}, val: Value(<ZST>) } } bb3: { StorageDead(_5); // scope 0 at $DIR/async_await.rs:+1:13: +1:14 - nop; // scope 0 at $DIR/async_await.rs:+1:8: +1:14 - (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#3).0: impl std::future::Future<Output = ()>) = move _4; // scope 0 at $DIR/async_await.rs:+1:8: +1:14 - goto -> bb4; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 + nop; // scope 0 at $DIR/async_await.rs:+1:9: +1:14 + (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#3).0: impl std::future::Future<Output = ()>) = move _4; // scope 0 at $DIR/async_await.rs:+1:9: +1:14 + goto -> bb4; // scope 1 at $DIR/async_await.rs:+1:9: +1:14 } bb4: { - StorageLive(_8); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - StorageLive(_9); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - StorageLive(_10); // scope 2 at $DIR/async_await.rs:+1:8: +1:14 - StorageLive(_11); // scope 2 at $DIR/async_await.rs:+1:8: +1:14 - StorageLive(_12); // scope 2 at $DIR/async_await.rs:+1:8: +1:14 - _12 = &mut (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#3).0: impl std::future::Future<Output = ()>); // scope 2 at $DIR/async_await.rs:+1:8: +1:14 - _11 = &mut (*_12); // scope 2 at $DIR/async_await.rs:+1:8: +1:14 - _10 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _11) -> [return: bb5, unwind unreachable]; // scope 2 at $DIR/async_await.rs:+1:8: +1:14 + StorageLive(_8); // scope 1 at $DIR/async_await.rs:+1:9: +1:14 + StorageLive(_9); // scope 1 at $DIR/async_await.rs:+1:9: +1:14 + StorageLive(_10); // scope 2 at $DIR/async_await.rs:+1:9: +1:14 + StorageLive(_11); // scope 2 at $DIR/async_await.rs:+1:9: +1:14 + StorageLive(_12); // scope 2 at $DIR/async_await.rs:+1:9: +1:14 + _12 = &mut (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#3).0: impl std::future::Future<Output = ()>); // scope 2 at $DIR/async_await.rs:+1:9: +1:14 + _11 = &mut (*_12); // scope 2 at $DIR/async_await.rs:+1:9: +1:14 + _10 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _11) -> [return: bb5, unwind unreachable]; // scope 2 at $DIR/async_await.rs:+1:9: +1:14 // mir::Constant - // + span: $DIR/async_await.rs:15:8: 15:14 + // + span: $DIR/async_await.rs:15:9: 15:14 // + literal: Const { ty: unsafe fn(&mut impl Future<Output = ()>) -> Pin<&mut impl Future<Output = ()>> {Pin::<&mut impl Future<Output = ()>>::new_unchecked}, val: Value(<ZST>) } } @@ -136,8 +136,8 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, StorageDead(_11); // scope 2 at $DIR/async_await.rs:+1:13: +1:14 StorageLive(_13); // scope 2 at $DIR/async_await.rs:+1:5: +1:14 StorageLive(_14); // scope 2 at $DIR/async_await.rs:+1:5: +1:14 - StorageLive(_15); // scope 2 at $DIR/async_await.rs:+1:8: +1:14 - _15 = _38; // scope 2 at $DIR/async_await.rs:+1:8: +1:14 + StorageLive(_15); // scope 2 at $DIR/async_await.rs:+1:9: +1:14 + _15 = _38; // scope 2 at $DIR/async_await.rs:+1:9: +1:14 _14 = move _15; // scope 2 at $DIR/async_await.rs:+1:5: +1:14 goto -> bb6; // scope 2 at $DIR/async_await.rs:+1:5: +1:14 } @@ -145,35 +145,35 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, bb6: { _13 = &mut (*_14); // scope 2 at $DIR/async_await.rs:+1:5: +1:14 StorageDead(_15); // scope 2 at $DIR/async_await.rs:+1:13: +1:14 - _9 = <impl Future<Output = ()> as Future>::poll(move _10, move _13) -> [return: bb7, unwind unreachable]; // scope 2 at $DIR/async_await.rs:+1:8: +1:14 + _9 = <impl Future<Output = ()> as Future>::poll(move _10, move _13) -> [return: bb7, unwind unreachable]; // scope 2 at $DIR/async_await.rs:+1:9: +1:14 // mir::Constant - // + span: $DIR/async_await.rs:15:8: 15:14 + // + span: $DIR/async_await.rs:15:9: 15:14 // + literal: Const { ty: for<'a, 'b, 'c> fn(Pin<&'a mut impl Future<Output = ()>>, &'b mut Context<'c>) -> Poll<<impl Future<Output = ()> as Future>::Output> {<impl Future<Output = ()> as Future>::poll}, val: Value(<ZST>) } } bb7: { StorageDead(_13); // scope 2 at $DIR/async_await.rs:+1:13: +1:14 StorageDead(_10); // scope 2 at $DIR/async_await.rs:+1:13: +1:14 - _16 = discriminant(_9); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - switchInt(move _16) -> [0: bb10, 1: bb8, otherwise: bb9]; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 + _16 = discriminant(_9); // scope 1 at $DIR/async_await.rs:+1:9: +1:14 + switchInt(move _16) -> [0: bb10, 1: bb8, otherwise: bb9]; // scope 1 at $DIR/async_await.rs:+1:9: +1:14 } bb8: { - _8 = const (); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 + _8 = const (); // scope 1 at $DIR/async_await.rs:+1:9: +1:14 StorageDead(_14); // scope 1 at $DIR/async_await.rs:+1:13: +1:14 StorageDead(_12); // scope 1 at $DIR/async_await.rs:+1:13: +1:14 StorageDead(_9); // scope 1 at $DIR/async_await.rs:+1:13: +1:14 StorageDead(_8); // scope 1 at $DIR/async_await.rs:+1:13: +1:14 - StorageLive(_19); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - StorageLive(_20); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - _20 = (); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - _0 = Poll::<()>::Pending; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2]))) = 3; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - return; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 + StorageLive(_19); // scope 1 at $DIR/async_await.rs:+1:9: +1:14 + StorageLive(_20); // scope 1 at $DIR/async_await.rs:+1:9: +1:14 + _20 = (); // scope 1 at $DIR/async_await.rs:+1:9: +1:14 + _0 = Poll::<()>::Pending; // scope 1 at $DIR/async_await.rs:+1:9: +1:14 + discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2]))) = 3; // scope 1 at $DIR/async_await.rs:+1:9: +1:14 + return; // scope 1 at $DIR/async_await.rs:+1:9: +1:14 } bb9: { - unreachable; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 + unreachable; // scope 1 at $DIR/async_await.rs:+1:9: +1:14 } bb10: { @@ -190,10 +190,10 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, bb11: { StorageDead(_20); // scope 1 at $DIR/async_await.rs:+1:13: +1:14 - _38 = move _19; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 + _38 = move _19; // scope 1 at $DIR/async_await.rs:+1:9: +1:14 StorageDead(_19); // scope 1 at $DIR/async_await.rs:+1:13: +1:14 - _7 = const (); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - goto -> bb4; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 + _7 = const (); // scope 1 at $DIR/async_await.rs:+1:9: +1:14 + goto -> bb4; // scope 1 at $DIR/async_await.rs:+1:9: +1:14 } bb12: { @@ -204,7 +204,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, bb13: { StorageDead(_4); // scope 0 at $DIR/async_await.rs:+1:14: +1:15 StorageDead(_3); // scope 0 at $DIR/async_await.rs:+1:14: +1:15 - StorageLive(_21); // scope 0 at $DIR/async_await.rs:+2:8: +2:14 + StorageLive(_21); // scope 0 at $DIR/async_await.rs:+2:9: +2:14 StorageLive(_22); // scope 0 at $DIR/async_await.rs:+2:5: +2:8 _22 = a() -> [return: bb14, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+2:5: +2:8 // mir::Constant @@ -213,30 +213,30 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, } bb14: { - _21 = <impl Future<Output = ()> as IntoFuture>::into_future(move _22) -> [return: bb15, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+2:8: +2:14 + _21 = <impl Future<Output = ()> as IntoFuture>::into_future(move _22) -> [return: bb15, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+2:9: +2:14 // mir::Constant - // + span: $DIR/async_await.rs:16:8: 16:14 + // + span: $DIR/async_await.rs:16:9: 16:14 // + literal: Const { ty: fn(impl Future<Output = ()>) -> <impl Future<Output = ()> as IntoFuture>::IntoFuture {<impl Future<Output = ()> as IntoFuture>::into_future}, val: Value(<ZST>) } } bb15: { StorageDead(_22); // scope 0 at $DIR/async_await.rs:+2:13: +2:14 - nop; // scope 0 at $DIR/async_await.rs:+2:8: +2:14 - (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#4).0: impl std::future::Future<Output = ()>) = move _21; // scope 0 at $DIR/async_await.rs:+2:8: +2:14 - goto -> bb16; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 + nop; // scope 0 at $DIR/async_await.rs:+2:9: +2:14 + (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#4).0: impl std::future::Future<Output = ()>) = move _21; // scope 0 at $DIR/async_await.rs:+2:9: +2:14 + goto -> bb16; // scope 4 at $DIR/async_await.rs:+2:9: +2:14 } bb16: { - StorageLive(_24); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - StorageLive(_25); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - StorageLive(_26); // scope 5 at $DIR/async_await.rs:+2:8: +2:14 - StorageLive(_27); // scope 5 at $DIR/async_await.rs:+2:8: +2:14 - StorageLive(_28); // scope 5 at $DIR/async_await.rs:+2:8: +2:14 - _28 = &mut (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#4).0: impl std::future::Future<Output = ()>); // scope 5 at $DIR/async_await.rs:+2:8: +2:14 - _27 = &mut (*_28); // scope 5 at $DIR/async_await.rs:+2:8: +2:14 - _26 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _27) -> [return: bb17, unwind unreachable]; // scope 5 at $DIR/async_await.rs:+2:8: +2:14 + StorageLive(_24); // scope 4 at $DIR/async_await.rs:+2:9: +2:14 + StorageLive(_25); // scope 4 at $DIR/async_await.rs:+2:9: +2:14 + StorageLive(_26); // scope 5 at $DIR/async_await.rs:+2:9: +2:14 + StorageLive(_27); // scope 5 at $DIR/async_await.rs:+2:9: +2:14 + StorageLive(_28); // scope 5 at $DIR/async_await.rs:+2:9: +2:14 + _28 = &mut (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#4).0: impl std::future::Future<Output = ()>); // scope 5 at $DIR/async_await.rs:+2:9: +2:14 + _27 = &mut (*_28); // scope 5 at $DIR/async_await.rs:+2:9: +2:14 + _26 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _27) -> [return: bb17, unwind unreachable]; // scope 5 at $DIR/async_await.rs:+2:9: +2:14 // mir::Constant - // + span: $DIR/async_await.rs:16:8: 16:14 + // + span: $DIR/async_await.rs:16:9: 16:14 // + literal: Const { ty: unsafe fn(&mut impl Future<Output = ()>) -> Pin<&mut impl Future<Output = ()>> {Pin::<&mut impl Future<Output = ()>>::new_unchecked}, val: Value(<ZST>) } } @@ -244,8 +244,8 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, StorageDead(_27); // scope 5 at $DIR/async_await.rs:+2:13: +2:14 StorageLive(_29); // scope 5 at $DIR/async_await.rs:+2:5: +2:14 StorageLive(_30); // scope 5 at $DIR/async_await.rs:+2:5: +2:14 - StorageLive(_31); // scope 5 at $DIR/async_await.rs:+2:8: +2:14 - _31 = _38; // scope 5 at $DIR/async_await.rs:+2:8: +2:14 + StorageLive(_31); // scope 5 at $DIR/async_await.rs:+2:9: +2:14 + _31 = _38; // scope 5 at $DIR/async_await.rs:+2:9: +2:14 _30 = move _31; // scope 5 at $DIR/async_await.rs:+2:5: +2:14 goto -> bb18; // scope 5 at $DIR/async_await.rs:+2:5: +2:14 } @@ -253,31 +253,31 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, bb18: { _29 = &mut (*_30); // scope 5 at $DIR/async_await.rs:+2:5: +2:14 StorageDead(_31); // scope 5 at $DIR/async_await.rs:+2:13: +2:14 - _25 = <impl Future<Output = ()> as Future>::poll(move _26, move _29) -> [return: bb19, unwind unreachable]; // scope 5 at $DIR/async_await.rs:+2:8: +2:14 + _25 = <impl Future<Output = ()> as Future>::poll(move _26, move _29) -> [return: bb19, unwind unreachable]; // scope 5 at $DIR/async_await.rs:+2:9: +2:14 // mir::Constant - // + span: $DIR/async_await.rs:16:8: 16:14 + // + span: $DIR/async_await.rs:16:9: 16:14 // + literal: Const { ty: for<'a, 'b, 'c> fn(Pin<&'a mut impl Future<Output = ()>>, &'b mut Context<'c>) -> Poll<<impl Future<Output = ()> as Future>::Output> {<impl Future<Output = ()> as Future>::poll}, val: Value(<ZST>) } } bb19: { StorageDead(_29); // scope 5 at $DIR/async_await.rs:+2:13: +2:14 StorageDead(_26); // scope 5 at $DIR/async_await.rs:+2:13: +2:14 - _32 = discriminant(_25); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - switchInt(move _32) -> [0: bb21, 1: bb20, otherwise: bb9]; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 + _32 = discriminant(_25); // scope 4 at $DIR/async_await.rs:+2:9: +2:14 + switchInt(move _32) -> [0: bb21, 1: bb20, otherwise: bb9]; // scope 4 at $DIR/async_await.rs:+2:9: +2:14 } bb20: { - _24 = const (); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 + _24 = const (); // scope 4 at $DIR/async_await.rs:+2:9: +2:14 StorageDead(_30); // scope 4 at $DIR/async_await.rs:+2:13: +2:14 StorageDead(_28); // scope 4 at $DIR/async_await.rs:+2:13: +2:14 StorageDead(_25); // scope 4 at $DIR/async_await.rs:+2:13: +2:14 StorageDead(_24); // scope 4 at $DIR/async_await.rs:+2:13: +2:14 - StorageLive(_35); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - StorageLive(_36); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - _36 = (); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - _0 = Poll::<()>::Pending; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2]))) = 4; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - return; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 + StorageLive(_35); // scope 4 at $DIR/async_await.rs:+2:9: +2:14 + StorageLive(_36); // scope 4 at $DIR/async_await.rs:+2:9: +2:14 + _36 = (); // scope 4 at $DIR/async_await.rs:+2:9: +2:14 + _0 = Poll::<()>::Pending; // scope 4 at $DIR/async_await.rs:+2:9: +2:14 + discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2]))) = 4; // scope 4 at $DIR/async_await.rs:+2:9: +2:14 + return; // scope 4 at $DIR/async_await.rs:+2:9: +2:14 } bb21: { @@ -294,10 +294,10 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, bb22: { StorageDead(_36); // scope 4 at $DIR/async_await.rs:+2:13: +2:14 - _38 = move _35; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 + _38 = move _35; // scope 4 at $DIR/async_await.rs:+2:9: +2:14 StorageDead(_35); // scope 4 at $DIR/async_await.rs:+2:13: +2:14 - _7 = const (); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - goto -> bb16; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 + _7 = const (); // scope 4 at $DIR/async_await.rs:+2:9: +2:14 + goto -> bb16; // scope 4 at $DIR/async_await.rs:+2:9: +2:14 } bb23: { diff --git a/tests/mir-opt/const_prop/mult_by_zero.rs b/tests/mir-opt/const_prop/mult_by_zero.rs index c839f92f2ceb1..7bd30975a738c 100644 --- a/tests/mir-opt/const_prop/mult_by_zero.rs +++ b/tests/mir-opt/const_prop/mult_by_zero.rs @@ -1,5 +1,4 @@ -// unit-test -// compile-flags: -O -Zmir-opt-level=4 +// unit-test: ConstProp // EMIT_MIR mult_by_zero.test.ConstProp.diff fn test(x : i32) -> i32 { diff --git a/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff b/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff index 1cfe47d0a8612..629c8e60148fd 100644 --- a/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff +++ b/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff @@ -7,8 +7,11 @@ let mut _2: i32; // in scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:4 bb0: { -- _0 = Mul(_1, const 0_i32); // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:8 + StorageLive(_2); // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:4 + _2 = _1; // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:4 +- _0 = Mul(move _2, const 0_i32); // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:8 + _0 = const 0_i32; // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:8 + StorageDead(_2); // scope 0 at $DIR/mult_by_zero.rs:+1:7: +1:8 return; // scope 0 at $DIR/mult_by_zero.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/const_prop/mutable_variable.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable.main.ConstProp.diff index a672c457a72b1..bd010e7b16080 100644 --- a/tests/mir-opt/const_prop/mutable_variable.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable.main.ConstProp.diff @@ -19,6 +19,7 @@ StorageLive(_2); // scope 1 at $DIR/mutable_variable.rs:+3:9: +3:10 - _2 = _1; // scope 1 at $DIR/mutable_variable.rs:+3:13: +3:14 + _2 = const 99_i32; // scope 1 at $DIR/mutable_variable.rs:+3:13: +3:14 + _0 = const (); // scope 0 at $DIR/mutable_variable.rs:+0:11: +4:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable.rs:+4:1: +4:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable.rs:+4:1: +4:2 return; // scope 0 at $DIR/mutable_variable.rs:+4:2: +4:2 diff --git a/tests/mir-opt/const_prop/mutable_variable.rs b/tests/mir-opt/const_prop/mutable_variable.rs index cb01719dd77a9..95987ef7fa9fa 100644 --- a/tests/mir-opt/const_prop/mutable_variable.rs +++ b/tests/mir-opt/const_prop/mutable_variable.rs @@ -1,5 +1,4 @@ -// unit-test -// compile-flags: -O +// unit-test: ConstProp // EMIT_MIR mutable_variable.main.ConstProp.diff fn main() { diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff index d088c4f662b7b..539f6dd94b926 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff @@ -3,27 +3,26 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_aggregate.rs:+0:11: +0:11 - let mut _3: i32; // in scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 - let mut _4: i32; // in scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 + let mut _1: (i32, i32); // in scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 scope 1 { - debug x => (i32, i32){ .0 => _3, .1 => _4, }; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 - let _1: i32; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 - let _2: i32; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 + debug x => _1; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 + let _2: (i32, i32); // in scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 scope 2 { - debug y => (i32, i32){ .0 => _3, .1 => _2, }; // in scope 2 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 + debug y => _2; // in scope 2 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 } } bb0: { - StorageLive(_4); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 - _3 = const 42_i32; // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25 - _4 = const 43_i32; // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25 - _4 = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:+2:5: +2:13 + StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 +- _1 = (const 42_i32, const 43_i32); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25 ++ _1 = const (42_i32, 43_i32); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25 + (_1.1: i32) = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:+2:5: +2:13 StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 -- _2 = _4; // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14 -+ _2 = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14 +- _2 = _1; // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14 ++ _2 = const (42_i32, 99_i32); // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14 + _0 = const (); // scope 0 at $DIR/mutable_variable_aggregate.rs:+0:11: +4:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2 - StorageDead(_4); // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2 + StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2 return; // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:2: +4:2 } } diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate.rs index d4ff8d8907342..a145c0354380c 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate.rs @@ -1,5 +1,4 @@ -// unit-test -// compile-flags: -O +// unit-test: ConstProp // EMIT_MIR mutable_variable_aggregate.main.ConstProp.diff fn main() { diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff index 134f0c080bf81..bec641ecfae89 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff @@ -9,10 +9,9 @@ let _2: &mut (i32, i32); // in scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:9: +2:10 scope 2 { debug z => _2; // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:9: +2:10 - let _3: i32; // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 - let _4: i32; // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 + let _3: (i32, i32); // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 scope 3 { - debug y => (i32, i32){ .0 => _3, .1 => _4, }; // in scope 3 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 + debug y => _3; // in scope 3 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 } } } @@ -24,11 +23,9 @@ _2 = &mut _1; // scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:13: +2:19 ((*_2).1: i32) = const 99_i32; // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+3:5: +3:13 StorageLive(_3); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 - StorageLive(_4); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 - _3 = (_1.0: i32); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:13: +4:14 - _4 = (_1.1: i32); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:13: +4:14 + _3 = _1; // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:13: +4:14 + _0 = const (); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+0:11: +5:2 StorageDead(_3); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 - StorageDead(_4); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 return; // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:2: +5:2 diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs index 9060f7e9bd3e6..3099e659f3fbb 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs @@ -1,5 +1,4 @@ -// unit-test -// compile-flags: -O +// unit-test: ConstProp // EMIT_MIR mutable_variable_aggregate_mut_ref.main.ConstProp.diff fn main() { diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff index 75f6ebc58c751..374151057acda 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.diff @@ -16,7 +16,7 @@ StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+1:9: +1:14 _1 = foo() -> bb1; // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+1:29: +1:34 // mir::Constant - // + span: $DIR/mutable_variable_aggregate_partial_read.rs:7:29: 7:32 + // + span: $DIR/mutable_variable_aggregate_partial_read.rs:6:29: 6:32 // + literal: Const { ty: fn() -> (i32, i32) {foo}, val: Value(<ZST>) } } @@ -26,6 +26,7 @@ StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:9: +4:10 - _2 = (_1.1: i32); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:13: +4:16 + _2 = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+4:13: +4:16 + _0 = const (); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+0:11: +5:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate_partial_read.rs:+5:1: +5:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+5:1: +5:2 return; // scope 0 at $DIR/mutable_variable_aggregate_partial_read.rs:+5:2: +5:2 diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs index 70a287cf381ea..0e823e9dc0845 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs @@ -1,6 +1,5 @@ // ignore-wasm32 compiled with panic=abort by default -// unit-test -// compile-flags: -O +// unit-test: ConstProp // EMIT_MIR mutable_variable_aggregate_partial_read.main.ConstProp.diff fn main() { diff --git a/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff index 7fa29cccd50d6..fab81063028aa 100644 --- a/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff @@ -4,34 +4,39 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_no_prop.rs:+0:11: +0:11 let mut _1: u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+1:9: +1:14 - let mut _2: u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 - let mut _3: *mut u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 + let _2: (); // in scope 0 at $DIR/mutable_variable_no_prop.rs:+2:5: +4:6 + let mut _3: u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 + let mut _4: *mut u32; // in scope 0 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 scope 1 { debug x => _1; // in scope 1 at $DIR/mutable_variable_no_prop.rs:+1:9: +1:14 - let _4: u32; // in scope 1 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 + let _5: u32; // in scope 1 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 scope 2 { } scope 3 { - debug y => _4; // in scope 3 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 + debug y => _5; // in scope 3 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 } } bb0: { StorageLive(_1); // scope 0 at $DIR/mutable_variable_no_prop.rs:+1:9: +1:14 _1 = const 42_u32; // scope 0 at $DIR/mutable_variable_no_prop.rs:+1:17: +1:19 - StorageLive(_2); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 + StorageLive(_2); // scope 1 at $DIR/mutable_variable_no_prop.rs:+2:5: +4:6 StorageLive(_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 - _3 = const {alloc1: *mut u32}; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 + StorageLive(_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 + _4 = const {alloc1: *mut u32}; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 // mir::Constant - // + span: $DIR/mutable_variable_no_prop.rs:10:13: 10:19 + // + span: $DIR/mutable_variable_no_prop.rs:9:13: 9:19 // + literal: Const { ty: *mut u32, val: Value(Scalar(alloc1)) } - _2 = (*_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 - _1 = move _2; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:9: +3:19 - StorageDead(_2); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:18: +3:19 - StorageDead(_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:19: +3:20 - StorageLive(_4); // scope 1 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 - _4 = _1; // scope 1 at $DIR/mutable_variable_no_prop.rs:+5:13: +5:14 - StorageDead(_4); // scope 1 at $DIR/mutable_variable_no_prop.rs:+6:1: +6:2 + _3 = (*_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:13: +3:19 + _1 = move _3; // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:9: +3:19 + StorageDead(_3); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:18: +3:19 + StorageDead(_4); // scope 2 at $DIR/mutable_variable_no_prop.rs:+3:19: +3:20 + _2 = const (); // scope 2 at $DIR/mutable_variable_no_prop.rs:+2:5: +4:6 + StorageDead(_2); // scope 1 at $DIR/mutable_variable_no_prop.rs:+4:5: +4:6 + StorageLive(_5); // scope 1 at $DIR/mutable_variable_no_prop.rs:+5:9: +5:10 + _5 = _1; // scope 1 at $DIR/mutable_variable_no_prop.rs:+5:13: +5:14 + _0 = const (); // scope 0 at $DIR/mutable_variable_no_prop.rs:+0:11: +6:2 + StorageDead(_5); // scope 1 at $DIR/mutable_variable_no_prop.rs:+6:1: +6:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_no_prop.rs:+6:1: +6:2 return; // scope 0 at $DIR/mutable_variable_no_prop.rs:+6:2: +6:2 } diff --git a/tests/mir-opt/const_prop/mutable_variable_no_prop.rs b/tests/mir-opt/const_prop/mutable_variable_no_prop.rs index b69ec931a6311..e51c6223555d5 100644 --- a/tests/mir-opt/const_prop/mutable_variable_no_prop.rs +++ b/tests/mir-opt/const_prop/mutable_variable_no_prop.rs @@ -1,5 +1,4 @@ -// unit-test -// compile-flags: -O +// unit-test: ConstProp static mut STATIC: u32 = 0x42424242; diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff index 9582504b25e81..3048122d8fff7 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff @@ -4,17 +4,16 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+0:11: +0:11 let _1: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10 - let mut _2: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 + let mut _3: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 scope 1 { debug a => _1; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10 - let mut _5: i32; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 - let mut _6: i32; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 + let mut _2: (i32, i32); // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 scope 2 { - debug x => (i32, i32){ .0 => _5, .1 => _6, }; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 - let _3: i32; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 + debug x => _2; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 + let _4: i32; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 scope 3 { - debug y => _3; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 - let _4: i32; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 + debug y => _4; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 + let _5: i32; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 scope 4 { debug z => _5; // in scope 4 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 } @@ -26,22 +25,27 @@ StorageLive(_1); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10 _1 = foo() -> bb1; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+1:13: +1:18 // mir::Constant - // + span: $DIR/mutable_variable_unprop_assign.rs:7:13: 7:16 + // + span: $DIR/mutable_variable_unprop_assign.rs:6:13: 6:16 // + literal: Const { ty: fn() -> i32 {foo}, val: Value(<ZST>) } } bb1: { - StorageLive(_6); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 - _5 = const 1_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 - _6 = const 2_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 - StorageLive(_2); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 - _2 = _1; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 - _6 = move _2; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:5: +3:12 - StorageDead(_2); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 - StorageLive(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 - _3 = _6; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:13: +4:16 - StorageDead(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 - StorageDead(_6); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 + StorageLive(_2); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 +- _2 = (const 1_i32, const 2_i32); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 ++ _2 = const (1_i32, 2_i32); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 + StorageLive(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 + _3 = _1; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 + (_2.1: i32) = move _3; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:5: +3:12 + StorageDead(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 + StorageLive(_4); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 + _4 = (_2.1: i32); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:13: +4:16 + StorageLive(_5); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 +- _5 = (_2.0: i32); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16 ++ _5 = const 1_i32; // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16 + _0 = const (); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+0:11: +6:2 + StorageDead(_5); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 + StorageDead(_4); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 + StorageDead(_2); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 return; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+6:2: +6:2 } diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs index fabd04e9bd27c..5577f78a96363 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs @@ -1,6 +1,5 @@ // ignore-wasm32 compiled with panic=abort by default -// unit-test -// compile-flags: -O +// unit-test: ConstProp // EMIT_MIR mutable_variable_unprop_assign.main.ConstProp.diff fn main() { diff --git a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.diff b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.diff index 4e2f1b39d2b16..e768a47a96d14 100644 --- a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.diff +++ b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.diff @@ -33,6 +33,7 @@ StorageLive(_4); // scope 3 at $DIR/offset_of.rs:+4:9: +4:11 - _4 = OffsetOf(Alpha, [2, 1]); // scope 3 at $DIR/offset_of.rs:+4:14: +4:36 + _4 = const 3_usize; // scope 3 at $DIR/offset_of.rs:+4:14: +4:36 + _0 = const (); // scope 0 at $DIR/offset_of.rs:+0:15: +5:2 StorageDead(_4); // scope 3 at $DIR/offset_of.rs:+5:1: +5:2 StorageDead(_3); // scope 2 at $DIR/offset_of.rs:+5:1: +5:2 StorageDead(_2); // scope 1 at $DIR/offset_of.rs:+5:1: +5:2 diff --git a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.diff b/tests/mir-opt/const_prop/offset_of.generic.ConstProp.diff index 5c6cb47089e82..e40fdbd79d84e 100644 --- a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.diff +++ b/tests/mir-opt/const_prop/offset_of.generic.ConstProp.diff @@ -29,6 +29,7 @@ _3 = OffsetOf(Delta<T>, [1]); // scope 2 at $DIR/offset_of.rs:+3:14: +3:37 StorageLive(_4); // scope 3 at $DIR/offset_of.rs:+4:9: +4:11 _4 = OffsetOf(Delta<T>, [2]); // scope 3 at $DIR/offset_of.rs:+4:14: +4:37 + _0 = const (); // scope 0 at $DIR/offset_of.rs:+0:17: +5:2 StorageDead(_4); // scope 3 at $DIR/offset_of.rs:+5:1: +5:2 StorageDead(_3); // scope 2 at $DIR/offset_of.rs:+5:1: +5:2 StorageDead(_2); // scope 1 at $DIR/offset_of.rs:+5:1: +5:2 diff --git a/tests/mir-opt/const_prop/offset_of.rs b/tests/mir-opt/const_prop/offset_of.rs index eabdf84807986..4cdcd28eeb292 100644 --- a/tests/mir-opt/const_prop/offset_of.rs +++ b/tests/mir-opt/const_prop/offset_of.rs @@ -1,5 +1,4 @@ -// unit-test -// compile-flags: -O +// unit-test: ConstProp #![feature(offset_of)] diff --git a/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff b/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff index 388c6ca810b6e..c290fba563a22 100644 --- a/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff @@ -18,7 +18,7 @@ StorageLive(_3); // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 _3 = const {alloc1: &u8}; // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 // mir::Constant - // + span: $DIR/read_immutable_static.rs:8:13: 8:16 + // + span: $DIR/read_immutable_static.rs:7:13: 7:16 // + literal: Const { ty: &u8, val: Value(Scalar(alloc1)) } - _2 = (*_3); // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 + _2 = const 2_u8; // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:16 @@ -26,7 +26,7 @@ StorageLive(_5); // scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22 _5 = const {alloc1: &u8}; // scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22 // mir::Constant - // + span: $DIR/read_immutable_static.rs:8:19: 8:22 + // + span: $DIR/read_immutable_static.rs:7:19: 7:22 // + literal: Const { ty: &u8, val: Value(Scalar(alloc1)) } - _4 = (*_5); // scope 0 at $DIR/read_immutable_static.rs:+1:19: +1:22 - _1 = Add(move _2, move _4); // scope 0 at $DIR/read_immutable_static.rs:+1:13: +1:22 @@ -36,6 +36,7 @@ StorageDead(_2); // scope 0 at $DIR/read_immutable_static.rs:+1:21: +1:22 StorageDead(_5); // scope 0 at $DIR/read_immutable_static.rs:+1:22: +1:23 StorageDead(_3); // scope 0 at $DIR/read_immutable_static.rs:+1:22: +1:23 + _0 = const (); // scope 0 at $DIR/read_immutable_static.rs:+0:11: +2:2 StorageDead(_1); // scope 0 at $DIR/read_immutable_static.rs:+2:1: +2:2 return; // scope 0 at $DIR/read_immutable_static.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/const_prop/read_immutable_static.rs b/tests/mir-opt/const_prop/read_immutable_static.rs index 4f7afe6cad4a1..fb8f9fe996a6d 100644 --- a/tests/mir-opt/const_prop/read_immutable_static.rs +++ b/tests/mir-opt/const_prop/read_immutable_static.rs @@ -1,5 +1,4 @@ -// unit-test -// compile-flags: -O +// unit-test: ConstProp static FOO: u8 = 2; diff --git a/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff index 93863fca344a6..b022e2ba42bb8 100644 --- a/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff @@ -24,7 +24,7 @@ _4 = &raw const (*_1); // scope 1 at $DIR/lower_intrinsics.rs:+2:55: +2:56 - _3 = option_payload_ptr::<usize>(move _4) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:18: +2:57 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:132:18: 132:54 +- // + span: $DIR/lower_intrinsics.rs:137:18: 137:54 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const Option<usize>) -> *const usize {option_payload_ptr::<usize>}, val: Value(<ZST>) } + _3 = &raw const (((*_4) as Some).0: usize); // scope 1 at $DIR/lower_intrinsics.rs:+2:18: +2:57 + goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+2:18: +2:57 @@ -37,7 +37,7 @@ _6 = &raw const (*_2); // scope 2 at $DIR/lower_intrinsics.rs:+3:55: +3:56 - _5 = option_payload_ptr::<String>(move _6) -> [return: bb2, unwind unreachable]; // scope 2 at $DIR/lower_intrinsics.rs:+3:18: +3:57 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:133:18: 133:54 +- // + span: $DIR/lower_intrinsics.rs:138:18: 138:54 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const Option<String>) -> *const String {option_payload_ptr::<String>}, val: Value(<ZST>) } + _5 = &raw const (((*_6) as Some).0: std::string::String); // scope 2 at $DIR/lower_intrinsics.rs:+3:18: +3:57 + goto -> bb2; // scope 2 at $DIR/lower_intrinsics.rs:+3:18: +3:57 diff --git a/tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff index 37f1995a53a9d..60a1dd0ba7d09 100644 --- a/tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff @@ -15,7 +15,7 @@ _4 = _2; // scope 0 at $DIR/lower_intrinsics.rs:+1:33: +1:34 - _0 = offset::<*const i32, isize>(move _3, move _4) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:35 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:139:5: 139:29 +- // + span: $DIR/lower_intrinsics.rs:144:5: 144:29 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const i32, isize) -> *const i32 {offset::<*const i32, isize>}, val: Value(<ZST>) } + _0 = Offset(move _3, move _4); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:35 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:35 diff --git a/tests/mir-opt/lower_intrinsics.rs b/tests/mir-opt/lower_intrinsics.rs index 2b1e67be2a967..0ca88a42e3fd0 100644 --- a/tests/mir-opt/lower_intrinsics.rs +++ b/tests/mir-opt/lower_intrinsics.rs @@ -124,6 +124,11 @@ pub fn read_via_copy_uninhabited(r: &Never) -> Never { unsafe { core::intrinsics::read_via_copy(r) } } +// EMIT_MIR lower_intrinsics.write_via_move_string.LowerIntrinsics.diff +pub fn write_via_move_string(r: &mut String, v: String) { + unsafe { core::intrinsics::write_via_move(r, v) } +} + pub enum Never {} // EMIT_MIR lower_intrinsics.option_payload.LowerIntrinsics.diff diff --git a/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.diff new file mode 100644 index 0000000000000..38d99f661dc64 --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.diff @@ -0,0 +1,36 @@ +- // MIR for `write_via_move_string` before LowerIntrinsics ++ // MIR for `write_via_move_string` after LowerIntrinsics + + fn write_via_move_string(_1: &mut String, _2: String) -> () { + debug r => _1; // in scope 0 at $DIR/lower_intrinsics.rs:+0:30: +0:31 + debug v => _2; // in scope 0 at $DIR/lower_intrinsics.rs:+0:46: +0:47 + let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:57: +0:57 + let mut _3: *mut std::string::String; // in scope 0 at $DIR/lower_intrinsics.rs:+1:47: +1:48 + let mut _4: std::string::String; // in scope 0 at $DIR/lower_intrinsics.rs:+1:50: +1:51 + scope 1 { + } + + bb0: { + StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:+1:47: +1:48 + _3 = &raw mut (*_1); // scope 1 at $DIR/lower_intrinsics.rs:+1:47: +1:48 + StorageLive(_4); // scope 1 at $DIR/lower_intrinsics.rs:+1:50: +1:51 + _4 = move _2; // scope 1 at $DIR/lower_intrinsics.rs:+1:50: +1:51 +- _0 = write_via_move::<String>(move _3, move _4) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:52 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:129:14: 129:46 +- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*mut String, String) {write_via_move::<String>}, val: Value(<ZST>) } ++ (*_3) = move _4; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:52 ++ goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:52 + } + + bb1: { + StorageDead(_4); // scope 1 at $DIR/lower_intrinsics.rs:+1:51: +1:52 + StorageDead(_3); // scope 1 at $DIR/lower_intrinsics.rs:+1:51: +1:52 + goto -> bb2; // scope 0 at $DIR/lower_intrinsics.rs:+2:1: +2:2 + } + + bb2: { + return; // scope 0 at $DIR/lower_intrinsics.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/pre-codegen/mem_replace.manual_replace.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/mem_replace.manual_replace.PreCodegen.after.mir new file mode 100644 index 0000000000000..2b4971e2ef919 --- /dev/null +++ b/tests/mir-opt/pre-codegen/mem_replace.manual_replace.PreCodegen.after.mir @@ -0,0 +1,16 @@ +// MIR for `manual_replace` after PreCodegen + +fn manual_replace(_1: &mut u32, _2: u32) -> u32 { + debug r => _1; // in scope 0 at $DIR/mem_replace.rs:+0:23: +0:24 + debug v => _2; // in scope 0 at $DIR/mem_replace.rs:+0:36: +0:37 + let mut _0: u32; // return place in scope 0 at $DIR/mem_replace.rs:+1:9: +1:13 + scope 1 { + debug temp => _0; // in scope 1 at $DIR/mem_replace.rs:+1:9: +1:13 + } + + bb0: { + _0 = (*_1); // scope 0 at $DIR/mem_replace.rs:+1:16: +1:18 + (*_1) = _2; // scope 1 at $DIR/mem_replace.rs:+2:5: +2:11 + return; // scope 0 at $DIR/mem_replace.rs:+4:2: +4:2 + } +} diff --git a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir new file mode 100644 index 0000000000000..50e0538c13368 --- /dev/null +++ b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir @@ -0,0 +1,53 @@ +// MIR for `mem_replace` after PreCodegen + +fn mem_replace(_1: &mut u32, _2: u32) -> u32 { + debug r => _1; // in scope 0 at $DIR/mem_replace.rs:+0:20: +0:21 + debug v => _2; // in scope 0 at $DIR/mem_replace.rs:+0:33: +0:34 + let mut _0: u32; // return place in scope 0 at $DIR/mem_replace.rs:+0:44: +0:47 + scope 1 (inlined std::mem::replace::<u32>) { // at $DIR/mem_replace.rs:16:5: 16:28 + debug dest => _1; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug src => _2; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + let mut _3: *const u32; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + let mut _4: *mut u32; // in scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + scope 2 { + scope 3 { + debug result => _0; // in scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + scope 7 (inlined std::ptr::write::<u32>) { // at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug dst => _4; // in scope 7 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + debug src => _2; // in scope 7 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + let mut _6: *mut u32; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + scope 8 { + scope 9 (inlined std::ptr::write::runtime::<u32>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug dst => _6; // in scope 9 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + } + } + } + } + scope 4 (inlined std::ptr::read::<u32>) { // at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug src => _3; // in scope 4 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + let mut _5: *const u32; // in scope 4 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + scope 5 { + scope 6 (inlined std::ptr::read::runtime::<u32>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug src => _5; // in scope 6 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + } + } + } + } + } + + bb0: { + StorageLive(_3); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _3 = &raw const (*_1); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _0 = (*_3); // scope 5 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + StorageDead(_5); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + StorageDead(_3); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + StorageLive(_4); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + _4 = &raw mut (*_1); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + StorageLive(_6); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + (*_4) = _2; // scope 8 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + StorageDead(_6); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + StorageDead(_4); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + return; // scope 0 at $DIR/mem_replace.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/pre-codegen/mem_replace.rs b/tests/mir-opt/pre-codegen/mem_replace.rs new file mode 100644 index 0000000000000..e5066c38b9679 --- /dev/null +++ b/tests/mir-opt/pre-codegen/mem_replace.rs @@ -0,0 +1,17 @@ +// compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 +// only-64bit +// ignore-debug + +#![crate_type = "lib"] + +// EMIT_MIR mem_replace.manual_replace.PreCodegen.after.mir +pub fn manual_replace(r: &mut u32, v: u32) -> u32 { + let temp = *r; + *r = v; + temp +} + +// EMIT_MIR mem_replace.mem_replace.PreCodegen.after.mir +pub fn mem_replace(r: &mut u32, v: u32) -> u32 { + std::mem::replace(r, v) +} diff --git a/tests/pretty/offset_of.rs b/tests/pretty/offset_of.rs new file mode 100644 index 0000000000000..e1783432857e2 --- /dev/null +++ b/tests/pretty/offset_of.rs @@ -0,0 +1,4 @@ +// pp-exact +#![feature(offset_of)] + +fn main() { std::mem::offset_of!(std :: ops :: Range < usize >, end); } diff --git a/tests/pretty/tests-are-sorted.pp b/tests/pretty/tests-are-sorted.pp index 58f746f2e0ef8..7d7f682130df8 100644 --- a/tests/pretty/tests-are-sorted.pp +++ b/tests/pretty/tests-are-sorted.pp @@ -79,6 +79,7 @@ }; fn a_test() {} #[rustc_main] +#[no_coverage] pub fn main() -> () { extern crate test; test::test_main_static(&[&a_test, &m_test, &z_test]) diff --git a/tests/run-make/c-unwind-abi-catch-lib-panic/main.rs b/tests/run-make/c-unwind-abi-catch-lib-panic/main.rs index 78a71219c7811..42d3efa82d618 100644 --- a/tests/run-make/c-unwind-abi-catch-lib-panic/main.rs +++ b/tests/run-make/c-unwind-abi-catch-lib-panic/main.rs @@ -2,7 +2,6 @@ //! //! This test triggers a panic in a Rust library that our foreign function invokes. This shows //! that we can unwind through the C code in that library, and catch the underlying panic. -#![feature(c_unwind)] use std::panic::{catch_unwind, AssertUnwindSafe}; diff --git a/tests/run-make/c-unwind-abi-catch-lib-panic/panic.rs b/tests/run-make/c-unwind-abi-catch-lib-panic/panic.rs index a99a04d5c6f4b..9e7bc3e53a1ac 100644 --- a/tests/run-make/c-unwind-abi-catch-lib-panic/panic.rs +++ b/tests/run-make/c-unwind-abi-catch-lib-panic/panic.rs @@ -1,5 +1,4 @@ #![crate_type = "staticlib"] -#![feature(c_unwind)] /// This function will panic if `x` is greater than 10. /// diff --git a/tests/run-make/c-unwind-abi-catch-panic/main.rs b/tests/run-make/c-unwind-abi-catch-panic/main.rs index 15d38d7216058..1903be9561c57 100644 --- a/tests/run-make/c-unwind-abi-catch-panic/main.rs +++ b/tests/run-make/c-unwind-abi-catch-panic/main.rs @@ -1,7 +1,6 @@ //! A test for calling `C-unwind` functions across foreign function boundaries. //! //! This test triggers a panic when calling a foreign function that calls *back* into Rust. -#![feature(c_unwind)] use std::panic::{catch_unwind, AssertUnwindSafe}; diff --git a/tests/run-make/core-no-oom-handling/Makefile b/tests/run-make/core-no-oom-handling/Makefile new file mode 100644 index 0000000000000..28c5261ff854d --- /dev/null +++ b/tests/run-make/core-no-oom-handling/Makefile @@ -0,0 +1,6 @@ +include ../tools.mk + +FAKEROOT=$(TMPDIR)/fakeroot + +all: + $(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../library/core/src/lib.rs --sysroot=$(FAKEROOT) --cfg no_global_oom_handling diff --git a/tests/run-make/coverage-reports/Makefile b/tests/run-make/coverage-reports/Makefile index d06cd9c6a54f0..d4ae03e590a30 100644 --- a/tests/run-make/coverage-reports/Makefile +++ b/tests/run-make/coverage-reports/Makefile @@ -174,7 +174,7 @@ else # files are redundant, so there is no need to generate `expected_*.json` files or # compare actual JSON results.) - $(DIFF) --ignore-matching-lines='^ | .*::<.*>.*:$$' --ignore-matching-lines='^ | <.*>::.*:$$' \ + $(DIFF) --ignore-matching-lines='^ \| .*::<.*>.*:$$' --ignore-matching-lines='^ \| <.*>::.*:$$' \ expected_show_coverage.$@.txt "$(TMPDIR)"/actual_show_coverage.$@.txt || \ ( grep -q '^\/\/ ignore-llvm-cov-show-diffs' $(SOURCEDIR)/$@.rs && \ >&2 echo 'diff failed, but suppressed with `// ignore-llvm-cov-show-diffs` in $(SOURCEDIR)/$@.rs' \ diff --git a/tests/run-make/coverage-reports/expected_show_coverage.test_harness.txt b/tests/run-make/coverage-reports/expected_show_coverage.test_harness.txt new file mode 100644 index 0000000000000..93bd1cfcb4897 --- /dev/null +++ b/tests/run-make/coverage-reports/expected_show_coverage.test_harness.txt @@ -0,0 +1,11 @@ + 1| |// Verify that the entry point injected by the test harness doesn't cause + 2| |// weird artifacts in the coverage report (e.g. issue #10749). + 3| | + 4| |// compile-flags: --test + 5| | + 6| |#[allow(dead_code)] + 7| 0|fn unused() {} + 8| | + 9| 1|#[test] + 10| 1|fn my_test() {} + diff --git a/tests/run-make/coverage/test_harness.rs b/tests/run-make/coverage/test_harness.rs new file mode 100644 index 0000000000000..12a755734c198 --- /dev/null +++ b/tests/run-make/coverage/test_harness.rs @@ -0,0 +1,10 @@ +// Verify that the entry point injected by the test harness doesn't cause +// weird artifacts in the coverage report (e.g. issue #10749). + +// compile-flags: --test + +#[allow(dead_code)] +fn unused() {} + +#[test] +fn my_test() {} diff --git a/tests/run-make/foreign-double-unwind/foo.rs b/tests/run-make/foreign-double-unwind/foo.rs index cae8aa9402d88..c085480b4f88d 100644 --- a/tests/run-make/foreign-double-unwind/foo.rs +++ b/tests/run-make/foreign-double-unwind/foo.rs @@ -1,8 +1,6 @@ // Tests that C++ double unwinding through Rust code will be properly guarded // against instead of exhibiting undefined behaviour. -#![feature(c_unwind)] - extern "C-unwind" { fn throw_cxx_exception(); fn cxx_catch_callback(cb: extern "C-unwind" fn()); diff --git a/tests/run-make/foreign-exceptions/foo.rs b/tests/run-make/foreign-exceptions/foo.rs index dd3b7c76f2867..ccf858d858794 100644 --- a/tests/run-make/foreign-exceptions/foo.rs +++ b/tests/run-make/foreign-exceptions/foo.rs @@ -2,8 +2,6 @@ // are caught by catch_unwind. Also tests that Rust panics can unwind through // C++ code. -#![feature(c_unwind)] - use std::panic::{catch_unwind, AssertUnwindSafe}; struct DropCheck<'a>(&'a mut bool); diff --git a/tests/run-make/foreign-rust-exceptions/bar.rs b/tests/run-make/foreign-rust-exceptions/bar.rs index 5f9efe323609b..1d865b429fa95 100644 --- a/tests/run-make/foreign-rust-exceptions/bar.rs +++ b/tests/run-make/foreign-rust-exceptions/bar.rs @@ -1,5 +1,4 @@ #![crate_type = "cdylib"] -#![feature(c_unwind)] #[no_mangle] extern "C-unwind" fn panic() { diff --git a/tests/run-make/foreign-rust-exceptions/foo.rs b/tests/run-make/foreign-rust-exceptions/foo.rs index 266987c5b6d63..38942c55b19b0 100644 --- a/tests/run-make/foreign-rust-exceptions/foo.rs +++ b/tests/run-make/foreign-rust-exceptions/foo.rs @@ -1,5 +1,3 @@ -#![feature(c_unwind)] - #[cfg_attr(not(windows), link(name = "bar"))] #[cfg_attr(windows, link(name = "bar.dll"))] extern "C-unwind" { diff --git a/tests/rustdoc-json/fn_pointer/abi.rs b/tests/rustdoc-json/fn_pointer/abi.rs index 3c1a453d12de2..6a30acc2cc32c 100644 --- a/tests/rustdoc-json/fn_pointer/abi.rs +++ b/tests/rustdoc-json/fn_pointer/abi.rs @@ -1,7 +1,6 @@ // ignore-tidy-linelength #![feature(abi_vectorcall)] -#![feature(c_unwind)] // @is "$.index[*][?(@.name=='AbiRust')].inner.type.inner.header.abi" \"Rust\" pub type AbiRust = fn(); diff --git a/tests/rustdoc-json/fns/abi.rs b/tests/rustdoc-json/fns/abi.rs index 0e8b78bc0e6eb..7a5dbee730c7d 100644 --- a/tests/rustdoc-json/fns/abi.rs +++ b/tests/rustdoc-json/fns/abi.rs @@ -1,7 +1,6 @@ // ignore-tidy-linelength #![feature(abi_vectorcall)] -#![feature(c_unwind)] // @is "$.index[*][?(@.name=='abi_rust')].inner.header.abi" \"Rust\" pub fn abi_rust() {} diff --git a/tests/rustdoc-json/methods/abi.rs b/tests/rustdoc-json/methods/abi.rs index 4c97d97ceba52..fd03d92d65b97 100644 --- a/tests/rustdoc-json/methods/abi.rs +++ b/tests/rustdoc-json/methods/abi.rs @@ -1,7 +1,6 @@ // ignore-tidy-linelength #![feature(abi_vectorcall)] -#![feature(c_unwind)] #![feature(no_core)] #![no_core] diff --git a/tests/rustdoc-ui/check-cfg-test.stderr b/tests/rustdoc-ui/check-cfg/check-cfg-test.stderr similarity index 100% rename from tests/rustdoc-ui/check-cfg-test.stderr rename to tests/rustdoc-ui/check-cfg/check-cfg-test.stderr diff --git a/tests/rustdoc-ui/check-cfg-unstable.rs b/tests/rustdoc-ui/check-cfg/check-cfg-unstable.rs similarity index 100% rename from tests/rustdoc-ui/check-cfg-unstable.rs rename to tests/rustdoc-ui/check-cfg/check-cfg-unstable.rs diff --git a/tests/rustdoc-ui/check-cfg-unstable.stderr b/tests/rustdoc-ui/check-cfg/check-cfg-unstable.stderr similarity index 100% rename from tests/rustdoc-ui/check-cfg-unstable.stderr rename to tests/rustdoc-ui/check-cfg/check-cfg-unstable.stderr diff --git a/tests/rustdoc-ui/check-cfg.rs b/tests/rustdoc-ui/check-cfg/check-cfg.rs similarity index 100% rename from tests/rustdoc-ui/check-cfg.rs rename to tests/rustdoc-ui/check-cfg/check-cfg.rs diff --git a/tests/rustdoc-ui/check-cfg.stderr b/tests/rustdoc-ui/check-cfg/check-cfg.stderr similarity index 100% rename from tests/rustdoc-ui/check-cfg.stderr rename to tests/rustdoc-ui/check-cfg/check-cfg.stderr diff --git a/tests/rustdoc-ui/auxiliary/extern_macros.rs b/tests/rustdoc-ui/doctest/auxiliary/extern_macros.rs similarity index 100% rename from tests/rustdoc-ui/auxiliary/extern_macros.rs rename to tests/rustdoc-ui/doctest/auxiliary/extern_macros.rs diff --git a/tests/rustdoc-ui/block-doc-comment.rs b/tests/rustdoc-ui/doctest/block-doc-comment.rs similarity index 100% rename from tests/rustdoc-ui/block-doc-comment.rs rename to tests/rustdoc-ui/doctest/block-doc-comment.rs diff --git a/tests/rustdoc-ui/block-doc-comment.stdout b/tests/rustdoc-ui/doctest/block-doc-comment.stdout similarity index 100% rename from tests/rustdoc-ui/block-doc-comment.stdout rename to tests/rustdoc-ui/doctest/block-doc-comment.stdout diff --git a/tests/rustdoc-ui/cfg-test.rs b/tests/rustdoc-ui/doctest/cfg-test.rs similarity index 90% rename from tests/rustdoc-ui/cfg-test.rs rename to tests/rustdoc-ui/doctest/cfg-test.rs index d40b928373555..a263baa9738c5 100644 --- a/tests/rustdoc-ui/cfg-test.rs +++ b/tests/rustdoc-ui/doctest/cfg-test.rs @@ -1,6 +1,6 @@ // check-pass // compile-flags:--test --test-args --test-threads=1 -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // Crates like core have doctests gated on `cfg(not(test))` so we need to make diff --git a/tests/rustdoc-ui/cfg-test.stdout b/tests/rustdoc-ui/doctest/cfg-test.stdout similarity index 100% rename from tests/rustdoc-ui/cfg-test.stdout rename to tests/rustdoc-ui/doctest/cfg-test.stdout diff --git a/tests/rustdoc-ui/check-attr-test.rs b/tests/rustdoc-ui/doctest/check-attr-test.rs similarity index 100% rename from tests/rustdoc-ui/check-attr-test.rs rename to tests/rustdoc-ui/doctest/check-attr-test.rs diff --git a/tests/rustdoc-ui/check-attr-test.stderr b/tests/rustdoc-ui/doctest/check-attr-test.stderr similarity index 100% rename from tests/rustdoc-ui/check-attr-test.stderr rename to tests/rustdoc-ui/doctest/check-attr-test.stderr diff --git a/tests/rustdoc-ui/check-cfg-test.rs b/tests/rustdoc-ui/doctest/check-cfg-test.rs similarity index 72% rename from tests/rustdoc-ui/check-cfg-test.rs rename to tests/rustdoc-ui/doctest/check-cfg-test.rs index 920432276cba0..49a801c3fb352 100644 --- a/tests/rustdoc-ui/check-cfg-test.rs +++ b/tests/rustdoc-ui/doctest/check-cfg-test.rs @@ -1,7 +1,7 @@ // check-pass // compile-flags: --test --nocapture --check-cfg=values(feature,"test") -Z unstable-options -// normalize-stderr-test: "tests/rustdoc-ui" -> "$$DIR" -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stderr-test: "tests/rustdoc-ui/doctest" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" /// The doctest will produce a warning because feature invalid is unexpected diff --git a/tests/rustdoc-ui/doctest/check-cfg-test.stderr b/tests/rustdoc-ui/doctest/check-cfg-test.stderr new file mode 100644 index 0000000000000..9770be2f191f0 --- /dev/null +++ b/tests/rustdoc-ui/doctest/check-cfg-test.stderr @@ -0,0 +1,11 @@ +warning: unexpected `cfg` condition value + --> $DIR/check-cfg-test.rs:9:7 + | +LL | #[cfg(feature = "invalid")] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: test + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: 1 warning emitted + diff --git a/tests/rustdoc-ui/check-cfg-test.stdout b/tests/rustdoc-ui/doctest/check-cfg-test.stdout similarity index 100% rename from tests/rustdoc-ui/check-cfg-test.stdout rename to tests/rustdoc-ui/doctest/check-cfg-test.stdout diff --git a/tests/rustdoc-ui/display-output.rs b/tests/rustdoc-ui/doctest/display-output.rs similarity index 84% rename from tests/rustdoc-ui/display-output.rs rename to tests/rustdoc-ui/doctest/display-output.rs index 23bc54e3cde1a..7a26dbff98613 100644 --- a/tests/rustdoc-ui/display-output.rs +++ b/tests/rustdoc-ui/doctest/display-output.rs @@ -3,7 +3,7 @@ // check-pass // edition:2018 // compile-flags:--test --test-args=--show-output -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" /// ``` diff --git a/tests/rustdoc-ui/display-output.stdout b/tests/rustdoc-ui/doctest/display-output.stdout similarity index 100% rename from tests/rustdoc-ui/display-output.stdout rename to tests/rustdoc-ui/doctest/display-output.stdout diff --git a/tests/rustdoc-ui/doc-comment-multi-line-attr.rs b/tests/rustdoc-ui/doctest/doc-comment-multi-line-attr.rs similarity index 80% rename from tests/rustdoc-ui/doc-comment-multi-line-attr.rs rename to tests/rustdoc-ui/doctest/doc-comment-multi-line-attr.rs index db674e229fc0d..75508f435b3ca 100644 --- a/tests/rustdoc-ui/doc-comment-multi-line-attr.rs +++ b/tests/rustdoc-ui/doctest/doc-comment-multi-line-attr.rs @@ -1,6 +1,6 @@ // Regression test for #97440: Multiline inner attribute triggers ICE during doctest // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // check-pass diff --git a/tests/rustdoc-ui/doc-comment-multi-line-attr.stdout b/tests/rustdoc-ui/doctest/doc-comment-multi-line-attr.stdout similarity index 100% rename from tests/rustdoc-ui/doc-comment-multi-line-attr.stdout rename to tests/rustdoc-ui/doctest/doc-comment-multi-line-attr.stdout diff --git a/tests/rustdoc-ui/doc-comment-multi-line-cfg-attr.rs b/tests/rustdoc-ui/doctest/doc-comment-multi-line-cfg-attr.rs similarity index 78% rename from tests/rustdoc-ui/doc-comment-multi-line-cfg-attr.rs rename to tests/rustdoc-ui/doctest/doc-comment-multi-line-cfg-attr.rs index 6ce3cb9fc0707..3b0b27edb7d08 100644 --- a/tests/rustdoc-ui/doc-comment-multi-line-cfg-attr.rs +++ b/tests/rustdoc-ui/doctest/doc-comment-multi-line-cfg-attr.rs @@ -1,5 +1,5 @@ // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // check-pass diff --git a/tests/rustdoc-ui/doc-comment-multi-line-cfg-attr.stdout b/tests/rustdoc-ui/doctest/doc-comment-multi-line-cfg-attr.stdout similarity index 100% rename from tests/rustdoc-ui/doc-comment-multi-line-cfg-attr.stdout rename to tests/rustdoc-ui/doctest/doc-comment-multi-line-cfg-attr.stdout diff --git a/tests/rustdoc-ui/doc-test-attr-pass.rs b/tests/rustdoc-ui/doctest/doc-test-attr-pass.rs similarity index 100% rename from tests/rustdoc-ui/doc-test-attr-pass.rs rename to tests/rustdoc-ui/doctest/doc-test-attr-pass.rs diff --git a/tests/rustdoc-ui/doc-test-attr.rs b/tests/rustdoc-ui/doctest/doc-test-attr.rs similarity index 100% rename from tests/rustdoc-ui/doc-test-attr.rs rename to tests/rustdoc-ui/doctest/doc-test-attr.rs diff --git a/tests/rustdoc-ui/doc-test-attr.stderr b/tests/rustdoc-ui/doctest/doc-test-attr.stderr similarity index 100% rename from tests/rustdoc-ui/doc-test-attr.stderr rename to tests/rustdoc-ui/doctest/doc-test-attr.stderr diff --git a/tests/rustdoc-ui/doc-test-doctest-feature.rs b/tests/rustdoc-ui/doctest/doc-test-doctest-feature.rs similarity index 81% rename from tests/rustdoc-ui/doc-test-doctest-feature.rs rename to tests/rustdoc-ui/doctest/doc-test-doctest-feature.rs index 88cf44e643be0..9c1f4936eab31 100644 --- a/tests/rustdoc-ui/doc-test-doctest-feature.rs +++ b/tests/rustdoc-ui/doctest/doc-test-doctest-feature.rs @@ -1,6 +1,6 @@ // check-pass // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // Make sure `cfg(doctest)` is set when finding doctests but not inside diff --git a/tests/rustdoc-ui/doc-test-doctest-feature.stdout b/tests/rustdoc-ui/doctest/doc-test-doctest-feature.stdout similarity index 100% rename from tests/rustdoc-ui/doc-test-doctest-feature.stdout rename to tests/rustdoc-ui/doctest/doc-test-doctest-feature.stdout diff --git a/tests/rustdoc-ui/doc-test-rustdoc-feature.rs b/tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.rs similarity index 82% rename from tests/rustdoc-ui/doc-test-rustdoc-feature.rs rename to tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.rs index dc72a4857645e..1f90d13af84fc 100644 --- a/tests/rustdoc-ui/doc-test-rustdoc-feature.rs +++ b/tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.rs @@ -1,6 +1,6 @@ // check-pass // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" #![feature(doc_cfg)] diff --git a/tests/rustdoc-ui/doc-test-rustdoc-feature.stdout b/tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.stdout similarity index 100% rename from tests/rustdoc-ui/doc-test-rustdoc-feature.stdout rename to tests/rustdoc-ui/doctest/doc-test-rustdoc-feature.stdout diff --git a/tests/rustdoc-ui/doctest-edition.rs b/tests/rustdoc-ui/doctest/doctest-edition.rs similarity index 100% rename from tests/rustdoc-ui/doctest-edition.rs rename to tests/rustdoc-ui/doctest/doctest-edition.rs diff --git a/tests/rustdoc-ui/doctest-edition.stderr b/tests/rustdoc-ui/doctest/doctest-edition.stderr similarity index 100% rename from tests/rustdoc-ui/doctest-edition.stderr rename to tests/rustdoc-ui/doctest/doctest-edition.stderr diff --git a/tests/rustdoc-ui/doctest-multiline-crate-attribute.rs b/tests/rustdoc-ui/doctest/doctest-multiline-crate-attribute.rs similarity index 81% rename from tests/rustdoc-ui/doctest-multiline-crate-attribute.rs rename to tests/rustdoc-ui/doctest/doctest-multiline-crate-attribute.rs index 260f5a7a64f50..a3bde6cb94103 100644 --- a/tests/rustdoc-ui/doctest-multiline-crate-attribute.rs +++ b/tests/rustdoc-ui/doctest/doctest-multiline-crate-attribute.rs @@ -1,5 +1,5 @@ // compile-flags:--test --test-args=--test-threads=1 -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // check-pass diff --git a/tests/rustdoc-ui/doctest-multiline-crate-attribute.stdout b/tests/rustdoc-ui/doctest/doctest-multiline-crate-attribute.stdout similarity index 100% rename from tests/rustdoc-ui/doctest-multiline-crate-attribute.stdout rename to tests/rustdoc-ui/doctest/doctest-multiline-crate-attribute.stdout diff --git a/tests/rustdoc-ui/doctest-output.rs b/tests/rustdoc-ui/doctest/doctest-output.rs similarity index 87% rename from tests/rustdoc-ui/doctest-output.rs rename to tests/rustdoc-ui/doctest/doctest-output.rs index 303f768969817..26754b73f0bc0 100644 --- a/tests/rustdoc-ui/doctest-output.rs +++ b/tests/rustdoc-ui/doctest/doctest-output.rs @@ -1,7 +1,7 @@ // edition:2018 // aux-build:extern_macros.rs // compile-flags:--test --test-args=--test-threads=1 -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // check-pass diff --git a/tests/rustdoc-ui/doctest-output.stdout b/tests/rustdoc-ui/doctest/doctest-output.stdout similarity index 100% rename from tests/rustdoc-ui/doctest-output.stdout rename to tests/rustdoc-ui/doctest/doctest-output.stdout diff --git a/tests/rustdoc-ui/failed-doctest-compile-fail.rs b/tests/rustdoc-ui/doctest/failed-doctest-compile-fail.rs similarity index 84% rename from tests/rustdoc-ui/failed-doctest-compile-fail.rs rename to tests/rustdoc-ui/doctest/failed-doctest-compile-fail.rs index 4dfca600f1627..53b3857dfde69 100644 --- a/tests/rustdoc-ui/failed-doctest-compile-fail.rs +++ b/tests/rustdoc-ui/doctest/failed-doctest-compile-fail.rs @@ -2,7 +2,7 @@ // adapted to use that, and that normalize line can go away // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // failure-status: 101 diff --git a/tests/rustdoc-ui/failed-doctest-compile-fail.stdout b/tests/rustdoc-ui/doctest/failed-doctest-compile-fail.stdout similarity index 100% rename from tests/rustdoc-ui/failed-doctest-compile-fail.stdout rename to tests/rustdoc-ui/doctest/failed-doctest-compile-fail.stdout diff --git a/tests/rustdoc-ui/failed-doctest-extra-semicolon-on-item.rs b/tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.rs similarity index 88% rename from tests/rustdoc-ui/failed-doctest-extra-semicolon-on-item.rs rename to tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.rs index 03a5b9d5d842f..84e4d61603aef 100644 --- a/tests/rustdoc-ui/failed-doctest-extra-semicolon-on-item.rs +++ b/tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.rs @@ -2,7 +2,7 @@ // adapted to use that, and that normalize line can go away // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // failure-status: 101 diff --git a/tests/rustdoc-ui/failed-doctest-extra-semicolon-on-item.stdout b/tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.stdout similarity index 100% rename from tests/rustdoc-ui/failed-doctest-extra-semicolon-on-item.stdout rename to tests/rustdoc-ui/doctest/failed-doctest-extra-semicolon-on-item.stdout diff --git a/tests/rustdoc-ui/failed-doctest-missing-codes.rs b/tests/rustdoc-ui/doctest/failed-doctest-missing-codes.rs similarity index 84% rename from tests/rustdoc-ui/failed-doctest-missing-codes.rs rename to tests/rustdoc-ui/doctest/failed-doctest-missing-codes.rs index 66a229a0c7576..4e3b848fc02bc 100644 --- a/tests/rustdoc-ui/failed-doctest-missing-codes.rs +++ b/tests/rustdoc-ui/doctest/failed-doctest-missing-codes.rs @@ -2,7 +2,7 @@ // adapted to use that, and that normalize line can go away // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // failure-status: 101 diff --git a/tests/rustdoc-ui/failed-doctest-missing-codes.stdout b/tests/rustdoc-ui/doctest/failed-doctest-missing-codes.stdout similarity index 100% rename from tests/rustdoc-ui/failed-doctest-missing-codes.stdout rename to tests/rustdoc-ui/doctest/failed-doctest-missing-codes.stdout diff --git a/tests/rustdoc-ui/failed-doctest-output-windows.rs b/tests/rustdoc-ui/doctest/failed-doctest-output-windows.rs similarity index 92% rename from tests/rustdoc-ui/failed-doctest-output-windows.rs rename to tests/rustdoc-ui/doctest/failed-doctest-output-windows.rs index 456a9e68f20c1..6bc6c33c76ecc 100644 --- a/tests/rustdoc-ui/failed-doctest-output-windows.rs +++ b/tests/rustdoc-ui/doctest/failed-doctest-output-windows.rs @@ -7,7 +7,7 @@ // compile-flags:--test --test-args --test-threads=1 // rustc-env:RUST_BACKTRACE=0 -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // failure-status: 101 diff --git a/tests/rustdoc-ui/failed-doctest-output-windows.stdout b/tests/rustdoc-ui/doctest/failed-doctest-output-windows.stdout similarity index 100% rename from tests/rustdoc-ui/failed-doctest-output-windows.stdout rename to tests/rustdoc-ui/doctest/failed-doctest-output-windows.stdout diff --git a/tests/rustdoc-ui/failed-doctest-output.rs b/tests/rustdoc-ui/doctest/failed-doctest-output.rs similarity index 92% rename from tests/rustdoc-ui/failed-doctest-output.rs rename to tests/rustdoc-ui/doctest/failed-doctest-output.rs index 77647f8eca954..3e1312382ee87 100644 --- a/tests/rustdoc-ui/failed-doctest-output.rs +++ b/tests/rustdoc-ui/doctest/failed-doctest-output.rs @@ -7,7 +7,7 @@ // compile-flags:--test --test-args --test-threads=1 // rustc-env:RUST_BACKTRACE=0 -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // failure-status: 101 diff --git a/tests/rustdoc-ui/failed-doctest-output.stdout b/tests/rustdoc-ui/doctest/failed-doctest-output.stdout similarity index 100% rename from tests/rustdoc-ui/failed-doctest-output.stdout rename to tests/rustdoc-ui/doctest/failed-doctest-output.stdout diff --git a/tests/rustdoc-ui/failed-doctest-should-panic.rs b/tests/rustdoc-ui/doctest/failed-doctest-should-panic.rs similarity index 84% rename from tests/rustdoc-ui/failed-doctest-should-panic.rs rename to tests/rustdoc-ui/doctest/failed-doctest-should-panic.rs index c134f80064d55..36284e814f3c4 100644 --- a/tests/rustdoc-ui/failed-doctest-should-panic.rs +++ b/tests/rustdoc-ui/doctest/failed-doctest-should-panic.rs @@ -2,7 +2,7 @@ // adapted to use that, and that normalize line can go away // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // failure-status: 101 diff --git a/tests/rustdoc-ui/failed-doctest-should-panic.stdout b/tests/rustdoc-ui/doctest/failed-doctest-should-panic.stdout similarity index 100% rename from tests/rustdoc-ui/failed-doctest-should-panic.stdout rename to tests/rustdoc-ui/doctest/failed-doctest-should-panic.stdout diff --git a/tests/rustdoc-ui/no-run-flag-error.rs b/tests/rustdoc-ui/doctest/no-run-flag-error.rs similarity index 100% rename from tests/rustdoc-ui/no-run-flag-error.rs rename to tests/rustdoc-ui/doctest/no-run-flag-error.rs diff --git a/tests/rustdoc-ui/no-run-flag-error.stderr b/tests/rustdoc-ui/doctest/no-run-flag-error.stderr similarity index 100% rename from tests/rustdoc-ui/no-run-flag-error.stderr rename to tests/rustdoc-ui/doctest/no-run-flag-error.stderr diff --git a/tests/rustdoc-ui/no-run-flag.rs b/tests/rustdoc-ui/doctest/no-run-flag.rs similarity index 91% rename from tests/rustdoc-ui/no-run-flag.rs rename to tests/rustdoc-ui/doctest/no-run-flag.rs index 181730eb41618..1cf3b7c4bb3d0 100644 --- a/tests/rustdoc-ui/no-run-flag.rs +++ b/tests/rustdoc-ui/doctest/no-run-flag.rs @@ -2,7 +2,7 @@ // check-pass // compile-flags:-Z unstable-options --test --no-run --test-args=--test-threads=1 -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" /// ``` diff --git a/tests/rustdoc-ui/no-run-flag.stdout b/tests/rustdoc-ui/doctest/no-run-flag.stdout similarity index 100% rename from tests/rustdoc-ui/no-run-flag.stdout rename to tests/rustdoc-ui/doctest/no-run-flag.stdout diff --git a/tests/rustdoc-ui/nocapture-fail.rs b/tests/rustdoc-ui/doctest/nocapture-fail.rs similarity index 63% rename from tests/rustdoc-ui/nocapture-fail.rs rename to tests/rustdoc-ui/doctest/nocapture-fail.rs index 9a3fb592c6304..ce487a43db418 100644 --- a/tests/rustdoc-ui/nocapture-fail.rs +++ b/tests/rustdoc-ui/doctest/nocapture-fail.rs @@ -1,7 +1,7 @@ // check-pass // compile-flags:--test -Zunstable-options --nocapture -// normalize-stderr-test: "tests/rustdoc-ui" -> "$$DIR" -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stderr-test: "tests/rustdoc-ui/doctest" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" /// ```compile_fail diff --git a/tests/rustdoc-ui/nocapture-fail.stderr b/tests/rustdoc-ui/doctest/nocapture-fail.stderr similarity index 100% rename from tests/rustdoc-ui/nocapture-fail.stderr rename to tests/rustdoc-ui/doctest/nocapture-fail.stderr diff --git a/tests/rustdoc-ui/nocapture-fail.stdout b/tests/rustdoc-ui/doctest/nocapture-fail.stdout similarity index 100% rename from tests/rustdoc-ui/nocapture-fail.stdout rename to tests/rustdoc-ui/doctest/nocapture-fail.stdout diff --git a/tests/rustdoc-ui/nocapture.rs b/tests/rustdoc-ui/doctest/nocapture.rs similarity index 77% rename from tests/rustdoc-ui/nocapture.rs rename to tests/rustdoc-ui/doctest/nocapture.rs index 3eb38f2fb3b8b..25fbcf857e256 100644 --- a/tests/rustdoc-ui/nocapture.rs +++ b/tests/rustdoc-ui/doctest/nocapture.rs @@ -1,6 +1,6 @@ // check-pass // compile-flags:--test -Zunstable-options --nocapture -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" /// ``` diff --git a/tests/rustdoc-ui/nocapture.stderr b/tests/rustdoc-ui/doctest/nocapture.stderr similarity index 100% rename from tests/rustdoc-ui/nocapture.stderr rename to tests/rustdoc-ui/doctest/nocapture.stderr diff --git a/tests/rustdoc-ui/nocapture.stdout b/tests/rustdoc-ui/doctest/nocapture.stdout similarity index 100% rename from tests/rustdoc-ui/nocapture.stdout rename to tests/rustdoc-ui/doctest/nocapture.stdout diff --git a/tests/rustdoc-ui/private-doc-test.rs b/tests/rustdoc-ui/doctest/private-doc-test.rs similarity index 100% rename from tests/rustdoc-ui/private-doc-test.rs rename to tests/rustdoc-ui/doctest/private-doc-test.rs diff --git a/tests/rustdoc-ui/private-item-doc-test.rs b/tests/rustdoc-ui/doctest/private-item-doc-test.rs similarity index 100% rename from tests/rustdoc-ui/private-item-doc-test.rs rename to tests/rustdoc-ui/doctest/private-item-doc-test.rs diff --git a/tests/rustdoc-ui/private-item-doc-test.stderr b/tests/rustdoc-ui/doctest/private-item-doc-test.stderr similarity index 100% rename from tests/rustdoc-ui/private-item-doc-test.stderr rename to tests/rustdoc-ui/doctest/private-item-doc-test.stderr diff --git a/tests/rustdoc-ui/private-public-item-doc-test.rs b/tests/rustdoc-ui/doctest/private-public-item-doc-test.rs similarity index 100% rename from tests/rustdoc-ui/private-public-item-doc-test.rs rename to tests/rustdoc-ui/doctest/private-public-item-doc-test.rs diff --git a/tests/rustdoc-ui/private-public-item-doc-test.stderr b/tests/rustdoc-ui/doctest/private-public-item-doc-test.stderr similarity index 100% rename from tests/rustdoc-ui/private-public-item-doc-test.stderr rename to tests/rustdoc-ui/doctest/private-public-item-doc-test.stderr diff --git a/tests/rustdoc-ui/public-reexported-item-doc-test.rs b/tests/rustdoc-ui/doctest/public-reexported-item-doc-test.rs similarity index 100% rename from tests/rustdoc-ui/public-reexported-item-doc-test.rs rename to tests/rustdoc-ui/doctest/public-reexported-item-doc-test.rs diff --git a/tests/rustdoc-ui/run-directory.correct.stdout b/tests/rustdoc-ui/doctest/run-directory.correct.stdout similarity index 100% rename from tests/rustdoc-ui/run-directory.correct.stdout rename to tests/rustdoc-ui/doctest/run-directory.correct.stdout diff --git a/tests/rustdoc-ui/run-directory.incorrect.stdout b/tests/rustdoc-ui/doctest/run-directory.incorrect.stdout similarity index 100% rename from tests/rustdoc-ui/run-directory.incorrect.stdout rename to tests/rustdoc-ui/doctest/run-directory.incorrect.stdout diff --git a/tests/rustdoc-ui/run-directory.rs b/tests/rustdoc-ui/doctest/run-directory.rs similarity index 70% rename from tests/rustdoc-ui/run-directory.rs rename to tests/rustdoc-ui/doctest/run-directory.rs index b8d0647f08d8e..1ff0af2d17cb3 100644 --- a/tests/rustdoc-ui/run-directory.rs +++ b/tests/rustdoc-ui/doctest/run-directory.rs @@ -4,12 +4,12 @@ // check-pass // [correct]compile-flags:--test --test-run-directory={{src-base}} // [incorrect]compile-flags:--test --test-run-directory={{src-base}}/coverage -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" /// ``` /// assert_eq!( -/// std::fs::read_to_string("run-directory.rs").unwrap(), +/// std::fs::read_to_string("doctest/run-directory.rs").unwrap(), /// include_str!("run-directory.rs"), /// ); /// ``` @@ -17,7 +17,7 @@ pub fn foo() {} /// ``` -/// assert!(std::fs::read_to_string("run-directory.rs").is_err()); +/// assert!(std::fs::read_to_string("doctest/run-directory.rs").is_err()); /// ``` #[cfg(incorrect)] pub fn foo() {} diff --git a/tests/rustdoc-ui/test-compile-fail1.rs b/tests/rustdoc-ui/doctest/test-compile-fail1.rs similarity index 100% rename from tests/rustdoc-ui/test-compile-fail1.rs rename to tests/rustdoc-ui/doctest/test-compile-fail1.rs diff --git a/tests/rustdoc-ui/test-compile-fail1.stderr b/tests/rustdoc-ui/doctest/test-compile-fail1.stderr similarity index 100% rename from tests/rustdoc-ui/test-compile-fail1.stderr rename to tests/rustdoc-ui/doctest/test-compile-fail1.stderr diff --git a/tests/rustdoc-ui/test-compile-fail2.rs b/tests/rustdoc-ui/doctest/test-compile-fail2.rs similarity index 100% rename from tests/rustdoc-ui/test-compile-fail2.rs rename to tests/rustdoc-ui/doctest/test-compile-fail2.rs diff --git a/tests/rustdoc-ui/test-compile-fail2.stderr b/tests/rustdoc-ui/doctest/test-compile-fail2.stderr similarity index 100% rename from tests/rustdoc-ui/test-compile-fail2.stderr rename to tests/rustdoc-ui/doctest/test-compile-fail2.stderr diff --git a/tests/rustdoc-ui/test-compile-fail3.rs b/tests/rustdoc-ui/doctest/test-compile-fail3.rs similarity index 100% rename from tests/rustdoc-ui/test-compile-fail3.rs rename to tests/rustdoc-ui/doctest/test-compile-fail3.rs diff --git a/tests/rustdoc-ui/test-compile-fail3.stderr b/tests/rustdoc-ui/doctest/test-compile-fail3.stderr similarity index 100% rename from tests/rustdoc-ui/test-compile-fail3.stderr rename to tests/rustdoc-ui/doctest/test-compile-fail3.stderr diff --git a/tests/rustdoc-ui/test-no_std.rs b/tests/rustdoc-ui/doctest/test-no_std.rs similarity index 75% rename from tests/rustdoc-ui/test-no_std.rs rename to tests/rustdoc-ui/doctest/test-no_std.rs index 51abf1c721768..fd651d1a34421 100644 --- a/tests/rustdoc-ui/test-no_std.rs +++ b/tests/rustdoc-ui/doctest/test-no_std.rs @@ -1,5 +1,5 @@ // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // check-pass diff --git a/tests/rustdoc-ui/test-no_std.stdout b/tests/rustdoc-ui/doctest/test-no_std.stdout similarity index 100% rename from tests/rustdoc-ui/test-no_std.stdout rename to tests/rustdoc-ui/doctest/test-no_std.stdout diff --git a/tests/rustdoc-ui/test-type.rs b/tests/rustdoc-ui/doctest/test-type.rs similarity index 87% rename from tests/rustdoc-ui/test-type.rs rename to tests/rustdoc-ui/doctest/test-type.rs index 7f5a8f3fc415a..036d37f9db2b2 100644 --- a/tests/rustdoc-ui/test-type.rs +++ b/tests/rustdoc-ui/doctest/test-type.rs @@ -1,6 +1,6 @@ // compile-flags: --test --test-args=--test-threads=1 // check-pass -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" /// ``` diff --git a/tests/rustdoc-ui/test-type.stdout b/tests/rustdoc-ui/doctest/test-type.stdout similarity index 100% rename from tests/rustdoc-ui/test-type.stdout rename to tests/rustdoc-ui/doctest/test-type.stdout diff --git a/tests/rustdoc-ui/unparseable-doc-test.rs b/tests/rustdoc-ui/doctest/unparseable-doc-test.rs similarity index 77% rename from tests/rustdoc-ui/unparseable-doc-test.rs rename to tests/rustdoc-ui/doctest/unparseable-doc-test.rs index f0a56a91bf549..fd8b2094d0201 100644 --- a/tests/rustdoc-ui/unparseable-doc-test.rs +++ b/tests/rustdoc-ui/doctest/unparseable-doc-test.rs @@ -1,5 +1,5 @@ // compile-flags: --test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // failure-status: 101 // rustc-env: RUST_BACKTRACE=0 diff --git a/tests/rustdoc-ui/unparseable-doc-test.stdout b/tests/rustdoc-ui/doctest/unparseable-doc-test.stdout similarity index 100% rename from tests/rustdoc-ui/unparseable-doc-test.stdout rename to tests/rustdoc-ui/doctest/unparseable-doc-test.stdout diff --git a/tests/rustdoc-ui/generate-link-to-definition-opt-unstable.rs b/tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt-unstable.rs similarity index 100% rename from tests/rustdoc-ui/generate-link-to-definition-opt-unstable.rs rename to tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt-unstable.rs diff --git a/tests/rustdoc-ui/generate-link-to-definition-opt-unstable.stderr b/tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt-unstable.stderr similarity index 100% rename from tests/rustdoc-ui/generate-link-to-definition-opt-unstable.stderr rename to tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt-unstable.stderr diff --git a/tests/rustdoc-ui/generate-link-to-definition-opt.rs b/tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt.rs similarity index 100% rename from tests/rustdoc-ui/generate-link-to-definition-opt.rs rename to tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt.rs diff --git a/tests/rustdoc-ui/generate-link-to-definition-opt.stderr b/tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt.stderr similarity index 100% rename from tests/rustdoc-ui/generate-link-to-definition-opt.stderr rename to tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt.stderr diff --git a/tests/rustdoc-ui/generate-link-to-definition-opt2.rs b/tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt2.rs similarity index 100% rename from tests/rustdoc-ui/generate-link-to-definition-opt2.rs rename to tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt2.rs diff --git a/tests/rustdoc-ui/generate-link-to-definition-opt2.stderr b/tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt2.stderr similarity index 100% rename from tests/rustdoc-ui/generate-link-to-definition-opt2.stderr rename to tests/rustdoc-ui/generate-link-to-definition/generate-link-to-definition-opt2.stderr diff --git a/tests/rustdoc-ui/assoc-item-not-in-scope.rs b/tests/rustdoc-ui/intra-doc/assoc-item-not-in-scope.rs similarity index 100% rename from tests/rustdoc-ui/assoc-item-not-in-scope.rs rename to tests/rustdoc-ui/intra-doc/assoc-item-not-in-scope.rs diff --git a/tests/rustdoc-ui/assoc-item-not-in-scope.stderr b/tests/rustdoc-ui/intra-doc/assoc-item-not-in-scope.stderr similarity index 100% rename from tests/rustdoc-ui/assoc-item-not-in-scope.stderr rename to tests/rustdoc-ui/intra-doc/assoc-item-not-in-scope.stderr diff --git a/tests/rustdoc-ui/deny-intra-link-resolution-failure.rs b/tests/rustdoc-ui/intra-doc/deny-intra-link-resolution-failure.rs similarity index 100% rename from tests/rustdoc-ui/deny-intra-link-resolution-failure.rs rename to tests/rustdoc-ui/intra-doc/deny-intra-link-resolution-failure.rs diff --git a/tests/rustdoc-ui/deny-intra-link-resolution-failure.stderr b/tests/rustdoc-ui/intra-doc/deny-intra-link-resolution-failure.stderr similarity index 100% rename from tests/rustdoc-ui/deny-intra-link-resolution-failure.stderr rename to tests/rustdoc-ui/intra-doc/deny-intra-link-resolution-failure.stderr diff --git a/tests/rustdoc-ui/pub-export-lint.rs b/tests/rustdoc-ui/intra-doc/pub-export-lint.rs similarity index 100% rename from tests/rustdoc-ui/pub-export-lint.rs rename to tests/rustdoc-ui/intra-doc/pub-export-lint.rs diff --git a/tests/rustdoc-ui/pub-export-lint.stderr b/tests/rustdoc-ui/intra-doc/pub-export-lint.stderr similarity index 100% rename from tests/rustdoc-ui/pub-export-lint.stderr rename to tests/rustdoc-ui/intra-doc/pub-export-lint.stderr diff --git a/tests/rustdoc-ui/reference-link-reports-error-once.rs b/tests/rustdoc-ui/intra-doc/reference-link-reports-error-once.rs similarity index 100% rename from tests/rustdoc-ui/reference-link-reports-error-once.rs rename to tests/rustdoc-ui/intra-doc/reference-link-reports-error-once.rs diff --git a/tests/rustdoc-ui/reference-link-reports-error-once.stderr b/tests/rustdoc-ui/intra-doc/reference-link-reports-error-once.stderr similarity index 100% rename from tests/rustdoc-ui/reference-link-reports-error-once.stderr rename to tests/rustdoc-ui/intra-doc/reference-link-reports-error-once.stderr diff --git a/tests/rustdoc-ui/reference-links.rs b/tests/rustdoc-ui/intra-doc/reference-links.rs similarity index 100% rename from tests/rustdoc-ui/reference-links.rs rename to tests/rustdoc-ui/intra-doc/reference-links.rs diff --git a/tests/rustdoc-ui/reference-links.stderr b/tests/rustdoc-ui/intra-doc/reference-links.stderr similarity index 100% rename from tests/rustdoc-ui/reference-links.stderr rename to tests/rustdoc-ui/intra-doc/reference-links.stderr diff --git a/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.rs b/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.rs new file mode 100644 index 0000000000000..c920a815fda75 --- /dev/null +++ b/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.rs @@ -0,0 +1,12 @@ +type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>; +//~^ ERROR cycle detected when expanding type alias + +fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { + Box::new(i) +} + +fn main() { + let meh = 42; + let muh = 42; + assert!(bar(&meh) == bar(&muh)); +} diff --git a/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.stderr b/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.stderr new file mode 100644 index 0000000000000..79e1b753112b8 --- /dev/null +++ b/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.stderr @@ -0,0 +1,25 @@ +error[E0391]: cycle detected when expanding type alias `Bar` + --> $DIR/issue-110629-private-type-cycle-dyn.rs:1:38 + | +LL | type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>; + | ^^^^^^^^^^^ + | + = note: ...which immediately requires expanding type alias `Bar` again + = note: type aliases cannot be recursive + = help: consider using a struct, enum, or union instead to break the cycle + = help: see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information +note: cycle used when collecting item types in top-level module + --> $DIR/issue-110629-private-type-cycle-dyn.rs:1:1 + | +LL | / type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>; +LL | | +LL | | +LL | | fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { +... | +LL | | assert!(bar(&meh) == bar(&muh)); +LL | | } + | |_^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/rustdoc-ui/issue-110629-private-type-cycle.rs b/tests/rustdoc-ui/issue-110629-private-type-cycle.rs new file mode 100644 index 0000000000000..2d46ddbfa6e52 --- /dev/null +++ b/tests/rustdoc-ui/issue-110629-private-type-cycle.rs @@ -0,0 +1,15 @@ +// check-pass + +#![feature(type_alias_impl_trait)] + +type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + std::fmt::Debug; + +fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { + i +} + +fn main() { + let meh = 42; + let muh = 42; + assert_eq!(bar(&meh), bar(&muh)); +} diff --git a/tests/rustdoc-ui/auxiliary/empty-fn.rs b/tests/rustdoc-ui/issues/auxiliary/empty-fn.rs similarity index 100% rename from tests/rustdoc-ui/auxiliary/empty-fn.rs rename to tests/rustdoc-ui/issues/auxiliary/empty-fn.rs diff --git a/tests/rustdoc-ui/auxiliary/issue-61592.rs b/tests/rustdoc-ui/issues/auxiliary/issue-61592.rs similarity index 100% rename from tests/rustdoc-ui/auxiliary/issue-61592.rs rename to tests/rustdoc-ui/issues/auxiliary/issue-61592.rs diff --git a/tests/rustdoc-ui/auxiliary/panic-handler.rs b/tests/rustdoc-ui/issues/auxiliary/panic-handler.rs similarity index 100% rename from tests/rustdoc-ui/auxiliary/panic-handler.rs rename to tests/rustdoc-ui/issues/auxiliary/panic-handler.rs diff --git a/tests/rustdoc-ui/issue-101076.rs b/tests/rustdoc-ui/issues/issue-101076.rs similarity index 100% rename from tests/rustdoc-ui/issue-101076.rs rename to tests/rustdoc-ui/issues/issue-101076.rs diff --git a/tests/rustdoc-ui/issue-102986.rs b/tests/rustdoc-ui/issues/issue-102986.rs similarity index 100% rename from tests/rustdoc-ui/issue-102986.rs rename to tests/rustdoc-ui/issues/issue-102986.rs diff --git a/tests/rustdoc-ui/issue-102986.stderr b/tests/rustdoc-ui/issues/issue-102986.stderr similarity index 100% rename from tests/rustdoc-ui/issue-102986.stderr rename to tests/rustdoc-ui/issues/issue-102986.stderr diff --git a/tests/rustdoc-ui/issue-103997.rs b/tests/rustdoc-ui/issues/issue-103997.rs similarity index 100% rename from tests/rustdoc-ui/issue-103997.rs rename to tests/rustdoc-ui/issues/issue-103997.rs diff --git a/tests/rustdoc-ui/issue-103997.stderr b/tests/rustdoc-ui/issues/issue-103997.stderr similarity index 100% rename from tests/rustdoc-ui/issue-103997.stderr rename to tests/rustdoc-ui/issues/issue-103997.stderr diff --git a/tests/rustdoc-ui/issue-105334.rs b/tests/rustdoc-ui/issues/issue-105334.rs similarity index 100% rename from tests/rustdoc-ui/issue-105334.rs rename to tests/rustdoc-ui/issues/issue-105334.rs diff --git a/tests/rustdoc-ui/issue-105334.stderr b/tests/rustdoc-ui/issues/issue-105334.stderr similarity index 100% rename from tests/rustdoc-ui/issue-105334.stderr rename to tests/rustdoc-ui/issues/issue-105334.stderr diff --git a/tests/rustdoc-ui/issue-105737.rs b/tests/rustdoc-ui/issues/issue-105737.rs similarity index 100% rename from tests/rustdoc-ui/issue-105737.rs rename to tests/rustdoc-ui/issues/issue-105737.rs diff --git a/tests/rustdoc-ui/issue-105737.stderr b/tests/rustdoc-ui/issues/issue-105737.stderr similarity index 100% rename from tests/rustdoc-ui/issue-105737.stderr rename to tests/rustdoc-ui/issues/issue-105737.stderr diff --git a/tests/rustdoc-ui/issue-105742.rs b/tests/rustdoc-ui/issues/issue-105742.rs similarity index 100% rename from tests/rustdoc-ui/issue-105742.rs rename to tests/rustdoc-ui/issues/issue-105742.rs diff --git a/tests/rustdoc-ui/issue-105742.stderr b/tests/rustdoc-ui/issues/issue-105742.stderr similarity index 100% rename from tests/rustdoc-ui/issue-105742.stderr rename to tests/rustdoc-ui/issues/issue-105742.stderr diff --git a/tests/rustdoc-ui/issue-106213.rs b/tests/rustdoc-ui/issues/issue-106213.rs similarity index 100% rename from tests/rustdoc-ui/issue-106213.rs rename to tests/rustdoc-ui/issues/issue-106213.rs diff --git a/tests/rustdoc-ui/issue-106213.stderr b/tests/rustdoc-ui/issues/issue-106213.stderr similarity index 100% rename from tests/rustdoc-ui/issue-106213.stderr rename to tests/rustdoc-ui/issues/issue-106213.stderr diff --git a/tests/rustdoc-ui/issue-106226.rs b/tests/rustdoc-ui/issues/issue-106226.rs similarity index 100% rename from tests/rustdoc-ui/issue-106226.rs rename to tests/rustdoc-ui/issues/issue-106226.rs diff --git a/tests/rustdoc-ui/issue-106226.stderr b/tests/rustdoc-ui/issues/issue-106226.stderr similarity index 100% rename from tests/rustdoc-ui/issue-106226.stderr rename to tests/rustdoc-ui/issues/issue-106226.stderr diff --git a/tests/rustdoc-ui/issue-107918.rs b/tests/rustdoc-ui/issues/issue-107918.rs similarity index 100% rename from tests/rustdoc-ui/issue-107918.rs rename to tests/rustdoc-ui/issues/issue-107918.rs diff --git a/tests/rustdoc-ui/issue-109282-import-inline-merge.rs b/tests/rustdoc-ui/issues/issue-109282-import-inline-merge.rs similarity index 100% rename from tests/rustdoc-ui/issue-109282-import-inline-merge.rs rename to tests/rustdoc-ui/issues/issue-109282-import-inline-merge.rs diff --git a/tests/rustdoc-ui/issue-110900.rs b/tests/rustdoc-ui/issues/issue-110900.rs similarity index 100% rename from tests/rustdoc-ui/issue-110900.rs rename to tests/rustdoc-ui/issues/issue-110900.rs diff --git a/tests/rustdoc-ui/issue-58473-2.rs b/tests/rustdoc-ui/issues/issue-58473-2.rs similarity index 100% rename from tests/rustdoc-ui/issue-58473-2.rs rename to tests/rustdoc-ui/issues/issue-58473-2.rs diff --git a/tests/rustdoc-ui/issue-58473.rs b/tests/rustdoc-ui/issues/issue-58473.rs similarity index 100% rename from tests/rustdoc-ui/issue-58473.rs rename to tests/rustdoc-ui/issues/issue-58473.rs diff --git a/tests/rustdoc-ui/issue-61592-2.rs b/tests/rustdoc-ui/issues/issue-61592-2.rs similarity index 100% rename from tests/rustdoc-ui/issue-61592-2.rs rename to tests/rustdoc-ui/issues/issue-61592-2.rs diff --git a/tests/rustdoc-ui/issue-61592-2.stderr b/tests/rustdoc-ui/issues/issue-61592-2.stderr similarity index 100% rename from tests/rustdoc-ui/issue-61592-2.stderr rename to tests/rustdoc-ui/issues/issue-61592-2.stderr diff --git a/tests/rustdoc-ui/issue-61592.rs b/tests/rustdoc-ui/issues/issue-61592.rs similarity index 100% rename from tests/rustdoc-ui/issue-61592.rs rename to tests/rustdoc-ui/issues/issue-61592.rs diff --git a/tests/rustdoc-ui/issue-61592.stderr b/tests/rustdoc-ui/issues/issue-61592.stderr similarity index 100% rename from tests/rustdoc-ui/issue-61592.stderr rename to tests/rustdoc-ui/issues/issue-61592.stderr diff --git a/tests/rustdoc-ui/issue-61732.rs b/tests/rustdoc-ui/issues/issue-61732.rs similarity index 100% rename from tests/rustdoc-ui/issue-61732.rs rename to tests/rustdoc-ui/issues/issue-61732.rs diff --git a/tests/rustdoc-ui/issue-61732.stderr b/tests/rustdoc-ui/issues/issue-61732.stderr similarity index 100% rename from tests/rustdoc-ui/issue-61732.stderr rename to tests/rustdoc-ui/issues/issue-61732.stderr diff --git a/tests/rustdoc-ui/issue-74134.private.stderr b/tests/rustdoc-ui/issues/issue-74134.private.stderr similarity index 100% rename from tests/rustdoc-ui/issue-74134.private.stderr rename to tests/rustdoc-ui/issues/issue-74134.private.stderr diff --git a/tests/rustdoc-ui/issue-74134.public.stderr b/tests/rustdoc-ui/issues/issue-74134.public.stderr similarity index 100% rename from tests/rustdoc-ui/issue-74134.public.stderr rename to tests/rustdoc-ui/issues/issue-74134.public.stderr diff --git a/tests/rustdoc-ui/issue-74134.rs b/tests/rustdoc-ui/issues/issue-74134.rs similarity index 100% rename from tests/rustdoc-ui/issue-74134.rs rename to tests/rustdoc-ui/issues/issue-74134.rs diff --git a/tests/rustdoc-ui/issue-79465.rs b/tests/rustdoc-ui/issues/issue-79465.rs similarity index 100% rename from tests/rustdoc-ui/issue-79465.rs rename to tests/rustdoc-ui/issues/issue-79465.rs diff --git a/tests/rustdoc-ui/issue-79465.stderr b/tests/rustdoc-ui/issues/issue-79465.stderr similarity index 100% rename from tests/rustdoc-ui/issue-79465.stderr rename to tests/rustdoc-ui/issues/issue-79465.stderr diff --git a/tests/rustdoc-ui/issue-79467.rs b/tests/rustdoc-ui/issues/issue-79467.rs similarity index 100% rename from tests/rustdoc-ui/issue-79467.rs rename to tests/rustdoc-ui/issues/issue-79467.rs diff --git a/tests/rustdoc-ui/issue-79467.stderr b/tests/rustdoc-ui/issues/issue-79467.stderr similarity index 100% rename from tests/rustdoc-ui/issue-79467.stderr rename to tests/rustdoc-ui/issues/issue-79467.stderr diff --git a/tests/rustdoc-ui/issue-79494.rs b/tests/rustdoc-ui/issues/issue-79494.rs similarity index 100% rename from tests/rustdoc-ui/issue-79494.rs rename to tests/rustdoc-ui/issues/issue-79494.rs diff --git a/tests/rustdoc-ui/issue-79494.stderr b/tests/rustdoc-ui/issues/issue-79494.stderr similarity index 100% rename from tests/rustdoc-ui/issue-79494.stderr rename to tests/rustdoc-ui/issues/issue-79494.stderr diff --git a/tests/rustdoc-ui/issue-80992.rs b/tests/rustdoc-ui/issues/issue-80992.rs similarity index 78% rename from tests/rustdoc-ui/issue-80992.rs rename to tests/rustdoc-ui/issues/issue-80992.rs index 80ff225b8791f..f5ae16981ca11 100644 --- a/tests/rustdoc-ui/issue-80992.rs +++ b/tests/rustdoc-ui/issues/issue-80992.rs @@ -1,6 +1,6 @@ // check-pass // compile-flags:--test -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/issues" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" pub fn test() -> Result<(), ()> { diff --git a/tests/rustdoc-ui/issue-80992.stdout b/tests/rustdoc-ui/issues/issue-80992.stdout similarity index 100% rename from tests/rustdoc-ui/issue-80992.stdout rename to tests/rustdoc-ui/issues/issue-80992.stdout diff --git a/tests/rustdoc-ui/issue-81662-shortness.rs b/tests/rustdoc-ui/issues/issue-81662-shortness.rs similarity index 81% rename from tests/rustdoc-ui/issue-81662-shortness.rs rename to tests/rustdoc-ui/issues/issue-81662-shortness.rs index 8a90813b31d52..0240d217bee52 100644 --- a/tests/rustdoc-ui/issue-81662-shortness.rs +++ b/tests/rustdoc-ui/issues/issue-81662-shortness.rs @@ -1,5 +1,5 @@ // compile-flags:--test --error-format=short -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/issues" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // failure-status: 101 diff --git a/tests/rustdoc-ui/issue-81662-shortness.stdout b/tests/rustdoc-ui/issues/issue-81662-shortness.stdout similarity index 100% rename from tests/rustdoc-ui/issue-81662-shortness.stdout rename to tests/rustdoc-ui/issues/issue-81662-shortness.stdout diff --git a/tests/rustdoc-ui/issue-83883-describe-lints.rs b/tests/rustdoc-ui/issues/issue-83883-describe-lints.rs similarity index 100% rename from tests/rustdoc-ui/issue-83883-describe-lints.rs rename to tests/rustdoc-ui/issues/issue-83883-describe-lints.rs diff --git a/tests/rustdoc-ui/issue-83883-describe-lints.stdout b/tests/rustdoc-ui/issues/issue-83883-describe-lints.stdout similarity index 100% rename from tests/rustdoc-ui/issue-83883-describe-lints.stdout rename to tests/rustdoc-ui/issues/issue-83883-describe-lints.stdout diff --git a/tests/rustdoc-ui/issue-91134.rs b/tests/rustdoc-ui/issues/issue-91134.rs similarity index 85% rename from tests/rustdoc-ui/issue-91134.rs rename to tests/rustdoc-ui/issues/issue-91134.rs index 42703ee4d7998..85362f186cc7f 100644 --- a/tests/rustdoc-ui/issue-91134.rs +++ b/tests/rustdoc-ui/issues/issue-91134.rs @@ -1,7 +1,7 @@ // compile-flags: --test --crate-name=empty_fn --extern=empty_fn --test-args=--test-threads=1 // aux-build:empty-fn.rs // check-pass -// normalize-stdout-test: "tests/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test: "tests/rustdoc-ui/issues" -> "$$DIR" // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // edition:2021 diff --git a/tests/rustdoc-ui/issue-91134.stdout b/tests/rustdoc-ui/issues/issue-91134.stdout similarity index 100% rename from tests/rustdoc-ui/issue-91134.stdout rename to tests/rustdoc-ui/issues/issue-91134.stdout diff --git a/tests/rustdoc-ui/issue-91713.rs b/tests/rustdoc-ui/issues/issue-91713.rs similarity index 100% rename from tests/rustdoc-ui/issue-91713.rs rename to tests/rustdoc-ui/issues/issue-91713.rs diff --git a/tests/rustdoc-ui/issue-91713.stderr b/tests/rustdoc-ui/issues/issue-91713.stderr similarity index 100% rename from tests/rustdoc-ui/issue-91713.stderr rename to tests/rustdoc-ui/issues/issue-91713.stderr diff --git a/tests/rustdoc-ui/issue-91713.stdout b/tests/rustdoc-ui/issues/issue-91713.stdout similarity index 100% rename from tests/rustdoc-ui/issue-91713.stdout rename to tests/rustdoc-ui/issues/issue-91713.stdout diff --git a/tests/rustdoc-ui/issue-96287.rs b/tests/rustdoc-ui/issues/issue-96287.rs similarity index 100% rename from tests/rustdoc-ui/issue-96287.rs rename to tests/rustdoc-ui/issues/issue-96287.rs diff --git a/tests/rustdoc-ui/issue-96287.stderr b/tests/rustdoc-ui/issues/issue-96287.stderr similarity index 100% rename from tests/rustdoc-ui/issue-96287.stderr rename to tests/rustdoc-ui/issues/issue-96287.stderr diff --git a/tests/rustdoc-ui/issue-98690.rs b/tests/rustdoc-ui/issues/issue-98690.rs similarity index 100% rename from tests/rustdoc-ui/issue-98690.rs rename to tests/rustdoc-ui/issues/issue-98690.rs diff --git a/tests/rustdoc-ui/issue-98690.stderr b/tests/rustdoc-ui/issues/issue-98690.stderr similarity index 100% rename from tests/rustdoc-ui/issue-98690.stderr rename to tests/rustdoc-ui/issues/issue-98690.stderr diff --git a/tests/rustdoc-ui/bare-urls.fixed b/tests/rustdoc-ui/lints/bare-urls.fixed similarity index 100% rename from tests/rustdoc-ui/bare-urls.fixed rename to tests/rustdoc-ui/lints/bare-urls.fixed diff --git a/tests/rustdoc-ui/bare-urls.rs b/tests/rustdoc-ui/lints/bare-urls.rs similarity index 100% rename from tests/rustdoc-ui/bare-urls.rs rename to tests/rustdoc-ui/lints/bare-urls.rs diff --git a/tests/rustdoc-ui/bare-urls.stderr b/tests/rustdoc-ui/lints/bare-urls.stderr similarity index 100% rename from tests/rustdoc-ui/bare-urls.stderr rename to tests/rustdoc-ui/lints/bare-urls.stderr diff --git a/tests/rustdoc-ui/check-attr.rs b/tests/rustdoc-ui/lints/check-attr.rs similarity index 100% rename from tests/rustdoc-ui/check-attr.rs rename to tests/rustdoc-ui/lints/check-attr.rs diff --git a/tests/rustdoc-ui/check-attr.stderr b/tests/rustdoc-ui/lints/check-attr.stderr similarity index 100% rename from tests/rustdoc-ui/check-attr.stderr rename to tests/rustdoc-ui/lints/check-attr.stderr diff --git a/tests/rustdoc-ui/check-fail.rs b/tests/rustdoc-ui/lints/check-fail.rs similarity index 100% rename from tests/rustdoc-ui/check-fail.rs rename to tests/rustdoc-ui/lints/check-fail.rs diff --git a/tests/rustdoc-ui/check-fail.stderr b/tests/rustdoc-ui/lints/check-fail.stderr similarity index 100% rename from tests/rustdoc-ui/check-fail.stderr rename to tests/rustdoc-ui/lints/check-fail.stderr diff --git a/tests/rustdoc-ui/check.rs b/tests/rustdoc-ui/lints/check.rs similarity index 100% rename from tests/rustdoc-ui/check.rs rename to tests/rustdoc-ui/lints/check.rs diff --git a/tests/rustdoc-ui/check.stderr b/tests/rustdoc-ui/lints/check.stderr similarity index 100% rename from tests/rustdoc-ui/check.stderr rename to tests/rustdoc-ui/lints/check.stderr diff --git a/tests/rustdoc-ui/deny-missing-docs-crate.rs b/tests/rustdoc-ui/lints/deny-missing-docs-crate.rs similarity index 100% rename from tests/rustdoc-ui/deny-missing-docs-crate.rs rename to tests/rustdoc-ui/lints/deny-missing-docs-crate.rs diff --git a/tests/rustdoc-ui/deny-missing-docs-crate.stderr b/tests/rustdoc-ui/lints/deny-missing-docs-crate.stderr similarity index 100% rename from tests/rustdoc-ui/deny-missing-docs-crate.stderr rename to tests/rustdoc-ui/lints/deny-missing-docs-crate.stderr diff --git a/tests/rustdoc-ui/deny-missing-docs-macro.rs b/tests/rustdoc-ui/lints/deny-missing-docs-macro.rs similarity index 100% rename from tests/rustdoc-ui/deny-missing-docs-macro.rs rename to tests/rustdoc-ui/lints/deny-missing-docs-macro.rs diff --git a/tests/rustdoc-ui/deny-missing-docs-macro.stderr b/tests/rustdoc-ui/lints/deny-missing-docs-macro.stderr similarity index 100% rename from tests/rustdoc-ui/deny-missing-docs-macro.stderr rename to tests/rustdoc-ui/lints/deny-missing-docs-macro.stderr diff --git a/tests/rustdoc-ui/doc-attr.rs b/tests/rustdoc-ui/lints/doc-attr.rs similarity index 100% rename from tests/rustdoc-ui/doc-attr.rs rename to tests/rustdoc-ui/lints/doc-attr.rs diff --git a/tests/rustdoc-ui/doc-attr.stderr b/tests/rustdoc-ui/lints/doc-attr.stderr similarity index 100% rename from tests/rustdoc-ui/doc-attr.stderr rename to tests/rustdoc-ui/lints/doc-attr.stderr diff --git a/tests/rustdoc-ui/doc-spotlight.fixed b/tests/rustdoc-ui/lints/doc-spotlight.fixed similarity index 100% rename from tests/rustdoc-ui/doc-spotlight.fixed rename to tests/rustdoc-ui/lints/doc-spotlight.fixed diff --git a/tests/rustdoc-ui/doc-spotlight.rs b/tests/rustdoc-ui/lints/doc-spotlight.rs similarity index 100% rename from tests/rustdoc-ui/doc-spotlight.rs rename to tests/rustdoc-ui/lints/doc-spotlight.rs diff --git a/tests/rustdoc-ui/doc-spotlight.stderr b/tests/rustdoc-ui/lints/doc-spotlight.stderr similarity index 100% rename from tests/rustdoc-ui/doc-spotlight.stderr rename to tests/rustdoc-ui/lints/doc-spotlight.stderr diff --git a/tests/rustdoc-ui/doc-without-codeblock.rs b/tests/rustdoc-ui/lints/doc-without-codeblock.rs similarity index 100% rename from tests/rustdoc-ui/doc-without-codeblock.rs rename to tests/rustdoc-ui/lints/doc-without-codeblock.rs diff --git a/tests/rustdoc-ui/doc-without-codeblock.stderr b/tests/rustdoc-ui/lints/doc-without-codeblock.stderr similarity index 100% rename from tests/rustdoc-ui/doc-without-codeblock.stderr rename to tests/rustdoc-ui/lints/doc-without-codeblock.stderr diff --git a/tests/rustdoc-ui/doc_cfg_hide.rs b/tests/rustdoc-ui/lints/doc_cfg_hide.rs similarity index 100% rename from tests/rustdoc-ui/doc_cfg_hide.rs rename to tests/rustdoc-ui/lints/doc_cfg_hide.rs diff --git a/tests/rustdoc-ui/doc_cfg_hide.stderr b/tests/rustdoc-ui/lints/doc_cfg_hide.stderr similarity index 100% rename from tests/rustdoc-ui/doc_cfg_hide.stderr rename to tests/rustdoc-ui/lints/doc_cfg_hide.stderr diff --git a/tests/rustdoc-ui/expect-tool-lint-rfc-2383.rs b/tests/rustdoc-ui/lints/expect-tool-lint-rfc-2383.rs similarity index 100% rename from tests/rustdoc-ui/expect-tool-lint-rfc-2383.rs rename to tests/rustdoc-ui/lints/expect-tool-lint-rfc-2383.rs diff --git a/tests/rustdoc-ui/expect-tool-lint-rfc-2383.stderr b/tests/rustdoc-ui/lints/expect-tool-lint-rfc-2383.stderr similarity index 100% rename from tests/rustdoc-ui/expect-tool-lint-rfc-2383.stderr rename to tests/rustdoc-ui/lints/expect-tool-lint-rfc-2383.stderr diff --git a/tests/rustdoc-ui/feature-gate-rustdoc_missing_doc_code_examples.rs b/tests/rustdoc-ui/lints/feature-gate-rustdoc_missing_doc_code_examples.rs similarity index 100% rename from tests/rustdoc-ui/feature-gate-rustdoc_missing_doc_code_examples.rs rename to tests/rustdoc-ui/lints/feature-gate-rustdoc_missing_doc_code_examples.rs diff --git a/tests/rustdoc-ui/feature-gate-rustdoc_missing_doc_code_examples.stderr b/tests/rustdoc-ui/lints/feature-gate-rustdoc_missing_doc_code_examples.stderr similarity index 100% rename from tests/rustdoc-ui/feature-gate-rustdoc_missing_doc_code_examples.stderr rename to tests/rustdoc-ui/lints/feature-gate-rustdoc_missing_doc_code_examples.stderr diff --git a/tests/rustdoc-ui/invalid-doc-attr.rs b/tests/rustdoc-ui/lints/invalid-doc-attr.rs similarity index 100% rename from tests/rustdoc-ui/invalid-doc-attr.rs rename to tests/rustdoc-ui/lints/invalid-doc-attr.rs diff --git a/tests/rustdoc-ui/invalid-doc-attr.stderr b/tests/rustdoc-ui/lints/invalid-doc-attr.stderr similarity index 100% rename from tests/rustdoc-ui/invalid-doc-attr.stderr rename to tests/rustdoc-ui/lints/invalid-doc-attr.stderr diff --git a/tests/rustdoc-ui/invalid-html-self-closing-tag.rs b/tests/rustdoc-ui/lints/invalid-html-self-closing-tag.rs similarity index 100% rename from tests/rustdoc-ui/invalid-html-self-closing-tag.rs rename to tests/rustdoc-ui/lints/invalid-html-self-closing-tag.rs diff --git a/tests/rustdoc-ui/invalid-html-self-closing-tag.stderr b/tests/rustdoc-ui/lints/invalid-html-self-closing-tag.stderr similarity index 100% rename from tests/rustdoc-ui/invalid-html-self-closing-tag.stderr rename to tests/rustdoc-ui/lints/invalid-html-self-closing-tag.stderr diff --git a/tests/rustdoc-ui/invalid-html-tags.rs b/tests/rustdoc-ui/lints/invalid-html-tags.rs similarity index 100% rename from tests/rustdoc-ui/invalid-html-tags.rs rename to tests/rustdoc-ui/lints/invalid-html-tags.rs diff --git a/tests/rustdoc-ui/invalid-html-tags.stderr b/tests/rustdoc-ui/lints/invalid-html-tags.stderr similarity index 100% rename from tests/rustdoc-ui/invalid-html-tags.stderr rename to tests/rustdoc-ui/lints/invalid-html-tags.stderr diff --git a/tests/rustdoc-ui/lint-group.rs b/tests/rustdoc-ui/lints/lint-group.rs similarity index 100% rename from tests/rustdoc-ui/lint-group.rs rename to tests/rustdoc-ui/lints/lint-group.rs diff --git a/tests/rustdoc-ui/lint-group.stderr b/tests/rustdoc-ui/lints/lint-group.stderr similarity index 100% rename from tests/rustdoc-ui/lint-group.stderr rename to tests/rustdoc-ui/lints/lint-group.stderr diff --git a/tests/rustdoc-ui/lint-missing-doc-code-example.rs b/tests/rustdoc-ui/lints/lint-missing-doc-code-example.rs similarity index 100% rename from tests/rustdoc-ui/lint-missing-doc-code-example.rs rename to tests/rustdoc-ui/lints/lint-missing-doc-code-example.rs diff --git a/tests/rustdoc-ui/lint-missing-doc-code-example.stderr b/tests/rustdoc-ui/lints/lint-missing-doc-code-example.stderr similarity index 100% rename from tests/rustdoc-ui/lint-missing-doc-code-example.stderr rename to tests/rustdoc-ui/lints/lint-missing-doc-code-example.stderr diff --git a/tests/rustdoc-ui/no-crate-level-doc-lint.rs b/tests/rustdoc-ui/lints/no-crate-level-doc-lint.rs similarity index 100% rename from tests/rustdoc-ui/no-crate-level-doc-lint.rs rename to tests/rustdoc-ui/lints/no-crate-level-doc-lint.rs diff --git a/tests/rustdoc-ui/no-crate-level-doc-lint.stderr b/tests/rustdoc-ui/lints/no-crate-level-doc-lint.stderr similarity index 100% rename from tests/rustdoc-ui/no-crate-level-doc-lint.stderr rename to tests/rustdoc-ui/lints/no-crate-level-doc-lint.stderr diff --git a/tests/rustdoc-ui/renamed-lint-still-applies.rs b/tests/rustdoc-ui/lints/renamed-lint-still-applies.rs similarity index 100% rename from tests/rustdoc-ui/renamed-lint-still-applies.rs rename to tests/rustdoc-ui/lints/renamed-lint-still-applies.rs diff --git a/tests/rustdoc-ui/renamed-lint-still-applies.stderr b/tests/rustdoc-ui/lints/renamed-lint-still-applies.stderr similarity index 100% rename from tests/rustdoc-ui/renamed-lint-still-applies.stderr rename to tests/rustdoc-ui/lints/renamed-lint-still-applies.stderr diff --git a/tests/rustdoc-ui/rustdoc-all-only-stable-lints.rs b/tests/rustdoc-ui/lints/rustdoc-all-only-stable-lints.rs similarity index 100% rename from tests/rustdoc-ui/rustdoc-all-only-stable-lints.rs rename to tests/rustdoc-ui/lints/rustdoc-all-only-stable-lints.rs diff --git a/tests/rustdoc-ui/unknown-renamed-lints.rs b/tests/rustdoc-ui/lints/unknown-renamed-lints.rs similarity index 100% rename from tests/rustdoc-ui/unknown-renamed-lints.rs rename to tests/rustdoc-ui/lints/unknown-renamed-lints.rs diff --git a/tests/rustdoc-ui/unknown-renamed-lints.stderr b/tests/rustdoc-ui/lints/unknown-renamed-lints.stderr similarity index 100% rename from tests/rustdoc-ui/unknown-renamed-lints.stderr rename to tests/rustdoc-ui/lints/unknown-renamed-lints.stderr diff --git a/tests/rustdoc-ui/unused-braces-lint.rs b/tests/rustdoc-ui/lints/unused-braces-lint.rs similarity index 100% rename from tests/rustdoc-ui/unused-braces-lint.rs rename to tests/rustdoc-ui/lints/unused-braces-lint.rs diff --git a/tests/rustdoc-ui/unused.rs b/tests/rustdoc-ui/lints/unused.rs similarity index 100% rename from tests/rustdoc-ui/unused.rs rename to tests/rustdoc-ui/lints/unused.rs diff --git a/tests/rustdoc-ui/scrape-examples-fail-if-type-error.rs b/tests/rustdoc-ui/scrape-examples/scrape-examples-fail-if-type-error.rs similarity index 100% rename from tests/rustdoc-ui/scrape-examples-fail-if-type-error.rs rename to tests/rustdoc-ui/scrape-examples/scrape-examples-fail-if-type-error.rs diff --git a/tests/rustdoc-ui/scrape-examples-fail-if-type-error.stderr b/tests/rustdoc-ui/scrape-examples/scrape-examples-fail-if-type-error.stderr similarity index 100% rename from tests/rustdoc-ui/scrape-examples-fail-if-type-error.stderr rename to tests/rustdoc-ui/scrape-examples/scrape-examples-fail-if-type-error.stderr diff --git a/tests/rustdoc-ui/scrape-examples-ice.rs b/tests/rustdoc-ui/scrape-examples/scrape-examples-ice.rs similarity index 100% rename from tests/rustdoc-ui/scrape-examples-ice.rs rename to tests/rustdoc-ui/scrape-examples/scrape-examples-ice.rs diff --git a/tests/rustdoc-ui/scrape-examples-wrong-options-1.rs b/tests/rustdoc-ui/scrape-examples/scrape-examples-wrong-options-1.rs similarity index 100% rename from tests/rustdoc-ui/scrape-examples-wrong-options-1.rs rename to tests/rustdoc-ui/scrape-examples/scrape-examples-wrong-options-1.rs diff --git a/tests/rustdoc-ui/scrape-examples-wrong-options-1.stderr b/tests/rustdoc-ui/scrape-examples/scrape-examples-wrong-options-1.stderr similarity index 100% rename from tests/rustdoc-ui/scrape-examples-wrong-options-1.stderr rename to tests/rustdoc-ui/scrape-examples/scrape-examples-wrong-options-1.stderr diff --git a/tests/rustdoc-ui/scrape-examples-wrong-options-2.rs b/tests/rustdoc-ui/scrape-examples/scrape-examples-wrong-options-2.rs similarity index 100% rename from tests/rustdoc-ui/scrape-examples-wrong-options-2.rs rename to tests/rustdoc-ui/scrape-examples/scrape-examples-wrong-options-2.rs diff --git a/tests/rustdoc-ui/scrape-examples-wrong-options-2.stderr b/tests/rustdoc-ui/scrape-examples/scrape-examples-wrong-options-2.stderr similarity index 100% rename from tests/rustdoc-ui/scrape-examples-wrong-options-2.stderr rename to tests/rustdoc-ui/scrape-examples/scrape-examples-wrong-options-2.stderr diff --git a/tests/rustdoc/inline_cross/auxiliary/repr.rs b/tests/rustdoc/inline_cross/auxiliary/repr.rs index 64a98f1814626..4a6648a643980 100644 --- a/tests/rustdoc/inline_cross/auxiliary/repr.rs +++ b/tests/rustdoc/inline_cross/auxiliary/repr.rs @@ -1,4 +1,22 @@ -#[repr(C)] -pub struct Foo { +#![feature(repr_simd)] + +#[repr(C, align(8))] +pub struct ReprC { field: u8, } +#[repr(simd, packed(2))] +pub struct ReprSimd { + field: u8, +} +#[repr(transparent)] +pub struct ReprTransparent { + field: u8, +} +#[repr(isize)] +pub enum ReprIsize { + Bla, +} +#[repr(u8)] +pub enum ReprU8 { + Bla, +} diff --git a/tests/rustdoc/inline_cross/repr.rs b/tests/rustdoc/inline_cross/repr.rs index 7e1f2799af1cd..9e107cee9e91b 100644 --- a/tests/rustdoc/inline_cross/repr.rs +++ b/tests/rustdoc/inline_cross/repr.rs @@ -7,7 +7,23 @@ extern crate repr; -// @has 'foo/struct.Foo.html' -// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(C)]' +// @has 'foo/struct.ReprC.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(C, align(8))]' #[doc(inline)] -pub use repr::Foo; +pub use repr::ReprC; +// @has 'foo/struct.ReprSimd.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(simd, packed(2))]' +#[doc(inline)] +pub use repr::ReprSimd; +// @has 'foo/struct.ReprTransparent.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +#[doc(inline)] +pub use repr::ReprTransparent; +// @has 'foo/enum.ReprIsize.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(isize)]' +#[doc(inline)] +pub use repr::ReprIsize; +// @has 'foo/enum.ReprU8.html' +// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(u8)]' +#[doc(inline)] +pub use repr::ReprU8; diff --git a/tests/rustdoc/issue-110629-private-type-cycle.rs b/tests/rustdoc/issue-110629-private-type-cycle.rs new file mode 100644 index 0000000000000..a4efbb098f74e --- /dev/null +++ b/tests/rustdoc/issue-110629-private-type-cycle.rs @@ -0,0 +1,19 @@ +// compile-flags: --document-private-items + +#![feature(type_alias_impl_trait)] + +type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + std::fmt::Debug; + +// @has issue_110629_private_type_cycle/type.Bar.html +// @has - '//pre[@class="rust item-decl"]' \ +// "pub(crate) type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + Debug;" + +fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { + i +} + +fn main() { + let meh = 42; + let muh = 42; + assert_eq!(bar(&meh), bar(&muh)); +} diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs index 79cee55177ba0..58ce41d1a8933 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs @@ -2,7 +2,6 @@ #![feature(return_type_notation, async_fn_in_trait)] //~^ WARN the feature `return_type_notation` is incomplete -//~| WARN the feature `async_fn_in_trait` is incomplete trait Trait { async fn method() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr index b23e0f791eae4..95ef7d82fcab8 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr @@ -1,11 +1,11 @@ error: return type notation uses `()` instead of `(..)` for elided arguments - --> $DIR/bad-inputs-and-output.rs:19:24 + --> $DIR/bad-inputs-and-output.rs:18:24 | LL | fn baz<T: Trait<method(..): Send>>() {} | ^^ help: remove the `..` error[E0658]: associated type bounds are unstable - --> $DIR/bad-inputs-and-output.rs:11:17 + --> $DIR/bad-inputs-and-output.rs:10:17 | LL | fn foo<T: Trait<method(i32): Send>>() {} | ^^^^^^^^^^^^^^^^^ @@ -14,7 +14,7 @@ LL | fn foo<T: Trait<method(i32): Send>>() {} = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/bad-inputs-and-output.rs:15:17 + --> $DIR/bad-inputs-and-output.rs:14:17 | LL | fn bar<T: Trait<method() -> (): Send>>() {} | ^^^^^^^^^^^^^^^^^^^^ @@ -31,26 +31,18 @@ LL | #![feature(return_type_notation, async_fn_in_trait)] = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/bad-inputs-and-output.rs:3:34 - | -LL | #![feature(return_type_notation, async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - error: argument types not allowed with return type notation - --> $DIR/bad-inputs-and-output.rs:11:23 + --> $DIR/bad-inputs-and-output.rs:10:23 | LL | fn foo<T: Trait<method(i32): Send>>() {} | ^^^^^ help: remove the input types: `()` error: return type not allowed with return type notation - --> $DIR/bad-inputs-and-output.rs:15:25 + --> $DIR/bad-inputs-and-output.rs:14:25 | LL | fn bar<T: Trait<method() -> (): Send>>() {} | ^^^^^^ help: remove the return type -error: aborting due to 5 previous errors; 2 warnings emitted +error: aborting due to 5 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.rs b/tests/ui/associated-type-bounds/return-type-notation/basic.rs index 0b7530b65d758..edc6a8e4caf0a 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.rs @@ -4,7 +4,6 @@ #![feature(return_type_notation, async_fn_in_trait)] //~^ WARN the feature `return_type_notation` is incomplete -//~| WARN the feature `async_fn_in_trait` is incomplete trait Foo { async fn method() -> Result<(), ()>; diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr index 722c774cb3394..9962f4706b314 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr @@ -7,13 +7,5 @@ LL | #![feature(return_type_notation, async_fn_in_trait)] = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/basic.rs:5:34 - | -LL | #![feature(return_type_notation, async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - -warning: 2 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr index 1645d8c26502a..c2da4f57696f5 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr @@ -7,31 +7,23 @@ LL | #![feature(return_type_notation, async_fn_in_trait)] = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/basic.rs:5:34 - | -LL | #![feature(return_type_notation, async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - error: future cannot be sent between threads safely - --> $DIR/basic.rs:24:13 + --> $DIR/basic.rs:23:13 | LL | is_send(foo::<T>()); | ^^^^^^^^^^ future returned by `foo` is not `Send` | = help: within `impl Future<Output = Result<(), ()>>`, the trait `Send` is not implemented for `impl Future<Output = Result<(), ()>>` note: future is not `Send` as it awaits another future which is not `Send` - --> $DIR/basic.rs:14:5 + --> $DIR/basic.rs:13:5 | LL | T::method().await?; | ^^^^^^^^^^^ await occurs here on type `impl Future<Output = Result<(), ()>>`, which is not `Send` note: required by a bound in `is_send` - --> $DIR/basic.rs:18:20 + --> $DIR/basic.rs:17:20 | LL | fn is_send(_: impl Send) {} | ^^^^ required by this bound in `is_send` -error: aborting due to previous error; 2 warnings emitted +error: aborting due to previous error; 1 warning emitted diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.rs b/tests/ui/associated-type-bounds/return-type-notation/equality.rs index 75f757e90259b..6884305d7b37b 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/equality.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.rs @@ -2,7 +2,6 @@ #![feature(return_type_notation, async_fn_in_trait)] //~^ WARN the feature `return_type_notation` is incomplete -//~| WARN the feature `async_fn_in_trait` is incomplete use std::future::Future; diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.stderr b/tests/ui/associated-type-bounds/return-type-notation/equality.stderr index c5b2e5710d4a7..490bfdc4c3c60 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/equality.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.stderr @@ -7,19 +7,11 @@ LL | #![feature(return_type_notation, async_fn_in_trait)] = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/equality.rs:3:34 - | -LL | #![feature(return_type_notation, async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - error: return type notation is not allowed to use type equality - --> $DIR/equality.rs:13:18 + --> $DIR/equality.rs:12:18 | LL | fn test<T: Trait<method() = Box<dyn Future<Output = ()>>>>() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error; 2 warnings emitted +error: aborting due to previous error; 1 warning emitted diff --git a/tests/ui/associated-type-bounds/return-type-notation/missing.rs b/tests/ui/associated-type-bounds/return-type-notation/missing.rs index 7b98a5cdafdd3..b84b5a717b72d 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/missing.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/missing.rs @@ -2,7 +2,6 @@ #![feature(return_type_notation, async_fn_in_trait)] //~^ WARN the feature `return_type_notation` is incomplete -//~| WARN the feature `async_fn_in_trait` is incomplete trait Trait { async fn method() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/missing.stderr b/tests/ui/associated-type-bounds/return-type-notation/missing.stderr index 34f5bda884d4c..954d9f74767a7 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/missing.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/missing.stderr @@ -7,19 +7,11 @@ LL | #![feature(return_type_notation, async_fn_in_trait)] = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/missing.rs:3:34 - | -LL | #![feature(return_type_notation, async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - error: cannot find associated function `methid` in trait `Trait` - --> $DIR/missing.rs:11:17 + --> $DIR/missing.rs:10:17 | LL | fn bar<T: Trait<methid(): Send>>() {} | ^^^^^^^^^^^^^^ -error: aborting due to previous error; 2 warnings emitted +error: aborting due to previous error; 1 warning emitted diff --git a/tests/ui/async-await/async-await-let-else.drop_tracking.stderr b/tests/ui/async-await/async-await-let-else.drop_tracking.stderr index fb83ca90a3787..dee90262fd443 100644 --- a/tests/ui/async-await/async-await-let-else.drop_tracking.stderr +++ b/tests/ui/async-await/async-await-let-else.drop_tracking.stderr @@ -6,12 +6,12 @@ LL | is_send(foo(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:11:14 + --> $DIR/async-await-let-else.rs:11:15 | LL | let r = Rc::new(()); | - has type `Rc<()>` which is not `Send` LL | bar().await - | ^^^^^^ await occurs here, with `r` maybe used later + | ^^^^^ await occurs here, with `r` maybe used later LL | }; | - `r` is later dropped here note: required by a bound in `is_send` @@ -65,12 +65,12 @@ LL | is_send(foo3(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:33:28 + --> $DIR/async-await-let-else.rs:33:29 | LL | (Rc::new(()), bar().await); - | ----------- ^^^^^^ - `Rc::new(())` is later dropped here - | | | - | | await occurs here, with `Rc::new(())` maybe used later + | ----------- ^^^^^ - `Rc::new(())` is later dropped here + | | | + | | await occurs here, with `Rc::new(())` maybe used later | has type `Rc<()>` which is not `Send` note: required by a bound in `is_send` --> $DIR/async-await-let-else.rs:19:15 @@ -86,12 +86,12 @@ LL | is_send(foo4(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:41:14 + --> $DIR/async-await-let-else.rs:41:15 | LL | let r = Rc::new(()); | - has type `Rc<()>` which is not `Send` LL | bar().await; - | ^^^^^^ await occurs here, with `r` maybe used later + | ^^^^^ await occurs here, with `r` maybe used later ... LL | }; | - `r` is later dropped here diff --git a/tests/ui/async-await/async-await-let-else.drop_tracking_mir.stderr b/tests/ui/async-await/async-await-let-else.drop_tracking_mir.stderr index c284bbfb1cc66..e3fcceaa3921a 100644 --- a/tests/ui/async-await/async-await-let-else.drop_tracking_mir.stderr +++ b/tests/ui/async-await/async-await-let-else.drop_tracking_mir.stderr @@ -6,12 +6,12 @@ LL | is_send(foo(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:11:14 + --> $DIR/async-await-let-else.rs:11:15 | LL | let r = Rc::new(()); | - has type `Rc<()>` which is not `Send` LL | bar().await - | ^^^^^^ await occurs here, with `r` maybe used later + | ^^^^^ await occurs here, with `r` maybe used later note: required by a bound in `is_send` --> $DIR/async-await-let-else.rs:19:15 | @@ -63,10 +63,10 @@ LL | is_send(foo3(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:33:28 + --> $DIR/async-await-let-else.rs:33:29 | LL | (Rc::new(()), bar().await); - | ----------- ^^^^^^ await occurs here, with `Rc::new(())` maybe used later + | ----------- ^^^^^ await occurs here, with `Rc::new(())` maybe used later | | | has type `Rc<()>` which is not `Send` note: required by a bound in `is_send` @@ -83,12 +83,12 @@ LL | is_send(foo4(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:41:14 + --> $DIR/async-await-let-else.rs:41:15 | LL | let r = Rc::new(()); | - has type `Rc<()>` which is not `Send` LL | bar().await; - | ^^^^^^ await occurs here, with `r` maybe used later + | ^^^^^ await occurs here, with `r` maybe used later note: required by a bound in `is_send` --> $DIR/async-await-let-else.rs:19:15 | diff --git a/tests/ui/async-await/async-await-let-else.no_drop_tracking.stderr b/tests/ui/async-await/async-await-let-else.no_drop_tracking.stderr index d3c5e80a30df4..ece4e51ecff10 100644 --- a/tests/ui/async-await/async-await-let-else.no_drop_tracking.stderr +++ b/tests/ui/async-await/async-await-let-else.no_drop_tracking.stderr @@ -6,12 +6,12 @@ LL | is_send(foo(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:11:14 + --> $DIR/async-await-let-else.rs:11:15 | LL | let r = Rc::new(()); | - has type `Rc<()>` which is not `Send` LL | bar().await - | ^^^^^^ await occurs here, with `r` maybe used later + | ^^^^^ await occurs here, with `r` maybe used later LL | }; | - `r` is later dropped here note: required by a bound in `is_send` @@ -28,10 +28,10 @@ LL | is_send(foo2(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:23:26 + --> $DIR/async-await-let-else.rs:23:27 | LL | bar2(Rc::new(())).await - | ----------- ^^^^^^ await occurs here, with `Rc::new(())` maybe used later + | ----------- ^^^^^ await occurs here, with `Rc::new(())` maybe used later | | | has type `Rc<()>` which is not `Send` LL | }; @@ -50,12 +50,12 @@ LL | is_send(foo3(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:33:28 + --> $DIR/async-await-let-else.rs:33:29 | LL | (Rc::new(()), bar().await); - | ----------- ^^^^^^ - `Rc::new(())` is later dropped here - | | | - | | await occurs here, with `Rc::new(())` maybe used later + | ----------- ^^^^^ - `Rc::new(())` is later dropped here + | | | + | | await occurs here, with `Rc::new(())` maybe used later | has type `Rc<()>` which is not `Send` note: required by a bound in `is_send` --> $DIR/async-await-let-else.rs:19:15 @@ -71,12 +71,12 @@ LL | is_send(foo4(Some(true))); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-await-let-else.rs:41:14 + --> $DIR/async-await-let-else.rs:41:15 | LL | let r = Rc::new(()); | - has type `Rc<()>` which is not `Send` LL | bar().await; - | ^^^^^^ await occurs here, with `r` maybe used later + | ^^^^^ await occurs here, with `r` maybe used later ... LL | }; | - `r` is later dropped here diff --git a/tests/ui/async-await/async-error-span.drop_tracking.stderr b/tests/ui/async-await/async-error-span.drop_tracking.stderr index c6257cb324d9a..99a674a2684c4 100644 --- a/tests/ui/async-await/async-error-span.drop_tracking.stderr +++ b/tests/ui/async-await/async-error-span.drop_tracking.stderr @@ -14,10 +14,10 @@ LL | let a; | ^ cannot infer type | note: the type is part of the `async fn` body because of this `await` - --> $DIR/async-error-span.rs:19:17 + --> $DIR/async-error-span.rs:19:18 | LL | get_future().await; - | ^^^^^^ + | ^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/async-error-span.no_drop_tracking.stderr b/tests/ui/async-await/async-error-span.no_drop_tracking.stderr index c6257cb324d9a..99a674a2684c4 100644 --- a/tests/ui/async-await/async-error-span.no_drop_tracking.stderr +++ b/tests/ui/async-await/async-error-span.no_drop_tracking.stderr @@ -14,10 +14,10 @@ LL | let a; | ^ cannot infer type | note: the type is part of the `async fn` body because of this `await` - --> $DIR/async-error-span.rs:19:17 + --> $DIR/async-error-span.rs:19:18 | LL | get_future().await; - | ^^^^^^ + | ^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/async-fn-nonsend.drop_tracking.stderr b/tests/ui/async-await/async-fn-nonsend.drop_tracking.stderr index 0f0dc335e7f27..0515edaeda342 100644 --- a/tests/ui/async-await/async-fn-nonsend.drop_tracking.stderr +++ b/tests/ui/async-await/async-fn-nonsend.drop_tracking.stderr @@ -6,12 +6,12 @@ LL | assert_send(non_send_temporary_in_match()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:36:25 + --> $DIR/async-fn-nonsend.rs:36:26 | LL | match Some(non_send()) { | ---------------- has type `Option<impl Debug>` which is not `Send` LL | Some(_) => fut().await, - | ^^^^^^ await occurs here, with `Some(non_send())` maybe used later + | ^^^^^ await occurs here, with `Some(non_send())` maybe used later ... LL | } | - `Some(non_send())` is later dropped here @@ -29,13 +29,13 @@ LL | assert_send(non_sync_with_method_call()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `dyn std::fmt::Write` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:49:14 + --> $DIR/async-fn-nonsend.rs:49:15 | LL | let f: &mut std::fmt::Formatter = &mut get_formatter(); | --------------- has type `Formatter<'_>` which is not `Send` ... LL | fut().await; - | ^^^^^^ await occurs here, with `get_formatter()` maybe used later + | ^^^^^ await occurs here, with `get_formatter()` maybe used later LL | } LL | } | - `get_formatter()` is later dropped here diff --git a/tests/ui/async-await/async-fn-nonsend.drop_tracking_mir.stderr b/tests/ui/async-await/async-fn-nonsend.drop_tracking_mir.stderr index 57a0128014554..219945e0971b9 100644 --- a/tests/ui/async-await/async-fn-nonsend.drop_tracking_mir.stderr +++ b/tests/ui/async-await/async-fn-nonsend.drop_tracking_mir.stderr @@ -6,12 +6,12 @@ LL | assert_send(non_send_temporary_in_match()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:36:25 + --> $DIR/async-fn-nonsend.rs:36:26 | LL | match Some(non_send()) { | ---------------- has type `Option<impl Debug>` which is not `Send` LL | Some(_) => fut().await, - | ^^^^^^ await occurs here, with `Some(non_send())` maybe used later + | ^^^^^ await occurs here, with `Some(non_send())` maybe used later note: required by a bound in `assert_send` --> $DIR/async-fn-nonsend.rs:67:24 | @@ -26,13 +26,13 @@ LL | assert_send(non_sync_with_method_call()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `dyn std::fmt::Write` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:49:14 + --> $DIR/async-fn-nonsend.rs:49:15 | LL | let f: &mut std::fmt::Formatter = &mut get_formatter(); | --------------- has type `Formatter<'_>` which is not `Send` ... LL | fut().await; - | ^^^^^^ await occurs here, with `get_formatter()` maybe used later + | ^^^^^ await occurs here, with `get_formatter()` maybe used later note: required by a bound in `assert_send` --> $DIR/async-fn-nonsend.rs:67:24 | diff --git a/tests/ui/async-await/async-fn-nonsend.no_drop_tracking.stderr b/tests/ui/async-await/async-fn-nonsend.no_drop_tracking.stderr index 5cec21d890ef1..b29d2e192f4f5 100644 --- a/tests/ui/async-await/async-fn-nonsend.no_drop_tracking.stderr +++ b/tests/ui/async-await/async-fn-nonsend.no_drop_tracking.stderr @@ -6,13 +6,13 @@ LL | assert_send(local_dropped_before_await()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:27:10 + --> $DIR/async-fn-nonsend.rs:27:11 | LL | let x = non_send(); | - has type `impl Debug` which is not `Send` LL | drop(x); LL | fut().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later LL | } | - `x` is later dropped here note: required by a bound in `assert_send` @@ -29,12 +29,12 @@ LL | assert_send(non_send_temporary_in_match()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:36:25 + --> $DIR/async-fn-nonsend.rs:36:26 | LL | match Some(non_send()) { | ---------- has type `impl Debug` which is not `Send` LL | Some(_) => fut().await, - | ^^^^^^ await occurs here, with `non_send()` maybe used later + | ^^^^^ await occurs here, with `non_send()` maybe used later ... LL | } | - `non_send()` is later dropped here @@ -52,13 +52,13 @@ LL | assert_send(non_sync_with_method_call()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `dyn std::fmt::Write` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:49:14 + --> $DIR/async-fn-nonsend.rs:49:15 | LL | let f: &mut std::fmt::Formatter = &mut get_formatter(); | --------------- has type `Formatter<'_>` which is not `Send` ... LL | fut().await; - | ^^^^^^ await occurs here, with `get_formatter()` maybe used later + | ^^^^^ await occurs here, with `get_formatter()` maybe used later LL | } LL | } | - `get_formatter()` is later dropped here @@ -76,13 +76,13 @@ LL | assert_send(non_sync_with_method_call_panic()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `dyn std::fmt::Write` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:56:14 + --> $DIR/async-fn-nonsend.rs:56:15 | LL | let f: &mut std::fmt::Formatter = panic!(); | - has type `&mut Formatter<'_>` which is not `Send` LL | if non_sync().fmt(f).unwrap() == () { LL | fut().await; - | ^^^^^^ await occurs here, with `f` maybe used later + | ^^^^^ await occurs here, with `f` maybe used later LL | } LL | } | - `f` is later dropped here @@ -100,13 +100,13 @@ LL | assert_send(non_sync_with_method_call_infinite_loop()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `dyn std::fmt::Write` note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:63:14 + --> $DIR/async-fn-nonsend.rs:63:15 | LL | let f: &mut std::fmt::Formatter = loop {}; | - has type `&mut Formatter<'_>` which is not `Send` LL | if non_sync().fmt(f).unwrap() == () { LL | fut().await; - | ^^^^^^ await occurs here, with `f` maybe used later + | ^^^^^ await occurs here, with `f` maybe used later LL | } LL | } | - `f` is later dropped here diff --git a/tests/ui/async-await/async-fn-nonsend.stderr b/tests/ui/async-await/async-fn-nonsend.stderr deleted file mode 100644 index 0f0dc335e7f27..0000000000000 --- a/tests/ui/async-await/async-fn-nonsend.stderr +++ /dev/null @@ -1,49 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/async-fn-nonsend.rs:72:17 - | -LL | assert_send(non_send_temporary_in_match()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `non_send_temporary_in_match` is not `Send` - | - = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>` -note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:36:25 - | -LL | match Some(non_send()) { - | ---------------- has type `Option<impl Debug>` which is not `Send` -LL | Some(_) => fut().await, - | ^^^^^^ await occurs here, with `Some(non_send())` maybe used later -... -LL | } - | - `Some(non_send())` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/async-fn-nonsend.rs:67:24 - | -LL | fn assert_send(_: impl Send) {} - | ^^^^ required by this bound in `assert_send` - -error: future cannot be sent between threads safely - --> $DIR/async-fn-nonsend.rs:74:17 - | -LL | assert_send(non_sync_with_method_call()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `non_sync_with_method_call` is not `Send` - | - = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `dyn std::fmt::Write` -note: future is not `Send` as this value is used across an await - --> $DIR/async-fn-nonsend.rs:49:14 - | -LL | let f: &mut std::fmt::Formatter = &mut get_formatter(); - | --------------- has type `Formatter<'_>` which is not `Send` -... -LL | fut().await; - | ^^^^^^ await occurs here, with `get_formatter()` maybe used later -LL | } -LL | } - | - `get_formatter()` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/async-fn-nonsend.rs:67:24 - | -LL | fn assert_send(_: impl Send) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/async-await/async-is-unwindsafe.stderr b/tests/ui/async-await/async-is-unwindsafe.stderr index d6404b30e74f1..5d29325c82730 100644 --- a/tests/ui/async-await/async-is-unwindsafe.stderr +++ b/tests/ui/async-await/async-is-unwindsafe.stderr @@ -17,13 +17,13 @@ LL | | }); = help: within `[async block@$DIR/async-is-unwindsafe.rs:12:19: 29:6]`, the trait `UnwindSafe` is not implemented for `&mut Context<'_>` = note: `UnwindSafe` is implemented for `&std::task::Context<'_>`, but not for `&mut std::task::Context<'_>` note: future does not implement `UnwindSafe` as this value is used across an await - --> $DIR/async-is-unwindsafe.rs:25:17 + --> $DIR/async-is-unwindsafe.rs:25:18 | LL | let cx_ref = &mut cx; | ------ has type `&mut Context<'_>` which does not implement `UnwindSafe` LL | LL | async {}.await; // this needs an inner await point - | ^^^^^^ await occurs here, with `cx_ref` maybe used later + | ^^^^^ await occurs here, with `cx_ref` maybe used later ... LL | }); | - `cx_ref` is later dropped here diff --git a/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr b/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr index b30f2883732b4..7b03e56662a74 100644 --- a/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr +++ b/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr @@ -143,7 +143,7 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks LL | fn foo9() -> Result<(), ()> { | ---- this is not `async` LL | let _ = await bar(); - | ^^^^^^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks --> $DIR/incorrect-syntax-suggestions.rs:57:13 @@ -151,7 +151,7 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks LL | fn foo10() -> Result<(), ()> { | ----- this is not `async` LL | let _ = await? bar(); - | ^^^^^^^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks --> $DIR/incorrect-syntax-suggestions.rs:66:14 @@ -159,71 +159,71 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks LL | fn foo12() -> Result<(), ()> { | ----- this is not `async` LL | let _ = (await bar())?; - | ^^^^^^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:71:18 + --> $DIR/incorrect-syntax-suggestions.rs:71:19 | LL | fn foo13() -> Result<(), ()> { | ----- this is not `async` LL | let _ = bar().await(); - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:76:18 + --> $DIR/incorrect-syntax-suggestions.rs:76:19 | LL | fn foo14() -> Result<(), ()> { | ----- this is not `async` LL | let _ = bar().await()?; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:81:18 + --> $DIR/incorrect-syntax-suggestions.rs:81:19 | LL | fn foo15() -> Result<(), ()> { | ----- this is not `async` LL | let _ = bar().await; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:85:18 + --> $DIR/incorrect-syntax-suggestions.rs:85:19 | LL | fn foo16() -> Result<(), ()> { | ----- this is not `async` LL | let _ = bar().await?; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:90:22 + --> $DIR/incorrect-syntax-suggestions.rs:90:23 | LL | fn foo() -> Result<(), ()> { | --- this is not `async` LL | let _ = bar().await?; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:97:22 + --> $DIR/incorrect-syntax-suggestions.rs:97:23 | LL | let foo = || { | -- this is not `async` LL | let _ = bar().await?; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:113:29 + --> $DIR/incorrect-syntax-suggestions.rs:113:17 | LL | fn foo() -> Result<(), ()> { | --- this is not `async` LL | let _ = await!(bar())?; - | ^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/incorrect-syntax-suggestions.rs:121:29 + --> $DIR/incorrect-syntax-suggestions.rs:121:17 | LL | let foo = || { | -- this is not `async` LL | let _ = await!(bar())?; - | ^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error: aborting due to 33 previous errors diff --git a/tests/ui/async-await/clone-suggestion.fixed b/tests/ui/async-await/clone-suggestion.fixed new file mode 100644 index 0000000000000..3514cd63df198 --- /dev/null +++ b/tests/ui/async-await/clone-suggestion.fixed @@ -0,0 +1,28 @@ +// edition: 2021 +// run-rustfix + +#![allow(unused)] + +use std::future::Future; +use std::pin::Pin; +use std::task::{Context, Poll}; + +#[derive(Clone)] +struct SharedFuture; + +impl Future for SharedFuture { + type Output = (); + + fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<<Self as Future>::Output> { + todo!() + } +} + +async fn foo() { + let f = SharedFuture; + f.clone().await; + f.await; + //~^ ERROR use of moved value +} + +fn main() {} diff --git a/tests/ui/async-await/clone-suggestion.rs b/tests/ui/async-await/clone-suggestion.rs new file mode 100644 index 0000000000000..5a4f70cbf4437 --- /dev/null +++ b/tests/ui/async-await/clone-suggestion.rs @@ -0,0 +1,28 @@ +// edition: 2021 +// run-rustfix + +#![allow(unused)] + +use std::future::Future; +use std::pin::Pin; +use std::task::{Context, Poll}; + +#[derive(Clone)] +struct SharedFuture; + +impl Future for SharedFuture { + type Output = (); + + fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<<Self as Future>::Output> { + todo!() + } +} + +async fn foo() { + let f = SharedFuture; + f.await; + f.await; + //~^ ERROR use of moved value +} + +fn main() {} diff --git a/tests/ui/async-await/clone-suggestion.stderr b/tests/ui/async-await/clone-suggestion.stderr new file mode 100644 index 0000000000000..c02206f6f9bf0 --- /dev/null +++ b/tests/ui/async-await/clone-suggestion.stderr @@ -0,0 +1,20 @@ +error[E0382]: use of moved value: `f` + --> $DIR/clone-suggestion.rs:24:5 + | +LL | let f = SharedFuture; + | - move occurs because `f` has type `SharedFuture`, which does not implement the `Copy` trait +LL | f.await; + | ----- `f` moved due to this await +LL | f.await; + | ^ value used here after move + | +note: `into_future` takes ownership of the receiver `self`, which moves `f` + --> $SRC_DIR/core/src/future/into_future.rs:LL:COL +help: you can `clone` the value and consume it, but this might not be your desired behavior + | +LL | f.clone().await; + | ++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/async-await/drop-track-bad-field-in-fru.stderr b/tests/ui/async-await/drop-track-bad-field-in-fru.stderr index 819b64ad77f5d..07ab8b3c90353 100644 --- a/tests/ui/async-await/drop-track-bad-field-in-fru.stderr +++ b/tests/ui/async-await/drop-track-bad-field-in-fru.stderr @@ -5,12 +5,12 @@ LL | None { value: (), ..Default::default() }.await; | ^^^^^ `Option<_>::None` does not have this field error[E0277]: `Option<_>` is not a future - --> $DIR/drop-track-bad-field-in-fru.rs:7:45 + --> $DIR/drop-track-bad-field-in-fru.rs:7:46 | LL | None { value: (), ..Default::default() }.await; - | ^^^^^^ - | | - | `Option<_>` is not a future + | -^^^^^ + | || + | |`Option<_>` is not a future | help: remove the `.await` | = help: the trait `Future` is not implemented for `Option<_>` diff --git a/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking.stderr b/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking.stderr index e2bba812d05b1..80402d8424de0 100644 --- a/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking.stderr +++ b/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking.stderr @@ -6,13 +6,13 @@ LL | assert_send(agent.handle()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<String>` note: future is not `Send` as this value is used across an await - --> $DIR/drop-track-field-assign-nonsend.rs:23:38 + --> $DIR/drop-track-field-assign-nonsend.rs:23:39 | LL | let mut info = self.info_result.clone(); | -------- has type `InfoResult` which is not `Send` ... LL | let _ = send_element(element).await; - | ^^^^^^ await occurs here, with `mut info` maybe used later + | ^^^^^ await occurs here, with `mut info` maybe used later LL | } | - `mut info` is later dropped here note: required by a bound in `assert_send` diff --git a/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr b/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr index b89d868040750..d9141cf4e3642 100644 --- a/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr +++ b/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr @@ -6,13 +6,13 @@ LL | assert_send(agent.handle()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<String>` note: future is not `Send` as this value is used across an await - --> $DIR/drop-track-field-assign-nonsend.rs:23:38 + --> $DIR/drop-track-field-assign-nonsend.rs:23:39 | LL | let mut info = self.info_result.clone(); | -------- has type `InfoResult` which is not `Send` ... LL | let _ = send_element(element).await; - | ^^^^^^ await occurs here, with `mut info` maybe used later + | ^^^^^ await occurs here, with `mut info` maybe used later note: required by a bound in `assert_send` --> $DIR/drop-track-field-assign-nonsend.rs:40:19 | diff --git a/tests/ui/async-await/drop-track-field-assign-nonsend.no_drop_tracking.stderr b/tests/ui/async-await/drop-track-field-assign-nonsend.no_drop_tracking.stderr index e2bba812d05b1..80402d8424de0 100644 --- a/tests/ui/async-await/drop-track-field-assign-nonsend.no_drop_tracking.stderr +++ b/tests/ui/async-await/drop-track-field-assign-nonsend.no_drop_tracking.stderr @@ -6,13 +6,13 @@ LL | assert_send(agent.handle()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<String>` note: future is not `Send` as this value is used across an await - --> $DIR/drop-track-field-assign-nonsend.rs:23:38 + --> $DIR/drop-track-field-assign-nonsend.rs:23:39 | LL | let mut info = self.info_result.clone(); | -------- has type `InfoResult` which is not `Send` ... LL | let _ = send_element(element).await; - | ^^^^^^ await occurs here, with `mut info` maybe used later + | ^^^^^ await occurs here, with `mut info` maybe used later LL | } | - `mut info` is later dropped here note: required by a bound in `assert_send` diff --git a/tests/ui/async-await/field-assign-nonsend.drop_tracking.stderr b/tests/ui/async-await/field-assign-nonsend.drop_tracking.stderr index ac461a671a82a..e2e64c9ae0c4f 100644 --- a/tests/ui/async-await/field-assign-nonsend.drop_tracking.stderr +++ b/tests/ui/async-await/field-assign-nonsend.drop_tracking.stderr @@ -6,13 +6,13 @@ LL | assert_send(agent.handle()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<String>` note: future is not `Send` as this value is used across an await - --> $DIR/field-assign-nonsend.rs:23:38 + --> $DIR/field-assign-nonsend.rs:23:39 | LL | let mut info = self.info_result.clone(); | -------- has type `InfoResult` which is not `Send` ... LL | let _ = send_element(element).await; - | ^^^^^^ await occurs here, with `mut info` maybe used later + | ^^^^^ await occurs here, with `mut info` maybe used later LL | } | - `mut info` is later dropped here note: required by a bound in `assert_send` diff --git a/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr b/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr index 8c9d14d624cd9..d1df8e91afa2c 100644 --- a/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr +++ b/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr @@ -6,13 +6,13 @@ LL | assert_send(agent.handle()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<String>` note: future is not `Send` as this value is used across an await - --> $DIR/field-assign-nonsend.rs:23:38 + --> $DIR/field-assign-nonsend.rs:23:39 | LL | let mut info = self.info_result.clone(); | -------- has type `InfoResult` which is not `Send` ... LL | let _ = send_element(element).await; - | ^^^^^^ await occurs here, with `mut info` maybe used later + | ^^^^^ await occurs here, with `mut info` maybe used later note: required by a bound in `assert_send` --> $DIR/field-assign-nonsend.rs:40:19 | diff --git a/tests/ui/async-await/field-assign-nonsend.no_drop_tracking.stderr b/tests/ui/async-await/field-assign-nonsend.no_drop_tracking.stderr index ac461a671a82a..e2e64c9ae0c4f 100644 --- a/tests/ui/async-await/field-assign-nonsend.no_drop_tracking.stderr +++ b/tests/ui/async-await/field-assign-nonsend.no_drop_tracking.stderr @@ -6,13 +6,13 @@ LL | assert_send(agent.handle()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<String>` note: future is not `Send` as this value is used across an await - --> $DIR/field-assign-nonsend.rs:23:38 + --> $DIR/field-assign-nonsend.rs:23:39 | LL | let mut info = self.info_result.clone(); | -------- has type `InfoResult` which is not `Send` ... LL | let _ = send_element(element).await; - | ^^^^^^ await occurs here, with `mut info` maybe used later + | ^^^^^ await occurs here, with `mut info` maybe used later LL | } | - `mut info` is later dropped here note: required by a bound in `assert_send` diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.current.stderr b/tests/ui/async-await/in-trait/async-default-fn-overridden.current.stderr deleted file mode 100644 index 2142ee232ca5c..0000000000000 --- a/tests/ui/async-await/in-trait/async-default-fn-overridden.current.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/async-default-fn-overridden.rs:6:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.next.stderr b/tests/ui/async-await/in-trait/async-default-fn-overridden.next.stderr deleted file mode 100644 index 2142ee232ca5c..0000000000000 --- a/tests/ui/async-await/in-trait/async-default-fn-overridden.next.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/async-default-fn-overridden.rs:6:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs index dd1af93d706c4..99c3ba6a3c20e 100644 --- a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs +++ b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs @@ -4,7 +4,6 @@ // revisions: current next #![feature(async_fn_in_trait)] -//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use use std::future::Future; diff --git a/tests/ui/async-await/in-trait/bad-signatures.current.stderr b/tests/ui/async-await/in-trait/bad-signatures.current.stderr index 5a05b080c3e57..ae590fb057f3b 100644 --- a/tests/ui/async-await/in-trait/bad-signatures.current.stderr +++ b/tests/ui/async-await/in-trait/bad-signatures.current.stderr @@ -1,11 +1,11 @@ error: expected identifier, found keyword `self` - --> $DIR/bad-signatures.rs:9:23 + --> $DIR/bad-signatures.rs:8:23 | LL | async fn bar(&abc self); | ^^^^ expected identifier, found keyword error: expected one of `:`, `@`, or `|`, found keyword `self` - --> $DIR/bad-signatures.rs:9:23 + --> $DIR/bad-signatures.rs:8:23 | LL | async fn bar(&abc self); | -----^^^^ @@ -13,14 +13,5 @@ LL | async fn bar(&abc self); | | expected one of `:`, `@`, or `|` | help: declare the type after the parameter binding: `<identifier>: <type>` -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/bad-signatures.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/in-trait/bad-signatures.next.stderr b/tests/ui/async-await/in-trait/bad-signatures.next.stderr index 5a05b080c3e57..ae590fb057f3b 100644 --- a/tests/ui/async-await/in-trait/bad-signatures.next.stderr +++ b/tests/ui/async-await/in-trait/bad-signatures.next.stderr @@ -1,11 +1,11 @@ error: expected identifier, found keyword `self` - --> $DIR/bad-signatures.rs:9:23 + --> $DIR/bad-signatures.rs:8:23 | LL | async fn bar(&abc self); | ^^^^ expected identifier, found keyword error: expected one of `:`, `@`, or `|`, found keyword `self` - --> $DIR/bad-signatures.rs:9:23 + --> $DIR/bad-signatures.rs:8:23 | LL | async fn bar(&abc self); | -----^^^^ @@ -13,14 +13,5 @@ LL | async fn bar(&abc self); | | expected one of `:`, `@`, or `|` | help: declare the type after the parameter binding: `<identifier>: <type>` -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/bad-signatures.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/in-trait/bad-signatures.rs b/tests/ui/async-await/in-trait/bad-signatures.rs index e0093be8cb33f..4baddd8ccb835 100644 --- a/tests/ui/async-await/in-trait/bad-signatures.rs +++ b/tests/ui/async-await/in-trait/bad-signatures.rs @@ -3,7 +3,6 @@ // revisions: current next #![feature(async_fn_in_trait)] -//~^ WARN the feature `async_fn_in_trait` is incomplete trait MyTrait { async fn bar(&abc self); diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.current.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.current.stderr index 1e67cdca248d4..eec5ab065397c 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.current.stderr +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.current.stderr @@ -1,12 +1,3 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/dont-project-to-specializable-projection.rs:6:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error: async associated function in trait cannot be specialized --> $DIR/dont-project-to-specializable-projection.rs:16:5 | @@ -15,5 +6,5 @@ LL | default async fn foo(_: T) -> &'static str { | = note: specialization behaves in inconsistent and surprising ways with `#![feature(async_fn_in_trait)]`, and for now is disallowed -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.next.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.next.stderr index fa89c6b77e0b9..25a7f3bb56a50 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.next.stderr +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.next.stderr @@ -1,12 +1,3 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/dont-project-to-specializable-projection.rs:6:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0053]: method `foo` has an incompatible type for trait --> $DIR/dont-project-to-specializable-projection.rs:16:35 | @@ -29,6 +20,6 @@ LL | default async fn foo(_: T) -> &'static str { | = note: specialization behaves in inconsistent and surprising ways with `#![feature(async_fn_in_trait)]`, and for now is disallowed -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/async-await/in-trait/lifetime-mismatch.current.stderr b/tests/ui/async-await/in-trait/lifetime-mismatch.current.stderr index 0e9477544a4a6..69e7c65ee3e70 100644 --- a/tests/ui/async-await/in-trait/lifetime-mismatch.current.stderr +++ b/tests/ui/async-await/in-trait/lifetime-mismatch.current.stderr @@ -1,14 +1,5 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/lifetime-mismatch.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration - --> $DIR/lifetime-mismatch.rs:14:17 + --> $DIR/lifetime-mismatch.rs:13:17 | LL | async fn foo<'a>(&self); | ---- lifetimes in impl do not match this method in trait @@ -16,6 +7,6 @@ LL | async fn foo<'a>(&self); LL | async fn foo(&self) {} | ^ lifetimes do not match method in trait -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error For more information about this error, try `rustc --explain E0195`. diff --git a/tests/ui/async-await/in-trait/lifetime-mismatch.next.stderr b/tests/ui/async-await/in-trait/lifetime-mismatch.next.stderr index 0e9477544a4a6..69e7c65ee3e70 100644 --- a/tests/ui/async-await/in-trait/lifetime-mismatch.next.stderr +++ b/tests/ui/async-await/in-trait/lifetime-mismatch.next.stderr @@ -1,14 +1,5 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/lifetime-mismatch.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration - --> $DIR/lifetime-mismatch.rs:14:17 + --> $DIR/lifetime-mismatch.rs:13:17 | LL | async fn foo<'a>(&self); | ---- lifetimes in impl do not match this method in trait @@ -16,6 +7,6 @@ LL | async fn foo<'a>(&self); LL | async fn foo(&self) {} | ^ lifetimes do not match method in trait -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error For more information about this error, try `rustc --explain E0195`. diff --git a/tests/ui/async-await/in-trait/lifetime-mismatch.rs b/tests/ui/async-await/in-trait/lifetime-mismatch.rs index 5ff5a01a1ee03..46183f72bce68 100644 --- a/tests/ui/async-await/in-trait/lifetime-mismatch.rs +++ b/tests/ui/async-await/in-trait/lifetime-mismatch.rs @@ -3,7 +3,6 @@ // revisions: current next #![feature(async_fn_in_trait)] -//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes trait MyTrait { async fn foo<'a>(&self); diff --git a/tests/ui/async-await/in-trait/missing-send-bound.current.stderr b/tests/ui/async-await/in-trait/missing-send-bound.current.stderr index 319ed582e2719..9aa37f7437e4e 100644 --- a/tests/ui/async-await/in-trait/missing-send-bound.current.stderr +++ b/tests/ui/async-await/in-trait/missing-send-bound.current.stderr @@ -1,29 +1,20 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/missing-send-bound.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error: future cannot be sent between threads safely - --> $DIR/missing-send-bound.rs:17:20 + --> $DIR/missing-send-bound.rs:16:20 | LL | assert_is_send(test::<T>()); | ^^^^^^^^^^^ future returned by `test` is not `Send` | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>` note: future is not `Send` as it awaits another future which is not `Send` - --> $DIR/missing-send-bound.rs:13:5 + --> $DIR/missing-send-bound.rs:12:5 | LL | T::bar().await; | ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send` note: required by a bound in `assert_is_send` - --> $DIR/missing-send-bound.rs:21:27 + --> $DIR/missing-send-bound.rs:20:27 | LL | fn assert_is_send(_: impl Send) {} | ^^^^ required by this bound in `assert_is_send` -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error diff --git a/tests/ui/async-await/in-trait/missing-send-bound.next.stderr b/tests/ui/async-await/in-trait/missing-send-bound.next.stderr index 319ed582e2719..9aa37f7437e4e 100644 --- a/tests/ui/async-await/in-trait/missing-send-bound.next.stderr +++ b/tests/ui/async-await/in-trait/missing-send-bound.next.stderr @@ -1,29 +1,20 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/missing-send-bound.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error: future cannot be sent between threads safely - --> $DIR/missing-send-bound.rs:17:20 + --> $DIR/missing-send-bound.rs:16:20 | LL | assert_is_send(test::<T>()); | ^^^^^^^^^^^ future returned by `test` is not `Send` | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>` note: future is not `Send` as it awaits another future which is not `Send` - --> $DIR/missing-send-bound.rs:13:5 + --> $DIR/missing-send-bound.rs:12:5 | LL | T::bar().await; | ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send` note: required by a bound in `assert_is_send` - --> $DIR/missing-send-bound.rs:21:27 + --> $DIR/missing-send-bound.rs:20:27 | LL | fn assert_is_send(_: impl Send) {} | ^^^^ required by this bound in `assert_is_send` -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error diff --git a/tests/ui/async-await/in-trait/missing-send-bound.rs b/tests/ui/async-await/in-trait/missing-send-bound.rs index 705fcf322f9ea..b602865cbb12d 100644 --- a/tests/ui/async-await/in-trait/missing-send-bound.rs +++ b/tests/ui/async-await/in-trait/missing-send-bound.rs @@ -3,7 +3,6 @@ // revisions: current next #![feature(async_fn_in_trait)] -//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes trait Foo { async fn bar(); diff --git a/tests/ui/async-await/in-trait/object-safety.current.stderr b/tests/ui/async-await/in-trait/object-safety.current.stderr index 90e049a99606f..7f7ec39142cdf 100644 --- a/tests/ui/async-await/in-trait/object-safety.current.stderr +++ b/tests/ui/async-await/in-trait/object-safety.current.stderr @@ -1,20 +1,11 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/object-safety.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:13:12 + --> $DIR/object-safety.rs:12:12 | LL | let x: &dyn Foo = todo!(); | ^^^^^^^^ `Foo` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/object-safety.rs:9:14 + --> $DIR/object-safety.rs:8:14 | LL | trait Foo { | --- this trait cannot be made into an object... @@ -22,6 +13,6 @@ LL | async fn foo(&self); | ^^^ ...because method `foo` is `async` = help: consider moving `foo` to another trait -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/async-await/in-trait/object-safety.next.stderr b/tests/ui/async-await/in-trait/object-safety.next.stderr index 90e049a99606f..7f7ec39142cdf 100644 --- a/tests/ui/async-await/in-trait/object-safety.next.stderr +++ b/tests/ui/async-await/in-trait/object-safety.next.stderr @@ -1,20 +1,11 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/object-safety.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:13:12 + --> $DIR/object-safety.rs:12:12 | LL | let x: &dyn Foo = todo!(); | ^^^^^^^^ `Foo` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/object-safety.rs:9:14 + --> $DIR/object-safety.rs:8:14 | LL | trait Foo { | --- this trait cannot be made into an object... @@ -22,6 +13,6 @@ LL | async fn foo(&self); | ^^^ ...because method `foo` is `async` = help: consider moving `foo` to another trait -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/async-await/in-trait/object-safety.rs b/tests/ui/async-await/in-trait/object-safety.rs index f67286a20a244..4edad1512e93a 100644 --- a/tests/ui/async-await/in-trait/object-safety.rs +++ b/tests/ui/async-await/in-trait/object-safety.rs @@ -3,7 +3,6 @@ // revisions: current next #![feature(async_fn_in_trait)] -//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes trait Foo { async fn foo(&self); diff --git a/tests/ui/async-await/in-trait/return-type-suggestion.current.stderr b/tests/ui/async-await/in-trait/return-type-suggestion.current.stderr index a5efc75715656..6a107d7beb8fd 100644 --- a/tests/ui/async-await/in-trait/return-type-suggestion.current.stderr +++ b/tests/ui/async-await/in-trait/return-type-suggestion.current.stderr @@ -1,14 +1,5 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/return-type-suggestion.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0308]: mismatched types - --> $DIR/return-type-suggestion.rs:10:9 + --> $DIR/return-type-suggestion.rs:9:9 | LL | Ok(()) | ^^^^^^- help: consider using a semicolon here: `;` @@ -18,6 +9,6 @@ LL | Ok(()) = note: expected unit type `()` found enum `Result<(), _>` -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/async-await/in-trait/return-type-suggestion.next.stderr b/tests/ui/async-await/in-trait/return-type-suggestion.next.stderr index a5efc75715656..6a107d7beb8fd 100644 --- a/tests/ui/async-await/in-trait/return-type-suggestion.next.stderr +++ b/tests/ui/async-await/in-trait/return-type-suggestion.next.stderr @@ -1,14 +1,5 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/return-type-suggestion.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0308]: mismatched types - --> $DIR/return-type-suggestion.rs:10:9 + --> $DIR/return-type-suggestion.rs:9:9 | LL | Ok(()) | ^^^^^^- help: consider using a semicolon here: `;` @@ -18,6 +9,6 @@ LL | Ok(()) = note: expected unit type `()` found enum `Result<(), _>` -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/async-await/in-trait/return-type-suggestion.rs b/tests/ui/async-await/in-trait/return-type-suggestion.rs index 3de66306d9ab8..d63bccefa9fdc 100644 --- a/tests/ui/async-await/in-trait/return-type-suggestion.rs +++ b/tests/ui/async-await/in-trait/return-type-suggestion.rs @@ -3,7 +3,6 @@ // revisions: current next #![feature(async_fn_in_trait)] -//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes trait A { async fn e() { diff --git a/tests/ui/async-await/issue-101715.stderr b/tests/ui/async-await/issue-101715.stderr index a0e8d2a894371..d161fb0c05e75 100644 --- a/tests/ui/async-await/issue-101715.stderr +++ b/tests/ui/async-await/issue-101715.stderr @@ -1,10 +1,10 @@ error[E0277]: `()` is not a future - --> $DIR/issue-101715.rs:11:9 + --> $DIR/issue-101715.rs:11:10 | LL | .await - | ^^^^^^ - | | - | `()` is not a future + | -^^^^^ + | || + | |`()` is not a future | help: remove the `.await` | = help: the trait `Future` is not implemented for `()` diff --git a/tests/ui/async-await/issue-64130-1-sync.drop_tracking.stderr b/tests/ui/async-await/issue-64130-1-sync.drop_tracking.stderr index c4c7f26c7c70b..56aa035f44bab 100644 --- a/tests/ui/async-await/issue-64130-1-sync.drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-1-sync.drop_tracking.stderr @@ -6,12 +6,12 @@ LL | is_sync(bar()); | = help: within `impl Future<Output = ()>`, the trait `Sync` is not implemented for `Foo` note: future is not `Sync` as this value is used across an await - --> $DIR/issue-64130-1-sync.rs:18:10 + --> $DIR/issue-64130-1-sync.rs:18:11 | LL | let x = Foo; | - has type `Foo` which is not `Sync` LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later LL | drop(x); LL | } | - `x` is later dropped here diff --git a/tests/ui/async-await/issue-64130-1-sync.drop_tracking_mir.stderr b/tests/ui/async-await/issue-64130-1-sync.drop_tracking_mir.stderr index 6f43b568a7a68..ea1bfb9f9ac23 100644 --- a/tests/ui/async-await/issue-64130-1-sync.drop_tracking_mir.stderr +++ b/tests/ui/async-await/issue-64130-1-sync.drop_tracking_mir.stderr @@ -6,12 +6,12 @@ LL | is_sync(bar()); | = help: within `impl Future<Output = ()>`, the trait `Sync` is not implemented for `Foo` note: future is not `Sync` as this value is used across an await - --> $DIR/issue-64130-1-sync.rs:18:10 + --> $DIR/issue-64130-1-sync.rs:18:11 | LL | let x = Foo; | - has type `Foo` which is not `Sync` LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later note: required by a bound in `is_sync` --> $DIR/issue-64130-1-sync.rs:14:15 | diff --git a/tests/ui/async-await/issue-64130-1-sync.no_drop_tracking.stderr b/tests/ui/async-await/issue-64130-1-sync.no_drop_tracking.stderr index c4c7f26c7c70b..56aa035f44bab 100644 --- a/tests/ui/async-await/issue-64130-1-sync.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-1-sync.no_drop_tracking.stderr @@ -6,12 +6,12 @@ LL | is_sync(bar()); | = help: within `impl Future<Output = ()>`, the trait `Sync` is not implemented for `Foo` note: future is not `Sync` as this value is used across an await - --> $DIR/issue-64130-1-sync.rs:18:10 + --> $DIR/issue-64130-1-sync.rs:18:11 | LL | let x = Foo; | - has type `Foo` which is not `Sync` LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later LL | drop(x); LL | } | - `x` is later dropped here diff --git a/tests/ui/async-await/issue-64130-1-sync.stderr b/tests/ui/async-await/issue-64130-1-sync.stderr deleted file mode 100644 index 8d5169a6302ee..0000000000000 --- a/tests/ui/async-await/issue-64130-1-sync.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error: future cannot be shared between threads safely - --> $DIR/issue-64130-1-sync.rs:24:13 - | -LL | is_sync(bar()); - | ^^^^^ future returned by `bar` is not `Sync` - | - = help: within `impl Future<Output = ()>`, the trait `Sync` is not implemented for `Foo` -note: future is not `Sync` as this value is used across an await - --> $DIR/issue-64130-1-sync.rs:18:10 - | -LL | let x = Foo; - | - has type `Foo` which is not `Sync` -LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later -LL | } - | - `x` is later dropped here -note: required by a bound in `is_sync` - --> $DIR/issue-64130-1-sync.rs:14:15 - | -LL | fn is_sync<T: Sync>(t: T) { } - | ^^^^ required by this bound in `is_sync` - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-64130-2-send.drop_tracking.stderr b/tests/ui/async-await/issue-64130-2-send.drop_tracking.stderr index b6a73c2a5cb83..d1717ad3310ab 100644 --- a/tests/ui/async-await/issue-64130-2-send.drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-2-send.drop_tracking.stderr @@ -6,12 +6,12 @@ LL | is_send(bar()); | = note: the trait bound `Unique<Foo>: Send` is not satisfied note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-2-send.rs:18:10 + --> $DIR/issue-64130-2-send.rs:18:11 | LL | let x = Box::new(Foo); | - has type `Box<Foo>` which is not `Send` LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later LL | } | - `x` is later dropped here note: required by a bound in `is_send` diff --git a/tests/ui/async-await/issue-64130-2-send.drop_tracking_mir.stderr b/tests/ui/async-await/issue-64130-2-send.drop_tracking_mir.stderr index 560560f60366e..45e43525a206a 100644 --- a/tests/ui/async-await/issue-64130-2-send.drop_tracking_mir.stderr +++ b/tests/ui/async-await/issue-64130-2-send.drop_tracking_mir.stderr @@ -6,12 +6,12 @@ LL | is_send(bar()); | = note: the trait bound `Unique<Foo>: Send` is not satisfied note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-2-send.rs:18:10 + --> $DIR/issue-64130-2-send.rs:18:11 | LL | let x = Box::new(Foo); | - has type `Box<Foo>` which is not `Send` LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later note: required by a bound in `is_send` --> $DIR/issue-64130-2-send.rs:14:15 | diff --git a/tests/ui/async-await/issue-64130-2-send.no_drop_tracking.stderr b/tests/ui/async-await/issue-64130-2-send.no_drop_tracking.stderr index b6a73c2a5cb83..d1717ad3310ab 100644 --- a/tests/ui/async-await/issue-64130-2-send.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-2-send.no_drop_tracking.stderr @@ -6,12 +6,12 @@ LL | is_send(bar()); | = note: the trait bound `Unique<Foo>: Send` is not satisfied note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-2-send.rs:18:10 + --> $DIR/issue-64130-2-send.rs:18:11 | LL | let x = Box::new(Foo); | - has type `Box<Foo>` which is not `Send` LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later LL | } | - `x` is later dropped here note: required by a bound in `is_send` diff --git a/tests/ui/async-await/issue-64130-2-send.stderr b/tests/ui/async-await/issue-64130-2-send.stderr deleted file mode 100644 index f6505cad69e21..0000000000000 --- a/tests/ui/async-await/issue-64130-2-send.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-64130-2-send.rs:24:13 - | -LL | is_send(bar()); - | ^^^^^ future returned by `bar` is not `Send` - | - = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Foo` -note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-2-send.rs:18:10 - | -LL | let x = Foo; - | - has type `Foo` which is not `Send` -LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later -LL | } - | - `x` is later dropped here -note: required by a bound in `is_send` - --> $DIR/issue-64130-2-send.rs:14:15 - | -LL | fn is_send<T: Send>(t: T) { } - | ^^^^ required by this bound in `is_send` - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-64130-3-other.drop_tracking.stderr b/tests/ui/async-await/issue-64130-3-other.drop_tracking.stderr index d65aae8cc3fdd..b69f06da1cde5 100644 --- a/tests/ui/async-await/issue-64130-3-other.drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-3-other.drop_tracking.stderr @@ -8,12 +8,12 @@ LL | is_qux(bar()); | ^^^^^ within `impl Future<Output = ()>`, the trait `Qux` is not implemented for `Foo` | note: future does not implement `Qux` as this value is used across an await - --> $DIR/issue-64130-3-other.rs:21:10 + --> $DIR/issue-64130-3-other.rs:21:11 | LL | let x = Box::new(Foo); | - has type `Box<Foo>` which does not implement `Qux` LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later LL | } | - `x` is later dropped here note: required by a bound in `is_qux` diff --git a/tests/ui/async-await/issue-64130-3-other.drop_tracking_mir.stderr b/tests/ui/async-await/issue-64130-3-other.drop_tracking_mir.stderr index 8fed69d9d8898..1298371241ced 100644 --- a/tests/ui/async-await/issue-64130-3-other.drop_tracking_mir.stderr +++ b/tests/ui/async-await/issue-64130-3-other.drop_tracking_mir.stderr @@ -8,12 +8,12 @@ LL | is_qux(bar()); | ^^^^^ within `impl Future<Output = ()>`, the trait `Qux` is not implemented for `Foo` | note: future does not implement `Qux` as this value is used across an await - --> $DIR/issue-64130-3-other.rs:21:10 + --> $DIR/issue-64130-3-other.rs:21:11 | LL | let x = Box::new(Foo); | - has type `Box<Foo>` which does not implement `Qux` LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later note: required by a bound in `is_qux` --> $DIR/issue-64130-3-other.rs:17:14 | diff --git a/tests/ui/async-await/issue-64130-3-other.no_drop_tracking.stderr b/tests/ui/async-await/issue-64130-3-other.no_drop_tracking.stderr index d65aae8cc3fdd..b69f06da1cde5 100644 --- a/tests/ui/async-await/issue-64130-3-other.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-3-other.no_drop_tracking.stderr @@ -8,12 +8,12 @@ LL | is_qux(bar()); | ^^^^^ within `impl Future<Output = ()>`, the trait `Qux` is not implemented for `Foo` | note: future does not implement `Qux` as this value is used across an await - --> $DIR/issue-64130-3-other.rs:21:10 + --> $DIR/issue-64130-3-other.rs:21:11 | LL | let x = Box::new(Foo); | - has type `Box<Foo>` which does not implement `Qux` LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later + | ^^^^^ await occurs here, with `x` maybe used later LL | } | - `x` is later dropped here note: required by a bound in `is_qux` diff --git a/tests/ui/async-await/issue-64130-3-other.stderr b/tests/ui/async-await/issue-64130-3-other.stderr deleted file mode 100644 index cb36a3811b280..0000000000000 --- a/tests/ui/async-await/issue-64130-3-other.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0277]: the trait bound `Foo: Qux` is not satisfied in `impl Future<Output = ()>` - --> $DIR/issue-64130-3-other.rs:27:12 - | -LL | async fn bar() { - | - within this `impl Future<Output = ()>` -... -LL | is_qux(bar()); - | ^^^^^ within `impl Future<Output = ()>`, the trait `Qux` is not implemented for `Foo` - | -note: future does not implement `Qux` as this value is used across an await - --> $DIR/issue-64130-3-other.rs:21:10 - | -LL | let x = Foo; - | - has type `Foo` which does not implement `Qux` -LL | baz().await; - | ^^^^^^ await occurs here, with `x` maybe used later -LL | } - | - `x` is later dropped here -note: required by a bound in `is_qux` - --> $DIR/issue-64130-3-other.rs:17:14 - | -LL | fn is_qux<T: Qux>(t: T) {} - | ^^^ required by this bound in `is_qux` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr b/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr index 0bc7cb2f2acda..4b575a3d3b47a 100644 --- a/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr @@ -6,13 +6,13 @@ LL | pub fn foo() -> impl Future + Send { | = help: the trait `Sync` is not implemented for `(dyn Any + Send + 'static)` note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-4-async-move.rs:27:31 + --> $DIR/issue-64130-4-async-move.rs:27:32 | LL | match client.status() { | ------ has type `&Client` which is not `Send` LL | 200 => { LL | let _x = get().await; - | ^^^^^^ await occurs here, with `client` maybe used later + | ^^^^^ await occurs here, with `client` maybe used later ... LL | } | - `client` is later dropped here diff --git a/tests/ui/async-await/issue-64130-non-send-future-diags.stderr b/tests/ui/async-await/issue-64130-non-send-future-diags.stderr index 1da80d98bf8fc..e044e2ca011f0 100644 --- a/tests/ui/async-await/issue-64130-non-send-future-diags.stderr +++ b/tests/ui/async-await/issue-64130-non-send-future-diags.stderr @@ -6,12 +6,12 @@ LL | is_send(foo()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `MutexGuard<'_, u32>` note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-non-send-future-diags.rs:17:10 + --> $DIR/issue-64130-non-send-future-diags.rs:17:11 | LL | let g = x.lock().unwrap(); | - has type `MutexGuard<'_, u32>` which is not `Send` LL | baz().await; - | ^^^^^^ await occurs here, with `g` maybe used later + | ^^^^^ await occurs here, with `g` maybe used later LL | } | - `g` is later dropped here note: required by a bound in `is_send` diff --git a/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking.stderr b/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking.stderr index fc8bcc8ae7964..fa22298658b34 100644 --- a/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking.stderr +++ b/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking.stderr @@ -11,12 +11,12 @@ LL | | }); | = help: within `[async block@$DIR/issue-67252-unnamed-future.rs:21:11: 25:6]`, the trait `Send` is not implemented for `*mut ()` note: future is not `Send` as this value is used across an await - --> $DIR/issue-67252-unnamed-future.rs:23:16 + --> $DIR/issue-67252-unnamed-future.rs:23:17 | LL | let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` | - has type `*mut ()` which is not `Send` LL | AFuture.await; - | ^^^^^^ await occurs here, with `a` maybe used later + | ^^^^^ await occurs here, with `a` maybe used later LL | drop(a); LL | }); | - `a` is later dropped here diff --git a/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking_mir.stderr b/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking_mir.stderr index a3ef7add11669..8cf7bb8d9179a 100644 --- a/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking_mir.stderr +++ b/tests/ui/async-await/issue-67252-unnamed-future.drop_tracking_mir.stderr @@ -6,12 +6,12 @@ LL | spawn(async { | = help: within `[async block@$DIR/issue-67252-unnamed-future.rs:21:11: 25:6]`, the trait `Send` is not implemented for `*mut ()` note: future is not `Send` as this value is used across an await - --> $DIR/issue-67252-unnamed-future.rs:23:16 + --> $DIR/issue-67252-unnamed-future.rs:23:17 | LL | let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` | - has type `*mut ()` which is not `Send` LL | AFuture.await; - | ^^^^^^ await occurs here, with `a` maybe used later + | ^^^^^ await occurs here, with `a` maybe used later note: required by a bound in `spawn` --> $DIR/issue-67252-unnamed-future.rs:9:13 | diff --git a/tests/ui/async-await/issue-67252-unnamed-future.no_drop_tracking.stderr b/tests/ui/async-await/issue-67252-unnamed-future.no_drop_tracking.stderr index fc8bcc8ae7964..fa22298658b34 100644 --- a/tests/ui/async-await/issue-67252-unnamed-future.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-67252-unnamed-future.no_drop_tracking.stderr @@ -11,12 +11,12 @@ LL | | }); | = help: within `[async block@$DIR/issue-67252-unnamed-future.rs:21:11: 25:6]`, the trait `Send` is not implemented for `*mut ()` note: future is not `Send` as this value is used across an await - --> $DIR/issue-67252-unnamed-future.rs:23:16 + --> $DIR/issue-67252-unnamed-future.rs:23:17 | LL | let a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` | - has type `*mut ()` which is not `Send` LL | AFuture.await; - | ^^^^^^ await occurs here, with `a` maybe used later + | ^^^^^ await occurs here, with `a` maybe used later LL | drop(a); LL | }); | - `a` is later dropped here diff --git a/tests/ui/async-await/issue-70594.stderr b/tests/ui/async-await/issue-70594.stderr index d3cf57d3b1402..9866e00bb83a9 100644 --- a/tests/ui/async-await/issue-70594.stderr +++ b/tests/ui/async-await/issue-70594.stderr @@ -1,10 +1,10 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/issue-70594.rs:4:11 + --> $DIR/issue-70594.rs:4:12 | LL | async fn fun() { | --- this is not `async` LL | [1; ().await]; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0744]: `.await` is not allowed in a `const` --> $DIR/issue-70594.rs:4:9 @@ -13,18 +13,18 @@ LL | [1; ().await]; | ^^^^^^^^ error[E0744]: `.await` is not allowed in a `const` - --> $DIR/issue-70594.rs:4:11 + --> $DIR/issue-70594.rs:4:12 | LL | [1; ().await]; - | ^^^^^^ + | ^^^^^ error[E0277]: `()` is not a future - --> $DIR/issue-70594.rs:4:11 + --> $DIR/issue-70594.rs:4:12 | LL | [1; ().await]; - | ^^^^^^ - | | - | `()` is not a future + | -^^^^^ + | || + | |`()` is not a future | help: remove the `.await` | = help: the trait `Future` is not implemented for `()` diff --git a/tests/ui/async-await/issue-70818.stderr b/tests/ui/async-await/issue-70818.stderr deleted file mode 100644 index ab0698c3ec213..0000000000000 --- a/tests/ui/async-await/issue-70818.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: future cannot be sent between threads safely - --> $DIR/issue-70818.rs:7:38 - | -LL | fn foo<T: Send, U>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` - | -note: captured value is not `Send` - --> $DIR/issue-70818.rs:9:18 - | -LL | async { (ty, ty1) } - | ^^^ has type `U` which is not `Send` -help: consider restricting type parameter `U` - | -LL | fn foo<T: Send, U: std::marker::Send>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send { - | +++++++++++++++++++ - -error: aborting due to previous error - diff --git a/tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr b/tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr index 8036d82daa4a3..ef0e182e5156f 100644 --- a/tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr @@ -6,15 +6,15 @@ LL | fn foo(tx: std::sync::mpsc::Sender<i32>) -> impl Future + Send { | = help: the trait `Sync` is not implemented for `Sender<i32>` note: future is not `Send` as this value is used across an await - --> $DIR/issue-70935-complex-spans.rs:19:11 + --> $DIR/issue-70935-complex-spans.rs:19:12 | LL | baz(|| async{ | _____________- LL | | foo(tx.clone()); LL | | }).await; - | | - ^^^^^^- the value is later dropped here - | | | | - | |_________| await occurs here, with the value maybe used later + | | - ^^^^^- the value is later dropped here + | | | | + | |_________| await occurs here, with the value maybe used later | has type `[closure@$DIR/issue-70935-complex-spans.rs:17:13: 17:15]` which is not `Send` error: aborting due to previous error diff --git a/tests/ui/async-await/issue-71137.stderr b/tests/ui/async-await/issue-71137.stderr index eade6aa2d3dcc..a344246d6bfff 100644 --- a/tests/ui/async-await/issue-71137.stderr +++ b/tests/ui/async-await/issue-71137.stderr @@ -6,12 +6,12 @@ LL | fake_spawn(wrong_mutex()); | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `MutexGuard<'_, i32>` note: future is not `Send` as this value is used across an await - --> $DIR/issue-71137.rs:14:25 + --> $DIR/issue-71137.rs:14:26 | LL | let mut guard = m.lock().unwrap(); | --------- has type `MutexGuard<'_, i32>` which is not `Send` LL | (async { "right"; }).await; - | ^^^^^^ await occurs here, with `mut guard` maybe used later + | ^^^^^ await occurs here, with `mut guard` maybe used later LL | *guard += 1; LL | } | - `mut guard` is later dropped here diff --git a/tests/ui/async-await/issue-73741-type-err-drop-tracking.stderr b/tests/ui/async-await/issue-73741-type-err-drop-tracking.stderr deleted file mode 100644 index 6d19c3beb2fe1..0000000000000 --- a/tests/ui/async-await/issue-73741-type-err-drop-tracking.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0070]: invalid left-hand side of assignment - --> $DIR/issue-73741-type-err-drop-tracking.rs:11:7 - | -LL | 1 = 2; - | - ^ - | | - | cannot assign to this expression - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0070`. diff --git a/tests/ui/async-await/issue-98634.stderr b/tests/ui/async-await/issue-98634.stderr index 5b7f18a98b539..574904ceafada 100644 --- a/tests/ui/async-await/issue-98634.stderr +++ b/tests/ui/async-await/issue-98634.stderr @@ -23,10 +23,10 @@ LL | pub struct StructAsync<F: Fn() -> Pin<Box<dyn Future<Output = ()>>>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StructAsync` error[E0271]: expected `callback` to be a fn item that returns `Pin<Box<dyn Future<Output = ()>>>`, but it returns `impl Future<Output = ()>` - --> $DIR/issue-98634.rs:45:33 + --> $DIR/issue-98634.rs:45:34 | LL | StructAsync { callback }.await; - | ^^^^^^ expected `Pin<Box<dyn Future<Output = ()>>>`, found future + | ^^^^^ expected `Pin<Box<dyn Future<Output = ()>>>`, found future | note: required by a bound in `StructAsync` --> $DIR/issue-98634.rs:9:35 diff --git a/tests/ui/async-await/issues/issue-107280.stderr b/tests/ui/async-await/issues/issue-107280.stderr index dd3e10fcc187c..2e69862a0e09f 100644 --- a/tests/ui/async-await/issues/issue-107280.stderr +++ b/tests/ui/async-await/issues/issue-107280.stderr @@ -23,10 +23,10 @@ LL | inner::<false>().await | ^^^^^^^^^^^^^^ cannot infer the value of const parameter `PING` declared on the function `inner` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/issue-107280.rs:4:21 + --> $DIR/issue-107280.rs:4:22 | LL | inner::<false>().await - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/issue-107280.rs:4:5 @@ -35,10 +35,10 @@ LL | inner::<false>().await | ^^^^^^^^^^^^^^ cannot infer the value of const parameter `PING` declared on the function `inner` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/issue-107280.rs:4:21 + --> $DIR/issue-107280.rs:4:22 | LL | inner::<false>().await - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/issue-107280.rs:4:5 @@ -47,10 +47,10 @@ LL | inner::<false>().await | ^^^^^^^^^^^^^^ cannot infer the value of const parameter `PING` declared on the function `inner` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/issue-107280.rs:4:21 + --> $DIR/issue-107280.rs:4:22 | LL | inner::<false>().await - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/issue-107280.rs:4:5 @@ -59,10 +59,10 @@ LL | inner::<false>().await | ^^^^^^^^^^^^^^ cannot infer the value of const parameter `PING` declared on the function `inner` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/issue-107280.rs:4:21 + --> $DIR/issue-107280.rs:4:22 | LL | inner::<false>().await - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/issue-107280.rs:4:5 @@ -71,10 +71,10 @@ LL | inner::<false>().await | ^^^^^^^^^^^^^^ cannot infer the value of const parameter `PING` declared on the function `inner` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/issue-107280.rs:4:21 + --> $DIR/issue-107280.rs:4:22 | LL | inner::<false>().await - | ^^^^^^ + | ^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/async-await/issues/issue-51719.stderr b/tests/ui/async-await/issues/issue-51719.stderr index f3ce5d1c897c3..19cc339ec0a07 100644 --- a/tests/ui/async-await/issues/issue-51719.stderr +++ b/tests/ui/async-await/issues/issue-51719.stderr @@ -1,8 +1,8 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/issue-51719.rs:8:24 + --> $DIR/issue-51719.rs:8:25 | LL | let _gen = || foo().await; - | -- ^^^^^^ only allowed inside `async` functions and blocks + | -- ^^^^^ only allowed inside `async` functions and blocks | | | this is not `async` diff --git a/tests/ui/async-await/issues/issue-51751.stderr b/tests/ui/async-await/issues/issue-51751.stderr index 8696a5b798b3c..6dd3726608ba8 100644 --- a/tests/ui/async-await/issues/issue-51751.stderr +++ b/tests/ui/async-await/issues/issue-51751.stderr @@ -1,11 +1,11 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/issue-51751.rs:9:26 + --> $DIR/issue-51751.rs:9:27 | LL | fn main() { | ---- this is not `async` LL | let result = inc(10000); LL | let finished = result.await; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error: aborting due to previous error diff --git a/tests/ui/async-await/issues/issue-62009-1.stderr b/tests/ui/async-await/issues/issue-62009-1.stderr index 222afb2c7b2bb..53d0577a1b23c 100644 --- a/tests/ui/async-await/issues/issue-62009-1.stderr +++ b/tests/ui/async-await/issues/issue-62009-1.stderr @@ -1,36 +1,36 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/issue-62009-1.rs:6:22 + --> $DIR/issue-62009-1.rs:6:23 | LL | fn main() { | ---- this is not `async` LL | async { let (); }.await; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/issue-62009-1.rs:10:6 + --> $DIR/issue-62009-1.rs:10:7 | LL | fn main() { | ---- this is not `async` ... LL | }.await; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/issue-62009-1.rs:12:15 + --> $DIR/issue-62009-1.rs:12:16 | LL | fn main() { | ---- this is not `async` ... LL | (|_| 2333).await; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error[E0277]: `[closure@$DIR/issue-62009-1.rs:12:6: 12:9]` is not a future - --> $DIR/issue-62009-1.rs:12:15 + --> $DIR/issue-62009-1.rs:12:16 | LL | (|_| 2333).await; - | ^^^^^^ - | | - | `[closure@$DIR/issue-62009-1.rs:12:6: 12:9]` is not a future + | -^^^^^ + | || + | |`[closure@$DIR/issue-62009-1.rs:12:6: 12:9]` is not a future | help: remove the `.await` | = help: the trait `Future` is not implemented for closure `[closure@$DIR/issue-62009-1.rs:12:6: 12:9]` diff --git a/tests/ui/async-await/issues/issue-62009-2.stderr b/tests/ui/async-await/issues/issue-62009-2.stderr index 92e9a8a69a88b..9c2f20df6576f 100644 --- a/tests/ui/async-await/issues/issue-62009-2.stderr +++ b/tests/ui/async-await/issues/issue-62009-2.stderr @@ -1,10 +1,10 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/issue-62009-2.rs:8:22 + --> $DIR/issue-62009-2.rs:8:23 | LL | fn main() { | ---- this is not `async` LL | (async || 2333)().await; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error: aborting due to previous error diff --git a/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr b/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr index 8745bdd973bea..53d32620241c7 100644 --- a/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr +++ b/tests/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr @@ -10,12 +10,12 @@ LL | | }) | = help: within `[async block@$DIR/issue-65436-raw-ptr-not-send.rs:17:17: 20:6]`, the trait `Send` is not implemented for `*const u8` note: future is not `Send` as this value is used across an await - --> $DIR/issue-65436-raw-ptr-not-send.rs:19:35 + --> $DIR/issue-65436-raw-ptr-not-send.rs:19:36 | LL | bar(Foo(std::ptr::null())).await; - | ---------------- ^^^^^^- `std::ptr::null()` is later dropped here - | | | - | | await occurs here, with `std::ptr::null()` maybe used later + | ---------------- ^^^^^- `std::ptr::null()` is later dropped here + | | | + | | await occurs here, with `std::ptr::null()` maybe used later | has type `*const u8` which is not `Send` help: consider moving this into a `let` binding to create a shorter lived borrow --> $DIR/issue-65436-raw-ptr-not-send.rs:19:13 diff --git a/tests/ui/async-await/issues/issue-67893.stderr b/tests/ui/async-await/issues/issue-67893.stderr index ce9424c8b252b..c941b9eeb29ac 100644 --- a/tests/ui/async-await/issues/issue-67893.stderr +++ b/tests/ui/async-await/issues/issue-67893.stderr @@ -6,12 +6,12 @@ LL | g(issue_67893::run()) | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `MutexGuard<'_, ()>` note: future is not `Send` as this value is used across an await - --> $DIR/auxiliary/issue_67893.rs:12:26 + --> $DIR/auxiliary/issue_67893.rs:12:27 | LL | f(*x.lock().unwrap()).await; - | ----------------- ^^^^^^- `x.lock().unwrap()` is later dropped here - | | | - | | await occurs here, with `x.lock().unwrap()` maybe used later + | ----------------- ^^^^^- `x.lock().unwrap()` is later dropped here + | | | + | | await occurs here, with `x.lock().unwrap()` maybe used later | has type `MutexGuard<'_, ()>` which is not `Send` note: required by a bound in `g` --> $DIR/issue-67893.rs:6:14 diff --git a/tests/ui/async-await/issues/non-async-enclosing-span.stderr b/tests/ui/async-await/issues/non-async-enclosing-span.stderr index 20b827479fa80..b6583022c161a 100644 --- a/tests/ui/async-await/issues/non-async-enclosing-span.stderr +++ b/tests/ui/async-await/issues/non-async-enclosing-span.stderr @@ -1,11 +1,11 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/non-async-enclosing-span.rs:9:27 + --> $DIR/non-async-enclosing-span.rs:9:28 | LL | fn main() { | ---- this is not `async` LL | let x = move || {}; LL | let y = do_the_thing().await; - | ^^^^^^ only allowed inside `async` functions and blocks + | ^^^^^ only allowed inside `async` functions and blocks error: aborting due to previous error diff --git a/tests/ui/async-await/mutually-recursive-async-impl-trait-type.stderr b/tests/ui/async-await/mutually-recursive-async-impl-trait-type.stderr deleted file mode 100644 index 8a7317bb95a70..0000000000000 --- a/tests/ui/async-await/mutually-recursive-async-impl-trait-type.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/mutually-recursive-async-impl-trait-type.rs:9:18 - | -LL | async fn rec_1() { - | ^ recursive `async fn` - | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` - = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion - -error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/mutually-recursive-async-impl-trait-type.rs:13:18 - | -LL | async fn rec_2() { - | ^ recursive `async fn` - | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` - = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0733`. diff --git a/tests/ui/async-await/recursive-async-impl-trait-type.stderr b/tests/ui/async-await/recursive-async-impl-trait-type.stderr deleted file mode 100644 index 7e63a8da55255..0000000000000 --- a/tests/ui/async-await/recursive-async-impl-trait-type.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/recursive-async-impl-trait-type.rs:8:40 - | -LL | async fn recursive_async_function() -> () { - | ^^ recursive `async fn` - | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` - = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0733`. diff --git a/tests/ui/async-await/return-type-notation/issue-110963-early.stderr b/tests/ui/async-await/return-type-notation/issue-110963-early.stderr index b4a3924d8dab9..33e22dec3f7b2 100644 --- a/tests/ui/async-await/return-type-notation/issue-110963-early.stderr +++ b/tests/ui/async-await/return-type-notation/issue-110963-early.stderr @@ -7,14 +7,6 @@ LL | #![feature(return_type_notation)] = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-110963-early.rs:5:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - error: higher-ranked lifetime error --> $DIR/issue-110963-early.rs:15:5 | @@ -41,5 +33,5 @@ LL | | }); | = note: could not prove `[async block@$DIR/issue-110963-early.rs:15:11: 20:6]: Send` -error: aborting due to 2 previous errors; 2 warnings emitted +error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui/async-await/return-type-notation/issue-110963-late.rs b/tests/ui/async-await/return-type-notation/issue-110963-late.rs index 2a35922eaa1b5..17b5d775d4479 100644 --- a/tests/ui/async-await/return-type-notation/issue-110963-late.rs +++ b/tests/ui/async-await/return-type-notation/issue-110963-late.rs @@ -4,7 +4,6 @@ #![feature(return_type_notation)] //~^ WARN the feature `return_type_notation` is incomplete #![feature(async_fn_in_trait)] -//~^ WARN the feature `async_fn_in_trait` is incomplete trait HealthCheck { async fn check(&mut self) -> bool; diff --git a/tests/ui/async-await/return-type-notation/issue-110963-late.stderr b/tests/ui/async-await/return-type-notation/issue-110963-late.stderr index 36ef3ad0a4c82..9c6966537a73a 100644 --- a/tests/ui/async-await/return-type-notation/issue-110963-late.stderr +++ b/tests/ui/async-await/return-type-notation/issue-110963-late.stderr @@ -7,13 +7,5 @@ LL | #![feature(return_type_notation)] = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = note: `#[warn(incomplete_features)]` on by default -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-110963-late.rs:6:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - -warning: 2 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/async-await/unnecessary-await.rs b/tests/ui/async-await/unnecessary-await.rs index 24673777b8039..cd1e28714322a 100644 --- a/tests/ui/async-await/unnecessary-await.rs +++ b/tests/ui/async-await/unnecessary-await.rs @@ -11,4 +11,24 @@ async fn baz() -> std::io::Result<()> { std::io::Result::Ok(()) } +macro_rules! e { + () => { + () + }; +} + +macro_rules! f { + ($expr:expr) => { + $expr.await + //~^ ERROR `()` is not a future + }; +} + +async fn with_macros() { + e!().await; + //~^ ERROR `()` is not a future + + f!(()); +} + fn main() {} diff --git a/tests/ui/async-await/unnecessary-await.stderr b/tests/ui/async-await/unnecessary-await.stderr index dc3089336974a..9a2a035b2dd08 100644 --- a/tests/ui/async-await/unnecessary-await.stderr +++ b/tests/ui/async-await/unnecessary-await.stderr @@ -1,8 +1,8 @@ error[E0277]: `()` is not a future - --> $DIR/unnecessary-await.rs:9:10 + --> $DIR/unnecessary-await.rs:9:11 | LL | boo().await; - | -----^^^^^^ `()` is not a future + | ----- ^^^^^ `()` is not a future | | | this call returns `()` | @@ -19,6 +19,36 @@ help: alternatively, consider making `fn boo` asynchronous LL | async fn boo() {} | +++++ -error: aborting due to previous error +error[E0277]: `()` is not a future + --> $DIR/unnecessary-await.rs:28:10 + | +LL | e!().await; + | -^^^^^ + | || + | |`()` is not a future + | help: remove the `.await` + | + = help: the trait `Future` is not implemented for `()` + = note: () must be a future or must implement `IntoFuture` to be awaited + = note: required for `()` to implement `IntoFuture` + +error[E0277]: `()` is not a future + --> $DIR/unnecessary-await.rs:22:15 + | +LL | $expr.await + | ^^^^^ + | | + | `()` is not a future + | remove the `.await` +... +LL | f!(()); + | ------ in this macro invocation + | + = help: the trait `Future` is not implemented for `()` + = note: () must be a future or must implement `IntoFuture` to be awaited + = note: required for `()` to implement `IntoFuture` + = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/unresolved_type_param.drop_tracking.stderr b/tests/ui/async-await/unresolved_type_param.drop_tracking.stderr index 912e2b34c0541..6b4a3a36395f8 100644 --- a/tests/ui/async-await/unresolved_type_param.drop_tracking.stderr +++ b/tests/ui/async-await/unresolved_type_param.drop_tracking.stderr @@ -5,10 +5,10 @@ LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:10 + --> $DIR/unresolved_type_param.rs:12:11 | LL | bar().await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/unresolved_type_param.rs:12:5 @@ -17,10 +17,10 @@ LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:10 + --> $DIR/unresolved_type_param.rs:12:11 | LL | bar().await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/unresolved_type_param.rs:12:5 @@ -29,10 +29,10 @@ LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:10 + --> $DIR/unresolved_type_param.rs:12:11 | LL | bar().await; - | ^^^^^^ + | ^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/async-await/unresolved_type_param.no_drop_tracking.stderr b/tests/ui/async-await/unresolved_type_param.no_drop_tracking.stderr index 16d618caa5713..6642e90acd861 100644 --- a/tests/ui/async-await/unresolved_type_param.no_drop_tracking.stderr +++ b/tests/ui/async-await/unresolved_type_param.no_drop_tracking.stderr @@ -5,10 +5,10 @@ LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:10 + --> $DIR/unresolved_type_param.rs:12:11 | LL | bar().await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/unresolved_type_param.rs:12:5 @@ -17,10 +17,10 @@ LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:10 + --> $DIR/unresolved_type_param.rs:12:11 | LL | bar().await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/unresolved_type_param.rs:12:5 @@ -29,10 +29,10 @@ LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:10 + --> $DIR/unresolved_type_param.rs:12:11 | LL | bar().await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/unresolved_type_param.rs:12:5 @@ -41,10 +41,10 @@ LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:10 + --> $DIR/unresolved_type_param.rs:12:11 | LL | bar().await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async fn` body must be known in this context --> $DIR/unresolved_type_param.rs:12:5 @@ -53,10 +53,10 @@ LL | bar().await; | ^^^ cannot infer type for type parameter `T` declared on the function `bar` | note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:12:10 + --> $DIR/unresolved_type_param.rs:12:11 | LL | bar().await; - | ^^^^^^ + | ^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/async-await/unresolved_type_param.stderr b/tests/ui/async-await/unresolved_type_param.stderr deleted file mode 100644 index 64a31b5fc32dc..0000000000000 --- a/tests/ui/async-await/unresolved_type_param.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:13:5 - | -LL | bar().await; - | ^^^ cannot infer type for type parameter `T` declared on the function `bar` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:13:10 - | -LL | bar().await; - | ^^^^^^ - -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:13:5 - | -LL | bar().await; - | ^^^ cannot infer type for type parameter `T` declared on the function `bar` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:13:10 - | -LL | bar().await; - | ^^^^^^ - -error[E0698]: type inside `async fn` body must be known in this context - --> $DIR/unresolved_type_param.rs:13:5 - | -LL | bar().await; - | ^^^ cannot infer type for type parameter `T` declared on the function `bar` - | -note: the type is part of the `async fn` body because of this `await` - --> $DIR/unresolved_type_param.rs:13:10 - | -LL | bar().await; - | ^^^^^^ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0698`. diff --git a/tests/ui/binding/issue-53114-safety-checks.stderr b/tests/ui/binding/issue-53114-safety-checks.stderr index 41318d0a38a17..349c4639a9e2d 100644 --- a/tests/ui/binding/issue-53114-safety-checks.stderr +++ b/tests/ui/binding/issue-53114-safety-checks.stderr @@ -4,7 +4,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &p.b; | ^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -13,7 +14,8 @@ error[E0793]: reference to packed field is unaligned LL | let (_,) = (&p.b,); | ^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -22,7 +24,8 @@ error[E0793]: reference to packed field is unaligned LL | let _: _ = &p.b; | ^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -31,7 +34,8 @@ error[E0793]: reference to packed field is unaligned LL | let (_,): _ = (&p.b,); | ^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -40,7 +44,8 @@ error[E0793]: reference to packed field is unaligned LL | match &p.b { _ => { } } | ^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -49,7 +54,8 @@ error[E0793]: reference to packed field is unaligned LL | match (&p.b,) { (_,) => { } } | ^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0133]: access to union field is unsafe and requires unsafe function or block diff --git a/tests/ui/borrowck/tainted-promoteds.rs b/tests/ui/borrowck/tainted-promoteds.rs new file mode 100644 index 0000000000000..2b6f0ddbd6c7f --- /dev/null +++ b/tests/ui/borrowck/tainted-promoteds.rs @@ -0,0 +1,12 @@ +// Regression test for issue #110856, where a borrowck error for a MIR tainted +// all promoteds within. This in turn generated a spurious "erroneous constant +// used" note when trying to evaluate a promoted. + +pub fn f() -> u32 { + let a = 0; + a = &0 * &1 * &2 * &3; + //~^ ERROR: cannot assign twice to immutable variable + a +} + +fn main() {} diff --git a/tests/ui/borrowck/tainted-promoteds.stderr b/tests/ui/borrowck/tainted-promoteds.stderr new file mode 100644 index 0000000000000..b276ea9acebe9 --- /dev/null +++ b/tests/ui/borrowck/tainted-promoteds.stderr @@ -0,0 +1,14 @@ +error[E0384]: cannot assign twice to immutable variable `a` + --> $DIR/tainted-promoteds.rs:7:5 + | +LL | let a = 0; + | - + | | + | first assignment to `a` + | help: consider making this binding mutable: `mut a` +LL | a = &0 * &1 * &2 * &3; + | ^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr b/tests/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr index 9c2c434572ae5..8c44229bcebe1 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr @@ -4,7 +4,8 @@ error[E0793]: reference to packed field is unaligned LL | println!("{}", foo.x); | ^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.rs b/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.rs new file mode 100644 index 0000000000000..72652ef60349a --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.rs @@ -0,0 +1,21 @@ +// Test precise capture of a multi-variant enum (when remaining variants are +// visibly uninhabited). +// edition:2021 +// run-pass +#![feature(exhaustive_patterns)] +#![feature(never_type)] + +pub fn main() { + let mut r = Result::<!, (u32, u32)>::Err((0, 0)); + let mut f = || { + let Err((ref mut a, _)) = r; + *a = 1; + }; + let mut g = || { + let Err((_, ref mut b)) = r; + *b = 2; + }; + f(); + g(); + assert_eq!(r, Err((1, 2))); +} diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr b/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr index c3a371e25e896..1bdb2574eadc3 100644 --- a/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr @@ -1,5 +1,5 @@ error[E0658]: return type notation is experimental - --> $DIR/feature-gate-return_type_notation.rs:15:17 + --> $DIR/feature-gate-return_type_notation.rs:14:17 | LL | fn foo<T: Trait<m(): Send>>() {} | ^^^^^^^^^ @@ -7,17 +7,8 @@ LL | fn foo<T: Trait<m(): Send>>() {} = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = help: add `#![feature(return_type_notation)]` to the crate attributes to enable -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/feature-gate-return_type_notation.rs:7:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error: parenthesized generic arguments cannot be used in associated type constraints - --> $DIR/feature-gate-return_type_notation.rs:15:17 + --> $DIR/feature-gate-return_type_notation.rs:14:17 | LL | fn foo<T: Trait<m(): Send>>() {} | ^-- @@ -25,12 +16,12 @@ LL | fn foo<T: Trait<m(): Send>>() {} | help: remove these parentheses error[E0220]: associated type `m` not found for `Trait` - --> $DIR/feature-gate-return_type_notation.rs:15:17 + --> $DIR/feature-gate-return_type_notation.rs:14:17 | LL | fn foo<T: Trait<m(): Send>>() {} | ^ associated type `m` not found -error: aborting due to 3 previous errors; 1 warning emitted +error: aborting due to 3 previous errors Some errors have detailed explanations: E0220, E0658. For more information about an error, try `rustc --explain E0220`. diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr b/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr index 52c90c1565cff..dd6ebb6103862 100644 --- a/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr @@ -1,14 +1,5 @@ -warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/feature-gate-return_type_notation.rs:7:12 - | -LL | #![feature(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - warning: return type notation is experimental - --> $DIR/feature-gate-return_type_notation.rs:15:17 + --> $DIR/feature-gate-return_type_notation.rs:14:17 | LL | fn foo<T: Trait<m(): Send>>() {} | ^^^^^^^^^ @@ -18,5 +9,5 @@ LL | fn foo<T: Trait<m(): Send>>() {} = warning: unstable syntax can change at any point in the future, causing a hard error! = note: for more information, see issue #65860 <https://github.com/rust-lang/rust/issues/65860> -warning: 2 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.rs b/tests/ui/feature-gates/feature-gate-return_type_notation.rs index 5028b9ec9e3de..d9bcb65feba9a 100644 --- a/tests/ui/feature-gates/feature-gate-return_type_notation.rs +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.rs @@ -5,7 +5,6 @@ // Since we're not adding new syntax, `cfg`'d out RTN must pass. #![feature(async_fn_in_trait)] -//~^ WARN the feature `async_fn_in_trait` is incomplete trait Trait { async fn m(); diff --git a/tests/ui/unwind-abis/feature-gate-thiscall-unwind.rs b/tests/ui/feature-gates/feature-gate-thiscall.rs similarity index 89% rename from tests/ui/unwind-abis/feature-gate-thiscall-unwind.rs rename to tests/ui/feature-gates/feature-gate-thiscall.rs index 0a323e50fcf26..97a732bcff7f3 100644 --- a/tests/ui/unwind-abis/feature-gate-thiscall-unwind.rs +++ b/tests/ui/feature-gates/feature-gate-thiscall.rs @@ -1,5 +1,4 @@ // gate-test-abi_thiscall -// gate-test-c_unwind // needs-llvm-components: x86 // compile-flags: --target=i686-pc-windows-msvc --crate-type=rlib #![no_core] @@ -7,8 +6,8 @@ #[lang="sized"] trait Sized { } -// Test that the "thiscall-unwind" ABI is feature-gated, and cannot be used when -// the `c_unwind` feature gate is not used. +// Test that the "thiscall" ABI is feature-gated, and cannot be used when +// the `abi_thiscall` feature gate is not used. extern "thiscall-unwind" fn fu() {} //~ ERROR thiscall-unwind ABI is experimental extern "thiscall" fn f() {} //~ ERROR thiscall is experimental diff --git a/tests/ui/unwind-abis/feature-gate-thiscall-unwind.stderr b/tests/ui/feature-gates/feature-gate-thiscall.stderr similarity index 59% rename from tests/ui/unwind-abis/feature-gate-thiscall-unwind.stderr rename to tests/ui/feature-gates/feature-gate-thiscall.stderr index 9ca00a55cd85b..346e45952cde8 100644 --- a/tests/ui/unwind-abis/feature-gate-thiscall-unwind.stderr +++ b/tests/ui/feature-gates/feature-gate-thiscall.stderr @@ -1,14 +1,13 @@ error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:13:8 + --> $DIR/feature-gate-thiscall.rs:12:8 | LL | extern "thiscall-unwind" fn fu() {} | ^^^^^^^^^^^^^^^^^ | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable + = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:14:8 + --> $DIR/feature-gate-thiscall.rs:13:8 | LL | extern "thiscall" fn f() {} | ^^^^^^^^^^ @@ -16,7 +15,7 @@ LL | extern "thiscall" fn f() {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:17:12 + --> $DIR/feature-gate-thiscall.rs:16:12 | LL | extern "thiscall" fn m(); | ^^^^^^^^^^ @@ -24,16 +23,15 @@ LL | extern "thiscall" fn m(); = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:18:12 + --> $DIR/feature-gate-thiscall.rs:17:12 | LL | extern "thiscall-unwind" fn mu(); | ^^^^^^^^^^^^^^^^^ | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable + = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:20:12 + --> $DIR/feature-gate-thiscall.rs:19:12 | LL | extern "thiscall" fn dm() {} | ^^^^^^^^^^ @@ -41,16 +39,15 @@ LL | extern "thiscall" fn dm() {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:21:12 + --> $DIR/feature-gate-thiscall.rs:20:12 | LL | extern "thiscall-unwind" fn dmu() {} | ^^^^^^^^^^^^^^^^^ | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable + = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:26:12 + --> $DIR/feature-gate-thiscall.rs:25:12 | LL | extern "thiscall" fn m() {} | ^^^^^^^^^^ @@ -58,16 +55,15 @@ LL | extern "thiscall" fn m() {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:27:12 + --> $DIR/feature-gate-thiscall.rs:26:12 | LL | extern "thiscall-unwind" fn mu() {} | ^^^^^^^^^^^^^^^^^ | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable + = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:31:12 + --> $DIR/feature-gate-thiscall.rs:30:12 | LL | extern "thiscall" fn im() {} | ^^^^^^^^^^ @@ -75,16 +71,15 @@ LL | extern "thiscall" fn im() {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:32:12 + --> $DIR/feature-gate-thiscall.rs:31:12 | LL | extern "thiscall-unwind" fn imu() {} | ^^^^^^^^^^^^^^^^^ | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable + = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:35:18 + --> $DIR/feature-gate-thiscall.rs:34:18 | LL | type TA = extern "thiscall" fn(); | ^^^^^^^^^^ @@ -92,16 +87,15 @@ LL | type TA = extern "thiscall" fn(); = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:36:19 + --> $DIR/feature-gate-thiscall.rs:35:19 | LL | type TAU = extern "thiscall-unwind" fn(); | ^^^^^^^^^^^^^^^^^ | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable + = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:38:8 + --> $DIR/feature-gate-thiscall.rs:37:8 | LL | extern "thiscall" {} | ^^^^^^^^^^ @@ -109,13 +103,12 @@ LL | extern "thiscall" {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: thiscall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-thiscall-unwind.rs:39:8 + --> $DIR/feature-gate-thiscall.rs:38:8 | LL | extern "thiscall-unwind" {} | ^^^^^^^^^^^^^^^^^ | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable + = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error: aborting due to 14 previous errors diff --git a/tests/ui/feature-gates/feature-gate-vectorcall.rs b/tests/ui/feature-gates/feature-gate-vectorcall.rs index 5a6c6d28804c7..706780dfd6c5b 100644 --- a/tests/ui/feature-gates/feature-gate-vectorcall.rs +++ b/tests/ui/feature-gates/feature-gate-vectorcall.rs @@ -6,8 +6,8 @@ #[lang="sized"] trait Sized { } -// Test that the "vectorcall-unwind" ABI is feature-gated, and cannot be used when -// the `c_unwind` feature gate is not used. +// Test that the "vectorcall" ABI is feature-gated, and cannot be used when +// the `vectorcall` feature gate is not used. extern "vectorcall" fn f() {} //~ ERROR vectorcall is experimental diff --git a/tests/ui/generator/borrowing.stderr b/tests/ui/generator/borrowing.stderr deleted file mode 100644 index 96e3c327f8b31..0000000000000 --- a/tests/ui/generator/borrowing.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:13:33 - | -LL | let _b = { - | -- borrow later stored here -LL | let a = 3; -LL | Pin::new(&mut || yield &a).resume(()) - | -- ^ borrowed value does not live long enough - | | - | value captured here by generator -LL | -LL | }; - | - `a` dropped here while still borrowed - -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:20:20 - | -LL | let _b = { - | -- borrow later stored here -LL | let a = 3; -LL | || { - | -- value captured here by generator -LL | yield &a - | ^ borrowed value does not live long enough -... -LL | }; - | - `a` dropped here while still borrowed - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/generator/retain-resume-ref.stderr b/tests/ui/generator/retain-resume-ref.stderr deleted file mode 100644 index 7122a951e8070..0000000000000 --- a/tests/ui/generator/retain-resume-ref.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0499]: cannot borrow `thing` as mutable more than once at a time - --> $DIR/retain-resume-ref.rs:27:25 - | -LL | gen.as_mut().resume(&mut thing); - | ---------- first mutable borrow occurs here -LL | gen.as_mut().resume(&mut thing); - | ------ ^^^^^^^^^^ second mutable borrow occurs here - | | - | first borrow later used by call - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/generator/unresolved-ct-var-drop-tracking.stderr b/tests/ui/generator/unresolved-ct-var-drop-tracking.stderr index 9e1fed54c548a..dec0141ab6717 100644 --- a/tests/ui/generator/unresolved-ct-var-drop-tracking.stderr +++ b/tests/ui/generator/unresolved-ct-var-drop-tracking.stderr @@ -1,10 +1,10 @@ error[E0277]: `[(); _]` is not a future - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:44 + --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ---------------------------^^^^^^ - | | | - | | `[(); _]` is not a future + | ----------------------------^^^^^ + | | || + | | |`[(); _]` is not a future | | help: remove the `.await` | this call returns `[(); _]` | @@ -19,10 +19,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:44 + --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async` block must be known in this context --> $DIR/unresolved-ct-var-drop-tracking.rs:7:17 @@ -31,10 +31,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:44 + --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async` block must be known in this context --> $DIR/unresolved-ct-var-drop-tracking.rs:7:17 @@ -43,10 +43,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:44 + --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async` block must be known in this context --> $DIR/unresolved-ct-var-drop-tracking.rs:7:17 @@ -55,10 +55,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:44 + --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async` block must be known in this context --> $DIR/unresolved-ct-var-drop-tracking.rs:7:17 @@ -67,10 +67,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var-drop-tracking.rs:7:44 + --> $DIR/unresolved-ct-var-drop-tracking.rs:7:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/generator/unresolved-ct-var.stderr b/tests/ui/generator/unresolved-ct-var.stderr index fdf00dfad7ab7..ace254178b7fa 100644 --- a/tests/ui/generator/unresolved-ct-var.stderr +++ b/tests/ui/generator/unresolved-ct-var.stderr @@ -1,10 +1,10 @@ error[E0277]: `[(); _]` is not a future - --> $DIR/unresolved-ct-var.rs:6:44 + --> $DIR/unresolved-ct-var.rs:6:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ---------------------------^^^^^^ - | | | - | | `[(); _]` is not a future + | ----------------------------^^^^^ + | | || + | | |`[(); _]` is not a future | | help: remove the `.await` | this call returns `[(); _]` | @@ -19,10 +19,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:44 + --> $DIR/unresolved-ct-var.rs:6:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async` block must be known in this context --> $DIR/unresolved-ct-var.rs:6:17 @@ -31,10 +31,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:44 + --> $DIR/unresolved-ct-var.rs:6:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async` block must be known in this context --> $DIR/unresolved-ct-var.rs:6:17 @@ -43,10 +43,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:44 + --> $DIR/unresolved-ct-var.rs:6:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async` block must be known in this context --> $DIR/unresolved-ct-var.rs:6:17 @@ -55,10 +55,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:44 + --> $DIR/unresolved-ct-var.rs:6:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error[E0698]: type inside `async` block must be known in this context --> $DIR/unresolved-ct-var.rs:6:17 @@ -67,10 +67,10 @@ LL | let s = std::array::from_fn(|_| ()).await; | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` | note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:44 + --> $DIR/unresolved-ct-var.rs:6:45 | LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ + | ^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.current.stderr b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.current.stderr deleted file mode 100644 index 05c025cc169ff..0000000000000 --- a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.current.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/box-coerce-span-in-default.rs:5:12 - | -LL | #![feature(return_position_impl_trait_in_trait)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.next.stderr b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.next.stderr deleted file mode 100644 index 05c025cc169ff..0000000000000 --- a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.next.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/box-coerce-span-in-default.rs:5:12 - | -LL | #![feature(return_position_impl_trait_in_trait)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs index 163bb4fcf773d..f5290a5f4af8f 100644 --- a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs +++ b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs @@ -3,7 +3,6 @@ // revisions: current next #![feature(return_position_impl_trait_in_trait)] -//~^ WARN the feature `return_position_impl_trait_in_trait` is incomplete struct TestA {} struct TestB {} diff --git a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.current.stderr b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.current.stderr deleted file mode 100644 index a0c0589b9a1c0..0000000000000 --- a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.current.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/default-method-binder-shifting.rs:5:12 - | -LL | #![feature(return_position_impl_trait_in_trait)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.next.stderr b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.next.stderr deleted file mode 100644 index a0c0589b9a1c0..0000000000000 --- a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.next.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/default-method-binder-shifting.rs:5:12 - | -LL | #![feature(return_position_impl_trait_in_trait)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs index de82544f29338..187039f449c8d 100644 --- a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs +++ b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs @@ -3,7 +3,6 @@ // revisions: current next #![feature(return_position_impl_trait_in_trait)] -//~^ WARN the feature `return_position_impl_trait_in_trait` is incomplete trait Trait { type Type; diff --git a/tests/ui/impl-trait/in-trait/default-method-constraint.current.stderr b/tests/ui/impl-trait/in-trait/default-method-constraint.current.stderr deleted file mode 100644 index 7bb79911f56f8..0000000000000 --- a/tests/ui/impl-trait/in-trait/default-method-constraint.current.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/default-method-constraint.rs:7:12 - | -LL | #![feature(return_position_impl_trait_in_trait)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/impl-trait/in-trait/default-method-constraint.next.stderr b/tests/ui/impl-trait/in-trait/default-method-constraint.next.stderr deleted file mode 100644 index 7bb79911f56f8..0000000000000 --- a/tests/ui/impl-trait/in-trait/default-method-constraint.next.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/default-method-constraint.rs:7:12 - | -LL | #![feature(return_position_impl_trait_in_trait)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/impl-trait/in-trait/default-method-constraint.rs b/tests/ui/impl-trait/in-trait/default-method-constraint.rs index e85fe3c8626f4..4f0bf2e7dfe16 100644 --- a/tests/ui/impl-trait/in-trait/default-method-constraint.rs +++ b/tests/ui/impl-trait/in-trait/default-method-constraint.rs @@ -5,7 +5,6 @@ // This didn't work in the previous default RPITIT method hack attempt #![feature(return_position_impl_trait_in_trait)] -//~^ WARN the feature `return_position_impl_trait_in_trait` is incomplete trait Foo { fn bar(x: bool) -> impl Sized { diff --git a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr index b8a793e1a7bb5..d4d0124a6599c 100644 --- a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr +++ b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr @@ -1,14 +1,5 @@ -warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/dont-project-to-rpitit-with-no-value.rs:4:12 - | -LL | #![feature(return_position_impl_trait_in_trait)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0046]: not all trait items implemented, missing: `foo` - --> $DIR/dont-project-to-rpitit-with-no-value.rs:12:1 + --> $DIR/dont-project-to-rpitit-with-no-value.rs:11:1 | LL | fn foo(&self) -> impl Sized; | ---------------------------- `foo` from trait @@ -16,6 +7,6 @@ LL | fn foo(&self) -> impl Sized; LL | impl MyTrait for i32 { | ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.next.stderr b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.next.stderr index b8a793e1a7bb5..d4d0124a6599c 100644 --- a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.next.stderr +++ b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.next.stderr @@ -1,14 +1,5 @@ -warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/dont-project-to-rpitit-with-no-value.rs:4:12 - | -LL | #![feature(return_position_impl_trait_in_trait)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0046]: not all trait items implemented, missing: `foo` - --> $DIR/dont-project-to-rpitit-with-no-value.rs:12:1 + --> $DIR/dont-project-to-rpitit-with-no-value.rs:11:1 | LL | fn foo(&self) -> impl Sized; | ---------------------------- `foo` from trait @@ -16,6 +7,6 @@ LL | fn foo(&self) -> impl Sized; LL | impl MyTrait for i32 { | ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs index 8329ce1f835d0..4d50b8c927870 100644 --- a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs +++ b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs @@ -2,7 +2,6 @@ // revisions: current next #![feature(return_position_impl_trait_in_trait)] -//~^ WARN the feature `return_position_impl_trait_in_trait` is incomplete trait MyTrait { fn foo(&self) -> impl Sized; diff --git a/tests/ui/lifetimes/elided-lifetime-in-anon-const.rs b/tests/ui/lifetimes/elided-lifetime-in-anon-const.rs new file mode 100644 index 0000000000000..69a7b61bab418 --- /dev/null +++ b/tests/ui/lifetimes/elided-lifetime-in-anon-const.rs @@ -0,0 +1,20 @@ +// Verify that elided lifetimes inside anonymous constants are not forced to be `'static`. +// check-pass + +fn foo() -> [(); { + let a = 10_usize; + let b: &'_ usize = &a; + *b + }] { + [(); 10] +} + +fn bar() -> [(); 10] { + [(); { + let a = 10_usize; + let b: &'_ usize = &a; + *b + }] +} + +fn main() {} diff --git a/tests/ui/lint/must_not_suspend/boxed.stderr b/tests/ui/lint/must_not_suspend/boxed.stderr index 9efc7b0693bfd..a2abfffc170b7 100644 --- a/tests/ui/lint/must_not_suspend/boxed.stderr +++ b/tests/ui/lint/must_not_suspend/boxed.stderr @@ -4,7 +4,7 @@ error: boxed `Umm` held across a suspend point, but should not be LL | let _guard = bar(); | ^^^^^^ LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/boxed.rs:20:9 diff --git a/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr index 262657da5fe6f..cd3baa857abff 100644 --- a/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr @@ -4,7 +4,7 @@ error: `No` held across a suspend point, but should not be LL | let no = No {}; | ^^ LL | wheeee(&no).await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/dedup.rs:19:9 diff --git a/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr index 262657da5fe6f..cd3baa857abff 100644 --- a/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr +++ b/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr @@ -4,7 +4,7 @@ error: `No` held across a suspend point, but should not be LL | let no = No {}; | ^^ LL | wheeee(&no).await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/dedup.rs:19:9 diff --git a/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr index 7ed43d2571989..aff2f7c32b96d 100644 --- a/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr @@ -4,7 +4,7 @@ error: `No` held across a suspend point, but should not be LL | let no = No {}; | ^^ LL | wheeee(&no).await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/dedup.rs:19:9 @@ -21,7 +21,7 @@ error: `No` held across a suspend point, but should not be --> $DIR/dedup.rs:20:13 | LL | wheeee(&no).await; - | ^^ ------ the value is held across this suspend point + | ^^ ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/dedup.rs:20:13 diff --git a/tests/ui/lint/must_not_suspend/dedup.stderr b/tests/ui/lint/must_not_suspend/dedup.stderr deleted file mode 100644 index 18880f5a757e0..0000000000000 --- a/tests/ui/lint/must_not_suspend/dedup.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: `No` held across a suspend point, but should not be - --> $DIR/dedup.rs:19:13 - | -LL | wheeee(&No {}).await; - | ^^^^^ ------ the value is held across this suspend point - | -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/dedup.rs:19:13 - | -LL | wheeee(&No {}).await; - | ^^^^^ -note: the lint level is defined here - --> $DIR/dedup.rs:6:9 - | -LL | #![deny(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/lint/must_not_suspend/mutex.stderr b/tests/ui/lint/must_not_suspend/mutex.stderr index c251cb84589e0..9b5fc37a3329b 100644 --- a/tests/ui/lint/must_not_suspend/mutex.stderr +++ b/tests/ui/lint/must_not_suspend/mutex.stderr @@ -4,7 +4,7 @@ error: `MutexGuard` held across a suspend point, but should not be LL | let _guard = m.lock().unwrap(); | ^^^^^^ LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: holding a MutexGuard across suspend points can cause deadlocks, delays, and cause Futures to not implement `Send` --> $DIR/mutex.rs:8:9 diff --git a/tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr b/tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr index 180e187c1b012..348880b9c9f31 100644 --- a/tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr +++ b/tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr @@ -5,7 +5,7 @@ LL | let guard = &mut self.u; | ^^^^^ LL | LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/ref-drop-tracking.rs:19:13 diff --git a/tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr index e3628ca5e4934..fb18c2be9cb3a 100644 --- a/tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr @@ -5,7 +5,7 @@ LL | let guard = &mut self.u; | ^^^^^ LL | LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/ref.rs:22:13 diff --git a/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr index e3628ca5e4934..fb18c2be9cb3a 100644 --- a/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr +++ b/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr @@ -5,7 +5,7 @@ LL | let guard = &mut self.u; | ^^^^^ LL | LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/ref.rs:22:13 diff --git a/tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr index e9bfa08b5ddd9..6976dd3499194 100644 --- a/tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr @@ -5,7 +5,7 @@ LL | let guard = &mut self.u; | ^^^^^^ LL | LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/ref.rs:22:26 diff --git a/tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr index 6e62a228a43a5..8c8ad1f3788da 100644 --- a/tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr @@ -5,7 +5,7 @@ LL | let _guard1 = r#impl(); | ^^^^^^^ ... LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/trait.rs:24:9 @@ -25,7 +25,7 @@ LL | let _guard2 = r#dyn(); | ^^^^^^^ LL | LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/trait.rs:25:9 diff --git a/tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr index 6e62a228a43a5..8c8ad1f3788da 100644 --- a/tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr +++ b/tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr @@ -5,7 +5,7 @@ LL | let _guard1 = r#impl(); | ^^^^^^^ ... LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/trait.rs:24:9 @@ -25,7 +25,7 @@ LL | let _guard2 = r#dyn(); | ^^^^^^^ LL | LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/trait.rs:25:9 diff --git a/tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr index 6e62a228a43a5..8c8ad1f3788da 100644 --- a/tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr @@ -5,7 +5,7 @@ LL | let _guard1 = r#impl(); | ^^^^^^^ ... LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/trait.rs:24:9 @@ -25,7 +25,7 @@ LL | let _guard2 = r#dyn(); | ^^^^^^^ LL | LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point --> $DIR/trait.rs:25:9 diff --git a/tests/ui/lint/must_not_suspend/trait.stderr b/tests/ui/lint/must_not_suspend/trait.stderr deleted file mode 100644 index 6e62a228a43a5..0000000000000 --- a/tests/ui/lint/must_not_suspend/trait.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error: implementer of `Wow` held across a suspend point, but should not be - --> $DIR/trait.rs:24:9 - | -LL | let _guard1 = r#impl(); - | ^^^^^^^ -... -LL | other().await; - | ------ the value is held across this suspend point - | -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/trait.rs:24:9 - | -LL | let _guard1 = r#impl(); - | ^^^^^^^ -note: the lint level is defined here - --> $DIR/trait.rs:6:9 - | -LL | #![deny(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -error: boxed `Wow` trait object held across a suspend point, but should not be - --> $DIR/trait.rs:25:9 - | -LL | let _guard2 = r#dyn(); - | ^^^^^^^ -LL | -LL | other().await; - | ------ the value is held across this suspend point - | -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/trait.rs:25:9 - | -LL | let _guard2 = r#dyn(); - | ^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr index f89b3e341fd8c..e24cffdd0df43 100644 --- a/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr @@ -4,7 +4,7 @@ error: `Umm` held across a suspend point, but should not be LL | let _guard = bar(); | ^^^^^^ LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/unit.rs:22:9 diff --git a/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr index f89b3e341fd8c..e24cffdd0df43 100644 --- a/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr +++ b/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr @@ -4,7 +4,7 @@ error: `Umm` held across a suspend point, but should not be LL | let _guard = bar(); | ^^^^^^ LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/unit.rs:22:9 diff --git a/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr index f89b3e341fd8c..e24cffdd0df43 100644 --- a/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr @@ -4,7 +4,7 @@ error: `Umm` held across a suspend point, but should not be LL | let _guard = bar(); | ^^^^^^ LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/unit.rs:22:9 diff --git a/tests/ui/lint/must_not_suspend/unit.stderr b/tests/ui/lint/must_not_suspend/unit.stderr deleted file mode 100644 index 50ca292c2f6fd..0000000000000 --- a/tests/ui/lint/must_not_suspend/unit.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: `Umm` held across a suspend point, but should not be - --> $DIR/unit.rs:23:9 - | -LL | let _guard = bar(); - | ^^^^^^ -LL | other().await; - | ------ the value is held across this suspend point - | -note: You gotta use Umm's, ya know? - --> $DIR/unit.rs:23:9 - | -LL | let _guard = bar(); - | ^^^^^^ -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/unit.rs:23:9 - | -LL | let _guard = bar(); - | ^^^^^^ -note: the lint level is defined here - --> $DIR/unit.rs:6:9 - | -LL | #![deny(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr index 7a422891ab102..4f7b40a5efed1 100644 --- a/tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr @@ -4,7 +4,7 @@ warning: `Umm` held across a suspend point, but should not be LL | let _guard = bar(); | ^^^^^^ LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/warn.rs:24:9 diff --git a/tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr index 7a422891ab102..4f7b40a5efed1 100644 --- a/tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr +++ b/tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr @@ -4,7 +4,7 @@ warning: `Umm` held across a suspend point, but should not be LL | let _guard = bar(); | ^^^^^^ LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/warn.rs:24:9 diff --git a/tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr index 7a422891ab102..4f7b40a5efed1 100644 --- a/tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr +++ b/tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr @@ -4,7 +4,7 @@ warning: `Umm` held across a suspend point, but should not be LL | let _guard = bar(); | ^^^^^^ LL | other().await; - | ------ the value is held across this suspend point + | ----- the value is held across this suspend point | note: You gotta use Umm's, ya know? --> $DIR/warn.rs:24:9 diff --git a/tests/ui/lint/must_not_suspend/warn.stderr b/tests/ui/lint/must_not_suspend/warn.stderr deleted file mode 100644 index 7a422891ab102..0000000000000 --- a/tests/ui/lint/must_not_suspend/warn.stderr +++ /dev/null @@ -1,26 +0,0 @@ -warning: `Umm` held across a suspend point, but should not be - --> $DIR/warn.rs:24:9 - | -LL | let _guard = bar(); - | ^^^^^^ -LL | other().await; - | ------ the value is held across this suspend point - | -note: You gotta use Umm's, ya know? - --> $DIR/warn.rs:24:9 - | -LL | let _guard = bar(); - | ^^^^^^ -help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point - --> $DIR/warn.rs:24:9 - | -LL | let _guard = bar(); - | ^^^^^^ -note: the lint level is defined here - --> $DIR/warn.rs:7:9 - | -LL | #![warn(must_not_suspend)] - | ^^^^^^^^^^^^^^^^ - -warning: 1 warning emitted - diff --git a/tests/ui/lint/unaligned_references.stderr b/tests/ui/lint/unaligned_references.stderr index 775dcac678e76..5f9cecadbffa6 100644 --- a/tests/ui/lint/unaligned_references.stderr +++ b/tests/ui/lint/unaligned_references.stderr @@ -4,7 +4,8 @@ error[E0793]: reference to packed field is unaligned LL | &self.x; | ^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -13,7 +14,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &good.ptr; | ^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -22,7 +24,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &good.data; | ^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -31,7 +34,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &good.data as *const _; | ^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -40,7 +44,8 @@ error[E0793]: reference to packed field is unaligned LL | let _: *const _ = &good.data; | ^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -49,7 +54,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = good.data.clone(); | ^^^^^^^^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -58,7 +64,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &good.data2[0]; | ^^^^^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -67,7 +74,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &packed2.x; | ^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -76,7 +84,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ref = &m1.1.a; | ^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -85,7 +94,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ref = &m2.1.a; | ^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: aborting due to 10 previous errors diff --git a/tests/ui/lint/unaligned_references_external_macro.stderr b/tests/ui/lint/unaligned_references_external_macro.stderr index 5b08f433e3280..94a95c1d8fda7 100644 --- a/tests/ui/lint/unaligned_references_external_macro.stderr +++ b/tests/ui/lint/unaligned_references_external_macro.stderr @@ -9,7 +9,8 @@ LL | | } LL | | } | |_^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) = note: this error originates in the macro `unaligned_references_external_crate::mac` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/match/guards-parenthesized-and.rs b/tests/ui/match/guards-parenthesized-and.rs new file mode 100644 index 0000000000000..3a1c341f3ee5a --- /dev/null +++ b/tests/ui/match/guards-parenthesized-and.rs @@ -0,0 +1,10 @@ +// check-pass + +fn main() { + let c = 1; + let w = "T"; + match Some(5) { + None if c == 1 && (w != "Y" && w != "E") => {} + _ => panic!(), + } +} diff --git a/tests/ui/native-library-link-flags/msvc-non-utf8-output.rs b/tests/ui/native-library-link-flags/msvc-non-utf8-output.rs new file mode 100644 index 0000000000000..3fb2842d694cc --- /dev/null +++ b/tests/ui/native-library-link-flags/msvc-non-utf8-output.rs @@ -0,0 +1,6 @@ +// build-fail +// compile-flags:-C link-arg=märchenhaft +// only-msvc +// error-pattern:= note: LINK : fatal error LNK1181: +// normalize-stderr-test "(\s*\|\n)\s*= note: .*\n" -> "$1" +pub fn main() {} diff --git a/tests/ui/native-library-link-flags/msvc-non-utf8-output.stderr b/tests/ui/native-library-link-flags/msvc-non-utf8-output.stderr new file mode 100644 index 0000000000000..f843aad782c30 --- /dev/null +++ b/tests/ui/native-library-link-flags/msvc-non-utf8-output.stderr @@ -0,0 +1,7 @@ +error: linking with `link.exe` failed: exit code: 1181 + | + = note: LINK : fatal error LNK1181: cannot open input file 'märchenhaft.obj' + + +error: aborting due to previous error + diff --git a/tests/ui/packed/issue-27060.stderr b/tests/ui/packed/issue-27060.stderr index b4753284f725d..4dc31a283865c 100644 --- a/tests/ui/packed/issue-27060.stderr +++ b/tests/ui/packed/issue-27060.stderr @@ -4,7 +4,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &good.data; | ^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -13,7 +14,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &good.data2[0]; | ^^^^^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -22,7 +24,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &good.data; | ^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -31,7 +34,8 @@ error[E0793]: reference to packed field is unaligned LL | let _ = &good.data2[0]; | ^^^^^^^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: aborting due to 4 previous errors diff --git a/tests/ui/packed/packed-struct-borrow-element-64bit.stderr b/tests/ui/packed/packed-struct-borrow-element-64bit.stderr index 32943b0f07b8c..57630a4b47018 100644 --- a/tests/ui/packed/packed-struct-borrow-element-64bit.stderr +++ b/tests/ui/packed/packed-struct-borrow-element-64bit.stderr @@ -4,7 +4,8 @@ error[E0793]: reference to packed field is unaligned LL | let brw = &foo.baz; | ^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: aborting due to previous error diff --git a/tests/ui/packed/packed-struct-borrow-element.stderr b/tests/ui/packed/packed-struct-borrow-element.stderr index 29d867fc5b9ad..c1f749d6fbbbd 100644 --- a/tests/ui/packed/packed-struct-borrow-element.stderr +++ b/tests/ui/packed/packed-struct-borrow-element.stderr @@ -4,7 +4,8 @@ error[E0793]: reference to packed field is unaligned LL | let brw = &foo.baz; | ^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned @@ -13,7 +14,8 @@ error[E0793]: reference to packed field is unaligned LL | let brw = &foo.baz; | ^^^^^^^^ | - = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: aborting due to 2 previous errors diff --git a/tests/ui/panic-runtime/auxiliary/needs-unwind.rs b/tests/ui/panic-runtime/auxiliary/needs-unwind.rs index d555b531986b0..ba917b52d9a98 100644 --- a/tests/ui/panic-runtime/auxiliary/needs-unwind.rs +++ b/tests/ui/panic-runtime/auxiliary/needs-unwind.rs @@ -3,7 +3,6 @@ #![crate_type = "rlib"] #![no_std] -#![feature(c_unwind)] extern "C-unwind" fn foo() {} diff --git a/tests/ui/stability-attribute/stability-attribute-trait-impl.rs b/tests/ui/stability-attribute/stability-attribute-trait-impl.rs index 0c771ae87953c..1d138e264086c 100644 --- a/tests/ui/stability-attribute/stability-attribute-trait-impl.rs +++ b/tests/ui/stability-attribute/stability-attribute-trait-impl.rs @@ -1,4 +1,4 @@ -#![feature(staged_api, never_type, c_unwind)] +#![feature(staged_api, never_type, rust_cold_cc)] //~^ ERROR module has missing stability attribute #[stable(feature = "a", since = "1")] @@ -25,9 +25,9 @@ impl UnstableTrait for StableType {} #[unstable(feature = "h", issue = "none")] impl StableTrait for ! {} -// Note: If C-unwind is stabilized, switch this to another (unstable) ABI. +// Note: If rust_cold_cc is stabilized, switch this to another (unstable) ABI. #[unstable(feature = "i", issue = "none")] -impl StableTrait for extern "C-unwind" fn() {} +impl StableTrait for extern "rust-cold" fn() {} #[unstable(feature = "j", issue = "none")] //~^ ERROR an `#[unstable]` annotation here has no effect [ineffective_unstable_trait_impl] diff --git a/tests/ui/stability-attribute/stability-attribute-trait-impl.stderr b/tests/ui/stability-attribute/stability-attribute-trait-impl.stderr index b91a1d2e11a8a..96322c2c94509 100644 --- a/tests/ui/stability-attribute/stability-attribute-trait-impl.stderr +++ b/tests/ui/stability-attribute/stability-attribute-trait-impl.stderr @@ -18,7 +18,7 @@ LL | #[unstable(feature = "k", issue = "none")] error: module has missing stability attribute --> $DIR/stability-attribute-trait-impl.rs:1:1 | -LL | / #![feature(staged_api, never_type, c_unwind)] +LL | / #![feature(staged_api, never_type, rust_cold_cc)] LL | | LL | | LL | | #[stable(feature = "a", since = "1")] diff --git a/tests/ui/suggestions/issue-96555.stderr b/tests/ui/suggestions/issue-96555.stderr index 9a8a183dc2d41..1a1e069f09eb4 100644 --- a/tests/ui/suggestions/issue-96555.stderr +++ b/tests/ui/suggestions/issue-96555.stderr @@ -1,8 +1,8 @@ error[E0277]: `()` is not a future - --> $DIR/issue-96555.rs:4:12 + --> $DIR/issue-96555.rs:4:13 | LL | m::f1().await; - | -------^^^^^^ `()` is not a future + | ------- ^^^^^ `()` is not a future | | | this call returns `()` | @@ -20,10 +20,10 @@ LL | pub async fn f1() {} | +++++ error[E0277]: `()` is not a future - --> $DIR/issue-96555.rs:5:12 + --> $DIR/issue-96555.rs:5:13 | LL | m::f2().await; - | -------^^^^^^ `()` is not a future + | ------- ^^^^^ `()` is not a future | | | this call returns `()` | @@ -41,10 +41,10 @@ LL | pub(crate) async fn f2() {} | +++++ error[E0277]: `()` is not a future - --> $DIR/issue-96555.rs:6:12 + --> $DIR/issue-96555.rs:6:13 | LL | m::f3().await; - | -------^^^^^^ `()` is not a future + | ------- ^^^^^ `()` is not a future | | | this call returns `()` | diff --git a/tests/ui/traits/unsend-future.stderr b/tests/ui/traits/unsend-future.stderr index 4aaa7c4a92426..6ce1cf452f459 100644 --- a/tests/ui/traits/unsend-future.stderr +++ b/tests/ui/traits/unsend-future.stderr @@ -6,12 +6,12 @@ LL | require_handler(handler) | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `*const i32` note: future is not `Send` as this value is used across an await - --> $DIR/unsend-future.rs:15:13 + --> $DIR/unsend-future.rs:15:14 | LL | let a = &1 as *const i32; | - has type `*const i32` which is not `Send` LL | async {}.await; - | ^^^^^^ await occurs here, with `a` maybe used later + | ^^^^^ await occurs here, with `a` maybe used later LL | } | - `a` is later dropped here note: required by a bound in `require_handler` diff --git a/tests/ui/unwind-abis/feature-gate-c-unwind-enabled.rs b/tests/ui/unwind-abis/feature-gate-c-unwind-enabled.rs deleted file mode 100644 index 6ff5dbda2d560..0000000000000 --- a/tests/ui/unwind-abis/feature-gate-c-unwind-enabled.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Test that the "C-unwind" ABI is feature-gated, and *can* be used when the -// `c_unwind` feature gate is enabled. - -// check-pass - -#![feature(c_unwind)] - -extern "C-unwind" fn f() {} - -fn main() { - f(); -} diff --git a/tests/ui/unwind-abis/feature-gate-c-unwind.rs b/tests/ui/unwind-abis/feature-gate-c-unwind.rs deleted file mode 100644 index ba72f74f20ce6..0000000000000 --- a/tests/ui/unwind-abis/feature-gate-c-unwind.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Test that the "C-unwind" ABI is feature-gated, and cannot be used when the -// `c_unwind` feature gate is not used. - -#![allow(ffi_unwind_calls)] -//~^ WARNING unknown lint: `ffi_unwind_calls` -//~| WARNING unknown lint: `ffi_unwind_calls` - -extern "C-unwind" fn f() {} -//~^ ERROR C-unwind ABI is experimental and subject to change [E0658] - -fn main() { - f(); -} diff --git a/tests/ui/unwind-abis/feature-gate-c-unwind.stderr b/tests/ui/unwind-abis/feature-gate-c-unwind.stderr deleted file mode 100644 index 214ddc45ce901..0000000000000 --- a/tests/ui/unwind-abis/feature-gate-c-unwind.stderr +++ /dev/null @@ -1,33 +0,0 @@ -warning: unknown lint: `ffi_unwind_calls` - --> $DIR/feature-gate-c-unwind.rs:4:1 - | -LL | #![allow(ffi_unwind_calls)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `ffi_unwind_calls` lint is unstable - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - = note: `#[warn(unknown_lints)]` on by default - -error[E0658]: C-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-c-unwind.rs:8:8 - | -LL | extern "C-unwind" fn f() {} - | ^^^^^^^^^^ - | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -warning: unknown lint: `ffi_unwind_calls` - --> $DIR/feature-gate-c-unwind.rs:4:1 - | -LL | #![allow(ffi_unwind_calls)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the `ffi_unwind_calls` lint is unstable - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -error: aborting due to previous error; 2 warnings emitted - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/unwind-abis/feature-gate-c_unwind.rs b/tests/ui/unwind-abis/feature-gate-c_unwind.rs new file mode 100644 index 0000000000000..d73fe3e0bdada --- /dev/null +++ b/tests/ui/unwind-abis/feature-gate-c_unwind.rs @@ -0,0 +1,4 @@ +// ignore-test + +// After partial stabilisation, `c_unwind` only contains codegen behaviour changes +// and are tested in `src/test/codegen/unwind-abis` diff --git a/tests/ui/unwind-abis/feature-gate-stdcall-unwind.rs b/tests/ui/unwind-abis/feature-gate-stdcall-unwind.rs deleted file mode 100644 index cfa8eb3cad04b..0000000000000 --- a/tests/ui/unwind-abis/feature-gate-stdcall-unwind.rs +++ /dev/null @@ -1,30 +0,0 @@ -// gate-test-c_unwind -// needs-llvm-components: x86 -// compile-flags: --target=i686-pc-windows-msvc --crate-type=rlib -#![no_core] -#![feature(no_core, lang_items)] -#[lang="sized"] -trait Sized { } - -// Test that the "stdcall-unwind" ABI is feature-gated, and cannot be used when -// the `c_unwind` feature gate is not used. - -extern "stdcall-unwind" fn fu() {} //~ ERROR stdcall-unwind ABI is experimental - -trait T { - extern "stdcall-unwind" fn mu(); //~ ERROR stdcall-unwind ABI is experimental - extern "stdcall-unwind" fn dmu() {} //~ ERROR stdcall-unwind ABI is experimental -} - -struct S; -impl T for S { - extern "stdcall-unwind" fn mu() {} //~ ERROR stdcall-unwind ABI is experimental -} - -impl S { - extern "stdcall-unwind" fn imu() {} //~ ERROR stdcall-unwind ABI is experimental -} - -type TAU = extern "stdcall-unwind" fn(); //~ ERROR stdcall-unwind ABI is experimental - -extern "stdcall-unwind" {} //~ ERROR stdcall-unwind ABI is experimental diff --git a/tests/ui/unwind-abis/feature-gate-stdcall-unwind.stderr b/tests/ui/unwind-abis/feature-gate-stdcall-unwind.stderr deleted file mode 100644 index c2cce0e1193cd..0000000000000 --- a/tests/ui/unwind-abis/feature-gate-stdcall-unwind.stderr +++ /dev/null @@ -1,66 +0,0 @@ -error[E0658]: stdcall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-stdcall-unwind.rs:12:8 - | -LL | extern "stdcall-unwind" fn fu() {} - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -error[E0658]: stdcall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-stdcall-unwind.rs:15:12 - | -LL | extern "stdcall-unwind" fn mu(); - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -error[E0658]: stdcall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-stdcall-unwind.rs:16:12 - | -LL | extern "stdcall-unwind" fn dmu() {} - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -error[E0658]: stdcall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-stdcall-unwind.rs:21:12 - | -LL | extern "stdcall-unwind" fn mu() {} - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -error[E0658]: stdcall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-stdcall-unwind.rs:25:12 - | -LL | extern "stdcall-unwind" fn imu() {} - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -error[E0658]: stdcall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-stdcall-unwind.rs:28:19 - | -LL | type TAU = extern "stdcall-unwind" fn(); - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -error[E0658]: stdcall-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-stdcall-unwind.rs:30:8 - | -LL | extern "stdcall-unwind" {} - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -error: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/unwind-abis/feature-gate-system-unwind.rs b/tests/ui/unwind-abis/feature-gate-system-unwind.rs deleted file mode 100644 index 26c2de4e81767..0000000000000 --- a/tests/ui/unwind-abis/feature-gate-system-unwind.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Test that the "system-unwind" ABI is feature-gated, and cannot be used when -// the `c_unwind` feature gate is not used. - -extern "system-unwind" fn f() {} -//~^ ERROR system-unwind ABI is experimental and subject to change [E0658] - -fn main() { - f(); -} diff --git a/tests/ui/unwind-abis/feature-gate-system-unwind.stderr b/tests/ui/unwind-abis/feature-gate-system-unwind.stderr deleted file mode 100644 index 87877336475b4..0000000000000 --- a/tests/ui/unwind-abis/feature-gate-system-unwind.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: system-unwind ABI is experimental and subject to change - --> $DIR/feature-gate-system-unwind.rs:4:8 - | -LL | extern "system-unwind" fn f() {} - | ^^^^^^^^^^^^^^^ - | - = note: see issue #74990 <https://github.com/rust-lang/rust/issues/74990> for more information - = help: add `#![feature(c_unwind)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/unwind-abis/ffi-unwind-calls-lint.rs b/tests/ui/unwind-abis/ffi-unwind-calls-lint.rs index 9a324f00435c7..8f000737656a2 100644 --- a/tests/ui/unwind-abis/ffi-unwind-calls-lint.rs +++ b/tests/ui/unwind-abis/ffi-unwind-calls-lint.rs @@ -1,7 +1,6 @@ // build-pass // needs-unwind -#![feature(c_unwind)] #![warn(ffi_unwind_calls)] mod foo { diff --git a/tests/ui/unwind-abis/ffi-unwind-calls-lint.stderr b/tests/ui/unwind-abis/ffi-unwind-calls-lint.stderr index 937a2b3dff8b6..cf8a7782e35ee 100644 --- a/tests/ui/unwind-abis/ffi-unwind-calls-lint.stderr +++ b/tests/ui/unwind-abis/ffi-unwind-calls-lint.stderr @@ -1,17 +1,17 @@ warning: call to foreign function with FFI-unwind ABI - --> $DIR/ffi-unwind-calls-lint.rs:20:14 + --> $DIR/ffi-unwind-calls-lint.rs:19:14 | LL | unsafe { foo(); } | ^^^^^ call to foreign function with FFI-unwind ABI | note: the lint level is defined here - --> $DIR/ffi-unwind-calls-lint.rs:5:9 + --> $DIR/ffi-unwind-calls-lint.rs:4:9 | LL | #![warn(ffi_unwind_calls)] | ^^^^^^^^^^^^^^^^ warning: call to function pointer with FFI-unwind ABI - --> $DIR/ffi-unwind-calls-lint.rs:24:5 + --> $DIR/ffi-unwind-calls-lint.rs:23:5 | LL | ptr(); | ^^^^^ call to function pointer with FFI-unwind ABI diff --git a/triagebot.toml b/triagebot.toml index 917acce901bda..89867b63d64f8 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -367,6 +367,10 @@ cc = ["@lcnr", "@compiler-errors"] message = "Some changes occurred in diagnostic error codes" cc = ["@GuillaumeGomez"] +[mentions."compiler/rustc_mir_build/src/thir/pattern"] +message = "Some changes might have occurred in exhaustiveness checking" +cc = ["@Nadrieril"] + [mentions."library"] message = """ Hey! It looks like you've submitted a new PR for the library teams! diff --git a/x.py b/x.py index 5dee953a31899..b8cdf67712c43 100755 --- a/x.py +++ b/x.py @@ -4,26 +4,29 @@ # This file is only a "symlink" to bootstrap.py, all logic should go there. -import os -import sys +# Parts of `bootstrap.py` use the `multiprocessing` module, so this entry point +# must use the normal `if __name__ == '__main__':` convention to avoid problems. +if __name__ == '__main__': + import os + import sys -# If this is python2, check if python3 is available and re-execute with that -# interpreter. Only python3 allows downloading CI LLVM. -# -# This matters if someone's system `python` is python2. -if sys.version_info.major < 3: - try: - os.execvp("py", ["py", "-3"] + sys.argv) - except OSError: + # If this is python2, check if python3 is available and re-execute with that + # interpreter. Only python3 allows downloading CI LLVM. + # + # This matters if someone's system `python` is python2. + if sys.version_info.major < 3: try: - os.execvp("python3", ["python3"] + sys.argv) + os.execvp("py", ["py", "-3"] + sys.argv) except OSError: - # Python 3 isn't available, fall back to python 2 - pass + try: + os.execvp("python3", ["python3"] + sys.argv) + except OSError: + # Python 3 isn't available, fall back to python 2 + pass -rust_dir = os.path.dirname(os.path.abspath(__file__)) -# For the import below, have Python search in src/bootstrap first. -sys.path.insert(0, os.path.join(rust_dir, "src", "bootstrap")) + rust_dir = os.path.dirname(os.path.abspath(__file__)) + # For the import below, have Python search in src/bootstrap first. + sys.path.insert(0, os.path.join(rust_dir, "src", "bootstrap")) -import bootstrap -bootstrap.main() + import bootstrap + bootstrap.main()