Skip to content
Closed
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3dd0a7d
Do not call `unwrap` with `signatures` option enabled
JohnTitor Oct 25, 2020
443b45f
rustc_target: Change os from "unknown" to "none" for bare metal targets
petrochenkov Nov 11, 2020
1def24c
rustc_target: Normalize vendor from "" to "unknown" for all targets
petrochenkov Nov 11, 2020
e0a8f22
rustc_target: Make sure that in-tree targets follow conventions for o…
petrochenkov Nov 11, 2020
f5e67b5
Add a test for r# identifiers
poliorcetics Nov 12, 2020
9c70696
Ignore tidy linelength
poliorcetics Nov 12, 2020
bd0eb07
Added some unit tests as requested
richkadel Nov 3, 2020
ecfeac5
Use intradoc-links for the whole test, add a @has check
poliorcetics Nov 12, 2020
562d50e
Include llvm-as in llvm-tools-preview component
zec Nov 12, 2020
e4a43fc
Merge changes from rust-lang/rust
zec Nov 12, 2020
eb9f2bb
Overcome Sync issues with non-parallel compiler
richkadel Nov 12, 2020
fe56d26
Fix and re-enable two coverage tests on MacOS
richkadel Nov 8, 2020
775f1e5
fix pretty print for qpath
gui1117 Nov 12, 2020
04d41e1
rustc_target: Mark UEFI targets as `is_like_windows`/`is_like_msvc`
petrochenkov Nov 11, 2020
0b4af16
Never inline when `no_sanitize` attributes differ
tmiasko Nov 11, 2020
ae43326
Never inline cold functions
tmiasko Nov 11, 2020
9bb3d6b
Remove check for impossible condition
tmiasko Nov 11, 2020
2879ab7
rustc_parse: Remove optimization for 0-length streams in `collect_tok…
petrochenkov Nov 4, 2020
66cadec
Fix generator inlining by checking for rust-call abi and spread arg
tmiasko Nov 11, 2020
79d853e
Never inline C variadic functions
tmiasko Nov 11, 2020
2a010dd
./x.py test --bless
tmiasko Nov 11, 2020
d486bfc
Normalize function type during validation
tmiasko Nov 12, 2020
99be78d
Always use param_env_reveal_all_normalized in validator
tmiasko Nov 12, 2020
c131063
Added a unit test for BcbCounters
richkadel Nov 13, 2020
309d863
Fix wrong XPath
poliorcetics Nov 13, 2020
b4b0ef3
Addressed feedback
richkadel Nov 13, 2020
bf6902c
Add BTreeMap::retain and BTreeSet::retain
mbrubeck Nov 13, 2020
5dd0a87
Rollup merge of #78352 - JohnTitor:issue-75229, r=Dylan-DPC
Dylan-DPC Nov 13, 2020
c71ea50
Rollup merge of #78736 - petrochenkov:lazyenum, r=Aaron1011
Dylan-DPC Nov 13, 2020
8d173a5
Rollup merge of #78888 - richkadel:llvm-coverage-tests, r=tmandry
Dylan-DPC Nov 13, 2020
aaa50cb
Rollup merge of #78951 - petrochenkov:unknown, r=ehuss
Dylan-DPC Nov 13, 2020
7c93b43
Rollup merge of #78959 - petrochenkov:likeuefi, r=nagisa
Dylan-DPC Nov 13, 2020
6c58f45
Rollup merge of #78962 - poliorcetics:rustdoc-raw-ident-test, r=jyn514
Dylan-DPC Nov 13, 2020
afd7a4c
Rollup merge of #78963 - richkadel:llvm-coverage-counters-2.0.4, r=tm…
Dylan-DPC Nov 13, 2020
3b4b47f
Rollup merge of #78966 - tmiasko:inline-never, r=oli-obk
Dylan-DPC Nov 13, 2020
f0f0398
Rollup merge of #78968 - zec:add-llvm-as, r=Mark-Simulacrum
Dylan-DPC Nov 13, 2020
d22b8ce
Rollup merge of #78969 - tmiasko:normalize, r=davidtwco
Dylan-DPC Nov 13, 2020
bca4c86
Rollup merge of #78980 - thiolliere:gui-fix-qpath, r=estebank
Dylan-DPC Nov 13, 2020
ecb123a
Rollup merge of #79026 - mbrubeck:btree_retain, r=m-ou-se
Dylan-DPC Nov 13, 2020
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
8 changes: 8 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -721,6 +721,13 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a21fa21941700a3cd8fcb4091f361a6a712fac632f85d9f487cc892045d55c6"

[[package]]
name = "coverage_test_macros"
version = "0.0.0"
dependencies = [
"proc-macro2",
]

[[package]]
name = "cpuid-bool"
version = "0.1.2"
@@ -3922,6 +3929,7 @@ dependencies = [
name = "rustc_mir"
version = "0.0.0"
dependencies = [
"coverage_test_macros",
"either",
"itertools 0.9.0",
"polonius-engine",
11 changes: 6 additions & 5 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
@@ -2327,11 +2327,12 @@ impl<'a> State<'a> {
self.print_path(path, false, depth);
}
self.s.word(">");
self.s.word("::");
let item_segment = path.segments.last().unwrap();
self.print_ident(item_segment.ident);
if let Some(ref args) = item_segment.args {
self.print_generic_args(args, colons_before_params)
for item_segment in &path.segments[qself.position..] {
self.s.word("::");
self.print_ident(item_segment.ident);
if let Some(ref args) = item_segment.args {
self.print_generic_args(args, colons_before_params)
}
}
}

4 changes: 1 addition & 3 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
@@ -925,9 +925,7 @@ unsafe fn embed_bitcode(
|| cgcx.opts.target_triple.triple().starts_with("asmjs")
{
// nothing to do here
} else if cgcx.opts.target_triple.triple().contains("windows")
|| cgcx.opts.target_triple.triple().contains("uefi")
{
} else if cgcx.is_pe_coff {
let asm = "
.section .llvmbc,\"n\"
.section .llvmcmd,\"n\"
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
@@ -307,6 +307,7 @@ pub struct CodegenContext<B: WriteBackendMethods> {
pub allocator_module_config: Arc<ModuleConfig>,
pub tm_factory: TargetMachineFactory<B>,
pub msvc_imps_needed: bool,
pub is_pe_coff: bool,
pub target_pointer_width: u32,
pub target_arch: String,
pub debuginfo: config::DebugInfo,
@@ -1022,6 +1023,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
tm_factory: TargetMachineFactory(backend.target_machine_factory(tcx.sess, ol)),
total_cgus,
msvc_imps_needed: msvc_imps_needed(tcx),
is_pe_coff: tcx.sess.target.is_like_windows,
target_pointer_width: tcx.sess.target.pointer_width,
target_arch: tcx.sess.target.arch.clone(),
debuginfo: tcx.sess.opts.debuginfo,
12 changes: 12 additions & 0 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
@@ -611,6 +611,18 @@ pub struct TyS<'tcx> {
outer_exclusive_binder: ty::DebruijnIndex,
}

impl<'tcx> TyS<'tcx> {
/// A constructor used only for internal testing.
#[allow(rustc::usage_of_ty_tykind)]
pub fn make_for_test(
kind: TyKind<'tcx>,
flags: TypeFlags,
outer_exclusive_binder: ty::DebruijnIndex,
) -> TyS<'tcx> {
TyS { kind, flags, outer_exclusive_binder }
}
}

// `TyS` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
static_assert_size!(TyS<'_>, 32);
3 changes: 3 additions & 0 deletions compiler/rustc_mir/Cargo.toml
Original file line number Diff line number Diff line change
@@ -31,3 +31,6 @@ rustc_ast = { path = "../rustc_ast" }
rustc_span = { path = "../rustc_span" }
rustc_apfloat = { path = "../rustc_apfloat" }
smallvec = { version = "1.0", features = ["union", "may_dangle"] }

[dev-dependencies]
coverage_test_macros = { path = "src/transform/coverage/test_macros" }
5 changes: 2 additions & 3 deletions compiler/rustc_mir/src/transform/coverage/counters.rs
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ use rustc_middle::mir::coverage::*;

/// Manages the counter and expression indexes/IDs to generate `CoverageKind` components for MIR
/// `Coverage` statements.
pub(crate) struct CoverageCounters {
pub(super) struct CoverageCounters {
function_source_hash: u64,
next_counter_id: u32,
num_expressions: u32,
@@ -37,7 +37,7 @@ impl CoverageCounters {
self.debug_counters.enable();
}

/// Makes `CoverageKind` `Counter`s and `Expressions` for the `BasicCoverageBlocks` directly or
/// Makes `CoverageKind` `Counter`s and `Expressions` for the `BasicCoverageBlock`s directly or
/// indirectly associated with `CoverageSpans`, and returns additional `Expression`s
/// representing intermediate values.
pub fn make_bcb_counters(
@@ -120,7 +120,6 @@ struct BcbCounters<'a> {
basic_coverage_blocks: &'a mut CoverageGraph,
}

// FIXME(richkadel): Add unit tests for `BcbCounters` functions/algorithms.
impl<'a> BcbCounters<'a> {
fn new(
coverage_counters: &'a mut CoverageCounters,
16 changes: 8 additions & 8 deletions compiler/rustc_mir/src/transform/coverage/debug.rs
Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ pub const NESTED_INDENT: &str = " ";

const RUSTC_COVERAGE_DEBUG_OPTIONS: &str = "RUSTC_COVERAGE_DEBUG_OPTIONS";

pub(crate) fn debug_options<'a>() -> &'a DebugOptions {
pub(super) fn debug_options<'a>() -> &'a DebugOptions {
static DEBUG_OPTIONS: SyncOnceCell<DebugOptions> = SyncOnceCell::new();

&DEBUG_OPTIONS.get_or_init(|| DebugOptions::from_env())
@@ -136,7 +136,7 @@ pub(crate) fn debug_options<'a>() -> &'a DebugOptions {
/// Parses and maintains coverage-specific debug options captured from the environment variable
/// "RUSTC_COVERAGE_DEBUG_OPTIONS", if set.
#[derive(Debug, Clone)]
pub(crate) struct DebugOptions {
pub(super) struct DebugOptions {
pub allow_unused_expressions: bool,
counter_format: ExpressionFormat,
}
@@ -250,7 +250,7 @@ impl Default for ExpressionFormat {
///
/// `DebugCounters` supports a recursive rendering of `Expression` counters, so they can be
/// presented as nested expressions such as `(bcb3 - (bcb0 + bcb1))`.
pub(crate) struct DebugCounters {
pub(super) struct DebugCounters {
some_counters: Option<FxHashMap<ExpressionOperandId, DebugCounter>>,
}

@@ -386,7 +386,7 @@ impl DebugCounter {

/// If enabled, this data structure captures additional debugging information used when generating
/// a Graphviz (.dot file) representation of the `CoverageGraph`, for debugging purposes.
pub(crate) struct GraphvizData {
pub(super) struct GraphvizData {
some_bcb_to_coverage_spans_with_counters:
Option<FxHashMap<BasicCoverageBlock, Vec<(CoverageSpan, CoverageKind)>>>,
some_bcb_to_dependency_counters: Option<FxHashMap<BasicCoverageBlock, Vec<CoverageKind>>>,
@@ -496,7 +496,7 @@ impl GraphvizData {
/// directly or indirectly, to compute the coverage counts for all `CoverageSpan`s, and any that are
/// _not_ used are retained in the `unused_expressions` Vec, to be included in debug output (logs
/// and/or a `CoverageGraph` graphviz output).
pub(crate) struct UsedExpressions {
pub(super) struct UsedExpressions {
some_used_expression_operands:
Option<FxHashMap<ExpressionOperandId, Vec<InjectedExpressionId>>>,
some_unused_expressions:
@@ -626,7 +626,7 @@ impl UsedExpressions {
}

/// Generates the MIR pass `CoverageSpan`-specific spanview dump file.
pub(crate) fn dump_coverage_spanview(
pub(super) fn dump_coverage_spanview(
tcx: TyCtxt<'tcx>,
mir_body: &mir::Body<'tcx>,
basic_coverage_blocks: &CoverageGraph,
@@ -666,7 +666,7 @@ fn span_viewables(
}

/// Generates the MIR pass coverage-specific graphviz dump file.
pub(crate) fn dump_coverage_graphviz(
pub(super) fn dump_coverage_graphviz(
tcx: TyCtxt<'tcx>,
mir_body: &mir::Body<'tcx>,
pass_name: &str,
@@ -815,7 +815,7 @@ fn bcb_to_string_sections(

/// Returns a simple string representation of a `TerminatorKind` variant, indenpendent of any
/// values it might hold.
pub(crate) fn term_type(kind: &TerminatorKind<'tcx>) -> &'static str {
pub(super) fn term_type(kind: &TerminatorKind<'tcx>) -> &'static str {
match kind {
TerminatorKind::Goto { .. } => "Goto",
TerminatorKind::SwitchInt { .. } => "SwitchInt",
16 changes: 8 additions & 8 deletions compiler/rustc_mir/src/transform/coverage/graph.rs
Original file line number Diff line number Diff line change
@@ -17,7 +17,8 @@ const ID_SEPARATOR: &str = ",";
/// `CoverageKind` counter (to be added by `CoverageCounters::make_bcb_counters`), and an optional
/// set of additional counters--if needed--to count incoming edges, if there are more than one.
/// (These "edge counters" are eventually converted into new MIR `BasicBlock`s.)
pub(crate) struct CoverageGraph {
#[derive(Debug)]
pub(super) struct CoverageGraph {
bcbs: IndexVec<BasicCoverageBlock, BasicCoverageBlockData>,
bb_to_bcb: IndexVec<BasicBlock, Option<BasicCoverageBlock>>,
pub successors: IndexVec<BasicCoverageBlock, Vec<BasicCoverageBlock>>,
@@ -275,7 +276,7 @@ impl graph::WithPredecessors for CoverageGraph {

rustc_index::newtype_index! {
/// A node in the [control-flow graph][CFG] of CoverageGraph.
pub(crate) struct BasicCoverageBlock {
pub(super) struct BasicCoverageBlock {
DEBUG_FORMAT = "bcb{}",
}
}
@@ -305,7 +306,7 @@ rustc_index::newtype_index! {
/// queries (`is_dominated_by()`, `predecessors`, `successors`, etc.) have branch (control flow)
/// significance.
#[derive(Debug, Clone)]
pub(crate) struct BasicCoverageBlockData {
pub(super) struct BasicCoverageBlockData {
pub basic_blocks: Vec<BasicBlock>,
pub counter_kind: Option<CoverageKind>,
edge_from_bcbs: Option<FxHashMap<BasicCoverageBlock, CoverageKind>>,
@@ -431,7 +432,7 @@ impl BasicCoverageBlockData {
/// the specific branching BCB, representing the edge between the two. The latter case
/// distinguishes this incoming edge from other incoming edges to the same `target_bcb`.
#[derive(Clone, Copy, PartialEq, Eq)]
pub(crate) struct BcbBranch {
pub(super) struct BcbBranch {
pub edge_from_bcb: Option<BasicCoverageBlock>,
pub target_bcb: BasicCoverageBlock,
}
@@ -498,9 +499,8 @@ fn bcb_filtered_successors<'a, 'tcx>(
/// Maintains separate worklists for each loop in the BasicCoverageBlock CFG, plus one for the
/// CoverageGraph outside all loops. This supports traversing the BCB CFG in a way that
/// ensures a loop is completely traversed before processing Blocks after the end of the loop.
// FIXME(richkadel): Add unit tests for TraversalContext.
#[derive(Debug)]
pub(crate) struct TraversalContext {
pub(super) struct TraversalContext {
/// From one or more backedges returning to a loop header.
pub loop_backedges: Option<(Vec<BasicCoverageBlock>, BasicCoverageBlock)>,

@@ -510,7 +510,7 @@ pub(crate) struct TraversalContext {
pub worklist: Vec<BasicCoverageBlock>,
}

pub(crate) struct TraverseCoverageGraphWithLoops {
pub(super) struct TraverseCoverageGraphWithLoops {
pub backedges: IndexVec<BasicCoverageBlock, Vec<BasicCoverageBlock>>,
pub context_stack: Vec<TraversalContext>,
visited: BitSet<BasicCoverageBlock>,
@@ -642,7 +642,7 @@ impl TraverseCoverageGraphWithLoops {
}
}

fn find_loop_backedges(
pub(super) fn find_loop_backedges(
basic_coverage_blocks: &CoverageGraph,
) -> IndexVec<BasicCoverageBlock, Vec<BasicCoverageBlock>> {
let num_bcbs = basic_coverage_blocks.num_nodes();
5 changes: 4 additions & 1 deletion compiler/rustc_mir/src/transform/coverage/mod.rs
Original file line number Diff line number Diff line change
@@ -5,6 +5,9 @@ mod debug;
mod graph;
mod spans;

#[cfg(test)]
mod tests;

use counters::CoverageCounters;
use graph::{BasicCoverageBlock, BasicCoverageBlockData, CoverageGraph};
use spans::{CoverageSpan, CoverageSpans};
@@ -31,7 +34,7 @@ use rustc_span::{CharPos, Pos, SourceFile, Span, Symbol};

/// A simple error message wrapper for `coverage::Error`s.
#[derive(Debug)]
pub(crate) struct Error {
struct Error {
message: String,
}

16 changes: 11 additions & 5 deletions compiler/rustc_mir/src/transform/coverage/spans.rs
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ use rustc_span::{BytePos, Span, SyntaxContext};
use std::cmp::Ordering;

#[derive(Debug, Copy, Clone)]
pub(crate) enum CoverageStatement {
pub(super) enum CoverageStatement {
Statement(BasicBlock, Span, usize),
Terminator(BasicBlock, Span),
}
@@ -66,7 +66,7 @@ impl CoverageStatement {
/// or is subsumed by the `Span` associated with this `CoverageSpan`, and it's `BasicBlock`
/// `is_dominated_by()` the `BasicBlock`s in this `CoverageSpan`.
#[derive(Debug, Clone)]
pub(crate) struct CoverageSpan {
pub(super) struct CoverageSpan {
pub span: Span,
pub bcb: BasicCoverageBlock,
pub coverage_statements: Vec<CoverageStatement>,
@@ -214,7 +214,7 @@ pub struct CoverageSpans<'a, 'tcx> {
}

impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
pub(crate) fn generate_coverage_spans(
pub(super) fn generate_coverage_spans(
mir_body: &'a mir::Body<'tcx>,
body_span: Span,
basic_coverage_blocks: &'a CoverageGraph,
@@ -645,7 +645,10 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
}
}

fn filtered_statement_span(statement: &'a Statement<'tcx>, body_span: Span) -> Option<Span> {
pub(super) fn filtered_statement_span(
statement: &'a Statement<'tcx>,
body_span: Span,
) -> Option<Span> {
match statement.kind {
// These statements have spans that are often outside the scope of the executed source code
// for their parent `BasicBlock`.
@@ -686,7 +689,10 @@ fn filtered_statement_span(statement: &'a Statement<'tcx>, body_span: Span) -> O
}
}

fn filtered_terminator_span(terminator: &'a Terminator<'tcx>, body_span: Span) -> Option<Span> {
pub(super) fn filtered_terminator_span(
terminator: &'a Terminator<'tcx>,
body_span: Span,
) -> Option<Span> {
match terminator.kind {
// These terminators have spans that don't positively contribute to computing a reasonable
// span of actually executed source code. (For example, SwitchInt terminators extracted from
12 changes: 12 additions & 0 deletions compiler/rustc_mir/src/transform/coverage/test_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
authors = ["The Rust Project Developers"]
name = "coverage_test_macros"
version = "0.0.0"
edition = "2018"

[lib]
proc-macro = true
doctest = false

[dependencies]
proc-macro2 = "1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use proc_macro::TokenStream;

#[proc_macro]
pub fn let_bcb(item: TokenStream) -> TokenStream {
format!("let bcb{} = graph::BasicCoverageBlock::from_usize({});", item, item).parse().unwrap()
}
714 changes: 714 additions & 0 deletions compiler/rustc_mir/src/transform/coverage/tests.rs

Large diffs are not rendered by default.

41 changes: 19 additions & 22 deletions compiler/rustc_mir/src/transform/inline.rs
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ use rustc_index::vec::Idx;
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
use rustc_middle::mir::visit::*;
use rustc_middle::mir::*;
use rustc_middle::ty::subst::Subst;
use rustc_middle::ty::{self, ConstKind, Instance, InstanceDef, ParamEnv, Ty, TyCtxt};
use rustc_span::{hygiene::ExpnKind, ExpnData, Span};
use rustc_target::spec::abi::Abi;
@@ -28,6 +29,7 @@ pub struct Inline;
#[derive(Copy, Clone, Debug)]
struct CallSite<'tcx> {
callee: Instance<'tcx>,
fn_sig: ty::PolyFnSig<'tcx>,
block: BasicBlock,
target: Option<BasicBlock>,
source_info: SourceInfo,
@@ -173,22 +175,23 @@ impl Inliner<'tcx> {

// Only consider direct calls to functions
let terminator = bb_data.terminator();
if let TerminatorKind::Call { func: ref op, ref destination, .. } = terminator.kind {
if let ty::FnDef(callee_def_id, substs) = *op.ty(caller_body, self.tcx).kind() {
// To resolve an instance its substs have to be fully normalized, so
// we do this here.
let normalized_substs = self.tcx.normalize_erasing_regions(self.param_env, substs);
if let TerminatorKind::Call { ref func, ref destination, .. } = terminator.kind {
let func_ty = func.ty(caller_body, self.tcx);
if let ty::FnDef(def_id, substs) = *func_ty.kind() {
// To resolve an instance its substs have to be fully normalized.
let substs = self.tcx.normalize_erasing_regions(self.param_env, substs);
let callee =
Instance::resolve(self.tcx, self.param_env, callee_def_id, normalized_substs)
.ok()
.flatten()?;
Instance::resolve(self.tcx, self.param_env, def_id, substs).ok().flatten()?;

if let InstanceDef::Virtual(..) | InstanceDef::Intrinsic(_) = callee.def {
return None;
}

let fn_sig = self.tcx.fn_sig(def_id).subst(self.tcx, substs);

return Some(CallSite {
callee,
fn_sig,
block: bb,
target: destination.map(|(_, target)| target),
source_info: terminator.source_info,
@@ -203,9 +206,8 @@ impl Inliner<'tcx> {
debug!("should_inline({:?})", callsite);
let tcx = self.tcx;

// Cannot inline generators which haven't been transformed yet
if callee_body.yield_ty.is_some() {
debug!(" yield ty present - not inlining");
if callsite.fn_sig.c_variadic() {
debug!("callee is variadic - not inlining");
return false;
}

@@ -218,11 +220,7 @@ impl Inliner<'tcx> {
return false;
}

let self_no_sanitize =
self.codegen_fn_attrs.no_sanitize & self.tcx.sess.opts.debugging_opts.sanitizer;
let callee_no_sanitize =
codegen_fn_attrs.no_sanitize & self.tcx.sess.opts.debugging_opts.sanitizer;
if self_no_sanitize != callee_no_sanitize {
if self.codegen_fn_attrs.no_sanitize != codegen_fn_attrs.no_sanitize {
debug!("`callee has incompatible no_sanitize attribute - not inlining");
return false;
}
@@ -256,9 +254,9 @@ impl Inliner<'tcx> {
self.tcx.sess.opts.debugging_opts.inline_mir_threshold
};

// Significantly lower the threshold for inlining cold functions
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::COLD) {
threshold /= 5;
debug!("#[cold] present - not inlining");
return false;
}

// Give a bonus functions with a small number of blocks,
@@ -447,7 +445,7 @@ impl Inliner<'tcx> {
};

// Copy the arguments if needed.
let args: Vec<_> = self.make_call_args(args, &callsite, caller_body);
let args: Vec<_> = self.make_call_args(args, &callsite, caller_body, &callee_body);

let mut integrator = Integrator {
args: &args,
@@ -528,6 +526,7 @@ impl Inliner<'tcx> {
args: Vec<Operand<'tcx>>,
callsite: &CallSite<'tcx>,
caller_body: &mut Body<'tcx>,
callee_body: &Body<'tcx>,
) -> Vec<Local> {
let tcx = self.tcx;

@@ -554,9 +553,7 @@ impl Inliner<'tcx> {
// tmp2 = tuple_tmp.2
//
// and the vector is `[closure_ref, tmp0, tmp1, tmp2]`.
// FIXME(eddyb) make this check for `"rust-call"` ABI combined with
// `callee_body.spread_arg == None`, instead of special-casing closures.
if tcx.is_closure(callsite.callee.def_id()) {
if callsite.fn_sig.abi() == Abi::RustCall && callee_body.spread_arg.is_none() {
let mut args = args.into_iter();
let self_ = self.create_temp_if_necessary(args.next().unwrap(), callsite, caller_body);
let tuple = self.create_temp_if_necessary(args.next().unwrap(), callsite, caller_body);
15 changes: 7 additions & 8 deletions compiler/rustc_mir/src/transform/validate.rs
Original file line number Diff line number Diff line change
@@ -38,7 +38,9 @@ pub struct Validator {
impl<'tcx> MirPass<'tcx> for Validator {
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
let def_id = body.source.def_id();
let param_env = tcx.param_env(def_id);
// We need to param_env_reveal_all_normalized, as some optimizations
// change types in ways that require unfolding opaque types.
let param_env = tcx.param_env_reveal_all_normalized(def_id);
let mir_phase = self.mir_phase;

let always_live_locals = AlwaysLiveLocals::new(body);
@@ -79,7 +81,6 @@ pub fn equal_up_to_regions(
}

// Normalize lifetimes away on both sides, then compare.
let param_env = param_env.with_reveal_all_normalized(tcx);
let normalize = |ty: Ty<'tcx>| {
tcx.normalize_erasing_regions(
param_env,
@@ -167,17 +168,14 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
return true;
}
// Normalize projections and things like that.
// FIXME: We need to reveal_all, as some optimizations change types in ways
// that require unfolding opaque types.
let param_env = self.param_env.with_reveal_all_normalized(self.tcx);
let src = self.tcx.normalize_erasing_regions(param_env, src);
let dest = self.tcx.normalize_erasing_regions(param_env, dest);
let src = self.tcx.normalize_erasing_regions(self.param_env, src);
let dest = self.tcx.normalize_erasing_regions(self.param_env, dest);

// Type-changing assignments can happen when subtyping is used. While
// all normal lifetimes are erased, higher-ranked types with their
// late-bound lifetimes are still around and can lead to type
// differences. So we compare ignoring lifetimes.
equal_up_to_regions(self.tcx, param_env, src, dest)
equal_up_to_regions(self.tcx, self.param_env, src, dest)
}
}

@@ -358,6 +356,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
}
TerminatorKind::Call { func, args, destination, cleanup, .. } => {
let func_ty = func.ty(&self.body.local_decls, self.tcx);
let func_ty = self.tcx.normalize_erasing_regions(self.param_env, func_ty);
match func_ty.kind() {
ty::FnPtr(..) | ty::FnDef(..) => {}
_ => self.fail(
14 changes: 5 additions & 9 deletions compiler/rustc_parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
@@ -1180,8 +1180,7 @@ impl<'a> Parser<'a> {
/// Records all tokens consumed by the provided callback,
/// including the current token. These tokens are collected
/// into a `LazyTokenStream`, and returned along with the result
/// of the callback. The returned `LazyTokenStream` will be `None`
/// if not tokens were captured.
/// of the callback.
///
/// Note: If your callback consumes an opening delimiter
/// (including the case where you call `collect_tokens`
@@ -1203,17 +1202,14 @@ impl<'a> Parser<'a> {

let ret = f(self)?;

// We didn't capture any tokens
let num_calls = self.token_cursor.num_next_calls - cursor_snapshot.num_next_calls;
if num_calls == 0 {
return Ok((ret, None));
}

// Produces a `TokenStream` on-demand. Using `cursor_snapshot`
// and `num_calls`, we can reconstruct the `TokenStream` seen
// by the callback. This allows us to avoid producing a `TokenStream`
// if it is never needed - for example, a captured `macro_rules!`
// argument that is never passed to a proc macro.
// In practice token stream creation happens rarely compared to
// calls to `collect_tokens` (see some statistics in #78736),
// so we are doing as little up-front work as possible.
//
// This also makes `Parser` very cheap to clone, since
// there is no intermediate collection buffer to clone.
@@ -1247,8 +1243,8 @@ impl<'a> Parser<'a> {

let lazy_impl = LazyTokenStreamImpl {
start_token,
num_calls: self.token_cursor.num_next_calls - cursor_snapshot.num_next_calls,
cursor_snapshot,
num_calls,
desugar_doc_comments: self.desugar_doc_comments,
};
Ok((ret, Some(LazyTokenStream::new(lazy_impl))))
4 changes: 2 additions & 2 deletions compiler/rustc_save_analysis/src/sig.rs
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
// references.
//
// Signatures do not include visibility info. I'm not sure if this is a feature
// or an ommission (FIXME).
// or an omission (FIXME).
//
// FIXME where clauses need implementing, defs/refs in generics are mostly missing.

@@ -677,7 +677,7 @@ impl<'hir> Sig for hir::Variant<'hir> {
let mut text = self.ident.to_string();
match self.data {
hir::VariantData::Struct(fields, r) => {
let id = parent_id.unwrap();
let id = parent_id.ok_or("Missing id for Variant's parent")?;
let name_def = SigElement {
id: id_from_hir_id(id, scx),
start: offset,
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/aarch64_unknown_none.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOp

pub fn target() -> Target {
let opts = TargetOptions {
vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".to_owned()),
features: "+strict-align,+neon,+fp-armv8".to_string(),
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOp

pub fn target() -> Target {
let opts = TargetOptions {
vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".to_owned()),
features: "+strict-align,-neon,-fp-armv8".to_string(),
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armebv7r_none_eabi.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ pub fn target() -> Target {

options: TargetOptions {
endian: "big".to_string(),
vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
executables: true,
linker: Some("rust-lld".to_owned()),
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ pub fn target() -> Target {

options: TargetOptions {
endian: "big".to_string(),
vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
executables: true,
linker: Some("rust-lld".to_owned()),
4 changes: 0 additions & 4 deletions compiler/rustc_target/src/spec/armv7a_none_eabi.rs
Original file line number Diff line number Diff line change
@@ -10,9 +10,6 @@
// bare-metal binaries (the `gcc` linker has the advantage that it knows where C
// libraries and crt*.o are but it's not much of an advantage here); LLD is also
// faster
// - `os` set to `none`. rationale: matches `thumb` targets
// - `env` and `vendor` are set to an empty string. rationale: matches `thumb`
// targets
// - `panic_strategy` set to `abort`. rationale: matches `thumb` targets
// - `relocation-model` set to `static`; also no PIE, no relro and no dynamic
// linking. rationale: matches `thumb` targets
@@ -21,7 +18,6 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOp

pub fn target() -> Target {
let opts = TargetOptions {
vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".to_owned()),
features: "+v7,+thumb2,+soft-float,-neon,+strict-align".to_string(),
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armv7a_none_eabihf.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOp

pub fn target() -> Target {
let opts = TargetOptions {
vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".to_owned()),
features: "+v7,+vfp3,-d32,+thumb2,-neon,+strict-align".to_string(),
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armv7r_none_eabi.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@ pub fn target() -> Target {
arch: "arm".to_string(),

options: TargetOptions {
vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
executables: true,
linker: Some("rust-lld".to_owned()),
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armv7r_none_eabihf.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@ pub fn target() -> Target {
arch: "arm".to_string(),

options: TargetOptions {
vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
executables: true,
linker: Some("rust-lld".to_owned()),
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/avr_gnu_base.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@ pub fn target(target_cpu: String) -> Target {
pointer_width: 16,
options: TargetOptions {
c_int_width: "16".to_string(),
os: "unknown".to_string(),
cpu: target_cpu.clone(),
exe_suffix: ".elf".to_string(),

1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/fuchsia_base.rs
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@ pub fn opts() -> TargetOptions {

TargetOptions {
os: "fuchsia".to_string(),
vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".to_owned()),
lld_flavor: LldFlavor::Ld,
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/mipsel_unknown_none.rs
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@ pub fn target() -> Target {
arch: "mips".to_string(),

options: TargetOptions {
vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
cpu: "mips32r2".to_string(),
features: "+mips32r2,+soft-float,+noabicalls".to_string(),
28 changes: 22 additions & 6 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
@@ -713,11 +713,14 @@ pub struct TargetOptions {
pub endian: String,
/// Width of c_int type. Defaults to "32".
pub c_int_width: String,
/// OS name to use for conditional compilation. Defaults to "none".
/// OS name to use for conditional compilation (`target_os`). Defaults to "none".
/// "none" implies a bare metal target without `std` library.
/// A couple of targets having `std` also use "unknown" as an `os` value,
/// but they are exceptions.
pub os: String,
/// Environment name to use for conditional compilation. Defaults to "".
/// Environment name to use for conditional compilation (`target_env`). Defaults to "".
pub env: String,
/// Vendor name to use for conditional compilation. Defaults to "unknown".
/// Vendor name to use for conditional compilation (`target_vendor`). Defaults to "unknown".
pub vendor: String,
/// Default linker flavor used if `-C linker-flavor` or `-C linker` are not passed
/// on the command line. Defaults to `LinkerFlavor::Gcc`.
@@ -819,10 +822,23 @@ pub struct TargetOptions {
/// Only useful for compiling against Illumos/Solaris,
/// as they have a different set of linker flags. Defaults to false.
pub is_like_solaris: bool,
/// Whether the target toolchain is like Windows'. Only useful for compiling against Windows,
/// only really used for figuring out how to find libraries, since Windows uses its own
/// library naming convention. Defaults to false.
/// Whether the target is like Windows.
/// This is a combination of several more specific properties represented as a single flag:
/// - The target uses a Windows ABI,
/// - uses PE/COFF as a format for object code,
/// - uses Windows-style dllexport/dllimport for shared libraries,
/// - uses import libraries and .def files for symbol exports,
/// - executables support setting a subsystem.
pub is_like_windows: bool,
/// Whether the target is like MSVC.
/// This is a combination of several more specific properties represented as a single flag:
/// - The target has all the properties from `is_like_windows`
/// (for in-tree targets "is_like_msvc ⇒ is_like_windows" is ensured by a unit test),
/// - has some MSVC-specific Windows ABI properties,
/// - uses a link.exe-like linker,
/// - uses CodeView/PDB for debuginfo and natvis for its visualization,
/// - uses SEH-based unwinding,
/// - supports control flow guard mechanism.
pub is_like_msvc: bool,
/// Whether the target toolchain is like Emscripten's. Only useful for compiling with
/// Emscripten toolchain.
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/msp430_none_elf.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ pub fn target() -> Target {

options: TargetOptions {
c_int_width: "16".to_string(),
vendor: String::new(),
executables: true,

// The LLVM backend currently can't generate object files. To
15 changes: 15 additions & 0 deletions compiler/rustc_target/src/spec/tests/tests_impl.rs
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ pub(super) fn test_target(target: Target) {

impl Target {
fn check_consistency(&self) {
assert!(self.is_like_windows || !self.is_like_msvc);
// Check that LLD with the given flavor is treated identically to the linker it emulates.
// If your target really needs to deviate from the rules below, except it and document the
// reasons.
@@ -16,6 +17,7 @@ impl Target {
|| self.linker_flavor == LinkerFlavor::Lld(LldFlavor::Link),
self.lld_flavor == LldFlavor::Link,
);
assert_eq!(self.is_like_msvc, self.lld_flavor == LldFlavor::Link);
for args in &[
&self.pre_link_args,
&self.late_link_args,
@@ -36,5 +38,18 @@ impl Target {
&& self.post_link_objects_fallback.is_empty())
|| self.crt_objects_fallback.is_some()
);
// Keep the default "unknown" vendor instead.
assert_ne!(self.vendor, "");
if !self.can_use_os_unknown() {
// Keep the default "none" for bare metal targets instead.
assert_ne!(self.os, "unknown");
}
}

// Add your target to the whitelist if it has `std` library
// and you certainly want "unknown" for the OS name.
fn can_use_os_unknown(&self) -> bool {
self.llvm_target == "wasm32-unknown-unknown"
|| (self.env == "sgx" && self.vendor == "fortanix")
}
}
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/thumb_base.rs
Original file line number Diff line number Diff line change
@@ -32,7 +32,6 @@ use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, TargetOpti
pub fn opts() -> TargetOptions {
// See rust-lang/rfcs#1645 for a discussion about these defaults
TargetOptions {
vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
executables: true,
// In most cases, LLD is good enough
9 changes: 0 additions & 9 deletions compiler/rustc_target/src/spec/uefi_msvc_base.rs
Original file line number Diff line number Diff line change
@@ -46,15 +46,6 @@ pub fn opts() -> TargetOptions {
stack_probes: true,
singlethread: true,
linker: Some("rust-lld".to_string()),
// FIXME: This should likely be `true` inherited from `msvc_base`
// because UEFI follows Windows ABI and uses PE/COFF.
// The `false` is probably causing ABI bugs right now.
is_like_windows: false,
// FIXME: This should likely be `true` inherited from `msvc_base`
// because UEFI follows Windows ABI and uses PE/COFF.
// The `false` is probably causing ABI bugs right now.
is_like_msvc: false,

..base
}
}
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/wasm32_wasi.rs
Original file line number Diff line number Diff line change
@@ -79,7 +79,6 @@ pub fn target() -> Target {
let mut options = wasm32_base::options();

options.os = "wasi".to_string();
options.vendor = String::new();
options.linker_flavor = LinkerFlavor::Lld(LldFlavor::Wasm);
options
.pre_link_args
24 changes: 24 additions & 0 deletions library/alloc/src/collections/btree/map.rs
Original file line number Diff line number Diff line change
@@ -863,6 +863,30 @@ impl<K: Ord, V> BTreeMap<K, V> {
}
}

/// Retains only the elements specified by the predicate.
///
/// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)` returns `false`.
///
/// # Examples
///
/// ```
/// #![feature(btree_retain)]
/// use std::collections::BTreeMap;
///
/// let mut map: BTreeMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();
/// // Keep only the elements with even-numbered keys.
/// map.retain(|&k, _| k % 2 == 0);
/// assert!(map.into_iter().eq(vec![(0, 0), (2, 20), (4, 40), (6, 60)]));
/// ```
#[inline]
#[unstable(feature = "btree_retain", issue = "79025")]
pub fn retain<F>(&mut self, mut f: F)
where
F: FnMut(&K, &mut V) -> bool,
{
self.drain_filter(|k, v| !f(k, v));
}

/// Moves all elements from `other` into `Self`, leaving `other` empty.
///
/// # Examples
11 changes: 11 additions & 0 deletions library/alloc/src/collections/btree/map/tests.rs
Original file line number Diff line number Diff line change
@@ -808,6 +808,17 @@ fn test_range_mut() {
map.check();
}

#[test]
fn test_retain() {
let mut map: BTreeMap<i32, i32> = (0..100).map(|x| (x, x * 10)).collect();

map.retain(|&k, _| k % 2 == 0);
assert_eq!(map.len(), 50);
assert_eq!(map[&2], 20);
assert_eq!(map[&4], 40);
assert_eq!(map[&6], 60);
}

mod test_drain_filter {
use super::*;

24 changes: 24 additions & 0 deletions library/alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
@@ -798,6 +798,30 @@ impl<T: Ord> BTreeSet<T> {
Recover::take(&mut self.map, value)
}

/// Retains only the elements specified by the predicate.
///
/// In other words, remove all elements `e` such that `f(&e)` returns `false`.
///
/// # Examples
///
/// ```
/// #![feature(btree_retain)]
/// use std::collections::BTreeSet;
///
/// let xs = [1, 2, 3, 4, 5, 6];
/// let mut set: BTreeSet<i32> = xs.iter().cloned().collect();
/// // Keep only the even numbers.
/// set.retain(|&k| k % 2 == 0);
/// assert!(set.iter().eq([2, 4, 6].iter()));
/// ```
#[unstable(feature = "btree_retain", issue = "79025")]
pub fn retain<F>(&mut self, mut f: F)
where
F: FnMut(&T) -> bool,
{
self.drain_filter(|v| !f(v));
}

/// Moves all elements from `other` into `Self`, leaving `other` empty.
///
/// # Examples
11 changes: 11 additions & 0 deletions library/alloc/src/collections/btree/set/tests.rs
Original file line number Diff line number Diff line change
@@ -324,6 +324,17 @@ fn test_is_subset() {
assert_eq!(is_subset(&[99, 100], &large), false);
}

#[test]
fn test_retain() {
let xs = [1, 2, 3, 4, 5, 6];
let mut set: BTreeSet<i32> = xs.iter().cloned().collect();
set.retain(|&k| k % 2 == 0);
assert_eq!(set.len(), 3);
assert!(set.contains(&2));
assert!(set.contains(&4));
assert!(set.contains(&6));
}

#[test]
fn test_drain_filter() {
let mut x: BTreeSet<_> = [1].iter().copied().collect();
1 change: 1 addition & 0 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
@@ -178,6 +178,7 @@ const LLVM_TOOLS: &[&str] = &[
"llvm-size", // used to prints the size of the linker sections of a program
"llvm-strip", // used to discard symbols from binary files to reduce their size
"llvm-ar", // used for creating and modifying archive files
"llvm-as", // used to convert LLVM assembly to LLVM bitcode
"llvm-dis", // used to disassemble LLVM bitcode
"llc", // used to compile LLVM bytecode
"opt", // used to optimize LLVM bytecode
22 changes: 19 additions & 3 deletions src/test/mir-opt/inline/inline-compatibility.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Checks that only functions with compatible attributes are inlined.
//
// only-x86_64
// needs-sanitizer-address
// compile-flags: -Zsanitizer=address

#![crate_type = "lib"]
#![feature(no_sanitize)]
#![feature(target_feature_11)]
#![feature(c_variadic)]

// EMIT_MIR inline_compatibility.inlined_target_feature.Inline.diff
#[target_feature(enable = "sse2")]
@@ -35,5 +34,22 @@ pub unsafe fn not_inlined_no_sanitize() {
pub unsafe fn target_feature() {}

#[inline]
#[no_sanitize(address, memory)]
#[no_sanitize(address)]
pub unsafe fn no_sanitize() {}

// EMIT_MIR inline_compatibility.not_inlined_c_variadic.Inline.diff
pub unsafe fn not_inlined_c_variadic() {
let s = sum(4u32, 4u32, 30u32, 200u32, 1000u32);
}

#[no_mangle]
#[inline(always)]
unsafe extern "C" fn sum(n: u32, mut vs: ...) -> u32 {
let mut s = 0;
let mut i = 0;
while i != n {
s += vs.arg::<u32>();
i += 1;
}
s
}
16 changes: 16 additions & 0 deletions src/test/mir-opt/inline/inline-generator.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// ignore-wasm32-bare compiled with panic=abort by default
#![feature(generators, generator_trait)]

use std::ops::Generator;
use std::pin::Pin;

// EMIT_MIR inline_generator.main.Inline.diff
fn main() {
let _r = Pin::new(&mut g()).resume(false);
}

#[inline(always)]
pub fn g() -> impl Generator<bool> {
#[inline(always)]
|a| { yield if a { 7 } else { 13 } }
}
Original file line number Diff line number Diff line change
@@ -2,24 +2,24 @@
+ // MIR for `inlined_no_sanitize` after Inline

fn inlined_no_sanitize() -> () {
let mut _0: (); // return place in scope 0 at $DIR/inline-compatibility.rs:24:37: 24:37
let _1: (); // in scope 0 at $DIR/inline-compatibility.rs:25:5: 25:18
+ scope 1 (inlined no_sanitize) { // at $DIR/inline-compatibility.rs:25:5: 25:18
let mut _0: (); // return place in scope 0 at $DIR/inline-compatibility.rs:23:37: 23:37
let _1: (); // in scope 0 at $DIR/inline-compatibility.rs:24:5: 24:18
+ scope 1 (inlined no_sanitize) { // at $DIR/inline-compatibility.rs:24:5: 24:18
+ }

bb0: {
StorageLive(_1); // scope 0 at $DIR/inline-compatibility.rs:25:5: 25:18
- _1 = no_sanitize() -> bb1; // scope 0 at $DIR/inline-compatibility.rs:25:5: 25:18
StorageLive(_1); // scope 0 at $DIR/inline-compatibility.rs:24:5: 24:18
- _1 = no_sanitize() -> bb1; // scope 0 at $DIR/inline-compatibility.rs:24:5: 24:18
- // mir::Constant
- // + span: $DIR/inline-compatibility.rs:25:5: 25:16
- // + span: $DIR/inline-compatibility.rs:24:5: 24:16
- // + literal: Const { ty: unsafe fn() {no_sanitize}, val: Value(Scalar(<ZST>)) }
- }
-
- bb1: {
+ _1 = const (); // scope 1 at $DIR/inline-compatibility.rs:25:5: 25:18
StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:25:18: 25:19
_0 = const (); // scope 0 at $DIR/inline-compatibility.rs:24:37: 26:2
return; // scope 0 at $DIR/inline-compatibility.rs:26:2: 26:2
+ _1 = const (); // scope 1 at $DIR/inline-compatibility.rs:24:5: 24:18
StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:24:18: 24:19
_0 = const (); // scope 0 at $DIR/inline-compatibility.rs:23:37: 25:2
return; // scope 0 at $DIR/inline-compatibility.rs:25:2: 25:2
}
}

Original file line number Diff line number Diff line change
@@ -2,24 +2,24 @@
+ // MIR for `inlined_target_feature` after Inline

fn inlined_target_feature() -> () {
let mut _0: (); // return place in scope 0 at $DIR/inline-compatibility.rs:13:40: 13:40
let _1: (); // in scope 0 at $DIR/inline-compatibility.rs:14:5: 14:21
+ scope 1 (inlined target_feature) { // at $DIR/inline-compatibility.rs:14:5: 14:21
let mut _0: (); // return place in scope 0 at $DIR/inline-compatibility.rs:12:40: 12:40
let _1: (); // in scope 0 at $DIR/inline-compatibility.rs:13:5: 13:21
+ scope 1 (inlined target_feature) { // at $DIR/inline-compatibility.rs:13:5: 13:21
+ }

bb0: {
StorageLive(_1); // scope 0 at $DIR/inline-compatibility.rs:14:5: 14:21
- _1 = target_feature() -> bb1; // scope 0 at $DIR/inline-compatibility.rs:14:5: 14:21
StorageLive(_1); // scope 0 at $DIR/inline-compatibility.rs:13:5: 13:21
- _1 = target_feature() -> bb1; // scope 0 at $DIR/inline-compatibility.rs:13:5: 13:21
- // mir::Constant
- // + span: $DIR/inline-compatibility.rs:14:5: 14:19
- // + span: $DIR/inline-compatibility.rs:13:5: 13:19
- // + literal: Const { ty: unsafe fn() {target_feature}, val: Value(Scalar(<ZST>)) }
- }
-
- bb1: {
+ _1 = const (); // scope 1 at $DIR/inline-compatibility.rs:14:5: 14:21
StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:14:21: 14:22
_0 = const (); // scope 0 at $DIR/inline-compatibility.rs:13:40: 15:2
return; // scope 0 at $DIR/inline-compatibility.rs:15:2: 15:2
+ _1 = const (); // scope 1 at $DIR/inline-compatibility.rs:13:5: 13:21
StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:13:21: 13:22
_0 = const (); // scope 0 at $DIR/inline-compatibility.rs:12:40: 14:2
return; // scope 0 at $DIR/inline-compatibility.rs:14:2: 14:2
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- // MIR for `not_inlined_c_variadic` before Inline
+ // MIR for `not_inlined_c_variadic` after Inline

fn not_inlined_c_variadic() -> () {
let mut _0: (); // return place in scope 0 at $DIR/inline-compatibility.rs:41:40: 41:40
let _1: u32; // in scope 0 at $DIR/inline-compatibility.rs:42:9: 42:10
scope 1 {
debug s => _1; // in scope 1 at $DIR/inline-compatibility.rs:42:9: 42:10
}

bb0: {
StorageLive(_1); // scope 0 at $DIR/inline-compatibility.rs:42:9: 42:10
_1 = sum(const 4_u32, const 4_u32, const 30_u32, const 200_u32, const 1000_u32) -> bb1; // scope 0 at $DIR/inline-compatibility.rs:42:13: 42:52
// mir::Constant
// + span: $DIR/inline-compatibility.rs:42:13: 42:16
// + literal: Const { ty: unsafe extern "C" fn(u32, ...) -> u32 {sum}, val: Value(Scalar(<ZST>)) }
}

bb1: {
_0 = const (); // scope 0 at $DIR/inline-compatibility.rs:41:40: 43:2
StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:43:1: 43:2
return; // scope 0 at $DIR/inline-compatibility.rs:43:2: 43:2
}
}

Original file line number Diff line number Diff line change
@@ -2,21 +2,21 @@
+ // MIR for `not_inlined_no_sanitize` after Inline

fn not_inlined_no_sanitize() -> () {
let mut _0: (); // return place in scope 0 at $DIR/inline-compatibility.rs:29:41: 29:41
let _1: (); // in scope 0 at $DIR/inline-compatibility.rs:30:5: 30:18
let mut _0: (); // return place in scope 0 at $DIR/inline-compatibility.rs:28:41: 28:41
let _1: (); // in scope 0 at $DIR/inline-compatibility.rs:29:5: 29:18

bb0: {
StorageLive(_1); // scope 0 at $DIR/inline-compatibility.rs:30:5: 30:18
_1 = no_sanitize() -> bb1; // scope 0 at $DIR/inline-compatibility.rs:30:5: 30:18
StorageLive(_1); // scope 0 at $DIR/inline-compatibility.rs:29:5: 29:18
_1 = no_sanitize() -> bb1; // scope 0 at $DIR/inline-compatibility.rs:29:5: 29:18
// mir::Constant
// + span: $DIR/inline-compatibility.rs:30:5: 30:16
// + span: $DIR/inline-compatibility.rs:29:5: 29:16
// + literal: Const { ty: unsafe fn() {no_sanitize}, val: Value(Scalar(<ZST>)) }
}

bb1: {
StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:30:18: 30:19
_0 = const (); // scope 0 at $DIR/inline-compatibility.rs:29:41: 31:2
return; // scope 0 at $DIR/inline-compatibility.rs:31:2: 31:2
StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:29:18: 29:19
_0 = const (); // scope 0 at $DIR/inline-compatibility.rs:28:41: 30:2
return; // scope 0 at $DIR/inline-compatibility.rs:30:2: 30:2
}
}

Original file line number Diff line number Diff line change
@@ -2,21 +2,21 @@
+ // MIR for `not_inlined_target_feature` after Inline

fn not_inlined_target_feature() -> () {
let mut _0: (); // return place in scope 0 at $DIR/inline-compatibility.rs:18:44: 18:44
let _1: (); // in scope 0 at $DIR/inline-compatibility.rs:19:5: 19:21
let mut _0: (); // return place in scope 0 at $DIR/inline-compatibility.rs:17:44: 17:44
let _1: (); // in scope 0 at $DIR/inline-compatibility.rs:18:5: 18:21

bb0: {
StorageLive(_1); // scope 0 at $DIR/inline-compatibility.rs:19:5: 19:21
_1 = target_feature() -> bb1; // scope 0 at $DIR/inline-compatibility.rs:19:5: 19:21
StorageLive(_1); // scope 0 at $DIR/inline-compatibility.rs:18:5: 18:21
_1 = target_feature() -> bb1; // scope 0 at $DIR/inline-compatibility.rs:18:5: 18:21
// mir::Constant
// + span: $DIR/inline-compatibility.rs:19:5: 19:19
// + span: $DIR/inline-compatibility.rs:18:5: 18:19
// + literal: Const { ty: unsafe fn() {target_feature}, val: Value(Scalar(<ZST>)) }
}

bb1: {
StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:19:21: 19:22
_0 = const (); // scope 0 at $DIR/inline-compatibility.rs:18:44: 20:2
return; // scope 0 at $DIR/inline-compatibility.rs:20:2: 20:2
StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:18:21: 18:22
_0 = const (); // scope 0 at $DIR/inline-compatibility.rs:17:44: 19:2
return; // scope 0 at $DIR/inline-compatibility.rs:19:2: 19:2
}
}

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

fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/inline-generator.rs:8:11: 8:11
let _1: 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>; // in scope 0 at $DIR/inline-generator.rs:9:9: 9:11
let mut _2: std::pin::Pin<&mut impl std::ops::Generator<bool>>; // in scope 0 at $DIR/inline-generator.rs:9:14: 9:32
let mut _3: &mut impl std::ops::Generator<bool>; // in scope 0 at $DIR/inline-generator.rs:9:23: 9:31
let mut _4: impl std::ops::Generator<bool>; // in scope 0 at $DIR/inline-generator.rs:9:28: 9:31
+ let mut _7: bool; // in scope 0 at $DIR/inline-generator.rs:9:14: 9:46
scope 1 {
debug _r => _1; // in scope 1 at $DIR/inline-generator.rs:9:9: 9:11
}
+ scope 2 (inlined g) { // at $DIR/inline-generator.rs:9:28: 9:31
+ }
+ scope 3 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]>::new) { // at $DIR/inline-generator.rs:9:14: 9:32
+ debug pointer => _3; // in scope 3 at $DIR/inline-generator.rs:9:14: 9:32
+ let mut _5: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]; // in scope 3 at $DIR/inline-generator.rs:9:14: 9:32
+ scope 4 {
+ scope 5 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]>::new_unchecked) { // at $DIR/inline-generator.rs:9:14: 9:32
+ debug pointer => _5; // in scope 5 at $DIR/inline-generator.rs:9:14: 9:32
+ let mut _6: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]; // in scope 5 at $DIR/inline-generator.rs:9:14: 9:32
+ }
+ }
+ }
+ 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
+ }

bb0: {
StorageLive(_1); // scope 0 at $DIR/inline-generator.rs:9:9: 9:11
StorageLive(_2); // scope 0 at $DIR/inline-generator.rs:9:14: 9:32
StorageLive(_3); // scope 0 at $DIR/inline-generator.rs:9:23: 9:31
StorageLive(_4); // scope 0 at $DIR/inline-generator.rs:9:28: 9:31
- _4 = g() -> bb1; // scope 0 at $DIR/inline-generator.rs:9:28: 9:31
- // mir::Constant
- // + span: $DIR/inline-generator.rs:9:28: 9:29
- // + literal: Const { ty: fn() -> impl std::ops::Generator<bool> {g}, val: Value(Scalar(<ZST>)) }
- }
-
- bb1: {
+ discriminant(_4) = 0; // scope 2 at $DIR/inline-generator.rs:9:28: 9:31
_3 = &mut _4; // scope 0 at $DIR/inline-generator.rs:9:23: 9:31
- _2 = Pin::<&mut impl Generator<bool>>::new(move _3) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/inline-generator.rs:9:14: 9:32
- // mir::Constant
- // + span: $DIR/inline-generator.rs:9:14: 9:22
- // + user_ty: UserType(0)
- // + literal: Const { ty: fn(&mut impl std::ops::Generator<bool>) -> std::pin::Pin<&mut impl std::ops::Generator<bool>> {std::pin::Pin::<&mut impl std::ops::Generator<bool>>::new}, val: Value(Scalar(<ZST>)) }
- }
-
- bb2: {
+ StorageLive(_5); // scope 4 at $DIR/inline-generator.rs:9:14: 9:32
+ _5 = move _3; // scope 4 at $DIR/inline-generator.rs:9:14: 9:32
+ StorageLive(_6); // scope 5 at $DIR/inline-generator.rs:9:14: 9:32
+ _6 = move _5; // scope 5 at $DIR/inline-generator.rs:9:14: 9:32
+ (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]) = move _6; // scope 5 at $DIR/inline-generator.rs:9:14: 9:32
+ StorageDead(_6); // scope 5 at $DIR/inline-generator.rs:9:14: 9:32
+ StorageDead(_5); // scope 4 at $DIR/inline-generator.rs:9:14: 9:32
StorageDead(_3); // scope 0 at $DIR/inline-generator.rs:9:31: 9:32
- _1 = <impl Generator<bool> as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
- // mir::Constant
- // + span: $DIR/inline-generator.rs:9:33: 9:39
- // + 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
+ _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
}

- bb3: {
+ bb1: {
+ 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
_0 = const (); // scope 0 at $DIR/inline-generator.rs:8:11: 10:2
StorageDead(_1); // scope 0 at $DIR/inline-generator.rs:10:1: 10:2
return; // scope 0 at $DIR/inline-generator.rs:10:2: 10:2
}

- bb4 (cleanup): {
+ bb2 (cleanup): {
resume; // scope 0 at $DIR/inline-generator.rs:8:1: 10:2
+ }
+
+ bb3: {
+ _8 = move _7; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ switchInt(_8) -> [false: bb4, otherwise: bb5]; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ }
+
+ bb4: {
+ ((_1 as Yielded).0: i32) = 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
+ }
+
+ bb5: {
+ ((_1 as Yielded).0: i32) = 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
+ }
+
+ bb6: {
+ 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
+ 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
+ }
+
+ bb8: {
+ assert(const false, "generator resumed after completion") -> [success: bb8, unwind: bb2]; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ }
+
+ bb9: {
+ unreachable; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
}
}

16 changes: 16 additions & 0 deletions src/test/pretty/qpath-associated-type-bound.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// pp-exact


mod m {
pub trait Tr {
type Ts: super::Tu;
}
}

trait Tu {
fn dummy() { }
}

fn foo<T: m::Tr>() { <T as m::Tr>::Ts::dummy(); }

fn main() { }
14 changes: 6 additions & 8 deletions src/test/run-make-fulldeps/coverage-reports-base/Makefile
Original file line number Diff line number Diff line change
@@ -13,15 +13,13 @@
BASEDIR=../coverage-reports-base
SOURCEDIR=../coverage

ifeq ($(UNAME),Darwin)
# FIXME(richkadel): It appears that --debug is not available on MacOS even when not running
# under CI.
NO_LLVM_ASSERTIONS=1
endif

# The `llvm-cov show` flag `--debug`, used to generate the `counters` output files, is only enabled
# if LLVM assertions are enabled. Some CI builds disable debug assertions.
ifndef NO_LLVM_ASSERTIONS
# if LLVM assertions are enabled. Requires Rust config `llvm/optimize` and not
# `llvm/release_debuginfo`. Note that some CI builds disable debug assertions (by setting
# `NO_LLVM_ASSERTIONS=1`), so it is not OK to fail the test, but `bless`ed test results cannot be
# generated without debug assertions.
LLVM_COV_DEBUG := $(shell "$(LLVM_BIN_DIR)"/llvm-cov show --debug 2>&1 | grep -q "Unknown command line argument '--debug'"; echo $$?)
ifeq ($(LLVM_COV_DEBUG), 1)
DEBUG_FLAG=--debug
endif

44 changes: 17 additions & 27 deletions src/test/run-make-fulldeps/coverage-spanview-base/Makefile
Original file line number Diff line number Diff line change
@@ -9,9 +9,20 @@
BASEDIR=../coverage-spanview-base
SOURCEDIR=../coverage

ifeq ($(UNAME),Darwin)
SED_HAS_ISSUES=1
endif
define SPANVIEW_HEADER
<!DOCTYPE html>
<!--

Preview this file as rendered HTML from the github source at:
https://htmlpreview.github.io/?https://github.com/rust-lang/rust/blob/master/src/test/run-make-fulldeps/coverage-spanview-base/expected_mir_dump.%s/%s

For revisions in Pull Requests (PR):
* Replace "rust-lang" with the github PR author
* Replace "master" with the PR branch name

-->
endef
export SPANVIEW_HEADER

all: $(patsubst $(SOURCEDIR)/%.rs,%,$(wildcard $(SOURCEDIR)/*.rs))

@@ -33,31 +44,12 @@ endif
-Zdump-mir-spanview \
-Zdump-mir-dir="$(TMPDIR)"/mir_dump.$@

ifdef SED_HAS_ISSUES
# FIXME(richkadel): MacOS's default sed has some significant limitations. Until I've come up
# with a better workaround, I'm disabling this test for MacOS.
#
# For future reference, see if `gsed` is available as an alternative.
which gsed || echo "no gsed"
else

for path in "$(TMPDIR)"/mir_dump.$@/*; do \
echo $$path; \
file="$$(basename "$$path")"; \
echo $$file; \
urlescaped="$$("$(PYTHON)" $(BASEDIR)/escape_url.py $$file)" || exit $$?; \
echo $$urlescaped; \
sed -i -e '1a\
<!--\
\
Preview this file as rendered HTML from the github source at:\
https://htmlpreview.github.io/?https://github.com/rust-lang/rust/blob/master/src/test/run-make-fulldeps/coverage-spanview-base/expected_mir_dump.$@/'"$$urlescaped"'\
\
For revisions in Pull Requests (PR):\
* Replace "rust-lang" with the github PR author\
* Replace "master" with the PR branch name\
\
-->' "$$path"; \
printf "$$SPANVIEW_HEADER\n" "$@" "$$urlescaped" > "$$path".modified; \
tail -n +2 "$$path" >> "$$path".modified; \
mv "$$path".modified "$$path"; \
done && true # for/done ends in non-zero status

ifdef RUSTC_BLESS_TEST
@@ -70,5 +62,3 @@ else
cp "$(TMPDIR)"/mir_dump.$@/*InstrumentCoverage.0.html "$(TMPDIR)"/actual_mir_dump.$@/
$(DIFF) -r expected_mir_dump.$@/ "$(TMPDIR)"/actual_mir_dump.$@/
endif

endif
22 changes: 22 additions & 0 deletions src/test/rustdoc/raw-ident-eliminate-r-hashtag.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// ignore-tidy-linelength

#![crate_type="lib"]

pub mod internal {
// @has 'raw_ident_eliminate_r_hashtag/internal/struct.mod.html'
pub struct r#mod;

/// See [name], [other name]
///
/// [name]: mod
/// [other name]: crate::internal::mod
// @has 'raw_ident_eliminate_r_hashtag/internal/struct.B.html' '//*a[@href="../../raw_ident_eliminate_r_hashtag/internal/struct.mod.html"]' 'name'
// @has 'raw_ident_eliminate_r_hashtag/internal/struct.B.html' '//*a[@href="../../raw_ident_eliminate_r_hashtag/internal/struct.mod.html"]' 'other name'
pub struct B;
}

/// See [name].
///
/// [name]: internal::mod
// @has 'raw_ident_eliminate_r_hashtag/struct.A.html' '//*a[@href="../raw_ident_eliminate_r_hashtag/internal/struct.mod.html"]' 'name'
pub struct A;
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// revisions: default miropt
//[miropt]compile-flags: -Z mir-opt-level=2
// ~^ This flag is for #77668, it used to be ICE.

#![crate_type = "lib"]

pub fn bar<P>( // Error won't happen if "bar" is not generic
18 changes: 14 additions & 4 deletions src/test/ui/mir/mir-inlining/ice-issue-77306-1.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
// run-pass
// Regression test for various issues related to normalization & inlining.
// * #68347, #77306, #77668 - missed normalization during inlining.
// * #78442 - missed normalization in validator after inlining.
//
// build-pass
// compile-flags:-Zmir-opt-level=2

// Previously ICEd because we did not normalize during inlining,
// see https://github.com/rust-lang/rust/pull/77306 for more discussion.

pub fn write() {
create()()
}

pub fn write_generic<T>(_t: T) {
hide()();
}

pub fn create() -> impl FnOnce() {
|| ()
}

pub fn hide() -> impl Fn() {
write
}

fn main() {
write();
write_generic(());
}