Skip to content

Commit

Permalink
Auto merge of rust-lang#124140 - workingjubilee:rollup-wrub705, r=wor…
Browse files Browse the repository at this point in the history
…kingjubilee

Rollup of 6 pull requests

Successful merges:

 - rust-lang#117919 (Introduce perma-unstable `wasm-c-abi` flag)
 - rust-lang#123571 (Correctly change type when adding adjustments on top of `NeverToAny`)
 - rust-lang#123752 (Properly handle emojis as literal prefix in macros)
 - rust-lang#123980 ( Add an opt-in to store incoming edges in `VecGraph` + misc)
 - rust-lang#124110 (Fix negating `f16` and `f128` constants)
 - rust-lang#124116 (when suggesting RUST_BACKTRACE=1, add a special note for Miri's env var isolation)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Apr 18, 2024
2 parents e3181b0 + 8d5587e commit 5b2e2f5
Show file tree
Hide file tree
Showing 60 changed files with 566 additions and 132 deletions.
8 changes: 7 additions & 1 deletion compiler/rustc_codegen_gcc/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use rustc_span::Span;
use rustc_target::abi::{
self, call::FnAbi, Align, HasDataLayout, Size, TargetDataLayout, WrappingRange,
};
use rustc_target::spec::{HasTargetSpec, Target};
use rustc_target::spec::{HasTargetSpec, HasWasmCAbiOpt, Target, WasmCAbi};

use crate::common::{type_is_pointer, SignType, TypeReflection};
use crate::context::CodegenCx;
Expand Down Expand Up @@ -2352,6 +2352,12 @@ impl<'tcx> HasTargetSpec for Builder<'_, '_, 'tcx> {
}
}

impl<'tcx> HasWasmCAbiOpt for Builder<'_, '_, 'tcx> {
fn wasm_c_abi_opt(&self) -> WasmCAbi {
self.cx.wasm_c_abi_opt()
}
}

pub trait ToGccComp {
fn to_gcc_comparison(&self) -> ComparisonOp;
}
Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_codegen_gcc/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use rustc_span::{source_map::respan, Span};
use rustc_target::abi::{
call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx,
};
use rustc_target::spec::{HasTargetSpec, Target, TlsModel};
use rustc_target::spec::{HasTargetSpec, HasWasmCAbiOpt, Target, TlsModel, WasmCAbi};

use crate::callee::get_fn;
use crate::common::SignType;
Expand Down Expand Up @@ -557,6 +557,12 @@ impl<'gcc, 'tcx> HasTargetSpec for CodegenCx<'gcc, 'tcx> {
}
}

impl<'gcc, 'tcx> HasWasmCAbiOpt for CodegenCx<'gcc, 'tcx> {
fn wasm_c_abi_opt(&self) -> WasmCAbi {
self.tcx.sess.opts.unstable_opts.wasm_c_abi
}
}

impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
type LayoutOfResult = TyAndLayout<'tcx>;

Expand Down
22 changes: 11 additions & 11 deletions compiler/rustc_data_structures/src/graph/iterate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,21 @@ pub fn reverse_post_order<G: DirectedGraph + Successors>(
}

/// A "depth-first search" iterator for a directed graph.
pub struct DepthFirstSearch<'graph, G>
pub struct DepthFirstSearch<G>
where
G: ?Sized + DirectedGraph + Successors,
G: DirectedGraph + Successors,
{
graph: &'graph G,
graph: G,
stack: Vec<G::Node>,
visited: BitSet<G::Node>,
}

impl<'graph, G> DepthFirstSearch<'graph, G>
impl<G> DepthFirstSearch<G>
where
G: ?Sized + DirectedGraph + Successors,
G: DirectedGraph + Successors,
{
pub fn new(graph: &'graph G) -> Self {
Self { graph, stack: vec![], visited: BitSet::new_empty(graph.num_nodes()) }
pub fn new(graph: G) -> Self {
Self { stack: vec![], visited: BitSet::new_empty(graph.num_nodes()), graph }
}

/// Version of `push_start_node` that is convenient for chained
Expand Down Expand Up @@ -125,9 +125,9 @@ where
}
}

impl<G> std::fmt::Debug for DepthFirstSearch<'_, G>
impl<G> std::fmt::Debug for DepthFirstSearch<G>
where
G: ?Sized + DirectedGraph + Successors,
G: DirectedGraph + Successors,
{
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut f = fmt.debug_set();
Expand All @@ -138,9 +138,9 @@ where
}
}

impl<G> Iterator for DepthFirstSearch<'_, G>
impl<G> Iterator for DepthFirstSearch<G>
where
G: ?Sized + DirectedGraph + Successors,
G: DirectedGraph + Successors,
{
type Item = G::Node;

Expand Down
30 changes: 28 additions & 2 deletions compiler/rustc_data_structures/src/graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,35 @@ where
.is_some()
}

pub fn depth_first_search<G>(graph: &G, from: G::Node) -> iterate::DepthFirstSearch<'_, G>
pub fn depth_first_search<G>(graph: G, from: G::Node) -> iterate::DepthFirstSearch<G>
where
G: ?Sized + Successors,
G: Successors,
{
iterate::DepthFirstSearch::new(graph).with_start_node(from)
}

pub fn depth_first_search_as_undirected<G>(
graph: G,
from: G::Node,
) -> iterate::DepthFirstSearch<impl Successors<Node = G::Node>>
where
G: Successors + Predecessors,
{
struct AsUndirected<G>(G);

impl<G: DirectedGraph> DirectedGraph for AsUndirected<G> {
type Node = G::Node;

fn num_nodes(&self) -> usize {
self.0.num_nodes()
}
}

impl<G: Successors + Predecessors> Successors for AsUndirected<G> {
fn successors(&self, node: Self::Node) -> impl Iterator<Item = Self::Node> {
self.0.successors(node).chain(self.0.predecessors(node))
}
}

iterate::DepthFirstSearch::new(AsUndirected(graph)).with_start_node(from)
}
Loading

0 comments on commit 5b2e2f5

Please sign in to comment.