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 9 pull requests #125955

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fc1e52a
Add tracking issue and unstable book page for `"vectorcall"` ABI
beetrees Apr 28, 2024
494cbd8
bootstrap: implement new feature `bootstrap-self-test`
onur-ozkan May 19, 2024
1dcf764
Item bounds can reference self projections and still be object safe
compiler-errors Mar 21, 2024
65dffc1
Change pedantically incorrect OnceCell/OnceLock wording
mqudsi May 24, 2024
a126c11
Reorder the TOC so that targets are put under their meta-group
Lokathor May 28, 2024
f646314
make the fact that arm-none-eabi is a group of targets the first thin…
Lokathor May 28, 2024
144adf6
update armv4t docs
Lokathor May 28, 2024
d8704b9
It's spelled "ARM", in all caps.
Lokathor May 28, 2024
bb1f5c3
delete the offending single space.
Lokathor May 28, 2024
94d4040
The modern styling is apparently to use Title Case for the chip/compa…
Lokathor May 31, 2024
5f0043a
Handle no values cfg with --print=check-cfg
Urgau May 31, 2024
f58bf91
Add missing tracking issue number for --print=check-cfg
Urgau May 31, 2024
b320ac7
Add a regression test for a former blanket impl synthesis ICE
fmease Jun 3, 2024
4576027
Remove stray "this"
tbu- Jun 3, 2024
273b990
Align Term methods with GenericArg methods
compiler-errors May 30, 2024
960aeed
Rollup merge of #122804 - compiler-errors:item-bounds-can-reference-s…
Noratrieb Jun 4, 2024
b70e78f
Rollup merge of #124486 - beetrees:vectorcall-tracking-issue, r=ehuss
Noratrieb Jun 4, 2024
7735809
Rollup merge of #125273 - onur-ozkan:bootstrap-self-test, r=albertlar…
Noratrieb Jun 4, 2024
d65a179
Rollup merge of #125504 - mqudsi:once_nominal, r=cuviper
Noratrieb Jun 4, 2024
f0ddb4b
Rollup merge of #125690 - Lokathor:arm-maintainer-reorg, r=ehuss
Noratrieb Jun 4, 2024
5b9bf8d
Rollup merge of #125750 - compiler-errors:expect, r=lcnr
Noratrieb Jun 4, 2024
7506409
Rollup merge of #125818 - Urgau:print-check-cfg-no-values, r=petroche…
Noratrieb Jun 4, 2024
5e26f6a
Rollup merge of #125909 - fmease:rustdoc-add-test-synth-blanket-impls…
Noratrieb Jun 4, 2024
292985b
Rollup merge of #125919 - tbu-:pr_fix_typo, r=lqd
Noratrieb Jun 4, 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
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ fn push_debuginfo_type_name<'tcx>(
let ExistentialProjection { def_id: item_def_id, term, .. } =
tcx.instantiate_bound_regions_with_erased(bound);
// FIXME(associated_const_equality): allow for consts here
(item_def_id, term.ty().unwrap())
(item_def_id, term.expect_type())
})
.collect();

Expand Down
18 changes: 11 additions & 7 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -814,13 +814,17 @@ fn print_crate_info(
match expected_values {
ExpectedValues::Any => check_cfgs.push(format!("{name}=any()")),
ExpectedValues::Some(values) => {
check_cfgs.extend(values.iter().map(|value| {
if let Some(value) = value {
format!("{name}=\"{value}\"")
} else {
name.to_string()
}
}))
if !values.is_empty() {
check_cfgs.extend(values.iter().map(|value| {
if let Some(value) = value {
format!("{name}=\"{value}\"")
} else {
name.to_string()
}
}))
} else {
check_cfgs.push(format!("{name}="))
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ declare_features! (

/// Allows using the `unadjusted` ABI; perma-unstable.
(internal, abi_unadjusted, "1.16.0", None),
/// Allows using the `vectorcall` ABI.
(unstable, abi_vectorcall, "1.7.0", None),
/// Allows using `#![needs_allocator]`, an implementation detail of `#[global_allocator]`.
(internal, allocator_internals, "1.20.0", None),
/// Allows using `#[allow_internal_unsafe]`. This is an
Expand Down Expand Up @@ -243,6 +241,8 @@ declare_features! (
// feature-group-start: internal feature gates
// -------------------------------------------------------------------------

/// Allows using the `vectorcall` ABI.
(unstable, abi_vectorcall, "1.7.0", Some(124485)),
/// Allows features specific to auto traits.
/// Renamed from `optin_builtin_traits`.
(unstable, auto_traits, "1.50.0", Some(13231)),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2281,7 +2281,7 @@ fn try_report_async_mismatch<'tcx>(
&& let Some(proj) = proj.no_bound_vars()
&& infcx.can_eq(
error.root_obligation.param_env,
proj.term.ty().unwrap(),
proj.term.expect_type(),
impl_sig.output(),
)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ fn report_mismatched_rpitit_signature<'tcx>(
.explicit_item_bounds(future_ty.def_id)
.iter_instantiated_copied(tcx, future_ty.args)
.find_map(|(clause, _)| match clause.kind().no_bound_vars()? {
ty::ClauseKind::Projection(proj) => proj.term.ty(),
ty::ClauseKind::Projection(proj) => proj.term.as_type(),
_ => None,
})
else {
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_hir_analysis/src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,9 @@ fn fn_sig_suggestion<'tcx>(
output = if let ty::Alias(_, alias_ty) = *output.kind() {
tcx.explicit_item_super_predicates(alias_ty.def_id)
.iter_instantiated_copied(tcx, alias_ty.args)
.find_map(|(bound, _)| bound.as_projection_clause()?.no_bound_vars()?.term.ty())
.find_map(|(bound, _)| {
bound.as_projection_clause()?.no_bound_vars()?.term.as_type()
})
.unwrap_or_else(|| {
span_bug!(
ident.span,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_typeck/src/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
};

// Since this is a return parameter type it is safe to unwrap.
let ret_param_ty = projection.skip_binder().term.ty().unwrap();
let ret_param_ty = projection.skip_binder().term.expect_type();
let ret_param_ty = self.resolve_vars_if_possible(ret_param_ty);
debug!(?ret_param_ty);

Expand Down Expand Up @@ -956,7 +956,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let output_ty = self.resolve_vars_if_possible(predicate.term);
debug!("deduce_future_output_from_projection: output_ty={:?}", output_ty);
// This is a projection on a Fn trait so will always be a type.
Some(output_ty.ty().unwrap())
Some(output_ty.expect_type())
}

/// Converts the types that the user supplied, in case that doing
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl<'tcx> TypeckRootCtxt<'tcx> {
{
// If the projection predicate (Foo::Bar == X) has X as a non-TyVid,
// we need to make it into one.
if let Some(vid) = predicate.term.ty().and_then(|ty| ty.ty_vid()) {
if let Some(vid) = predicate.term.as_type().and_then(|ty| ty.ty_vid()) {
debug!("infer_var_info: {:?}.output = true", vid);
infer_var_info.entry(vid).or_default().output = true;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ impl<'tcx> InferCtxt<'tcx> {
ty::ClauseKind::Projection(projection_predicate)
if projection_predicate.projection_term.def_id == item_def_id =>
{
projection_predicate.term.ty()
projection_predicate.term.as_type()
}
_ => None,
})
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@ pub enum ValuePairs<'tcx> {
impl<'tcx> ValuePairs<'tcx> {
pub fn ty(&self) -> Option<(Ty<'tcx>, Ty<'tcx>)> {
if let ValuePairs::Terms(ExpectedFound { expected, found }) = self
&& let Some(expected) = expected.ty()
&& let Some(found) = found.ty()
&& let Some(expected) = expected.as_type()
&& let Some(found) = found.as_type()
{
Some((expected, found))
} else {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound {
};
// Only check types, since those are the only things that may
// have opaques in them anyways.
let Some(proj_term) = proj.term.ty() else { return };
let Some(proj_term) = proj.term.as_type() else { return };

// HACK: `impl Trait<Assoc = impl Trait2>` from an RPIT is "ok"...
if let ty::Alias(ty::Opaque, opaque_ty) = *proj_term.kind()
Expand Down
12 changes: 10 additions & 2 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,14 +624,22 @@ impl<'tcx> Term<'tcx> {
}
}

pub fn ty(&self) -> Option<Ty<'tcx>> {
pub fn as_type(&self) -> Option<Ty<'tcx>> {
if let TermKind::Ty(ty) = self.unpack() { Some(ty) } else { None }
}

pub fn ct(&self) -> Option<Const<'tcx>> {
pub fn expect_type(&self) -> Ty<'tcx> {
self.as_type().expect("expected a type, but found a const")
}

pub fn as_const(&self) -> Option<Const<'tcx>> {
if let TermKind::Const(c) = self.unpack() { Some(c) } else { None }
}

pub fn expect_const(&self) -> Const<'tcx> {
self.as_const().expect("expected a const, but found a type")
}

pub fn into_arg(self) -> GenericArg<'tcx> {
match self.unpack() {
TermKind::Ty(ty) => ty.into(),
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
}

p!(")");
if let Some(ty) = return_ty.skip_binder().ty() {
if let Some(ty) = return_ty.skip_binder().as_type() {
if !ty.is_unit() {
p!(" -> ", print(return_ty));
}
Expand Down Expand Up @@ -1144,7 +1144,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
for (assoc_item_def_id, term) in assoc_items {
// Skip printing `<{coroutine@} as Coroutine<_>>::Return` from async blocks,
// unless we can find out what coroutine return type it comes from.
let term = if let Some(ty) = term.skip_binder().ty()
let term = if let Some(ty) = term.skip_binder().as_type()
&& let ty::Alias(ty::Projection, proj) = ty.kind()
&& let Some(assoc) = tcx.opt_associated_item(proj.def_id)
&& assoc.trait_container(tcx) == tcx.lang_items().coroutine_trait()
Expand Down Expand Up @@ -1322,7 +1322,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
p!(pretty_fn_sig(
tys,
false,
proj.skip_binder().term.ty().expect("Return type was a const")
proj.skip_binder().term.as_type().expect("Return type was a const")
));
resugared = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceProjectionWith<'_, 'tcx> {
)
.expect("expected to be able to unify goal projection with dyn's projection"),
);
proj.term.ty().unwrap()
proj.term.expect_type()
} else {
ty.super_fold_with(self)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
) -> QueryResult<'tcx> {
let tcx = self.interner();
let opaque_ty = goal.predicate.alias;
let expected = goal.predicate.term.ty().expect("no such thing as an opaque const");
let expected = goal.predicate.term.as_type().expect("no such thing as an opaque const");

match (goal.param_env.reveal(), self.solver_mode()) {
(Reveal::UserFacing, SolverMode::Normal) => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
}

fn is_self_referential_projection(&self, p: ty::PolyProjectionPredicate<'tcx>) -> bool {
if let Some(ty) = p.term().skip_binder().ty() {
if let Some(ty) = p.term().skip_binder().as_type() {
matches!(ty.kind(), ty::Alias(ty::Projection, proj) if proj == &p.skip_binder().projection_term.expect_ty(self.tcx))
} else {
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
{
Some((
DefIdOrName::DefId(def_id),
pred.kind().rebind(proj.term.ty().unwrap()),
pred.kind().rebind(proj.term.expect_type()),
pred.kind().rebind(args.as_slice()),
))
} else {
Expand All @@ -1129,7 +1129,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
{
Some((
DefIdOrName::Name("trait object"),
pred.rebind(proj.term.ty().unwrap()),
pred.rebind(proj.term.expect_type()),
pred.rebind(args.as_slice()),
))
} else {
Expand Down Expand Up @@ -1157,7 +1157,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
{
Some((
name,
pred.kind().rebind(proj.term.ty().unwrap()),
pred.kind().rebind(proj.term.expect_type()),
pred.kind().rebind(args.as_slice()),
))
} else {
Expand Down Expand Up @@ -3840,7 +3840,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
})
} else if let Some(where_pred) = where_pred.as_projection_clause()
&& let Some(failed_pred) = failed_pred.as_projection_clause()
&& let Some(found) = failed_pred.skip_binder().term.ty()
&& let Some(found) = failed_pred.skip_binder().term.as_type()
{
type_diffs = vec![Sorts(ty::error::ExpectedFound {
expected: where_pred
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_trait_selection/src/traits/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx
obligations.len = ?self.obligations.len(),
"AssocTypeNormalizer: normalized type"
);
normalized_ty.ty().unwrap()
normalized_ty.expect_type()
}

ty::Projection => {
Expand Down Expand Up @@ -289,7 +289,7 @@ impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx
)
.ok()
.flatten()
.map(|term| term.ty().unwrap())
.map(|term| term.expect_type())
.map(|normalized_ty| {
PlaceholderReplacer::replace_placeholders(
infcx,
Expand Down
Loading
Loading