Skip to content

Commit 8ce334d

Browse files
committed
rustfmt
1 parent e340375 commit 8ce334d

File tree

1 file changed

+33
-26
lines changed

1 file changed

+33
-26
lines changed

src/librustc_trait_selection/traits/error_reporting/suggestions.rs

+33-26
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_hir as hir;
1010
use rustc_hir::def::DefKind;
1111
use rustc_hir::def_id::DefId;
1212
use rustc_hir::intravisit::Visitor;
13-
use rustc_hir::{GeneratorKind, AsyncGeneratorKind, Node};
13+
use rustc_hir::{AsyncGeneratorKind, GeneratorKind, Node};
1414
use rustc_middle::ty::TypeckTables;
1515
use rustc_middle::ty::{
1616
self, AdtKind, DefIdTree, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness,
@@ -1204,7 +1204,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
12041204
}
12051205
};
12061206

1207-
let generator_body = self.tcx
1207+
let generator_body = self
1208+
.tcx
12081209
.hir()
12091210
.as_local_hir_id(generator_did)
12101211
.and_then(|hir_id| self.tcx.hir().maybe_body_owned_by(hir_id))
@@ -1246,7 +1247,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
12461247
})
12471248
.map(|cause| {
12481249
// Check to see if any awaited expressions have the target type.
1249-
let from_awaited_ty = visitor.awaits.into_iter()
1250+
let from_awaited_ty = visitor
1251+
.awaits
1252+
.into_iter()
12501253
.map(|id| self.tcx.hir().expect_expr(id))
12511254
.find(|expr| {
12521255
let ty = tables.expr_ty_adjusted(&expr);
@@ -1335,29 +1338,32 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
13351338
err.clear_code();
13361339
err.set_primary_message(format!(
13371340
"{} cannot be {} between threads safely",
1338-
future_or_generator,
1339-
trait_verb
1341+
future_or_generator, trait_verb
13401342
));
13411343

13421344
let original_span = err.span.primary_span().unwrap();
13431345
let mut span = MultiSpan::from_span(original_span);
13441346

13451347
let message = outer_generator
1346-
.and_then(|generator_did| Some(
1347-
match self.tcx.generator_kind(generator_did).unwrap() {
1348+
.and_then(|generator_did| {
1349+
Some(match self.tcx.generator_kind(generator_did).unwrap() {
13481350
GeneratorKind::Gen => format!("generator is not {}", trait_name),
1349-
GeneratorKind::Async(AsyncGeneratorKind::Fn) =>
1350-
self.tcx.parent(generator_did)
1351-
.and_then(|parent_did| hir.as_local_hir_id(parent_did))
1352-
.and_then(|parent_hir_id| hir.opt_name(parent_hir_id))
1353-
.map(|name| format!("future returned by `{}` is not {}",
1354-
name, trait_name))?,
1355-
GeneratorKind::Async(AsyncGeneratorKind::Block) =>
1356-
format!("future created by async block is not {}", trait_name),
1357-
GeneratorKind::Async(AsyncGeneratorKind::Closure) =>
1358-
format!("future created by async closure is not {}", trait_name),
1359-
}
1360-
))
1351+
GeneratorKind::Async(AsyncGeneratorKind::Fn) => self
1352+
.tcx
1353+
.parent(generator_did)
1354+
.and_then(|parent_did| hir.as_local_hir_id(parent_did))
1355+
.and_then(|parent_hir_id| hir.opt_name(parent_hir_id))
1356+
.map(|name| {
1357+
format!("future returned by `{}` is not {}", name, trait_name)
1358+
})?,
1359+
GeneratorKind::Async(AsyncGeneratorKind::Block) => {
1360+
format!("future created by async block is not {}", trait_name)
1361+
}
1362+
GeneratorKind::Async(AsyncGeneratorKind::Closure) => {
1363+
format!("future created by async closure is not {}", trait_name)
1364+
}
1365+
})
1366+
})
13611367
.unwrap_or_else(|| format!("{} is not {}", future_or_generator, trait_name));
13621368

13631369
span.push_span_label(original_span, message);
@@ -1384,10 +1390,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
13841390
if let Some(await_span) = from_awaited_ty {
13851391
// The type causing this obligation is one being awaited at await_span.
13861392
let mut span = MultiSpan::from_span(await_span);
1387-
span.push_span_label(
1388-
await_span,
1389-
"await occurs here".to_string(),
1390-
);
1393+
span.push_span_label(await_span, "await occurs here".to_string());
13911394

13921395
if target_span != await_span {
13931396
push_target_span(&mut span);
@@ -1422,7 +1425,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
14221425

14231426
err.span_note(
14241427
span,
1425-
&format!("{} as this value is used across an {}", trait_explanation, await_or_yield),
1428+
&format!(
1429+
"{} as this value is used across an {}",
1430+
trait_explanation, await_or_yield
1431+
),
14261432
);
14271433
}
14281434

@@ -1784,8 +1790,9 @@ impl<'v> Visitor<'v> for AwaitsVisitor {
17841790

17851791
fn visit_expr(&mut self, ex: &'v hir::Expr<'v>) {
17861792
match ex.kind {
1787-
hir::ExprKind::Yield(_, hir::YieldSource::Await { expr: Some(id) }) =>
1788-
self.awaits.push(id),
1793+
hir::ExprKind::Yield(_, hir::YieldSource::Await { expr: Some(id) }) => {
1794+
self.awaits.push(id)
1795+
}
17891796
_ => (),
17901797
}
17911798
hir::intravisit::walk_expr(self, ex)

0 commit comments

Comments
 (0)