Skip to content

Rollup of 5 pull requests #107727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Feb 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/parse.ftl
Original file line number Diff line number Diff line change
@@ -475,6 +475,9 @@ parse_unexpected_token_after_struct_name_found_other = expected `where`, `{"{"}`
parse_unexpected_self_in_generic_parameters = unexpected keyword `Self` in generic parameters
.note = you cannot use `Self` as a generic parameter because it is reserved for associated items
parse_unexpected_default_value_for_lifetime_in_generic_parameters = unexpected default lifetime parameter
.label = lifetime parameters cannot have default values
parse_multiple_where_clauses = cannot define duplicate `where` clauses on an item
.label = previous `where` clause starts here
.suggestion = consider joining the two `where` clauses into one
1 change: 1 addition & 0 deletions compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
@@ -60,6 +60,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|| self.suggest_clone_for_ref(err, expr, expr_ty, expected)
|| self.suggest_into(err, expr, expr_ty, expected)
|| self.suggest_floating_point_literal(err, expr, expected)
|| self.suggest_null_ptr_for_literal_zero_given_to_ptr_arg(err, expr, expected)
|| self.note_result_coercion(err, expr, expected, expr_ty);
if !suggested {
self.point_at_expr_source_of_inferred_type(err, expr, expr_ty, expected, expr.span);
16 changes: 16 additions & 0 deletions compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
@@ -921,6 +921,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
kind: hir::ImplItemKind::Fn(ref sig, ..),
..
}) => Some((&sig.decl, ident, false)),
Node::Expr(&hir::Expr {
hir_id,
kind: hir::ExprKind::Closure(..),
..
}) if let Some(Node::Expr(&hir::Expr {
hir_id,
kind: hir::ExprKind::Call(..),
..
})) = self.tcx.hir().find_parent(hir_id) &&
let Some(Node::Item(&hir::Item {
ident,
kind: hir::ItemKind::Fn(ref sig, ..),
..
})) = self.tcx.hir().find_parent(hir_id) => {
Some((&sig.decl, ident, ident.name != sym::main))
},
_ => None,
}
}
74 changes: 73 additions & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ use rustc_hir::{
use rustc_hir_analysis::astconv::AstConv;
use rustc_infer::traits::{self, StatementAsExpression};
use rustc_middle::lint::in_external_macro;
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{
self, suggest_constraining_type_params, Binder, DefIdTree, IsSuggestable, ToPredicate, Ty,
TypeVisitable,
@@ -704,10 +705,38 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
hir::FnRetTy::Return(ty) => {
let span = ty.span;

if let hir::TyKind::OpaqueDef(item_id, ..) = ty.kind
&& let hir::Node::Item(hir::Item {
kind: hir::ItemKind::OpaqueTy(op_ty),
..
}) = self.tcx.hir().get(item_id.hir_id())
&& let hir::OpaqueTy {
bounds: [bound], ..
} = op_ty
&& let hir::GenericBound::LangItemTrait(
hir::LangItem::Future, _, _, generic_args) = bound
&& let hir::GenericArgs { bindings: [ty_binding], .. } = generic_args
&& let hir::TypeBinding { kind, .. } = ty_binding
&& let hir::TypeBindingKind::Equality { term } = kind
&& let hir::Term::Ty(term_ty) = term {
// Check if async function's return type was omitted.
// Don't emit suggestions if the found type is `impl Future<...>`.
debug!("suggest_missing_return_type: found = {:?}", found);
if found.is_suggestable(self.tcx, false) {
if term_ty.span.is_empty() {
err.subdiagnostic(AddReturnTypeSuggestion::Add { span, found: found.to_string() });
return true;
} else {
err.subdiagnostic(ExpectedReturnTypeLabel::Other { span, expected });
}
}
}

// Only point to return type if the expected type is the return type, as if they
// are not, the expectation must have been caused by something else.
debug!("suggest_missing_return_type: return type {:?} node {:?}", ty, ty.kind);
let span = ty.span;
let ty = self.astconv().ast_ty_to_ty(ty);
debug!("suggest_missing_return_type: return type {:?}", ty);
debug!("suggest_missing_return_type: expected type {:?}", ty);
@@ -1244,6 +1273,49 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

/// Suggest providing `std::ptr::null()` or `std::ptr::null_mut()` if they
/// pass in a literal 0 to an raw pointer.
#[instrument(skip(self, err))]
pub(crate) fn suggest_null_ptr_for_literal_zero_given_to_ptr_arg(
&self,
err: &mut Diagnostic,
expr: &hir::Expr<'_>,
expected_ty: Ty<'tcx>,
) -> bool {
// Expected type needs to be a raw pointer.
let ty::RawPtr(ty::TypeAndMut { mutbl, .. }) = expected_ty.kind() else {
return false;
};

// Provided expression needs to be a literal `0`.
let ExprKind::Lit(Spanned {
node: rustc_ast::LitKind::Int(0, _),
span,
}) = expr.kind else {
return false;
};

// We need to find a null pointer symbol to suggest
let null_sym = match mutbl {
hir::Mutability::Not => sym::ptr_null,
hir::Mutability::Mut => sym::ptr_null_mut,
};
let Some(null_did) = self.tcx.get_diagnostic_item(null_sym) else {
return false;
};
let null_path_str = with_no_trimmed_paths!(self.tcx.def_path_str(null_did));

// We have satisfied all requirements to provide a suggestion. Emit it.
err.span_suggestion(
span,
format!("if you meant to create a null pointer, use `{null_path_str}()`"),
null_path_str + "()",
Applicability::MachineApplicable,
);

true
}

pub(crate) fn suggest_associated_const(
&self,
err: &mut Diagnostic,
4 changes: 2 additions & 2 deletions compiler/rustc_mir_dataflow/src/value_analysis.rs
Original file line number Diff line number Diff line change
@@ -790,7 +790,7 @@ impl<V, T> TryFrom<ProjectionElem<V, T>> for TrackElem {
}

/// Invokes `f` on all direct fields of `ty`.
fn iter_fields<'tcx>(
pub fn iter_fields<'tcx>(
ty: Ty<'tcx>,
tcx: TyCtxt<'tcx>,
mut f: impl FnMut(Option<VariantIdx>, Field, Ty<'tcx>),
@@ -824,7 +824,7 @@ fn iter_fields<'tcx>(
}

/// Returns all locals with projections that have their reference or address taken.
fn excluded_locals(body: &Body<'_>) -> IndexVec<Local, bool> {
pub fn excluded_locals(body: &Body<'_>) -> IndexVec<Local, bool> {
struct Collector {
result: IndexVec<Local, bool>,
}
431 changes: 253 additions & 178 deletions compiler/rustc_mir_transform/src/sroa.rs

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions compiler/rustc_parse/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1601,6 +1601,14 @@ pub(crate) struct UnexpectedSelfInGenericParameters {
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(parse_unexpected_default_value_for_lifetime_in_generic_parameters)]
pub(crate) struct UnexpectedDefaultValueForLifetimeInGenericParameters {
#[primary_span]
#[label]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(parse_multiple_where_clauses)]
pub(crate) struct MultipleWhereClauses {
17 changes: 16 additions & 1 deletion compiler/rustc_parse/src/parser/generics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::errors::{
MultipleWhereClauses, UnexpectedSelfInGenericParameters, WhereClauseBeforeTupleStructBody,
MultipleWhereClauses, UnexpectedDefaultValueForLifetimeInGenericParameters,
UnexpectedSelfInGenericParameters, WhereClauseBeforeTupleStructBody,
WhereClauseBeforeTupleStructBodySugg,
};

@@ -145,6 +146,20 @@ impl<'a> Parser<'a> {
} else {
(None, Vec::new())
};

if this.check_noexpect(&token::Eq)
&& this.look_ahead(1, |t| t.is_lifetime())
{
let lo = this.token.span;
// Parse `= 'lifetime`.
this.bump(); // `=`
this.bump(); // `'lifetime`
let span = lo.to(this.prev_token.span);
this.sess.emit_err(
UnexpectedDefaultValueForLifetimeInGenericParameters { span },
);
}

Some(ast::GenericParam {
ident: lifetime.ident,
id: lifetime.id,
48 changes: 14 additions & 34 deletions src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
@@ -105,10 +105,9 @@ Original by Dempfi (https://github.com/dempfi/ayu)
--scrape-example-code-wrapper-background-end: rgba(15, 20, 25, 0);
}

h1, h2, h3, h4 {
color: white;
}
h1 a {
h1, h2, h3, h4,
h1 a, .sidebar h2 a, .sidebar h3 a,
#source-sidebar > .title {
color: #fff;
}
h4 {
@@ -118,24 +117,22 @@ h4 {
.docblock code {
color: #ffb454;
}
.code-header {
color: #e6e1cf;
}
.docblock pre > code, pre > code {
color: #e6e1cf;
}
.item-info code {
color: #e6e1cf;
}
.docblock a > code {
color: #39AFD7 !important;
}
pre, .rustdoc.source .example-wrap {
.code-header,
.docblock pre > code,
pre, pre > code,
.item-info code,
.rustdoc.source .example-wrap {
color: #e6e1cf;
}

.sidebar .current,
.sidebar a:hover {
.sidebar a:hover,
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
#source-sidebar div.files > a:focus, details.dir-entry summary:focus,
#source-sidebar div.files > a.selected {
color: #ffb44c;
}

@@ -149,27 +146,19 @@ pre, .rustdoc.source .example-wrap {
border-right: 1px solid #ffb44c;
}

.search-results a:hover {
color: #fff !important;
background-color: #3c3c3c;
}

.search-results a:hover,
.search-results a:focus {
color: #fff !important;
background-color: #3c3c3c;
}

.search-results a {
color: #0096cf;
}
.search-results a div.desc {
color: #c5c5c5;
}

.sidebar h2 a,
.sidebar h3 a {
color: white;
}

.result-name .primitive > i, .result-name .keyword > i {
color: #788797;
}
@@ -189,12 +178,3 @@ pre, .rustdoc.source .example-wrap {
#settings-menu > a img {
filter: invert(100);
}

#source-sidebar > .title {
color: #fff;
}
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
#source-sidebar div.files > a:focus, details.dir-entry summary:focus,
#source-sidebar div.files > a.selected {
color: #ffb44c;
}
58 changes: 30 additions & 28 deletions tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@
let mut _6: u8; // in scope 0 at $DIR/const_debuginfo.rs:+4:15: +4:16
let mut _7: u8; // in scope 0 at $DIR/const_debuginfo.rs:+4:19: +4:20
let mut _8: u8; // in scope 0 at $DIR/const_debuginfo.rs:+4:23: +4:24
let mut _14: u32; // in scope 0 at $DIR/const_debuginfo.rs:+13:13: +13:16
let mut _15: u32; // in scope 0 at $DIR/const_debuginfo.rs:+13:19: +13:22
let mut _12: u32; // in scope 0 at $DIR/const_debuginfo.rs:+13:13: +13:16
let mut _13: u32; // in scope 0 at $DIR/const_debuginfo.rs:+13:19: +13:22
scope 1 {
- debug x => _1; // in scope 1 at $DIR/const_debuginfo.rs:+1:9: +1:10
+ debug x => const 1_u8; // in scope 1 at $DIR/const_debuginfo.rs:+1:9: +1:10
@@ -29,18 +29,21 @@
scope 5 {
- debug s => _9; // in scope 5 at $DIR/const_debuginfo.rs:+6:9: +6:10
+ debug s => const "hello, world!"; // in scope 5 at $DIR/const_debuginfo.rs:+6:9: +6:10
let _10: (bool, bool, u32); // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10
let _14: bool; // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10
let _15: bool; // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10
let _16: u32; // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10
scope 6 {
debug f => _10; // in scope 6 at $DIR/const_debuginfo.rs:+8:9: +8:10
let _11: std::option::Option<u16>; // in scope 6 at $DIR/const_debuginfo.rs:+10:9: +10:10
debug f => (bool, bool, u32){ .0 => _14, .1 => _15, .2 => _16, }; // in scope 6 at $DIR/const_debuginfo.rs:+8:9: +8:10
let _10: std::option::Option<u16>; // in scope 6 at $DIR/const_debuginfo.rs:+10:9: +10:10
scope 7 {
debug o => _11; // in scope 7 at $DIR/const_debuginfo.rs:+10:9: +10:10
let _12: Point; // in scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10
debug o => _10; // in scope 7 at $DIR/const_debuginfo.rs:+10:9: +10:10
let _17: u32; // in scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10
let _18: u32; // in scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10
scope 8 {
debug p => _12; // in scope 8 at $DIR/const_debuginfo.rs:+12:9: +12:10
let _13: u32; // in scope 8 at $DIR/const_debuginfo.rs:+13:9: +13:10
debug p => Point{ .0 => _17, .1 => _18, }; // in scope 8 at $DIR/const_debuginfo.rs:+12:9: +12:10
let _11: u32; // in scope 8 at $DIR/const_debuginfo.rs:+13:9: +13:10
scope 9 {
- debug a => _13; // in scope 9 at $DIR/const_debuginfo.rs:+13:9: +13:10
- debug a => _11; // in scope 9 at $DIR/const_debuginfo.rs:+13:9: +13:10
+ debug a => const 64_u32; // in scope 9 at $DIR/const_debuginfo.rs:+13:9: +13:10
}
}
@@ -66,24 +69,23 @@
// mir::Constant
// + span: $DIR/const_debuginfo.rs:14:13: 14:28
// + literal: Const { ty: &str, val: Value(Slice(..)) }
StorageLive(_10); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10
_10 = (const true, const false, const 123_u32); // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34
StorageLive(_11); // scope 6 at $DIR/const_debuginfo.rs:+10:9: +10:10
_11 = Option::<u16>::Some(const 99_u16); // scope 6 at $DIR/const_debuginfo.rs:+10:13: +10:24
StorageLive(_12); // scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10
_12 = Point { x: const 32_u32, y: const 32_u32 }; // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35
StorageLive(_13); // scope 8 at $DIR/const_debuginfo.rs:+13:9: +13:10
StorageLive(_14); // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:16
_14 = const 32_u32; // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:16
StorageLive(_15); // scope 8 at $DIR/const_debuginfo.rs:+13:19: +13:22
_15 = const 32_u32; // scope 8 at $DIR/const_debuginfo.rs:+13:19: +13:22
_13 = const 64_u32; // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:22
StorageDead(_15); // scope 8 at $DIR/const_debuginfo.rs:+13:21: +13:22
StorageDead(_14); // scope 8 at $DIR/const_debuginfo.rs:+13:21: +13:22
StorageDead(_13); // scope 8 at $DIR/const_debuginfo.rs:+14:1: +14:2
StorageDead(_12); // scope 7 at $DIR/const_debuginfo.rs:+14:1: +14:2
StorageDead(_11); // scope 6 at $DIR/const_debuginfo.rs:+14:1: +14:2
StorageDead(_10); // scope 5 at $DIR/const_debuginfo.rs:+14:1: +14:2
StorageLive(_14); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10
StorageLive(_15); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10
StorageLive(_16); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10
_14 = const true; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34
_15 = const false; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34
_16 = const 123_u32; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34
StorageLive(_10); // scope 6 at $DIR/const_debuginfo.rs:+10:9: +10:10
_10 = Option::<u16>::Some(const 99_u16); // scope 6 at $DIR/const_debuginfo.rs:+10:13: +10:24
_17 = const 32_u32; // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35
_18 = const 32_u32; // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35
StorageLive(_11); // scope 8 at $DIR/const_debuginfo.rs:+13:9: +13:10
_11 = const 64_u32; // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:22
StorageDead(_11); // scope 8 at $DIR/const_debuginfo.rs:+14:1: +14:2
StorageDead(_10); // scope 6 at $DIR/const_debuginfo.rs:+14:1: +14:2
StorageDead(_14); // scope 5 at $DIR/const_debuginfo.rs:+14:1: +14:2
StorageDead(_15); // scope 5 at $DIR/const_debuginfo.rs:+14:1: +14:2
StorageDead(_16); // scope 5 at $DIR/const_debuginfo.rs:+14:1: +14:2
StorageDead(_9); // scope 4 at $DIR/const_debuginfo.rs:+14:1: +14:2
StorageDead(_4); // scope 3 at $DIR/const_debuginfo.rs:+14:1: +14:2
return; // scope 0 at $DIR/const_debuginfo.rs:+14:2: +14:2
Original file line number Diff line number Diff line change
@@ -3,25 +3,27 @@

fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_aggregate.rs:+0:11: +0:11
let mut _1: (i32, i32); // in scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14
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
scope 1 {
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
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
scope 2 {
debug y => _2; // in scope 2 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10
debug y => (i32, i32){ .0 => _3, .1 => _2, }; // in scope 2 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10
}
}

bb0: {
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(_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(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10
- _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
- _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
StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2
StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2
StorageDead(_4); // 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
}
}
Original file line number Diff line number Diff line change
@@ -9,9 +9,10 @@
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, i32); // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4: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
scope 3 {
debug y => _3; // in scope 3 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10
debug y => (i32, i32){ .0 => _3, .1 => _4, }; // in scope 3 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10
}
}
}
@@ -23,8 +24,11 @@
_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
_3 = _1; // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:13: +4:14
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
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
Original file line number Diff line number Diff line change
@@ -4,16 +4,17 @@
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 _3: i32; // in scope 0 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12
let mut _2: 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 _2: (i32, i32); // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14
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
scope 2 {
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
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
scope 3 {
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
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
scope 4 {
debug z => _5; // in scope 4 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10
}
@@ -30,21 +31,17 @@
}

bb1: {
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
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
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
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
}
Original file line number Diff line number Diff line change
@@ -9,15 +9,15 @@
let _5: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:32: +2:33
let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
let mut _9: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
scope 1 {
debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
let _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
scope 2 {
debug y => _3; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
let _8: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
scope 3 {
debug z => _8; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
debug z => _9; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
}
}
}
@@ -50,13 +50,7 @@
+ _3 = const 3_i32; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
StorageDead(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
_9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
- _8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
+ _8 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
StorageDead(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
_9 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2
Original file line number Diff line number Diff line change
@@ -9,15 +9,15 @@
let _5: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:32: +2:33
let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
let mut _9: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
scope 1 {
debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
let _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
scope 2 {
debug y => _3; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
let _8: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
scope 3 {
debug z => _8; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
debug z => _9; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
}
}
}
@@ -50,13 +50,7 @@
+ _3 = const 3_i32; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
StorageDead(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
_9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
- _8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
+ _8 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
StorageDead(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
_9 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2
Original file line number Diff line number Diff line change
@@ -3,12 +3,12 @@
fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11
let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
let mut _3: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
scope 1 {
debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
scope 2 {
debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
let _3: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
scope 3 {
debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
}
@@ -18,8 +18,6 @@ fn main() -> () {
bb0: {
StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
StorageLive(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
StorageDead(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2
Original file line number Diff line number Diff line change
@@ -3,12 +3,12 @@
fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11
let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
let mut _3: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
scope 1 {
debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
scope 2 {
debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
let _3: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
scope 3 {
debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
}
@@ -18,8 +18,6 @@ fn main() -> () {
bb0: {
StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
StorageLive(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
StorageDead(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2
Original file line number Diff line number Diff line change
@@ -10,6 +10,8 @@
let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
+ let mut _10: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
+ let mut _11: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
scope 1 {
debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
let _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
@@ -45,10 +47,20 @@
StorageDead(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
_9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
_8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
- StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
- _9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
- _8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
- StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
+ StorageLive(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
+ StorageLive(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
+ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
+ _10 = const 12_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
+ _11 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
+ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
+ _8 = _11; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
+ StorageDead(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
+ StorageDead(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
+ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
nop; // scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +4:2
StorageDead(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
Original file line number Diff line number Diff line change
@@ -10,6 +10,8 @@
let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34
let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
+ let mut _10: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
+ let mut _11: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
scope 1 {
debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
let _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
@@ -45,10 +47,20 @@
StorageDead(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35
StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
_9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
_8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
- StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
- _9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
- _8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
- StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
+ StorageLive(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
+ StorageLive(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
+ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
+ _10 = const 12_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
+ _11 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
+ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
+ _8 = _11; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38
+ StorageDead(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
+ StorageDead(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
+ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39
nop; // scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +4:2
StorageDead(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
Original file line number Diff line number Diff line change
@@ -3,12 +3,12 @@
fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11
let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
let mut _3: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
scope 1 {
debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
scope 2 {
debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
let _3: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
scope 3 {
debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
}
@@ -18,8 +18,6 @@ fn main() -> () {
bb0: {
StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
StorageLive(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
StorageDead(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2
Original file line number Diff line number Diff line change
@@ -3,12 +3,12 @@
fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11
let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
let mut _3: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36
scope 1 {
debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
scope 2 {
debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
let _3: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
scope 3 {
debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
}
@@ -18,8 +18,6 @@ fn main() -> () {
bb0: {
StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10
StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10
StorageLive(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10
StorageDead(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2
return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2
14 changes: 2 additions & 12 deletions tests/mir-opt/simple_option_map_e2e.ezmap.PreCodegen.after.mir
Original file line number Diff line number Diff line change
@@ -4,25 +4,22 @@ fn ezmap(_1: Option<i32>) -> Option<i32> {
debug x => _1; // in scope 0 at $DIR/simple_option_map_e2e.rs:+0:14: +0:15
let mut _0: std::option::Option<i32>; // return place in scope 0 at $DIR/simple_option_map_e2e.rs:+0:33: +0:44
let mut _2: [closure@$DIR/simple_option_map_e2e.rs:14:12: 14:15]; // in scope 0 at $DIR/simple_option_map_e2e.rs:+1:12: +1:21
let mut _7: i32; // in scope 0 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
scope 1 (inlined map::<i32, i32, [closure@$DIR/simple_option_map_e2e.rs:14:12: 14:15]>) { // at $DIR/simple_option_map_e2e.rs:14:5: 14:22
debug slf => _1; // in scope 1 at $DIR/simple_option_map_e2e.rs:2:17: 2:20
debug f => _2; // in scope 1 at $DIR/simple_option_map_e2e.rs:2:33: 2:34
let mut _3: isize; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:9: 7:16
let _4: i32; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:14: 7:15
let mut _5: i32; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
let mut _6: (i32,); // in scope 1 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
scope 2 {
debug x => _4; // in scope 2 at $DIR/simple_option_map_e2e.rs:7:14: 7:15
scope 3 (inlined ezmap::{closure#0}) { // at $DIR/simple_option_map_e2e.rs:7:25: 7:29
debug n => _7; // in scope 3 at $DIR/simple_option_map_e2e.rs:+1:13: +1:14
debug n => _4; // in scope 3 at $DIR/simple_option_map_e2e.rs:+1:13: +1:14
}
}
}

bb0: {
StorageLive(_2); // scope 0 at $DIR/simple_option_map_e2e.rs:+1:12: +1:21
StorageLive(_4); // scope 0 at $DIR/simple_option_map_e2e.rs:+1:5: +1:22
_3 = discriminant(_1); // scope 1 at $DIR/simple_option_map_e2e.rs:6:11: 6:14
switchInt(move _3) -> [0: bb1, 1: bb3, otherwise: bb2]; // scope 1 at $DIR/simple_option_map_e2e.rs:6:5: 6:14
}
@@ -39,20 +36,13 @@ fn ezmap(_1: Option<i32>) -> Option<i32> {
bb3: {
_4 = move ((_1 as Some).0: i32); // scope 1 at $DIR/simple_option_map_e2e.rs:7:14: 7:15
StorageLive(_5); // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
StorageLive(_6); // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
_6 = (move _4,); // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
StorageLive(_7); // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
_7 = move (_6.0: i32); // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
_5 = Add(_7, const 1_i32); // scope 3 at $DIR/simple_option_map_e2e.rs:+1:16: +1:21
StorageDead(_7); // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29
StorageDead(_6); // scope 2 at $DIR/simple_option_map_e2e.rs:7:28: 7:29
_5 = Add(_4, const 1_i32); // scope 3 at $DIR/simple_option_map_e2e.rs:+1:16: +1:21
_0 = Option::<i32>::Some(move _5); // scope 2 at $DIR/simple_option_map_e2e.rs:7:20: 7:30
StorageDead(_5); // scope 2 at $DIR/simple_option_map_e2e.rs:7:29: 7:30
goto -> bb4; // scope 1 at $DIR/simple_option_map_e2e.rs:10:1: 10:2
}

bb4: {
StorageDead(_4); // scope 0 at $DIR/simple_option_map_e2e.rs:+1:5: +1:22
StorageDead(_2); // scope 0 at $DIR/simple_option_map_e2e.rs:+1:21: +1:22
return; // scope 0 at $DIR/simple_option_map_e2e.rs:+2:2: +2:2
}
91 changes: 91 additions & 0 deletions tests/mir-opt/sroa.copies.ScalarReplacementOfAggregates.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
- // MIR for `copies` before ScalarReplacementOfAggregates
+ // MIR for `copies` after ScalarReplacementOfAggregates

fn copies(_1: Foo) -> () {
debug x => _1; // in scope 0 at $DIR/sroa.rs:+0:11: +0:12
let mut _0: (); // return place in scope 0 at $DIR/sroa.rs:+0:19: +0:19
let _2: Foo; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
+ let _11: u8; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
+ let _12: (); // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
+ let _13: &str; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
+ let _14: std::option::Option<isize>; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
scope 1 {
- debug y => _2; // in scope 1 at $DIR/sroa.rs:+1:9: +1:10
+ debug y => Foo{ .0 => _11, .1 => _12, .2 => _13, .3 => _14, }; // in scope 1 at $DIR/sroa.rs:+1:9: +1:10
let _3: u8; // in scope 1 at $DIR/sroa.rs:+2:9: +2:10
scope 2 {
debug t => _3; // in scope 2 at $DIR/sroa.rs:+2:9: +2:10
let _4: &str; // in scope 2 at $DIR/sroa.rs:+3:9: +3:10
scope 3 {
debug u => _4; // in scope 3 at $DIR/sroa.rs:+3:9: +3:10
let _5: Foo; // in scope 3 at $DIR/sroa.rs:+4:9: +4:10
+ let _7: u8; // in scope 3 at $DIR/sroa.rs:+4:9: +4:10
+ let _8: (); // in scope 3 at $DIR/sroa.rs:+4:9: +4:10
+ let _9: &str; // in scope 3 at $DIR/sroa.rs:+4:9: +4:10
+ let _10: std::option::Option<isize>; // in scope 3 at $DIR/sroa.rs:+4:9: +4:10
scope 4 {
- debug z => _5; // in scope 4 at $DIR/sroa.rs:+4:9: +4:10
+ debug z => Foo{ .0 => _7, .1 => _8, .2 => _9, .3 => _10, }; // in scope 4 at $DIR/sroa.rs:+4:9: +4:10
let _6: (); // in scope 4 at $DIR/sroa.rs:+5:9: +5:10
scope 5 {
debug a => _6; // in scope 5 at $DIR/sroa.rs:+5:9: +5:10
}
}
}
}
}

bb0: {
- StorageLive(_2); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
- _2 = _1; // scope 0 at $DIR/sroa.rs:+1:13: +1:14
+ StorageLive(_11); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
+ StorageLive(_12); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
+ StorageLive(_13); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
+ StorageLive(_14); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
+ nop; // scope 0 at $DIR/sroa.rs:+1:9: +1:10
+ _11 = (_1.0: u8); // scope 0 at $DIR/sroa.rs:+1:13: +1:14
+ _12 = (_1.1: ()); // scope 0 at $DIR/sroa.rs:+1:13: +1:14
+ _13 = (_1.2: &str); // scope 0 at $DIR/sroa.rs:+1:13: +1:14
+ _14 = (_1.3: std::option::Option<isize>); // scope 0 at $DIR/sroa.rs:+1:13: +1:14
+ nop; // scope 0 at $DIR/sroa.rs:+1:13: +1:14
StorageLive(_3); // scope 1 at $DIR/sroa.rs:+2:9: +2:10
- _3 = (_2.0: u8); // scope 1 at $DIR/sroa.rs:+2:13: +2:16
+ _3 = _11; // scope 1 at $DIR/sroa.rs:+2:13: +2:16
StorageLive(_4); // scope 2 at $DIR/sroa.rs:+3:9: +3:10
- _4 = (_2.2: &str); // scope 2 at $DIR/sroa.rs:+3:13: +3:16
- StorageLive(_5); // scope 3 at $DIR/sroa.rs:+4:9: +4:10
- _5 = _2; // scope 3 at $DIR/sroa.rs:+4:13: +4:14
+ _4 = _13; // scope 2 at $DIR/sroa.rs:+3:13: +3:16
+ StorageLive(_7); // scope 3 at $DIR/sroa.rs:+4:9: +4:10
+ StorageLive(_8); // scope 3 at $DIR/sroa.rs:+4:9: +4:10
+ StorageLive(_9); // scope 3 at $DIR/sroa.rs:+4:9: +4:10
+ StorageLive(_10); // scope 3 at $DIR/sroa.rs:+4:9: +4:10
+ nop; // scope 3 at $DIR/sroa.rs:+4:9: +4:10
+ _7 = _11; // scope 3 at $DIR/sroa.rs:+4:13: +4:14
+ _8 = _12; // scope 3 at $DIR/sroa.rs:+4:13: +4:14
+ _9 = _13; // scope 3 at $DIR/sroa.rs:+4:13: +4:14
+ _10 = _14; // scope 3 at $DIR/sroa.rs:+4:13: +4:14
+ nop; // scope 3 at $DIR/sroa.rs:+4:13: +4:14
StorageLive(_6); // scope 4 at $DIR/sroa.rs:+5:9: +5:10
- _6 = (_5.1: ()); // scope 4 at $DIR/sroa.rs:+5:13: +5:16
+ _6 = _8; // scope 4 at $DIR/sroa.rs:+5:13: +5:16
_0 = const (); // scope 0 at $DIR/sroa.rs:+0:19: +6:2
StorageDead(_6); // scope 4 at $DIR/sroa.rs:+6:1: +6:2
- StorageDead(_5); // scope 3 at $DIR/sroa.rs:+6:1: +6:2
+ StorageDead(_7); // scope 3 at $DIR/sroa.rs:+6:1: +6:2
+ StorageDead(_8); // scope 3 at $DIR/sroa.rs:+6:1: +6:2
+ StorageDead(_9); // scope 3 at $DIR/sroa.rs:+6:1: +6:2
+ StorageDead(_10); // scope 3 at $DIR/sroa.rs:+6:1: +6:2
+ nop; // scope 3 at $DIR/sroa.rs:+6:1: +6:2
StorageDead(_4); // scope 2 at $DIR/sroa.rs:+6:1: +6:2
StorageDead(_3); // scope 1 at $DIR/sroa.rs:+6:1: +6:2
- StorageDead(_2); // scope 0 at $DIR/sroa.rs:+6:1: +6:2
+ StorageDead(_11); // scope 0 at $DIR/sroa.rs:+6:1: +6:2
+ StorageDead(_12); // scope 0 at $DIR/sroa.rs:+6:1: +6:2
+ StorageDead(_13); // scope 0 at $DIR/sroa.rs:+6:1: +6:2
+ StorageDead(_14); // scope 0 at $DIR/sroa.rs:+6:1: +6:2
+ nop; // scope 0 at $DIR/sroa.rs:+6:1: +6:2
return; // scope 0 at $DIR/sroa.rs:+6:2: +6:2
}
}

Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
StorageLive(_5); // scope 0 at $DIR/sroa.rs:+2:34: +2:37
_5 = g() -> bb1; // scope 0 at $DIR/sroa.rs:+2:34: +2:37
// mir::Constant
// + span: $DIR/sroa.rs:78:34: 78:35
// + span: $DIR/sroa.rs:73:34: 73:35
// + literal: Const { ty: fn() -> u32 {g}, val: Value(<ZST>) }
}

@@ -28,7 +28,7 @@
_2 = &raw const (*_3); // scope 0 at $DIR/sroa.rs:+2:7: +2:41
_1 = f(move _2) -> bb2; // scope 0 at $DIR/sroa.rs:+2:5: +2:42
// mir::Constant
// + span: $DIR/sroa.rs:78:5: 78:6
// + span: $DIR/sroa.rs:73:5: 73:6
// + literal: Const { ty: fn(*const u32) {f}, val: Value(<ZST>) }
}

39 changes: 31 additions & 8 deletions tests/mir-opt/sroa.flat.ScalarReplacementOfAggregates.diff
Original file line number Diff line number Diff line change
@@ -10,6 +10,10 @@
let mut _5: Foo; // in scope 0 at $DIR/sroa.rs:+1:30: +1:70
let mut _6: (); // in scope 0 at $DIR/sroa.rs:+1:45: +1:47
let mut _7: std::option::Option<isize>; // in scope 0 at $DIR/sroa.rs:+1:60: +1:68
+ let mut _8: u8; // in scope 0 at $DIR/sroa.rs:+1:30: +1:70
+ let mut _9: (); // in scope 0 at $DIR/sroa.rs:+1:30: +1:70
+ let mut _10: &str; // in scope 0 at $DIR/sroa.rs:+1:30: +1:70
+ let mut _11: std::option::Option<isize>; // in scope 0 at $DIR/sroa.rs:+1:30: +1:70
scope 1 {
debug a => _1; // in scope 1 at $DIR/sroa.rs:+1:15: +1:16
debug b => _2; // in scope 1 at $DIR/sroa.rs:+1:18: +1:19
@@ -26,26 +30,45 @@
}

bb0: {
StorageLive(_5); // scope 0 at $DIR/sroa.rs:+1:30: +1:70
- StorageLive(_5); // scope 0 at $DIR/sroa.rs:+1:30: +1:70
+ StorageLive(_8); // scope 0 at $DIR/sroa.rs:+1:30: +1:70
+ StorageLive(_9); // scope 0 at $DIR/sroa.rs:+1:30: +1:70
+ StorageLive(_10); // scope 0 at $DIR/sroa.rs:+1:30: +1:70
+ StorageLive(_11); // scope 0 at $DIR/sroa.rs:+1:30: +1:70
+ nop; // scope 0 at $DIR/sroa.rs:+1:30: +1:70
StorageLive(_6); // scope 0 at $DIR/sroa.rs:+1:45: +1:47
_6 = (); // scope 0 at $DIR/sroa.rs:+1:45: +1:47
StorageLive(_7); // scope 0 at $DIR/sroa.rs:+1:60: +1:68
_7 = Option::<isize>::Some(const -4_isize); // scope 0 at $DIR/sroa.rs:+1:60: +1:68
_5 = Foo { a: const 5_u8, b: move _6, c: const "a", d: move _7 }; // scope 0 at $DIR/sroa.rs:+1:30: +1:70
- _5 = Foo { a: const 5_u8, b: move _6, c: const "a", d: move _7 }; // scope 0 at $DIR/sroa.rs:+1:30: +1:70
+ _8 = const 5_u8; // scope 0 at $DIR/sroa.rs:+1:30: +1:70
+ _9 = move _6; // scope 0 at $DIR/sroa.rs:+1:30: +1:70
+ _10 = const "a"; // scope 0 at $DIR/sroa.rs:+1:30: +1:70
// mir::Constant
// + span: $DIR/sroa.rs:57:52: 57:55
// + span: $DIR/sroa.rs:53:52: 53:55
// + literal: Const { ty: &str, val: Value(Slice(..)) }
+ _11 = move _7; // scope 0 at $DIR/sroa.rs:+1:30: +1:70
+ nop; // scope 0 at $DIR/sroa.rs:+1:30: +1:70
StorageDead(_7); // scope 0 at $DIR/sroa.rs:+1:69: +1:70
StorageDead(_6); // scope 0 at $DIR/sroa.rs:+1:69: +1:70
StorageLive(_1); // scope 0 at $DIR/sroa.rs:+1:15: +1:16
_1 = (_5.0: u8); // scope 0 at $DIR/sroa.rs:+1:15: +1:16
- _1 = (_5.0: u8); // scope 0 at $DIR/sroa.rs:+1:15: +1:16
+ _1 = _8; // scope 0 at $DIR/sroa.rs:+1:15: +1:16
StorageLive(_2); // scope 0 at $DIR/sroa.rs:+1:18: +1:19
_2 = (_5.1: ()); // scope 0 at $DIR/sroa.rs:+1:18: +1:19
- _2 = (_5.1: ()); // scope 0 at $DIR/sroa.rs:+1:18: +1:19
+ _2 = _9; // scope 0 at $DIR/sroa.rs:+1:18: +1:19
StorageLive(_3); // scope 0 at $DIR/sroa.rs:+1:21: +1:22
_3 = (_5.2: &str); // scope 0 at $DIR/sroa.rs:+1:21: +1:22
- _3 = (_5.2: &str); // scope 0 at $DIR/sroa.rs:+1:21: +1:22
+ _3 = _10; // scope 0 at $DIR/sroa.rs:+1:21: +1:22
StorageLive(_4); // scope 0 at $DIR/sroa.rs:+1:24: +1:25
_4 = (_5.3: std::option::Option<isize>); // scope 0 at $DIR/sroa.rs:+1:24: +1:25
StorageDead(_5); // scope 0 at $DIR/sroa.rs:+1:70: +1:71
- _4 = (_5.3: std::option::Option<isize>); // scope 0 at $DIR/sroa.rs:+1:24: +1:25
- StorageDead(_5); // scope 0 at $DIR/sroa.rs:+1:70: +1:71
+ _4 = _11; // scope 0 at $DIR/sroa.rs:+1:24: +1:25
+ StorageDead(_8); // scope 0 at $DIR/sroa.rs:+1:70: +1:71
+ StorageDead(_9); // scope 0 at $DIR/sroa.rs:+1:70: +1:71
+ StorageDead(_10); // scope 0 at $DIR/sroa.rs:+1:70: +1:71
+ StorageDead(_11); // scope 0 at $DIR/sroa.rs:+1:70: +1:71
+ nop; // scope 0 at $DIR/sroa.rs:+1:70: +1:71
_0 = const (); // scope 0 at $DIR/sroa.rs:+0:15: +6:2
StorageDead(_4); // scope 0 at $DIR/sroa.rs:+6:1: +6:2
StorageDead(_3); // scope 0 at $DIR/sroa.rs:+6:1: +6:2
56 changes: 56 additions & 0 deletions tests/mir-opt/sroa.ref_copies.ScalarReplacementOfAggregates.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
- // MIR for `ref_copies` before ScalarReplacementOfAggregates
+ // MIR for `ref_copies` after ScalarReplacementOfAggregates

fn ref_copies(_1: &Foo) -> () {
debug x => _1; // in scope 0 at $DIR/sroa.rs:+0:15: +0:16
let mut _0: (); // return place in scope 0 at $DIR/sroa.rs:+0:24: +0:24
let _2: Foo; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
+ let _5: u8; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
+ let _6: (); // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
+ let _7: &str; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
+ let _8: std::option::Option<isize>; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10
scope 1 {
- debug y => _2; // in scope 1 at $DIR/sroa.rs:+1:9: +1:10
+ debug y => Foo{ .0 => _5, .1 => _6, .2 => _7, .3 => _8, }; // in scope 1 at $DIR/sroa.rs:+1:9: +1:10
let _3: u8; // in scope 1 at $DIR/sroa.rs:+2:9: +2:10
scope 2 {
debug t => _3; // in scope 2 at $DIR/sroa.rs:+2:9: +2:10
let _4: &str; // in scope 2 at $DIR/sroa.rs:+3:9: +3:10
scope 3 {
debug u => _4; // in scope 3 at $DIR/sroa.rs:+3:9: +3:10
}
}
}

bb0: {
- StorageLive(_2); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
- _2 = (*_1); // scope 0 at $DIR/sroa.rs:+1:13: +1:15
+ StorageLive(_5); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
+ StorageLive(_6); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
+ StorageLive(_7); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
+ StorageLive(_8); // scope 0 at $DIR/sroa.rs:+1:9: +1:10
+ nop; // scope 0 at $DIR/sroa.rs:+1:9: +1:10
+ _5 = ((*_1).0: u8); // scope 0 at $DIR/sroa.rs:+1:13: +1:15
+ _6 = ((*_1).1: ()); // scope 0 at $DIR/sroa.rs:+1:13: +1:15
+ _7 = ((*_1).2: &str); // scope 0 at $DIR/sroa.rs:+1:13: +1:15
+ _8 = ((*_1).3: std::option::Option<isize>); // scope 0 at $DIR/sroa.rs:+1:13: +1:15
+ nop; // scope 0 at $DIR/sroa.rs:+1:13: +1:15
StorageLive(_3); // scope 1 at $DIR/sroa.rs:+2:9: +2:10
- _3 = (_2.0: u8); // scope 1 at $DIR/sroa.rs:+2:13: +2:16
+ _3 = _5; // scope 1 at $DIR/sroa.rs:+2:13: +2:16
StorageLive(_4); // scope 2 at $DIR/sroa.rs:+3:9: +3:10
- _4 = (_2.2: &str); // scope 2 at $DIR/sroa.rs:+3:13: +3:16
+ _4 = _7; // scope 2 at $DIR/sroa.rs:+3:13: +3:16
_0 = const (); // scope 0 at $DIR/sroa.rs:+0:24: +4:2
StorageDead(_4); // scope 2 at $DIR/sroa.rs:+4:1: +4:2
StorageDead(_3); // scope 1 at $DIR/sroa.rs:+4:1: +4:2
- StorageDead(_2); // scope 0 at $DIR/sroa.rs:+4:1: +4:2
+ StorageDead(_5); // scope 0 at $DIR/sroa.rs:+4:1: +4:2
+ StorageDead(_6); // scope 0 at $DIR/sroa.rs:+4:1: +4:2
+ StorageDead(_7); // scope 0 at $DIR/sroa.rs:+4:1: +4:2
+ StorageDead(_8); // scope 0 at $DIR/sroa.rs:+4:1: +4:2
+ nop; // scope 0 at $DIR/sroa.rs:+4:1: +4:2
return; // scope 0 at $DIR/sroa.rs:+4:2: +4:2
}
}

32 changes: 26 additions & 6 deletions tests/mir-opt/sroa.rs
Original file line number Diff line number Diff line change
@@ -12,17 +12,14 @@ impl Drop for Tag {
fn drop(&mut self) {}
}

// EMIT_MIR sroa.dropping.ScalarReplacementOfAggregates.diff
pub fn dropping() {
S(Tag(0), Tag(1), Tag(2)).1;
}

// EMIT_MIR sroa.enums.ScalarReplacementOfAggregates.diff
pub fn enums(a: usize) -> usize {
if let Some(a) = Some(a) { a } else { 0 }
}

// EMIT_MIR sroa.structs.ScalarReplacementOfAggregates.diff
pub fn structs(a: f32) -> f32 {
struct U {
_foo: usize,
@@ -32,7 +29,6 @@ pub fn structs(a: f32) -> f32 {
U { _foo: 0, a }.a
}

// EMIT_MIR sroa.unions.ScalarReplacementOfAggregates.diff
pub fn unions(a: f32) -> u32 {
union Repr {
f: f32,
@@ -41,6 +37,7 @@ pub fn unions(a: f32) -> u32 {
unsafe { Repr { f: a }.u }
}

#[derive(Copy, Clone)]
struct Foo {
a: u8,
b: (),
@@ -52,7 +49,6 @@ fn g() -> u32 {
3
}

// EMIT_MIR sroa.flat.ScalarReplacementOfAggregates.diff
pub fn flat() {
let Foo { a, b, c, d } = Foo { a: 5, b: (), c: "a", d: Some(-4) };
let _ = a;
@@ -72,17 +68,41 @@ fn f(a: *const u32) {
println!("{}", unsafe { *a.add(2) });
}

// EMIT_MIR sroa.escaping.ScalarReplacementOfAggregates.diff
pub fn escaping() {
// Verify this struct is not flattened.
f(&Escaping { a: 1, b: 2, c: g() }.a);
}

fn copies(x: Foo) {
let y = x;
let t = y.a;
let u = y.c;
let z = y;
let a = z.b;
}

fn ref_copies(x: &Foo) {
let y = *x;
let t = y.a;
let u = y.c;
}

fn main() {
dropping();
enums(5);
structs(5.);
unions(5.);
flat();
escaping();
copies(Foo { a: 5, b: (), c: "a", d: Some(-4) });
ref_copies(&Foo { a: 5, b: (), c: "a", d: Some(-4) });
}

// EMIT_MIR sroa.dropping.ScalarReplacementOfAggregates.diff
// EMIT_MIR sroa.enums.ScalarReplacementOfAggregates.diff
// EMIT_MIR sroa.structs.ScalarReplacementOfAggregates.diff
// EMIT_MIR sroa.unions.ScalarReplacementOfAggregates.diff
// EMIT_MIR sroa.flat.ScalarReplacementOfAggregates.diff
// EMIT_MIR sroa.escaping.ScalarReplacementOfAggregates.diff
// EMIT_MIR sroa.copies.ScalarReplacementOfAggregates.diff
// EMIT_MIR sroa.ref_copies.ScalarReplacementOfAggregates.diff
20 changes: 16 additions & 4 deletions tests/mir-opt/sroa.structs.ScalarReplacementOfAggregates.diff
Original file line number Diff line number Diff line change
@@ -6,15 +6,27 @@
let mut _0: f32; // return place in scope 0 at $DIR/sroa.rs:+0:27: +0:30
let mut _2: structs::U; // in scope 0 at $DIR/sroa.rs:+6:5: +6:21
let mut _3: f32; // in scope 0 at $DIR/sroa.rs:+6:18: +6:19
+ let mut _4: usize; // in scope 0 at $DIR/sroa.rs:+6:5: +6:21
+ let mut _5: f32; // in scope 0 at $DIR/sroa.rs:+6:5: +6:21

bb0: {
StorageLive(_2); // scope 0 at $DIR/sroa.rs:+6:5: +6:21
- StorageLive(_2); // scope 0 at $DIR/sroa.rs:+6:5: +6:21
+ StorageLive(_4); // scope 0 at $DIR/sroa.rs:+6:5: +6:21
+ StorageLive(_5); // scope 0 at $DIR/sroa.rs:+6:5: +6:21
+ nop; // scope 0 at $DIR/sroa.rs:+6:5: +6:21
StorageLive(_3); // scope 0 at $DIR/sroa.rs:+6:18: +6:19
_3 = _1; // scope 0 at $DIR/sroa.rs:+6:18: +6:19
_2 = U { _foo: const 0_usize, a: move _3 }; // scope 0 at $DIR/sroa.rs:+6:5: +6:21
- _2 = U { _foo: const 0_usize, a: move _3 }; // scope 0 at $DIR/sroa.rs:+6:5: +6:21
+ _4 = const 0_usize; // scope 0 at $DIR/sroa.rs:+6:5: +6:21
+ _5 = move _3; // scope 0 at $DIR/sroa.rs:+6:5: +6:21
+ nop; // scope 0 at $DIR/sroa.rs:+6:5: +6:21
StorageDead(_3); // scope 0 at $DIR/sroa.rs:+6:20: +6:21
_0 = (_2.1: f32); // scope 0 at $DIR/sroa.rs:+6:5: +6:23
StorageDead(_2); // scope 0 at $DIR/sroa.rs:+7:1: +7:2
- _0 = (_2.1: f32); // scope 0 at $DIR/sroa.rs:+6:5: +6:23
- StorageDead(_2); // scope 0 at $DIR/sroa.rs:+7:1: +7:2
+ _0 = _5; // scope 0 at $DIR/sroa.rs:+6:5: +6:23
+ StorageDead(_4); // scope 0 at $DIR/sroa.rs:+7:1: +7:2
+ StorageDead(_5); // scope 0 at $DIR/sroa.rs:+7:1: +7:2
+ nop; // scope 0 at $DIR/sroa.rs:+7:1: +7:2
return; // scope 0 at $DIR/sroa.rs:+7:2: +7:2
}
}
6 changes: 6 additions & 0 deletions tests/ui/lifetimes/issue-107492-default-value-for-lifetime.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pub struct DefaultLifetime<'a, 'b = 'static> {
//~^ ERROR unexpected default lifetime parameter
_marker: std::marker::PhantomData<&'a &'b ()>,
}

fn main(){}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: unexpected default lifetime parameter
--> $DIR/issue-107492-default-value-for-lifetime.rs:1:35
|
LL | pub struct DefaultLifetime<'a, 'b = 'static> {
| ^^^^^^^^^ lifetime parameters cannot have default values

error: aborting due to previous error

31 changes: 31 additions & 0 deletions tests/ui/suggest-null-ptr.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// run-rustfix

// Suggest providing a std::ptr::null{,_mut}() to a function that takes in a raw
// pointer if a literal 0 was provided by the user.

extern "C" {
fn foo(ptr: *const u8);

fn foo_mut(ptr: *mut u8);

fn usize(ptr: *const usize);

fn usize_mut(ptr: *mut usize);
}

fn main() {
unsafe {
foo(std::ptr::null());
//~^ mismatched types [E0308]
//~| if you meant to create a null pointer, use `std::ptr::null()`
foo_mut(std::ptr::null_mut());
//~^ mismatched types [E0308]
//~| if you meant to create a null pointer, use `std::ptr::null_mut()`
usize(std::ptr::null());
//~^ mismatched types [E0308]
//~| if you meant to create a null pointer, use `std::ptr::null()`
usize_mut(std::ptr::null_mut());
//~^ mismatched types [E0308]
//~| if you meant to create a null pointer, use `std::ptr::null_mut()`
}
}
31 changes: 31 additions & 0 deletions tests/ui/suggest-null-ptr.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// run-rustfix

// Suggest providing a std::ptr::null{,_mut}() to a function that takes in a raw
// pointer if a literal 0 was provided by the user.

extern "C" {
fn foo(ptr: *const u8);

fn foo_mut(ptr: *mut u8);

fn usize(ptr: *const usize);

fn usize_mut(ptr: *mut usize);
}

fn main() {
unsafe {
foo(0);
//~^ mismatched types [E0308]
//~| if you meant to create a null pointer, use `std::ptr::null()`
foo_mut(0);
//~^ mismatched types [E0308]
//~| if you meant to create a null pointer, use `std::ptr::null_mut()`
usize(0);
//~^ mismatched types [E0308]
//~| if you meant to create a null pointer, use `std::ptr::null()`
usize_mut(0);
//~^ mismatched types [E0308]
//~| if you meant to create a null pointer, use `std::ptr::null_mut()`
}
}
83 changes: 83 additions & 0 deletions tests/ui/suggest-null-ptr.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
error[E0308]: mismatched types
--> $DIR/suggest-null-ptr.rs:18:13
|
LL | foo(0);
| --- ^ expected `*const u8`, found `usize`
| |
| arguments to this function are incorrect
|
= note: expected raw pointer `*const u8`
found type `usize`
note: function defined here
--> $DIR/suggest-null-ptr.rs:7:8
|
LL | fn foo(ptr: *const u8);
| ^^^
help: if you meant to create a null pointer, use `std::ptr::null()`
|
LL | foo(std::ptr::null());
| ~~~~~~~~~~~~~~~~

error[E0308]: mismatched types
--> $DIR/suggest-null-ptr.rs:21:17
|
LL | foo_mut(0);
| ------- ^ expected `*mut u8`, found `usize`
| |
| arguments to this function are incorrect
|
= note: expected raw pointer `*mut u8`
found type `usize`
note: function defined here
--> $DIR/suggest-null-ptr.rs:9:8
|
LL | fn foo_mut(ptr: *mut u8);
| ^^^^^^^
help: if you meant to create a null pointer, use `std::ptr::null_mut()`
|
LL | foo_mut(std::ptr::null_mut());
| ~~~~~~~~~~~~~~~~~~~~

error[E0308]: mismatched types
--> $DIR/suggest-null-ptr.rs:24:15
|
LL | usize(0);
| ----- ^ expected `*const usize`, found `usize`
| |
| arguments to this function are incorrect
|
= note: expected raw pointer `*const usize`
found type `usize`
note: function defined here
--> $DIR/suggest-null-ptr.rs:11:8
|
LL | fn usize(ptr: *const usize);
| ^^^^^
help: if you meant to create a null pointer, use `std::ptr::null()`
|
LL | usize(std::ptr::null());
| ~~~~~~~~~~~~~~~~

error[E0308]: mismatched types
--> $DIR/suggest-null-ptr.rs:27:19
|
LL | usize_mut(0);
| --------- ^ expected `*mut usize`, found `usize`
| |
| arguments to this function are incorrect
|
= note: expected raw pointer `*mut usize`
found type `usize`
note: function defined here
--> $DIR/suggest-null-ptr.rs:13:8
|
LL | fn usize_mut(ptr: *mut usize);
| ^^^^^^^^^
help: if you meant to create a null pointer, use `std::ptr::null_mut()`
|
LL | usize_mut(std::ptr::null_mut());
| ~~~~~~~~~~~~~~~~~~~~

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0308`.
21 changes: 21 additions & 0 deletions tests/ui/typeck/issue-90027-async-fn-return-suggestion.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// edition:2018

async fn hello() { //~ HELP try adding a return type
0
//~^ ERROR [E0308]
}

async fn world() -> () {
0
//~^ ERROR [E0308]
}

async fn suggest_await_in_async_fn_return() {
hello()
//~^ ERROR mismatched types [E0308]
//~| HELP consider `await`ing on the `Future`
//~| HELP consider using a semicolon here
//~| SUGGESTION .await
}

fn main() {}
36 changes: 36 additions & 0 deletions tests/ui/typeck/issue-90027-async-fn-return-suggestion.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
error[E0308]: mismatched types
--> $DIR/issue-90027-async-fn-return-suggestion.rs:4:5
|
LL | async fn hello() {
| - help: try adding a return type: `-> i32`
LL | 0
| ^ expected `()`, found integer

error[E0308]: mismatched types
--> $DIR/issue-90027-async-fn-return-suggestion.rs:9:5
|
LL | async fn world() -> () {
| -- expected `()` because of return type
LL | 0
| ^ expected `()`, found integer

error[E0308]: mismatched types
--> $DIR/issue-90027-async-fn-return-suggestion.rs:14:5
|
LL | hello()
| ^^^^^^^ expected `()`, found opaque type
|
= note: expected unit type `()`
found opaque type `impl Future<Output = ()>`
help: consider `await`ing on the `Future`
|
LL | hello().await
| ++++++
help: consider using a semicolon here
|
LL | hello();
| +

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0308`.