8000 Rollup of 6 pull requests by Centril · Pull Request #71037 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 6 pull requests #71037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 28 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4c8bf50
Remove some dead code.
nnethercote Apr 1, 2020
72a28e8
Improve `ModuleConfig` initialization.
nnethercote Apr 1, 2020
5131c69
Rename `modules_config` as `regular_config`.
nnethercote Apr 1, 2020
b0ec96c
Use inner/outer generator naming instead of first/last
tmandry Mar 25, 2020
0c97636
Add test for #68112 (existing output)
tmandry Mar 25, 2020
ce8331f
Improve span label
tmandry Mar 25, 2020
b731478
Don't annotate type when type is opaque
tmandry Mar 25, 2020
455537e
Use "generator" instead of "future" when appropriate
tmandry Mar 25, 2020
9862bbe
Use clearer message when obligation is caused by await expr
tmandry Apr 2, 2020
cd501a6
Don't double-annotate the same Span
tmandry Apr 2, 2020
4687b8d
rustfmt
tmandry Apr 2, 2020
9aeaaa2
Include type info when available for awaited expr
tmandry Apr 2, 2020
9dba024
Fix style nits
tmandry Apr 8, 2020
889cfe1
Incorporate feedback into diagnostics
tmandry Apr 8, 2020
5aac1f3
Update stdarch submodule to use llvm_asm! instead of asm!
Amanieu Apr 10, 2020
921579c
Add or_insert_with_key to Entry of HashMap/BTreeMap
ChaiTRex Apr 10, 2020
7810237
Fixed doc tests for added methods
ChaiTRex Apr 10, 2020
34d608d
Update parking_lot dependency to avoid use of deprecated asm!
Amanieu Apr 10, 2020
43ee31f
Deprecate the asm! macro
Amanieu Apr 10, 2020
7f4048c
Store UNICODE_VERSION as a tuple
pyfisch Apr 11, 2020
b78ff99
Use write!-style syntax for MIR assert terminator
robojumper Apr 11, 2020
db0c39f
Change issue number to point to tracking issue
ChaiTRex Apr 11, 2020
8f98e5d
Rollup merge of #70644 - nnethercote:clean-up-ModuleConfig-init, r=Ma…
Centril Apr 11, 2020
6bad3ee
Rollup merge of #70679 - tmandry:issue-68112, r=nikomatsakis
Centril Apr 11, 2020
b90d0b3
Rollup merge of #70996 - ChaiTRex:master, r=Amanieu
Centril Apr 11, 2020
c8523b7
Rollup merge of #71007 - Amanieu:deprecate_asm, r=Mark-Simulacrum
Centril Apr 11, 2020
6fe2171
Rollup merge of #71020 - pyfisch:unicode-version, r=sfackler
Centril Apr 11, 2020
c6a6be0
Rollup merge of #71021 - robojumper:71000-mir-assert-syntax, r=jonas-…
Centril Apr 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rustfmt
  • Loading branch information
tmandry committed Apr 2, 2020
commit 4687b8d2d4504c8a2ae783c20b4e4dceed7aeadf
59 changes: 33 additions & 26 deletions src/librustc_trait_selection/traits/error_reporting/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::Visitor;
use rustc_hir::{GeneratorKind, AsyncGeneratorKind, Node};
use rustc_hir::{AsyncGeneratorKind, GeneratorKind, Node};
use rustc_middle::ty::TypeckTables;
use rustc_middle::ty::{
self, AdtKind, DefIdTree, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness,
Expand Down Expand Up @@ -1089,7 +1089,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
}
};

let generator_body = self.tcx
let generator_body = self
.tcx
.hir()
.as_local_hir_id(generator_did)
.and_then(|hir_id| self.tcx.hir().maybe_body_owned_by(hir_id))
Expand Down Expand Up @@ -1131,7 +1132,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
})
.map(|cause| {
// Check to see if any awaited expressions have the target type.
let from_awaited_ty = visitor.awaits.into_iter()
let from_awaited_ty = visitor
.awaits
.into_iter()
.map(|id| self.tcx.hir().expect_expr(id))
.find(|expr| {
let ty = tables.expr_ty_adjusted(&expr);
Expand Down Expand Up @@ -1220,29 +1223,32 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
err.clear_code();
err.set_primary_message(format!(
"{} cannot be {} between threads safely",
future_or_generator,
trait_verb
future_or_generator, trait_verb
));

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

let message = outer_generator
.and_then(|generator_did| Some(
match self.tcx.generator_kind(generator_did).unwrap() {
.and_then(|generator_did| {
Some(match self.tcx.generator_kind(generator_did).unwrap() {
GeneratorKind::Gen => format!("generator is not {}", trait_name),
GeneratorKind::Async(AsyncGeneratorKind::Fn) =>
self.tcx.parent(generator_did)
.and_then(|parent_did| hir.as_local_hir_id(parent_did))
.and_then(|parent_hir_id| hir.opt_name(parent_hir_id))
.map(|name| format!("future returned by `{}` is not {}",
name, trait_name))?,
GeneratorKind::Async(AsyncGeneratorKind::Block) =>
format!("future created by async block is not {}", trait_name),
GeneratorKind::Async(AsyncGeneratorKind::Closure) =>
format!("future created by async closure is not {}", trait_name),
}
))
GeneratorKind::Async(AsyncGeneratorKind::Fn) => self
.tcx
.parent(generator_did)
.and_then(|parent_did| hir.as_local_hir_id(parent_did))
.and_then(|parent_hir_id| hir.opt_name(parent_hir_id))
.map(|name| {
format!("future returned by `{}` is not {}", name, trait_name)
})?,
GeneratorKind::Async(AsyncGeneratorKind::Block) => {
format!("future created by async block is not {}", trait_name)
}
GeneratorKind::Async(AsyncGeneratorKind::Closure) => {
format!("future created by async closure is not {}", trait_name)
}
})
})
.unwrap_or_else(|| format!("{} is not {}", future_or_generator, trait_name));

span.push_span_label(original_span, message);
Expand All @@ -1269,10 +1275,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
if let Some(await_span) = from_awaited_ty {
// The type causing this obligation is one being awaited at await_span.
let mut span = MultiSpan::from_span(await_span);
span.push_span_label(
await_span,
"await occurs here".to_string(),
);
span.push_span_label(await_span, "await occurs here".to_string());

if target_span != await_span {
push_target_span(&mut span);
Expand Down Expand Up @@ -1307,7 +1310,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {

err.span_note(
span,
&format!("{} as this value is used across an {}", trait_explanation, await_or_yield),
&format!(
"{} as this value is used across an {}",
trait_explanation, await_or_yield
),
);
}

Expand Down Expand Up @@ -1662,8 +1668,9 @@ impl<'v> Visitor<'v> for AwaitsVisitor {

fn visit_expr(&mut self, ex: &'v hir::Expr<'v>) {
match ex.kind {
hir::ExprKind::Yield(_, hir::YieldSource::Await { expr: Some(id) }) =>
self.awaits.push(id),
hir::ExprKind::Yield(_, hir::YieldSource::Await { expr: Some(id) }) => {
self.awaits.push(id)
}
_ => (),
}
hir::intravisit::walk_expr(self, ex)
Expand Down
0