Skip to content

Rollup of 5 pull requests #96974

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions compiler/rustc_graphviz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -292,7 +290,7 @@ pub enum LabelText<'a> {
LabelStr(Cow<'a, str>),

/// This kind of label uses the graphviz label escString type:
/// <https://www.graphviz.org/content/attrs#kescString>
/// <https://www.graphviz.org/docs/attr-types/escString>
///
/// Occurrences of backslashes (`\`) are not escaped; instead they
/// are interpreted as initiating an escString escape sequence.
Expand All @@ -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 <https://www.graphviz.org/doc/info/attrs.html#k:style> for descriptions.
/// See <https://www.graphviz.org/docs/attr-types/style/> for descriptions.
/// Note that some of these are not valid for edges.
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum Style {
Expand Down Expand Up @@ -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<LabelText<'a>> {
None
}
Expand Down
16 changes: 7 additions & 9 deletions library/std/src/sys/unix/futex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -
//
// 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 {
Expand Down Expand Up @@ -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<Duration>) -> 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(
Expand Down
3 changes: 2 additions & 1 deletion library/std/src/sys/unix/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}

Expand Down Expand Up @@ -125,6 +125,7 @@ impl Timespec {
Some(Timespec::new(secs, nsec as i64))
}

#[allow(dead_code)]
pub fn to_timespec(&self) -> Option<libc::timespec> {
Some(libc::timespec {
tv_sec: self.tv_sec.try_into().ok()?,
Expand Down
58 changes: 58 additions & 0 deletions src/doc/rustc/src/platform-support/nvptx64-nvidia-cuda.md
Original file line number Diff line number Diff line change
@@ -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

<!-- FIXME: fill this out

## Requirements

Does the target support host tools, or only cross-compilation? Does the target
support std, or alloc (either with a default allocator, or if the user supplies
an allocator)?

Document the expectations of binaries built for the target. Do they assume
specific minimum features beyond the baseline of the CPU/environment/etc? What
version of the OS or environment do they expect?

Are there notable `#[target_feature(...)]` or `-C target-feature=` values that
programs may wish to use?

What calling convention does `extern "C"` use on the target?

What format do binaries use by default? ELF, PE, something else?

## Building the target

If Rust doesn't build the target by default, how can users build it? Can users
just add it to the `target` list in `config.toml`?

## Building Rust programs

Rust does not yet ship pre-compiled artifacts for this target. To compile for
this target, you will either need to build Rust with the target enabled (see
"Building the target" above), or build your own copy of `core` by using
`build-std` or similar.

## Testing

Does the target support running binaries, or do binaries have varying
expectations that prevent having a standard way to run them? If users can run
binaries, can they do so in some common emulator, or do they need native
hardware? Does the target support running the Rust testsuite?

## Cross-compilation toolchains and C code

Does the target support C code? If so, what toolchain target should users use
to build compatible C code? (This may match the target triple, or it may be a
toolchain for a different target triple, potentially with specific options or
caveats.)

-->
8 changes: 5 additions & 3 deletions src/librustdoc/html/render/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,11 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
|buf: &mut Buffer| {
write!(
buf,
"<script defer src=\"{}settings{}.js\"></script>",
page.static_root_path.unwrap_or(""),
page.resource_suffix
"<link rel=\"stylesheet\" type=\"text/css\" \
href=\"{root_path}settings{suffix}.css\">\
<script defer src=\"{root_path}settings{suffix}.js\"></script>",
root_path = page.static_root_path.unwrap_or(""),
suffix = page.resource_suffix,
)
},
&self.shared.style_files,
Expand Down
36 changes: 0 additions & 36 deletions src/librustdoc/html/static/css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -96,7 +64,6 @@
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .3s;
transition: .3s;
}

Expand All @@ -108,7 +75,6 @@
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .3s;
transition: .3s;
}

Expand All @@ -121,8 +87,6 @@ input:focus + .slider {
}

input:checked + .slider:before {
-webkit-transform: translateX(19px);
-ms-transform: translateX(19px);
transform: translateX(19px);
}

Expand Down
35 changes: 35 additions & 0 deletions src/test/mir-opt/inline/dyn-trait.rs
Original file line number Diff line number Diff line change
@@ -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<V = Self::V>;

fn cache<T>(s: &T) -> &Self::C;
}

// EMIT_MIR dyn_trait.mk_cycle.Inline.diff
#[inline(always)]
pub fn mk_cycle<V: Debug>(c: &dyn Cache<V = V>) {
c.store_nocache()
}

// EMIT_MIR dyn_trait.try_execute_query.Inline.diff
#[inline(always)]
pub fn try_execute_query<C: Cache>(c: &C) {
mk_cycle(c)
}

// EMIT_MIR dyn_trait.get_query.Inline.diff
#[inline(always)]
pub fn get_query<Q: Query, T>(t: &T) {
let c = Q::cache(t);
try_execute_query(c)
}
62 changes: 62 additions & 0 deletions src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff
Original file line number Diff line number Diff line change
@@ -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: &<Q as Query>::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: &<Q as Query>::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::<<Q as 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 = <Q as Query>::V>; // in scope 2 at $DIR/dyn-trait.rs:27:14: 27:15
+ let mut _6: &<Q as Query>::C; // in scope 2 at $DIR/dyn-trait.rs:27:14: 27:15
+ scope 3 (inlined mk_cycle::<<Q as Query>::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 = <Q as Query>::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 = <Q as Query>::cache::<T>(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 <Q as Query>::C {<Q as Query>::cache::<T>}, val: Value(Scalar(<ZST>)) }
}

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::<<Q as 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 = <Q as Query>::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 = <dyn Cache<V = <Q as Query>::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 <Q as Query>::C) {try_execute_query::<<Q as Query>::C>}, val: Value(Scalar(<ZST>)) }
+ // + span: $DIR/dyn-trait.rs:21:7: 21:20
+ // + literal: Const { ty: for<'r> fn(&'r dyn Cache<V = <Q as Query>::V>) {<dyn Cache<V = <Q as Query>::V> as Cache>::store_nocache}, val: Value(Scalar(<ZST>)) }
}

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
}
}

23 changes: 23 additions & 0 deletions src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
- // MIR for `mk_cycle` before Inline
+ // MIR for `mk_cycle` after Inline

fn mk_cycle(_1: &dyn Cache<V = V>) -> () {
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<V = V>; // 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 = <dyn Cache<V = V> 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<V = V>) {<dyn Cache<V = V> as Cache>::store_nocache}, val: Value(Scalar(<ZST>)) }
}

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
}
}

Loading