mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Auto merge of #108977 - matthiaskrgr:rollup-1bnl1hu, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #108879 (Unconstrained terms should account for infer vars being equated) - #108936 (Rustdoc: don't hide anonymous reexport) - #108940 (Add myself to compiler reviewers list) - #108945 (Make some report and emit errors take DefIds instead of BodyIds) - #108946 (Document the resulting values produced when using `From<bool>` on floats) - #108956 (Make ptr::from_ref and ptr::from_mut in #106116 const.) - #108960 (Remove `body_def_id` from `Inherited`) - #108963 (only call git on git checkouts during bootstrap) - #108964 (Fix the docs for pointer method with_metadata_of) Failed merges: - #108950 (Directly construct Inherited in typeck.) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
35a0961bbc
@ -325,7 +325,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
|
||||
if errors.is_empty() {
|
||||
definition_ty
|
||||
} else {
|
||||
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors, None);
|
||||
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
|
||||
self.tcx.ty_error(reported)
|
||||
}
|
||||
}
|
||||
|
@ -770,7 +770,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
|
||||
|
||||
let errors = ocx.select_all_or_error();
|
||||
if !errors.is_empty() {
|
||||
infcx.err_ctxt().report_fulfillment_errors(&errors, None);
|
||||
infcx.err_ctxt().report_fulfillment_errors(&errors);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -444,7 +444,7 @@ fn check_opaque_meets_bounds<'tcx>(
|
||||
// version.
|
||||
let errors = ocx.select_all_or_error();
|
||||
if !errors.is_empty() {
|
||||
infcx.err_ctxt().report_fulfillment_errors(&errors, None);
|
||||
infcx.err_ctxt().report_fulfillment_errors(&errors);
|
||||
}
|
||||
match origin {
|
||||
// Checked when type checking the function containing them.
|
||||
@ -1545,6 +1545,6 @@ pub(super) fn check_generator_obligations(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||
let errors = fulfillment_cx.select_all_or_error(&infcx);
|
||||
debug!(?errors);
|
||||
if !errors.is_empty() {
|
||||
infcx.err_ctxt().report_fulfillment_errors(&errors, None);
|
||||
infcx.err_ctxt().report_fulfillment_errors(&errors);
|
||||
}
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ fn compare_method_predicate_entailment<'tcx>(
|
||||
});
|
||||
}
|
||||
CheckImpliedWfMode::Skip => {
|
||||
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors, None);
|
||||
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
|
||||
return Err(reported);
|
||||
}
|
||||
}
|
||||
@ -720,7 +720,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
|
||||
// RPITs.
|
||||
let errors = ocx.select_all_or_error();
|
||||
if !errors.is_empty() {
|
||||
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors, None);
|
||||
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
|
||||
return Err(reported);
|
||||
}
|
||||
|
||||
@ -1731,7 +1731,7 @@ pub(super) fn compare_impl_const_raw(
|
||||
// version.
|
||||
let errors = ocx.select_all_or_error();
|
||||
if !errors.is_empty() {
|
||||
return Err(infcx.err_ctxt().report_fulfillment_errors(&errors, None));
|
||||
return Err(infcx.err_ctxt().report_fulfillment_errors(&errors));
|
||||
}
|
||||
|
||||
let outlives_environment = OutlivesEnvironment::new(param_env);
|
||||
@ -1831,7 +1831,7 @@ fn compare_type_predicate_entailment<'tcx>(
|
||||
// version.
|
||||
let errors = ocx.select_all_or_error();
|
||||
if !errors.is_empty() {
|
||||
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors, None);
|
||||
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
|
||||
return Err(reported);
|
||||
}
|
||||
|
||||
@ -2044,7 +2044,7 @@ pub(super) fn check_type_bounds<'tcx>(
|
||||
// version.
|
||||
let errors = ocx.select_all_or_error();
|
||||
if !errors.is_empty() {
|
||||
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors, None);
|
||||
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
|
||||
return Err(reported);
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ pub(super) fn enter_wf_checking_ctxt<'tcx, F>(
|
||||
|
||||
let errors = wfcx.select_all_or_error();
|
||||
if !errors.is_empty() {
|
||||
infcx.err_ctxt().report_fulfillment_errors(&errors, None);
|
||||
infcx.err_ctxt().report_fulfillment_errors(&errors);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
|
||||
}),
|
||||
);
|
||||
if !errors.is_empty() {
|
||||
infcx.err_ctxt().report_fulfillment_errors(&errors, None);
|
||||
infcx.err_ctxt().report_fulfillment_errors(&errors);
|
||||
}
|
||||
|
||||
// Finally, resolve all regions.
|
||||
@ -585,7 +585,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn
|
||||
predicate_for_trait_def(tcx, param_env, cause, trait_def_id, 0, [source, target]);
|
||||
let errors = traits::fully_solve_obligation(&infcx, predicate);
|
||||
if !errors.is_empty() {
|
||||
infcx.err_ctxt().report_fulfillment_errors(&errors, None);
|
||||
infcx.err_ctxt().report_fulfillment_errors(&errors);
|
||||
}
|
||||
|
||||
// Finally, resolve all regions.
|
||||
|
@ -174,7 +174,7 @@ fn get_impl_substs(
|
||||
|
||||
let errors = ocx.select_all_or_error();
|
||||
if !errors.is_empty() {
|
||||
ocx.infcx.err_ctxt().report_fulfillment_errors(&errors, None);
|
||||
ocx.infcx.err_ctxt().report_fulfillment_errors(&errors);
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ fn require_same_types<'tcx>(
|
||||
match &errors[..] {
|
||||
[] => true,
|
||||
errors => {
|
||||
infcx.err_ctxt().report_fulfillment_errors(errors, None);
|
||||
infcx.err_ctxt().report_fulfillment_errors(errors);
|
||||
false
|
||||
}
|
||||
}
|
||||
@ -309,7 +309,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
|
||||
ocx.register_bound(cause, param_env, norm_return_ty, term_did);
|
||||
let errors = ocx.select_all_or_error();
|
||||
if !errors.is_empty() {
|
||||
infcx.err_ctxt().report_fulfillment_errors(&errors, None);
|
||||
infcx.err_ctxt().report_fulfillment_errors(&errors);
|
||||
error = true;
|
||||
}
|
||||
// now we can take the return type of the given main function
|
||||
|
@ -581,7 +581,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
if !errors.is_empty() {
|
||||
self.adjust_fulfillment_errors_for_expr_obligation(&mut errors);
|
||||
self.err_ctxt().report_fulfillment_errors(&errors, self.inh.body_id);
|
||||
self.err_ctxt().report_fulfillment_errors(&errors);
|
||||
}
|
||||
}
|
||||
|
||||
@ -594,7 +594,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
if !result.is_empty() {
|
||||
mutate_fulfillment_errors(&mut result);
|
||||
self.adjust_fulfillment_errors_for_expr_obligation(&mut result);
|
||||
self.err_ctxt().report_fulfillment_errors(&result, self.inh.body_id);
|
||||
self.err_ctxt().report_fulfillment_errors(&result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1411,7 +1411,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
} else {
|
||||
let e = self.tainted_by_errors().unwrap_or_else(|| {
|
||||
self.err_ctxt()
|
||||
.emit_inference_failure_err((**self).body_id, sp, ty.into(), E0282, true)
|
||||
.emit_inference_failure_err(self.body_id, sp, ty.into(), E0282, true)
|
||||
.emit()
|
||||
});
|
||||
let err = self.tcx.ty_error(e);
|
||||
|
@ -58,8 +58,6 @@ pub struct Inherited<'tcx> {
|
||||
pub(super) deferred_generator_interiors:
|
||||
RefCell<Vec<(LocalDefId, hir::BodyId, Ty<'tcx>, hir::GeneratorKind)>>,
|
||||
|
||||
pub(super) body_id: Option<hir::BodyId>,
|
||||
|
||||
/// Whenever we introduce an adjustment from `!` into a type variable,
|
||||
/// we record that type variable here. This is later used to inform
|
||||
/// fallback. See the `fallback` module for details.
|
||||
@ -80,7 +78,6 @@ impl<'tcx> Deref for Inherited<'tcx> {
|
||||
/// without using `Rc` or something similar.
|
||||
pub struct InheritedBuilder<'tcx> {
|
||||
infcx: infer::InferCtxtBuilder<'tcx>,
|
||||
def_id: LocalDefId,
|
||||
typeck_results: RefCell<ty::TypeckResults<'tcx>>,
|
||||
}
|
||||
|
||||
@ -93,7 +90,6 @@ impl<'tcx> Inherited<'tcx> {
|
||||
.infer_ctxt()
|
||||
.ignoring_regions()
|
||||
.with_opaque_type_inference(DefiningAnchor::Bind(hir_owner.def_id)),
|
||||
def_id,
|
||||
typeck_results: RefCell::new(ty::TypeckResults::new(hir_owner)),
|
||||
}
|
||||
}
|
||||
@ -104,19 +100,13 @@ impl<'tcx> InheritedBuilder<'tcx> {
|
||||
where
|
||||
F: FnOnce(&Inherited<'tcx>) -> R,
|
||||
{
|
||||
let def_id = self.def_id;
|
||||
f(&Inherited::new(self.infcx.build(), def_id, self.typeck_results))
|
||||
f(&Inherited::new(self.infcx.build(), self.typeck_results))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Inherited<'tcx> {
|
||||
fn new(
|
||||
infcx: InferCtxt<'tcx>,
|
||||
def_id: LocalDefId,
|
||||
typeck_results: RefCell<ty::TypeckResults<'tcx>>,
|
||||
) -> Self {
|
||||
fn new(infcx: InferCtxt<'tcx>, typeck_results: RefCell<ty::TypeckResults<'tcx>>) -> Self {
|
||||
let tcx = infcx.tcx;
|
||||
let body_id = tcx.hir().maybe_body_owned_by(def_id);
|
||||
|
||||
Inherited {
|
||||
typeck_results,
|
||||
@ -130,7 +120,6 @@ impl<'tcx> Inherited<'tcx> {
|
||||
deferred_asm_checks: RefCell::new(Vec::new()),
|
||||
deferred_generator_interiors: RefCell::new(Vec::new()),
|
||||
diverging_type_vars: RefCell::new(Default::default()),
|
||||
body_id,
|
||||
infer_var_info: RefCell::new(Default::default()),
|
||||
}
|
||||
}
|
||||
|
@ -748,7 +748,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
|
||||
.infcx
|
||||
.err_ctxt()
|
||||
.emit_inference_failure_err(
|
||||
Some(self.body.id()),
|
||||
self.tcx.hir().body_owner_def_id(self.body.id()),
|
||||
self.span.to_span(self.tcx),
|
||||
p.into(),
|
||||
E0282,
|
||||
|
@ -10,7 +10,7 @@ use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed, IntoDiagnosticArg};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::def::{CtorOf, DefKind, Namespace};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::{Body, Closure, Expr, ExprKind, FnRetTy, HirId, Local, LocalSource};
|
||||
use rustc_middle::hir::nested_filter;
|
||||
@ -386,7 +386,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
#[instrument(level = "debug", skip(self, error_code))]
|
||||
pub fn emit_inference_failure_err(
|
||||
&self,
|
||||
body_id: Option<hir::BodyId>,
|
||||
body_def_id: LocalDefId,
|
||||
failure_span: Span,
|
||||
arg: GenericArg<'tcx>,
|
||||
error_code: TypeAnnotationNeeded,
|
||||
@ -403,8 +403,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
};
|
||||
|
||||
let mut local_visitor = FindInferSourceVisitor::new(&self, typeck_results, arg);
|
||||
if let Some(body_id) = body_id {
|
||||
let expr = self.tcx.hir().expect_expr(body_id.hir_id);
|
||||
if let Some(body_id) = self.tcx.hir().maybe_body_owned_by(
|
||||
self.tcx.typeck_root_def_id(body_def_id.to_def_id()).expect_local(),
|
||||
) {
|
||||
let expr = self.tcx.hir().body(body_id).value;
|
||||
local_visitor.visit_expr(expr);
|
||||
}
|
||||
|
||||
|
@ -93,37 +93,42 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
||||
};
|
||||
|
||||
// Guard against `<T as Trait<?0>>::Assoc = ?0>`.
|
||||
struct ContainsTerm<'tcx> {
|
||||
struct ContainsTerm<'a, 'tcx> {
|
||||
term: ty::Term<'tcx>,
|
||||
infcx: &'a InferCtxt<'tcx>,
|
||||
}
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ContainsTerm<'tcx> {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ContainsTerm<'_, 'tcx> {
|
||||
type BreakTy = ();
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if t.needs_infer() {
|
||||
if ty::Term::from(t) == self.term {
|
||||
ControlFlow::Break(())
|
||||
} else {
|
||||
t.super_visit_with(self)
|
||||
}
|
||||
if let Some(vid) = t.ty_vid()
|
||||
&& let ty::TermKind::Ty(term) = self.term.unpack()
|
||||
&& let Some(term_vid) = term.ty_vid()
|
||||
&& self.infcx.root_var(vid) == self.infcx.root_var(term_vid)
|
||||
{
|
||||
ControlFlow::Break(())
|
||||
} else if t.has_non_region_infer() {
|
||||
t.super_visit_with(self)
|
||||
} else {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_const(&mut self, c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if c.needs_infer() {
|
||||
if ty::Term::from(c) == self.term {
|
||||
ControlFlow::Break(())
|
||||
} else {
|
||||
c.super_visit_with(self)
|
||||
}
|
||||
if let ty::ConstKind::Infer(ty::InferConst::Var(vid)) = c.kind()
|
||||
&& let ty::TermKind::Const(term) = self.term.unpack()
|
||||
&& let ty::ConstKind::Infer(ty::InferConst::Var(term_vid)) = term.kind()
|
||||
&& self.infcx.root_const_var(vid) == self.infcx.root_const_var(term_vid)
|
||||
{
|
||||
ControlFlow::Break(())
|
||||
} else if c.has_non_region_infer() {
|
||||
c.super_visit_with(self)
|
||||
} else {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut visitor = ContainsTerm { term: goal.predicate.term };
|
||||
let mut visitor = ContainsTerm { infcx: self.infcx, term: goal.predicate.term };
|
||||
|
||||
term_is_infer
|
||||
&& goal.predicate.projection_ty.visit_with(&mut visitor).is_continue()
|
||||
|
@ -24,11 +24,9 @@ use rustc_errors::{
|
||||
};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::Namespace;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::intravisit::Visitor;
|
||||
use rustc_hir::GenericParam;
|
||||
use rustc_hir::Item;
|
||||
use rustc_hir::Node;
|
||||
use rustc_hir::{GenericParam, Item, Node};
|
||||
use rustc_infer::infer::error_reporting::TypeErrCtxt;
|
||||
use rustc_infer::infer::{InferOk, TypeTrace};
|
||||
use rustc_middle::traits::select::OverflowError;
|
||||
@ -126,11 +124,7 @@ pub trait TypeErrCtxtExt<'tcx> {
|
||||
+ Print<'tcx, FmtPrinter<'tcx, 'tcx>, Output = FmtPrinter<'tcx, 'tcx>>,
|
||||
<T as Print<'tcx, FmtPrinter<'tcx, 'tcx>>>::Error: std::fmt::Debug;
|
||||
|
||||
fn report_fulfillment_errors(
|
||||
&self,
|
||||
errors: &[FulfillmentError<'tcx>],
|
||||
body_id: Option<hir::BodyId>,
|
||||
) -> ErrorGuaranteed;
|
||||
fn report_fulfillment_errors(&self, errors: &[FulfillmentError<'tcx>]) -> ErrorGuaranteed;
|
||||
|
||||
fn report_overflow_obligation<T>(
|
||||
&self,
|
||||
@ -388,11 +382,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
fn report_fulfillment_errors(
|
||||
&self,
|
||||
errors: &[FulfillmentError<'tcx>],
|
||||
body_id: Option<hir::BodyId>,
|
||||
) -> ErrorGuaranteed {
|
||||
fn report_fulfillment_errors(&self, errors: &[FulfillmentError<'tcx>]) -> ErrorGuaranteed {
|
||||
#[derive(Debug)]
|
||||
struct ErrorDescriptor<'tcx> {
|
||||
predicate: ty::Predicate<'tcx>,
|
||||
@ -469,7 +459,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
for from_expansion in [false, true] {
|
||||
for (error, suppressed) in iter::zip(errors, &is_suppressed) {
|
||||
if !suppressed && error.obligation.cause.span.from_expansion() == from_expansion {
|
||||
self.report_fulfillment_error(error, body_id);
|
||||
self.report_fulfillment_error(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -955,8 +945,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
);
|
||||
}
|
||||
|
||||
let body_hir_id =
|
||||
self.tcx.hir().local_def_id_to_hir_id(obligation.cause.body_id);
|
||||
let body_def_id = obligation.cause.body_id;
|
||||
// Try to report a help message
|
||||
if is_fn_trait
|
||||
&& let Ok((implemented_kind, params)) = self.type_implements_fn_trait(
|
||||
@ -1037,7 +1026,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
if !self.report_similar_impl_candidates(
|
||||
impl_candidates,
|
||||
trait_ref,
|
||||
body_hir_id,
|
||||
body_def_id,
|
||||
&mut err,
|
||||
true,
|
||||
) {
|
||||
@ -1073,7 +1062,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
self.report_similar_impl_candidates(
|
||||
impl_candidates,
|
||||
trait_ref,
|
||||
body_hir_id,
|
||||
body_def_id,
|
||||
&mut err,
|
||||
true,
|
||||
);
|
||||
@ -1494,11 +1483,7 @@ trait InferCtxtPrivExt<'tcx> {
|
||||
// `error` occurring implies that `cond` occurs.
|
||||
fn error_implies(&self, cond: ty::Predicate<'tcx>, error: ty::Predicate<'tcx>) -> bool;
|
||||
|
||||
fn report_fulfillment_error(
|
||||
&self,
|
||||
error: &FulfillmentError<'tcx>,
|
||||
body_id: Option<hir::BodyId>,
|
||||
);
|
||||
fn report_fulfillment_error(&self, error: &FulfillmentError<'tcx>);
|
||||
|
||||
fn report_projection_error(
|
||||
&self,
|
||||
@ -1531,7 +1516,7 @@ trait InferCtxtPrivExt<'tcx> {
|
||||
&self,
|
||||
impl_candidates: Vec<ImplCandidate<'tcx>>,
|
||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
body_id: hir::HirId,
|
||||
body_def_id: LocalDefId,
|
||||
err: &mut Diagnostic,
|
||||
other: bool,
|
||||
) -> bool;
|
||||
@ -1561,11 +1546,7 @@ trait InferCtxtPrivExt<'tcx> {
|
||||
trait_ref_and_ty: ty::Binder<'tcx, (ty::TraitPredicate<'tcx>, Ty<'tcx>)>,
|
||||
) -> PredicateObligation<'tcx>;
|
||||
|
||||
fn maybe_report_ambiguity(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
body_id: Option<hir::BodyId>,
|
||||
);
|
||||
fn maybe_report_ambiguity(&self, obligation: &PredicateObligation<'tcx>);
|
||||
|
||||
fn predicate_can_apply(
|
||||
&self,
|
||||
@ -1647,11 +1628,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
}
|
||||
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn report_fulfillment_error(
|
||||
&self,
|
||||
error: &FulfillmentError<'tcx>,
|
||||
body_id: Option<hir::BodyId>,
|
||||
) {
|
||||
fn report_fulfillment_error(&self, error: &FulfillmentError<'tcx>) {
|
||||
match error.code {
|
||||
FulfillmentErrorCode::CodeSelectionError(ref selection_error) => {
|
||||
self.report_selection_error(
|
||||
@ -1664,7 +1641,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
self.report_projection_error(&error.obligation, e);
|
||||
}
|
||||
FulfillmentErrorCode::CodeAmbiguity => {
|
||||
self.maybe_report_ambiguity(&error.obligation, body_id);
|
||||
self.maybe_report_ambiguity(&error.obligation);
|
||||
}
|
||||
FulfillmentErrorCode::CodeSubtypeError(ref expected_found, ref err) => {
|
||||
self.report_mismatched_types(
|
||||
@ -2029,7 +2006,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
&self,
|
||||
impl_candidates: Vec<ImplCandidate<'tcx>>,
|
||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
body_id: hir::HirId,
|
||||
body_def_id: LocalDefId,
|
||||
err: &mut Diagnostic,
|
||||
other: bool,
|
||||
) -> bool {
|
||||
@ -2120,9 +2097,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
// FIXME(compiler-errors): This could be generalized, both to
|
||||
// be more granular, and probably look past other `#[fundamental]`
|
||||
// types, too.
|
||||
self.tcx
|
||||
.visibility(def.did())
|
||||
.is_accessible_from(body_id.owner.def_id, self.tcx)
|
||||
self.tcx.visibility(def.did()).is_accessible_from(body_def_id, self.tcx)
|
||||
} else {
|
||||
true
|
||||
}
|
||||
@ -2231,11 +2206,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
}
|
||||
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn maybe_report_ambiguity(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
body_id: Option<hir::BodyId>,
|
||||
) {
|
||||
fn maybe_report_ambiguity(&self, obligation: &PredicateObligation<'tcx>) {
|
||||
// Unable to successfully determine, probably means
|
||||
// insufficient type information, but could mean
|
||||
// ambiguous impls. The latter *ought* to be a
|
||||
@ -2277,7 +2248,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
if self.tcx.lang_items().sized_trait() == Some(trait_ref.def_id()) {
|
||||
if let None = self.tainted_by_errors() {
|
||||
self.emit_inference_failure_err(
|
||||
body_id,
|
||||
obligation.cause.body_id,
|
||||
span,
|
||||
trait_ref.self_ty().skip_binder().into(),
|
||||
ErrorCode::E0282,
|
||||
@ -2304,7 +2275,13 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
let subst = data.trait_ref.substs.iter().find(|s| s.has_non_region_infer());
|
||||
|
||||
let mut err = if let Some(subst) = subst {
|
||||
self.emit_inference_failure_err(body_id, span, subst, ErrorCode::E0283, true)
|
||||
self.emit_inference_failure_err(
|
||||
obligation.cause.body_id,
|
||||
span,
|
||||
subst,
|
||||
ErrorCode::E0283,
|
||||
true,
|
||||
)
|
||||
} else {
|
||||
struct_span_err!(
|
||||
self.tcx.sess,
|
||||
@ -2348,12 +2325,10 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
predicate.to_opt_poly_trait_pred().unwrap(),
|
||||
);
|
||||
if impl_candidates.len() < 10 {
|
||||
let hir =
|
||||
self.tcx.hir().local_def_id_to_hir_id(obligation.cause.body_id);
|
||||
self.report_similar_impl_candidates(
|
||||
impl_candidates,
|
||||
trait_ref,
|
||||
body_id.map(|id| id.hir_id).unwrap_or(hir),
|
||||
obligation.cause.body_id,
|
||||
&mut err,
|
||||
false,
|
||||
);
|
||||
@ -2375,9 +2350,9 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
self.suggest_fully_qualified_path(&mut err, def_id, span, trait_ref.def_id());
|
||||
}
|
||||
|
||||
if let (Some(body_id), Some(ty::subst::GenericArgKind::Type(_))) =
|
||||
(body_id, subst.map(|subst| subst.unpack()))
|
||||
if let Some(ty::subst::GenericArgKind::Type(_)) = subst.map(|subst| subst.unpack())
|
||||
{
|
||||
let body_id = self.tcx.hir().body_owned_by(obligation.cause.body_id);
|
||||
let mut expr_finder = FindExprBySpan::new(span);
|
||||
expr_finder.visit_expr(&self.tcx.hir().body(body_id).value);
|
||||
|
||||
@ -2473,7 +2448,13 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
self.emit_inference_failure_err(body_id, span, arg, ErrorCode::E0282, false)
|
||||
self.emit_inference_failure_err(
|
||||
obligation.cause.body_id,
|
||||
span,
|
||||
arg,
|
||||
ErrorCode::E0282,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
ty::PredicateKind::Subtype(data) => {
|
||||
@ -2487,7 +2468,13 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
let SubtypePredicate { a_is_expected: _, a, b } = data;
|
||||
// both must be type variables, or the other would've been instantiated
|
||||
assert!(a.is_ty_var() && b.is_ty_var());
|
||||
self.emit_inference_failure_err(body_id, span, a.into(), ErrorCode::E0282, true)
|
||||
self.emit_inference_failure_err(
|
||||
obligation.cause.body_id,
|
||||
span,
|
||||
a.into(),
|
||||
ErrorCode::E0282,
|
||||
true,
|
||||
)
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::Projection(data)) => {
|
||||
if predicate.references_error() || self.tainted_by_errors().is_some() {
|
||||
@ -2501,7 +2488,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
.find(|g| g.has_non_region_infer());
|
||||
if let Some(subst) = subst {
|
||||
let mut err = self.emit_inference_failure_err(
|
||||
body_id,
|
||||
obligation.cause.body_id,
|
||||
span,
|
||||
subst,
|
||||
ErrorCode::E0284,
|
||||
@ -2530,7 +2517,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
let subst = data.walk().find(|g| g.is_non_region_infer());
|
||||
if let Some(subst) = subst {
|
||||
let err = self.emit_inference_failure_err(
|
||||
body_id,
|
||||
obligation.cause.body_id,
|
||||
span,
|
||||
subst,
|
||||
ErrorCode::E0284,
|
||||
|
@ -210,7 +210,7 @@ fn do_normalize_predicates<'tcx>(
|
||||
let predicates = match fully_normalize(&infcx, cause, elaborated_env, predicates) {
|
||||
Ok(predicates) => predicates,
|
||||
Err(errors) => {
|
||||
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors, None);
|
||||
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
|
||||
return Err(reported);
|
||||
}
|
||||
};
|
||||
|
@ -172,7 +172,18 @@ impl_from! { f32, f64, #[stable(feature = "lossless_float_conv", since = "1.6.0"
|
||||
#[stable(feature = "float_from_bool", since = "1.68.0")]
|
||||
#[rustc_const_unstable(feature = "const_num_from_num", issue = "87852")]
|
||||
impl const From<bool> for f32 {
|
||||
/// Converts `bool` to `f32` losslessly.
|
||||
/// Converts `bool` to `f32` losslessly. The resulting value is positive
|
||||
/// `0.0` for `false` and `1.0` for `true` values.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```
|
||||
/// let x: f32 = false.into();
|
||||
/// assert_eq!(x, 0.0);
|
||||
/// assert!(x.is_sign_positive());
|
||||
///
|
||||
/// let y: f32 = true.into();
|
||||
/// assert_eq!(y, 1.0);
|
||||
/// ```
|
||||
#[inline]
|
||||
fn from(small: bool) -> Self {
|
||||
small as u8 as Self
|
||||
@ -181,7 +192,18 @@ impl const From<bool> for f32 {
|
||||
#[stable(feature = "float_from_bool", since = "1.68.0")]
|
||||
#[rustc_const_unstable(feature = "const_num_from_num", issue = "87852")]
|
||||
impl const From<bool> for f64 {
|
||||
/// Converts `bool` to `f64` losslessly.
|
||||
/// Converts `bool` to `f64` losslessly. The resulting value is positive
|
||||
/// `0.0` for `false` and `1.0` for `true` values.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```
|
||||
/// let x: f64 = false.into();
|
||||
/// assert_eq!(x, 0.0);
|
||||
/// assert!(x.is_sign_positive());
|
||||
///
|
||||
/// let y: f64 = true.into();
|
||||
/// assert_eq!(y, 1.0);
|
||||
/// ```
|
||||
#[inline]
|
||||
fn from(small: bool) -> Self {
|
||||
small as u8 as Self
|
||||
|
@ -61,14 +61,14 @@ impl<T: ?Sized> *const T {
|
||||
|
||||
/// Use the pointer value in a new pointer of another type.
|
||||
///
|
||||
/// In case `val` is a (fat) pointer to an unsized type, this operation
|
||||
/// In case `meta` is a (fat) pointer to an unsized type, this operation
|
||||
/// will ignore the pointer part, whereas for (thin) pointers to sized
|
||||
/// types, this has the same effect as a simple cast.
|
||||
///
|
||||
/// The resulting pointer will have provenance of `self`, i.e., for a fat
|
||||
/// pointer, this operation is semantically the same as creating a new
|
||||
/// fat pointer with the data pointer value of `self` but the metadata of
|
||||
/// `val`.
|
||||
/// `meta`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -691,7 +691,7 @@ where
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
#[unstable(feature = "ptr_from_ref", issue = "106116")]
|
||||
pub fn from_ref<T: ?Sized>(r: &T) -> *const T {
|
||||
pub const fn from_ref<T: ?Sized>(r: &T) -> *const T {
|
||||
r
|
||||
}
|
||||
|
||||
@ -702,7 +702,7 @@ pub fn from_ref<T: ?Sized>(r: &T) -> *const T {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
#[unstable(feature = "ptr_from_ref", issue = "106116")]
|
||||
pub fn from_mut<T: ?Sized>(r: &mut T) -> *mut T {
|
||||
pub const fn from_mut<T: ?Sized>(r: &mut T) -> *mut T {
|
||||
r
|
||||
}
|
||||
|
||||
|
@ -60,14 +60,14 @@ impl<T: ?Sized> *mut T {
|
||||
|
||||
/// Use the pointer value in a new pointer of another type.
|
||||
///
|
||||
/// In case `val` is a (fat) pointer to an unsized type, this operation
|
||||
/// In case `meta` is a (fat) pointer to an unsized type, this operation
|
||||
/// will ignore the pointer part, whereas for (thin) pointers to sized
|
||||
/// types, this has the same effect as a simple cast.
|
||||
///
|
||||
/// The resulting pointer will have provenance of `self`, i.e., for a fat
|
||||
/// pointer, this operation is semantically the same as creating a new
|
||||
/// fat pointer with the data pointer value of `self` but the metadata of
|
||||
/// `val`.
|
||||
/// `meta`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -216,7 +216,7 @@ pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool {
|
||||
|
||||
/// Returns true if we're running in CI with modified LLVM (and thus can't download it)
|
||||
pub(crate) fn is_ci_llvm_modified(config: &Config) -> bool {
|
||||
CiEnv::is_ci() && {
|
||||
CiEnv::is_ci() && config.rust_info.is_managed_git_subrepository() && {
|
||||
// We assume we have access to git, so it's okay to unconditionally pass
|
||||
// `true` here.
|
||||
let llvm_sha = detect_llvm_sha(config, true);
|
||||
|
@ -224,6 +224,11 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
) -> bool {
|
||||
debug!("maybe_inline_local res: {:?}", res);
|
||||
|
||||
if renamed == Some(kw::Underscore) {
|
||||
// We never inline `_` reexports.
|
||||
return false;
|
||||
}
|
||||
|
||||
if self.cx.output_format.is_json() {
|
||||
return false;
|
||||
}
|
||||
@ -346,8 +351,8 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
self.visit_foreign_item_inner(item, None);
|
||||
}
|
||||
}
|
||||
// If we're inlining, skip private items or item reexported as "_".
|
||||
_ if self.inlining && (!is_pub || renamed == Some(kw::Underscore)) => {}
|
||||
// If we're inlining, skip private items.
|
||||
_ if self.inlining && !is_pub => {}
|
||||
hir::ItemKind::GlobalAsm(..) => {}
|
||||
hir::ItemKind::Use(_, hir::UseKind::ListStem) => {}
|
||||
hir::ItemKind::Use(path, kind) => {
|
||||
|
@ -4,9 +4,13 @@
|
||||
|
||||
// @has 'foo/index.html'
|
||||
// @has - '//*[@id="main-content"]' ''
|
||||
// We check that the only "h2" present is for "Bla".
|
||||
// @count - '//*[@id="main-content"]/h2' 1
|
||||
// We check that the only "h2" present are "Structs" (for "Bla") and "Re-exports".
|
||||
// @count - '//*[@id="main-content"]/h2' 2
|
||||
// @has - '//*[@id="main-content"]/h2' 'Structs'
|
||||
// @has - '//*[@id="main-content"]/h2' 'Re-exports'
|
||||
// The 3 re-exports.
|
||||
// @count - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 3
|
||||
// The public struct.
|
||||
// @count - '//*[@id="main-content"]//a[@class="struct"]' 1
|
||||
|
||||
mod ext {
|
||||
|
21
tests/rustdoc/issue-108931-anonymous-reexport.rs
Normal file
21
tests/rustdoc/issue-108931-anonymous-reexport.rs
Normal file
@ -0,0 +1,21 @@
|
||||
// Ensuring that anonymous re-exports are always inlined.
|
||||
|
||||
#![crate_name = "foo"]
|
||||
|
||||
pub mod foo {
|
||||
pub struct Foo;
|
||||
}
|
||||
|
||||
mod bar {
|
||||
pub struct Bar;
|
||||
}
|
||||
|
||||
// @has 'foo/index.html'
|
||||
// We check that the only "h2" present are "Re-exports" and "Modules".
|
||||
// @count - '//*[@id="main-content"]/h2' 2
|
||||
// @has - '//*[@id="main-content"]/h2' 'Re-exports'
|
||||
// @has - '//*[@id="main-content"]/h2' 'Modules'
|
||||
// @has - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 'pub use foo::Foo as _;'
|
||||
// @has - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 'pub use bar::Bar as _;'
|
||||
pub use foo::Foo as _;
|
||||
pub use bar::Bar as _;
|
@ -501,6 +501,7 @@ compiler-team-contributors = [
|
||||
"@TaKO8Ki",
|
||||
"@Nilstrieb",
|
||||
"@WaffleLapkin",
|
||||
"@b-naber",
|
||||
]
|
||||
compiler = [
|
||||
"compiler-team",
|
||||
|
Loading…
Reference in New Issue
Block a user