Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #91945

Merged
merged 32 commits into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3f2a1c9
Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`
tmiasko Dec 13, 2021
7f2f9c6
Iterator::cycle() — document empty iterator special case
xkr47 Dec 13, 2021
715c562
[ReviewFix] Linguistics
xkr47 Dec 13, 2021
7227a87
When `.await` is called on a non-`Future` expression, suggest removal
estebank Nov 16, 2021
75b6275
Reduce verbosity when calling `for`-loop on non-`Iterator` expression
estebank Nov 16, 2021
caf0c1b
Reduce verbosity for `?` on non-`Try` expressions
estebank Nov 16, 2021
81a3b90
Further silence `?` errors
estebank Nov 16, 2021
79749d6
Remove yet more output from `for`-loop and `?` errors
estebank Nov 16, 2021
4f2b1c0
Remove unnecessary argument
estebank Nov 16, 2021
d45e030
Fix mistake
estebank Nov 16, 2021
f640438
Keep info on pre-desugaring expression for better "incorrect `.await`…
estebank Nov 16, 2021
8888d0d
Fix clippy uses of QPath::LangItem
estebank Nov 16, 2021
b825b0f
Fix rebase and clippy tests
estebank Nov 16, 2021
9ecb141
tidy fix
estebank Nov 16, 2021
d59f74a
Simplify diagnostic logic
estebank Nov 17, 2021
64dea33
review comments
estebank Dec 2, 2021
1a7f2d5
review comment: change wording of suggestion
estebank Dec 10, 2021
64f88e8
fix clippy tests
estebank Dec 10, 2021
f2fc84f
fix coverage report test
estebank Dec 13, 2021
3011154
Revert "Set MACOSX_DEPLOYMENT_TARGET env var to default for linking i…
hkratz Dec 13, 2021
ae21dd0
Remove in_band_lifetimes
Patrick-Poitras Dec 14, 2021
a586e7d
Make suggestions from @jackh726; run fmt
Patrick-Poitras Dec 14, 2021
304ede6
Stabilize iter::zip.
Patrick-Poitras Dec 13, 2021
047adb5
Remove iter::zip feature gate from clippy
Patrick-Poitras Dec 14, 2021
d9dd360
Update cargo
ehuss Dec 14, 2021
272188e
Rollup merge of #90939 - estebank:wg-af-polish, r=tmandry
matthiaskrgr Dec 15, 2021
d6c802e
Rollup merge of #91859 - xkr47:patch-2, r=yaahc
matthiaskrgr Dec 15, 2021
ccfc22b
Rollup merge of #91868 - tmiasko:llvm-time-trace-out, r=oli-obk
matthiaskrgr Dec 15, 2021
2f270e4
Rollup merge of #91870 - rusticstuff:macosx_min_version_revert, r=Mar…
matthiaskrgr Dec 15, 2021
4e7497b
Rollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcm
matthiaskrgr Dec 15, 2021
6abad4c
Rollup merge of #91882 - Patrick-Poitras:remove-in-band-lifetimes-fro…
matthiaskrgr Dec 15, 2021
22fc403
Rollup merge of #91940 - ehuss:update-cargo, r=ehuss
matthiaskrgr Dec 15, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ dependencies = [

[[package]]
name = "cargo"
version = "0.59.0"
version = "0.60.0"
dependencies = [
"anyhow",
"atty",
Expand Down Expand Up @@ -419,7 +419,7 @@ dependencies = [

[[package]]
name = "cargo-util"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"anyhow",
"core-foundation",
Expand Down Expand Up @@ -768,7 +768,7 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634"

[[package]]
name = "crates-io"
version = "0.33.0"
version = "0.33.1"
dependencies = [
"anyhow",
"curl",
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_apfloat/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
70 changes: 55 additions & 15 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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))
}

Expand Down Expand Up @@ -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])
Expand All @@ -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 => {
Expand All @@ -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) =
Expand All @@ -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))
};
Expand All @@ -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)
};
Expand All @@ -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);
Expand Down Expand Up @@ -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> {
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -1417,6 +1451,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
head_span,
hir::LangItem::IntoIterIntoIter,
arena_vec![self; head],
None,
)
};

Expand Down Expand Up @@ -1472,6 +1507,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
unstable_span,
hir::LangItem::TryTraitBranch,
arena_vec![self; sub_expr],
None,
)
};

Expand Down Expand Up @@ -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)
}

Expand All @@ -1638,19 +1676,21 @@ 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(
&mut self,
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,
)
}
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

#![feature(crate_visibility_modifier)]
#![feature(box_patterns)]
#![feature(iter_zip)]
#![feature(never_type)]
#![recursion_limit = "256"]

Expand Down Expand Up @@ -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(
Expand All @@ -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))
}

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_cranelift/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>)>()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>")
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_codegen_llvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#![feature(crate_visibility_modifier)]
#![feature(extern_types)]
#![feature(in_band_lifetimes)]
#![feature(iter_zip)]
#![feature(nll)]
#![recursion_limit = "256"]

Expand Down Expand Up @@ -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>>()
Expand All @@ -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);
}
});

Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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());
}
}
Expand Down
Loading