mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Auto merge of #91945 - matthiaskrgr:rollup-jszf9zp, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #90939 (Tweak errors coming from `for`-loop, `?` and `.await` desugaring) - #91859 (Iterator::cycle() — document empty iterator special case) - #91868 (Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`) - #91870 (Revert setting a default for the MACOSX_DEPLOYMENT_TARGET env var for linking) - #91881 (Stabilize `iter::zip`) - #91882 (Remove `in_band_lifetimes` from `rustc_typeck`) - #91940 (Update cargo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
195e931b02
@ -276,7 +276,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cargo"
|
||||
version = "0.59.0"
|
||||
version = "0.60.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"atty",
|
||||
@ -419,7 +419,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cargo-util"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"core-foundation",
|
||||
@ -768,7 +768,7 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634"
|
||||
|
||||
[[package]]
|
||||
name = "crates-io"
|
||||
version = "0.33.0"
|
||||
version = "0.33.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"curl",
|
||||
|
@ -33,7 +33,6 @@
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![no_std]
|
||||
#![forbid(unsafe_code)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(nll)]
|
||||
|
||||
#[macro_use]
|
||||
|
@ -11,7 +11,6 @@
|
||||
#![feature(box_patterns)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(if_let_guard)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(label_break_value)]
|
||||
#![feature(nll)]
|
||||
#![feature(min_specialization)]
|
||||
|
@ -130,7 +130,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
hir::AsyncGeneratorKind::Block,
|
||||
|this| this.with_new_scopes(|this| this.lower_block_expr(block)),
|
||||
),
|
||||
ExprKind::Await(ref expr) => self.lower_expr_await(e.span, expr),
|
||||
ExprKind::Await(ref expr) => {
|
||||
let span = if expr.span.hi() < e.span.hi() {
|
||||
expr.span.shrink_to_hi().with_hi(e.span.hi())
|
||||
} else {
|
||||
// this is a recovered `await expr`
|
||||
e.span
|
||||
};
|
||||
self.lower_expr_await(span, expr)
|
||||
}
|
||||
ExprKind::Closure(
|
||||
capture_clause,
|
||||
asyncness,
|
||||
@ -479,8 +487,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
expr: &'hir hir::Expr<'hir>,
|
||||
overall_span: Span,
|
||||
) -> &'hir hir::Expr<'hir> {
|
||||
let constructor =
|
||||
self.arena.alloc(self.expr_lang_item_path(method_span, lang_item, ThinVec::new()));
|
||||
let constructor = self.arena.alloc(self.expr_lang_item_path(
|
||||
method_span,
|
||||
lang_item,
|
||||
ThinVec::new(),
|
||||
None,
|
||||
));
|
||||
self.expr_call(overall_span, constructor, std::slice::from_ref(expr))
|
||||
}
|
||||
|
||||
@ -584,8 +596,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
// `future::from_generator`:
|
||||
let unstable_span =
|
||||
self.mark_span_with_reason(DesugaringKind::Async, span, self.allow_gen_future.clone());
|
||||
let gen_future =
|
||||
self.expr_lang_item_path(unstable_span, hir::LangItem::FromGenerator, ThinVec::new());
|
||||
let gen_future = self.expr_lang_item_path(
|
||||
unstable_span,
|
||||
hir::LangItem::FromGenerator,
|
||||
ThinVec::new(),
|
||||
None,
|
||||
);
|
||||
|
||||
// `future::from_generator(generator)`:
|
||||
hir::ExprKind::Call(self.arena.alloc(gen_future), arena_vec![self; generator])
|
||||
@ -607,6 +623,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
/// }
|
||||
/// ```
|
||||
fn lower_expr_await(&mut self, await_span: Span, expr: &Expr) -> hir::ExprKind<'hir> {
|
||||
let dot_await_span = expr.span.shrink_to_hi().to(await_span);
|
||||
match self.generator_kind {
|
||||
Some(hir::GeneratorKind::Async(_)) => {}
|
||||
Some(hir::GeneratorKind::Gen) | None => {
|
||||
@ -623,13 +640,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
err.emit();
|
||||
}
|
||||
}
|
||||
let span = self.mark_span_with_reason(DesugaringKind::Await, await_span, None);
|
||||
let span = self.mark_span_with_reason(DesugaringKind::Await, dot_await_span, None);
|
||||
let gen_future_span = self.mark_span_with_reason(
|
||||
DesugaringKind::Await,
|
||||
await_span,
|
||||
self.allow_gen_future.clone(),
|
||||
);
|
||||
let expr = self.lower_expr_mut(expr);
|
||||
let expr_hir_id = expr.hir_id;
|
||||
|
||||
let pinned_ident = Ident::with_dummy_span(sym::pinned);
|
||||
let (pinned_pat, pinned_pat_hid) =
|
||||
@ -656,16 +674,19 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
span,
|
||||
hir::LangItem::PinNewUnchecked,
|
||||
arena_vec![self; ref_mut_pinned],
|
||||
Some(expr_hir_id),
|
||||
);
|
||||
let get_context = self.expr_call_lang_item_fn_mut(
|
||||
gen_future_span,
|
||||
hir::LangItem::GetContext,
|
||||
arena_vec![self; task_context],
|
||||
Some(expr_hir_id),
|
||||
);
|
||||
let call = self.expr_call_lang_item_fn(
|
||||
span,
|
||||
hir::LangItem::FuturePoll,
|
||||
arena_vec![self; new_unchecked, get_context],
|
||||
Some(expr_hir_id),
|
||||
);
|
||||
self.arena.alloc(self.expr_unsafe(call))
|
||||
};
|
||||
@ -678,18 +699,28 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
let (x_pat, x_pat_hid) = self.pat_ident(span, x_ident);
|
||||
let x_expr = self.expr_ident(span, x_ident, x_pat_hid);
|
||||
let ready_field = self.single_pat_field(span, x_pat);
|
||||
let ready_pat = self.pat_lang_item_variant(span, hir::LangItem::PollReady, ready_field);
|
||||
let ready_pat = self.pat_lang_item_variant(
|
||||
span,
|
||||
hir::LangItem::PollReady,
|
||||
ready_field,
|
||||
Some(expr_hir_id),
|
||||
);
|
||||
let break_x = self.with_loop_scope(loop_node_id, move |this| {
|
||||
let expr_break =
|
||||
hir::ExprKind::Break(this.lower_loop_destination(None), Some(x_expr));
|
||||
this.arena.alloc(this.expr(await_span, expr_break, ThinVec::new()))
|
||||
this.arena.alloc(this.expr(span, expr_break, ThinVec::new()))
|
||||
});
|
||||
self.arm(ready_pat, break_x)
|
||||
};
|
||||
|
||||
// `::std::task::Poll::Pending => {}`
|
||||
let pending_arm = {
|
||||
let pending_pat = self.pat_lang_item_variant(span, hir::LangItem::PollPending, &[]);
|
||||
let pending_pat = self.pat_lang_item_variant(
|
||||
span,
|
||||
hir::LangItem::PollPending,
|
||||
&[],
|
||||
Some(expr_hir_id),
|
||||
);
|
||||
let empty_block = self.expr_block_empty(span);
|
||||
self.arm(pending_pat, empty_block)
|
||||
};
|
||||
@ -709,7 +740,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
let unit = self.expr_unit(span);
|
||||
let yield_expr = self.expr(
|
||||
span,
|
||||
hir::ExprKind::Yield(unit, hir::YieldSource::Await { expr: Some(expr.hir_id) }),
|
||||
hir::ExprKind::Yield(unit, hir::YieldSource::Await { expr: Some(expr_hir_id) }),
|
||||
ThinVec::new(),
|
||||
);
|
||||
let yield_expr = self.arena.alloc(yield_expr);
|
||||
@ -756,6 +787,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
into_future_span,
|
||||
hir::LangItem::IntoFutureIntoFuture,
|
||||
arena_vec![self; expr],
|
||||
Some(expr_hir_id),
|
||||
);
|
||||
|
||||
// match <into_future_expr> {
|
||||
@ -1160,7 +1192,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
fn lower_expr_range_closed(&mut self, span: Span, e1: &Expr, e2: &Expr) -> hir::ExprKind<'hir> {
|
||||
let e1 = self.lower_expr_mut(e1);
|
||||
let e2 = self.lower_expr_mut(e2);
|
||||
let fn_path = hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, self.lower_span(span));
|
||||
let fn_path =
|
||||
hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, self.lower_span(span), None);
|
||||
let fn_expr =
|
||||
self.arena.alloc(self.expr(span, hir::ExprKind::Path(fn_path), ThinVec::new()));
|
||||
hir::ExprKind::Call(fn_expr, arena_vec![self; e1, e2])
|
||||
@ -1194,7 +1227,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
);
|
||||
|
||||
hir::ExprKind::Struct(
|
||||
self.arena.alloc(hir::QPath::LangItem(lang_item, self.lower_span(span))),
|
||||
self.arena.alloc(hir::QPath::LangItem(lang_item, self.lower_span(span), None)),
|
||||
fields,
|
||||
None,
|
||||
)
|
||||
@ -1389,6 +1422,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
head_span,
|
||||
hir::LangItem::IteratorNext,
|
||||
arena_vec![self; ref_mut_iter],
|
||||
None,
|
||||
);
|
||||
let arms = arena_vec![self; none_arm, some_arm];
|
||||
|
||||
@ -1417,6 +1451,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
head_span,
|
||||
hir::LangItem::IntoIterIntoIter,
|
||||
arena_vec![self; head],
|
||||
None,
|
||||
)
|
||||
};
|
||||
|
||||
@ -1472,6 +1507,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
unstable_span,
|
||||
hir::LangItem::TryTraitBranch,
|
||||
arena_vec![self; sub_expr],
|
||||
None,
|
||||
)
|
||||
};
|
||||
|
||||
@ -1628,8 +1664,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
span: Span,
|
||||
lang_item: hir::LangItem,
|
||||
args: &'hir [hir::Expr<'hir>],
|
||||
hir_id: Option<hir::HirId>,
|
||||
) -> hir::Expr<'hir> {
|
||||
let path = self.arena.alloc(self.expr_lang_item_path(span, lang_item, ThinVec::new()));
|
||||
let path =
|
||||
self.arena.alloc(self.expr_lang_item_path(span, lang_item, ThinVec::new(), hir_id));
|
||||
self.expr_call_mut(span, path, args)
|
||||
}
|
||||
|
||||
@ -1638,8 +1676,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
span: Span,
|
||||
lang_item: hir::LangItem,
|
||||
args: &'hir [hir::Expr<'hir>],
|
||||
hir_id: Option<hir::HirId>,
|
||||
) -> &'hir hir::Expr<'hir> {
|
||||
self.arena.alloc(self.expr_call_lang_item_fn_mut(span, lang_item, args))
|
||||
self.arena.alloc(self.expr_call_lang_item_fn_mut(span, lang_item, args, hir_id))
|
||||
}
|
||||
|
||||
fn expr_lang_item_path(
|
||||
@ -1647,10 +1686,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
span: Span,
|
||||
lang_item: hir::LangItem,
|
||||
attrs: AttrVec,
|
||||
hir_id: Option<hir::HirId>,
|
||||
) -> hir::Expr<'hir> {
|
||||
self.expr(
|
||||
span,
|
||||
hir::ExprKind::Path(hir::QPath::LangItem(lang_item, self.lower_span(span))),
|
||||
hir::ExprKind::Path(hir::QPath::LangItem(lang_item, self.lower_span(span), hir_id)),
|
||||
attrs,
|
||||
)
|
||||
}
|
||||
|
@ -32,7 +32,6 @@
|
||||
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(box_patterns)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(never_type)]
|
||||
#![recursion_limit = "256"]
|
||||
|
||||
@ -2127,21 +2126,21 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
|
||||
fn pat_cf_continue(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
|
||||
let field = self.single_pat_field(span, pat);
|
||||
self.pat_lang_item_variant(span, hir::LangItem::ControlFlowContinue, field)
|
||||
self.pat_lang_item_variant(span, hir::LangItem::ControlFlowContinue, field, None)
|
||||
}
|
||||
|
||||
fn pat_cf_break(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
|
||||
let field = self.single_pat_field(span, pat);
|
||||
self.pat_lang_item_variant(span, hir::LangItem::ControlFlowBreak, field)
|
||||
self.pat_lang_item_variant(span, hir::LangItem::ControlFlowBreak, field, None)
|
||||
}
|
||||
|
||||
fn pat_some(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
|
||||
let field = self.single_pat_field(span, pat);
|
||||
self.pat_lang_item_variant(span, hir::LangItem::OptionSome, field)
|
||||
self.pat_lang_item_variant(span, hir::LangItem::OptionSome, field, None)
|
||||
}
|
||||
|
||||
fn pat_none(&mut self, span: Span) -> &'hir hir::Pat<'hir> {
|
||||
self.pat_lang_item_variant(span, hir::LangItem::OptionNone, &[])
|
||||
self.pat_lang_item_variant(span, hir::LangItem::OptionNone, &[], None)
|
||||
}
|
||||
|
||||
fn single_pat_field(
|
||||
@ -2164,8 +2163,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
span: Span,
|
||||
lang_item: hir::LangItem,
|
||||
fields: &'hir [hir::PatField<'hir>],
|
||||
hir_id: Option<hir::HirId>,
|
||||
) -> &'hir hir::Pat<'hir> {
|
||||
let qpath = hir::QPath::LangItem(lang_item, self.lower_span(span));
|
||||
let qpath = hir::QPath::LangItem(lang_item, self.lower_span(span), hir_id);
|
||||
self.pat(span, hir::PatKind::Struct(qpath, fields, false))
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
#![feature(box_patterns)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(let_else)]
|
||||
#![feature(min_specialization)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
|
@ -6,7 +6,6 @@
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(decl_macro)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(nll)]
|
||||
#![feature(proc_macro_internals)]
|
||||
#![feature(proc_macro_quote)]
|
||||
|
@ -205,6 +205,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
||||
&self,
|
||||
ongoing_codegen: Box<dyn Any>,
|
||||
_sess: &Session,
|
||||
_outputs: &OutputFilenames,
|
||||
) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorReported> {
|
||||
Ok(*ongoing_codegen
|
||||
.downcast::<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>)>()
|
||||
|
@ -96,7 +96,7 @@ impl CodegenBackend for GccCodegenBackend {
|
||||
Box::new(res)
|
||||
}
|
||||
|
||||
fn join_codegen(&self, ongoing_codegen: Box<dyn Any>, sess: &Session) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorReported> {
|
||||
fn join_codegen(&self, ongoing_codegen: Box<dyn Any>, sess: &Session, _outputs: &OutputFilenames) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorReported> {
|
||||
let (codegen_results, work_products) = ongoing_codegen
|
||||
.downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<GccCodegenBackend>>()
|
||||
.expect("Expected GccCodegenBackend's OngoingCodegen, found Box<Any>")
|
||||
|
@ -9,7 +9,6 @@
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(extern_types)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(nll)]
|
||||
#![recursion_limit = "256"]
|
||||
|
||||
@ -339,6 +338,7 @@ impl CodegenBackend for LlvmCodegenBackend {
|
||||
&self,
|
||||
ongoing_codegen: Box<dyn Any>,
|
||||
sess: &Session,
|
||||
outputs: &OutputFilenames,
|
||||
) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorReported> {
|
||||
let (codegen_results, work_products) = ongoing_codegen
|
||||
.downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<LlvmCodegenBackend>>()
|
||||
@ -347,7 +347,8 @@ impl CodegenBackend for LlvmCodegenBackend {
|
||||
|
||||
sess.time("llvm_dump_timing_file", || {
|
||||
if sess.opts.debugging_opts.llvm_time_trace {
|
||||
llvm_util::time_trace_profiler_finish("llvm_timings.json");
|
||||
let file_name = outputs.with_extension("llvm_timings.json");
|
||||
llvm_util::time_trace_profiler_finish(&file_name);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -4,6 +4,7 @@ use libc::c_int;
|
||||
use libloading::Library;
|
||||
use rustc_codegen_ssa::target_features::supported_target_features;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_fs_util::path_to_c_string;
|
||||
use rustc_middle::bug;
|
||||
use rustc_session::config::PrintRequest;
|
||||
use rustc_session::Session;
|
||||
@ -13,6 +14,7 @@ use std::ffi::{CStr, CString};
|
||||
use tracing::debug;
|
||||
|
||||
use std::mem;
|
||||
use std::path::Path;
|
||||
use std::ptr;
|
||||
use std::slice;
|
||||
use std::str;
|
||||
@ -134,9 +136,9 @@ unsafe fn configure_llvm(sess: &Session) {
|
||||
llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int, llvm_args.as_ptr());
|
||||
}
|
||||
|
||||
pub fn time_trace_profiler_finish(file_name: &str) {
|
||||
pub fn time_trace_profiler_finish(file_name: &Path) {
|
||||
unsafe {
|
||||
let file_name = CString::new(file_name).unwrap();
|
||||
let file_name = path_to_c_string(file_name);
|
||||
llvm::LLVMTimeTraceProfilerFinish(file_name.as_ptr());
|
||||
}
|
||||
}
|
||||
|
@ -97,6 +97,7 @@ pub trait CodegenBackend {
|
||||
&self,
|
||||
ongoing_codegen: Box<dyn Any>,
|
||||
sess: &Session,
|
||||
outputs: &OutputFilenames,
|
||||
) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorReported>;
|
||||
|
||||
/// This is called on the returned `Box<dyn Any>` from `join_codegen`
|
||||
|
@ -11,7 +11,6 @@ Rust MIR: a lowered representation of Rust.
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(decl_macro)]
|
||||
#![feature(exact_size_is_empty)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(let_else)]
|
||||
#![feature(map_try_insert)]
|
||||
#![feature(min_specialization)]
|
||||
|
@ -6,7 +6,6 @@
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(backtrace)]
|
||||
#![feature(if_let_guard)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(let_else)]
|
||||
#![feature(nll)]
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
#![feature(decl_macro)]
|
||||
#![feature(destructuring_assignment)]
|
||||
#![feature(if_let_guard)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(let_else)]
|
||||
#![feature(proc_macro_diagnostic)]
|
||||
#![feature(proc_macro_internals)]
|
||||
|
@ -1627,13 +1627,13 @@ pub fn is_range_literal(expr: &Expr<'_>) -> bool {
|
||||
| LangItem::RangeFrom
|
||||
| LangItem::RangeFull
|
||||
| LangItem::RangeToInclusive,
|
||||
_,
|
||||
..
|
||||
)
|
||||
),
|
||||
|
||||
// `..=` desugars into `::std::ops::RangeInclusive::new(...)`.
|
||||
ExprKind::Call(ref func, _) => {
|
||||
matches!(func.kind, ExprKind::Path(QPath::LangItem(LangItem::RangeInclusiveNew, _)))
|
||||
matches!(func.kind, ExprKind::Path(QPath::LangItem(LangItem::RangeInclusiveNew, ..)))
|
||||
}
|
||||
|
||||
_ => false,
|
||||
@ -1788,8 +1788,8 @@ pub enum QPath<'hir> {
|
||||
/// the `X` and `Y` nodes each being a `TyKind::Path(QPath::TypeRelative(..))`.
|
||||
TypeRelative(&'hir Ty<'hir>, &'hir PathSegment<'hir>),
|
||||
|
||||
/// Reference to a `#[lang = "foo"]` item.
|
||||
LangItem(LangItem, Span),
|
||||
/// Reference to a `#[lang = "foo"]` item. `HirId` of the inner expr.
|
||||
LangItem(LangItem, Span, Option<HirId>),
|
||||
}
|
||||
|
||||
impl<'hir> QPath<'hir> {
|
||||
@ -1798,7 +1798,7 @@ impl<'hir> QPath<'hir> {
|
||||
match *self {
|
||||
QPath::Resolved(_, path) => path.span,
|
||||
QPath::TypeRelative(qself, ps) => qself.span.to(ps.ident.span),
|
||||
QPath::LangItem(_, span) => span,
|
||||
QPath::LangItem(_, span, _) => span,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1808,7 +1808,7 @@ impl<'hir> QPath<'hir> {
|
||||
match *self {
|
||||
QPath::Resolved(_, path) => path.span,
|
||||
QPath::TypeRelative(qself, _) => qself.span,
|
||||
QPath::LangItem(_, span) => span,
|
||||
QPath::LangItem(_, span, _) => span,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1818,7 +1818,7 @@ impl<'hir> QPath<'hir> {
|
||||
match *self {
|
||||
QPath::Resolved(_, path) => path.segments.last().unwrap().ident.span,
|
||||
QPath::TypeRelative(_, segment) => segment.ident.span,
|
||||
QPath::LangItem(_, span) => span,
|
||||
QPath::LangItem(_, span, _) => span,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1731,7 +1731,7 @@ impl<'a> State<'a> {
|
||||
colons_before_params,
|
||||
)
|
||||
}
|
||||
hir::QPath::LangItem(lang_item, span) => {
|
||||
hir::QPath::LangItem(lang_item, span, _) => {
|
||||
self.word("#[lang = \"");
|
||||
self.print_ident(Ident::new(lang_item.name(), span));
|
||||
self.word("\"]");
|
||||
|
@ -1,7 +1,6 @@
|
||||
#![feature(allow_internal_unstable)]
|
||||
#![feature(bench_black_box)]
|
||||
#![feature(extend_one)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(min_specialization)]
|
||||
#![feature(step_trait)]
|
||||
#![feature(test)]
|
||||
|
@ -17,7 +17,6 @@
|
||||
#![feature(box_patterns)]
|
||||
#![feature(derive_default_enum)]
|
||||
#![feature(extend_one)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(let_else)]
|
||||
#![feature(never_type)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
|
@ -335,8 +335,11 @@ pub struct Linker {
|
||||
|
||||
impl Linker {
|
||||
pub fn link(self) -> Result<()> {
|
||||
let (codegen_results, work_products) =
|
||||
self.codegen_backend.join_codegen(self.ongoing_codegen, &self.sess)?;
|
||||
let (codegen_results, work_products) = self.codegen_backend.join_codegen(
|
||||
self.ongoing_codegen,
|
||||
&self.sess,
|
||||
&self.prepare_outputs,
|
||||
)?;
|
||||
|
||||
self.sess.compile_status()?;
|
||||
|
||||
|
@ -52,7 +52,7 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter {
|
||||
if let hir::ExprKind::Call(path, [arg]) = &arg.kind {
|
||||
if let hir::ExprKind::Path(hir::QPath::LangItem(
|
||||
hir::LangItem::IntoIterIntoIter,
|
||||
_,
|
||||
..,
|
||||
)) = &path.kind
|
||||
{
|
||||
self.for_expr_span = arg.span;
|
||||
|
@ -31,7 +31,6 @@
|
||||
#![feature(box_patterns)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(iter_order_by)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(let_else)]
|
||||
#![feature(never_type)]
|
||||
#![feature(nll)]
|
||||
|
@ -51,7 +51,6 @@
|
||||
#![feature(half_open_range_patterns)]
|
||||
#![feature(control_flow_enum)]
|
||||
#![feature(associated_type_defaults)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(trusted_step)]
|
||||
#![feature(try_blocks)]
|
||||
#![feature(try_reserve_kind)]
|
||||
|
@ -348,6 +348,12 @@ pub enum ObligationCauseCode<'tcx> {
|
||||
/// If `X` is the concrete type of an opaque type `impl Y`, then `X` must implement `Y`
|
||||
OpaqueType,
|
||||
|
||||
AwaitableExpr(Option<hir::HirId>),
|
||||
|
||||
ForLoopIterator,
|
||||
|
||||
QuestionMark,
|
||||
|
||||
/// Well-formed checking. If a `WellFormedLoc` is provided,
|
||||
/// then it will be used to eprform HIR-based wf checking
|
||||
/// after an error occurs, in order to generate a more precise error span.
|
||||
|
@ -5,7 +5,6 @@
|
||||
#![feature(control_flow_enum)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(let_else)]
|
||||
#![feature(once_cell)]
|
||||
#![feature(min_specialization)]
|
||||
|
@ -4,7 +4,6 @@
|
||||
#![feature(box_syntax)]
|
||||
#![feature(exact_size_is_empty)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(let_else)]
|
||||
#![feature(min_specialization)]
|
||||
#![feature(once_cell)]
|
||||
|
@ -1,7 +1,6 @@
|
||||
#![feature(box_patterns)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(let_else)]
|
||||
#![feature(map_try_insert)]
|
||||
#![feature(min_specialization)]
|
||||
|
@ -7,7 +7,6 @@
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(map_try_insert)]
|
||||
#![feature(min_specialization)]
|
||||
#![feature(nll)]
|
||||
|
@ -421,11 +421,14 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h
|
||||
// Mark this expr's scope and all parent scopes as containing `yield`.
|
||||
let mut scope = Scope { id: expr.hir_id.local_id, data: ScopeData::Node };
|
||||
loop {
|
||||
let data = YieldData {
|
||||
span: expr.span,
|
||||
expr_and_pat_count: visitor.expr_and_pat_count,
|
||||
source: *source,
|
||||
let span = match expr.kind {
|
||||
hir::ExprKind::Yield(expr, hir::YieldSource::Await { .. }) => {
|
||||
expr.span.shrink_to_hi().to(expr.span)
|
||||
}
|
||||
_ => expr.span,
|
||||
};
|
||||
let data =
|
||||
YieldData { span, expr_and_pat_count: visitor.expr_and_pat_count, source: *source };
|
||||
visitor.scope_tree.yield_in_scope.insert(scope, data);
|
||||
if visitor.pessimistic_yield {
|
||||
debug!("resolve_expr in pessimistic_yield - marking scope {:?} for fixup", scope);
|
||||
|
@ -2,7 +2,6 @@
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(hash_raw_entry)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(let_else)]
|
||||
#![feature(min_specialization)]
|
||||
#![feature(extern_types)]
|
||||
|
@ -13,7 +13,6 @@
|
||||
#![feature(drain_filter)]
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(let_else)]
|
||||
#![feature(never_type)]
|
||||
#![feature(nll)]
|
||||
|
@ -286,7 +286,7 @@ impl<'hir> Sig for hir::Ty<'hir> {
|
||||
refs: vec![SigElement { id, start, end }],
|
||||
})
|
||||
}
|
||||
hir::TyKind::Path(hir::QPath::LangItem(lang_item, _)) => {
|
||||
hir::TyKind::Path(hir::QPath::LangItem(lang_item, _, _)) => {
|
||||
Ok(text_sig(format!("#[lang = \"{}\"]", lang_item.name())))
|
||||
}
|
||||
hir::TyKind::TraitObject(bounds, ..) => {
|
||||
|
@ -91,7 +91,6 @@
|
||||
#![feature(never_type)]
|
||||
#![feature(nll)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(iter_zip)]
|
||||
#![recursion_limit = "256"]
|
||||
|
||||
#[macro_use]
|
||||
|
@ -9,7 +9,6 @@ pub fn target() -> Target {
|
||||
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::THREAD;
|
||||
|
||||
base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-arch".to_string(), "arm64".to_string()]);
|
||||
base.link_env.extend(super::apple_base::macos_link_env("arm64"));
|
||||
base.link_env_remove.extend(super::apple_base::macos_link_env_remove());
|
||||
|
||||
// Clang automatically chooses a more specific target based on
|
||||
|
@ -79,18 +79,6 @@ pub fn macos_llvm_target(arch: &str) -> String {
|
||||
format!("{}-apple-macosx{}.{}.0", arch, major, minor)
|
||||
}
|
||||
|
||||
pub fn macos_link_env(arch: &str) -> Vec<(String, String)> {
|
||||
// Use the default deployment target for linking just as with the LLVM target if not
|
||||
// specified via MACOSX_DEPLOYMENT_TARGET, otherwise the system linker would use its
|
||||
// default which varies with Xcode version.
|
||||
if env::var("MACOSX_DEPLOYMENT_TARGET").is_err() {
|
||||
let default = macos_default_deployment_target(arch);
|
||||
vec![("MACOSX_DEPLOYMENT_TARGET".to_string(), format!("{}.{}", default.0, default.1))]
|
||||
} else {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn macos_link_env_remove() -> Vec<String> {
|
||||
let mut env_remove = Vec::with_capacity(2);
|
||||
// Remove the `SDKROOT` environment variable if it's clearly set for the wrong platform, which
|
||||
|
@ -5,7 +5,6 @@ pub fn target() -> Target {
|
||||
base.cpu = "yonah".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m32".to_string()]);
|
||||
base.link_env.extend(super::apple_base::macos_link_env("i686"));
|
||||
base.link_env_remove.extend(super::apple_base::macos_link_env_remove());
|
||||
// don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
|
||||
base.stack_probes = StackProbeType::Call;
|
||||
|
@ -10,7 +10,6 @@ pub fn target() -> Target {
|
||||
LinkerFlavor::Gcc,
|
||||
vec!["-m64".to_string(), "-arch".to_string(), "x86_64".to_string()],
|
||||
);
|
||||
base.link_env.extend(super::apple_base::macos_link_env("x86_64"));
|
||||
base.link_env_remove.extend(super::apple_base::macos_link_env_remove());
|
||||
// don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
|
||||
base.stack_probes = StackProbeType::Call;
|
||||
|
@ -17,7 +17,6 @@
|
||||
#![feature(derive_default_enum)]
|
||||
#![feature(hash_drain_filter)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(let_else)]
|
||||
#![feature(never_type)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
|
@ -439,6 +439,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
self.suggest_remove_reference(&obligation, &mut err, trait_ref);
|
||||
self.suggest_semicolon_removal(&obligation, &mut err, span, trait_ref);
|
||||
self.note_version_mismatch(&mut err, &trait_ref);
|
||||
self.suggest_remove_await(&obligation, &mut err);
|
||||
|
||||
if Some(trait_ref.def_id()) == tcx.lang_items().try_trait() {
|
||||
self.suggest_await_before_try(&mut err, &obligation, trait_ref, span);
|
||||
|
@ -89,6 +89,12 @@ pub trait InferCtxtExt<'tcx> {
|
||||
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||
);
|
||||
|
||||
fn suggest_remove_await(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
);
|
||||
|
||||
fn suggest_change_mut(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
@ -873,6 +879,63 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn suggest_remove_await(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
) {
|
||||
let span = obligation.cause.span;
|
||||
|
||||
if let ObligationCauseCode::AwaitableExpr(hir_id) = obligation.cause.code.peel_derives() {
|
||||
let hir = self.tcx.hir();
|
||||
if let Some(node) = hir_id.and_then(|hir_id| hir.find(hir_id)) {
|
||||
if let hir::Node::Expr(expr) = node {
|
||||
// FIXME: use `obligation.predicate.kind()...trait_ref.self_ty()` to see if we have `()`
|
||||
// and if not maybe suggest doing something else? If we kept the expression around we
|
||||
// could also check if it is an fn call (very likely) and suggest changing *that*, if
|
||||
// it is from the local crate.
|
||||
err.span_suggestion_verbose(
|
||||
expr.span.shrink_to_hi().with_hi(span.hi()),
|
||||
"remove the `.await`",
|
||||
String::new(),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
// FIXME: account for associated `async fn`s.
|
||||
if let hir::Expr { span, kind: hir::ExprKind::Call(base, _), .. } = expr {
|
||||
if let ty::PredicateKind::Trait(pred) =
|
||||
obligation.predicate.kind().skip_binder()
|
||||
{
|
||||
err.span_label(
|
||||
*span,
|
||||
&format!("this call returns `{}`", pred.self_ty()),
|
||||
);
|
||||
}
|
||||
if let Some(typeck_results) =
|
||||
self.in_progress_typeck_results.map(|t| t.borrow())
|
||||
{
|
||||
let ty = typeck_results.expr_ty_adjusted(base);
|
||||
if let ty::FnDef(def_id, _substs) = ty.kind() {
|
||||
if let Some(hir::Node::Item(hir::Item { span, ident, .. })) =
|
||||
hir.get_if_local(*def_id)
|
||||
{
|
||||
err.span_suggestion_verbose(
|
||||
span.shrink_to_lo(),
|
||||
&format!(
|
||||
"alternatively, consider making `fn {}` asynchronous",
|
||||
ident
|
||||
),
|
||||
"async ".to_string(),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if the trait bound is implemented for a different mutability and note it in the
|
||||
/// final error.
|
||||
fn suggest_change_mut(
|
||||
@ -1654,120 +1717,51 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
format!("does not implement `{}`", trait_ref.print_only_trait_path())
|
||||
};
|
||||
|
||||
let mut explain_yield =
|
||||
|interior_span: Span, yield_span: Span, scope_span: Option<Span>| {
|
||||
let mut explain_yield = |interior_span: Span,
|
||||
yield_span: Span,
|
||||
scope_span: Option<Span>| {
|
||||
let mut span = MultiSpan::from_span(yield_span);
|
||||
if let Ok(snippet) = source_map.span_to_snippet(interior_span) {
|
||||
// #70935: If snippet contains newlines, display "the value" instead
|
||||
// so that we do not emit complex diagnostics.
|
||||
let snippet = &format!("`{}`", snippet);
|
||||
let snippet = if snippet.contains('\n') { "the value" } else { snippet };
|
||||
// The multispan can be complex here, like:
|
||||
// note: future is not `Send` as this value is used across an await
|
||||
// --> $DIR/issue-70935-complex-spans.rs:13:9
|
||||
// |
|
||||
// LL | baz(|| async {
|
||||
// | __________^___-
|
||||
// | | _________|
|
||||
// | ||
|
||||
// LL | || foo(tx.clone());
|
||||
// LL | || }).await;
|
||||
// | || - ^- value is later dropped here
|
||||
// | ||_________|______|
|
||||
// | |__________| await occurs here, with value maybe used later
|
||||
// | has type `closure` which is not `Send`
|
||||
//
|
||||
// So, detect it and separate into some notes, like:
|
||||
//
|
||||
// note: future is not `Send` as this value is used across an await
|
||||
// --> $DIR/issue-70935-complex-spans.rs:13:9
|
||||
// |
|
||||
// LL | / baz(|| async{
|
||||
// | ______________-
|
||||
// | |
|
||||
// | |
|
||||
// LL | | foo(tx.clone());
|
||||
// LL | | }).await;
|
||||
// | |________________^ first, await occurs here, with the value maybe used later...
|
||||
// note: the value is later dropped here
|
||||
// --> $DIR/issue-70935-complex-spans.rs:15:17
|
||||
// |
|
||||
// LL | }).await;
|
||||
// | ^
|
||||
// | | - ^^^^^^ await occurs here, with value maybe used later
|
||||
// | |__________|
|
||||
// | has type `closure` which is not `Send`
|
||||
// note: value is later dropped here
|
||||
// LL | | }).await;
|
||||
// | | ^
|
||||
//
|
||||
span.push_span_label(
|
||||
yield_span,
|
||||
format!("{} occurs here, with {} maybe used later", await_or_yield, snippet),
|
||||
);
|
||||
span.push_span_label(
|
||||
interior_span,
|
||||
format!("has type `{}` which {}", target_ty, trait_explanation),
|
||||
);
|
||||
// If available, use the scope span to annotate the drop location.
|
||||
let mut scope_note = None;
|
||||
if let Some(scope_span) = scope_span {
|
||||
let scope_span = source_map.end_point(scope_span);
|
||||
let is_overlapped =
|
||||
yield_span.overlaps(scope_span) || yield_span.overlaps(interior_span);
|
||||
if is_overlapped {
|
||||
span.push_span_label(
|
||||
yield_span,
|
||||
format!(
|
||||
"first, {} occurs here, with {} maybe used later...",
|
||||
await_or_yield, snippet
|
||||
),
|
||||
);
|
||||
err.span_note(
|
||||
span,
|
||||
&format!(
|
||||
"{} {} as this value is used across {}",
|
||||
future_or_generator, trait_explanation, an_await_or_yield
|
||||
),
|
||||
);
|
||||
if source_map.is_multiline(interior_span) {
|
||||
err.span_note(
|
||||
scope_span,
|
||||
&format!("{} is later dropped here", snippet),
|
||||
);
|
||||
err.span_note(
|
||||
interior_span,
|
||||
&format!(
|
||||
"this has type `{}` which {}",
|
||||
target_ty, trait_explanation
|
||||
),
|
||||
);
|
||||
|
||||
let msg = format!("{} is later dropped here", snippet);
|
||||
if source_map.is_multiline(yield_span.between(scope_span)) {
|
||||
span.push_span_label(scope_span, msg);
|
||||
} else {
|
||||
let mut span = MultiSpan::from_span(scope_span);
|
||||
span.push_span_label(
|
||||
interior_span,
|
||||
format!("has type `{}` which {}", target_ty, trait_explanation),
|
||||
);
|
||||
err.span_note(span, &format!("{} is later dropped here", snippet));
|
||||
scope_note = Some((scope_span, msg));
|
||||
}
|
||||
} else {
|
||||
span.push_span_label(
|
||||
yield_span,
|
||||
format!(
|
||||
"{} occurs here, with {} maybe used later",
|
||||
await_or_yield, snippet
|
||||
),
|
||||
);
|
||||
span.push_span_label(
|
||||
scope_span,
|
||||
format!("{} is later dropped here", snippet),
|
||||
);
|
||||
span.push_span_label(
|
||||
interior_span,
|
||||
format!("has type `{}` which {}", target_ty, trait_explanation),
|
||||
);
|
||||
err.span_note(
|
||||
span,
|
||||
&format!(
|
||||
"{} {} as this value is used across {}",
|
||||
future_or_generator, trait_explanation, an_await_or_yield
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
span.push_span_label(
|
||||
yield_span,
|
||||
format!(
|
||||
"{} occurs here, with {} maybe used later",
|
||||
await_or_yield, snippet
|
||||
),
|
||||
);
|
||||
span.push_span_label(
|
||||
interior_span,
|
||||
format!("has type `{}` which {}", target_ty, trait_explanation),
|
||||
);
|
||||
err.span_note(
|
||||
span,
|
||||
&format!(
|
||||
@ -1775,6 +1769,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
future_or_generator, trait_explanation, an_await_or_yield
|
||||
),
|
||||
);
|
||||
if let Some((span, msg)) = scope_note {
|
||||
err.span_note(span, &msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1935,6 +1931,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
| ObligationCauseCode::ReturnType
|
||||
| ObligationCauseCode::ReturnValue(_)
|
||||
| ObligationCauseCode::BlockTailExpression(_)
|
||||
| ObligationCauseCode::AwaitableExpr(_)
|
||||
| ObligationCauseCode::ForLoopIterator
|
||||
| ObligationCauseCode::QuestionMark
|
||||
| ObligationCauseCode::LetElse => {}
|
||||
ObligationCauseCode::SliceOrArrayElem => {
|
||||
err.note("slice and array elements must have `Sized` type");
|
||||
|
@ -92,7 +92,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
&self,
|
||||
span: Span,
|
||||
trait_def_id: DefId,
|
||||
trait_segment: &'a hir::PathSegment<'a>,
|
||||
trait_segment: &'_ hir::PathSegment<'_>,
|
||||
) {
|
||||
let trait_def = self.tcx().trait_def(trait_def_id);
|
||||
|
||||
|
@ -2340,7 +2340,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
.map(|(ty, _, _)| ty)
|
||||
.unwrap_or_else(|_| tcx.ty_error())
|
||||
}
|
||||
hir::TyKind::Path(hir::QPath::LangItem(lang_item, span)) => {
|
||||
hir::TyKind::Path(hir::QPath::LangItem(lang_item, span, _)) => {
|
||||
let def_id = tcx.require_lang_item(lang_item, Some(span));
|
||||
let (substs, _) = self.create_substs_for_ast_path(
|
||||
span,
|
||||
|
@ -557,7 +557,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn arms_contain_ref_bindings(arms: &'tcx [hir::Arm<'tcx>]) -> Option<hir::Mutability> {
|
||||
fn arms_contain_ref_bindings<'tcx>(arms: &'tcx [hir::Arm<'tcx>]) -> Option<hir::Mutability> {
|
||||
arms.iter().filter_map(|a| a.pat.contains_explicit_ref_binding()).max_by_key(|m| match *m {
|
||||
hir::Mutability::Mut => 1,
|
||||
hir::Mutability::Not => 0,
|
||||
|
@ -453,7 +453,7 @@ pub(super) fn check_opaque<'tcx>(
|
||||
/// Checks that an opaque type does not use `Self` or `T::Foo` projections that would result
|
||||
/// in "inheriting lifetimes".
|
||||
#[instrument(level = "debug", skip(tcx, span))]
|
||||
pub(super) fn check_opaque_for_inheriting_lifetimes(
|
||||
pub(super) fn check_opaque_for_inheriting_lifetimes<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
def_id: LocalDefId,
|
||||
span: Span,
|
||||
@ -517,7 +517,7 @@ pub(super) fn check_opaque_for_inheriting_lifetimes(
|
||||
}
|
||||
}
|
||||
|
||||
impl Visitor<'tcx> for ProhibitOpaqueVisitor<'tcx> {
|
||||
impl<'tcx> Visitor<'tcx> for ProhibitOpaqueVisitor<'tcx> {
|
||||
type Map = rustc_middle::hir::map::Map<'tcx>;
|
||||
|
||||
fn nested_visit_map(&mut self) -> hir::intravisit::NestedVisitorMap<Self::Map> {
|
||||
@ -1512,7 +1512,7 @@ pub(super) use wfcheck::check_trait_item as check_trait_item_well_formed;
|
||||
|
||||
pub(super) use wfcheck::check_impl_item as check_impl_item_well_formed;
|
||||
|
||||
fn async_opaque_type_cycle_error(tcx: TyCtxt<'tcx>, span: Span) {
|
||||
fn async_opaque_type_cycle_error(tcx: TyCtxt<'_>, span: Span) {
|
||||
struct_span_err!(tcx.sess, span, E0733, "recursion in an `async fn` requires boxing")
|
||||
.span_label(span, "recursive `async fn`")
|
||||
.note("a recursive `async fn` must be rewritten to return a boxed `dyn Future`")
|
||||
@ -1530,7 +1530,7 @@ fn async_opaque_type_cycle_error(tcx: TyCtxt<'tcx>, span: Span) {
|
||||
///
|
||||
/// If all the return expressions evaluate to `!`, then we explain that the error will go away
|
||||
/// after changing it. This can happen when a user uses `panic!()` or similar as a placeholder.
|
||||
fn opaque_type_cycle_error(tcx: TyCtxt<'tcx>, def_id: LocalDefId, span: Span) {
|
||||
fn opaque_type_cycle_error(tcx: TyCtxt<'_>, def_id: LocalDefId, span: Span) {
|
||||
let mut err = struct_span_err!(tcx.sess, span, E0720, "cannot resolve opaque type");
|
||||
|
||||
let mut label = false;
|
||||
|
@ -102,7 +102,7 @@ fn identity(_: Ty<'_>) -> Vec<Adjustment<'_>> {
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn simple(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>> {
|
||||
fn simple<'tcx>(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>> {
|
||||
move |target| vec![Adjustment { kind, target }]
|
||||
}
|
||||
|
||||
@ -1694,7 +1694,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
||||
err.help("you could instead create a new `enum` with a variant for each returned type");
|
||||
}
|
||||
|
||||
fn is_return_ty_unsized(&self, fcx: &FnCtxt<'a, 'tcx>, blk_id: hir::HirId) -> bool {
|
||||
fn is_return_ty_unsized<'a>(&self, fcx: &FnCtxt<'a, 'tcx>, blk_id: hir::HirId) -> bool {
|
||||
if let Some((fn_decl, _)) = fcx.get_fn_decl(blk_id) {
|
||||
if let hir::FnRetTy::Return(ty) = fn_decl.output {
|
||||
let ty = <dyn AstConv<'_>>::ast_ty_to_ty(fcx, ty);
|
||||
|
@ -302,7 +302,7 @@ impl<'tcx> SimpleEqRelation<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeRelation<'tcx> for SimpleEqRelation<'tcx> {
|
||||
impl<'tcx> TypeRelation<'tcx> for SimpleEqRelation<'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
@ -277,8 +277,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
ExprKind::AddrOf(kind, mutbl, oprnd) => {
|
||||
self.check_expr_addr_of(kind, mutbl, oprnd, expected, expr)
|
||||
}
|
||||
ExprKind::Path(QPath::LangItem(lang_item, _)) => {
|
||||
self.check_lang_item_path(lang_item, expr)
|
||||
ExprKind::Path(QPath::LangItem(lang_item, _, hir_id)) => {
|
||||
self.check_lang_item_path(lang_item, expr, hir_id)
|
||||
}
|
||||
ExprKind::Path(ref qpath) => self.check_expr_path(qpath, expr, &[]),
|
||||
ExprKind::InlineAsm(asm) => self.check_expr_asm(asm),
|
||||
@ -498,8 +498,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
&self,
|
||||
lang_item: hir::LangItem,
|
||||
expr: &'tcx hir::Expr<'tcx>,
|
||||
hir_id: Option<hir::HirId>,
|
||||
) -> Ty<'tcx> {
|
||||
self.resolve_lang_item_path(lang_item, expr.span, expr.hir_id).1
|
||||
self.resolve_lang_item_path(lang_item, expr.span, expr.hir_id, hir_id).1
|
||||
}
|
||||
|
||||
pub(crate) fn check_expr_path(
|
||||
|
@ -791,6 +791,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
lang_item: hir::LangItem,
|
||||
span: Span,
|
||||
hir_id: hir::HirId,
|
||||
expr_hir_id: Option<hir::HirId>,
|
||||
) -> (Res, Ty<'tcx>) {
|
||||
let def_id = self.tcx.require_lang_item(lang_item, Some(span));
|
||||
let def_kind = self.tcx.def_kind(def_id);
|
||||
@ -804,7 +805,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
let ty = item_ty.subst(self.tcx, substs);
|
||||
|
||||
self.write_resolution(hir_id, Ok((def_kind, def_id)));
|
||||
self.add_required_obligations(span, def_id, &substs);
|
||||
self.add_required_obligations_with_code(
|
||||
span,
|
||||
def_id,
|
||||
&substs,
|
||||
match lang_item {
|
||||
hir::LangItem::IntoFutureIntoFuture => {
|
||||
ObligationCauseCode::AwaitableExpr(expr_hir_id)
|
||||
}
|
||||
hir::LangItem::IteratorNext | hir::LangItem::IntoIterIntoIter => {
|
||||
ObligationCauseCode::ForLoopIterator
|
||||
}
|
||||
hir::LangItem::TryTraitFromOutput
|
||||
| hir::LangItem::TryTraitFromResidual
|
||||
| hir::LangItem::TryTraitBranch => ObligationCauseCode::QuestionMark,
|
||||
_ => traits::ItemObligation(def_id),
|
||||
},
|
||||
);
|
||||
(Res::Def(def_kind, def_id), ty)
|
||||
}
|
||||
|
||||
@ -1486,12 +1503,27 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
|
||||
/// Add all the obligations that are required, substituting and normalized appropriately.
|
||||
#[tracing::instrument(level = "debug", skip(self, span, def_id, substs))]
|
||||
crate fn add_required_obligations(&self, span: Span, def_id: DefId, substs: &SubstsRef<'tcx>) {
|
||||
self.add_required_obligations_with_code(
|
||||
span,
|
||||
def_id,
|
||||
substs,
|
||||
traits::ItemObligation(def_id),
|
||||
)
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self, span, def_id, substs))]
|
||||
fn add_required_obligations_with_code(
|
||||
&self,
|
||||
span: Span,
|
||||
def_id: DefId,
|
||||
substs: &SubstsRef<'tcx>,
|
||||
code: ObligationCauseCode<'tcx>,
|
||||
) {
|
||||
let (bounds, _) = self.instantiate_bounds(span, def_id, &substs);
|
||||
|
||||
for obligation in traits::predicates_for_generics(
|
||||
traits::ObligationCause::new(span, self.body_id, traits::ItemObligation(def_id)),
|
||||
traits::ObligationCause::new(span, self.body_id, code),
|
||||
self.param_env,
|
||||
bounds,
|
||||
) {
|
||||
|
@ -938,8 +938,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
(result.map_or(Res::Err, |(kind, def_id)| Res::Def(kind, def_id)), ty)
|
||||
}
|
||||
QPath::LangItem(lang_item, span) => {
|
||||
self.resolve_lang_item_path(lang_item, span, hir_id)
|
||||
QPath::LangItem(lang_item, span, id) => {
|
||||
self.resolve_lang_item_path(lang_item, span, hir_id, id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ pub struct InheritedBuilder<'tcx> {
|
||||
def_id: LocalDefId,
|
||||
}
|
||||
|
||||
impl Inherited<'_, 'tcx> {
|
||||
impl<'tcx> Inherited<'_, 'tcx> {
|
||||
pub fn build(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> InheritedBuilder<'tcx> {
|
||||
let hir_owner = tcx.hir().local_def_id_to_hir_id(def_id).owner;
|
||||
|
||||
@ -97,7 +97,7 @@ impl<'tcx> InheritedBuilder<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Inherited<'a, 'tcx> {
|
||||
impl<'a, 'tcx> Inherited<'a, 'tcx> {
|
||||
pub(super) fn new(infcx: InferCtxt<'a, 'tcx>, def_id: LocalDefId) -> Self {
|
||||
let tcx = infcx.tcx;
|
||||
let item_id = tcx.hir().local_def_id_to_hir_id(def_id);
|
||||
|
@ -1968,7 +1968,7 @@ fn find_use_placement<'tcx>(tcx: TyCtxt<'tcx>, target_module: LocalDefId) -> (Op
|
||||
(span, found_use)
|
||||
}
|
||||
|
||||
fn print_disambiguation_help(
|
||||
fn print_disambiguation_help<'tcx>(
|
||||
item_name: Ident,
|
||||
args: Option<&'tcx [hir::Expr<'tcx>]>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
|
@ -508,7 +508,7 @@ struct GeneratorTypes<'tcx> {
|
||||
|
||||
/// Given a `DefId` for an opaque type in return position, find its parent item's return
|
||||
/// expressions.
|
||||
fn get_owner_return_paths(
|
||||
fn get_owner_return_paths<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
def_id: LocalDefId,
|
||||
) -> Option<(hir::HirId, ReturnsVisitor<'tcx>)> {
|
||||
@ -906,7 +906,7 @@ struct CheckItemTypesVisitor<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
}
|
||||
|
||||
impl ItemLikeVisitor<'tcx> for CheckItemTypesVisitor<'tcx> {
|
||||
impl<'tcx> ItemLikeVisitor<'tcx> for CheckItemTypesVisitor<'tcx> {
|
||||
fn visit_item(&mut self, i: &'tcx hir::Item<'tcx>) {
|
||||
check_item_type(self.tcx, i);
|
||||
}
|
||||
|
@ -893,7 +893,7 @@ enum Op {
|
||||
}
|
||||
|
||||
/// Dereferences a single level of immutable referencing.
|
||||
fn deref_ty_if_possible(ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
fn deref_ty_if_possible<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match ty.kind() {
|
||||
ty::Ref(_, ty, hir::Mutability::Not) => ty,
|
||||
_ => ty,
|
||||
@ -1007,7 +1007,7 @@ impl<'tcx> TypeVisitor<'tcx> for TypeParamVisitor<'tcx> {
|
||||
|
||||
struct TypeParamEraser<'a, 'tcx>(&'a FnCtxt<'a, 'tcx>, Span);
|
||||
|
||||
impl TypeFolder<'tcx> for TypeParamEraser<'_, 'tcx> {
|
||||
impl<'tcx> TypeFolder<'tcx> for TypeParamEraser<'_, 'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
self.0.tcx
|
||||
}
|
||||
|
@ -740,7 +740,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_pat_path(
|
||||
fn check_pat_path<'b>(
|
||||
&self,
|
||||
pat: &Pat<'_>,
|
||||
path_resolution: (Res, Option<Ty<'tcx>>, &'b [hir::PathSegment<'b>]),
|
||||
@ -816,7 +816,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
false
|
||||
}
|
||||
|
||||
fn emit_bad_pat_path(
|
||||
fn emit_bad_pat_path<'b>(
|
||||
&self,
|
||||
mut e: DiagnosticBuilder<'_>,
|
||||
pat_span: Span,
|
||||
|
@ -106,7 +106,7 @@ macro_rules! ignore_err {
|
||||
pub(crate) trait OutlivesEnvironmentExt<'tcx> {
|
||||
fn add_implied_bounds(
|
||||
&mut self,
|
||||
infcx: &InferCtxt<'a, 'tcx>,
|
||||
infcx: &InferCtxt<'_, 'tcx>,
|
||||
fn_sig_tys: FxHashSet<Ty<'tcx>>,
|
||||
body_id: hir::HirId,
|
||||
span: Span,
|
||||
@ -130,7 +130,7 @@ impl<'tcx> OutlivesEnvironmentExt<'tcx> for OutlivesEnvironment<'tcx> {
|
||||
/// add those assumptions into the outlives-environment.
|
||||
///
|
||||
/// Tests: `src/test/ui/regions/regions-free-region-ordering-*.rs`
|
||||
fn add_implied_bounds(
|
||||
fn add_implied_bounds<'a>(
|
||||
&mut self,
|
||||
infcx: &InferCtxt<'a, 'tcx>,
|
||||
fn_sig_tys: FxHashSet<Ty<'tcx>>,
|
||||
|
@ -1672,7 +1672,7 @@ fn restrict_repr_packed_field_ref_capture<'tcx>(
|
||||
}
|
||||
|
||||
/// Returns a Ty that applies the specified capture kind on the provided capture Ty
|
||||
fn apply_capture_kind_on_capture_ty(
|
||||
fn apply_capture_kind_on_capture_ty<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
capture_kind: UpvarCapture<'tcx>,
|
||||
@ -1685,7 +1685,7 @@ fn apply_capture_kind_on_capture_ty(
|
||||
}
|
||||
|
||||
/// Returns the Span of where the value with the provided HirId would be dropped
|
||||
fn drop_location_span(tcx: TyCtxt<'tcx>, hir_id: &hir::HirId) -> Span {
|
||||
fn drop_location_span<'tcx>(tcx: TyCtxt<'tcx>, hir_id: &hir::HirId) -> Span {
|
||||
let owner_id = tcx.hir().get_enclosing_scope(*hir_id).unwrap();
|
||||
|
||||
let owner_node = tcx.hir().get(owner_id);
|
||||
@ -1999,7 +1999,7 @@ fn restrict_precision_for_drop_types<'a, 'tcx>(
|
||||
/// - No projections are applied to raw pointers, since these require unsafe blocks. We capture
|
||||
/// them completely.
|
||||
/// - No projections are applied on top of Union ADTs, since these require unsafe blocks.
|
||||
fn restrict_precision_for_unsafe(
|
||||
fn restrict_precision_for_unsafe<'tcx>(
|
||||
mut place: Place<'tcx>,
|
||||
mut curr_mode: ty::UpvarCapture<'tcx>,
|
||||
) -> (Place<'tcx>, ty::UpvarCapture<'tcx>) {
|
||||
@ -2097,7 +2097,7 @@ fn adjust_for_non_move_closure<'tcx>(
|
||||
(place, kind)
|
||||
}
|
||||
|
||||
fn construct_place_string(tcx: TyCtxt<'_>, place: &Place<'tcx>) -> String {
|
||||
fn construct_place_string<'tcx>(tcx: TyCtxt<'_>, place: &Place<'tcx>) -> String {
|
||||
let variable_name = match place.base {
|
||||
PlaceBase::Upvar(upvar_id) => var_name(tcx, upvar_id.var_path.hir_id).to_string(),
|
||||
_ => bug!("Capture_information should only contain upvars"),
|
||||
@ -2120,7 +2120,7 @@ fn construct_place_string(tcx: TyCtxt<'_>, place: &Place<'tcx>) -> String {
|
||||
format!("{}[{}]", variable_name, projections_str)
|
||||
}
|
||||
|
||||
fn construct_capture_kind_reason_string(
|
||||
fn construct_capture_kind_reason_string<'tcx>(
|
||||
tcx: TyCtxt<'_>,
|
||||
place: &Place<'tcx>,
|
||||
capture_info: &ty::CaptureInfo<'tcx>,
|
||||
@ -2135,13 +2135,13 @@ fn construct_capture_kind_reason_string(
|
||||
format!("{} captured as {} here", place_str, capture_kind_str)
|
||||
}
|
||||
|
||||
fn construct_path_string(tcx: TyCtxt<'_>, place: &Place<'tcx>) -> String {
|
||||
fn construct_path_string<'tcx>(tcx: TyCtxt<'_>, place: &Place<'tcx>) -> String {
|
||||
let place_str = construct_place_string(tcx, place);
|
||||
|
||||
format!("{} used here", place_str)
|
||||
}
|
||||
|
||||
fn construct_capture_info_string(
|
||||
fn construct_capture_info_string<'tcx>(
|
||||
tcx: TyCtxt<'_>,
|
||||
place: &Place<'tcx>,
|
||||
capture_info: &ty::CaptureInfo<'tcx>,
|
||||
@ -2233,7 +2233,7 @@ fn migration_suggestion_for_2229(
|
||||
/// would've already handled `E1`, and have an existing capture_information for it.
|
||||
/// Calling `determine_capture_info(existing_info_e1, current_info_e2)` will return
|
||||
/// `existing_info_e1` in this case, allowing us to point to `E1` in case of diagnostics.
|
||||
fn determine_capture_info(
|
||||
fn determine_capture_info<'tcx>(
|
||||
capture_info_a: ty::CaptureInfo<'tcx>,
|
||||
capture_info_b: ty::CaptureInfo<'tcx>,
|
||||
) -> ty::CaptureInfo<'tcx> {
|
||||
@ -2292,7 +2292,7 @@ fn determine_capture_info(
|
||||
///
|
||||
/// Note: Capture kind changes from `MutBorrow` to `UniqueImmBorrow` if the truncated part of the `place`
|
||||
/// contained `Deref` of `&mut`.
|
||||
fn truncate_place_to_len_and_update_capture_kind(
|
||||
fn truncate_place_to_len_and_update_capture_kind<'tcx>(
|
||||
place: &mut Place<'tcx>,
|
||||
curr_mode: &mut ty::UpvarCapture<'tcx>,
|
||||
len: usize,
|
||||
@ -2330,7 +2330,7 @@ fn truncate_place_to_len_and_update_capture_kind(
|
||||
/// `PlaceAncestryRelation::Ancestor` implies Place A is ancestor of Place B
|
||||
/// `PlaceAncestryRelation::Descendant` implies Place A is descendant of Place B
|
||||
/// `PlaceAncestryRelation::Divergent` implies neither of them is the ancestor of the other.
|
||||
fn determine_place_ancestry_relation(
|
||||
fn determine_place_ancestry_relation<'tcx>(
|
||||
place_a: &Place<'tcx>,
|
||||
place_b: &Place<'tcx>,
|
||||
) -> PlaceAncestryRelation {
|
||||
|
@ -1488,7 +1488,7 @@ fn check_method_receiver<'fcx, 'tcx>(
|
||||
}
|
||||
}
|
||||
|
||||
fn e0307(fcx: &FnCtxt<'fcx, 'tcx>, span: Span, receiver_ty: Ty<'_>) {
|
||||
fn e0307<'tcx>(fcx: &FnCtxt<'_, 'tcx>, span: Span, receiver_ty: Ty<'_>) {
|
||||
struct_span_err!(
|
||||
fcx.tcx.sess.diagnostic(),
|
||||
span,
|
||||
@ -1591,7 +1591,7 @@ fn receiver_is_valid<'fcx, 'tcx>(
|
||||
true
|
||||
}
|
||||
|
||||
fn receiver_is_implemented(
|
||||
fn receiver_is_implemented<'tcx>(
|
||||
fcx: &FnCtxt<'_, 'tcx>,
|
||||
receiver_trait_def_id: DefId,
|
||||
cause: ObligationCause<'tcx>,
|
||||
@ -1734,13 +1734,13 @@ pub struct CheckTypeWellFormedVisitor<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
}
|
||||
|
||||
impl CheckTypeWellFormedVisitor<'tcx> {
|
||||
impl<'tcx> CheckTypeWellFormedVisitor<'tcx> {
|
||||
pub fn new(tcx: TyCtxt<'tcx>) -> CheckTypeWellFormedVisitor<'tcx> {
|
||||
CheckTypeWellFormedVisitor { tcx }
|
||||
}
|
||||
}
|
||||
|
||||
impl ParItemLikeVisitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> {
|
||||
impl<'tcx> ParItemLikeVisitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> {
|
||||
fn visit_item(&self, i: &'tcx hir::Item<'tcx>) {
|
||||
Visitor::visit_item(&mut self.clone(), i);
|
||||
}
|
||||
@ -1758,7 +1758,7 @@ impl ParItemLikeVisitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Visitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> {
|
||||
impl<'tcx> Visitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> {
|
||||
type Map = hir_map::Map<'tcx>;
|
||||
|
||||
fn nested_visit_map(&mut self) -> hir_visit::NestedVisitorMap<Self::Map> {
|
||||
|
@ -21,7 +21,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
|
||||
unused_crates_lint(tcx);
|
||||
}
|
||||
|
||||
impl ItemLikeVisitor<'v> for CheckVisitor<'tcx> {
|
||||
impl<'tcx> ItemLikeVisitor<'_> for CheckVisitor<'tcx> {
|
||||
fn visit_item(&mut self, item: &hir::Item<'_>) {
|
||||
if item.vis.node.is_pub() || item.span.is_dummy() {
|
||||
return;
|
||||
@ -43,7 +43,7 @@ struct CheckVisitor<'tcx> {
|
||||
used_trait_imports: FxHashSet<LocalDefId>,
|
||||
}
|
||||
|
||||
impl CheckVisitor<'tcx> {
|
||||
impl<'tcx> CheckVisitor<'tcx> {
|
||||
fn check_import(&self, item_id: hir::ItemId, span: Span) {
|
||||
if !self.tcx.maybe_unused_trait_import(item_id.def_id) {
|
||||
return;
|
||||
|
@ -108,7 +108,7 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_implementation_of_coerce_unsized(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) {
|
||||
fn visit_implementation_of_coerce_unsized<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) {
|
||||
debug!("visit_implementation_of_coerce_unsized: impl_did={:?}", impl_did);
|
||||
|
||||
// Just compute this for the side-effects, in particular reporting
|
||||
@ -118,7 +118,7 @@ fn visit_implementation_of_coerce_unsized(tcx: TyCtxt<'tcx>, impl_did: LocalDefI
|
||||
tcx.at(span).coerce_unsized_info(impl_did);
|
||||
}
|
||||
|
||||
fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
|
||||
fn visit_implementation_of_dispatch_from_dyn<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) {
|
||||
debug!("visit_implementation_of_dispatch_from_dyn: impl_did={:?}", impl_did);
|
||||
|
||||
let impl_hir_id = tcx.hir().local_def_id_to_hir_id(impl_did);
|
||||
@ -287,7 +287,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
|
||||
})
|
||||
}
|
||||
|
||||
pub fn coerce_unsized_info(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedInfo {
|
||||
pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedInfo {
|
||||
debug!("compute_coerce_unsized_info(impl_did={:?})", impl_did);
|
||||
|
||||
// this provider should only get invoked for local def-ids
|
||||
|
@ -38,7 +38,7 @@ struct InherentCollect<'tcx> {
|
||||
impls_map: CrateInherentImpls,
|
||||
}
|
||||
|
||||
impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
||||
impl<'tcx> ItemLikeVisitor<'_> for InherentCollect<'tcx> {
|
||||
fn visit_item(&mut self, item: &hir::Item<'_>) {
|
||||
let (ty, assoc_items) = match item.kind {
|
||||
hir::ItemKind::Impl(hir::Impl { of_trait: None, ref self_ty, items, .. }) => {
|
||||
@ -370,7 +370,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
||||
fn visit_foreign_item(&mut self, _foreign_item: &hir::ForeignItem<'_>) {}
|
||||
}
|
||||
|
||||
impl InherentCollect<'tcx> {
|
||||
impl<'tcx> InherentCollect<'tcx> {
|
||||
fn check_def_id(&mut self, item: &hir::Item<'_>, def_id: DefId) {
|
||||
if let Some(def_id) = def_id.as_local() {
|
||||
// Add the implementation to the mapping from implementation to base
|
||||
|
@ -18,7 +18,7 @@ struct InherentOverlapChecker<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
}
|
||||
|
||||
impl InherentOverlapChecker<'tcx> {
|
||||
impl<'tcx> InherentOverlapChecker<'tcx> {
|
||||
/// Checks whether any associated items in impls 1 and 2 share the same identifier and
|
||||
/// namespace.
|
||||
fn impls_have_common_items(
|
||||
@ -115,8 +115,8 @@ impl InherentOverlapChecker<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl ItemLikeVisitor<'v> for InherentOverlapChecker<'tcx> {
|
||||
fn visit_item(&mut self, item: &'v hir::Item<'v>) {
|
||||
impl<'tcx> ItemLikeVisitor<'_> for InherentOverlapChecker<'tcx> {
|
||||
fn visit_item(&mut self, item: &hir::Item<'_>) {
|
||||
match item.kind {
|
||||
hir::ItemKind::Enum(..)
|
||||
| hir::ItemKind::Struct(..)
|
||||
@ -300,9 +300,9 @@ impl ItemLikeVisitor<'v> for InherentOverlapChecker<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, _trait_item: &hir::TraitItem<'v>) {}
|
||||
fn visit_trait_item(&mut self, _trait_item: &hir::TraitItem<'_>) {}
|
||||
|
||||
fn visit_impl_item(&mut self, _impl_item: &hir::ImplItem<'v>) {}
|
||||
fn visit_impl_item(&mut self, _impl_item: &hir::ImplItem<'_>) {}
|
||||
|
||||
fn visit_foreign_item(&mut self, _foreign_item: &hir::ForeignItem<'v>) {}
|
||||
fn visit_foreign_item(&mut self, _foreign_item: &hir::ForeignItem<'_>) {}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ fn orphan_check_impl(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), ErrorRep
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn emit_orphan_check_error(
|
||||
fn emit_orphan_check_error<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
sp: Span,
|
||||
trait_span: Span,
|
||||
|
@ -16,10 +16,10 @@ struct UnsafetyChecker<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
}
|
||||
|
||||
impl UnsafetyChecker<'tcx> {
|
||||
impl<'tcx> UnsafetyChecker<'tcx> {
|
||||
fn check_unsafety_coherence(
|
||||
&mut self,
|
||||
item: &'v hir::Item<'v>,
|
||||
item: &hir::Item<'_>,
|
||||
impl_generics: Option<&hir::Generics<'_>>,
|
||||
unsafety: hir::Unsafety,
|
||||
polarity: hir::ImplPolarity,
|
||||
@ -83,8 +83,8 @@ impl UnsafetyChecker<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl ItemLikeVisitor<'v> for UnsafetyChecker<'tcx> {
|
||||
fn visit_item(&mut self, item: &'v hir::Item<'v>) {
|
||||
impl<'tcx> ItemLikeVisitor<'_> for UnsafetyChecker<'tcx> {
|
||||
fn visit_item(&mut self, item: &hir::Item<'_>) {
|
||||
if let hir::ItemKind::Impl(ref impl_) = item.kind {
|
||||
self.check_unsafety_coherence(
|
||||
item,
|
||||
|
@ -147,7 +147,7 @@ struct CollectItemTypesVisitor<'tcx> {
|
||||
/// If there are any placeholder types (`_`), emit an error explaining that this is not allowed
|
||||
/// and suggest adding type parameters in the appropriate place, taking into consideration any and
|
||||
/// all already existing generic type parameters to avoid suggesting a name that is already in use.
|
||||
crate fn placeholder_type_error(
|
||||
crate fn placeholder_type_error<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
span: Option<Span>,
|
||||
generics: &[hir::GenericParam<'_>],
|
||||
@ -223,7 +223,10 @@ crate fn placeholder_type_error(
|
||||
err.emit();
|
||||
}
|
||||
|
||||
fn reject_placeholder_type_signatures_in_item(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) {
|
||||
fn reject_placeholder_type_signatures_in_item<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
item: &'tcx hir::Item<'tcx>,
|
||||
) {
|
||||
let (generics, suggest) = match &item.kind {
|
||||
hir::ItemKind::Union(_, generics)
|
||||
| hir::ItemKind::Enum(_, generics)
|
||||
@ -251,7 +254,7 @@ fn reject_placeholder_type_signatures_in_item(tcx: TyCtxt<'tcx>, item: &'tcx hir
|
||||
);
|
||||
}
|
||||
|
||||
impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
|
||||
impl<'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
|
||||
type Map = Map<'tcx>;
|
||||
|
||||
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
||||
@ -311,7 +314,7 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Utility types and common code for the above passes.
|
||||
|
||||
fn bad_placeholder_type(
|
||||
fn bad_placeholder_type<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
mut spans: Vec<Span>,
|
||||
kind: &'static str,
|
||||
@ -332,7 +335,7 @@ fn bad_placeholder_type(
|
||||
err
|
||||
}
|
||||
|
||||
impl ItemCtxt<'tcx> {
|
||||
impl<'tcx> ItemCtxt<'tcx> {
|
||||
pub fn new(tcx: TyCtxt<'tcx>, item_def_id: DefId) -> ItemCtxt<'tcx> {
|
||||
ItemCtxt { tcx, item_def_id }
|
||||
}
|
||||
@ -350,7 +353,7 @@ impl ItemCtxt<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl AstConv<'tcx> for ItemCtxt<'tcx> {
|
||||
impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
@ -643,7 +646,7 @@ fn type_param_predicates(
|
||||
result
|
||||
}
|
||||
|
||||
impl ItemCtxt<'tcx> {
|
||||
impl<'tcx> ItemCtxt<'tcx> {
|
||||
/// Finds bounds from `hir::Generics`. This requires scanning through the
|
||||
/// AST. We do this to avoid having to convert *all* the bounds, which
|
||||
/// would create artificial cycles. Instead, we can only convert the
|
||||
@ -1239,7 +1242,7 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option<S
|
||||
has_late_bound_regions: Option<Span>,
|
||||
}
|
||||
|
||||
impl Visitor<'tcx> for LateBoundRegionsDetector<'tcx> {
|
||||
impl<'tcx> Visitor<'tcx> for LateBoundRegionsDetector<'tcx> {
|
||||
type Map = intravisit::ErasedMap<'tcx>;
|
||||
|
||||
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
||||
@ -1746,7 +1749,7 @@ fn is_suggestable_infer_ty(ty: &hir::Ty<'_>) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_infer_ret_ty(output: &'hir hir::FnRetTy<'hir>) -> Option<&'hir hir::Ty<'hir>> {
|
||||
pub fn get_infer_ret_ty<'hir>(output: &'hir hir::FnRetTy<'hir>) -> Option<&'hir hir::Ty<'hir>> {
|
||||
if let hir::FnRetTy::Return(ty) = output {
|
||||
if is_suggestable_infer_ty(ty) {
|
||||
return Some(&*ty);
|
||||
|
@ -731,7 +731,7 @@ fn infer_placeholder_type<'a>(
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeFolder<'tcx> for MakeNameable<'tcx> {
|
||||
impl<'tcx> TypeFolder<'tcx> for MakeNameable<'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
@ -482,7 +482,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn walk_struct_expr(
|
||||
fn walk_struct_expr<'hir>(
|
||||
&mut self,
|
||||
fields: &[hir::ExprField<'_>],
|
||||
opt_with: &Option<&'hir hir::Expr<'_>>,
|
||||
@ -705,7 +705,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
||||
/// - When reporting the Place back to the Delegate, ensure that the UpvarId uses the enclosing
|
||||
/// closure as the DefId.
|
||||
fn walk_captures(&mut self, closure_expr: &hir::Expr<'_>) {
|
||||
fn upvar_is_local_variable(
|
||||
fn upvar_is_local_variable<'tcx>(
|
||||
upvars: Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>>,
|
||||
upvar_id: &hir::HirId,
|
||||
body_owner_is_closure: bool,
|
||||
@ -846,7 +846,7 @@ fn delegate_consume<'a, 'tcx>(
|
||||
}
|
||||
}
|
||||
|
||||
fn is_multivariant_adt(ty: Ty<'tcx>) -> bool {
|
||||
fn is_multivariant_adt(ty: Ty<'_>) -> bool {
|
||||
if let ty::Adt(def, _) = ty.kind() {
|
||||
// Note that if a non-exhaustive SingleVariant is defined in another crate, we need
|
||||
// to assume that more cases will be added to the variant in the future. This mean
|
||||
|
@ -76,7 +76,7 @@ struct ImplWfCheck<'tcx> {
|
||||
min_specialization: bool,
|
||||
}
|
||||
|
||||
impl ItemLikeVisitor<'tcx> for ImplWfCheck<'tcx> {
|
||||
impl<'tcx> ItemLikeVisitor<'tcx> for ImplWfCheck<'tcx> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
||||
if let hir::ItemKind::Impl(ref impl_) = item.kind {
|
||||
enforce_impl_params_are_constrained(self.tcx, item.def_id, impl_.items);
|
||||
|
@ -59,9 +59,7 @@ This API is completely unstable and subject to change.
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(if_let_guard)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(is_sorted)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(let_else)]
|
||||
#![feature(min_specialization)]
|
||||
#![feature(nll)]
|
||||
|
@ -12,7 +12,7 @@ struct OutlivesTest<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
}
|
||||
|
||||
impl ItemLikeVisitor<'tcx> for OutlivesTest<'tcx> {
|
||||
impl<'tcx> ItemLikeVisitor<'tcx> for OutlivesTest<'tcx> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
||||
// For unit testing: check for a special "rustc_outlives"
|
||||
// attribute and report an error with various results if found.
|
||||
|
@ -12,7 +12,7 @@ struct VarianceTest<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
}
|
||||
|
||||
impl ItemLikeVisitor<'tcx> for VarianceTest<'tcx> {
|
||||
impl<'tcx> ItemLikeVisitor<'tcx> for VarianceTest<'tcx> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
||||
// For unit testing: check for a special "rustc_variance"
|
||||
// attribute and report an error with various results if found.
|
||||
|
@ -107,7 +107,6 @@
|
||||
#![feature(inherent_ascii_escape)]
|
||||
#![feature(inplace_iteration)]
|
||||
#![feature(iter_advance_by)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(layout_for_ptr)]
|
||||
#![feature(maybe_uninit_extra)]
|
||||
#![feature(maybe_uninit_slice)]
|
||||
|
@ -54,7 +54,7 @@ pub use self::zip::TrustedRandomAccess;
|
||||
#[unstable(feature = "trusted_random_access", issue = "none")]
|
||||
pub use self::zip::TrustedRandomAccessNoCoerce;
|
||||
|
||||
#[unstable(feature = "iter_zip", issue = "83574")]
|
||||
#[stable(feature = "iter_zip", since = "1.59.0")]
|
||||
pub use self::zip::zip;
|
||||
|
||||
/// This trait provides transitive access to source-stage in an iterator-adapter pipeline
|
||||
|
@ -40,7 +40,6 @@ impl<A: Iterator, B: Iterator> Zip<A, B> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(iter_zip)]
|
||||
/// use std::iter::zip;
|
||||
///
|
||||
/// let xs = [1, 2, 3];
|
||||
@ -63,7 +62,7 @@ impl<A: Iterator, B: Iterator> Zip<A, B> {
|
||||
/// assert_eq!(iter.next().unwrap(), ((3, 6), 9));
|
||||
/// assert!(iter.next().is_none());
|
||||
/// ```
|
||||
#[unstable(feature = "iter_zip", issue = "83574")]
|
||||
#[stable(feature = "iter_zip", since = "1.59.0")]
|
||||
pub fn zip<A, B>(a: A, b: B) -> Zip<A::IntoIter, B::IntoIter>
|
||||
where
|
||||
A: IntoIterator,
|
||||
|
@ -391,7 +391,7 @@ pub use self::traits::{
|
||||
DoubleEndedIterator, ExactSizeIterator, Extend, FromIterator, IntoIterator, Product, Sum,
|
||||
};
|
||||
|
||||
#[unstable(feature = "iter_zip", issue = "83574")]
|
||||
#[stable(feature = "iter_zip", since = "1.59.0")]
|
||||
pub use self::adapters::zip;
|
||||
#[stable(feature = "iter_cloned", since = "1.1.0")]
|
||||
pub use self::adapters::Cloned;
|
||||
|
@ -3028,7 +3028,8 @@ pub trait Iterator {
|
||||
///
|
||||
/// Instead of stopping at [`None`], the iterator will instead start again,
|
||||
/// from the beginning. After iterating again, it will start at the
|
||||
/// beginning again. And again. And again. Forever.
|
||||
/// beginning again. And again. And again. Forever. Note that in case the
|
||||
/// original iterator is empty, the resulting iterator will also be empty.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -115,15 +115,14 @@ use crate::ops::ControlFlow;
|
||||
#[unstable(feature = "try_trait_v2", issue = "84277")]
|
||||
#[rustc_on_unimplemented(
|
||||
on(
|
||||
all(from_method = "from_output", from_desugaring = "TryBlock"),
|
||||
all(from_desugaring = "TryBlock"),
|
||||
message = "a `try` block must return `Result` or `Option` \
|
||||
(or another type that implements `{Try}`)",
|
||||
label = "could not wrap the final value of the block as `{Self}` doesn't implement `Try`",
|
||||
),
|
||||
on(
|
||||
all(from_method = "branch", from_desugaring = "QuestionMark"),
|
||||
message = "the `?` operator can only be applied to values \
|
||||
that implement `{Try}`",
|
||||
all(from_desugaring = "QuestionMark"),
|
||||
message = "the `?` operator can only be applied to values that implement `{Try}`",
|
||||
label = "the `?` operator cannot be applied to type `{Self}`"
|
||||
)
|
||||
)]
|
||||
@ -226,7 +225,6 @@ pub trait Try: FromResidual {
|
||||
#[rustc_on_unimplemented(
|
||||
on(
|
||||
all(
|
||||
from_method = "from_residual",
|
||||
from_desugaring = "QuestionMark",
|
||||
_Self = "std::result::Result<T, E>",
|
||||
R = "std::option::Option<std::convert::Infallible>"
|
||||
@ -238,7 +236,6 @@ pub trait Try: FromResidual {
|
||||
),
|
||||
on(
|
||||
all(
|
||||
from_method = "from_residual",
|
||||
from_desugaring = "QuestionMark",
|
||||
_Self = "std::result::Result<T, E>",
|
||||
),
|
||||
@ -252,7 +249,6 @@ pub trait Try: FromResidual {
|
||||
),
|
||||
on(
|
||||
all(
|
||||
from_method = "from_residual",
|
||||
from_desugaring = "QuestionMark",
|
||||
_Self = "std::option::Option<T>",
|
||||
R = "std::result::Result<T, E>",
|
||||
@ -264,7 +260,6 @@ pub trait Try: FromResidual {
|
||||
),
|
||||
on(
|
||||
all(
|
||||
from_method = "from_residual",
|
||||
from_desugaring = "QuestionMark",
|
||||
_Self = "std::option::Option<T>",
|
||||
),
|
||||
@ -277,7 +272,6 @@ pub trait Try: FromResidual {
|
||||
),
|
||||
on(
|
||||
all(
|
||||
from_method = "from_residual",
|
||||
from_desugaring = "QuestionMark",
|
||||
_Self = "std::ops::ControlFlow<B, C>",
|
||||
R = "std::ops::ControlFlow<B, C>",
|
||||
@ -290,7 +284,6 @@ pub trait Try: FromResidual {
|
||||
),
|
||||
on(
|
||||
all(
|
||||
from_method = "from_residual",
|
||||
from_desugaring = "QuestionMark",
|
||||
_Self = "std::ops::ControlFlow<B, C>",
|
||||
// `R` is not a `ControlFlow`, as that case was matched previously
|
||||
@ -301,10 +294,7 @@ pub trait Try: FromResidual {
|
||||
enclosing_scope = "this function returns a `ControlFlow`",
|
||||
),
|
||||
on(
|
||||
all(
|
||||
from_method = "from_residual",
|
||||
from_desugaring = "QuestionMark"
|
||||
),
|
||||
all(from_desugaring = "QuestionMark"),
|
||||
message = "the `?` operator can only be used in {ItemContext} \
|
||||
that returns `Result` or `Option` \
|
||||
(or another type that implements `{FromResidual}`)",
|
||||
|
@ -292,7 +292,6 @@
|
||||
#![feature(int_log)]
|
||||
#![feature(into_future)]
|
||||
#![feature(intra_doc_pointers)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(lang_items)]
|
||||
#![feature(linkage)]
|
||||
#![feature(llvm_asm)]
|
||||
|
@ -41,9 +41,9 @@
|
||||
41| 1| // executed asynchronously.
|
||||
42| 1| match x {
|
||||
43| 1| y if c(x).await == y + 1 => { d().await; }
|
||||
^0 ^0
|
||||
^0 ^0 ^0 ^0
|
||||
44| 1| y if f().await == y + 1 => (),
|
||||
^0 ^0
|
||||
^0 ^0 ^0
|
||||
45| 1| _ => (),
|
||||
46| | }
|
||||
47| 1|}
|
||||
|
@ -46,6 +46,7 @@ impl CodegenBackend for TheBackend {
|
||||
&self,
|
||||
ongoing_codegen: Box<dyn Any>,
|
||||
_sess: &Session,
|
||||
_outputs: &OutputFilenames,
|
||||
) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorReported> {
|
||||
let codegen_results = ongoing_codegen
|
||||
.downcast::<CodegenResults>()
|
||||
|
@ -14,10 +14,10 @@ LL | let a;
|
||||
| ^ cannot infer type
|
||||
|
|
||||
note: the type is part of the `async fn` body because of this `await`
|
||||
--> $DIR/async-error-span.rs:14:5
|
||||
--> $DIR/async-error-span.rs:14:17
|
||||
|
|
||||
LL | get_future().await;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -6,13 +6,13 @@ LL | assert_send(local_dropped_before_await());
|
||||
|
|
||||
= help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>`
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/async-fn-nonsend.rs:24:5
|
||||
--> $DIR/async-fn-nonsend.rs:24:10
|
||||
|
|
||||
LL | let x = non_send();
|
||||
| - has type `impl Debug` which is not `Send`
|
||||
LL | drop(x);
|
||||
LL | fut().await;
|
||||
| ^^^^^^^^^^^ await occurs here, with `x` maybe used later
|
||||
| ^^^^^^ await occurs here, with `x` maybe used later
|
||||
LL | }
|
||||
| - `x` is later dropped here
|
||||
note: required by a bound in `assert_send`
|
||||
@ -29,12 +29,12 @@ LL | assert_send(non_send_temporary_in_match());
|
||||
|
|
||||
= help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>`
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/async-fn-nonsend.rs:33:20
|
||||
--> $DIR/async-fn-nonsend.rs:33:25
|
||||
|
|
||||
LL | match Some(non_send()) {
|
||||
| ---------- has type `impl Debug` which is not `Send`
|
||||
LL | Some(_) => fut().await,
|
||||
| ^^^^^^^^^^^ await occurs here, with `non_send()` maybe used later
|
||||
| ^^^^^^ await occurs here, with `non_send()` maybe used later
|
||||
...
|
||||
LL | }
|
||||
| - `non_send()` is later dropped here
|
||||
@ -52,13 +52,13 @@ LL | assert_send(non_sync_with_method_call());
|
||||
|
|
||||
= help: the trait `Send` is not implemented for `dyn std::fmt::Write`
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/async-fn-nonsend.rs:42:9
|
||||
--> $DIR/async-fn-nonsend.rs:42:14
|
||||
|
|
||||
LL | let f: &mut std::fmt::Formatter = panic!();
|
||||
| - has type `&mut Formatter<'_>` which is not `Send`
|
||||
LL | if non_sync().fmt(f).unwrap() == () {
|
||||
LL | fut().await;
|
||||
| ^^^^^^^^^^^ await occurs here, with `f` maybe used later
|
||||
| ^^^^^^ await occurs here, with `f` maybe used later
|
||||
LL | }
|
||||
LL | }
|
||||
| - `f` is later dropped here
|
||||
|
@ -162,68 +162,68 @@ LL | let _ = (await bar())?;
|
||||
| ^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:71:13
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:71:18
|
||||
|
|
||||
LL | fn foo13() -> Result<(), ()> {
|
||||
| ----- this is not `async`
|
||||
LL | let _ = bar().await();
|
||||
| ^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:76:13
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:76:18
|
||||
|
|
||||
LL | fn foo14() -> Result<(), ()> {
|
||||
| ----- this is not `async`
|
||||
LL | let _ = bar().await()?;
|
||||
| ^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:81:13
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:81:18
|
||||
|
|
||||
LL | fn foo15() -> Result<(), ()> {
|
||||
| ----- this is not `async`
|
||||
LL | let _ = bar().await;
|
||||
| ^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:85:13
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:85:18
|
||||
|
|
||||
LL | fn foo16() -> Result<(), ()> {
|
||||
| ----- this is not `async`
|
||||
LL | let _ = bar().await?;
|
||||
| ^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:90:17
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:90:22
|
||||
|
|
||||
LL | fn foo() -> Result<(), ()> {
|
||||
| --- this is not `async`
|
||||
LL | let _ = bar().await?;
|
||||
| ^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:97:17
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:97:22
|
||||
|
|
||||
LL | let foo = || {
|
||||
| -- this is not `async`
|
||||
LL | let _ = bar().await?;
|
||||
| ^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:113:17
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:113:29
|
||||
|
|
||||
LL | fn foo() -> Result<(), ()> {
|
||||
| --- this is not `async`
|
||||
LL | let _ = await!(bar())?;
|
||||
| ^^^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:121:17
|
||||
--> $DIR/incorrect-syntax-suggestions.rs:121:29
|
||||
|
|
||||
LL | let foo = || {
|
||||
| -- this is not `async`
|
||||
LL | let _ = await!(bar())?;
|
||||
| ^^^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^ only allowed inside `async` functions and blocks
|
||||
|
||||
error: aborting due to 33 previous errors
|
||||
|
||||
|
@ -6,12 +6,12 @@ LL | is_sync(bar());
|
||||
|
|
||||
= help: within `impl Future<Output = ()>`, the trait `Sync` is not implemented for `Foo`
|
||||
note: future is not `Sync` as this value is used across an await
|
||||
--> $DIR/issue-64130-1-sync.rs:15:5
|
||||
--> $DIR/issue-64130-1-sync.rs:15:10
|
||||
|
|
||||
LL | let x = Foo;
|
||||
| - has type `Foo` which is not `Sync`
|
||||
LL | baz().await;
|
||||
| ^^^^^^^^^^^ await occurs here, with `x` maybe used later
|
||||
| ^^^^^^ await occurs here, with `x` maybe used later
|
||||
LL | }
|
||||
| - `x` is later dropped here
|
||||
note: required by a bound in `is_sync`
|
||||
|
@ -6,12 +6,12 @@ LL | is_send(bar());
|
||||
|
|
||||
= help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Foo`
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/issue-64130-2-send.rs:15:5
|
||||
--> $DIR/issue-64130-2-send.rs:15:10
|
||||
|
|
||||
LL | let x = Foo;
|
||||
| - has type `Foo` which is not `Send`
|
||||
LL | baz().await;
|
||||
| ^^^^^^^^^^^ await occurs here, with `x` maybe used later
|
||||
| ^^^^^^ await occurs here, with `x` maybe used later
|
||||
LL | }
|
||||
| - `x` is later dropped here
|
||||
note: required by a bound in `is_send`
|
||||
|
@ -8,12 +8,12 @@ LL | is_qux(bar());
|
||||
| ^^^^^ within `impl Future<Output = ()>`, the trait `Qux` is not implemented for `Foo`
|
||||
|
|
||||
note: future does not implement `Qux` as this value is used across an await
|
||||
--> $DIR/issue-64130-3-other.rs:18:5
|
||||
--> $DIR/issue-64130-3-other.rs:18:10
|
||||
|
|
||||
LL | let x = Foo;
|
||||
| - has type `Foo` which does not implement `Qux`
|
||||
LL | baz().await;
|
||||
| ^^^^^^^^^^^ await occurs here, with `x` maybe used later
|
||||
| ^^^^^^ await occurs here, with `x` maybe used later
|
||||
LL | }
|
||||
| - `x` is later dropped here
|
||||
note: required by a bound in `is_qux`
|
||||
|
@ -6,13 +6,13 @@ LL | pub fn foo() -> impl Future + Send {
|
||||
|
|
||||
= help: the trait `Sync` is not implemented for `(dyn Any + Send + 'static)`
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/issue-64130-4-async-move.rs:21:26
|
||||
--> $DIR/issue-64130-4-async-move.rs:21:31
|
||||
|
|
||||
LL | match client.status() {
|
||||
| ------ has type `&Client` which is not `Send`
|
||||
LL | 200 => {
|
||||
LL | let _x = get().await;
|
||||
| ^^^^^^^^^^^ await occurs here, with `client` maybe used later
|
||||
| ^^^^^^ await occurs here, with `client` maybe used later
|
||||
...
|
||||
LL | }
|
||||
| - `client` is later dropped here
|
||||
|
@ -6,12 +6,12 @@ LL | is_send(foo());
|
||||
|
|
||||
= help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `MutexGuard<'_, u32>`
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/issue-64130-non-send-future-diags.rs:17:5
|
||||
--> $DIR/issue-64130-non-send-future-diags.rs:17:10
|
||||
|
|
||||
LL | let g = x.lock().unwrap();
|
||||
| - has type `MutexGuard<'_, u32>` which is not `Send`
|
||||
LL | baz().await;
|
||||
| ^^^^^^^^^^^ await occurs here, with `g` maybe used later
|
||||
| ^^^^^^ await occurs here, with `g` maybe used later
|
||||
LL | }
|
||||
| - `g` is later dropped here
|
||||
note: required by a bound in `is_send`
|
||||
|
@ -6,12 +6,12 @@ LL | spawn(async {
|
||||
|
|
||||
= help: within `impl Future<Output = [async output]>`, the trait `Send` is not implemented for `*mut ()`
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/issue-67252-unnamed-future.rs:20:9
|
||||
--> $DIR/issue-67252-unnamed-future.rs:20:16
|
||||
|
|
||||
LL | let _a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send`
|
||||
| -- has type `*mut ()` which is not `Send`
|
||||
LL | AFuture.await;
|
||||
| ^^^^^^^^^^^^^ await occurs here, with `_a` maybe used later
|
||||
| ^^^^^^ await occurs here, with `_a` maybe used later
|
||||
LL | });
|
||||
| - `_a` is later dropped here
|
||||
note: required by a bound in `spawn`
|
||||
|
@ -1,10 +1,10 @@
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/issue-70594.rs:4:9
|
||||
--> $DIR/issue-70594.rs:4:11
|
||||
|
|
||||
LL | async fn fun() {
|
||||
| --- this is not `async`
|
||||
LL | [1; ().await];
|
||||
| ^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0744]: `.await` is not allowed in a `const`
|
||||
--> $DIR/issue-70594.rs:4:9
|
||||
@ -13,20 +13,25 @@ LL | [1; ().await];
|
||||
| ^^^^^^^^
|
||||
|
||||
error[E0744]: `.await` is not allowed in a `const`
|
||||
--> $DIR/issue-70594.rs:4:9
|
||||
--> $DIR/issue-70594.rs:4:11
|
||||
|
|
||||
LL | [1; ().await];
|
||||
| ^^^^^^^^
|
||||
| ^^^^^^
|
||||
|
||||
error[E0277]: `()` is not a future
|
||||
--> $DIR/issue-70594.rs:4:9
|
||||
--> $DIR/issue-70594.rs:4:11
|
||||
|
|
||||
LL | [1; ().await];
|
||||
| ^^^^^^^^ `()` is not a future
|
||||
| ^^^^^^ `()` is not a future
|
||||
|
|
||||
= help: the trait `Future` is not implemented for `()`
|
||||
= note: () must be a future or must implement `IntoFuture` to be awaited
|
||||
= note: required because of the requirements on the impl of `IntoFuture` for `()`
|
||||
help: remove the `.await`
|
||||
|
|
||||
LL - [1; ().await];
|
||||
LL + [1; ()];
|
||||
|
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
@ -6,25 +6,20 @@ LL | fn foo(tx: std::sync::mpsc::Sender<i32>) -> impl Future + Send {
|
||||
|
|
||||
= help: the trait `Sync` is not implemented for `Sender<i32>`
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/issue-70935-complex-spans.rs:13:9
|
||||
--> $DIR/issue-70935-complex-spans.rs:15:11
|
||||
|
|
||||
LL | / baz(|| async{
|
||||
LL | baz(|| async{
|
||||
| _____________-
|
||||
LL | | foo(tx.clone());
|
||||
LL | | }).await;
|
||||
| |________________^ first, await occurs here, with the value maybe used later...
|
||||
| | - ^^^^^^ await occurs here, with the value maybe used later
|
||||
| |_________|
|
||||
| has type `[closure@$DIR/issue-70935-complex-spans.rs:13:13: 15:10]` which is not `Send`
|
||||
note: the value is later dropped here
|
||||
--> $DIR/issue-70935-complex-spans.rs:15:17
|
||||
|
|
||||
LL | }).await;
|
||||
| ^
|
||||
note: this has type `[closure@$DIR/issue-70935-complex-spans.rs:13:13: 15:10]` which is not `Send`
|
||||
--> $DIR/issue-70935-complex-spans.rs:13:13
|
||||
|
|
||||
LL | baz(|| async{
|
||||
| _____________^
|
||||
LL | | foo(tx.clone());
|
||||
LL | | }).await;
|
||||
| |_________^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -6,12 +6,12 @@ LL | fake_spawn(wrong_mutex());
|
||||
|
|
||||
= help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `MutexGuard<'_, i32>`
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/issue-71137.rs:14:5
|
||||
--> $DIR/issue-71137.rs:14:25
|
||||
|
|
||||
LL | let mut guard = m.lock().unwrap();
|
||||
| --------- has type `MutexGuard<'_, i32>` which is not `Send`
|
||||
LL | (async { "right"; }).await;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ await occurs here, with `mut guard` maybe used later
|
||||
| ^^^^^^ await occurs here, with `mut guard` maybe used later
|
||||
LL | *guard += 1;
|
||||
LL | }
|
||||
| - `mut guard` is later dropped here
|
||||
|
@ -1,8 +1,8 @@
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/issue-51719.rs:8:19
|
||||
--> $DIR/issue-51719.rs:8:24
|
||||
|
|
||||
LL | let _gen = || foo().await;
|
||||
| -- ^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
| -- ^^^^^^ only allowed inside `async` functions and blocks
|
||||
| |
|
||||
| this is not `async`
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/issue-51751.rs:9:20
|
||||
--> $DIR/issue-51751.rs:9:26
|
||||
|
|
||||
LL | fn main() {
|
||||
| ---- this is not `async`
|
||||
LL | let result = inc(10000);
|
||||
LL | let finished = result.await;
|
||||
| ^^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -6,10 +6,10 @@ fn main() {
|
||||
async { let (); }.await;
|
||||
//~^ ERROR `await` is only allowed inside `async` functions and blocks
|
||||
async {
|
||||
//~^ ERROR `await` is only allowed inside `async` functions and blocks
|
||||
let task1 = print_dur().await;
|
||||
}.await;
|
||||
//~^ ERROR `await` is only allowed inside `async` functions and blocks
|
||||
(|_| 2333).await;
|
||||
//~^ ERROR `await` is only allowed inside `async` functions and blocks
|
||||
//~^^ ERROR
|
||||
//~| ERROR is not a future
|
||||
}
|
||||
|
@ -1,41 +1,43 @@
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/issue-62009-1.rs:6:5
|
||||
--> $DIR/issue-62009-1.rs:6:22
|
||||
|
|
||||
LL | fn main() {
|
||||
| ---- this is not `async`
|
||||
LL | async { let (); }.await;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/issue-62009-1.rs:8:5
|
||||
--> $DIR/issue-62009-1.rs:10:6
|
||||
|
|
||||
LL | fn main() {
|
||||
| ---- this is not `async`
|
||||
...
|
||||
LL | / async {
|
||||
LL | |
|
||||
LL | | let task1 = print_dur().await;
|
||||
LL | | }.await;
|
||||
| |___________^ only allowed inside `async` functions and blocks
|
||||
LL | }.await;
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/issue-62009-1.rs:12:5
|
||||
--> $DIR/issue-62009-1.rs:12:15
|
||||
|
|
||||
LL | fn main() {
|
||||
| ---- this is not `async`
|
||||
...
|
||||
LL | (|_| 2333).await;
|
||||
| ^^^^^^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error[E0277]: `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]` is not a future
|
||||
--> $DIR/issue-62009-1.rs:12:5
|
||||
--> $DIR/issue-62009-1.rs:12:15
|
||||
|
|
||||
LL | (|_| 2333).await;
|
||||
| ^^^^^^^^^^^^^^^^ `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]` is not a future
|
||||
| ^^^^^^ `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]` is not a future
|
||||
|
|
||||
= help: the trait `Future` is not implemented for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]`
|
||||
= note: [closure@$DIR/issue-62009-1.rs:12:5: 12:15] must be a future or must implement `IntoFuture` to be awaited
|
||||
= note: required because of the requirements on the impl of `IntoFuture` for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]`
|
||||
help: remove the `.await`
|
||||
|
|
||||
LL - (|_| 2333).await;
|
||||
LL + (|_| 2333);
|
||||
|
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/issue-62009-2.rs:8:5
|
||||
--> $DIR/issue-62009-2.rs:8:22
|
||||
|
|
||||
LL | fn main() {
|
||||
| ---- this is not `async`
|
||||
LL | (async || 2333)().await;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -6,17 +6,17 @@ LL | assert_send(async {
|
||||
|
|
||||
= help: within `impl Future<Output = [async output]>`, the trait `Send` is not implemented for `*const u8`
|
||||
note: future is not `Send` as this value is used across an await
|
||||
--> $DIR/issue-65436-raw-ptr-not-send.rs:14:9
|
||||
--> $DIR/issue-65436-raw-ptr-not-send.rs:14:35
|
||||
|
|
||||
LL | bar(Foo(std::ptr::null())).await;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ first, await occurs here, with `std::ptr::null()` maybe used later...
|
||||
| ---------------- ^^^^^^ await occurs here, with `std::ptr::null()` maybe used later
|
||||
| |
|
||||
| has type `*const u8` which is not `Send`
|
||||
note: `std::ptr::null()` is later dropped here
|
||||
--> $DIR/issue-65436-raw-ptr-not-send.rs:14:41
|
||||
|
|
||||
LL | bar(Foo(std::ptr::null())).await;
|
||||
| ---------------- ^
|
||||
| |
|
||||
| has type `*const u8` which is not `Send`
|
||||
| ^
|
||||
help: consider moving this into a `let` binding to create a shorter lived borrow
|
||||
--> $DIR/issue-65436-raw-ptr-not-send.rs:14:13
|
||||
|
|
||||
|
@ -1,11 +1,11 @@
|
||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||
--> $DIR/non-async-enclosing-span.rs:9:13
|
||||
--> $DIR/non-async-enclosing-span.rs:9:27
|
||||
|
|
||||
LL | fn main() {
|
||||
| ---- this is not `async`
|
||||
LL | let x = move || {};
|
||||
LL | let y = do_the_thing().await;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ only allowed inside `async` functions and blocks
|
||||
| ^^^^^^ only allowed inside `async` functions and blocks
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
14
src/test/ui/async-await/unnecessary-await.rs
Normal file
14
src/test/ui/async-await/unnecessary-await.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// edition:2018
|
||||
|
||||
async fn foo () { }
|
||||
fn bar() -> impl std::future::Future { async {} }
|
||||
fn boo() {}
|
||||
|
||||
async fn baz() -> std::io::Result<()> {
|
||||
foo().await;
|
||||
boo().await; //~ ERROR `()` is not a future
|
||||
bar().await;
|
||||
std::io::Result::Ok(())
|
||||
}
|
||||
|
||||
fn main() {}
|
24
src/test/ui/async-await/unnecessary-await.stderr
Normal file
24
src/test/ui/async-await/unnecessary-await.stderr
Normal file
@ -0,0 +1,24 @@
|
||||
error[E0277]: `()` is not a future
|
||||
--> $DIR/unnecessary-await.rs:9:10
|
||||
|
|
||||
LL | boo().await;
|
||||
| -----^^^^^^ `()` is not a future
|
||||
| |
|
||||
| this call returns `()`
|
||||
|
|
||||
= help: the trait `Future` is not implemented for `()`
|
||||
= note: () must be a future or must implement `IntoFuture` to be awaited
|
||||
= note: required because of the requirements on the impl of `IntoFuture` for `()`
|
||||
help: remove the `.await`
|
||||
|
|
||||
LL - boo().await;
|
||||
LL + boo();
|
||||
|
|
||||
help: alternatively, consider making `fn boo` asynchronous
|
||||
|
|
||||
LL | async fn boo() {}
|
||||
| +++++
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user