Skip to content

Commit 3eb8eb9

Browse files
committed
review comments
1 parent 562f496 commit 3eb8eb9

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/librustc_infer/infer/error_reporting/nice_region_error/named_anon_conflict.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
9292
.next()
9393
.is_some()
9494
{
95+
// If the failure is due to a `'static` requirement coming from a `dyn` or
96+
// `impl` Trait that *isn't* caused by `async fn` desugaring, handle this case
97+
// better in `static_impl_trait`.
9598
debug!("try_report_named_anon_conflict: impl Trait + 'static");
96-
// This is an `impl Trait` or `dyn Trait` return that evaluates de need of
97-
// `'static`. We handle this case better in `static_impl_trait`.
9899
return None;
99100
}
100101
}

src/librustc_infer/infer/error_reporting/nice_region_error/static_impl_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
2626
);
2727
let anon_reg_sup = self.tcx().is_suitable_region(sup_r)?;
2828
debug!("try_report_static_impl_trait: anon_reg_sup={:?}", anon_reg_sup);
29-
let fn_returns = self.tcx().return_type_impl_or_dyn_trait(anon_reg_sup.def_id);
29+
let fn_returns = self.tcx().return_type_impl_or_dyn_traits(anon_reg_sup.def_id);
3030
if fn_returns.is_empty() {
3131
return None;
3232
}

src/librustc_middle/ty/context.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,8 @@ impl<'tcx> TyCtxt<'tcx> {
14061406
})
14071407
}
14081408

1409-
pub fn return_type_impl_or_dyn_trait(&self, scope_def_id: DefId) -> Vec<&'tcx hir::Ty<'tcx>> {
1409+
/// Given a `DefId` for an `fn`, return all the `dyn` and `impl` traits in its return type.
1410+
pub fn return_type_impl_or_dyn_traits(&self, scope_def_id: DefId) -> Vec<&'tcx hir::Ty<'tcx>> {
14101411
let hir_id = self.hir().as_local_hir_id(scope_def_id.expect_local());
14111412
let hir_output = match self.hir().get(hir_id) {
14121413
Node::Item(hir::Item {

0 commit comments

Comments
 (0)