Auto merge of #143934 - samueltardieu:rollup-w3iw614, r=samueltardieu
Rollup of 8 pull requests Successful merges: - rust-lang/rust#141809 (Don't call WSACleanup on process exit) - rust-lang/rust#143710 (Updates to random number generation APIs) - rust-lang/rust#143848 (Rename `stable_mir` and `rustc_smir`) - rust-lang/rust#143855 (Port `#[omit_gdb_pretty_printer_section]` to the new attribute parsing) - rust-lang/rust#143868 (warn on align on fields to avoid breaking changes) - rust-lang/rust#143870 ([COMPILETEST-UNTANGLE 6/N] Use `TestSuite` enum instead of stringly-typed test suites) - rust-lang/rust#143901 (Region constraint nits) - rust-lang/rust#143903 (Fix typos in documentation files) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
aa51a9b094
101 changed files with 461 additions and 407 deletions
66
Cargo.lock
66
Cargo.lock
|
|
@ -3271,8 +3271,8 @@ dependencies = [
|
|||
"rustc_codegen_ssa",
|
||||
"rustc_driver",
|
||||
"rustc_driver_impl",
|
||||
"rustc_smir",
|
||||
"stable_mir",
|
||||
"rustc_public",
|
||||
"rustc_public_bridge",
|
||||
"tikv-jemalloc-sys",
|
||||
]
|
||||
|
||||
|
|
@ -3709,6 +3709,7 @@ dependencies = [
|
|||
"rustc_passes",
|
||||
"rustc_pattern_analysis",
|
||||
"rustc_privacy",
|
||||
"rustc_public",
|
||||
"rustc_query_system",
|
||||
"rustc_resolve",
|
||||
"rustc_session",
|
||||
|
|
@ -3718,7 +3719,6 @@ dependencies = [
|
|||
"rustc_ty_utils",
|
||||
"serde_json",
|
||||
"shlex",
|
||||
"stable_mir",
|
||||
"tracing",
|
||||
"windows 0.61.3",
|
||||
]
|
||||
|
|
@ -4415,6 +4415,36 @@ dependencies = [
|
|||
"rustc-literal-escaper",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_public"
|
||||
version = "0.1.0-preview"
|
||||
dependencies = [
|
||||
"rustc_abi",
|
||||
"rustc_hir",
|
||||
"rustc_middle",
|
||||
"rustc_public_bridge",
|
||||
"rustc_session",
|
||||
"rustc_span",
|
||||
"rustc_target",
|
||||
"scoped-tls",
|
||||
"serde",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_public_bridge"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"rustc_abi",
|
||||
"rustc_data_structures",
|
||||
"rustc_hir",
|
||||
"rustc_hir_pretty",
|
||||
"rustc_middle",
|
||||
"rustc_session",
|
||||
"rustc_span",
|
||||
"rustc_target",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_query_impl"
|
||||
version = "0.0.0"
|
||||
|
|
@ -4542,20 +4572,6 @@ dependencies = [
|
|||
"windows 0.61.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_smir"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"rustc_abi",
|
||||
"rustc_data_structures",
|
||||
"rustc_hir",
|
||||
"rustc_hir_pretty",
|
||||
"rustc_middle",
|
||||
"rustc_session",
|
||||
"rustc_span",
|
||||
"rustc_target",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_span"
|
||||
version = "0.0.0"
|
||||
|
|
@ -5103,22 +5119,6 @@ version = "1.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||
|
||||
[[package]]
|
||||
name = "stable_mir"
|
||||
version = "0.1.0-preview"
|
||||
dependencies = [
|
||||
"rustc_abi",
|
||||
"rustc_hir",
|
||||
"rustc_middle",
|
||||
"rustc_session",
|
||||
"rustc_smir",
|
||||
"rustc_span",
|
||||
"rustc_target",
|
||||
"scoped-tls",
|
||||
"serde",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stacker"
|
||||
version = "0.1.21"
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
|
|||
rustc_driver = { path = "../rustc_driver" }
|
||||
rustc_driver_impl = { path = "../rustc_driver_impl" }
|
||||
|
||||
# Make sure rustc_smir ends up in the sysroot, because this
|
||||
# crate is intended to be used by stable MIR consumers, which are not in-tree.
|
||||
rustc_smir = { path = "../rustc_smir" }
|
||||
rustc_public = { path = "../rustc_public" }
|
||||
|
||||
stable_mir = { path = "../stable_mir" }
|
||||
# Make sure rustc_public_bridge ends up in the sysroot, because this
|
||||
# crate is intended to be used by stable MIR consumers, which are not in-tree.
|
||||
rustc_public_bridge = { path = "../rustc_public_bridge" }
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[dependencies.tikv-jemalloc-sys]
|
||||
|
|
|
|||
|
|
@ -334,6 +334,9 @@ pub enum AttributeKind {
|
|||
/// Represents `#[non_exhaustive]`
|
||||
NonExhaustive(Span),
|
||||
|
||||
/// Represents `#[omit_gdb_pretty_printer_section]`
|
||||
OmitGdbPrettyPrinterSection,
|
||||
|
||||
/// Represents `#[optimize(size|speed)]`
|
||||
Optimize(OptimizeAttr, Span),
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ impl AttributeKind {
|
|||
NoImplicitPrelude(..) => No,
|
||||
NoMangle(..) => No,
|
||||
NonExhaustive(..) => Yes,
|
||||
OmitGdbPrettyPrinterSection => No,
|
||||
Optimize(..) => No,
|
||||
ParenSugar(..) => No,
|
||||
PassByValue(..) => Yes,
|
||||
|
|
|
|||
|
|
@ -334,3 +334,11 @@ impl<S: Stage> CombineAttributeParser<S> for TargetFeatureParser {
|
|||
features
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct OmitGdbPrettyPrinterSectionParser;
|
||||
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for OmitGdbPrettyPrinterSectionParser {
|
||||
const PATH: &[Symbol] = &[sym::omit_gdb_pretty_printer_section];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
|
||||
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::OmitGdbPrettyPrinterSection;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol, sym};
|
|||
|
||||
use crate::attributes::allow_unstable::{AllowConstFnUnstableParser, AllowInternalUnstableParser};
|
||||
use crate::attributes::codegen_attrs::{
|
||||
ColdParser, ExportNameParser, NakedParser, NoMangleParser, OptimizeParser, TargetFeatureParser,
|
||||
TrackCallerParser, UsedParser,
|
||||
ColdParser, ExportNameParser, NakedParser, NoMangleParser, OmitGdbPrettyPrinterSectionParser,
|
||||
OptimizeParser, TargetFeatureParser, TrackCallerParser, UsedParser,
|
||||
};
|
||||
use crate::attributes::confusables::ConfusablesParser;
|
||||
use crate::attributes::deprecation::DeprecationParser;
|
||||
|
|
@ -175,6 +175,7 @@ attribute_parsers!(
|
|||
Single<WithoutArgs<NoImplicitPreludeParser>>,
|
||||
Single<WithoutArgs<NoMangleParser>>,
|
||||
Single<WithoutArgs<NonExhaustiveParser>>,
|
||||
Single<WithoutArgs<OmitGdbPrettyPrinterSectionParser>>,
|
||||
Single<WithoutArgs<ParenSugarParser>>,
|
||||
Single<WithoutArgs<PassByValueParser>>,
|
||||
Single<WithoutArgs<PubTransparentParser>>,
|
||||
|
|
|
|||
|
|
@ -159,6 +159,9 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
|
|||
}
|
||||
|
||||
GenericArgKind::Type(mut t1) => {
|
||||
// Scraped constraints may have had inference vars.
|
||||
t1 = self.infcx.resolve_vars_if_possible(t1);
|
||||
|
||||
// Normalize the type we receive from a `TypeOutlives` obligation
|
||||
// in the new trait solver.
|
||||
if infcx.next_trait_solver() {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
// .debug_gdb_scripts binary section.
|
||||
|
||||
use rustc_ast::attr;
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
use rustc_codegen_ssa::base::collect_debugger_visualizers_transitive;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerType;
|
||||
use rustc_session::config::{CrateType, DebugInfo};
|
||||
use rustc_span::sym;
|
||||
|
||||
use crate::builder::Builder;
|
||||
use crate::common::CodegenCx;
|
||||
|
|
@ -87,7 +86,7 @@ pub(crate) fn get_or_insert_gdb_debug_scripts_section_global<'ll>(
|
|||
|
||||
pub(crate) fn needs_gdb_debug_scripts_section(cx: &CodegenCx<'_, '_>) -> bool {
|
||||
let omit_gdb_pretty_printer_section =
|
||||
attr::contains_name(cx.tcx.hir_krate_attrs(), sym::omit_gdb_pretty_printer_section);
|
||||
find_attr!(cx.tcx.hir_krate_attrs(), AttributeKind::OmitGdbPrettyPrinterSection);
|
||||
|
||||
// To ensure the section `__rustc_debug_gdb_scripts_section__` will not create
|
||||
// ODR violations at link time, this section will not be emitted for rlibs since
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ rustc_parse = { path = "../rustc_parse" }
|
|||
rustc_passes = { path = "../rustc_passes" }
|
||||
rustc_pattern_analysis = { path = "../rustc_pattern_analysis" }
|
||||
rustc_privacy = { path = "../rustc_privacy" }
|
||||
rustc_public = { path = "../rustc_public", features = ["rustc_internal"] }
|
||||
rustc_query_system = { path = "../rustc_query_system" }
|
||||
rustc_resolve = { path = "../rustc_resolve" }
|
||||
rustc_session = { path = "../rustc_session" }
|
||||
|
|
@ -50,7 +51,6 @@ rustc_trait_selection = { path = "../rustc_trait_selection" }
|
|||
rustc_ty_utils = { path = "../rustc_ty_utils" }
|
||||
serde_json = "1.0.59"
|
||||
shlex = "1.0"
|
||||
stable_mir = { path = "../stable_mir", features = ["rustc_internal"] }
|
||||
tracing = { version = "0.1.35" }
|
||||
# tidy-alphabetical-end
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ use rustc_middle::bug;
|
|||
use rustc_middle::mir::{write_mir_graphviz, write_mir_pretty};
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_mir_build::thir::print::{thir_flat, thir_tree};
|
||||
use rustc_public::rustc_internal::pretty::write_smir_pretty;
|
||||
use rustc_session::Session;
|
||||
use rustc_session::config::{OutFileName, PpHirMode, PpMode, PpSourceMode};
|
||||
use rustc_span::{FileName, Ident};
|
||||
use stable_mir::rustc_internal::pretty::write_smir_pretty;
|
||||
use tracing::debug;
|
||||
use {rustc_ast as ast, rustc_hir_pretty as pprust_hir};
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ use std::iter;
|
|||
use rustc_index::{Idx, IndexVec};
|
||||
use rustc_middle::arena::ArenaAllocatable;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::mir::ConstraintCategory;
|
||||
use rustc_middle::ty::{self, BoundVar, GenericArg, GenericArgKind, Ty, TyCtxt, TypeFoldable};
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
|
|
@ -23,7 +22,9 @@ use crate::infer::canonical::{
|
|||
QueryRegionConstraints, QueryResponse,
|
||||
};
|
||||
use crate::infer::region_constraints::{Constraint, RegionConstraintData};
|
||||
use crate::infer::{DefineOpaqueTypes, InferCtxt, InferOk, InferResult, SubregionOrigin};
|
||||
use crate::infer::{
|
||||
DefineOpaqueTypes, InferCtxt, InferOk, InferResult, SubregionOrigin, TypeOutlivesConstraint,
|
||||
};
|
||||
use crate::traits::query::NoSolution;
|
||||
use crate::traits::{ObligationCause, PredicateObligations, ScrubbedTraitError, TraitEngine};
|
||||
|
||||
|
|
@ -117,13 +118,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
let region_obligations = self.take_registered_region_obligations();
|
||||
debug!(?region_obligations);
|
||||
let region_constraints = self.with_region_constraints(|region_constraints| {
|
||||
make_query_region_constraints(
|
||||
tcx,
|
||||
region_obligations
|
||||
.iter()
|
||||
.map(|r_o| (r_o.sup_type, r_o.sub_region, r_o.origin.to_constraint_category())),
|
||||
region_constraints,
|
||||
)
|
||||
make_query_region_constraints(tcx, region_obligations, region_constraints)
|
||||
});
|
||||
debug!(?region_constraints);
|
||||
|
||||
|
|
@ -570,7 +565,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
/// creates query region constraints.
|
||||
pub fn make_query_region_constraints<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
outlives_obligations: impl Iterator<Item = (Ty<'tcx>, ty::Region<'tcx>, ConstraintCategory<'tcx>)>,
|
||||
outlives_obligations: Vec<TypeOutlivesConstraint<'tcx>>,
|
||||
region_constraints: &RegionConstraintData<'tcx>,
|
||||
) -> QueryRegionConstraints<'tcx> {
|
||||
let RegionConstraintData { constraints, verifys } = region_constraints;
|
||||
|
|
@ -599,8 +594,11 @@ pub fn make_query_region_constraints<'tcx>(
|
|||
};
|
||||
(constraint, origin.to_constraint_category())
|
||||
})
|
||||
.chain(outlives_obligations.map(|(ty, r, constraint_category)| {
|
||||
(ty::OutlivesPredicate(ty.into(), r), constraint_category)
|
||||
.chain(outlives_obligations.into_iter().map(|obl| {
|
||||
(
|
||||
ty::OutlivesPredicate(obl.sup_type.into(), obl.sub_region),
|
||||
obl.origin.to_constraint_category(),
|
||||
)
|
||||
}))
|
||||
.collect();
|
||||
|
||||
|
|
|
|||
|
|
@ -166,6 +166,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
|
||||
/// Trait queries just want to pass back type obligations "as is"
|
||||
pub fn take_registered_region_obligations(&self) -> Vec<TypeOutlivesConstraint<'tcx>> {
|
||||
assert!(!self.in_snapshot(), "cannot take registered region obligations in a snapshot");
|
||||
std::mem::take(&mut self.inner.borrow_mut().region_obligations)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use std::assert_matches::assert_matches;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use rustc_data_structures::undo_log::{Rollback, UndoLogs};
|
||||
|
|
@ -73,7 +74,8 @@ impl<'tcx> Rollback<UndoLog<'tcx>> for InferCtxtInner<'tcx> {
|
|||
}
|
||||
UndoLog::ProjectionCache(undo) => self.projection_cache.reverse(undo),
|
||||
UndoLog::PushTypeOutlivesConstraint => {
|
||||
self.region_obligations.pop();
|
||||
let popped = self.region_obligations.pop();
|
||||
assert_matches!(popped, Some(_), "pushed region constraint but could not pop it");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -305,6 +305,7 @@ pub fn check_builtin_meta_item(
|
|||
| sym::naked
|
||||
| sym::no_mangle
|
||||
| sym::non_exhaustive
|
||||
| sym::omit_gdb_pretty_printer_section
|
||||
| sym::path
|
||||
| sym::ignore
|
||||
| sym::must_use
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@ passes_align_attr_application =
|
|||
`#[align(...)]` should be applied to a function item
|
||||
.label = not a function item
|
||||
|
||||
passes_align_on_fields =
|
||||
attribute should be applied to a function or method
|
||||
.warn = {-passes_previously_accepted}
|
||||
|
||||
passes_align_should_be_repr_align =
|
||||
`#[align(...)]` is not supported on {$item} items
|
||||
.suggestion = use `#[repr(align(...))]` instead
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ use rustc_trait_selection::infer::{TyCtxtInferExt, ValuePairs};
|
|||
use rustc_trait_selection::traits::ObligationCtxt;
|
||||
use tracing::debug;
|
||||
|
||||
use crate::errors::AlignOnFields;
|
||||
use crate::{errors, fluent_generated as fluent};
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
|
|
@ -207,8 +208,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
Attribute::Parsed(AttributeKind::ExportName { span: attr_span, .. }) => {
|
||||
self.check_export_name(hir_id, *attr_span, span, target)
|
||||
}
|
||||
Attribute::Parsed(AttributeKind::Align { align, span: repr_span }) => {
|
||||
self.check_align(span, target, *align, *repr_span)
|
||||
Attribute::Parsed(AttributeKind::Align { align, span: attr_span }) => {
|
||||
self.check_align(span, hir_id, target, *align, *attr_span)
|
||||
}
|
||||
Attribute::Parsed(AttributeKind::LinkSection { span: attr_span, .. }) => {
|
||||
self.check_link_section(hir_id, *attr_span, span, target)
|
||||
|
|
@ -250,7 +251,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
AttributeKind::BodyStability { .. }
|
||||
| AttributeKind::ConstStabilityIndirect
|
||||
| AttributeKind::MacroTransparency(_)
|
||||
| AttributeKind::Dummy,
|
||||
| AttributeKind::Dummy
|
||||
| AttributeKind::OmitGdbPrettyPrinterSection,
|
||||
) => { /* do nothing */ }
|
||||
Attribute::Parsed(AttributeKind::AsPtr(attr_span)) => {
|
||||
self.check_applied_to_fn_or_method(hir_id, *attr_span, span, target)
|
||||
|
|
@ -380,7 +382,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
// need to be fixed
|
||||
| sym::cfi_encoding // FIXME(cfi_encoding)
|
||||
| sym::pointee // FIXME(derive_coerce_pointee)
|
||||
| sym::omit_gdb_pretty_printer_section // FIXME(omit_gdb_pretty_printer_section)
|
||||
| sym::instruction_set // broken on stable!!!
|
||||
| sym::windows_subsystem // broken on stable!!!
|
||||
| sym::patchable_function_entry // FIXME(patchable_function_entry)
|
||||
|
|
@ -1953,22 +1954,37 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
}
|
||||
|
||||
/// Checks if the `#[align]` attributes on `item` are valid.
|
||||
fn check_align(&self, span: Span, target: Target, align: Align, repr_span: Span) {
|
||||
fn check_align(
|
||||
&self,
|
||||
span: Span,
|
||||
hir_id: HirId,
|
||||
target: Target,
|
||||
align: Align,
|
||||
attr_span: Span,
|
||||
) {
|
||||
match target {
|
||||
Target::Fn | Target::Method(_) | Target::ForeignFn => {}
|
||||
Target::Field => {
|
||||
self.tcx.emit_node_span_lint(
|
||||
UNUSED_ATTRIBUTES,
|
||||
hir_id,
|
||||
attr_span,
|
||||
AlignOnFields { span },
|
||||
);
|
||||
}
|
||||
Target::Struct | Target::Union | Target::Enum => {
|
||||
self.dcx().emit_err(errors::AlignShouldBeReprAlign {
|
||||
span: repr_span,
|
||||
span: attr_span,
|
||||
item: target.name(),
|
||||
align_bytes: align.bytes(),
|
||||
});
|
||||
}
|
||||
_ => {
|
||||
self.dcx().emit_err(errors::AlignAttrApplication { hint_span: repr_span, span });
|
||||
self.dcx().emit_err(errors::AlignAttrApplication { hint_span: attr_span, span });
|
||||
}
|
||||
}
|
||||
|
||||
self.check_align_value(align, repr_span);
|
||||
self.check_align_value(align, attr_span);
|
||||
}
|
||||
|
||||
/// Checks if the `#[repr]` attributes on `item` are valid.
|
||||
|
|
|
|||
|
|
@ -604,6 +604,14 @@ pub(crate) struct NoMangle {
|
|||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(passes_align_on_fields)]
|
||||
#[warning]
|
||||
pub(crate) struct AlignOnFields {
|
||||
#[label]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(passes_repr_conflicting, code = E0566)]
|
||||
pub(crate) struct ReprConflicting {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "stable_mir"
|
||||
name = "rustc_public"
|
||||
version = "0.1.0-preview"
|
||||
edition = "2024"
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ edition = "2024"
|
|||
rustc_abi = { path = "../rustc_abi" }
|
||||
rustc_hir = { path = "../rustc_hir" }
|
||||
rustc_middle = { path = "../rustc_middle" }
|
||||
rustc_public_bridge = { path = "../rustc_public_bridge" }
|
||||
rustc_session = { path = "../rustc_session" }
|
||||
rustc_smir = { path = "../rustc_smir" }
|
||||
rustc_span = { path = "../rustc_span" }
|
||||
rustc_target = { path = "../rustc_target" }
|
||||
scoped-tls = "1.0"
|
||||
|
|
@ -2,14 +2,14 @@
|
|||
//!
|
||||
//! This module is responsible for constructing stable components.
|
||||
//! All operations requiring rustc queries must be delegated
|
||||
//! to `rustc_smir::alloc` to maintain stability guarantees.
|
||||
//! to `rustc_public_bridge::alloc` to maintain stability guarantees.
|
||||
|
||||
use rustc_abi::Align;
|
||||
use rustc_middle::mir::ConstValue;
|
||||
use rustc_middle::mir::interpret::AllocRange;
|
||||
use rustc_smir::bridge::SmirError;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
use rustc_smir::{Tables, alloc};
|
||||
use rustc_public_bridge::bridge::SmirError;
|
||||
use rustc_public_bridge::context::SmirCtxt;
|
||||
use rustc_public_bridge::{Tables, alloc};
|
||||
|
||||
use super::Error;
|
||||
use super::compiler_interface::BridgeTys;
|
||||
|
|
@ -59,7 +59,7 @@ pub(crate) fn try_new_allocation<'tcx>(
|
|||
}
|
||||
ConstValue::Indirect { alloc_id, offset } => {
|
||||
let alloc = alloc::try_new_indirect(alloc_id, cx);
|
||||
use rustc_smir::context::SmirAllocRange;
|
||||
use rustc_public_bridge::context::SmirAllocRange;
|
||||
Ok(allocation_filter(&alloc.0, cx.alloc_range(offset, layout.size), tables, cx))
|
||||
}
|
||||
}
|
||||
|
|
@ -6,8 +6,8 @@
|
|||
use std::cell::Cell;
|
||||
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
use rustc_smir::{Bridge, SmirContainer};
|
||||
use rustc_public_bridge::context::SmirCtxt;
|
||||
use rustc_public_bridge::{Bridge, SmirContainer};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::abi::{FnAbi, Layout, LayoutShape, ReprOptions};
|
||||
|
|
@ -68,7 +68,7 @@ impl Bridge for BridgeTys {
|
|||
|
||||
/// Stable public API for querying compiler information.
|
||||
///
|
||||
/// All queries are delegated to [`rustc_smir::context::SmirCtxt`] that provides
|
||||
/// All queries are delegated to [`rustc_public_bridge::context::SmirCtxt`] that provides
|
||||
/// similar APIs but based on internal rustc constructs.
|
||||
///
|
||||
/// Do not use this directly. This is currently used in the macro expansion.
|
||||
|
|
@ -567,7 +567,7 @@ impl<'tcx> SmirInterface for SmirContainer<'tcx, BridgeTys> {
|
|||
DefKind::Fn => ForeignItemKind::Fn(tables.fn_def(def_id)),
|
||||
DefKind::Static { .. } => ForeignItemKind::Static(tables.static_def(def_id)),
|
||||
DefKind::ForeignTy => {
|
||||
use rustc_smir::context::SmirTy;
|
||||
use rustc_public_bridge::context::SmirTy;
|
||||
ForeignItemKind::Type(tables.intern_ty(cx.new_foreign(def_id)))
|
||||
}
|
||||
def_kind => unreachable!("Unexpected kind for a foreign item: {:?}", def_kind),
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
use std::fmt::{Debug, Display, Formatter};
|
||||
use std::{fmt, io};
|
||||
|
||||
use rustc_smir::bridge::SmirError;
|
||||
use rustc_public_bridge::bridge::SmirError;
|
||||
|
||||
macro_rules! error {
|
||||
($fmt: literal $(,)?) => { Error(format!($fmt)) };
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
//! The WIP stable interface to rustc internals.
|
||||
//! The WIP public interface to rustc internals.
|
||||
//!
|
||||
//! For more information see <https://github.com/rust-lang/project-stable-mir>
|
||||
//!
|
||||
|
|
@ -22,9 +22,9 @@
|
|||
use std::fmt::Debug;
|
||||
use std::{fmt, io};
|
||||
|
||||
pub(crate) use rustc_smir::IndexedVal;
|
||||
use rustc_smir::Tables;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
pub(crate) use rustc_public_bridge::IndexedVal;
|
||||
use rustc_public_bridge::Tables;
|
||||
use rustc_public_bridge::context::SmirCtxt;
|
||||
/// Export the rustc_internal APIs. Note that this module has no stability
|
||||
/// guarantees and it is not taken into account for semver.
|
||||
#[cfg(feature = "rustc_internal")]
|
||||
|
|
@ -244,7 +244,7 @@ pub fn opaque<T: Debug>(value: &T) -> Opaque {
|
|||
|
||||
macro_rules! bridge_impl {
|
||||
($name: ident, $ty: ty) => {
|
||||
impl rustc_smir::bridge::$name<compiler_interface::BridgeTys> for $ty {
|
||||
impl rustc_public_bridge::bridge::$name<compiler_interface::BridgeTys> for $ty {
|
||||
fn new(def: crate::DefId) -> Self {
|
||||
Self(def)
|
||||
}
|
||||
|
|
@ -273,13 +273,15 @@ bridge_impl!(AssocDef, crate::ty::AssocDef);
|
|||
bridge_impl!(OpaqueDef, crate::ty::OpaqueDef);
|
||||
bridge_impl!(StaticDef, crate::mir::mono::StaticDef);
|
||||
|
||||
impl rustc_smir::bridge::Prov<compiler_interface::BridgeTys> for crate::ty::Prov {
|
||||
impl rustc_public_bridge::bridge::Prov<compiler_interface::BridgeTys> for crate::ty::Prov {
|
||||
fn new(aid: crate::mir::alloc::AllocId) -> Self {
|
||||
Self(aid)
|
||||
}
|
||||
}
|
||||
|
||||
impl rustc_smir::bridge::Allocation<compiler_interface::BridgeTys> for crate::ty::Allocation {
|
||||
impl rustc_public_bridge::bridge::Allocation<compiler_interface::BridgeTys>
|
||||
for crate::ty::Allocation
|
||||
{
|
||||
fn new<'tcx>(
|
||||
bytes: Vec<Option<u8>>,
|
||||
ptrs: Vec<(usize, rustc_middle::mir::interpret::AllocId)>,
|
||||
|
|
@ -674,7 +674,7 @@ pub enum AggregateKind {
|
|||
Tuple,
|
||||
Adt(AdtDef, VariantIdx, GenericArgs, Option<UserTypeAnnotationIndex>, Option<FieldIdx>),
|
||||
Closure(ClosureDef, GenericArgs),
|
||||
// FIXME(stable_mir): Movability here is redundant
|
||||
// FIXME(rustc_public): Movability here is redundant
|
||||
Coroutine(CoroutineDef, GenericArgs, Movability),
|
||||
CoroutineClosure(CoroutineClosureDef, GenericArgs),
|
||||
RawPtr(Ty, Mutability),
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
use std::fmt::{Debug, Formatter};
|
||||
use std::io;
|
||||
|
||||
use rustc_smir::bridge::SmirError;
|
||||
use rustc_public_bridge::bridge::SmirError;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::abi::FnAbi;
|
||||
|
|
@ -6,8 +6,8 @@
|
|||
use std::cell::{Cell, RefCell};
|
||||
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
use rustc_smir::{Bridge, SmirContainer, Tables};
|
||||
use rustc_public_bridge::context::SmirCtxt;
|
||||
use rustc_public_bridge::{Bridge, SmirContainer, Tables};
|
||||
use rustc_span::def_id::CrateNum;
|
||||
use scoped_tls::scoped_thread_local;
|
||||
|
||||
|
|
@ -105,11 +105,11 @@ where
|
|||
/// # extern crate rustc_interface;
|
||||
/// # extern crate rustc_middle;
|
||||
/// # #[macro_use]
|
||||
/// # extern crate stable_mir;
|
||||
/// # extern crate rustc_public;
|
||||
/// #
|
||||
/// # fn main() {
|
||||
/// # use std::ops::ControlFlow;
|
||||
/// # use stable_mir::CompilerError;
|
||||
/// # use rustc_public::CompilerError;
|
||||
/// fn analyze_code() -> ControlFlow<(), ()> {
|
||||
/// // Your code goes in here.
|
||||
/// # ControlFlow::Continue(())
|
||||
|
|
@ -125,11 +125,11 @@ where
|
|||
/// # extern crate rustc_interface;
|
||||
/// # extern crate rustc_middle;
|
||||
/// # #[macro_use]
|
||||
/// # extern crate stable_mir;
|
||||
/// # extern crate rustc_public;
|
||||
/// #
|
||||
/// # fn main() {
|
||||
/// # use std::ops::ControlFlow;
|
||||
/// # use stable_mir::CompilerError;
|
||||
/// # use rustc_public::CompilerError;
|
||||
/// fn analyze_code(extra_args: Vec<String>) -> ControlFlow<(), ()> {
|
||||
/// # let _ = extra_args;
|
||||
/// // Your code goes in here.
|
||||
|
|
@ -187,8 +187,8 @@ macro_rules! run_driver {
|
|||
use rustc_driver::{Callbacks, Compilation, run_compiler};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_interface::interface;
|
||||
use stable_mir::rustc_internal;
|
||||
use stable_mir::CompilerError;
|
||||
use rustc_public::rustc_internal;
|
||||
use rustc_public::CompilerError;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
pub struct StableMir<B = (), C = (), F = fn($(optional!($with_tcx TyCtxt))?) -> ControlFlow<B, C>>
|
||||
|
|
@ -560,7 +560,7 @@ pub enum RigidTy {
|
|||
FnDef(FnDef, GenericArgs),
|
||||
FnPtr(PolyFnSig),
|
||||
Closure(ClosureDef, GenericArgs),
|
||||
// FIXME(stable_mir): Movability here is redundant
|
||||
// FIXME(rustc_public): Movability here is redundant
|
||||
Coroutine(CoroutineDef, GenericArgs, Movability),
|
||||
CoroutineClosure(CoroutineClosureDef, GenericArgs),
|
||||
Dynamic(Vec<Binder<ExistentialPredicate>>, Region, DynKind),
|
||||
|
|
@ -3,10 +3,10 @@
|
|||
//! This module will only include a few constructs to allow users to invoke internal rustc APIs
|
||||
//! due to incomplete stable coverage.
|
||||
|
||||
// Prefer importing stable_mir over internal rustc constructs to make this file more readable.
|
||||
// Prefer importing rustc_public over internal rustc constructs to make this file more readable.
|
||||
|
||||
use rustc_middle::ty::{self as rustc_ty, Const as InternalConst, Ty as InternalTy};
|
||||
use rustc_smir::Tables;
|
||||
use rustc_public_bridge::Tables;
|
||||
|
||||
use crate::abi::Layout;
|
||||
use crate::compiler_interface::BridgeTys;
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
//! This module holds the logic to convert rustc internal ADTs into stable mir ADTs.
|
||||
//!
|
||||
//! The conversion from stable to internal is not meant to be complete,
|
||||
//! and it should be added as when needed to be passed as input to rustc_smir functions.
|
||||
//! and it should be added as when needed to be passed as input to rustc_public_bridge functions.
|
||||
//!
|
||||
//! For contributors, please make sure to avoid calling rustc's internal functions and queries.
|
||||
//! These should be done via `rustc_smir` APIs, but it's possible to access ADT fields directly.
|
||||
//! These should be done via `rustc_public_bridge` APIs, but it's possible to access ADT fields directly.
|
||||
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
use rustc_smir::Tables;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
use rustc_public_bridge::Tables;
|
||||
use rustc_public_bridge::context::SmirCtxt;
|
||||
|
||||
use super::Stable;
|
||||
use crate::compiler_interface::BridgeTys;
|
||||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
use rustc_abi::{ArmCall, CanonAbi, InterruptKind, X86Call};
|
||||
use rustc_middle::ty;
|
||||
use rustc_smir::Tables;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
use rustc_public_bridge::Tables;
|
||||
use rustc_public_bridge::context::SmirCtxt;
|
||||
use rustc_target::callconv;
|
||||
|
||||
use crate::abi::{
|
||||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
use rustc_middle::mir::mono::MonoItem;
|
||||
use rustc_middle::{bug, mir};
|
||||
use rustc_smir::Tables;
|
||||
use rustc_smir::bridge::SmirError;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
use rustc_public_bridge::Tables;
|
||||
use rustc_public_bridge::bridge::SmirError;
|
||||
use rustc_public_bridge::context::SmirCtxt;
|
||||
|
||||
use crate::compiler_interface::BridgeTys;
|
||||
use crate::mir::alloc::GlobalAlloc;
|
||||
|
|
@ -821,7 +821,7 @@ impl<'tcx> Stable<'tcx> for mir::interpret::Allocation {
|
|||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use rustc_smir::context::SmirAllocRange;
|
||||
use rustc_public_bridge::context::SmirAllocRange;
|
||||
alloc::allocation_filter(
|
||||
self,
|
||||
cx.alloc_range(rustc_abi::Size::ZERO, self.size()),
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
//! Conversion of internal Rust compiler items to stable ones.
|
||||
|
||||
use rustc_abi::FieldIdx;
|
||||
use rustc_smir::Tables;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
use rustc_public_bridge::Tables;
|
||||
use rustc_public_bridge::context::SmirCtxt;
|
||||
|
||||
use super::Stable;
|
||||
use crate::compiler_interface::BridgeTys;
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_middle::{bug, mir, ty};
|
||||
use rustc_smir::Tables;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
use rustc_public_bridge::Tables;
|
||||
use rustc_public_bridge::context::SmirCtxt;
|
||||
|
||||
use crate::alloc;
|
||||
use crate::compiler_interface::BridgeTys;
|
||||
|
|
@ -9,8 +9,8 @@ use std::marker::PointeeSized;
|
|||
use rustc_hir::def::DefKind;
|
||||
use rustc_middle::ty::{List, Ty, TyCtxt};
|
||||
use rustc_middle::{mir, ty};
|
||||
use rustc_smir::Tables;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
use rustc_public_bridge::Tables;
|
||||
use rustc_public_bridge::context::SmirCtxt;
|
||||
|
||||
use super::compiler_interface::BridgeTys;
|
||||
use crate::{CtorKind, ItemKind};
|
||||
|
|
@ -21,7 +21,7 @@ mod internal_cx;
|
|||
/// Trait that defines the methods that are fine to call from [`RustcInternal`].
|
||||
///
|
||||
/// This trait is only for [`RustcInternal`]. Any other other access to rustc's internals
|
||||
/// should go through [`rustc_smir::context::SmirCtxt`].
|
||||
/// should go through [`rustc_public_bridge::context::SmirCtxt`].
|
||||
pub trait InternalCx<'tcx>: Copy + Clone {
|
||||
fn tcx(self) -> TyCtxt<'tcx>;
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "rustc_smir"
|
||||
name = "rustc_public_bridge"
|
||||
version = "0.0.0"
|
||||
edition = "2024"
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
//! Internal memory allocator implementation for StableMIR.
|
||||
//!
|
||||
//! This module handles all direct interactions with rustc queries and performs
|
||||
//! the actual memory allocations. The stable interface in `stable_mir::alloc`
|
||||
//! the actual memory allocations. The stable interface in `rustc_public::alloc`
|
||||
//! delegates all query-related operations to this implementation.
|
||||
|
||||
use rustc_abi::{Size, TyAndLayout};
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
//! Defines a set of traits that is used for abstracting
|
||||
//! stable_mir's components that are needed in rustc_smir.
|
||||
//! rustc_public's components that are needed in rustc_public_bridge.
|
||||
//!
|
||||
//! These traits are really useful when programming
|
||||
//! in stable_mir-agnostic settings.
|
||||
//! in rustc_public-agnostic settings.
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
//! This crate is responsible for building Stable MIR components from internal components.
|
||||
//!
|
||||
//! This crate is not intended to be invoked directly by users.
|
||||
//! This crate is the public API of rustc that will be invoked by the `stable_mir` crate.
|
||||
//! This crate is the public API of rustc that will be invoked by the `rustc_public` crate.
|
||||
//!
|
||||
//! For more information see <https://github.com/rust-lang/project-stable-mir>
|
||||
//!
|
||||
|
|
@ -42,7 +42,7 @@ pub mod bridge;
|
|||
mod builder;
|
||||
pub mod context;
|
||||
|
||||
#[deprecated(note = "please use `stable_mir::rustc_internal` instead")]
|
||||
#[deprecated(note = "please use `rustc_public::rustc_internal` instead")]
|
||||
pub mod rustc_internal {}
|
||||
|
||||
/// A container which is used for TLS.
|
||||
|
|
@ -211,7 +211,7 @@ impl<'tcx, B: Bridge> Tables<'tcx, B> {
|
|||
}
|
||||
|
||||
/// A trait defining types that are used to emulate StableMIR components, which is really
|
||||
/// useful when programming in stable_mir-agnostic settings.
|
||||
/// useful when programming in rustc_public-agnostic settings.
|
||||
pub trait Bridge: Sized {
|
||||
type DefId: Copy + Debug + PartialEq + IndexedVal;
|
||||
type AllocId: Copy + Debug + PartialEq + IndexedVal;
|
||||
|
|
@ -213,13 +213,7 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
|
|||
// inside of a `probe` whenever we have multiple choices inside of the solver.
|
||||
let region_obligations = self.0.inner.borrow().region_obligations().to_owned();
|
||||
let region_constraints = self.0.with_region_constraints(|region_constraints| {
|
||||
make_query_region_constraints(
|
||||
self.tcx,
|
||||
region_obligations
|
||||
.iter()
|
||||
.map(|r_o| (r_o.sup_type, r_o.sub_region, r_o.origin.to_constraint_category())),
|
||||
region_constraints,
|
||||
)
|
||||
make_query_region_constraints(self.tcx, region_obligations, region_constraints)
|
||||
});
|
||||
|
||||
let mut seen = FxHashSet::default();
|
||||
|
|
|
|||
|
|
@ -103,10 +103,7 @@ where
|
|||
let region_constraint_data = infcx.take_and_reset_region_constraints();
|
||||
let region_constraints = query_response::make_query_region_constraints(
|
||||
infcx.tcx,
|
||||
region_obligations
|
||||
.iter()
|
||||
.map(|r_o| (r_o.sup_type, r_o.sub_region, r_o.origin.to_constraint_category()))
|
||||
.map(|(ty, r, cc)| (infcx.resolve_vars_if_possible(ty), r, cc)),
|
||||
region_obligations,
|
||||
®ion_constraint_data,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -1081,13 +1081,11 @@ mod prim_str {}
|
|||
/// * [`Debug`]
|
||||
/// * [`Default`]
|
||||
/// * [`Hash`]
|
||||
/// * [`Random`]
|
||||
/// * [`From<[T; N]>`][from]
|
||||
///
|
||||
/// [from]: convert::From
|
||||
/// [`Debug`]: fmt::Debug
|
||||
/// [`Hash`]: hash::Hash
|
||||
/// [`Random`]: random::Random
|
||||
///
|
||||
/// The following traits are implemented for tuples of any length. These traits have
|
||||
/// implementations that are automatically generated by the compiler, so are not limited by
|
||||
|
|
|
|||
|
|
@ -1,48 +1,46 @@
|
|||
//! Random value generation.
|
||||
//!
|
||||
//! The [`Random`] trait allows generating a random value for a type using a
|
||||
//! given [`RandomSource`].
|
||||
|
||||
use crate::range::RangeFull;
|
||||
|
||||
/// A source of randomness.
|
||||
#[unstable(feature = "random", issue = "130703")]
|
||||
pub trait RandomSource {
|
||||
/// Fills `bytes` with random bytes.
|
||||
///
|
||||
/// Note that calling `fill_bytes` multiple times is not equivalent to calling `fill_bytes` once
|
||||
/// with a larger buffer. A `RandomSource` is allowed to return different bytes for those two
|
||||
/// cases. For instance, this allows a `RandomSource` to generate a word at a time and throw
|
||||
/// part of it away if not needed.
|
||||
fn fill_bytes(&mut self, bytes: &mut [u8]);
|
||||
}
|
||||
|
||||
/// A trait for getting a random value for a type.
|
||||
///
|
||||
/// **Warning:** Be careful when manipulating random values! The
|
||||
/// [`random`](Random::random) method on integers samples them with a uniform
|
||||
/// distribution, so a value of 1 is just as likely as [`i32::MAX`]. By using
|
||||
/// modulo operations, some of the resulting values can become more likely than
|
||||
/// others. Use audited crates when in doubt.
|
||||
/// A trait representing a distribution of random values for a type.
|
||||
#[unstable(feature = "random", issue = "130703")]
|
||||
pub trait Random: Sized {
|
||||
/// Generates a random value.
|
||||
fn random(source: &mut (impl RandomSource + ?Sized)) -> Self;
|
||||
pub trait Distribution<T> {
|
||||
/// Samples a random value from the distribution, using the specified random source.
|
||||
fn sample(&self, source: &mut (impl RandomSource + ?Sized)) -> T;
|
||||
}
|
||||
|
||||
impl Random for bool {
|
||||
fn random(source: &mut (impl RandomSource + ?Sized)) -> Self {
|
||||
u8::random(source) & 1 == 1
|
||||
impl<T, DT: Distribution<T>> Distribution<T> for &DT {
|
||||
fn sample(&self, source: &mut (impl RandomSource + ?Sized)) -> T {
|
||||
(*self).sample(source)
|
||||
}
|
||||
}
|
||||
|
||||
impl Distribution<bool> for RangeFull {
|
||||
fn sample(&self, source: &mut (impl RandomSource + ?Sized)) -> bool {
|
||||
let byte: u8 = RangeFull.sample(source);
|
||||
byte & 1 == 1
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! impl_primitive {
|
||||
($t:ty) => {
|
||||
impl Random for $t {
|
||||
/// Generates a random value.
|
||||
///
|
||||
/// **Warning:** Be careful when manipulating the resulting value! This
|
||||
/// method samples according to a uniform distribution, so a value of 1 is
|
||||
/// just as likely as [`MAX`](Self::MAX). By using modulo operations, some
|
||||
/// values can become more likely than others. Use audited crates when in
|
||||
/// doubt.
|
||||
fn random(source: &mut (impl RandomSource + ?Sized)) -> Self {
|
||||
let mut bytes = (0 as Self).to_ne_bytes();
|
||||
impl Distribution<$t> for RangeFull {
|
||||
fn sample(&self, source: &mut (impl RandomSource + ?Sized)) -> $t {
|
||||
let mut bytes = (0 as $t).to_ne_bytes();
|
||||
source.fill_bytes(&mut bytes);
|
||||
Self::from_ne_bytes(bytes)
|
||||
<$t>::from_ne_bytes(bytes)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
use crate::cmp::Ordering::{self, *};
|
||||
use crate::marker::{ConstParamTy_, StructuralPartialEq, UnsizedConstParamTy};
|
||||
use crate::ops::ControlFlow::{self, Break, Continue};
|
||||
use crate::random::{Random, RandomSource};
|
||||
|
||||
// Recursive macro for implementing n-ary tuple functions and operations
|
||||
//
|
||||
|
|
@ -131,16 +130,6 @@ macro_rules! tuple_impls {
|
|||
}
|
||||
}
|
||||
|
||||
maybe_tuple_doc! {
|
||||
$($T)+ @
|
||||
#[unstable(feature = "random", issue = "130703")]
|
||||
impl<$($T: Random),+> Random for ($($T,)+) {
|
||||
fn random(source: &mut (impl RandomSource + ?Sized)) -> Self {
|
||||
($({ let x: $T = Random::random(source); x},)+)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
maybe_tuple_doc! {
|
||||
$($T)+ @
|
||||
#[stable(feature = "array_tuple_conv", since = "1.71.0")]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
//! Random value generation.
|
||||
//!
|
||||
//! The [`Random`] trait allows generating a random value for a type using a
|
||||
//! given [`RandomSource`].
|
||||
|
||||
#[unstable(feature = "random", issue = "130703")]
|
||||
pub use core::random::*;
|
||||
|
|
@ -68,18 +65,11 @@ impl RandomSource for DefaultRandomSource {
|
|||
}
|
||||
}
|
||||
|
||||
/// Generates a random value with the default random source.
|
||||
/// Generates a random value from a distribution, using the default random source.
|
||||
///
|
||||
/// This is a convenience function for `T::random(&mut DefaultRandomSource)` and
|
||||
/// will sample according to the same distribution as the underlying [`Random`]
|
||||
/// trait implementation. See [`DefaultRandomSource`] for more information about
|
||||
/// how randomness is sourced.
|
||||
///
|
||||
/// **Warning:** Be careful when manipulating random values! The
|
||||
/// [`random`](Random::random) method on integers samples them with a uniform
|
||||
/// distribution, so a value of 1 is just as likely as [`i32::MAX`]. By using
|
||||
/// modulo operations, some of the resulting values can become more likely than
|
||||
/// others. Use audited crates when in doubt.
|
||||
/// This is a convenience function for `dist.sample(&mut DefaultRandomSource)` and will sample
|
||||
/// according to the same distribution as the underlying [`Distribution`] trait implementation. See
|
||||
/// [`DefaultRandomSource`] for more information about how randomness is sourced.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
@ -89,7 +79,7 @@ impl RandomSource for DefaultRandomSource {
|
|||
///
|
||||
/// use std::random::random;
|
||||
///
|
||||
/// let bits: u128 = random();
|
||||
/// let bits: u128 = random(..);
|
||||
/// let g1 = (bits >> 96) as u32;
|
||||
/// let g2 = (bits >> 80) as u16;
|
||||
/// let g3 = (0x4000 | (bits >> 64) & 0x0fff) as u16;
|
||||
|
|
@ -101,6 +91,6 @@ impl RandomSource for DefaultRandomSource {
|
|||
///
|
||||
/// [version 4/variant 1 UUID]: https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)
|
||||
#[unstable(feature = "random", issue = "130703")]
|
||||
pub fn random<T: Random>() -> T {
|
||||
T::random(&mut DefaultRandomSource)
|
||||
pub fn random<T>(dist: impl Distribution<T>) -> T {
|
||||
dist.sample(&mut DefaultRandomSource)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ use crate::net::{Shutdown, SocketAddr};
|
|||
use crate::os::windows::io::{
|
||||
AsRawSocket, AsSocket, BorrowedSocket, FromRawSocket, IntoRawSocket, OwnedSocket, RawSocket,
|
||||
};
|
||||
use crate::sync::OnceLock;
|
||||
use crate::sync::atomic::Atomic;
|
||||
use crate::sync::atomic::Ordering::{AcqRel, Relaxed};
|
||||
use crate::sys::c;
|
||||
use crate::sys_common::{AsInner, FromInner, IntoInner};
|
||||
use crate::time::Duration;
|
||||
|
|
@ -114,33 +115,38 @@ pub(super) mod netc {
|
|||
#[expect(missing_debug_implementations)]
|
||||
pub struct Socket(OwnedSocket);
|
||||
|
||||
static WSA_CLEANUP: OnceLock<unsafe extern "system" fn() -> i32> = OnceLock::new();
|
||||
static WSA_INITIALIZED: Atomic<bool> = Atomic::<bool>::new(false);
|
||||
|
||||
/// Checks whether the Windows socket interface has been started already, and
|
||||
/// if not, starts it.
|
||||
#[inline]
|
||||
pub fn init() {
|
||||
let _ = WSA_CLEANUP.get_or_init(|| unsafe {
|
||||
if !WSA_INITIALIZED.load(Relaxed) {
|
||||
wsa_startup();
|
||||
}
|
||||
}
|
||||
|
||||
#[cold]
|
||||
fn wsa_startup() {
|
||||
unsafe {
|
||||
let mut data: c::WSADATA = mem::zeroed();
|
||||
let ret = c::WSAStartup(
|
||||
0x202, // version 2.2
|
||||
&mut data,
|
||||
);
|
||||
assert_eq!(ret, 0);
|
||||
|
||||
// Only register `WSACleanup` if `WSAStartup` is actually ever called.
|
||||
// Workaround to prevent linking to `WS2_32.dll` when no network functionality is used.
|
||||
// See issue #85441.
|
||||
c::WSACleanup
|
||||
});
|
||||
if WSA_INITIALIZED.swap(true, AcqRel) {
|
||||
// If another thread raced with us and called WSAStartup first then call
|
||||
// WSACleanup so it's as though WSAStartup was only called once.
|
||||
c::WSACleanup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cleanup() {
|
||||
// only perform cleanup if network functionality was actually initialized
|
||||
if let Some(cleanup) = WSA_CLEANUP.get() {
|
||||
unsafe {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
// We don't need to call WSACleanup here because exiting the process will cause
|
||||
// the OS to clean everything for us, which is faster than doing it manually.
|
||||
// See #141799.
|
||||
}
|
||||
|
||||
/// Returns the last error from the Windows socket interface.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use crate::cmp;
|
|||
use crate::io::{
|
||||
BorrowedCursor, Error as IoError, ErrorKind, IoSlice, IoSliceMut, Result as IoResult,
|
||||
};
|
||||
use crate::random::{DefaultRandomSource, Random};
|
||||
use crate::random::random;
|
||||
use crate::time::{Duration, Instant};
|
||||
|
||||
pub(crate) mod alloc;
|
||||
|
|
@ -179,7 +179,7 @@ pub fn wait(event_mask: u64, mut timeout: u64) -> IoResult<u64> {
|
|||
// trusted to ensure accurate timeouts.
|
||||
if let Ok(timeout_signed) = i64::try_from(timeout) {
|
||||
let tenth = timeout_signed / 10;
|
||||
let deviation = i64::random(&mut DefaultRandomSource).checked_rem(tenth).unwrap_or(0);
|
||||
let deviation = random::<i64>(..).checked_rem(tenth).unwrap_or(0);
|
||||
timeout = timeout_signed.saturating_add(deviation) as _;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2400,10 +2400,10 @@ pub fn run_cargo(
|
|||
keep = true;
|
||||
} else if rlib_only_metadata {
|
||||
if filename.contains("jemalloc_sys")
|
||||
|| filename.contains("rustc_smir")
|
||||
|| filename.contains("stable_mir")
|
||||
|| filename.contains("rustc_public_bridge")
|
||||
|| filename.contains("rustc_public")
|
||||
{
|
||||
// jemalloc_sys and rustc_smir are not linked into librustc_driver.so,
|
||||
// jemalloc_sys and rustc_public_bridge are not linked into librustc_driver.so,
|
||||
// so we need to distribute them as rlib to be able to use them.
|
||||
keep |= filename.ends_with(".rlib");
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -53,6 +53,32 @@ impl TestMode {
|
|||
}
|
||||
}
|
||||
|
||||
// Note that coverage tests use the same test files for multiple test modes.
|
||||
string_enum! {
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
pub enum TestSuite {
|
||||
Assembly => "assembly",
|
||||
Codegen => "codegen",
|
||||
CodegenUnits => "codegen-units",
|
||||
Coverage => "coverage",
|
||||
CoverageRunRustdoc => "coverage-run-rustdoc",
|
||||
Crashes => "crashes",
|
||||
Debuginfo => "debuginfo",
|
||||
Incremental => "incremental",
|
||||
MirOpt => "mir-opt",
|
||||
Pretty => "pretty",
|
||||
RunMake => "run-make",
|
||||
Rustdoc => "rustdoc",
|
||||
RustdocGui => "rustdoc-gui",
|
||||
RustdocJs => "rustdoc-js",
|
||||
RustdocJsStd=> "rustdoc-js-std",
|
||||
RustdocJson => "rustdoc-json",
|
||||
RustdocUi => "rustdoc-ui",
|
||||
Ui => "ui",
|
||||
UiFullDeps => "ui-fulldeps",
|
||||
}
|
||||
}
|
||||
|
||||
string_enum! {
|
||||
#[derive(Clone, Copy, PartialEq, Debug, Hash)]
|
||||
pub enum PassMode {
|
||||
|
|
@ -276,15 +302,13 @@ pub struct Config {
|
|||
|
||||
/// The test suite.
|
||||
///
|
||||
/// Example: `tests/ui/` is the "UI" test *suite*, which happens to also be of the
|
||||
/// Example: `tests/ui/` is [`TestSuite::Ui`] test *suite*, which happens to also be of the
|
||||
/// [`TestMode::Ui`] test *mode*.
|
||||
///
|
||||
/// Note that the same test directory (e.g. `tests/coverage/`) may correspond to multiple test
|
||||
/// Note that the same test suite (e.g. `tests/coverage/`) may correspond to multiple test
|
||||
/// modes, e.g. `tests/coverage/` can be run under both [`TestMode::CoverageRun`] and
|
||||
/// [`TestMode::CoverageMap`].
|
||||
///
|
||||
/// FIXME: stop using stringly-typed test suites!
|
||||
pub suite: String,
|
||||
pub suite: TestSuite,
|
||||
|
||||
/// When specified, **only** the specified [`Debugger`] will be used to run against the
|
||||
/// `tests/debuginfo` test suite. When unspecified, `compiletest` will attempt to find all three
|
||||
|
|
@ -537,8 +561,8 @@ pub struct Config {
|
|||
// Configuration for various run-make tests frobbing things like C compilers or querying about
|
||||
// various LLVM component information.
|
||||
//
|
||||
// FIXME: this really should be better packaged together. FIXME: these need better docs, e.g.
|
||||
// for *host*, or for *target*?
|
||||
// FIXME: this really should be better packaged together.
|
||||
// FIXME: these need better docs, e.g. for *host*, or for *target*?
|
||||
pub cc: String,
|
||||
pub cxx: String,
|
||||
pub cflags: String,
|
||||
|
|
@ -617,6 +641,8 @@ impl Config {
|
|||
// For instance, `//@ ignore-stage1` will not work at all.
|
||||
Config {
|
||||
mode: TestMode::Rustdoc,
|
||||
// E.g. this has no sensible default tbh.
|
||||
suite: TestSuite::Ui,
|
||||
|
||||
// Dummy values.
|
||||
edition: Default::default(),
|
||||
|
|
@ -642,7 +668,6 @@ impl Config {
|
|||
sysroot_base: Utf8PathBuf::default(),
|
||||
stage: Default::default(),
|
||||
stage_id: String::default(),
|
||||
suite: Default::default(),
|
||||
debugger: Default::default(),
|
||||
run_ignored: Default::default(),
|
||||
with_rustc_debug_assertions: Default::default(),
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ impl EarlyProps {
|
|||
let mut poisoned = false;
|
||||
iter_directives(
|
||||
config.mode,
|
||||
&config.suite,
|
||||
&mut poisoned,
|
||||
testfile,
|
||||
rdr,
|
||||
|
|
@ -349,7 +348,6 @@ impl TestProps {
|
|||
|
||||
iter_directives(
|
||||
config.mode,
|
||||
&config.suite,
|
||||
&mut poisoned,
|
||||
testfile,
|
||||
file,
|
||||
|
|
@ -1115,7 +1113,6 @@ const COMPILETEST_DIRECTIVE_PREFIX: &str = "//@";
|
|||
|
||||
fn iter_directives(
|
||||
mode: TestMode,
|
||||
_suite: &str,
|
||||
poisoned: &mut bool,
|
||||
testfile: &Utf8Path,
|
||||
rdr: impl Read,
|
||||
|
|
@ -1634,7 +1631,6 @@ pub(crate) fn make_test_description<R: Read>(
|
|||
// Scan through the test file to handle `ignore-*`, `only-*`, and `needs-*` directives.
|
||||
iter_directives(
|
||||
config.mode,
|
||||
&config.suite,
|
||||
&mut local_poisoned,
|
||||
path,
|
||||
src,
|
||||
|
|
|
|||
|
|
@ -785,7 +785,7 @@ fn threads_support() {
|
|||
|
||||
fn run_path(poisoned: &mut bool, path: &Utf8Path, buf: &[u8]) {
|
||||
let rdr = std::io::Cursor::new(&buf);
|
||||
iter_directives(TestMode::Ui, "ui", poisoned, path, rdr, &mut |_| {});
|
||||
iter_directives(TestMode::Ui, poisoned, path, rdr, &mut |_| {});
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -360,7 +360,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
|||
stage_id: matches.opt_str("stage-id").unwrap(),
|
||||
|
||||
mode,
|
||||
suite: matches.opt_str("suite").unwrap(),
|
||||
suite: matches.opt_str("suite").unwrap().parse().expect("invalid suite"),
|
||||
debugger: matches.opt_str("debugger").map(|debugger| {
|
||||
debugger
|
||||
.parse::<Debugger>()
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ use regex::{Captures, Regex};
|
|||
use tracing::*;
|
||||
|
||||
use crate::common::{
|
||||
CompareMode, Config, Debugger, FailMode, PassMode, TestMode, TestPaths, UI_EXTENSIONS,
|
||||
UI_FIXED, UI_RUN_STDERR, UI_RUN_STDOUT, UI_STDERR, UI_STDOUT, UI_SVG, UI_WINDOWS_SVG,
|
||||
expected_output_path, incremental_dir, output_base_dir, output_base_name,
|
||||
CompareMode, Config, Debugger, FailMode, PassMode, TestMode, TestPaths, TestSuite,
|
||||
UI_EXTENSIONS, UI_FIXED, UI_RUN_STDERR, UI_RUN_STDOUT, UI_STDERR, UI_STDOUT, UI_SVG,
|
||||
UI_WINDOWS_SVG, expected_output_path, incremental_dir, output_base_dir, output_base_name,
|
||||
output_testname_unique,
|
||||
};
|
||||
use crate::compute_diff::{DiffLine, make_diff, write_diff, write_filtered_diff};
|
||||
|
|
@ -1494,7 +1494,10 @@ impl<'test> TestCx<'test> {
|
|||
}
|
||||
|
||||
fn is_rustdoc(&self) -> bool {
|
||||
matches!(self.config.suite.as_str(), "rustdoc-ui" | "rustdoc-js" | "rustdoc-json")
|
||||
matches!(
|
||||
self.config.suite,
|
||||
TestSuite::RustdocUi | TestSuite::RustdocJs | TestSuite::RustdocJson
|
||||
)
|
||||
}
|
||||
|
||||
fn make_compile_args(
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use std::process::Command;
|
|||
use camino::{Utf8Path, Utf8PathBuf};
|
||||
use glob::glob;
|
||||
|
||||
use crate::common::{UI_COVERAGE, UI_COVERAGE_MAP};
|
||||
use crate::common::{TestSuite, UI_COVERAGE, UI_COVERAGE_MAP};
|
||||
use crate::runtest::{Emit, ProcRes, TestCx, WillExecute};
|
||||
use crate::util::static_regex;
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ impl<'test> TestCx<'test> {
|
|||
let mut profraw_paths = vec![profraw_path];
|
||||
let mut bin_paths = vec![self.make_exe_name()];
|
||||
|
||||
if self.config.suite == "coverage-run-rustdoc" {
|
||||
if self.config.suite == TestSuite::CoverageRunRustdoc {
|
||||
self.run_doctests_for_coverage(&mut profraw_paths, &mut bin_paths);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(random)]
|
||||
|
||||
fn main() {
|
||||
let _x: i32 = std::random::random();
|
||||
let _x: i32 = std::random::random(..);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
The goal of this directory is to track the quality of MIR that is given to codegen in a standard `-O` condiguration.
|
||||
The goal of this directory is to track the quality of MIR that is given to codegen in a standard `-O` configuration.
|
||||
|
||||
As such, feel free to `--bless` whatever changes you get here, so long as doing so doesn't add substantially more MIR.
|
||||
|
|
|
|||
|
|
@ -14,17 +14,17 @@ extern crate rustc_middle;
|
|||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use stable_mir::abi::{
|
||||
use rustc_public::abi::{
|
||||
ArgAbi, CallConvention, FieldsShape, IntegerLength, PassMode, Primitive, Scalar, ValueAbi,
|
||||
VariantsShape,
|
||||
};
|
||||
use stable_mir::mir::MirVisitor;
|
||||
use stable_mir::mir::mono::Instance;
|
||||
use stable_mir::target::MachineInfo;
|
||||
use stable_mir::ty::{AdtDef, RigidTy, Ty, TyKind};
|
||||
use stable_mir::{CrateDef, CrateItem, CrateItems, ItemKind};
|
||||
use rustc_public::mir::MirVisitor;
|
||||
use rustc_public::mir::mono::Instance;
|
||||
use rustc_public::target::MachineInfo;
|
||||
use rustc_public::ty::{AdtDef, RigidTy, Ty, TyKind};
|
||||
use rustc_public::{CrateDef, CrateItem, CrateItems, ItemKind};
|
||||
use std::assert_matches::assert_matches;
|
||||
use std::collections::HashSet;
|
||||
use std::convert::TryFrom;
|
||||
|
|
@ -36,7 +36,7 @@ const CRATE_NAME: &str = "input";
|
|||
/// This function uses the Stable MIR APIs to get information about the test crate.
|
||||
fn test_stable_mir() -> ControlFlow<()> {
|
||||
// Find items in the local crate.
|
||||
let items = stable_mir::all_local_items();
|
||||
let items = rustc_public::all_local_items();
|
||||
|
||||
// Test fn_abi
|
||||
let target_fn = *get_item(&items, (ItemKind::Fn, "fn_abi")).unwrap();
|
||||
|
|
@ -69,7 +69,7 @@ fn test_stable_mir() -> ControlFlow<()> {
|
|||
assert!(ptr_variadic_fn_abi.c_variadic);
|
||||
assert_eq!(ptr_variadic_fn_abi.args.len(), 1);
|
||||
|
||||
let entry = stable_mir::entry_fn().unwrap();
|
||||
let entry = rustc_public::entry_fn().unwrap();
|
||||
let main_fn = Instance::try_from(entry).unwrap();
|
||||
let mut visitor = AdtDefVisitor::default();
|
||||
visitor.visit_body(&main_fn.body().unwrap());
|
||||
|
|
@ -147,7 +147,7 @@ fn check_niche(abi: &ArgAbi) {
|
|||
fn get_item<'a>(
|
||||
items: &'a CrateItems,
|
||||
item: (ItemKind, &str),
|
||||
) -> Option<&'a stable_mir::CrateItem> {
|
||||
) -> Option<&'a rustc_public::CrateItem> {
|
||||
items.iter().find(|crate_item| (item.0 == crate_item.kind()) && crate_item.name() == item.1)
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ struct AdtDefVisitor {
|
|||
}
|
||||
|
||||
impl MirVisitor for AdtDefVisitor {
|
||||
fn visit_ty(&mut self, ty: &Ty, _location: stable_mir::mir::visit::Location) {
|
||||
fn visit_ty(&mut self, ty: &Ty, _location: rustc_public::mir::visit::Location) {
|
||||
if let TyKind::RigidTy(RigidTy::Adt(adt, _)) = ty.kind() {
|
||||
self.adt_defs.insert(adt);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ extern crate rustc_middle;
|
|||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use std::ascii::Char;
|
||||
use std::assert_matches::assert_matches;
|
||||
|
|
@ -27,19 +27,19 @@ use std::ffi::CStr;
|
|||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
use stable_mir::crate_def::CrateDef;
|
||||
use stable_mir::mir::Body;
|
||||
use stable_mir::mir::alloc::GlobalAlloc;
|
||||
use stable_mir::mir::mono::{Instance, StaticDef};
|
||||
use stable_mir::ty::{Allocation, ConstantKind};
|
||||
use stable_mir::{CrateItem, CrateItems, ItemKind};
|
||||
use rustc_public::crate_def::CrateDef;
|
||||
use rustc_public::mir::Body;
|
||||
use rustc_public::mir::alloc::GlobalAlloc;
|
||||
use rustc_public::mir::mono::{Instance, StaticDef};
|
||||
use rustc_public::ty::{Allocation, ConstantKind};
|
||||
use rustc_public::{CrateItem, CrateItems, ItemKind};
|
||||
|
||||
const CRATE_NAME: &str = "input";
|
||||
|
||||
/// This function uses the Stable MIR APIs to get information about the test crate.
|
||||
fn test_stable_mir() -> ControlFlow<()> {
|
||||
// Find items in the local crate.
|
||||
let items = stable_mir::all_local_items();
|
||||
let items = rustc_public::all_local_items();
|
||||
check_foo(*get_item(&items, (ItemKind::Static, "FOO")).unwrap());
|
||||
check_bar(*get_item(&items, (ItemKind::Static, "BAR")).unwrap());
|
||||
check_len(*get_item(&items, (ItemKind::Static, "LEN")).unwrap());
|
||||
|
|
@ -164,7 +164,7 @@ fn check_other_consts(item: CrateItem) {
|
|||
}
|
||||
let bool_id = bool_id.unwrap();
|
||||
let char_id = char_id.unwrap();
|
||||
// FIXME(stable_mir): add `read_ptr` to `Allocation`
|
||||
// FIXME(rustc_public): add `read_ptr` to `Allocation`
|
||||
assert_ne!(bool_id, char_id);
|
||||
}
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ fn check_len(item: CrateItem) {
|
|||
fn get_item<'a>(
|
||||
items: &'a CrateItems,
|
||||
item: (ItemKind, &str),
|
||||
) -> Option<&'a stable_mir::CrateItem> {
|
||||
) -> Option<&'a rustc_public::CrateItem> {
|
||||
items.iter().find(|crate_item| (item.0 == crate_item.kind()) && crate_item.name() == item.1)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,20 +14,20 @@ extern crate rustc_middle;
|
|||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
use stable_mir::ty::*;
|
||||
use stable_mir::{CrateDef, *};
|
||||
use rustc_public::ty::*;
|
||||
use rustc_public::{CrateDef, *};
|
||||
|
||||
const CRATE_NAME: &str = "crate_assoc_items";
|
||||
|
||||
/// This function uses the Stable MIR APIs to get information about the test crate.
|
||||
fn test_assoc_items() -> ControlFlow<()> {
|
||||
let local_crate = stable_mir::local_crate();
|
||||
let local_crate = rustc_public::local_crate();
|
||||
check_items(
|
||||
&local_crate.fn_defs(),
|
||||
&[
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ extern crate rustc_middle;
|
|||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use stable_mir::{CrateDef, CrateItems};
|
||||
use rustc_public::{CrateDef, CrateItems};
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ const CRATE_NAME: &str = "input";
|
|||
/// This function uses the Stable MIR APIs to get information about the test crate.
|
||||
fn test_stable_mir() -> ControlFlow<()> {
|
||||
// Find items in the local crate.
|
||||
let items = stable_mir::all_local_items();
|
||||
let items = rustc_public::all_local_items();
|
||||
|
||||
test_tool(&items);
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ fn test_tool(items: &CrateItems) {
|
|||
fn get_item<'a>(
|
||||
items: &'a CrateItems,
|
||||
name: &str,
|
||||
) -> Option<&'a stable_mir::CrateItem> {
|
||||
) -> Option<&'a rustc_public::CrateItem> {
|
||||
items.iter().find(|crate_item| crate_item.name() == name)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ extern crate rustc_middle;
|
|||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use stable_mir::mir::mono::Instance;
|
||||
use stable_mir::mir::visit::{Location, MirVisitor};
|
||||
use stable_mir::mir::{LocalDecl, Rvalue, Statement, StatementKind, Terminator, TerminatorKind};
|
||||
use stable_mir::ty::{RigidTy, TyKind};
|
||||
use rustc_public::mir::mono::Instance;
|
||||
use rustc_public::mir::visit::{Location, MirVisitor};
|
||||
use rustc_public::mir::{LocalDecl, Rvalue, Statement, StatementKind, Terminator, TerminatorKind};
|
||||
use rustc_public::ty::{RigidTy, TyKind};
|
||||
use std::collections::HashSet;
|
||||
use std::convert::TryFrom;
|
||||
use std::io::Write;
|
||||
|
|
@ -27,7 +27,7 @@ use std::ops::ControlFlow;
|
|||
/// This function tests that we can correctly get type information from binary operations.
|
||||
fn test_binops() -> ControlFlow<()> {
|
||||
// Find items in the local crate.
|
||||
let items = stable_mir::all_local_items();
|
||||
let items = rustc_public::all_local_items();
|
||||
let mut instances =
|
||||
items.into_iter().map(|item| Instance::try_from(item).unwrap()).collect::<Vec<_>>();
|
||||
while let Some(instance) = instances.pop() {
|
||||
|
|
|
|||
|
|
@ -14,18 +14,18 @@ extern crate rustc_middle;
|
|||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
use stable_mir::mir::Body;
|
||||
use stable_mir::ty::{RigidTy, TyKind};
|
||||
use rustc_public::mir::Body;
|
||||
use rustc_public::ty::{RigidTy, TyKind};
|
||||
|
||||
const CRATE_NAME: &str = "crate_coroutine_body";
|
||||
|
||||
fn test_coroutine_body() -> ControlFlow<()> {
|
||||
let crate_items = stable_mir::all_local_items();
|
||||
let crate_items = rustc_public::all_local_items();
|
||||
if let Some(body) = crate_items.iter().find_map(|item| {
|
||||
let item_ty = item.ty();
|
||||
if let TyKind::RigidTy(RigidTy::Coroutine(def, ..)) = &item_ty.kind() {
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ extern crate rustc_middle;
|
|||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use stable_mir::CrateDef;
|
||||
use rustc_public::CrateDef;
|
||||
use std::collections::HashSet;
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
|
@ -26,7 +26,7 @@ const CRATE_NAME: &str = "crate_defs";
|
|||
/// This function uses the Stable MIR APIs to get information about the test crate.
|
||||
fn test_stable_mir() -> ControlFlow<()> {
|
||||
// Find items in the local crate.
|
||||
let local = stable_mir::local_crate();
|
||||
let local = rustc_public::local_crate();
|
||||
check_items(&local.statics(), &["PRIVATE_STATIC", "dummy::PUBLIC_STATIC"]);
|
||||
check_items(
|
||||
&local.fn_defs(),
|
||||
|
|
@ -44,7 +44,7 @@ fn test_stable_mir() -> ControlFlow<()> {
|
|||
// Find items inside core crate.
|
||||
// FIXME: We are currently missing primitive type methods and trait implementations for external
|
||||
// crates.
|
||||
let core = stable_mir::find_crates("core").pop().expect("Cannot find `core` crate");
|
||||
let core = rustc_public::find_crates("core").pop().expect("Cannot find `core` crate");
|
||||
contains(
|
||||
&core.fn_defs(),
|
||||
&[
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ extern crate rustc_middle;
|
|||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use stable_mir::ty::{Ty, ForeignItemKind};
|
||||
use stable_mir::*;
|
||||
use rustc_public::ty::{Ty, ForeignItemKind};
|
||||
use rustc_public::*;
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ const CRATE_NAME: &str = "crate_def_ty";
|
|||
|
||||
/// Test if we can retrieve type information from different definitions.
|
||||
fn test_def_tys() -> ControlFlow<()> {
|
||||
let items = stable_mir::all_local_items();
|
||||
let items = rustc_public::all_local_items();
|
||||
for item in &items {
|
||||
// Type from crate items.
|
||||
let ty = item.ty();
|
||||
|
|
@ -37,7 +37,7 @@ fn test_def_tys() -> ControlFlow<()> {
|
|||
}
|
||||
}
|
||||
|
||||
let foreign_items = stable_mir::local_crate().foreign_modules();
|
||||
let foreign_items = rustc_public::local_crate().foreign_modules();
|
||||
for item in foreign_items[0].module().items() {
|
||||
// Type from foreign items.
|
||||
let ty = item.ty();
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ extern crate rustc_middle;
|
|||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use std::assert_matches::assert_matches;
|
||||
use mir::{mono::Instance, TerminatorKind::*};
|
||||
use stable_mir::mir::mono::InstanceKind;
|
||||
use stable_mir::ty::{RigidTy, TyKind, Ty, UintTy};
|
||||
use stable_mir::*;
|
||||
use rustc_public::mir::mono::InstanceKind;
|
||||
use rustc_public::ty::{RigidTy, TyKind, Ty, UintTy};
|
||||
use rustc_public::*;
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ const CRATE_NAME: &str = "input";
|
|||
|
||||
/// This function uses the Stable MIR APIs to get information about the test crate.
|
||||
fn test_stable_mir() -> ControlFlow<()> {
|
||||
let entry = stable_mir::entry_fn().unwrap();
|
||||
let entry = rustc_public::entry_fn().unwrap();
|
||||
let main_fn = Instance::try_from(entry).unwrap();
|
||||
assert_eq!(main_fn.name(), "main");
|
||||
assert_eq!(main_fn.trimmed_name(), "main");
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ extern crate rustc_middle;
|
|||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate rustc_span;
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use stable_mir::{
|
||||
use rustc_public::{
|
||||
ty::{Abi, ForeignItemKind},
|
||||
*,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,21 +13,21 @@ extern crate rustc_middle;
|
|||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
use mir::mono::Instance;
|
||||
use mir::TerminatorKind::*;
|
||||
use stable_mir::ty::{RigidTy, TyKind};
|
||||
use stable_mir::*;
|
||||
use rustc_public::ty::{RigidTy, TyKind};
|
||||
use rustc_public::*;
|
||||
|
||||
const CRATE_NAME: &str = "input";
|
||||
|
||||
/// This function uses the Stable MIR APIs to get information about the test crate.
|
||||
fn test_stable_mir() -> ControlFlow<()> {
|
||||
let items = stable_mir::all_local_items();
|
||||
let items = rustc_public::all_local_items();
|
||||
|
||||
// Get all items and split generic vs monomorphic items.
|
||||
let (generic, mono): (Vec<_>, Vec<_>) =
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@ extern crate rustc_hir;
|
|||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use stable_mir::mir::mono::{Instance, InstanceKind};
|
||||
use stable_mir::mir::visit::{Location, MirVisitor};
|
||||
use stable_mir::mir::{LocalDecl, Terminator, TerminatorKind};
|
||||
use stable_mir::ty::{FnDef, GenericArgs, RigidTy, TyKind};
|
||||
use rustc_public::mir::mono::{Instance, InstanceKind};
|
||||
use rustc_public::mir::visit::{Location, MirVisitor};
|
||||
use rustc_public::mir::{LocalDecl, Terminator, TerminatorKind};
|
||||
use rustc_public::ty::{FnDef, GenericArgs, RigidTy, TyKind};
|
||||
use std::assert_matches::assert_matches;
|
||||
use std::convert::TryFrom;
|
||||
use std::io::Write;
|
||||
|
|
@ -32,7 +32,7 @@ use std::ops::ControlFlow;
|
|||
/// This function tests that we can correctly get type information from binary operations.
|
||||
fn test_intrinsics() -> ControlFlow<()> {
|
||||
// Find items in the local crate.
|
||||
let main_def = stable_mir::all_local_items()[0];
|
||||
let main_def = rustc_public::all_local_items()[0];
|
||||
let main_instance = Instance::try_from(main_def).unwrap();
|
||||
let main_body = main_instance.body().unwrap();
|
||||
let mut visitor = CallsVisitor { locals: main_body.locals(), calls: Default::default() };
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ extern crate rustc_middle;
|
|||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use stable_mir::*;
|
||||
use rustc_public::*;
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ const CRATE_NAME: &str = "input";
|
|||
|
||||
/// This function uses the Stable MIR APIs to get information about the test crate.
|
||||
fn test_item_kind() -> ControlFlow<()> {
|
||||
let items = stable_mir::all_local_items();
|
||||
let items = rustc_public::all_local_items();
|
||||
assert_eq!(items.len(), 4);
|
||||
// Constructor item.
|
||||
for item in items {
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ extern crate rustc_middle;
|
|||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use mir::mono::Instance;
|
||||
use ty::{Ty, TyKind, RigidTy};
|
||||
use stable_mir::*;
|
||||
use rustc_public::*;
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ const CRATE_NAME: &str = "input";
|
|||
|
||||
/// This function uses the Stable MIR APIs to get information about the test crate.
|
||||
fn test_stable_mir() -> ControlFlow<()> {
|
||||
let items = stable_mir::all_local_items();
|
||||
let items = rustc_public::all_local_items();
|
||||
|
||||
// Get all items and split generic vs monomorphic items.
|
||||
let instances: Vec<_> =
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ extern crate rustc_middle;
|
|||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use stable_mir::CrateDef;
|
||||
use rustc_public::CrateDef;
|
||||
use std::collections::HashSet;
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
|
@ -25,7 +25,7 @@ const CRATE_NAME: &str = "trait_test";
|
|||
|
||||
/// This function uses the Stable MIR APIs to get information about the test crate.
|
||||
fn test_traits() -> ControlFlow<()> {
|
||||
let local_crate = stable_mir::local_crate();
|
||||
let local_crate = rustc_public::local_crate();
|
||||
let local_traits = local_crate.trait_decls();
|
||||
assert_eq!(local_traits.len(), 1, "Expected `Max` trait, but found {:?}", local_traits);
|
||||
assert_eq!(&local_traits[0].name(), "Max");
|
||||
|
|
@ -42,14 +42,14 @@ fn test_traits() -> ControlFlow<()> {
|
|||
assert_impl(&impl_names, "<u64 as Max>");
|
||||
assert_impl(&impl_names, "<impl std::convert::From<Positive> for u64>");
|
||||
|
||||
let all_traits = stable_mir::all_trait_decls();
|
||||
let all_traits = rustc_public::all_trait_decls();
|
||||
assert!(all_traits.len() > local_traits.len());
|
||||
assert!(
|
||||
local_traits.iter().all(|t| all_traits.contains(t)),
|
||||
"Local: {local_traits:#?}, All: {all_traits:#?}"
|
||||
);
|
||||
|
||||
let all_impls = stable_mir::all_trait_impls();
|
||||
let all_impls = rustc_public::all_trait_impls();
|
||||
assert!(all_impls.len() > local_impls.len());
|
||||
assert!(
|
||||
local_impls.iter().all(|t| all_impls.contains(t)),
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ extern crate rustc_middle;
|
|||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use stable_mir::mir::alloc::GlobalAlloc;
|
||||
use stable_mir::mir::mono::Instance;
|
||||
use stable_mir::mir::{Body, ConstOperand, Operand, Rvalue, StatementKind, TerminatorKind};
|
||||
use stable_mir::ty::{ConstantKind, MirConst};
|
||||
use stable_mir::{CrateDef, CrateItems, ItemKind};
|
||||
use rustc_public::mir::alloc::GlobalAlloc;
|
||||
use rustc_public::mir::mono::Instance;
|
||||
use rustc_public::mir::{Body, ConstOperand, Operand, Rvalue, StatementKind, TerminatorKind};
|
||||
use rustc_public::ty::{ConstantKind, MirConst};
|
||||
use rustc_public::{CrateDef, CrateItems, ItemKind};
|
||||
use std::convert::TryFrom;
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
|
@ -31,7 +31,7 @@ const CRATE_NAME: &str = "input";
|
|||
/// This function uses the Stable MIR APIs to transform the MIR.
|
||||
fn test_transform() -> ControlFlow<()> {
|
||||
// Find items in the local crate.
|
||||
let items = stable_mir::all_local_items();
|
||||
let items = rustc_public::all_local_items();
|
||||
|
||||
// Test fn_abi
|
||||
let target_fn = *get_item(&items, (ItemKind::Fn, "dummy")).unwrap();
|
||||
|
|
@ -109,7 +109,7 @@ fn change_panic_msg(mut body: Body, new_msg: &str) -> Body {
|
|||
fn get_item<'a>(
|
||||
items: &'a CrateItems,
|
||||
item: (ItemKind, &str),
|
||||
) -> Option<&'a stable_mir::CrateItem> {
|
||||
) -> Option<&'a rustc_public::CrateItem> {
|
||||
items.iter().find(|crate_item| (item.0 == crate_item.kind()) && crate_item.name() == item.1)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ extern crate rustc_middle;
|
|||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use stable_mir::mir::{
|
||||
use rustc_public::mir::{
|
||||
Body, FieldIdx, MirVisitor, Place, ProjectionElem,
|
||||
visit::{Location, PlaceContext},
|
||||
};
|
||||
use stable_mir::ty::{RigidTy, Ty, TyKind};
|
||||
use rustc_public::ty::{RigidTy, Ty, TyKind};
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ const CRATE_NAME: &str = "input";
|
|||
|
||||
/// This function uses the Stable MIR APIs to get information about the test crate.
|
||||
fn test_stable_mir() -> ControlFlow<()> {
|
||||
let main_fn = stable_mir::entry_fn();
|
||||
let main_fn = rustc_public::entry_fn();
|
||||
let body = main_fn.unwrap().expect_body();
|
||||
let mut visitor = PlaceVisitor { body: &body, tested: false };
|
||||
visitor.visit_body(&body);
|
||||
|
|
|
|||
|
|
@ -15,15 +15,15 @@ extern crate rustc_middle;
|
|||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
use stable_mir::CrateItem;
|
||||
use stable_mir::crate_def::CrateDef;
|
||||
use stable_mir::mir::{AggregateKind, Rvalue, Statement, StatementKind};
|
||||
use stable_mir::ty::{IntTy, RigidTy, Ty};
|
||||
use rustc_public::CrateItem;
|
||||
use rustc_public::crate_def::CrateDef;
|
||||
use rustc_public::mir::{AggregateKind, Rvalue, Statement, StatementKind};
|
||||
use rustc_public::ty::{IntTy, RigidTy, Ty};
|
||||
|
||||
const CRATE_NAME: &str = "crate_variant_ty";
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ fn check_adt_poly2() {
|
|||
}
|
||||
|
||||
fn get_fn(name: &str) -> CrateItem {
|
||||
stable_mir::all_local_items().into_iter().find(|it| it.name().eq(name)).unwrap()
|
||||
rustc_public::all_local_items().into_iter().find(|it| it.name().eq(name)).unwrap()
|
||||
}
|
||||
|
||||
fn check_statement_is_aggregate_assign(
|
||||
|
|
|
|||
|
|
@ -14,18 +14,18 @@ extern crate rustc_middle;
|
|||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
use stable_mir::mir::{Body, ConstOperand, Operand, TerminatorKind};
|
||||
use stable_mir::ty::{FnDef, RigidTy, TyKind};
|
||||
use rustc_public::mir::{Body, ConstOperand, Operand, TerminatorKind};
|
||||
use rustc_public::ty::{FnDef, RigidTy, TyKind};
|
||||
|
||||
const CRATE_NAME: &str = "crate_closure_body";
|
||||
|
||||
fn test_closure_body() -> ControlFlow<()> {
|
||||
let crate_items = stable_mir::all_local_items();
|
||||
let crate_items = rustc_public::all_local_items();
|
||||
for item in crate_items {
|
||||
let item_ty = item.ty();
|
||||
match &item_ty.kind() {
|
||||
|
|
|
|||
|
|
@ -14,18 +14,18 @@ extern crate rustc_middle;
|
|||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
use stable_mir::mir::{Body, ConstOperand, Operand, TerminatorKind};
|
||||
use stable_mir::ty::{FnDef, RigidTy, TyKind};
|
||||
use rustc_public::mir::{Body, ConstOperand, Operand, TerminatorKind};
|
||||
use rustc_public::ty::{FnDef, RigidTy, TyKind};
|
||||
|
||||
const CRATE_NAME: &str = "crate_closure_body";
|
||||
|
||||
fn test_closure_body() -> ControlFlow<()> {
|
||||
let crate_items = stable_mir::all_local_items();
|
||||
let crate_items = rustc_public::all_local_items();
|
||||
for item in crate_items {
|
||||
let item_ty = item.ty();
|
||||
match &item_ty.kind() {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ extern crate rustc_middle;
|
|||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ fn test_continue(args: &[String]) {
|
|||
|
||||
fn test_break(args: &[String]) {
|
||||
let result = run!(args, || ControlFlow::Break::<bool, i32>(false));
|
||||
assert_eq!(result, Err(stable_mir::CompilerError::Interrupted(false)));
|
||||
assert_eq!(result, Err(rustc_public::CompilerError::Interrupted(false)));
|
||||
}
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
|
|
@ -48,7 +48,7 @@ fn test_skipped(args: &[String]) {
|
|||
let mut args = args.to_vec();
|
||||
args.push("--version".to_string());
|
||||
let result = run!(&args, || unreachable!() as ControlFlow<()>);
|
||||
assert_eq!(result, Err(stable_mir::CompilerError::Skipped));
|
||||
assert_eq!(result, Err(rustc_public::CompilerError::Skipped));
|
||||
}
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
|
|
@ -56,7 +56,7 @@ fn test_failed(args: &[String]) {
|
|||
let mut args = args.to_vec();
|
||||
args.push("--cfg=broken".to_string());
|
||||
let result = run!(&args, || unreachable!() as ControlFlow<()>);
|
||||
assert_eq!(result, Err(stable_mir::CompilerError::Failed));
|
||||
assert_eq!(result, Err(rustc_public::CompilerError::Failed));
|
||||
}
|
||||
|
||||
/// Test that we are able to pass a closure and set the return according to the captured value.
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ extern crate rustc_middle;
|
|||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use rustc_hir::def::DefKind;
|
||||
use stable_mir::ItemKind;
|
||||
use stable_mir::crate_def::CrateDef;
|
||||
use stable_mir::mir::mono::Instance;
|
||||
use stable_mir::ty::{RigidTy, TyKind};
|
||||
use rustc_public::ItemKind;
|
||||
use rustc_public::crate_def::CrateDef;
|
||||
use rustc_public::mir::mono::Instance;
|
||||
use rustc_public::ty::{RigidTy, TyKind};
|
||||
use std::assert_matches::assert_matches;
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
|
@ -30,18 +30,18 @@ const CRATE_NAME: &str = "input";
|
|||
|
||||
/// This function uses the Stable MIR APIs to get information about the test crate.
|
||||
fn test_stable_mir() -> ControlFlow<()> {
|
||||
// Get the local crate using stable_mir API.
|
||||
let local = stable_mir::local_crate();
|
||||
// Get the local crate using rustc_public API.
|
||||
let local = rustc_public::local_crate();
|
||||
assert_eq!(&local.name, CRATE_NAME);
|
||||
|
||||
assert_eq!(stable_mir::entry_fn(), None);
|
||||
assert_eq!(rustc_public::entry_fn(), None);
|
||||
|
||||
// Find items in the local crate.
|
||||
let items = stable_mir::all_local_items();
|
||||
let items = rustc_public::all_local_items();
|
||||
assert!(get_item(&items, (DefKind::Fn, "foo::bar")).is_some());
|
||||
|
||||
// Find the `std` crate and assert that there is only one of it.
|
||||
assert!(stable_mir::find_crates("std").len() == 1);
|
||||
assert!(rustc_public::find_crates("std").len() == 1);
|
||||
|
||||
let bar = get_item(&items, (DefKind::Fn, "bar")).unwrap();
|
||||
let body = bar.expect_body();
|
||||
|
|
@ -50,11 +50,11 @@ fn test_stable_mir() -> ControlFlow<()> {
|
|||
let block = &body.blocks[0];
|
||||
assert_eq!(block.statements.len(), 1);
|
||||
match &block.statements[0].kind {
|
||||
stable_mir::mir::StatementKind::Assign(..) => {}
|
||||
rustc_public::mir::StatementKind::Assign(..) => {}
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
match &block.terminator.kind {
|
||||
stable_mir::mir::TerminatorKind::Return => {}
|
||||
rustc_public::mir::TerminatorKind::Return => {}
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ fn test_stable_mir() -> ControlFlow<()> {
|
|||
assert_eq!(body.blocks.len(), 4);
|
||||
let block = &body.blocks[0];
|
||||
match &block.terminator.kind {
|
||||
stable_mir::mir::TerminatorKind::Call { .. } => {}
|
||||
rustc_public::mir::TerminatorKind::Call { .. } => {}
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
|
||||
|
|
@ -73,28 +73,32 @@ fn test_stable_mir() -> ControlFlow<()> {
|
|||
assert_eq!(body.locals().len(), 6);
|
||||
assert_matches!(
|
||||
body.locals()[0].ty.kind(),
|
||||
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool)
|
||||
rustc_public::ty::TyKind::RigidTy(rustc_public::ty::RigidTy::Bool)
|
||||
);
|
||||
assert_matches!(
|
||||
body.locals()[1].ty.kind(),
|
||||
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool)
|
||||
rustc_public::ty::TyKind::RigidTy(rustc_public::ty::RigidTy::Bool)
|
||||
);
|
||||
assert_matches!(
|
||||
body.locals()[2].ty.kind(),
|
||||
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Char)
|
||||
rustc_public::ty::TyKind::RigidTy(rustc_public::ty::RigidTy::Char)
|
||||
);
|
||||
assert_matches!(
|
||||
body.locals()[3].ty.kind(),
|
||||
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Int(stable_mir::ty::IntTy::I32))
|
||||
rustc_public::ty::TyKind::RigidTy(
|
||||
rustc_public::ty::RigidTy::Int(rustc_public::ty::IntTy::I32)
|
||||
)
|
||||
);
|
||||
assert_matches!(
|
||||
body.locals()[4].ty.kind(),
|
||||
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Uint(stable_mir::ty::UintTy::U64))
|
||||
rustc_public::ty::TyKind::RigidTy(
|
||||
rustc_public::ty::RigidTy::Uint(rustc_public::ty::UintTy::U64)
|
||||
)
|
||||
);
|
||||
assert_matches!(
|
||||
body.locals()[5].ty.kind(),
|
||||
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Float(
|
||||
stable_mir::ty::FloatTy::F64
|
||||
rustc_public::ty::TyKind::RigidTy(rustc_public::ty::RigidTy::Float(
|
||||
rustc_public::ty::FloatTy::F64
|
||||
))
|
||||
);
|
||||
|
||||
|
|
@ -103,7 +107,7 @@ fn test_stable_mir() -> ControlFlow<()> {
|
|||
assert_eq!(body.blocks.len(), 2);
|
||||
let block = &body.blocks[0];
|
||||
match &block.terminator.kind {
|
||||
stable_mir::mir::TerminatorKind::Drop { .. } => {}
|
||||
rustc_public::mir::TerminatorKind::Drop { .. } => {}
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +116,7 @@ fn test_stable_mir() -> ControlFlow<()> {
|
|||
assert_eq!(body.blocks.len(), 2);
|
||||
let block = &body.blocks[0];
|
||||
match &block.terminator.kind {
|
||||
stable_mir::mir::TerminatorKind::Assert { .. } => {}
|
||||
rustc_public::mir::TerminatorKind::Assert { .. } => {}
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +124,7 @@ fn test_stable_mir() -> ControlFlow<()> {
|
|||
let instance = Instance::try_from(monomorphic.clone()).unwrap();
|
||||
for block in instance.body().unwrap().blocks {
|
||||
match &block.terminator.kind {
|
||||
stable_mir::mir::TerminatorKind::Call { func, .. } => {
|
||||
rustc_public::mir::TerminatorKind::Call { func, .. } => {
|
||||
let TyKind::RigidTy(ty) = func.ty(&body.locals()).unwrap().kind() else {
|
||||
unreachable!()
|
||||
};
|
||||
|
|
@ -131,7 +135,7 @@ fn test_stable_mir() -> ControlFlow<()> {
|
|||
other => panic!("{other:?}"),
|
||||
}
|
||||
}
|
||||
stable_mir::mir::TerminatorKind::Return => {}
|
||||
rustc_public::mir::TerminatorKind::Return => {}
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
}
|
||||
|
|
@ -145,22 +149,26 @@ fn test_stable_mir() -> ControlFlow<()> {
|
|||
assert_eq!(body.locals().len(), 4);
|
||||
assert_matches!(
|
||||
body.ret_local().ty.kind(),
|
||||
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Char)
|
||||
rustc_public::ty::TyKind::RigidTy(rustc_public::ty::RigidTy::Char)
|
||||
);
|
||||
assert_eq!(body.arg_locals().len(), 2);
|
||||
assert_matches!(
|
||||
body.arg_locals()[0].ty.kind(),
|
||||
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Int(stable_mir::ty::IntTy::I32))
|
||||
rustc_public::ty::TyKind::RigidTy(
|
||||
rustc_public::ty::RigidTy::Int(rustc_public::ty::IntTy::I32)
|
||||
)
|
||||
);
|
||||
assert_matches!(
|
||||
body.arg_locals()[1].ty.kind(),
|
||||
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Uint(stable_mir::ty::UintTy::U64))
|
||||
rustc_public::ty::TyKind::RigidTy(
|
||||
rustc_public::ty::RigidTy::Uint(rustc_public::ty::UintTy::U64)
|
||||
)
|
||||
);
|
||||
assert_eq!(body.inner_locals().len(), 1);
|
||||
// If conditions have an extra inner local to hold their results
|
||||
assert_matches!(
|
||||
body.inner_locals()[0].ty.kind(),
|
||||
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool)
|
||||
rustc_public::ty::TyKind::RigidTy(rustc_public::ty::RigidTy::Bool)
|
||||
);
|
||||
|
||||
ControlFlow::Continue(())
|
||||
|
|
@ -168,9 +176,9 @@ fn test_stable_mir() -> ControlFlow<()> {
|
|||
|
||||
// Use internal API to find a function in a crate.
|
||||
fn get_item<'a>(
|
||||
items: &'a stable_mir::CrateItems,
|
||||
items: &'a rustc_public::CrateItems,
|
||||
item: (DefKind, &str),
|
||||
) -> Option<&'a stable_mir::CrateItem> {
|
||||
) -> Option<&'a rustc_public::CrateItem> {
|
||||
items.iter().find(|crate_item| {
|
||||
matches!(
|
||||
(item.0, crate_item.kind()),
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ extern crate rustc_middle;
|
|||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use stable_mir::ItemKind;
|
||||
use stable_mir::crate_def::CrateDef;
|
||||
use stable_mir::mir::{ProjectionElem, Rvalue, StatementKind};
|
||||
use stable_mir::ty::{RigidTy, TyKind, UintTy};
|
||||
use rustc_public::ItemKind;
|
||||
use rustc_public::crate_def::CrateDef;
|
||||
use rustc_public::mir::{ProjectionElem, Rvalue, StatementKind};
|
||||
use rustc_public::ty::{RigidTy, TyKind, UintTy};
|
||||
use std::assert_matches::assert_matches;
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
|
@ -29,15 +29,15 @@ const CRATE_NAME: &str = "input";
|
|||
|
||||
/// Tests projections within Place objects
|
||||
fn test_place_projections() -> ControlFlow<()> {
|
||||
let items = stable_mir::all_local_items();
|
||||
let items = rustc_public::all_local_items();
|
||||
let body = get_item(&items, (ItemKind::Fn, "projections")).unwrap().expect_body();
|
||||
assert_eq!(body.blocks.len(), 4);
|
||||
// The first statement assigns `&s.c` to a local. The projections include a deref for `s`, since
|
||||
// `s` is passed as a reference argument, and a field access for field `c`.
|
||||
match &body.blocks[0].statements[0].kind {
|
||||
StatementKind::Assign(
|
||||
place @ stable_mir::mir::Place { local: _, projection: local_proj },
|
||||
Rvalue::Ref(_, _, stable_mir::mir::Place { local: _, projection: r_proj }),
|
||||
place @ rustc_public::mir::Place { local: _, projection: local_proj },
|
||||
Rvalue::Ref(_, _, rustc_public::mir::Place { local: _, projection: r_proj }),
|
||||
) => {
|
||||
// We can't match on vecs, only on slices. Comparing statements for equality wouldn't be
|
||||
// any easier since we'd then have to add in the expected local and region values
|
||||
|
|
@ -48,7 +48,7 @@ fn test_place_projections() -> ControlFlow<()> {
|
|||
[ProjectionElem::Deref, ProjectionElem::Field(2, ty)] => {
|
||||
assert_matches!(
|
||||
ty.kind(),
|
||||
TyKind::RigidTy(RigidTy::Uint(stable_mir::ty::UintTy::U8))
|
||||
TyKind::RigidTy(RigidTy::Uint(rustc_public::ty::UintTy::U8))
|
||||
);
|
||||
let ty = place.ty(body.locals()).unwrap();
|
||||
assert_matches!(ty.kind().rigid(), Some(RigidTy::Ref(..)));
|
||||
|
|
@ -70,8 +70,8 @@ fn test_place_projections() -> ControlFlow<()> {
|
|||
// since `slice` is a reference, and an index.
|
||||
match &body.blocks[2].statements[0].kind {
|
||||
StatementKind::Assign(
|
||||
place @ stable_mir::mir::Place { local: _, projection: local_proj },
|
||||
Rvalue::Use(stable_mir::mir::Operand::Copy(stable_mir::mir::Place {
|
||||
place @ rustc_public::mir::Place { local: _, projection: local_proj },
|
||||
Rvalue::Use(rustc_public::mir::Operand::Copy(rustc_public::mir::Place {
|
||||
local: _,
|
||||
projection: r_proj,
|
||||
})),
|
||||
|
|
@ -93,18 +93,18 @@ fn test_place_projections() -> ControlFlow<()> {
|
|||
// The first terminator gets a slice of an array via the Index operation. Specifically it
|
||||
// performs `&vals[1..3]`. There are no projections in this case, the arguments are just locals.
|
||||
match &body.blocks[0].terminator.kind {
|
||||
stable_mir::mir::TerminatorKind::Call { args, .. } =>
|
||||
rustc_public::mir::TerminatorKind::Call { args, .. } =>
|
||||
// We can't match on vecs, only on slices. Comparing for equality wouldn't be any easier
|
||||
// since we'd then have to add in the expected local values instead of matching on
|
||||
// wildcards.
|
||||
{
|
||||
match &args[..] {
|
||||
[
|
||||
stable_mir::mir::Operand::Move(stable_mir::mir::Place {
|
||||
rustc_public::mir::Operand::Move(rustc_public::mir::Place {
|
||||
local: _,
|
||||
projection: arg1_proj,
|
||||
}),
|
||||
stable_mir::mir::Operand::Move(stable_mir::mir::Place {
|
||||
rustc_public::mir::Operand::Move(rustc_public::mir::Place {
|
||||
local: _,
|
||||
projection: arg2_proj,
|
||||
}),
|
||||
|
|
@ -133,9 +133,9 @@ fn test_place_projections() -> ControlFlow<()> {
|
|||
|
||||
// Use internal API to find a function in a crate.
|
||||
fn get_item<'a>(
|
||||
items: &'a stable_mir::CrateItems,
|
||||
items: &'a rustc_public::CrateItems,
|
||||
item: (ItemKind, &str),
|
||||
) -> Option<&'a stable_mir::CrateItem> {
|
||||
) -> Option<&'a rustc_public::CrateItem> {
|
||||
items.iter().find(|crate_item| crate_item.kind() == item.0 && crate_item.name() == item.1)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,17 +14,17 @@ extern crate rustc_driver;
|
|||
extern crate rustc_interface;
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use stable_mir::rustc_internal;
|
||||
use rustc_public::rustc_internal;
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
const CRATE_NAME: &str = "input";
|
||||
|
||||
fn test_translation(tcx: TyCtxt<'_>) -> ControlFlow<()> {
|
||||
let main_fn = stable_mir::entry_fn().unwrap();
|
||||
let main_fn = rustc_public::entry_fn().unwrap();
|
||||
let body = main_fn.expect_body();
|
||||
let orig_ty = body.locals()[0].ty;
|
||||
let rustc_ty = rustc_internal::internal(tcx, &orig_ty);
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@ extern crate rustc_middle;
|
|||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use serde_json::to_string;
|
||||
use stable_mir::mir::Body;
|
||||
use rustc_public::mir::Body;
|
||||
use std::io::{BufWriter, Write};
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
|
|
@ -29,9 +29,9 @@ const CRATE_NAME: &str = "input";
|
|||
fn serialize_to_json(_tcx: TyCtxt<'_>) -> ControlFlow<()> {
|
||||
let path = "output.json";
|
||||
let mut writer = BufWriter::new(std::fs::File::create(path).expect("Failed to create path"));
|
||||
let local_crate = stable_mir::local_crate();
|
||||
let local_crate = rustc_public::local_crate();
|
||||
let items: Vec<Body> =
|
||||
stable_mir::all_local_items().iter().map(|item| item.expect_body()).collect();
|
||||
rustc_public::all_local_items().iter().map(|item| item.expect_body()).collect();
|
||||
let crate_data = (local_crate.name, items);
|
||||
writer
|
||||
.write_all(to_string(&crate_data).expect("serde_json failed").as_bytes())
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ extern crate rustc_middle;
|
|||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate stable_mir;
|
||||
extern crate rustc_public;
|
||||
|
||||
use stable_mir::mir::MirVisitor;
|
||||
use stable_mir::mir::MutMirVisitor;
|
||||
use stable_mir::*;
|
||||
use rustc_public::mir::MirVisitor;
|
||||
use rustc_public::mir::MutMirVisitor;
|
||||
use rustc_public::*;
|
||||
use std::collections::HashSet;
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
|
@ -25,7 +25,7 @@ use std::ops::ControlFlow;
|
|||
const CRATE_NAME: &str = "input";
|
||||
|
||||
fn test_visitor() -> ControlFlow<()> {
|
||||
let main_fn = stable_mir::entry_fn();
|
||||
let main_fn = rustc_public::entry_fn();
|
||||
let main_body = main_fn.unwrap().expect_body();
|
||||
let main_visitor = TestVisitor::collect(&main_body);
|
||||
assert!(main_visitor.ret_val.is_some());
|
||||
|
|
@ -99,7 +99,7 @@ impl<'a> mir::MirVisitor for TestVisitor<'a> {
|
|||
}
|
||||
|
||||
fn test_mut_visitor() -> ControlFlow<()> {
|
||||
let main_fn = stable_mir::entry_fn();
|
||||
let main_fn = rustc_public::entry_fn();
|
||||
let mut main_body = main_fn.unwrap().expect_body();
|
||||
let locals = main_body.locals().to_vec();
|
||||
let mut main_visitor = TestMutVisitor::collect(locals);
|
||||
|
|
|
|||
|
|
@ -410,7 +410,7 @@ These tests revolve around command-line flags which change the way error/warning
|
|||
|
||||
## `tests/ui/diagnostic_namespace/`
|
||||
|
||||
Exercises `#[diagnostic::*]` namespaced attributes. See [RFC 3368 Diagnostic attribute namepsace](https://github.com/rust-lang/rfcs/blob/master/text/3368-diagnostic-attribute-namespace.md).
|
||||
Exercises `#[diagnostic::*]` namespaced attributes. See [RFC 3368 Diagnostic attribute namespace](https://github.com/rust-lang/rfcs/blob/master/text/3368-diagnostic-attribute-namespace.md).
|
||||
|
||||
## `tests/ui/diagnostic-width/`: `--diagnostic-width`
|
||||
|
||||
|
|
|
|||
|
|
@ -22,12 +22,6 @@ error[E0463]: can't find crate for `wloop`
|
|||
LL | extern crate wloop;
|
||||
| ^^^^^^^^^^^^^^^^^^^ can't find crate
|
||||
|
||||
error: malformed `omit_gdb_pretty_printer_section` attribute input
|
||||
--> $DIR/malformed-attrs.rs:26:1
|
||||
|
|
||||
LL | #![omit_gdb_pretty_printer_section = 1]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![omit_gdb_pretty_printer_section]`
|
||||
|
||||
error: malformed `windows_subsystem` attribute input
|
||||
--> $DIR/malformed-attrs.rs:29:1
|
||||
|
|
||||
|
|
@ -271,6 +265,15 @@ LL | #[debugger_visualizer]
|
|||
= note: OR
|
||||
= note: expected: `gdb_script_file = "..."`
|
||||
|
||||
error[E0565]: malformed `omit_gdb_pretty_printer_section` attribute input
|
||||
--> $DIR/malformed-attrs.rs:26:1
|
||||
|
|
||||
LL | #![omit_gdb_pretty_printer_section = 1]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---^
|
||||
| | |
|
||||
| | didn't expect any arguments here
|
||||
| help: must be of the form: `#[omit_gdb_pretty_printer_section]`
|
||||
|
||||
error[E0539]: malformed `export_name` attribute input
|
||||
--> $DIR/malformed-attrs.rs:32:1
|
||||
|
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue