Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #124628

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a51ad79
Refactor dlltool searching code into separate function
mati865 Apr 23, 2024
b1fd4a7
Skip dlltool tests on non `*windows-gnu` targets
mati865 Apr 23, 2024
1367827
remove extraneous note on `UnableToRunDsymutil` diagnostic
lqd Apr 26, 2024
65d7478
Align: add bytes_usize and bits_usize
RalfJung May 1, 2024
9af3b1e
library/std: Remove unused `gimli-symbolize` feature
Enselic May 2, 2024
3c15558
tests/ui: prepare some tests for --check-cfg by default
Urgau Apr 24, 2024
a96964d
compiletest: add no-auto-check-cfg directive
Urgau Apr 9, 2024
595ddb0
compiletest: add enable-by-default check-cfg
Urgau Apr 6, 2024
c4e882f
shallow resolve in orphan check
lcnr May 2, 2024
09aa772
Cleanup: Rid the `rmake` test runners of `extern crate run_make_suppo…
fmease May 2, 2024
dba1849
interpret: hide some reexports in rustdoc
RalfJung May 2, 2024
1bbe36b
Rollup merge of #124138 - mati865:ignore-llvm-abi-in-dlltool-tests, r…
fmease May 2, 2024
a56f12e
Rollup merge of #124345 - Urgau:compiletest-check-cfg, r=jieyouxu
fmease May 2, 2024
811a27f
Rollup merge of #124414 - lqd:subdiagnostics, r=davidtwco
fmease May 2, 2024
d556379
Rollup merge of #124579 - RalfJung:align-bytes-usize, r=fmease
fmease May 2, 2024
b7833a2
Rollup merge of #124604 - Enselic:std-gimli-symbolize, r=workingjubilee
fmease May 2, 2024
159ab18
Rollup merge of #124622 - fmease:yeet-extern-crate-run_make_support, …
fmease May 2, 2024
ba70a5b
Rollup merge of #124623 - lcnr:coherence-uwu, r=compiler-errors
fmease May 2, 2024
aba8ee4
Rollup merge of #124627 - RalfJung:interpret-doc-no-inline, r=fmease
fmease May 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,11 +742,21 @@ impl Align {
1 << self.pow2
}

#[inline]
pub fn bytes_usize(self) -> usize {
self.bytes().try_into().unwrap()
}

#[inline]
pub fn bits(self) -> u64 {
self.bytes() * 8
}

#[inline]
pub fn bits_usize(self) -> usize {
self.bits().try_into().unwrap()
}

/// Computes the best alignment possible for the given offset
/// (the largest power of two that the offset is a multiple of).
///
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_ssa/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ pub struct ProcessingDymutilFailed {

#[derive(Diagnostic)]
#[diag(codegen_ssa_unable_to_run_dsymutil)]
#[note]
pub struct UnableToRunDsymutil {
pub error: Error,
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_const_eval/src/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mod util;
mod validity;
mod visitor;

#[doc(no_inline)]
pub use rustc_middle::mir::interpret::*; // have all the `interpret` symbols in one place: here

pub use self::eval_context::{format_interp_error, Frame, FrameInfo, InterpCx, StackPopCleanup};
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_analysis/src/coherence/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ fn orphan_check<'tcx>(
};

let Ok(result) = traits::orphan_check_trait_ref::<!>(
&infcx,
trait_ref,
traits::InCrate::Local { mode },
lazily_normalize_ty,
Expand Down
12 changes: 4 additions & 8 deletions compiler/rustc_trait_selection/src/solve/assembly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use crate::solve::GoalSource;
use crate::solve::{inspect, EvalCtxt, SolverMode};
use crate::traits::coherence;
use rustc_hir::def_id::DefId;
use rustc_infer::traits::query::NoSolution;
use rustc_middle::traits::solve::inspect::ProbeKind;
Expand Down Expand Up @@ -769,13 +768,10 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
candidates.extend(self.probe_trait_candidate(CandidateSource::CoherenceUnknowable).enter(
|ecx| {
let trait_ref = goal.predicate.trait_ref(tcx);
let lazily_normalize_ty = |ty| ecx.structurally_normalize_ty(goal.param_env, ty);

match coherence::trait_ref_is_knowable(tcx, trait_ref, lazily_normalize_ty)? {
Ok(()) => Err(NoSolution),
Err(_) => {
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
}
if ecx.trait_ref_is_knowable(goal.param_env, trait_ref)? {
Err(NoSolution)
} else {
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
}
},
))
Expand Down
12 changes: 12 additions & 0 deletions compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use rustc_span::DUMMY_SP;
use std::io::Write;
use std::ops::ControlFlow;

use crate::traits::coherence;
use crate::traits::vtable::{count_own_vtable_entries, prepare_vtable_segments, VtblSegment};

use super::inspect::ProofTreeBuilder;
Expand Down Expand Up @@ -942,6 +943,17 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
}
}

pub(super) fn trait_ref_is_knowable(
&mut self,
param_env: ty::ParamEnv<'tcx>,
trait_ref: ty::TraitRef<'tcx>,
) -> Result<bool, NoSolution> {
let infcx = self.infcx;
let lazily_normalize_ty = |ty| self.structurally_normalize_ty(param_env, ty);
coherence::trait_ref_is_knowable(infcx, trait_ref, lazily_normalize_ty)
.map(|is_knowable| is_knowable.is_ok())
}

pub(super) fn can_define_opaque_ty(&self, def_id: impl Into<DefId>) -> bool {
self.infcx.can_define_opaque_ty(def_id)
}
Expand Down
53 changes: 26 additions & 27 deletions compiler/rustc_trait_selection/src/traits/coherence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,19 +618,20 @@ fn try_prove_negated_where_clause<'tcx>(
/// This both checks whether any downstream or sibling crates could
/// implement it and whether an upstream crate can add this impl
/// without breaking backwards compatibility.
#[instrument(level = "debug", skip(tcx, lazily_normalize_ty), ret)]
#[instrument(level = "debug", skip(infcx, lazily_normalize_ty), ret)]
pub fn trait_ref_is_knowable<'tcx, E: Debug>(
tcx: TyCtxt<'tcx>,
infcx: &InferCtxt<'tcx>,
trait_ref: ty::TraitRef<'tcx>,
mut lazily_normalize_ty: impl FnMut(Ty<'tcx>) -> Result<Ty<'tcx>, E>,
) -> Result<Result<(), Conflict>, E> {
if orphan_check_trait_ref(trait_ref, InCrate::Remote, &mut lazily_normalize_ty)?.is_ok() {
if orphan_check_trait_ref(infcx, trait_ref, InCrate::Remote, &mut lazily_normalize_ty)?.is_ok()
{
// A downstream or cousin crate is allowed to implement some
// generic parameters of this trait-ref.
return Ok(Err(Conflict::Downstream));
}

if trait_ref_is_local_or_fundamental(tcx, trait_ref) {
if trait_ref_is_local_or_fundamental(infcx.tcx, trait_ref) {
// This is a local or fundamental trait, so future-compatibility
// is no concern. We know that downstream/cousin crates are not
// allowed to implement a generic parameter of this trait ref,
Expand All @@ -648,6 +649,7 @@ pub fn trait_ref_is_knowable<'tcx, E: Debug>(
// about future-compatibility, which means that we're OK if
// we are an owner.
if orphan_check_trait_ref(
infcx,
trait_ref,
InCrate::Local { mode: OrphanCheckMode::Proper },
&mut lazily_normalize_ty,
Expand Down Expand Up @@ -786,46 +788,41 @@ pub struct UncoveredTyParams<'tcx, T> {
///
/// Note that this function is never called for types that have both type
/// parameters and inference variables.
#[instrument(level = "trace", skip(lazily_normalize_ty), ret)]
#[instrument(level = "trace", skip(infcx, lazily_normalize_ty), ret)]
pub fn orphan_check_trait_ref<'tcx, E: Debug>(
infcx: &InferCtxt<'tcx>,
trait_ref: ty::TraitRef<'tcx>,
in_crate: InCrate,
lazily_normalize_ty: impl FnMut(Ty<'tcx>) -> Result<Ty<'tcx>, E>,
) -> Result<Result<(), OrphanCheckErr<'tcx, Ty<'tcx>>>, E> {
if trait_ref.has_infer() && trait_ref.has_param() {
bug!(
"can't orphan check a trait ref with both params and inference variables {:?}",
trait_ref
);
if trait_ref.has_param() {
bug!("orphan check only expects inference variables: {trait_ref:?}");
}

let mut checker = OrphanChecker::new(in_crate, lazily_normalize_ty);

// Does there exist some local type after the `ParamTy`.
let search_first_local_ty = |checker: &mut OrphanChecker<'tcx, _>| {
checker.search_first_local_ty = true;
match trait_ref.visit_with(checker).break_value() {
Some(OrphanCheckEarlyExit::LocalTy(local_ty)) => Some(local_ty),
_ => None,
}
};

let mut checker = OrphanChecker::new(infcx, in_crate, lazily_normalize_ty);
Ok(match trait_ref.visit_with(&mut checker) {
ControlFlow::Continue(()) => Err(OrphanCheckErr::NonLocalInputType(checker.non_local_tys)),
ControlFlow::Break(residual) => match residual {
OrphanCheckEarlyExit::NormalizationFailure(err) => return Err(err),
OrphanCheckEarlyExit::UncoveredTyParam(ty) => {
// Does there exist some local type after the `ParamTy`.
checker.search_first_local_ty = true;
let local_ty = match trait_ref.visit_with(&mut checker).break_value() {
Some(OrphanCheckEarlyExit::LocalTy(local_ty)) => Some(local_ty),
_ => None,
};
Err(OrphanCheckErr::UncoveredTyParams(UncoveredTyParams {
uncovered: ty,
local_ty: search_first_local_ty(&mut checker),
local_ty,
}))
}
OrphanCheckEarlyExit::LocalTy(_) => Ok(()),
},
})
}

struct OrphanChecker<'tcx, F> {
struct OrphanChecker<'a, 'tcx, F> {
infcx: &'a InferCtxt<'tcx>,
in_crate: InCrate,
in_self_ty: bool,
lazily_normalize_ty: F,
Expand All @@ -834,12 +831,13 @@ struct OrphanChecker<'tcx, F> {
non_local_tys: Vec<(Ty<'tcx>, IsFirstInputType)>,
}

impl<'tcx, F, E> OrphanChecker<'tcx, F>
impl<'a, 'tcx, F, E> OrphanChecker<'a, 'tcx, F>
where
F: FnOnce(Ty<'tcx>) -> Result<Ty<'tcx>, E>,
{
fn new(in_crate: InCrate, lazily_normalize_ty: F) -> Self {
fn new(infcx: &'a InferCtxt<'tcx>, in_crate: InCrate, lazily_normalize_ty: F) -> Self {
OrphanChecker {
infcx,
in_crate,
in_self_ty: true,
lazily_normalize_ty,
Expand Down Expand Up @@ -878,7 +876,7 @@ enum OrphanCheckEarlyExit<'tcx, E> {
LocalTy(Ty<'tcx>),
}

impl<'tcx, F, E> TypeVisitor<TyCtxt<'tcx>> for OrphanChecker<'tcx, F>
impl<'a, 'tcx, F, E> TypeVisitor<TyCtxt<'tcx>> for OrphanChecker<'a, 'tcx, F>
where
F: FnMut(Ty<'tcx>) -> Result<Ty<'tcx>, E>,
{
Expand All @@ -889,6 +887,7 @@ where
}

fn visit_ty(&mut self, ty: Ty<'tcx>) -> Self::Result {
let ty = self.infcx.shallow_resolve(ty);
let ty = match (self.lazily_normalize_ty)(ty) {
Ok(norm_ty) if norm_ty.is_ty_var() => ty,
Ok(norm_ty) => norm_ty,
Expand Down Expand Up @@ -1149,7 +1148,7 @@ impl<'a, 'tcx> ProofTreeVisitor<'tcx> for AmbiguityCausesVisitor<'a, 'tcx> {
};

infcx.probe(|_| {
match trait_ref_is_knowable(infcx.tcx, trait_ref, lazily_normalize_ty) {
match trait_ref_is_knowable(infcx, trait_ref, lazily_normalize_ty) {
Err(()) => {}
Ok(Ok(())) => warn!("expected an unknowable trait ref: {trait_ref:?}"),
Ok(Err(conflict)) => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// bound regions.
let trait_ref = predicate.skip_binder().trait_ref;

coherence::trait_ref_is_knowable::<!>(self.tcx(), trait_ref, |ty| Ok(ty)).unwrap()
coherence::trait_ref_is_knowable::<!>(self.infcx, trait_ref, |ty| Ok(ty)).unwrap()
}

/// Returns `true` if the global caches can be used.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_transmute/src/layout/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ pub(crate) mod rustc {

ty::Ref(lifetime, ty, mutability) => {
let ty_and_layout = cx.layout_of(*ty)?;
let align = ty_and_layout.align.abi.bytes() as usize;
let align = ty_and_layout.align.abi.bytes_usize();
let size = ty_and_layout.size.bytes_usize();
Ok(Tree::Ref(Ref {
lifetime: *lifetime,
Expand Down
2 changes: 0 additions & 2 deletions library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@ r-efi-alloc = { version = "1.0.0", features = ['rustc-dep-of-std'] }

[features]
backtrace = [
"gimli-symbolize",
'addr2line/rustc-dep-of-std',
'object/rustc-dep-of-std',
'miniz_oxide/rustc-dep-of-std',
]
gimli-symbolize = []

panic-unwind = ["panic_unwind"]
profiler = ["profiler_builtins"]
Expand Down
7 changes: 7 additions & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ pub struct TestProps {
pub llvm_cov_flags: Vec<String>,
/// Extra flags to pass to LLVM's `filecheck` tool, in tests that use it.
pub filecheck_flags: Vec<String>,
/// Don't automatically insert any `--check-cfg` args
pub no_auto_check_cfg: bool,
}

mod directives {
Expand Down Expand Up @@ -249,6 +251,7 @@ mod directives {
pub const COMPARE_OUTPUT_LINES_BY_SUBSET: &'static str = "compare-output-lines-by-subset";
pub const LLVM_COV_FLAGS: &'static str = "llvm-cov-flags";
pub const FILECHECK_FLAGS: &'static str = "filecheck-flags";
pub const NO_AUTO_CHECK_CFG: &'static str = "no-auto-check-cfg";
// This isn't a real directive, just one that is probably mistyped often
pub const INCORRECT_COMPILER_FLAGS: &'static str = "compiler-flags";
}
Expand Down Expand Up @@ -304,6 +307,7 @@ impl TestProps {
remap_src_base: false,
llvm_cov_flags: vec![],
filecheck_flags: vec![],
no_auto_check_cfg: false,
}
}

Expand Down Expand Up @@ -567,6 +571,8 @@ impl TestProps {
if let Some(flags) = config.parse_name_value_directive(ln, FILECHECK_FLAGS) {
self.filecheck_flags.extend(split_flags(&flags));
}

config.set_name_directive(ln, NO_AUTO_CHECK_CFG, &mut self.no_auto_check_cfg);
},
);

Expand Down Expand Up @@ -860,6 +866,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"needs-unwind",
"needs-wasmtime",
"needs-xray",
"no-auto-check-cfg",
"no-prefer-dynamic",
"normalize-stderr-32bit",
"normalize-stderr-64bit",
Expand Down
Loading
Loading