Skip to content

Commit ad46af2

Browse files
committedJan 14, 2022
Auto merge of #92883 - matthiaskrgr:rollup-uoudywx, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #92045 (Don't fall back to crate-level opaque type definitions.) - #92381 (Suggest `return`ing tail expressions in async functions) - #92768 (Partially stabilize `maybe_uninit_extra`) - #92810 (Deduplicate box deref and regular deref suggestions) - #92818 (Update documentation for doc_cfg feature) - #92840 (Fix some lints documentation) - #92849 (Clippyup) - #92854 (Use the updated Rust logo in rustdoc) - #92864 (Fix a missing dot in the main item heading) Failed merges: - #92838 (Clean up some links in RELEASES) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 02c9e73 + 2ae4afd commit ad46af2

File tree

251 files changed

+3535
-1783
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

251 files changed

+3535
-1783
lines changed
 

‎Cargo.lock

+6-3
Original file line numberDiff line numberDiff line change
@@ -639,14 +639,15 @@ dependencies = [
639639

640640
[[package]]
641641
name = "clippy"
642-
version = "0.1.59"
642+
version = "0.1.60"
643643
dependencies = [
644644
"cargo_metadata 0.14.0",
645645
"clippy_lints",
646646
"clippy_utils",
647647
"compiletest_rs",
648648
"derive-new",
649649
"filetime",
650+
"futures 0.3.12",
650651
"if_chain",
651652
"itertools 0.10.1",
652653
"parking_lot",
@@ -659,6 +660,7 @@ dependencies = [
659660
"syn",
660661
"tempfile",
661662
"tester",
663+
"tokio",
662664
]
663665

664666
[[package]]
@@ -678,7 +680,7 @@ dependencies = [
678680

679681
[[package]]
680682
name = "clippy_lints"
681-
version = "0.1.59"
683+
version = "0.1.60"
682684
dependencies = [
683685
"cargo_metadata 0.14.0",
684686
"clippy_utils",
@@ -699,8 +701,9 @@ dependencies = [
699701

700702
[[package]]
701703
name = "clippy_utils"
702-
version = "0.1.59"
704+
version = "0.1.60"
703705
dependencies = [
706+
"arrayvec",
704707
"if_chain",
705708
"rustc-semver",
706709
]

‎compiler/rustc_infer/src/infer/mod.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub(crate) use self::undo_log::{InferCtxtUndoLogs, Snapshot, UndoLog};
1010

1111
use crate::traits::{self, ObligationCause, PredicateObligations, TraitEngine};
1212

13-
use hir::def_id::CRATE_DEF_ID;
1413
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1514
use rustc_data_structures::sync::Lrc;
1615
use rustc_data_structures::undo_log::Rollback;
@@ -291,7 +290,12 @@ pub struct InferCtxt<'a, 'tcx> {
291290

292291
/// The `DefId` of the item in whose context we are performing inference or typeck.
293292
/// It is used to check whether an opaque type use is a defining use.
294-
pub defining_use_anchor: LocalDefId,
293+
///
294+
/// If it is `None`, we can't resolve opaque types here and need to bubble up
295+
/// the obligation. This frequently happens for
296+
/// short lived InferCtxt within queries. The opaque type obligations are forwarded
297+
/// to the outside until the end up in an `InferCtxt` for typeck or borrowck.
298+
pub defining_use_anchor: Option<LocalDefId>,
295299

296300
/// During type-checking/inference of a body, `in_progress_typeck_results`
297301
/// contains a reference to the typeck results being built up, which are
@@ -547,7 +551,7 @@ impl<'tcx> fmt::Display for FixupError<'tcx> {
547551
pub struct InferCtxtBuilder<'tcx> {
548552
tcx: TyCtxt<'tcx>,
549553
fresh_typeck_results: Option<RefCell<ty::TypeckResults<'tcx>>>,
550-
defining_use_anchor: LocalDefId,
554+
defining_use_anchor: Option<LocalDefId>,
551555
}
552556

553557
pub trait TyCtxtInferExt<'tcx> {
@@ -556,11 +560,7 @@ pub trait TyCtxtInferExt<'tcx> {
556560

557561
impl<'tcx> TyCtxtInferExt<'tcx> for TyCtxt<'tcx> {
558562
fn infer_ctxt(self) -> InferCtxtBuilder<'tcx> {
559-
InferCtxtBuilder {
560-
tcx: self,
561-
defining_use_anchor: CRATE_DEF_ID,
562-
fresh_typeck_results: None,
563-
}
563+
InferCtxtBuilder { tcx: self, defining_use_anchor: None, fresh_typeck_results: None }
564564
}
565565
}
566566

@@ -580,7 +580,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
580580
/// (via `with_fresh_in_progress_typeck_results`) and for the inference context used
581581
/// in mir borrowck.
582582
pub fn with_opaque_type_inference(mut self, defining_use_anchor: LocalDefId) -> Self {
583-
self.defining_use_anchor = defining_use_anchor;
583+
self.defining_use_anchor = Some(defining_use_anchor);
584584
self
585585
}
586586

0 commit comments

Comments
 (0)
Please sign in to comment.