diff options
| author | bors <bors@rust-lang.org> | 2022-12-24 09:41:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-12-24 09:41:11 +0000 |
| commit | d23554fae855d884761d549cd6ee6537450b0f3c (patch) | |
| tree | b44bd3e79fa5019f0e8648737e71c432bc784188 /compiler/rustc_infer/src | |
| parent | 245357f61939d2b6d15f8c6b15f7026396f95871 (diff) | |
| parent | e52e0d855799fe651922be4a038fe84fe9009c72 (diff) | |
| download | rust-d23554fae855d884761d549cd6ee6537450b0f3c.tar.gz rust-d23554fae855d884761d549cd6ee6537450b0f3c.zip | |
Auto merge of #2738 - RalfJung:rustup, r=RalfJung
Rustup
Diffstat (limited to 'compiler/rustc_infer/src')
10 files changed, 33 insertions, 39 deletions
diff --git a/compiler/rustc_infer/src/infer/canonical/query_response.rs b/compiler/rustc_infer/src/infer/canonical/query_response.rs index 996b1c40e3f..a722613e331 100644 --- a/compiler/rustc_infer/src/infer/canonical/query_response.rs +++ b/compiler/rustc_infer/src/infer/canonical/query_response.rs @@ -151,7 +151,11 @@ impl<'tcx> InferCtxt<'tcx> { }) } - fn take_opaque_types_for_query_response(&self) -> Vec<(Ty<'tcx>, Ty<'tcx>)> { + /// FIXME: This method should only be used for canonical queries and therefore be private. + /// + /// As the new solver does canonicalization slightly differently, this is also used there + /// for now. This should hopefully change fairly soon. + pub fn take_opaque_types_for_query_response(&self) -> Vec<(Ty<'tcx>, Ty<'tcx>)> { self.inner .borrow_mut() .opaque_type_storage diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 397fa43175f..96a976fb89e 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -184,7 +184,7 @@ fn msg_span_from_early_bound_and_free_regions<'tcx>( let text = if br.has_name() { format!("the lifetime `{}` as defined here", br.name) } else { - format!("the anonymous lifetime as defined here") + "the anonymous lifetime as defined here".to_string() }; (text, sp) } @@ -203,7 +203,7 @@ fn msg_span_from_early_bound_and_free_regions<'tcx>( sp = param.span; } let text = if name == kw::UnderscoreLifetime { - format!("the anonymous lifetime as defined here") + "the anonymous lifetime as defined here".to_string() } else { format!("the lifetime `{}` as defined here", name) }; @@ -2199,10 +2199,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { ); } - fn binding_suggestion<'tcx, S: fmt::Display>( + fn binding_suggestion<S: fmt::Display>( err: &mut Diagnostic, type_param_span: Option<(Span, bool)>, - bound_kind: GenericKind<'tcx>, + bound_kind: GenericKind<'_>, sub: S, add_lt_sugg: Option<(Span, String)>, ) { diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_relation.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_relation.rs index c42240f2172..9534bce54ef 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_relation.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_relation.rs @@ -44,7 +44,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> { ); } (Some(sub_span), Some(sup_span), _, Some(sup_symbol)) => { - err.span_note(sub_span, format!("the lifetime defined here...")); + err.span_note(sub_span, "the lifetime defined here..."); err.span_note( sup_span, format!("...must outlive the lifetime `{sup_symbol}` defined here"), @@ -55,17 +55,11 @@ impl<'tcx> NiceRegionError<'_, 'tcx> { sub_span, format!("the lifetime `{sub_symbol}` defined here..."), ); - err.span_note( - sup_span, - format!("...must outlive the lifetime defined here"), - ); + err.span_note(sup_span, "...must outlive the lifetime defined here"); } (Some(sub_span), Some(sup_span), _, _) => { - err.span_note(sub_span, format!("the lifetime defined here...")); - err.span_note( - sup_span, - format!("...must outlive the lifetime defined here"), - ); + err.span_note(sub_span, "the lifetime defined here..."); + err.span_note(sup_span, "...must outlive the lifetime defined here"); } _ => {} } diff --git a/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs b/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs index ba990acfe6f..da2c6fbc05f 100644 --- a/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs +++ b/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs @@ -488,7 +488,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { // If this empty region is from a universe that can // name the placeholder, then the placeholder is // larger; otherwise, the only ancestor is `'static`. - if a_ui.can_name(placeholder.universe) { true } else { false } + return a_ui.can_name(placeholder.universe); } } } diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 996148a7090..a9ef91db059 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -1693,7 +1693,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { &self, generic_param_scope: LocalDefId, outlives_env: &OutlivesEnvironment<'tcx>, - ) { + ) -> Option<ErrorGuaranteed> { let errors = self.resolve_regions(outlives_env); if let None = self.tainted_by_errors() { @@ -1704,6 +1704,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { // errors from silly ones. self.report_region_errors(generic_param_scope, &errors); } + + (!errors.is_empty()).then(|| { + self.tcx.sess.delay_span_bug(rustc_span::DUMMY_SP, "error should have been emitted") + }) } // [Note-Type-error-reporting] @@ -1920,7 +1924,7 @@ impl<'tcx> TypeTrace<'tcx> { ) -> TypeTrace<'tcx> { TypeTrace { cause: cause.clone(), - values: PolyTraitRefs(ExpectedFound::new(a_is_expected, a.into(), b.into())), + values: PolyTraitRefs(ExpectedFound::new(a_is_expected, a, b)), } } diff --git a/compiler/rustc_infer/src/infer/outlives/obligations.rs b/compiler/rustc_infer/src/infer/outlives/obligations.rs index ccae7165d80..47bd1564f08 100644 --- a/compiler/rustc_infer/src/infer/outlives/obligations.rs +++ b/compiler/rustc_infer/src/infer/outlives/obligations.rs @@ -68,6 +68,7 @@ use crate::infer::{ }; use crate::traits::{ObligationCause, ObligationCauseCode}; use rustc_data_structures::undo_log::UndoLogs; +use rustc_errors::ErrorGuaranteed; use rustc_hir::def_id::DefId; use rustc_hir::def_id::LocalDefId; use rustc_middle::mir::ConstraintCategory; @@ -177,7 +178,7 @@ impl<'tcx> InferCtxt<'tcx> { &self, generic_param_scope: LocalDefId, outlives_env: &OutlivesEnvironment<'tcx>, - ) { + ) -> Option<ErrorGuaranteed> { self.process_registered_region_obligations( outlives_env.region_bound_pairs(), outlives_env.param_env, diff --git a/compiler/rustc_infer/src/infer/outlives/verify.rs b/compiler/rustc_infer/src/infer/outlives/verify.rs index 136da4a3cb1..40bbec8ddd0 100644 --- a/compiler/rustc_infer/src/infer/outlives/verify.rs +++ b/compiler/rustc_infer/src/infer/outlives/verify.rs @@ -5,7 +5,7 @@ use crate::infer::{GenericKind, VerifyBound}; use rustc_data_structures::sso::SsoHashSet; use rustc_hir::def_id::DefId; use rustc_middle::ty::GenericArg; -use rustc_middle::ty::{self, EarlyBinder, OutlivesPredicate, SubstsRef, Ty, TyCtxt}; +use rustc_middle::ty::{self, OutlivesPredicate, SubstsRef, Ty, TyCtxt}; use smallvec::smallvec; @@ -304,14 +304,13 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> { substs: SubstsRef<'tcx>, ) -> impl Iterator<Item = ty::Region<'tcx>> { let tcx = self.tcx; - let bounds = tcx.item_bounds(def_id); - trace!("{:#?}", bounds); + let bounds = tcx.bound_item_bounds(def_id); + trace!("{:#?}", bounds.0); bounds - .into_iter() + .subst_iter(tcx, substs) .filter_map(|p| p.to_opt_type_outlives()) .filter_map(|p| p.no_bound_vars()) - .map(|b| b.1) - .map(move |r| EarlyBinder(r).subst(tcx, substs)) + .map(|OutlivesPredicate(_, r)| r) } /// Searches through a predicate list for a predicate `T: 'a`. diff --git a/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs b/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs index 22b4bbb17d4..c46edc33ff4 100644 --- a/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs +++ b/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs @@ -357,15 +357,13 @@ impl<'tcx> SccUniverse<'tcx> { } rustc_index::newtype_index! { - struct LeakCheckNode { - DEBUG_FORMAT = "LeakCheckNode({})" - } + #[debug_format = "LeakCheckNode({})"] + struct LeakCheckNode {} } rustc_index::newtype_index! { - struct LeakCheckScc { - DEBUG_FORMAT = "LeakCheckScc({})" - } + #[debug_format = "LeakCheckScc({})"] + struct LeakCheckScc {} } /// Represents the graph of constraints. For each `R1: R2` constraint we create diff --git a/compiler/rustc_infer/src/infer/undo_log.rs b/compiler/rustc_infer/src/infer/undo_log.rs index 611961ab1cc..955c54e8515 100644 --- a/compiler/rustc_infer/src/infer/undo_log.rs +++ b/compiler/rustc_infer/src/infer/undo_log.rs @@ -87,18 +87,12 @@ impl<'tcx> Rollback<UndoLog<'tcx>> for InferCtxtInner<'tcx> { /// The combined undo log for all the various unification tables. For each change to the storage /// for any kind of inference variable, we record an UndoLog entry in the vector here. -#[derive(Clone)] +#[derive(Clone, Default)] pub(crate) struct InferCtxtUndoLogs<'tcx> { logs: Vec<UndoLog<'tcx>>, num_open_snapshots: usize, } -impl Default for InferCtxtUndoLogs<'_> { - fn default() -> Self { - Self { logs: Default::default(), num_open_snapshots: Default::default() } - } -} - /// The UndoLogs trait defines how we undo a particular kind of action (of type T). We can undo any /// action that is convertible into an UndoLog (per the From impls above). impl<'tcx, T> UndoLogs<T> for InferCtxtUndoLogs<'tcx> diff --git a/compiler/rustc_infer/src/traits/project.rs b/compiler/rustc_infer/src/traits/project.rs index aade57be9fe..ac455055b43 100644 --- a/compiler/rustc_infer/src/traits/project.rs +++ b/compiler/rustc_infer/src/traits/project.rs @@ -200,7 +200,7 @@ impl<'tcx> ProjectionCache<'_, 'tcx> { pub fn complete(&mut self, key: ProjectionCacheKey<'tcx>, result: EvaluationResult) { let mut map = self.map(); match map.get(&key) { - Some(&ProjectionCacheEntry::NormalizedTy { ref ty, complete: _ }) => { + Some(ProjectionCacheEntry::NormalizedTy { ty, complete: _ }) => { info!("ProjectionCacheEntry::complete({:?}) - completing {:?}", key, ty); let mut ty = ty.clone(); if result.must_apply_considering_regions() { |
