From ab4675583f58572478fa6abf42557c8aab9a358b Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Sun, 10 Apr 2022 23:13:12 +0300 Subject: [PATCH 01/10] Note the contacts for the nvptx64 target(s) --- .../platform-support/nvptx64-nvidia-cuda.md | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/doc/rustc/src/platform-support/nvptx64-nvidia-cuda.md diff --git a/src/doc/rustc/src/platform-support/nvptx64-nvidia-cuda.md b/src/doc/rustc/src/platform-support/nvptx64-nvidia-cuda.md new file mode 100644 index 0000000000000..1af1410d4bb60 --- /dev/null +++ b/src/doc/rustc/src/platform-support/nvptx64-nvidia-cuda.md @@ -0,0 +1,58 @@ +# `nvptx64-nvidia-cuda` + +**Tier: 2** + +This is the target meant for deploying code for Nvidia® accelerators based on their CUDA +platform. + +## Target maintainers + +- Riccardo D'Ambrosio, https://github.com/RDambrosio016 +- Kjetil Kjeka, https://github.com/kjetilkjeka + + From f75d02d66975bed3636e89f56077bbc53fe5f74d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Wed, 11 May 2022 04:50:23 +0000 Subject: [PATCH 02/10] openbsd: convert futex timeout managment to Timespec usage --- library/std/src/sys/unix/futex.rs | 14 ++++++-------- library/std/src/sys/unix/time.rs | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/library/std/src/sys/unix/futex.rs b/library/std/src/sys/unix/futex.rs index 8d5ad18997d07..d70108e7bd627 100644 --- a/library/std/src/sys/unix/futex.rs +++ b/library/std/src/sys/unix/futex.rs @@ -136,15 +136,13 @@ pub fn futex_wake_all(futex: &AtomicU32) { #[cfg(target_os = "openbsd")] pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option) -> bool { + use super::time::Timespec; use crate::ptr::{null, null_mut}; - let timespec = timeout.and_then(|d| { - Some(libc::timespec { - // Sleep forever if the timeout is longer than fits in a timespec. - tv_sec: d.as_secs().try_into().ok()?, - // This conversion never truncates, as subsec_nanos is always <1e9. - tv_nsec: d.subsec_nanos() as _, - }) - }); + + // Overflows are rounded up to an infinite timeout (None). + let timespec = timeout + .and_then(|d| Timespec::zero().checked_add_duration(&d)) + .and_then(|t| t.to_timespec()); let r = unsafe { libc::futex( diff --git a/library/std/src/sys/unix/time.rs b/library/std/src/sys/unix/time.rs index 333182bdad4de..df95f1494fd56 100644 --- a/library/std/src/sys/unix/time.rs +++ b/library/std/src/sys/unix/time.rs @@ -51,7 +51,7 @@ impl fmt::Debug for SystemTime { } impl Timespec { - const fn zero() -> Timespec { + pub const fn zero() -> Timespec { Timespec { tv_sec: 0, tv_nsec: 0 } } From 3cadc11d838d5f07b2849ba148dfb83c006fb70f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Wed, 11 May 2022 04:50:48 +0000 Subject: [PATCH 03/10] avoid using both Some() and ? on linux/android/freebsd code --- library/std/src/sys/unix/futex.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sys/unix/futex.rs b/library/std/src/sys/unix/futex.rs index d70108e7bd627..8d05cb44b9479 100644 --- a/library/std/src/sys/unix/futex.rs +++ b/library/std/src/sys/unix/futex.rs @@ -25,7 +25,7 @@ pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option) - // // Overflows are rounded up to an infinite timeout (None). let timespec = timeout - .and_then(|d| Some(Timespec::now(libc::CLOCK_MONOTONIC).checked_add_duration(&d)?)) + .and_then(|d| Timespec::now(libc::CLOCK_MONOTONIC).checked_add_duration(&d)) .and_then(|t| t.to_timespec()); loop { From 42f8e1f879487e3b0a48b9635eac11aaf7b672a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Wed, 11 May 2022 04:51:09 +0000 Subject: [PATCH 04/10] to_timespec could be unused by some targets --- library/std/src/sys/unix/time.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/std/src/sys/unix/time.rs b/library/std/src/sys/unix/time.rs index df95f1494fd56..f99c453a3a85b 100644 --- a/library/std/src/sys/unix/time.rs +++ b/library/std/src/sys/unix/time.rs @@ -125,6 +125,7 @@ impl Timespec { Some(Timespec::new(secs, nsec as i64)) } + #[allow(dead_code)] pub fn to_timespec(&self) -> Option { Some(libc::timespec { tv_sec: self.tv_sec.try_into().ok()?, From 84615e868b339716a93e7e05f9fb07356c5a9610 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 11 May 2022 11:27:00 +0200 Subject: [PATCH 05/10] Add missing CSS file for settings page --- src/librustdoc/html/render/context.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index a30c533aa48c8..528180288de6a 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -596,9 +596,11 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { |buf: &mut Buffer| { write!( buf, - "", - page.static_root_path.unwrap_or(""), - page.resource_suffix + "\ + ", + root_path = page.static_root_path.unwrap_or(""), + suffix = page.resource_suffix, ) }, &self.shared.style_files, From 92482cabaad0a0a63514bdcdcf6e4c8d8dee25e9 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 11 May 2022 11:27:13 +0200 Subject: [PATCH 06/10] Remove unused CSS settings rules --- src/librustdoc/html/static/css/settings.css | 36 --------------------- 1 file changed, 36 deletions(-) diff --git a/src/librustdoc/html/static/css/settings.css b/src/librustdoc/html/static/css/settings.css index 7b337c2bc7a33..07588748ad68e 100644 --- a/src/librustdoc/html/static/css/settings.css +++ b/src/librustdoc/html/static/css/settings.css @@ -56,38 +56,6 @@ position: absolute; } -.select-wrapper { - float: right; - position: relative; - height: 27px; - min-width: 25%; -} - -.select-wrapper select { - appearance: none; - -moz-appearance: none; - -webkit-appearance: none; - background: none; - border: 2px solid #ccc; - padding-right: 28px; - width: 100%; -} - -.select-wrapper img { - pointer-events: none; - position: absolute; - right: 0; - bottom: 0; - background: #ccc; - height: 100%; - width: 28px; - padding: 0px 4px; -} - -.select-wrapper select option { - color: initial; -} - .slider { position: absolute; cursor: pointer; @@ -96,7 +64,6 @@ right: 0; bottom: 0; background-color: #ccc; - -webkit-transition: .3s; transition: .3s; } @@ -108,7 +75,6 @@ left: 4px; bottom: 4px; background-color: white; - -webkit-transition: .3s; transition: .3s; } @@ -121,8 +87,6 @@ input:focus + .slider { } input:checked + .slider:before { - -webkit-transform: translateX(19px); - -ms-transform: translateX(19px); transform: translateX(19px); } From dd6bb09133f1f97db6a36024bf4e66489fc760c1 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 11 May 2022 11:29:21 +0200 Subject: [PATCH 07/10] Ensure that the settings CSS is loaded on the settings page --- src/test/rustdoc-gui/settings.goml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/rustdoc-gui/settings.goml b/src/test/rustdoc-gui/settings.goml index 6c4611b1cb2a6..18270264266f4 100644 --- a/src/test/rustdoc-gui/settings.goml +++ b/src/test/rustdoc-gui/settings.goml @@ -65,3 +65,8 @@ assert: ".setting-line.hidden #theme" // We check their text as well. assert-text: ("#preferred-dark-theme .setting-name", "Preferred dark theme") assert-text: ("#preferred-light-theme .setting-name", "Preferred light theme") + +// Now we go to the settings page to check that the CSS is loaded as expected. +goto: file://|DOC_PATH|/settings.html +wait-for: "#settings" +assert-css: (".setting-line .toggle", {"width": "45px", "margin-right": "20px"}) From 2c604f63fcc4287c4608f51467a44942f2dd482a Mon Sep 17 00:00:00 2001 From: "minami.yoshihiko" Date: Wed, 11 May 2022 20:21:10 +0900 Subject: [PATCH 08/10] update graphviz links add subdomain --- compiler/rustc_graphviz/src/lib.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_graphviz/src/lib.rs b/compiler/rustc_graphviz/src/lib.rs index e318090ebe15a..676c66f41a9ae 100644 --- a/compiler/rustc_graphviz/src/lib.rs +++ b/compiler/rustc_graphviz/src/lib.rs @@ -4,18 +4,16 @@ //! use with [Graphviz](https://www.graphviz.org/) by walking a labeled //! graph. (Graphviz can then automatically lay out the nodes and edges //! of the graph, and also optionally render the graph as an image or -//! other [output formats]( -//! https://www.graphviz.org/content/output-formats), such as SVG.) +//! other [output formats](https://www.graphviz.org/docs/outputs), such as SVG.) //! //! Rather than impose some particular graph data structure on clients, //! this library exposes two traits that clients can implement on their //! own structs before handing them over to the rendering function. //! //! Note: This library does not yet provide access to the full -//! expressiveness of the [DOT language]( -//! https://www.graphviz.org/doc/info/lang.html). For example, there are -//! many [attributes](https://www.graphviz.org/content/attrs) related to -//! providing layout hints (e.g., left-to-right versus top-down, which +//! expressiveness of the [DOT language](https://www.graphviz.org/doc/info/lang.html). +//! For example, there are many [attributes](https://www.graphviz.org/doc/info/attrs.html) +//! related to providing layout hints (e.g., left-to-right versus top-down, which //! algorithm to use, etc). The current intention of this library is to //! emit a human-readable .dot file with very regular structure suitable //! for easy post-processing. @@ -292,7 +290,7 @@ pub enum LabelText<'a> { LabelStr(Cow<'a, str>), /// This kind of label uses the graphviz label escString type: - /// + /// /// /// Occurrences of backslashes (`\`) are not escaped; instead they /// are interpreted as initiating an escString escape sequence. @@ -307,12 +305,12 @@ pub enum LabelText<'a> { /// printed exactly as given, but between `<` and `>`. **No /// escaping is performed.** /// - /// [html]: https://www.graphviz.org/content/node-shapes#html + /// [html]: https://www.graphviz.org/doc/info/shapes.html#html HtmlStr(Cow<'a, str>), } /// The style for a node or edge. -/// See for descriptions. +/// See for descriptions. /// Note that some of these are not valid for edges. #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub enum Style { @@ -439,7 +437,7 @@ pub trait Labeller<'a> { /// Maps `n` to one of the [graphviz `shape` names][1]. If `None` /// is returned, no `shape` attribute is specified. /// - /// [1]: https://www.graphviz.org/content/node-shapes + /// [1]: https://www.graphviz.org/doc/info/shapes.html fn node_shape(&'a self, _node: &Self::Node) -> Option> { None } From 0fa27efad79eb6ba496c0ea8542e225d60469dcb Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Mon, 9 May 2022 18:43:16 +0200 Subject: [PATCH 09/10] Add tests. --- .../associated-consts/issue-88599-ref-self.rs | 24 +++++++ src/test/ui/issues/issue-37725.rs | 2 + ...ssue-73021-impossible-inline.inline.stderr | 46 ++++++++++++ ...ssue-73021-impossible-inline.no-opt.stderr | 46 ++++++++++++ .../issue-73021-impossible-inline.rs | 71 +++++++++++++++++++ 5 files changed, 189 insertions(+) create mode 100644 src/test/ui/associated-consts/issue-88599-ref-self.rs create mode 100644 src/test/ui/trivial-bounds/issue-73021-impossible-inline.inline.stderr create mode 100644 src/test/ui/trivial-bounds/issue-73021-impossible-inline.no-opt.stderr create mode 100644 src/test/ui/trivial-bounds/issue-73021-impossible-inline.rs diff --git a/src/test/ui/associated-consts/issue-88599-ref-self.rs b/src/test/ui/associated-consts/issue-88599-ref-self.rs new file mode 100644 index 0000000000000..f1144db44ca44 --- /dev/null +++ b/src/test/ui/associated-consts/issue-88599-ref-self.rs @@ -0,0 +1,24 @@ +// check-pass +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +pub trait First { + const CONST: usize; +} +pub trait Second {} + +impl<'a> First for dyn Second +where + &'a Self: First, +{ + const CONST: usize = <&Self>::CONST; +} + +trait Third: First +where + [u8; Self::CONST]: +{ + const VAL: [u8; Self::CONST] = [0; Self::CONST]; +} + +fn main() {} diff --git a/src/test/ui/issues/issue-37725.rs b/src/test/ui/issues/issue-37725.rs index 965ecde6f3c04..1c6df0da60c0e 100644 --- a/src/test/ui/issues/issue-37725.rs +++ b/src/test/ui/issues/issue-37725.rs @@ -1,4 +1,6 @@ // build-pass +// compiler-opts: -Zmir-opt-level=2 + #![allow(dead_code)] trait Foo { fn foo(&self); diff --git a/src/test/ui/trivial-bounds/issue-73021-impossible-inline.inline.stderr b/src/test/ui/trivial-bounds/issue-73021-impossible-inline.inline.stderr new file mode 100644 index 0000000000000..40829f53709e5 --- /dev/null +++ b/src/test/ui/trivial-bounds/issue-73021-impossible-inline.inline.stderr @@ -0,0 +1,46 @@ +warning: trait bound for<'any> &'any mut (): Clone does not depend on any type or lifetime parameters + --> $DIR/issue-73021-impossible-inline.rs:20:29 + | +LL | for<'any> &'any mut (): Clone, + | ^^^^^ + | + = note: `#[warn(trivial_bounds)]` on by default + +warning: trait bound i32: Foo does not depend on any type or lifetime parameters + --> $DIR/issue-73021-impossible-inline.rs:28:21 + | +LL | struct S where i32: Foo; + | ^^^ + +warning: trait bound i32: Foo does not depend on any type or lifetime parameters + --> $DIR/issue-73021-impossible-inline.rs:31:28 + | +LL | impl Foo for () where i32: Foo { + | ^^^ + +warning: trait bound i32: Foo does not depend on any type or lifetime parameters + --> $DIR/issue-73021-impossible-inline.rs:40:19 + | +LL | fn f() where i32: Foo { + | ^^^ + +warning: trait bound &'static str: Foo does not depend on any type or lifetime parameters + --> $DIR/issue-73021-impossible-inline.rs:48:28 + | +LL | fn g() where &'static str: Foo { + | ^^^ + +warning: trait bound String: Neg does not depend on any type or lifetime parameters + --> $DIR/issue-73021-impossible-inline.rs:57:13 + | +LL | String: ::std::ops::Neg, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: trait bound i32: Iterator does not depend on any type or lifetime parameters + --> $DIR/issue-73021-impossible-inline.rs:65:10 + | +LL | i32: Iterator, + | ^^^^^^^^ + +warning: 7 warnings emitted + diff --git a/src/test/ui/trivial-bounds/issue-73021-impossible-inline.no-opt.stderr b/src/test/ui/trivial-bounds/issue-73021-impossible-inline.no-opt.stderr new file mode 100644 index 0000000000000..40829f53709e5 --- /dev/null +++ b/src/test/ui/trivial-bounds/issue-73021-impossible-inline.no-opt.stderr @@ -0,0 +1,46 @@ +warning: trait bound for<'any> &'any mut (): Clone does not depend on any type or lifetime parameters + --> $DIR/issue-73021-impossible-inline.rs:20:29 + | +LL | for<'any> &'any mut (): Clone, + | ^^^^^ + | + = note: `#[warn(trivial_bounds)]` on by default + +warning: trait bound i32: Foo does not depend on any type or lifetime parameters + --> $DIR/issue-73021-impossible-inline.rs:28:21 + | +LL | struct S where i32: Foo; + | ^^^ + +warning: trait bound i32: Foo does not depend on any type or lifetime parameters + --> $DIR/issue-73021-impossible-inline.rs:31:28 + | +LL | impl Foo for () where i32: Foo { + | ^^^ + +warning: trait bound i32: Foo does not depend on any type or lifetime parameters + --> $DIR/issue-73021-impossible-inline.rs:40:19 + | +LL | fn f() where i32: Foo { + | ^^^ + +warning: trait bound &'static str: Foo does not depend on any type or lifetime parameters + --> $DIR/issue-73021-impossible-inline.rs:48:28 + | +LL | fn g() where &'static str: Foo { + | ^^^ + +warning: trait bound String: Neg does not depend on any type or lifetime parameters + --> $DIR/issue-73021-impossible-inline.rs:57:13 + | +LL | String: ::std::ops::Neg, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: trait bound i32: Iterator does not depend on any type or lifetime parameters + --> $DIR/issue-73021-impossible-inline.rs:65:10 + | +LL | i32: Iterator, + | ^^^^^^^^ + +warning: 7 warnings emitted + diff --git a/src/test/ui/trivial-bounds/issue-73021-impossible-inline.rs b/src/test/ui/trivial-bounds/issue-73021-impossible-inline.rs new file mode 100644 index 0000000000000..ab6677e911b24 --- /dev/null +++ b/src/test/ui/trivial-bounds/issue-73021-impossible-inline.rs @@ -0,0 +1,71 @@ +// build-pass +// revisions: no-opt inline +// [inline]compile-flags: -Zmir-opt-level=3 --emit=mir +#![feature(trivial_bounds)] +#![allow(unused)] + +trait Foo { + fn test(&self); +} + +fn foo<'a>(s: &'a mut ()) +where + &'a mut (): Foo, +{ + s.test(); +} + +fn clone(it: &mut ()) -> &mut () +where + for<'any> &'any mut (): Clone, + //~^ WARN trait bound for<'any> &'any mut (): Clone does not depend on any type or lifetime parameters +{ + it.clone() +} + +fn generic_function(x: X) {} + +struct S where i32: Foo; +//~^ WARN trait bound i32: Foo does not depend on any type or lifetime parameters + +impl Foo for () where i32: Foo { +//~^ WARN trait bound i32: Foo does not depend on any type or lifetime parameters + fn test(&self) { + 3i32.test(); + Foo::test(&4i32); + generic_function(5i32); + } +} + +fn f() where i32: Foo { +//~^ WARN trait bound i32: Foo does not depend on any type or lifetime parameters + let s = S; + 3i32.test(); + Foo::test(&4i32); + generic_function(5i32); +} + +fn g() where &'static str: Foo { +//~^ WARN trait bound &'static str: Foo does not depend on any type or lifetime parameters + "Foo".test(); + Foo::test(&"Foo"); + generic_function("Foo"); +} + +fn use_op(s: String) -> String +where + String: ::std::ops::Neg, +//~^ WARN trait bound String: Neg does not depend on any type or lifetime parameters +{ + -s +} + +fn use_for() +where + i32: Iterator, +//~^ WARN trait bound i32: Iterator does not depend on any type or lifetime parameters +{ + for _ in 2i32 {} +} + +fn main() {} From bd41874eeadba20870f49e837babc56e67292b10 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Thu, 12 May 2022 12:46:28 +0200 Subject: [PATCH 10/10] Add mir-opt test. --- src/test/mir-opt/inline/dyn-trait.rs | 35 +++++++++++ .../inline/dyn_trait.get_query.Inline.diff | 62 +++++++++++++++++++ .../inline/dyn_trait.mk_cycle.Inline.diff | 23 +++++++ .../dyn_trait.try_execute_query.Inline.diff | 37 +++++++++++ 4 files changed, 157 insertions(+) create mode 100644 src/test/mir-opt/inline/dyn-trait.rs create mode 100644 src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff create mode 100644 src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff create mode 100644 src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff diff --git a/src/test/mir-opt/inline/dyn-trait.rs b/src/test/mir-opt/inline/dyn-trait.rs new file mode 100644 index 0000000000000..6a46e1e07b1a8 --- /dev/null +++ b/src/test/mir-opt/inline/dyn-trait.rs @@ -0,0 +1,35 @@ +#![crate_type = "lib"] + +use std::fmt::Debug; + +pub trait Cache { + type V: Debug; + + fn store_nocache(&self); +} + +pub trait Query { + type V; + type C: Cache; + + fn cache(s: &T) -> &Self::C; +} + +// EMIT_MIR dyn_trait.mk_cycle.Inline.diff +#[inline(always)] +pub fn mk_cycle(c: &dyn Cache) { + c.store_nocache() +} + +// EMIT_MIR dyn_trait.try_execute_query.Inline.diff +#[inline(always)] +pub fn try_execute_query(c: &C) { + mk_cycle(c) +} + +// EMIT_MIR dyn_trait.get_query.Inline.diff +#[inline(always)] +pub fn get_query(t: &T) { + let c = Q::cache(t); + try_execute_query(c) +} diff --git a/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff b/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff new file mode 100644 index 0000000000000..953d7b85c5ba7 --- /dev/null +++ b/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff @@ -0,0 +1,62 @@ +- // MIR for `get_query` before Inline ++ // MIR for `get_query` after Inline + + fn get_query(_1: &T) -> () { + debug t => _1; // in scope 0 at $DIR/dyn-trait.rs:32:31: 32:32 + let mut _0: (); // return place in scope 0 at $DIR/dyn-trait.rs:32:38: 32:38 + let _2: &::C; // in scope 0 at $DIR/dyn-trait.rs:33:9: 33:10 + let mut _3: &T; // in scope 0 at $DIR/dyn-trait.rs:33:22: 33:23 + let mut _4: &::C; // in scope 0 at $DIR/dyn-trait.rs:34:23: 34:24 + scope 1 { + debug c => _2; // in scope 1 at $DIR/dyn-trait.rs:33:9: 33:10 ++ scope 2 (inlined try_execute_query::<::C>) { // at $DIR/dyn-trait.rs:34:5: 34:25 ++ debug c => _4; // in scope 2 at $DIR/dyn-trait.rs:26:36: 26:37 ++ let mut _5: &dyn Cache::V>; // in scope 2 at $DIR/dyn-trait.rs:27:14: 27:15 ++ let mut _6: &::C; // in scope 2 at $DIR/dyn-trait.rs:27:14: 27:15 ++ scope 3 (inlined mk_cycle::<::V>) { // at $DIR/dyn-trait.rs:27:5: 27:16 ++ debug c => _5; // in scope 3 at $DIR/dyn-trait.rs:20:27: 20:28 ++ let mut _7: &dyn Cache::V>; // in scope 3 at $DIR/dyn-trait.rs:21:5: 21:22 ++ } ++ } + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/dyn-trait.rs:33:9: 33:10 + StorageLive(_3); // scope 0 at $DIR/dyn-trait.rs:33:22: 33:23 + _3 = &(*_1); // scope 0 at $DIR/dyn-trait.rs:33:22: 33:23 + _2 = ::cache::(move _3) -> bb1; // scope 0 at $DIR/dyn-trait.rs:33:13: 33:24 + // mir::Constant + // + span: $DIR/dyn-trait.rs:33:13: 33:21 + // + user_ty: UserType(0) + // + literal: Const { ty: for<'r> fn(&'r T) -> &'r ::C {::cache::}, val: Value(Scalar()) } + } + + bb1: { + StorageDead(_3); // scope 0 at $DIR/dyn-trait.rs:33:23: 33:24 + StorageLive(_4); // scope 1 at $DIR/dyn-trait.rs:34:23: 34:24 + _4 = &(*_2); // scope 1 at $DIR/dyn-trait.rs:34:23: 34:24 +- _0 = try_execute_query::<::C>(move _4) -> bb2; // scope 1 at $DIR/dyn-trait.rs:34:5: 34:25 ++ StorageLive(_5); // scope 2 at $DIR/dyn-trait.rs:27:14: 27:15 ++ StorageLive(_6); // scope 2 at $DIR/dyn-trait.rs:27:14: 27:15 ++ _6 = _4; // scope 2 at $DIR/dyn-trait.rs:27:14: 27:15 ++ _5 = move _6 as &dyn Cache::V> (Pointer(Unsize)); // scope 2 at $DIR/dyn-trait.rs:27:14: 27:15 ++ StorageDead(_6); // scope 2 at $DIR/dyn-trait.rs:27:14: 27:15 ++ StorageLive(_7); // scope 3 at $DIR/dyn-trait.rs:21:5: 21:22 ++ _7 = _5; // scope 3 at $DIR/dyn-trait.rs:21:5: 21:22 ++ _0 = ::V> as Cache>::store_nocache(move _7) -> bb2; // scope 3 at $DIR/dyn-trait.rs:21:5: 21:22 + // mir::Constant +- // + span: $DIR/dyn-trait.rs:34:5: 34:22 +- // + literal: Const { ty: for<'r> fn(&'r ::C) {try_execute_query::<::C>}, val: Value(Scalar()) } ++ // + span: $DIR/dyn-trait.rs:21:7: 21:20 ++ // + literal: Const { ty: for<'r> fn(&'r dyn Cache::V>) {::V> as Cache>::store_nocache}, val: Value(Scalar()) } + } + + bb2: { ++ StorageDead(_7); // scope 3 at $DIR/dyn-trait.rs:21:21: 21:22 ++ StorageDead(_5); // scope 2 at $DIR/dyn-trait.rs:27:15: 27:16 + StorageDead(_4); // scope 1 at $DIR/dyn-trait.rs:34:24: 34:25 + StorageDead(_2); // scope 0 at $DIR/dyn-trait.rs:35:1: 35:2 + return; // scope 0 at $DIR/dyn-trait.rs:35:2: 35:2 + } + } + diff --git a/src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff b/src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff new file mode 100644 index 0000000000000..27309328052c7 --- /dev/null +++ b/src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff @@ -0,0 +1,23 @@ +- // MIR for `mk_cycle` before Inline ++ // MIR for `mk_cycle` after Inline + + fn mk_cycle(_1: &dyn Cache) -> () { + debug c => _1; // in scope 0 at $DIR/dyn-trait.rs:20:27: 20:28 + let mut _0: (); // return place in scope 0 at $DIR/dyn-trait.rs:20:49: 20:49 + let mut _2: &dyn Cache; // in scope 0 at $DIR/dyn-trait.rs:21:5: 21:22 + + bb0: { + StorageLive(_2); // scope 0 at $DIR/dyn-trait.rs:21:5: 21:22 + _2 = &(*_1); // scope 0 at $DIR/dyn-trait.rs:21:5: 21:22 + _0 = as Cache>::store_nocache(move _2) -> bb1; // scope 0 at $DIR/dyn-trait.rs:21:5: 21:22 + // mir::Constant + // + span: $DIR/dyn-trait.rs:21:7: 21:20 + // + literal: Const { ty: for<'r> fn(&'r dyn Cache) { as Cache>::store_nocache}, val: Value(Scalar()) } + } + + bb1: { + StorageDead(_2); // scope 0 at $DIR/dyn-trait.rs:21:21: 21:22 + return; // scope 0 at $DIR/dyn-trait.rs:22:2: 22:2 + } + } + diff --git a/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff b/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff new file mode 100644 index 0000000000000..93bba58825d20 --- /dev/null +++ b/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff @@ -0,0 +1,37 @@ +- // MIR for `try_execute_query` before Inline ++ // MIR for `try_execute_query` after Inline + + fn try_execute_query(_1: &C) -> () { + debug c => _1; // in scope 0 at $DIR/dyn-trait.rs:26:36: 26:37 + let mut _0: (); // return place in scope 0 at $DIR/dyn-trait.rs:26:43: 26:43 + let mut _2: &dyn Cache::V>; // in scope 0 at $DIR/dyn-trait.rs:27:14: 27:15 + let mut _3: &C; // in scope 0 at $DIR/dyn-trait.rs:27:14: 27:15 ++ scope 1 (inlined mk_cycle::<::V>) { // at $DIR/dyn-trait.rs:27:5: 27:16 ++ debug c => _2; // in scope 1 at $DIR/dyn-trait.rs:20:27: 20:28 ++ let mut _4: &dyn Cache::V>; // in scope 1 at $DIR/dyn-trait.rs:21:5: 21:22 ++ } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/dyn-trait.rs:27:14: 27:15 + StorageLive(_3); // scope 0 at $DIR/dyn-trait.rs:27:14: 27:15 + _3 = &(*_1); // scope 0 at $DIR/dyn-trait.rs:27:14: 27:15 + _2 = move _3 as &dyn Cache::V> (Pointer(Unsize)); // scope 0 at $DIR/dyn-trait.rs:27:14: 27:15 + StorageDead(_3); // scope 0 at $DIR/dyn-trait.rs:27:14: 27:15 +- _0 = mk_cycle::<::V>(move _2) -> bb1; // scope 0 at $DIR/dyn-trait.rs:27:5: 27:16 ++ StorageLive(_4); // scope 1 at $DIR/dyn-trait.rs:21:5: 21:22 ++ _4 = _2; // scope 1 at $DIR/dyn-trait.rs:21:5: 21:22 ++ _0 = ::V> as Cache>::store_nocache(move _4) -> bb1; // scope 1 at $DIR/dyn-trait.rs:21:5: 21:22 + // mir::Constant +- // + span: $DIR/dyn-trait.rs:27:5: 27:13 +- // + literal: Const { ty: for<'r> fn(&'r (dyn Cache::V> + 'r)) {mk_cycle::<::V>}, val: Value(Scalar()) } ++ // + span: $DIR/dyn-trait.rs:21:7: 21:20 ++ // + literal: Const { ty: for<'r> fn(&'r dyn Cache::V>) {::V> as Cache>::store_nocache}, val: Value(Scalar()) } + } + + bb1: { ++ StorageDead(_4); // scope 1 at $DIR/dyn-trait.rs:21:21: 21:22 + StorageDead(_2); // scope 0 at $DIR/dyn-trait.rs:27:15: 27:16 + return; // scope 0 at $DIR/dyn-trait.rs:28:2: 28:2 + } + } +