diff options
| author | bors <bors@rust-lang.org> | 2021-03-08 14:59:20 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-03-08 14:59:20 +0000 |
| commit | 8f349be27815d43d462a32faeb270a22a68486b6 (patch) | |
| tree | 37413af1348b05c9f8e65925c614ee369c16a3f5 /src | |
| parent | 1d6b0f626aad4ee9f2eaec4d5582f45620ccab80 (diff) | |
| parent | 3b0a02a26b6db7a2f997cd32ca352e141ec795eb (diff) | |
| download | rust-8f349be27815d43d462a32faeb270a22a68486b6.tar.gz rust-8f349be27815d43d462a32faeb270a22a68486b6.zip | |
Auto merge of #82896 - Dylan-DPC:rollup-9setmme, r=Dylan-DPC
Rollup of 10 pull requests Successful merges: - #82047 (bypass auto_da_alloc for metadata files) - #82415 (expand: Refactor module loading) - #82557 (Add natvis for Result, NonNull, CString, CStr, and Cow) - #82613 (Remove Item::kind, use tagged enum. Rename variants to match) - #82642 (Fix jemalloc usage on OSX) - #82682 (Implement built-in attribute macro `#[cfg_eval]` + some refactoring) - #82684 (Disable destination propagation on all mir-opt-levels) - #82755 (Refactor confirm_builtin_call, remove partial if) - #82857 (Edit ructc_ast_lowering docs) - #82862 (Generalize Write impl for Vec<u8> to Vec<u8, A>) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
36 files changed, 699 insertions, 218 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 9317c89625d..22a1eb63702 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -397,6 +397,7 @@ impl<'a> Builder<'a> { test::Crate, test::CrateLibrustc, test::CrateRustdoc, + test::CrateRustdocJsonTypes, test::Linkcheck, test::TierCheck, test::Cargotest, diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index c0cd24dd81f..03ae684e23f 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1922,6 +1922,77 @@ impl Step for CrateRustdoc { } } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub struct CrateRustdocJsonTypes { + host: TargetSelection, + test_kind: TestKind, +} + +impl Step for CrateRustdocJsonTypes { + type Output = (); + const DEFAULT: bool = true; + const ONLY_HOSTS: bool = true; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.path("src/rustdoc-json-types") + } + + fn make_run(run: RunConfig<'_>) { + let builder = run.builder; + + let test_kind = builder.kind.into(); + + builder.ensure(CrateRustdocJsonTypes { host: run.target, test_kind }); + } + + 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 + // created when running compiletest for src/test/rustdoc. If this used + // `compiler`, then it would cause rustdoc to be built *again*, which + // isn't really necessary. + let compiler = builder.compiler_for(builder.top_stage, target, target); + builder.ensure(compile::Rustc { compiler, target }); + + let mut cargo = tool::prepare_tool_cargo( + builder, + compiler, + Mode::ToolRustc, + target, + test_kind.subcommand(), + "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'"); + } + + if !builder.config.verbose_tests { + cargo.arg("--quiet"); + } + + builder.info(&format!( + "{} rustdoc-json-types stage{} ({} -> {})", + test_kind, compiler.stage, &compiler.host, target + )); + let _time = util::timeit(&builder); + + try_run(builder, &mut cargo.into()); + } +} + /// Some test suites are run inside emulators or on remote devices, and most /// of our test binaries are linked dynamically which means we need to ship /// the standard library and such to the emulator ahead of time. This step diff --git a/src/etc/natvis/liballoc.natvis b/src/etc/natvis/liballoc.natvis index cfaafc5734b..9cc60fc7b47 100644 --- a/src/etc/natvis/liballoc.natvis +++ b/src/etc/natvis/liballoc.natvis @@ -75,4 +75,11 @@ <ExpandedItem>ptr.pointer->data</ExpandedItem> </Expand> </Type> + <Type Name="alloc::borrow::Cow<*>"> + <DisplayString Condition="RUST$ENUM$DISR == 0x0">Borrowed({__0})</DisplayString> + <DisplayString Condition="RUST$ENUM$DISR == 0x1">Owned({__0})</DisplayString> + <Expand> + <Item Name="[value]" ExcludeView="simple">__0</Item> + </Expand> + </Type> </AutoVisualizer> diff --git a/src/etc/natvis/libcore.natvis b/src/etc/natvis/libcore.natvis index 984a8bfb13c..9c3c26f5978 100644 --- a/src/etc/natvis/libcore.natvis +++ b/src/etc/natvis/libcore.natvis @@ -30,4 +30,19 @@ </Expand> </Type> + <Type Name="core::result::Result<*>"> + <DisplayString Condition="RUST$ENUM$DISR == 0x0">Ok({__0})</DisplayString> + <DisplayString Condition="RUST$ENUM$DISR == 0x1">Err({(*($T2*) &__0)})</DisplayString> + <Expand> + <Item Name="[value]" Condition="RUST$ENUM$DISR == 0x0">__0</Item> + <Item Name="[value]" Condition="RUST$ENUM$DISR == 0x1">(*($T2*) &__0)</Item> + </Expand> + </Type> + + <Type Name="core::ptr::non_null::NonNull<*>"> + <DisplayString>{(void*) pointer}</DisplayString> + <Expand> + <Item Name="[value]">*pointer</Item> + </Expand> + </Type> </AutoVisualizer> \ No newline at end of file diff --git a/src/etc/natvis/libstd.natvis b/src/etc/natvis/libstd.natvis index 7e5ee7b13da..b0542b0c633 100644 --- a/src/etc/natvis/libstd.natvis +++ b/src/etc/natvis/libstd.natvis @@ -72,4 +72,33 @@ </CustomListItems> </Expand> </Type> + + <Type Name="std::ffi::c_str::CString"> + <DisplayString>{inner.data_ptr,s}</DisplayString> + <Expand> + <Synthetic Name="[chars]"> + <Expand> + <ArrayItems> + <Size>inner.length</Size> + <ValuePointer>(char*)inner.data_ptr</ValuePointer> + </ArrayItems> + </Expand> + </Synthetic> + </Expand> + </Type> + + <Type Name="std::ffi::c_str::CStr"> + <DisplayString>{(char*) inner}</DisplayString> + <Expand> + <Synthetic Name="[chars]"> + <DisplayString>{(char*) inner}</DisplayString> + <Expand> + <ArrayItems> + <Size>strlen((char *) inner) + 1</Size> + <ValuePointer>(char*)inner</ValuePointer> + </ArrayItems> + </Expand> + </Synthetic> + </Expand> + </Type> </AutoVisualizer> diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 47e4f3f0aa3..063d8aab1ec 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -23,7 +23,6 @@ use std::collections::HashSet; impl JsonRenderer<'_> { pub(super) fn convert_item(&self, item: clean::Item) -> Option<Item> { - let item_type = ItemType::from(&item); let deprecation = item.deprecation(self.tcx); let clean::Item { source, name, attrs, kind, visibility, def_id } = item; let inner = match *kind { @@ -50,7 +49,6 @@ impl JsonRenderer<'_> { .map(rustc_ast_pretty::pprust::attribute_to_string) .collect(), deprecation: deprecation.map(from_deprecation), - kind: item_type.into(), inner, }) } @@ -154,30 +152,30 @@ crate fn from_def_id(did: DefId) -> Id { fn from_clean_item_kind(item: clean::ItemKind, tcx: TyCtxt<'_>, name: &Option<Symbol>) -> ItemEnum { use clean::ItemKind::*; match item { - ModuleItem(m) => ItemEnum::ModuleItem(m.into()), - ImportItem(i) => ItemEnum::ImportItem(i.into()), - StructItem(s) => ItemEnum::StructItem(s.into()), - UnionItem(u) => ItemEnum::UnionItem(u.into()), - StructFieldItem(f) => ItemEnum::StructFieldItem(f.into()), - EnumItem(e) => ItemEnum::EnumItem(e.into()), - VariantItem(v) => ItemEnum::VariantItem(v.into()), - FunctionItem(f) => ItemEnum::FunctionItem(f.into()), - ForeignFunctionItem(f) => ItemEnum::FunctionItem(f.into()), - TraitItem(t) => ItemEnum::TraitItem(t.into()), - TraitAliasItem(t) => ItemEnum::TraitAliasItem(t.into()), - MethodItem(m, _) => ItemEnum::MethodItem(from_function_method(m, true)), - TyMethodItem(m) => ItemEnum::MethodItem(from_function_method(m, false)), - ImplItem(i) => ItemEnum::ImplItem(i.into()), - StaticItem(s) => ItemEnum::StaticItem(from_clean_static(s, tcx)), - ForeignStaticItem(s) => ItemEnum::StaticItem(from_clean_static(s, tcx)), - ForeignTypeItem => ItemEnum::ForeignTypeItem, - TypedefItem(t, _) => ItemEnum::TypedefItem(t.into()), - OpaqueTyItem(t) => ItemEnum::OpaqueTyItem(t.into()), - ConstantItem(c) => ItemEnum::ConstantItem(c.into()), - MacroItem(m) => ItemEnum::MacroItem(m.source), - ProcMacroItem(m) => ItemEnum::ProcMacroItem(m.into()), - AssocConstItem(t, s) => ItemEnum::AssocConstItem { type_: t.into(), default: s }, - AssocTypeItem(g, t) => ItemEnum::AssocTypeItem { + ModuleItem(m) => ItemEnum::Module(m.into()), + ImportItem(i) => ItemEnum::Import(i.into()), + StructItem(s) => ItemEnum::Struct(s.into()), + UnionItem(u) => ItemEnum::Union(u.into()), + StructFieldItem(f) => ItemEnum::StructField(f.into()), + EnumItem(e) => ItemEnum::Enum(e.into()), + VariantItem(v) => ItemEnum::Variant(v.into()), + FunctionItem(f) => ItemEnum::Function(f.into()), + ForeignFunctionItem(f) => ItemEnum::Function(f.into()), + TraitItem(t) => ItemEnum::Trait(t.into()), + TraitAliasItem(t) => ItemEnum::TraitAlias(t.into()), + MethodItem(m, _) => ItemEnum::Method(from_function_method(m, true)), + TyMethodItem(m) => ItemEnum::Method(from_function_method(m, false)), + ImplItem(i) => ItemEnum::Impl(i.into()), + StaticItem(s) => ItemEnum::Static(from_clean_static(s, tcx)), + ForeignStaticItem(s) => ItemEnum::Static(from_clean_static(s, tcx)), + ForeignTypeItem => ItemEnum::ForeignType, + TypedefItem(t, _) => ItemEnum::Typedef(t.into()), + OpaqueTyItem(t) => ItemEnum::OpaqueTy(t.into()), + ConstantItem(c) => ItemEnum::Constant(c.into()), + MacroItem(m) => ItemEnum::Macro(m.source), + ProcMacroItem(m) => ItemEnum::ProcMacro(m.into()), + AssocConstItem(t, s) => ItemEnum::AssocConst { type_: t.into(), default: s }, + AssocTypeItem(g, t) => ItemEnum::AssocType { bounds: g.into_iter().map(Into::into).collect(), default: t.map(Into::into), }, @@ -185,7 +183,7 @@ fn from_clean_item_kind(item: clean::ItemKind, tcx: TyCtxt<'_>, name: &Option<Sy PrimitiveItem(_) | KeywordItem(_) => { panic!("{:?} is not supported for JSON output", item) } - ExternCrateItem { ref src } => ItemEnum::ExternCrateItem { + ExternCrateItem { ref src } => ItemEnum::ExternCrate { name: name.as_ref().unwrap().to_string(), rename: src.map(|x| x.to_string()), }, diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index 863610baed4..8b0c049c05b 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -108,8 +108,7 @@ impl JsonRenderer<'tcx> { .last() .map(Clone::clone), visibility: types::Visibility::Public, - kind: types::ItemKind::Trait, - inner: types::ItemEnum::TraitItem(trait_item.clone().into()), + inner: types::ItemEnum::Trait(trait_item.clone().into()), source: None, docs: Default::default(), links: Default::default(), @@ -158,11 +157,11 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { let id = item.def_id; if let Some(mut new_item) = self.convert_item(item) { - if let types::ItemEnum::TraitItem(ref mut t) = new_item.inner { + if let types::ItemEnum::Trait(ref mut t) = new_item.inner { t.implementors = self.get_trait_implementors(id) - } else if let types::ItemEnum::StructItem(ref mut s) = new_item.inner { + } else if let types::ItemEnum::Struct(ref mut s) = new_item.inner { s.impls = self.get_impls(id) - } else if let types::ItemEnum::EnumItem(ref mut e) = new_item.inner { + } else if let types::ItemEnum::Enum(ref mut e) = new_item.inner { e.impls = self.get_impls(id) } let removed = self.index.borrow_mut().insert(from_def_id(id), new_item.clone()); diff --git a/src/rustdoc-json-types/Cargo.toml b/src/rustdoc-json-types/Cargo.toml index 7bba16a68b9..9c02d5e645b 100644 --- a/src/rustdoc-json-types/Cargo.toml +++ b/src/rustdoc-json-types/Cargo.toml @@ -9,3 +9,6 @@ path = "lib.rs" [dependencies] serde = { version = "1.0", features = ["derive"] } + +[dev-dependencies] +serde_json = "1.0" diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs index 6188b87d2c6..4e7794fe610 100644 --- a/src/rustdoc-json-types/lib.rs +++ b/src/rustdoc-json-types/lib.rs @@ -76,7 +76,7 @@ pub struct Item { /// Stringified versions of the attributes on this item (e.g. `"#[inline]"`) pub attrs: Vec<String>, pub deprecation: Option<Deprecation>, - pub kind: ItemKind, + #[serde(flatten)] pub inner: ItemEnum, } @@ -185,48 +185,48 @@ pub enum ItemKind { } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] -#[serde(untagged)] +#[serde(tag = "kind", content = "inner", rename_all = "snake_case")] pub enum ItemEnum { - ModuleItem(Module), - ExternCrateItem { + Module(Module), + ExternCrate { name: String, rename: Option<String>, }, - ImportItem(Import), + Import(Import), - UnionItem(Union), - StructItem(Struct), - StructFieldItem(Type), - EnumItem(Enum), - VariantItem(Variant), + Union(Union), + Struct(Struct), + StructField(Type), + Enum(Enum), + Variant(Variant), - FunctionItem(Function), + Function(Function), - TraitItem(Trait), - TraitAliasItem(TraitAlias), - MethodItem(Method), - ImplItem(Impl), + Trait(Trait), + TraitAlias(TraitAlias), + Method(Method), + Impl(Impl), - TypedefItem(Typedef), - OpaqueTyItem(OpaqueTy), - ConstantItem(Constant), + Typedef(Typedef), + OpaqueTy(OpaqueTy), + Constant(Constant), - StaticItem(Static), + Static(Static), /// `type`s from an extern block - ForeignTypeItem, + ForeignType, /// Declarative macro_rules! macro - MacroItem(String), - ProcMacroItem(ProcMacro), + Macro(String), + ProcMacro(ProcMacro), - AssocConstItem { + AssocConst { #[serde(rename = "type")] type_: Type, /// e.g. `const X: usize = 5;` default: Option<String>, }, - AssocTypeItem { + AssocType { bounds: Vec<GenericBound>, /// e.g. `type X = usize;` default: Option<Type>, @@ -508,3 +508,6 @@ pub struct Static { pub mutable: bool, pub expr: String, } + +#[cfg(test)] +mod tests; diff --git a/src/rustdoc-json-types/tests.rs b/src/rustdoc-json-types/tests.rs new file mode 100644 index 00000000000..e7f6447ed87 --- /dev/null +++ b/src/rustdoc-json-types/tests.rs @@ -0,0 +1,34 @@ +use super::*; + +#[test] +fn test_struct_info_roundtrip() { + let s = ItemEnum::Struct(Struct { + struct_type: StructType::Plain, + generics: Generics { params: vec![], where_predicates: vec![] }, + fields_stripped: false, + fields: vec![], + impls: vec![], + }); + + let struct_json = serde_json::to_string(&s).unwrap(); + + let de_s = serde_json::from_str(&struct_json).unwrap(); + + assert_eq!(s, de_s); +} + +#[test] +fn test_union_info_roundtrip() { + let u = ItemEnum::Union(Union { + generics: Generics { params: vec![], where_predicates: vec![] }, + fields_stripped: false, + fields: vec![], + impls: vec![], + }); + + let union_json = serde_json::to_string(&u).unwrap(); + + let de_u = serde_json::from_str(&union_json).unwrap(); + + assert_eq!(u, de_u); +} diff --git a/src/test/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff b/src/test/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff index b6e4469e870..b0c97f42378 100644 --- a/src/test/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff +++ b/src/test/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff @@ -5,22 +5,26 @@ debug s => _1; // in scope 0 at $DIR/deduplicate_blocks.rs:2:36: 2:37 let mut _0: bool; // return place in scope 0 at $DIR/deduplicate_blocks.rs:2:48: 2:52 let mut _2: &[u8]; // in scope 0 at $DIR/deduplicate_blocks.rs:3:11: 3:23 - let mut _3: usize; // in scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31 - let mut _4: bool; // in scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31 - let mut _5: usize; // in scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37 - let mut _6: bool; // in scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37 + let mut _3: &str; // in scope 0 at $DIR/deduplicate_blocks.rs:3:11: 3:12 + let mut _4: usize; // in scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31 + let mut _5: bool; // in scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31 + let mut _6: usize; // in scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37 + let mut _7: bool; // in scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37 scope 1 (inlined core::str::<impl str>::as_bytes) { // at $DIR/deduplicate_blocks.rs:3:11: 3:23 - debug self => _7; // in scope 1 at $DIR/deduplicate_blocks.rs:3:11: 3:23 - let mut _7: &str; // in scope 1 at $DIR/deduplicate_blocks.rs:3:11: 3:23 + debug self => _3; // in scope 1 at $DIR/deduplicate_blocks.rs:3:11: 3:23 + let mut _8: &str; // in scope 1 at $DIR/deduplicate_blocks.rs:3:11: 3:23 scope 2 { } } bb0: { StorageLive(_2); // scope 0 at $DIR/deduplicate_blocks.rs:3:11: 3:23 - _7 = _1; // scope 0 at $DIR/deduplicate_blocks.rs:3:11: 3:12 -- _2 = transmute::<&str, &[u8]>(move _7) -> bb14; // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23 -+ _2 = transmute::<&str, &[u8]>(move _7) -> bb12; // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23 + StorageLive(_3); // scope 0 at $DIR/deduplicate_blocks.rs:3:11: 3:12 + _3 = _1; // scope 0 at $DIR/deduplicate_blocks.rs:3:11: 3:12 + StorageLive(_8); // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23 + _8 = _3; // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23 +- _2 = transmute::<&str, &[u8]>(move _8) -> bb14; // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23 ++ _2 = transmute::<&str, &[u8]>(move _8) -> bb12; // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23 // mir::Constant // + span: $DIR/deduplicate_blocks.rs:3:11: 3:23 // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&str) -> &[u8] {std::intrinsics::transmute::<&str, &[u8]>}, val: Value(Scalar(<ZST>)) } @@ -44,9 +48,9 @@ } bb5: { - _3 = Len((*_2)); // scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31 - _4 = Ge(move _3, const 3_usize); // scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31 - switchInt(move _4) -> [false: bb9, otherwise: bb6]; // scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31 + _4 = Len((*_2)); // scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31 + _5 = Ge(move _4, const 3_usize); // scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31 + switchInt(move _5) -> [false: bb9, otherwise: bb6]; // scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31 } bb6: { @@ -93,9 +97,11 @@ - bb14: { + bb12: { - _5 = Len((*_2)); // scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37 - _6 = Ge(move _5, const 4_usize); // scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37 - switchInt(move _6) -> [false: bb5, otherwise: bb1]; // scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37 + StorageDead(_8); // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23 + StorageDead(_3); // scope 0 at $DIR/deduplicate_blocks.rs:3:22: 3:23 + _6 = Len((*_2)); // scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37 + _7 = Ge(move _6, const 4_usize); // scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37 + switchInt(move _7) -> [false: bb5, otherwise: bb1]; // scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37 } } diff --git a/src/test/mir-opt/dest-prop/branch.rs b/src/test/mir-opt/dest-prop/branch.rs index 7e0e40671dd..fffcf82b3f1 100644 --- a/src/test/mir-opt/dest-prop/branch.rs +++ b/src/test/mir-opt/dest-prop/branch.rs @@ -1,5 +1,5 @@ //! Tests that assignment in both branches of an `if` are eliminated. - +// compile-flags: -Zunsound-mir-opts fn val() -> i32 { 1 } diff --git a/src/test/mir-opt/dest-prop/copy_propagation_arg.rs b/src/test/mir-opt/dest-prop/copy_propagation_arg.rs index b5188a8b4b2..41796247789 100644 --- a/src/test/mir-opt/dest-prop/copy_propagation_arg.rs +++ b/src/test/mir-opt/dest-prop/copy_propagation_arg.rs @@ -1,6 +1,6 @@ // Check that DestinationPropagation does not propagate an assignment to a function argument // (doing so can break usages of the original argument value) - +// compile-flags: -Zunsound-mir-opts fn dummy(x: u8) -> u8 { x } diff --git a/src/test/mir-opt/dest-prop/cycle.rs b/src/test/mir-opt/dest-prop/cycle.rs index 7fbffb13359..c9187d40867 100644 --- a/src/test/mir-opt/dest-prop/cycle.rs +++ b/src/test/mir-opt/dest-prop/cycle.rs @@ -1,5 +1,5 @@ //! Tests that cyclic assignments don't hang DestinationPropagation, and result in reasonable code. - +// compile-flags: -Zunsound-mir-opts fn val() -> i32 { 1 } diff --git a/src/test/mir-opt/dest-prop/simple.rs b/src/test/mir-opt/dest-prop/simple.rs index 4655f966998..3627d479a9a 100644 --- a/src/test/mir-opt/dest-prop/simple.rs +++ b/src/test/mir-opt/dest-prop/simple.rs @@ -1,5 +1,5 @@ //! Copy of `nrvo-simple.rs`, to ensure that full dest-prop handles it too. - +// compile-flags: -Zunsound-mir-opts // EMIT_MIR simple.nrvo.DestinationPropagation.diff fn nrvo(init: fn(&mut [u8; 1024])) -> [u8; 1024] { let mut buf = [0; 1024]; diff --git a/src/test/mir-opt/dest-prop/union.rs b/src/test/mir-opt/dest-prop/union.rs index b9d831389e8..0ac9661a66a 100644 --- a/src/test/mir-opt/dest-prop/union.rs +++ b/src/test/mir-opt/dest-prop/union.rs @@ -1,5 +1,5 @@ //! Tests that projections through unions cancel `DestinationPropagation`. - +// compile-flags: -Zunsound-mir-opts fn val() -> u32 { 1 } diff --git a/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir b/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir index a861eab39d3..a7c2c93aad2 100644 --- a/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir @@ -17,7 +17,8 @@ fn foo(_1: T, _2: i32) -> (i32, T) { debug _q => _9; // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 debug q => (*((*_6).0: &i32)); // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 debug t => (*((*_6).1: &T)); // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 - let mut _10: T; // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + let mut _10: i32; // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + let mut _11: T; // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 } } @@ -39,10 +40,13 @@ fn foo(_1: T, _2: i32) -> (i32, T) { (_7.0: i32) = move _8; // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 StorageLive(_9); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 _9 = move (_7.0: i32); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 - (_0.0: i32) = (*((*_6).0: &i32)); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 StorageLive(_10); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 - _10 = (*((*_6).1: &T)); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 - (_0.1: T) = move _10; // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + _10 = (*((*_6).0: &i32)); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + StorageLive(_11); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + _11 = (*((*_6).1: &T)); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + (_0.0: i32) = move _10; // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + (_0.1: T) = move _11; // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + StorageDead(_11); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 StorageDead(_10); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 StorageDead(_9); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 StorageDead(_8); // scope 1 at $DIR/inline-closure-captures.rs:12:8: 12:9 diff --git a/src/test/mir-opt/inline/inline_diverging.h.Inline.diff b/src/test/mir-opt/inline/inline_diverging.h.Inline.diff index e945629b613..e2fad5b60eb 100644 --- a/src/test/mir-opt/inline/inline_diverging.h.Inline.diff +++ b/src/test/mir-opt/inline/inline_diverging.h.Inline.diff @@ -5,18 +5,20 @@ let mut _0: (); // return place in scope 0 at $DIR/inline-diverging.rs:21:12: 21:12 let _1: (!, !); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 + let mut _2: fn() -> ! {sleep}; // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 -+ let mut _7: (); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 -+ let mut _8: (); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 ++ let mut _9: (); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 ++ let mut _10: (); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 + scope 1 (inlined call_twice::<!, fn() -> ! {sleep}>) { // at $DIR/inline-diverging.rs:22:5: 22:22 + debug f => _2; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + let _3: !; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + let mut _4: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 -+ let mut _5: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 -+ let mut _6: !; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 ++ let mut _6: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 ++ let mut _7: !; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 ++ let mut _8: !; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + scope 2 { + debug a => _3; // in scope 2 at $DIR/inline-diverging.rs:22:5: 22:22 ++ let _5: !; // in scope 2 at $DIR/inline-diverging.rs:22:5: 22:22 + scope 3 { -+ debug b => _6; // in scope 3 at $DIR/inline-diverging.rs:22:5: 22:22 ++ debug b => _5; // in scope 3 at $DIR/inline-diverging.rs:22:5: 22:22 + } + scope 6 (inlined <fn() -> ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { // at $DIR/inline-diverging.rs:22:5: 22:22 + scope 7 (inlined sleep) { // at $DIR/inline-diverging.rs:22:5: 22:22 @@ -40,12 +42,11 @@ - // mir::Constant // + span: $DIR/inline-diverging.rs:22:16: 22:21 // + literal: Const { ty: fn() -> ! {sleep}, val: Value(Scalar(<ZST>)) } -+ StorageLive(_6); // scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 + StorageLive(_3); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + StorageLive(_4); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + _4 = &_2; // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 -+ StorageLive(_7); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 -+ _7 = const (); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 ++ StorageLive(_9); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 ++ _9 = const (); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + goto -> bb1; // scope 4 at $DIR/inline-diverging.rs:22:5: 22:22 } diff --git a/src/test/mir-opt/inline/inline_generator.main.Inline.diff b/src/test/mir-opt/inline/inline_generator.main.Inline.diff index 066ac8d82d3..fba88c83eb4 100644 --- a/src/test/mir-opt/inline/inline_generator.main.Inline.diff +++ b/src/test/mir-opt/inline/inline_generator.main.Inline.diff @@ -24,9 +24,12 @@ + } + } + scope 6 (inlined g::{closure#0}) { // at $DIR/inline-generator.rs:9:14: 9:46 -+ debug a => _8; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ let mut _8: bool; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ let mut _9: u32; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ debug a => _11; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ let mut _8: i32; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ let mut _9: bool; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ let mut _10: bool; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ let _11: bool; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ let mut _12: u32; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + } bb0: { @@ -65,16 +68,18 @@ - // + literal: Const { ty: for<'r> fn(std::pin::Pin<&'r mut impl std::ops::Generator<bool>>, bool) -> std::ops::GeneratorState<<impl std::ops::Generator<bool> as std::ops::Generator<bool>>::Yield, <impl std::ops::Generator<bool> as std::ops::Generator<bool>>::Return> {<impl std::ops::Generator<bool> as std::ops::Generator<bool>>::resume}, val: Value(Scalar(<ZST>)) } + StorageLive(_7); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 + _7 = const false; // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 -+ StorageLive(_8); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 -+ StorageLive(_9); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 -+ _9 = discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]))); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ switchInt(move _9) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageLive(_10); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageLive(_11); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageLive(_12); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 ++ _12 = discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]))); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ switchInt(move _12) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 } - bb3: { + bb1: { -+ StorageDead(_9); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 -+ StorageDead(_8); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageDead(_12); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageDead(_11); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageDead(_10); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 + StorageDead(_7); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 StorageDead(_2); // scope 0 at $DIR/inline-generator.rs:9:45: 9:46 StorageDead(_4); // scope 0 at $DIR/inline-generator.rs:9:46: 9:47 @@ -89,28 +94,36 @@ + } + + bb3: { -+ _8 = move _7; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 -+ switchInt(move _8) -> [false: bb5, otherwise: bb4]; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ _11 = move _7; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageLive(_8); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageLive(_9); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ _9 = _11; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ switchInt(move _9) -> [false: bb5, otherwise: bb4]; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + } + + bb4: { -+ ((_1 as Yielded).0: i32) = const 7_i32; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ _8 = const 7_i32; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + goto -> bb6; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + } + + bb5: { -+ ((_1 as Yielded).0: i32) = const 13_i32; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ _8 = const 13_i32; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + goto -> bb6; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + } + + bb6: { ++ StorageDead(_9); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ ((_1 as Yielded).0: i32) = move _8; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + discriminant(_1) = 0; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]))) = 3; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + goto -> bb1; // scope 0 at $DIR/inline-generator.rs:15:11: 15:39 + } + + bb7: { -+ ((_1 as Complete).0: bool) = move _7; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageLive(_8); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ _10 = move _7; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ StorageDead(_8); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 ++ ((_1 as Complete).0: bool) = move _10; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + discriminant(_1) = 1; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]))) = 1; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46 + goto -> bb1; // scope 0 at $DIR/inline-generator.rs:15:41: 15:41 diff --git a/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff b/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff index c630ab70de1..e2ec0e82ebf 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff @@ -6,25 +6,32 @@ let _1: i32; // in scope 0 at $DIR/issue-73223.rs:2:9: 2:14 let mut _2: std::option::Option<i32>; // in scope 0 at $DIR/issue-73223.rs:2:23: 2:30 let _3: i32; // in scope 0 at $DIR/issue-73223.rs:3:14: 3:15 - let mut _5: (&i32, &i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _6: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _7: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _8: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _9: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _11: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _12: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _13: std::option::Option<std::fmt::Arguments>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _5: i32; // in scope 0 at $DIR/issue-73223.rs:7:22: 7:27 + let mut _6: (&i32, &i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _7: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _8: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _11: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _12: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _13: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _15: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _16: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _17: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _18: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _19: std::option::Option<std::fmt::Arguments>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 1 { debug split => _1; // in scope 1 at $DIR/issue-73223.rs:2:9: 2:14 let _4: std::option::Option<i32>; // in scope 1 at $DIR/issue-73223.rs:7:9: 7:14 scope 3 { debug _prev => _4; // in scope 3 at $DIR/issue-73223.rs:7:9: 7:14 + let _9: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _10: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _20: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 4 { - debug left_val => _11; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - debug right_val => _12; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _10: core::panicking::AssertKind; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug left_val => _9; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug right_val => _10; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _14: core::panicking::AssertKind; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 5 { - debug kind => _10; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug kind => _14; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } } } @@ -43,36 +50,57 @@ _1 = _3; // scope 2 at $DIR/issue-73223.rs:3:20: 3:21 StorageDead(_3); // scope 0 at $DIR/issue-73223.rs:3:20: 3:21 StorageDead(_2); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7 - ((_4 as Some).0: i32) = _1; // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 + StorageLive(_4); // scope 1 at $DIR/issue-73223.rs:7:9: 7:14 + StorageLive(_5); // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 + _5 = _1; // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 + ((_4 as Some).0: i32) = move _5; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 discriminant(_4) = 1; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 - (_5.0: &i32) = &_1; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _6 = const main::promoted[0]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_5); // scope 1 at $DIR/issue-73223.rs:7:27: 7:28 + StorageLive(_6); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _7 = &_1; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _20 = const main::promoted[0]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // ty::Const // + ty: &i32 // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[0])) // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[0])) } - (_5.1: &i32) = move _6; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _11 = (_5.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _12 = (_5.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_7); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_8); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_9); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _9 = (*_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _8 = Eq(move _9, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_9); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _7 = Not(move _8); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_8); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - switchInt(move _7) -> [false: bb2, otherwise: bb1]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _8 = _20; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + (_6.0: &i32) = move _7; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + (_6.1: &i32) = move _8; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _9 = (_6.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _10 = (_6.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _13 = (*_9); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _12 = Eq(move _13, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _11 = Not(move _12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + switchInt(move _11) -> [false: bb2, otherwise: bb1]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } bb1: { - StorageLive(_10); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_10) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_13); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_13) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - core::panicking::assert_failed::<i32, i32>(const core::panicking::AssertKind::Eq, move _11, move _12, move _13); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_14); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + discriminant(_14) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_15); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_16); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _16 = _9; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _15 = _16; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_17); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_18); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _18 = _10; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _17 = _18; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_19); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + discriminant(_19) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + core::panicking::assert_failed::<i32, i32>(const core::panicking::AssertKind::Eq, move _15, move _17, move _19); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(core::panicking::AssertKind, &'r i32, &'s i32, std::option::Option<std::fmt::Arguments<'t0>>) -> ! {core::panicking::assert_failed::<i32, i32>}, val: Value(Scalar(<ZST>)) } @@ -85,8 +113,12 @@ } bb2: { - StorageDead(_7); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_6); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 + StorageDead(_4); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2 StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 } diff --git a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff index c630ab70de1..e2ec0e82ebf 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff @@ -6,25 +6,32 @@ let _1: i32; // in scope 0 at $DIR/issue-73223.rs:2:9: 2:14 let mut _2: std::option::Option<i32>; // in scope 0 at $DIR/issue-73223.rs:2:23: 2:30 let _3: i32; // in scope 0 at $DIR/issue-73223.rs:3:14: 3:15 - let mut _5: (&i32, &i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _6: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _7: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _8: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _9: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _11: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _12: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _13: std::option::Option<std::fmt::Arguments>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _5: i32; // in scope 0 at $DIR/issue-73223.rs:7:22: 7:27 + let mut _6: (&i32, &i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _7: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _8: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _11: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _12: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _13: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _15: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _16: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _17: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _18: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _19: std::option::Option<std::fmt::Arguments>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 1 { debug split => _1; // in scope 1 at $DIR/issue-73223.rs:2:9: 2:14 let _4: std::option::Option<i32>; // in scope 1 at $DIR/issue-73223.rs:7:9: 7:14 scope 3 { debug _prev => _4; // in scope 3 at $DIR/issue-73223.rs:7:9: 7:14 + let _9: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _10: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _20: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 4 { - debug left_val => _11; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - debug right_val => _12; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _10: core::panicking::AssertKind; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug left_val => _9; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug right_val => _10; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _14: core::panicking::AssertKind; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 5 { - debug kind => _10; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug kind => _14; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } } } @@ -43,36 +50,57 @@ _1 = _3; // scope 2 at $DIR/issue-73223.rs:3:20: 3:21 StorageDead(_3); // scope 0 at $DIR/issue-73223.rs:3:20: 3:21 StorageDead(_2); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7 - ((_4 as Some).0: i32) = _1; // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 + StorageLive(_4); // scope 1 at $DIR/issue-73223.rs:7:9: 7:14 + StorageLive(_5); // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 + _5 = _1; // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 + ((_4 as Some).0: i32) = move _5; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 discriminant(_4) = 1; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 - (_5.0: &i32) = &_1; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _6 = const main::promoted[0]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_5); // scope 1 at $DIR/issue-73223.rs:7:27: 7:28 + StorageLive(_6); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _7 = &_1; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _20 = const main::promoted[0]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // ty::Const // + ty: &i32 // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[0])) // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[0])) } - (_5.1: &i32) = move _6; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _11 = (_5.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _12 = (_5.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_7); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_8); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_9); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _9 = (*_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _8 = Eq(move _9, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_9); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _7 = Not(move _8); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_8); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - switchInt(move _7) -> [false: bb2, otherwise: bb1]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _8 = _20; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + (_6.0: &i32) = move _7; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + (_6.1: &i32) = move _8; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _9 = (_6.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _10 = (_6.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _13 = (*_9); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _12 = Eq(move _13, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _11 = Not(move _12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + switchInt(move _11) -> [false: bb2, otherwise: bb1]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL } bb1: { - StorageLive(_10); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_10) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_13); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_13) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - core::panicking::assert_failed::<i32, i32>(const core::panicking::AssertKind::Eq, move _11, move _12, move _13); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_14); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + discriminant(_14) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_15); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_16); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _16 = _9; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _15 = _16; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_17); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_18); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _18 = _10; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _17 = _18; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_19); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + discriminant(_19) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + core::panicking::assert_failed::<i32, i32>(const core::panicking::AssertKind::Eq, move _15, move _17, move _19); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(core::panicking::AssertKind, &'r i32, &'s i32, std::option::Option<std::fmt::Arguments<'t0>>) -> ! {core::panicking::assert_failed::<i32, i32>}, val: Value(Scalar(<ZST>)) } @@ -85,8 +113,12 @@ } bb2: { - StorageDead(_7); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_6); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 + StorageDead(_4); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2 StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 } diff --git a/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir b/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir index 0f718a720f4..19d161ac2b1 100644 --- a/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir +++ b/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir @@ -3,60 +3,67 @@ fn num_to_digit(_1: char) -> u32 { debug num => _1; // in scope 0 at $DIR/issue-59352.rs:12:21: 12:24 let mut _0: u32; // return place in scope 0 at $DIR/issue-59352.rs:12:35: 12:38 - let mut _2: std::option::Option<u32>; // in scope 0 at $DIR/issue-59352.rs:14:26: 14:41 - let mut _3: char; // in scope 0 at $DIR/issue-59352.rs:14:26: 14:29 - let mut _4: u32; // in scope 0 at $DIR/issue-59352.rs:14:8: 14:23 - let mut _9: isize; // in scope 0 at $DIR/issue-59352.rs:14:8: 14:23 + let mut _2: char; // in scope 0 at $DIR/issue-59352.rs:14:8: 14:11 + let mut _3: std::option::Option<u32>; // in scope 0 at $DIR/issue-59352.rs:14:26: 14:41 + let mut _4: char; // in scope 0 at $DIR/issue-59352.rs:14:26: 14:29 + let mut _5: u32; // in scope 0 at $DIR/issue-59352.rs:14:8: 14:23 + let mut _11: isize; // in scope 0 at $DIR/issue-59352.rs:14:8: 14:23 scope 1 (inlined char::methods::<impl char>::is_digit) { // at $DIR/issue-59352.rs:14:8: 14:23 - debug self => _7; // in scope 1 at $DIR/issue-59352.rs:14:8: 14:23 - debug radix => _4; // in scope 1 at $DIR/issue-59352.rs:14:8: 14:23 - let mut _5: &std::option::Option<u32>; // in scope 1 at $DIR/issue-59352.rs:14:8: 14:23 - let _6: std::option::Option<u32>; // in scope 1 at $DIR/issue-59352.rs:14:8: 14:23 - let mut _7: char; // in scope 1 at $DIR/issue-59352.rs:14:8: 14:23 + debug self => _2; // in scope 1 at $DIR/issue-59352.rs:14:8: 14:23 + debug radix => _5; // in scope 1 at $DIR/issue-59352.rs:14:8: 14:23 + let mut _6: &std::option::Option<u32>; // in scope 1 at $DIR/issue-59352.rs:14:8: 14:23 + let _7: std::option::Option<u32>; // in scope 1 at $DIR/issue-59352.rs:14:8: 14:23 + let mut _8: char; // in scope 1 at $DIR/issue-59352.rs:14:8: 14:23 scope 2 (inlined Option::<u32>::is_some) { // at $DIR/issue-59352.rs:14:8: 14:23 - debug self => _5; // in scope 2 at $DIR/issue-59352.rs:14:8: 14:23 + debug self => _6; // in scope 2 at $DIR/issue-59352.rs:14:8: 14:23 + let mut _9: isize; // in scope 2 at $DIR/issue-59352.rs:14:8: 14:23 } } scope 3 (inlined #[track_caller] Option::<u32>::unwrap) { // at $DIR/issue-59352.rs:14:26: 14:50 - debug self => _2; // in scope 3 at $DIR/issue-59352.rs:14:26: 14:50 - let mut _8: isize; // in scope 3 at $DIR/issue-59352.rs:14:26: 14:50 + debug self => _3; // in scope 3 at $DIR/issue-59352.rs:14:26: 14:50 + let mut _10: isize; // in scope 3 at $DIR/issue-59352.rs:14:26: 14:50 scope 4 { debug val => _0; // in scope 4 at $DIR/issue-59352.rs:14:26: 14:50 } } bb0: { - _7 = _1; // scope 0 at $DIR/issue-59352.rs:14:8: 14:11 - StorageLive(_4); // scope 0 at $DIR/issue-59352.rs:14:8: 14:23 - _4 = const 8_u32; // scope 0 at $DIR/issue-59352.rs:14:8: 14:23 - StorageLive(_5); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 + StorageLive(_2); // scope 0 at $DIR/issue-59352.rs:14:8: 14:11 + _2 = _1; // scope 0 at $DIR/issue-59352.rs:14:8: 14:11 + StorageLive(_5); // scope 0 at $DIR/issue-59352.rs:14:8: 14:23 + _5 = const 8_u32; // scope 0 at $DIR/issue-59352.rs:14:8: 14:23 StorageLive(_6); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 - _6 = char::methods::<impl char>::to_digit(move _7, const 8_u32) -> bb5; // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 + StorageLive(_7); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 + StorageLive(_8); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 + _8 = _2; // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 + _7 = char::methods::<impl char>::to_digit(move _8, const 8_u32) -> bb5; // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 // mir::Constant // + span: $DIR/issue-59352.rs:14:8: 14:23 // + literal: Const { ty: fn(char, u32) -> std::option::Option<u32> {std::char::methods::<impl char>::to_digit}, val: Value(Scalar(<ZST>)) } } bb1: { - StorageLive(_2); // scope 0 at $DIR/issue-59352.rs:14:26: 14:41 - StorageLive(_3); // scope 0 at $DIR/issue-59352.rs:14:26: 14:29 - _3 = _1; // scope 0 at $DIR/issue-59352.rs:14:26: 14:29 - _2 = char::methods::<impl char>::to_digit(move _3, const 8_u32) -> bb3; // scope 0 at $DIR/issue-59352.rs:14:26: 14:41 + StorageDead(_11); // scope 0 at $DIR/issue-59352.rs:14:5: 14:63 + StorageLive(_3); // scope 0 at $DIR/issue-59352.rs:14:26: 14:41 + StorageLive(_4); // scope 0 at $DIR/issue-59352.rs:14:26: 14:29 + _4 = _1; // scope 0 at $DIR/issue-59352.rs:14:26: 14:29 + _3 = char::methods::<impl char>::to_digit(move _4, const 8_u32) -> bb3; // scope 0 at $DIR/issue-59352.rs:14:26: 14:41 // mir::Constant // + span: $DIR/issue-59352.rs:14:30: 14:38 // + literal: Const { ty: fn(char, u32) -> std::option::Option<u32> {std::char::methods::<impl char>::to_digit}, val: Value(Scalar(<ZST>)) } } bb2: { + StorageDead(_11); // scope 0 at $DIR/issue-59352.rs:14:5: 14:63 _0 = const 0_u32; // scope 0 at $DIR/issue-59352.rs:14:60: 14:61 goto -> bb4; // scope 0 at $DIR/issue-59352.rs:14:5: 14:63 } bb3: { - StorageDead(_3); // scope 0 at $DIR/issue-59352.rs:14:40: 14:41 - StorageLive(_8); // scope 0 at $DIR/issue-59352.rs:14:26: 14:50 - _8 = discriminant(_2); // scope 3 at $DIR/issue-59352.rs:14:26: 14:50 - switchInt(move _8) -> [0_isize: bb6, 1_isize: bb8, otherwise: bb7]; // scope 3 at $DIR/issue-59352.rs:14:26: 14:50 + StorageDead(_4); // scope 0 at $DIR/issue-59352.rs:14:40: 14:41 + StorageLive(_10); // scope 0 at $DIR/issue-59352.rs:14:26: 14:50 + _10 = discriminant(_3); // scope 3 at $DIR/issue-59352.rs:14:26: 14:50 + switchInt(move _10) -> [0_isize: bb6, 1_isize: bb8, otherwise: bb7]; // scope 3 at $DIR/issue-59352.rs:14:26: 14:50 } bb4: { @@ -64,12 +71,18 @@ fn num_to_digit(_1: char) -> u32 { } bb5: { - _5 = &_6; // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 - _9 = discriminant((*_5)); // scope 2 at $DIR/issue-59352.rs:14:8: 14:23 - StorageDead(_5); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 + _6 = &_7; // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 + StorageDead(_8); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 + StorageLive(_9); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 + _9 = discriminant((*_6)); // scope 2 at $DIR/issue-59352.rs:14:8: 14:23 + StorageLive(_11); // scope 2 at $DIR/issue-59352.rs:14:8: 14:23 + _11 = move _9; // scope 2 at $DIR/issue-59352.rs:14:8: 14:23 + StorageDead(_9); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 StorageDead(_6); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 - StorageDead(_4); // scope 0 at $DIR/issue-59352.rs:14:8: 14:23 - switchInt(move _9) -> [1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/issue-59352.rs:14:5: 14:63 + StorageDead(_7); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23 + StorageDead(_5); // scope 0 at $DIR/issue-59352.rs:14:8: 14:23 + StorageDead(_2); // scope 0 at $DIR/issue-59352.rs:14:22: 14:23 + switchInt(move _11) -> [1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/issue-59352.rs:14:5: 14:63 } bb6: { @@ -90,9 +103,9 @@ fn num_to_digit(_1: char) -> u32 { } bb8: { - _0 = move ((_2 as Some).0: u32); // scope 3 at $DIR/issue-59352.rs:14:26: 14:50 - StorageDead(_8); // scope 0 at $DIR/issue-59352.rs:14:26: 14:50 - StorageDead(_2); // scope 0 at $DIR/issue-59352.rs:14:49: 14:50 + _0 = move ((_3 as Some).0: u32); // scope 3 at $DIR/issue-59352.rs:14:26: 14:50 + StorageDead(_10); // scope 0 at $DIR/issue-59352.rs:14:26: 14:50 + StorageDead(_3); // scope 0 at $DIR/issue-59352.rs:14:49: 14:50 goto -> bb4; // scope 0 at $DIR/issue-59352.rs:14:5: 14:63 } } diff --git a/src/test/mir-opt/lower_intrinsics.f_u64.PreCodegen.before.mir b/src/test/mir-opt/lower_intrinsics.f_u64.PreCodegen.before.mir index 740a6e0edb0..a87d5e1f0ff 100644 --- a/src/test/mir-opt/lower_intrinsics.f_u64.PreCodegen.before.mir +++ b/src/test/mir-opt/lower_intrinsics.f_u64.PreCodegen.before.mir @@ -2,9 +2,9 @@ fn f_u64() -> () { let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics.rs:34:16: 34:16 + let mut _1: u64; // in scope 0 at $DIR/lower_intrinsics.rs:35:5: 35:21 scope 1 (inlined f_dispatch::<u64>) { // at $DIR/lower_intrinsics.rs:35:5: 35:21 debug t => _1; // in scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 - let mut _1: u64; // in scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 let _2: (); // in scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 let mut _3: u64; // in scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 scope 2 (inlined std::mem::size_of::<u64>) { // at $DIR/lower_intrinsics.rs:35:5: 35:21 @@ -12,6 +12,7 @@ fn f_u64() -> () { } bb0: { + StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:35:5: 35:21 _1 = const 0_u64; // scope 0 at $DIR/lower_intrinsics.rs:35:5: 35:21 StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 @@ -25,6 +26,7 @@ fn f_u64() -> () { bb1: { StorageDead(_3); // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 StorageDead(_2); // scope 1 at $DIR/lower_intrinsics.rs:35:5: 35:21 + StorageDead(_1); // scope 0 at $DIR/lower_intrinsics.rs:35:5: 35:21 _0 = const (); // scope 0 at $DIR/lower_intrinsics.rs:34:16: 36:2 return; // scope 0 at $DIR/lower_intrinsics.rs:36:2: 36:2 } diff --git a/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff index dbac7dff9e2..f1718c5752c 100644 --- a/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff @@ -17,8 +17,13 @@ StorageLive(_1); // scope 0 at $DIR/simplify-locals.rs:14:9: 14:14 _1 = [const 0_u8; 10]; // scope 0 at $DIR/simplify-locals.rs:14:17: 14:26 - StorageLive(_2); // scope 1 at $DIR/simplify-locals.rs:16:20: 16:26 -- _3 = &_1; // scope 1 at $DIR/simplify-locals.rs:16:20: 16:26 +- StorageLive(_3); // scope 1 at $DIR/simplify-locals.rs:16:20: 16:26 +- StorageLive(_4); // scope 1 at $DIR/simplify-locals.rs:16:20: 16:26 +- _4 = &_1; // scope 1 at $DIR/simplify-locals.rs:16:20: 16:26 +- _3 = _4; // scope 1 at $DIR/simplify-locals.rs:16:20: 16:26 - _2 = move _3 as &[u8] (Pointer(Unsize)); // scope 1 at $DIR/simplify-locals.rs:16:20: 16:26 +- StorageDead(_3); // scope 1 at $DIR/simplify-locals.rs:16:25: 16:26 +- StorageDead(_4); // scope 1 at $DIR/simplify-locals.rs:16:26: 16:27 - StorageDead(_2); // scope 1 at $DIR/simplify-locals.rs:16:26: 16:27 _0 = const (); // scope 0 at $DIR/simplify-locals.rs:13:8: 17:2 StorageDead(_1); // scope 0 at $DIR/simplify-locals.rs:17:1: 17:2 diff --git a/src/test/ui/directory_ownership/macro-expanded-mod.rs b/src/test/ui/directory_ownership/macro-expanded-mod.rs index 9cb159603a8..fa81769e5a8 100644 --- a/src/test/ui/directory_ownership/macro-expanded-mod.rs +++ b/src/test/ui/directory_ownership/macro-expanded-mod.rs @@ -2,7 +2,7 @@ macro_rules! mod_decl { ($i:ident) => { - mod $i; //~ ERROR Cannot declare a non-inline module inside a block + mod $i; //~ ERROR cannot declare a non-inline module inside a block }; } diff --git a/src/test/ui/directory_ownership/macro-expanded-mod.stderr b/src/test/ui/directory_ownership/macro-expanded-mod.stderr index f90419247c9..4039728e18a 100644 --- a/src/test/ui/directory_ownership/macro-expanded-mod.stderr +++ b/src/test/ui/directory_ownership/macro-expanded-mod.stderr @@ -1,4 +1,4 @@ -error: Cannot declare a non-inline module inside a block unless it has a path attribute +error: cannot declare a non-inline module inside a block unless it has a path attribute --> $DIR/macro-expanded-mod.rs:5:9 | LL | mod $i; diff --git a/src/test/ui/directory_ownership/non-inline-mod-restriction.rs b/src/test/ui/directory_ownership/non-inline-mod-restriction.rs index af31b8a4928..de4f816656c 100644 --- a/src/test/ui/directory_ownership/non-inline-mod-restriction.rs +++ b/src/test/ui/directory_ownership/non-inline-mod-restriction.rs @@ -1,5 +1,5 @@ // Test that non-inline modules are not allowed inside blocks. fn main() { - mod foo; //~ ERROR Cannot declare a non-inline module inside a block + mod foo; //~ ERROR cannot declare a non-inline module inside a block } diff --git a/src/test/ui/directory_ownership/non-inline-mod-restriction.stderr b/src/test/ui/directory_ownership/non-inline-mod-restriction.stderr index d034942ca5d..64189bee43f 100644 --- a/src/test/ui/directory_ownership/non-inline-mod-restriction.stderr +++ b/src/test/ui/directory_ownership/non-inline-mod-restriction.stderr @@ -1,4 +1,4 @@ -error: Cannot declare a non-inline module inside a block unless it has a path attribute +error: cannot declare a non-inline module inside a block unless it has a path attribute --> $DIR/non-inline-mod-restriction.rs:4:5 | LL | mod foo; diff --git a/src/test/ui/modules/path-no-file-name.rs b/src/test/ui/modules/path-no-file-name.rs new file mode 100644 index 00000000000..f62cd2a9eb4 --- /dev/null +++ b/src/test/ui/modules/path-no-file-name.rs @@ -0,0 +1,7 @@ +// normalize-stderr-test: "\.:.*\(" -> ".: $$ACCESS_DENIED_MSG (" +// normalize-stderr-test: "os error \d+" -> "os error $$ACCESS_DENIED_CODE" + +#[path = "."] +mod m; //~ ERROR couldn't read + +fn main() {} diff --git a/src/test/ui/modules/path-no-file-name.stderr b/src/test/ui/modules/path-no-file-name.stderr new file mode 100644 index 00000000000..32a213c68f6 --- /dev/null +++ b/src/test/ui/modules/path-no-file-name.stderr @@ -0,0 +1,8 @@ +error: couldn't read $DIR/.: $ACCESS_DENIED_MSG (os error $ACCESS_DENIED_CODE) + --> $DIR/path-no-file-name.rs:5:1 + | +LL | mod m; + | ^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/parser/circular_modules_main.rs b/src/test/ui/parser/circular_modules_main.rs index 1ae36a1f760..d4b47efe681 100644 --- a/src/test/ui/parser/circular_modules_main.rs +++ b/src/test/ui/parser/circular_modules_main.rs @@ -1,10 +1,12 @@ +// error-pattern: circular modules + #[path = "circular_modules_hello.rs"] -mod circular_modules_hello; //~ ERROR: circular modules +mod circular_modules_hello; pub fn hi_str() -> String { "Hi!".to_string() } fn main() { - circular_modules_hello::say_hello(); //~ ERROR cannot find function `say_hello` in module + circular_modules_hello::say_hello(); } diff --git a/src/test/ui/parser/circular_modules_main.stderr b/src/test/ui/parser/circular_modules_main.stderr index 5d4db8c31a2..ee45f65a3bd 100644 --- a/src/test/ui/parser/circular_modules_main.stderr +++ b/src/test/ui/parser/circular_modules_main.stderr @@ -1,18 +1,18 @@ -error: circular modules: $DIR/circular_modules_hello.rs -> $DIR/circular_modules_main.rs -> $DIR/circular_modules_hello.rs - --> $DIR/circular_modules_main.rs:2:1 +error: circular modules: $DIR/circular_modules_main.rs -> $DIR/circular_modules_hello.rs -> $DIR/circular_modules_main.rs + --> $DIR/circular_modules_hello.rs:4:1 | -LL | mod circular_modules_hello; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | mod circular_modules_main; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0425]: cannot find function `say_hello` in module `circular_modules_hello` - --> $DIR/circular_modules_main.rs:9:29 +error[E0425]: cannot find function `hi_str` in module `circular_modules_main` + --> $DIR/circular_modules_hello.rs:7:43 | -LL | circular_modules_hello::say_hello(); - | ^^^^^^^^^ not found in `circular_modules_hello` +LL | println!("{}", circular_modules_main::hi_str()); + | ^^^^^^ not found in `circular_modules_main` | help: consider importing this function | -LL | use circular_modules_hello::say_hello; +LL | use hi_str; | error: aborting due to 2 previous errors diff --git a/src/test/ui/proc-macro/cfg-eval-fail.rs b/src/test/ui/proc-macro/cfg-eval-fail.rs new file mode 100644 index 00000000000..379491f3126 --- /dev/null +++ b/src/test/ui/proc-macro/cfg-eval-fail.rs @@ -0,0 +1,9 @@ +#![feature(cfg_eval)] +#![feature(stmt_expr_attributes)] + +fn main() { + let _ = #[cfg_eval] #[cfg(FALSE)] 0; + //~^ ERROR removing an expression is not supported in this position + //~| ERROR removing an expression is not supported in this position + //~| ERROR removing an expression is not supported in this position +} diff --git a/src/test/ui/proc-macro/cfg-eval-fail.stderr b/src/test/ui/proc-macro/cfg-eval-fail.stderr new file mode 100644 index 00000000000..010ac006b0b --- /dev/null +++ b/src/test/ui/proc-macro/cfg-eval-fail.stderr @@ -0,0 +1,20 @@ +error: removing an expression is not supported in this position + --> $DIR/cfg-eval-fail.rs:5:25 + | +LL | let _ = #[cfg_eval] #[cfg(FALSE)] 0; + | ^^^^^^^^^^^^^ + +error: removing an expression is not supported in this position + --> $DIR/cfg-eval-fail.rs:5:25 + | +LL | let _ = #[cfg_eval] #[cfg(FALSE)] 0; + | ^^^^^^^^^^^^^ + +error: removing an expression is not supported in this position + --> $DIR/cfg-eval-fail.rs:5:25 + | +LL | let _ = #[cfg_eval] #[cfg(FALSE)] 0; + | ^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/proc-macro/cfg-eval.rs b/src/test/ui/proc-macro/cfg-eval.rs new file mode 100644 index 00000000000..ea397df5452 --- /dev/null +++ b/src/test/ui/proc-macro/cfg-eval.rs @@ -0,0 +1,32 @@ +// check-pass +// compile-flags: -Z span-debug +// aux-build:test-macros.rs + +#![feature(cfg_eval)] +#![feature(proc_macro_hygiene)] +#![feature(stmt_expr_attributes)] + +#![no_std] // Don't load unnecessary hygiene information from std +extern crate std; + +#[macro_use] +extern crate test_macros; + +#[cfg_eval] +#[print_attr] +struct S1 { + #[cfg(FALSE)] + field_false: u8, + #[cfg(all(/*true*/))] + #[cfg_attr(FALSE, unknown_attr)] + #[cfg_attr(all(/*true*/), allow())] + field_true: u8, +} + +#[cfg_eval] +#[cfg(FALSE)] +struct S2 {} + +fn main() { + let _ = #[cfg_eval] #[print_attr](#[cfg(FALSE)] 0, #[cfg(all(/*true*/))] 1); +} diff --git a/src/test/ui/proc-macro/cfg-eval.stdout b/src/test/ui/proc-macro/cfg-eval.stdout new file mode 100644 index 00000000000..b98e8961bfe --- /dev/null +++ b/src/test/ui/proc-macro/cfg-eval.stdout @@ -0,0 +1,135 @@ +PRINT-ATTR INPUT (DISPLAY): struct S1 { #[cfg(all())] #[allow()] field_true : u8, } +PRINT-ATTR INPUT (DEBUG): TokenStream [ + Ident { + ident: "struct", + span: $DIR/cfg-eval.rs:17:1: 24:2 (#0), + }, + Ident { + ident: "S1", + span: $DIR/cfg-eval.rs:17:1: 24:2 (#0), + }, + Group { + delimiter: Brace, + stream: TokenStream [ + Punct { + ch: '#', + spacing: Alone, + span: $DIR/cfg-eval.rs:17:1: 24:2 (#0), + }, + Group { + delimiter: Bracket, + stream: TokenStream [ + Ident { + ident: "cfg", + span: $DIR/cfg-eval.rs:17:1: 24:2 (#0), + }, + Group { + delimiter: Parenthesis, + stream: TokenStream [ + Ident { + ident: "all", + span: $DIR/cfg-eval.rs:17:1: 24:2 (#0), + }, + Group { + delimiter: Parenthesis, + stream: TokenStream [], + span: $DIR/cfg-eval.rs:17:1: 24:2 (#0), + }, + ], + span: $DIR/cfg-eval.rs:17:1: 24:2 (#0), + }, + ], + span: $DIR/cfg-eval.rs:17:1: 24:2 (#0), + }, + Punct { + ch: '#', + spacing: Alone, + span: $DIR/cfg-eval.rs:17:1: 24:2 (#0), + }, + Group { + delimiter: Bracket, + stream: TokenStream [ + Ident { + ident: "allow", + span: $DIR/cfg-eval.rs:17:1: 24:2 (#0), + }, + Group { + delimiter: Parenthesis, + stream: TokenStream [], + span: $DIR/cfg-eval.rs:17:1: 24:2 (#0), + }, + ], + span: $DIR/cfg-eval.rs:17:1: 24:2 (#0), + }, + Ident { + ident: "field_true", + span: $DIR/cfg-eval.rs:17:1: 24:2 (#0), + }, + Punct { + ch: ':', + spacing: Alone, + span: $DIR/cfg-eval.rs:17:1: 24:2 (#0), + }, + Ident { + ident: "u8", + span: $DIR/cfg-eval.rs:17:1: 24:2 (#0), + }, + Punct { + ch: ',', + spacing: Alone, + span: $DIR/cfg-eval.rs:17:1: 24:2 (#0), + }, + ], + span: $DIR/cfg-eval.rs:17:1: 24:2 (#0), + }, +] +PRINT-ATTR INPUT (DISPLAY): (#[cfg(all())] 1,) +PRINT-ATTR INPUT (DEBUG): TokenStream [ + Group { + delimiter: Parenthesis, + stream: TokenStream [ + Punct { + ch: '#', + spacing: Alone, + span: $DIR/cfg-eval.rs:31:38: 31:80 (#0), + }, + Group { + delimiter: Bracket, + stream: TokenStream [ + Ident { + ident: "cfg", + span: $DIR/cfg-eval.rs:31:38: 31:80 (#0), + }, + Group { + delimiter: Parenthesis, + stream: TokenStream [ + Ident { + ident: "all", + span: $DIR/cfg-eval.rs:31:38: 31:80 (#0), + }, + Group { + delimiter: Parenthesis, + stream: TokenStream [], + span: $DIR/cfg-eval.rs:31:38: 31:80 (#0), + }, + ], + span: $DIR/cfg-eval.rs:31:38: 31:80 (#0), + }, + ], + span: $DIR/cfg-eval.rs:31:38: 31:80 (#0), + }, + Literal { + kind: Integer, + symbol: "1", + suffix: None, + span: $DIR/cfg-eval.rs:31:38: 31:80 (#0), + }, + Punct { + ch: ',', + spacing: Alone, + span: $DIR/cfg-eval.rs:31:38: 31:80 (#0), + }, + ], + span: $DIR/cfg-eval.rs:31:38: 31:80 (#0), + }, +] |
