Auto merge of #109497 - matthiaskrgr:rollup-6txuxm0, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #109373 (Set LLVM `LLVM_UNREACHABLE_OPTIMIZE` to `OFF`) - #109392 (Custom MIR: Allow optional RET type annotation) - #109394 (adapt tests/codegen/vec-shrink-panik for LLVM 17) - #109412 (rustdoc: Add GUI test for "Auto-hide item contents for large items" setting) - #109452 (Ignore the vendor directory for tidy tests.) - #109457 (Remove comment about reusing rib allocations) - #109461 (rustdoc: remove redundant `.content` prefix from span/a colors) - #109477 (`HirId` to `LocalDefId` cleanup) - #109489 (More general captures) - #109494 (Do not feed param_env for RPITITs impl side) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
8859fde21f
21 changed files with 153 additions and 54 deletions
|
@ -424,7 +424,7 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
|
|||
.filter_map(|s| {
|
||||
let enable_disable = match s.chars().next() {
|
||||
None => return None,
|
||||
Some(c @ '+' | c @ '-') => c,
|
||||
Some(c @ ('+' | '-')) => c,
|
||||
Some(_) => {
|
||||
if diagnostics {
|
||||
sess.emit_warning(UnknownCTargetFeaturePrefix { feature: s });
|
||||
|
|
|
@ -1208,7 +1208,7 @@ fn infer_return_ty_for_fn_sig<'tcx>(
|
|||
fn_sig,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
} else if let Some(sugg) = suggest_impl_trait(tcx, ret_ty, ty.span, hir_id, def_id) {
|
||||
} else if let Some(sugg) = suggest_impl_trait(tcx, ret_ty, ty.span, def_id) {
|
||||
diag.span_suggestion(
|
||||
ty.span,
|
||||
"replace with an appropriate return type",
|
||||
|
@ -1240,12 +1240,10 @@ fn infer_return_ty_for_fn_sig<'tcx>(
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME(vincenzopalazzo): remove the hir item when the refactoring is stable
|
||||
fn suggest_impl_trait<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
ret_ty: Ty<'tcx>,
|
||||
span: Span,
|
||||
_hir_id: hir::HirId,
|
||||
def_id: LocalDefId,
|
||||
) -> Option<String> {
|
||||
let format_as_assoc: fn(_, _, _, _, _) -> _ =
|
||||
|
|
|
@ -231,7 +231,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
let ty = ensure_sufficient_stack(|| match &expr.kind {
|
||||
hir::ExprKind::Path(
|
||||
qpath @ hir::QPath::Resolved(..) | qpath @ hir::QPath::TypeRelative(..),
|
||||
qpath @ (hir::QPath::Resolved(..) | hir::QPath::TypeRelative(..)),
|
||||
) => self.check_expr_path(qpath, expr, args),
|
||||
_ => self.check_expr_kind(expr, expected),
|
||||
});
|
||||
|
|
|
@ -165,8 +165,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
&self,
|
||||
ty: Ty<'tcx>,
|
||||
) -> Option<(DefIdOrName, Ty<'tcx>, Vec<Ty<'tcx>>)> {
|
||||
let body_hir_id = self.tcx.hir().local_def_id_to_hir_id(self.body_id);
|
||||
self.err_ctxt().extract_callable_info(body_hir_id, self.param_env, ty)
|
||||
self.err_ctxt().extract_callable_info(self.body_id, self.param_env, ty)
|
||||
}
|
||||
|
||||
pub fn suggest_two_fn_call(
|
||||
|
|
|
@ -2525,7 +2525,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
ident
|
||||
}
|
||||
|
||||
// FIXME(vincenzoapalzzo): move the HirId to a LocalDefId
|
||||
// FIXME(vincenzopalazzo): move the HirId to a LocalDefId
|
||||
pub fn adjust_ident_and_get_scope(
|
||||
self,
|
||||
mut ident: Ident,
|
||||
|
|
|
@ -590,7 +590,6 @@ struct LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
parent_scope: ParentScope<'a>,
|
||||
|
||||
/// The current set of local scopes for types and values.
|
||||
/// FIXME #4948: Reuse ribs to avoid allocation.
|
||||
ribs: PerNS<Vec<Rib<'a>>>,
|
||||
|
||||
/// Previous poped `rib`, only used for diagnostic.
|
||||
|
|
|
@ -703,7 +703,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
PathResult::NonModule(path_res) if let Some(res) = path_res.full_res() => {
|
||||
check_consistency(self, &path, path_span, kind, initial_res, res)
|
||||
}
|
||||
path_res @ PathResult::NonModule(..) | path_res @ PathResult::Failed { .. } => {
|
||||
path_res @ (PathResult::NonModule(..) | PathResult::Failed { .. }) => {
|
||||
let mut suggestion = None;
|
||||
let (span, label) = if let PathResult::Failed { span, label, .. } = path_res {
|
||||
// try to suggest if it's not a macro, maybe a function
|
||||
|
|
|
@ -212,7 +212,7 @@ pub trait TypeErrCtxtExt<'tcx> {
|
|||
|
||||
fn extract_callable_info(
|
||||
&self,
|
||||
hir_id: HirId,
|
||||
body_id: LocalDefId,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
found: Ty<'tcx>,
|
||||
) -> Option<(DefIdOrName, Ty<'tcx>, Vec<Ty<'tcx>>)>;
|
||||
|
@ -909,9 +909,8 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
trait_pred.self_ty(),
|
||||
);
|
||||
|
||||
let body_hir_id = self.tcx.hir().local_def_id_to_hir_id(obligation.cause.body_id);
|
||||
let Some((def_id_or_name, output, inputs)) = self.extract_callable_info(
|
||||
body_hir_id,
|
||||
obligation.cause.body_id,
|
||||
obligation.param_env,
|
||||
self_ty,
|
||||
) else { return false; };
|
||||
|
@ -1113,10 +1112,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
/// Extracts information about a callable type for diagnostics. This is a
|
||||
/// heuristic -- it doesn't necessarily mean that a type is always callable,
|
||||
/// because the callable type must also be well-formed to be called.
|
||||
// FIXME(vincenzopalazzo): move the HirId to a LocalDefId
|
||||
fn extract_callable_info(
|
||||
&self,
|
||||
hir_id: HirId,
|
||||
body_id: LocalDefId,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
found: Ty<'tcx>,
|
||||
) -> Option<(DefIdOrName, Ty<'tcx>, Vec<Ty<'tcx>>)> {
|
||||
|
@ -1168,7 +1166,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
})
|
||||
}
|
||||
ty::Param(param) => {
|
||||
let generics = self.tcx.generics_of(hir_id.owner.to_def_id());
|
||||
let generics = self.tcx.generics_of(body_id);
|
||||
let name = if generics.count() > param.index as usize
|
||||
&& let def = generics.param_at(param.index as usize, self.tcx)
|
||||
&& matches!(def.kind, ty::GenericParamDefKind::Type { .. })
|
||||
|
|
|
@ -386,10 +386,6 @@ fn associated_type_for_impl_trait_in_impl(
|
|||
opt_rpitit_info: Some(ImplTraitInTraitData::Impl { fn_def_id: impl_fn_def_id.to_def_id() }),
|
||||
});
|
||||
|
||||
// Copy param_env of the containing function. The synthesized associated type doesn't have
|
||||
// extra predicates to assume.
|
||||
impl_assoc_ty.param_env(tcx.param_env(impl_fn_def_id));
|
||||
|
||||
// Copy visility of the containing function.
|
||||
impl_assoc_ty.visibility(tcx.visibility(impl_fn_def_id));
|
||||
|
||||
|
|
|
@ -130,7 +130,9 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
|
|||
// FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty): I don't like this, we should
|
||||
// at least be making sure that the generics in RPITITs and their parent fn don't
|
||||
// get out of alignment, or else we do actually need to substitute these predicates.
|
||||
if let Some(ImplTraitInTraitData::Trait { fn_def_id, .. }) = tcx.opt_rpitit_info(def_id) {
|
||||
if let Some(ImplTraitInTraitData::Trait { fn_def_id, .. })
|
||||
| Some(ImplTraitInTraitData::Impl { fn_def_id, .. }) = tcx.opt_rpitit_info(def_id)
|
||||
{
|
||||
predicates = tcx.predicates_of(fn_def_id).instantiate_identity(tcx).predicates;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue