Skip to content

Commit 25687ca

Browse files
committed
Auto merge of #73830 - Manishearth:rollup-8k68ysm, r=Manishearth
Rollup of 10 pull requests Successful merges: - #72796 (MIR sanity check: validate types on assignment) - #73243 (Add documentation to point to `File::open` or `OpenOptions::open` instead of `is_file` to check read/write possibility) - #73525 (Prepare for LLVM 11) - #73672 (Adds a clearer message for when the async keyword is missing from a f…) - #73708 (Explain move errors that occur due to method calls involving `self` (take two)) - #73758 (improper_ctypes: fix remaining `Reveal:All`) - #73763 (errors: use `-Z terminal-width` in JSON emitter) - #73796 (replace more `DefId`s with `LocalDefId`) - #73797 (fix typo in self-profile.md) - #73809 (Add links to fs::DirEntry::metadata) Failed merges: r? @ghost
2 parents 3b4a3d6 + cdb59d9 commit 25687ca

File tree

93 files changed

+1645
-623
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1645
-623
lines changed

src/doc/unstable-book/src/compiler-flags/self-profile.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ For example:
1313
First, run a compilation session and provide the `-Zself-profile` flag:
1414

1515
```console
16-
$ rustc --crate-name foo -Zself-profile`
16+
$ rustc --crate-name foo -Zself-profile
1717
```
1818

1919
This will generate three files in the working directory such as:

src/libcore/future/future.rs

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use crate::task::{Context, Poll};
2727
#[must_use = "futures do nothing unless you `.await` or poll them"]
2828
#[stable(feature = "futures_api", since = "1.36.0")]
2929
#[lang = "future_trait"]
30+
#[rustc_on_unimplemented(label = "`{Self}` is not a future", message = "`{Self}` is not a future")]
3031
pub trait Future {
3132
/// The type of value produced on completion.
3233
#[stable(feature = "futures_api", since = "1.36.0")]

src/libprofiler_builtins/build.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ fn main() {
2424
"InstrProfilingUtil.c",
2525
"InstrProfilingValue.c",
2626
"InstrProfilingWriter.c",
27+
// This file was renamed in LLVM 10.
28+
"InstrProfilingRuntime.cc",
29+
"InstrProfilingRuntime.cpp",
30+
// These files were added in LLVM 11.
31+
"InstrProfilingInternal.c",
32+
"InstrProfilingBiasVar.c",
2733
];
2834

2935
if target.contains("msvc") {
@@ -69,14 +75,12 @@ fn main() {
6975

7076
let src_root = root.join("lib").join("profile");
7177
for src in profile_sources {
72-
cfg.file(src_root.join(src));
78+
let path = src_root.join(src);
79+
if path.exists() {
80+
cfg.file(path);
81+
}
7382
}
7483

75-
// The file was renamed in LLVM 10.
76-
let old_runtime_path = src_root.join("InstrProfilingRuntime.cc");
77-
let new_runtime_path = src_root.join("InstrProfilingRuntime.cpp");
78-
cfg.file(if old_runtime_path.exists() { old_runtime_path } else { new_runtime_path });
79-
8084
cfg.include(root.join("include"));
8185
cfg.warnings(false);
8286
cfg.compile("profiler-rt");

src/librustc_ast_lowering/expr.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_data_structures::thin_vec::ThinVec;
99
use rustc_errors::struct_span_err;
1010
use rustc_hir as hir;
1111
use rustc_hir::def::Res;
12-
use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned};
12+
use rustc_span::source_map::{respan, DesugaringKind, ForLoopLoc, Span, Spanned};
1313
use rustc_span::symbol::{sym, Ident, Symbol};
1414
use rustc_target::asm;
1515
use std::collections::hash_map::Entry;
@@ -1361,9 +1361,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
13611361
body: &Block,
13621362
opt_label: Option<Label>,
13631363
) -> hir::Expr<'hir> {
1364+
let orig_head_span = head.span;
13641365
// expand <head>
13651366
let mut head = self.lower_expr_mut(head);
1366-
let desugared_span = self.mark_span_with_reason(DesugaringKind::ForLoop, head.span, None);
1367+
let desugared_span = self.mark_span_with_reason(
1368+
DesugaringKind::ForLoop(ForLoopLoc::Head),
1369+
orig_head_span,
1370+
None,
1371+
);
13671372
head.span = desugared_span;
13681373

13691374
let iter = Ident::with_dummy_span(sym::iter);
@@ -1458,10 +1463,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
14581463
// `mut iter => { ... }`
14591464
let iter_arm = self.arm(iter_pat, loop_expr);
14601465

1466+
let into_iter_span = self.mark_span_with_reason(
1467+
DesugaringKind::ForLoop(ForLoopLoc::IntoIter),
1468+
orig_head_span,
1469+
None,
1470+
);
1471+
14611472
// `match ::std::iter::IntoIterator::into_iter(<head>) { ... }`
14621473
let into_iter_expr = {
14631474
let into_iter_path = &[sym::iter, sym::IntoIterator, sym::into_iter];
1464-
self.expr_call_std_path(desugared_span, into_iter_path, arena_vec![self; head])
1475+
self.expr_call_std_path(into_iter_span, into_iter_path, arena_vec![self; head])
14651476
};
14661477

14671478
let match_expr = self.arena.alloc(self.expr_match(

src/librustc_codegen_llvm/back/lto.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@ pub unsafe fn optimize_thin_module(
797797
kind: ModuleKind::Regular,
798798
};
799799
{
800+
let target = &*module.module_llvm.tm;
800801
let llmod = module.module_llvm.llmod();
801802
save_temp_bitcode(&cgcx, &module, "thin-lto-input");
802803

@@ -833,7 +834,7 @@ pub unsafe fn optimize_thin_module(
833834
{
834835
let _timer =
835836
cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_rename", thin_module.name());
836-
if !llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod) {
837+
if !llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod, target) {
837838
let msg = "failed to prepare thin LTO module";
838839
return Err(write::llvm_err(&diag_handler, msg));
839840
}
@@ -865,7 +866,7 @@ pub unsafe fn optimize_thin_module(
865866
{
866867
let _timer =
867868
cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_import", thin_module.name());
868-
if !llvm::LLVMRustPrepareThinLTOImport(thin_module.shared.data.0, llmod) {
869+
if !llvm::LLVMRustPrepareThinLTOImport(thin_module.shared.data.0, llmod, target) {
869870
let msg = "failed to prepare thin LTO module";
870871
return Err(write::llvm_err(&diag_handler, msg));
871872
}

src/librustc_codegen_llvm/llvm/ffi.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ pub enum TypeKind {
233233
Metadata = 14,
234234
X86_MMX = 15,
235235
Token = 16,
236+
ScalableVector = 17,
237+
BFloat = 18,
236238
}
237239

238240
impl TypeKind {
@@ -255,6 +257,8 @@ impl TypeKind {
255257
TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata,
256258
TypeKind::X86_MMX => rustc_codegen_ssa::common::TypeKind::X86_MMX,
257259
TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token,
260+
TypeKind::ScalableVector => rustc_codegen_ssa::common::TypeKind::ScalableVector,
261+
TypeKind::BFloat => rustc_codegen_ssa::common::TypeKind::BFloat,
258262
}
259263
}
260264
}
@@ -2141,10 +2145,18 @@ extern "C" {
21412145
PreservedSymbols: *const *const c_char,
21422146
PreservedSymbolsLen: c_uint,
21432147
) -> Option<&'static mut ThinLTOData>;
2144-
pub fn LLVMRustPrepareThinLTORename(Data: &ThinLTOData, Module: &Module) -> bool;
2148+
pub fn LLVMRustPrepareThinLTORename(
2149+
Data: &ThinLTOData,
2150+
Module: &Module,
2151+
Target: &TargetMachine,
2152+
) -> bool;
21452153
pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
21462154
pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
2147-
pub fn LLVMRustPrepareThinLTOImport(Data: &ThinLTOData, Module: &Module) -> bool;
2155+
pub fn LLVMRustPrepareThinLTOImport(
2156+
Data: &ThinLTOData,
2157+
Module: &Module,
2158+
Target: &TargetMachine,
2159+
) -> bool;
21482160
pub fn LLVMRustGetThinLTOModuleImports(
21492161
Data: *const ThinLTOData,
21502162
ModuleNameCallback: ThinLTOModuleNameCallback,

src/librustc_codegen_ssa/common.rs

+2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ pub enum TypeKind {
9898
Metadata,
9999
X86_MMX,
100100
Token,
101+
ScalableVector,
102+
BFloat,
101103
}
102104

103105
// FIXME(mw): Anything that is produced via DepGraph::with_task() must implement

src/librustc_errors/json.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub struct JsonEmitter {
3636
pretty: bool,
3737
ui_testing: bool,
3838
json_rendered: HumanReadableErrorType,
39+
terminal_width: Option<usize>,
3940
macro_backtrace: bool,
4041
}
4142

@@ -45,6 +46,7 @@ impl JsonEmitter {
4546
source_map: Lrc<SourceMap>,
4647
pretty: bool,
4748
json_rendered: HumanReadableErrorType,
49+
terminal_width: Option<usize>,
4850
macro_backtrace: bool,
4951
) -> JsonEmitter {
5052
JsonEmitter {
@@ -54,13 +56,15 @@ impl JsonEmitter {
5456
pretty,
5557
ui_testing: false,
5658
json_rendered,
59+
terminal_width,
5760
macro_backtrace,
5861
}
5962
}
6063

6164
pub fn basic(
6265
pretty: bool,
6366
json_rendered: HumanReadableErrorType,
67+
terminal_width: Option<usize>,
6468
macro_backtrace: bool,
6569
) -> JsonEmitter {
6670
let file_path_mapping = FilePathMapping::empty();
@@ -69,6 +73,7 @@ impl JsonEmitter {
6973
Lrc::new(SourceMap::new(file_path_mapping)),
7074
pretty,
7175
json_rendered,
76+
terminal_width,
7277
macro_backtrace,
7378
)
7479
}
@@ -79,6 +84,7 @@ impl JsonEmitter {
7984
source_map: Lrc<SourceMap>,
8085
pretty: bool,
8186
json_rendered: HumanReadableErrorType,
87+
terminal_width: Option<usize>,
8288
macro_backtrace: bool,
8389
) -> JsonEmitter {
8490
JsonEmitter {
@@ -88,6 +94,7 @@ impl JsonEmitter {
8894
pretty,
8995
ui_testing: false,
9096
json_rendered,
97+
terminal_width,
9198
macro_backtrace,
9299
}
93100
}
@@ -247,7 +254,13 @@ impl Diagnostic {
247254
let buf = BufWriter::default();
248255
let output = buf.clone();
249256
je.json_rendered
250-
.new_emitter(Box::new(buf), Some(je.sm.clone()), false, None, je.macro_backtrace)
257+
.new_emitter(
258+
Box::new(buf),
259+
Some(je.sm.clone()),
260+
false,
261+
je.terminal_width,
262+
je.macro_backtrace,
263+
)
251264
.ui_testing(je.ui_testing)
252265
.emit_diagnostic(diag);
253266
let output = Arc::try_unwrap(output.0).unwrap().into_inner().unwrap();

src/librustc_hir/lang_items.rs

+55-25
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,26 @@ use rustc_span::Span;
2121

2222
use lazy_static::lazy_static;
2323

24+
pub enum LangItemGroup {
25+
Op,
26+
}
27+
28+
const NUM_GROUPS: usize = 1;
29+
30+
macro_rules! expand_group {
31+
() => {
32+
None
33+
};
34+
($group:expr) => {
35+
Some($group)
36+
};
37+
}
38+
2439
// The actual lang items defined come at the end of this file in one handy table.
2540
// So you probably just want to nip down to the end.
2641
macro_rules! language_item_table {
2742
(
28-
$( $variant:ident, $name:expr, $method:ident, $target:expr; )*
43+
$( $variant:ident $($group:expr)?, $name:expr, $method:ident, $target:expr; )*
2944
) => {
3045

3146
enum_from_u32! {
@@ -45,6 +60,13 @@ macro_rules! language_item_table {
4560
$( $variant => $name, )*
4661
}
4762
}
63+
64+
pub fn group(self) -> Option<LangItemGroup> {
65+
use LangItemGroup::*;
66+
match self {
67+
$( $variant => expand_group!($($group)*), )*
68+
}
69+
}
4870
}
4971

5072
#[derive(HashStable_Generic)]
@@ -54,6 +76,9 @@ macro_rules! language_item_table {
5476
pub items: Vec<Option<DefId>>,
5577
/// Lang items that were not found during collection.
5678
pub missing: Vec<LangItem>,
79+
/// Mapping from `LangItemGroup` discriminants to all
80+
/// `DefId`s of lang items in that group.
81+
pub groups: [Vec<DefId>; NUM_GROUPS],
5782
}
5883

5984
impl LanguageItems {
@@ -64,6 +89,7 @@ macro_rules! language_item_table {
6489
Self {
6590
items: vec![$(init_none($variant)),*],
6691
missing: Vec::new(),
92+
groups: [vec![]; NUM_GROUPS],
6793
}
6894
}
6995

@@ -79,6 +105,10 @@ macro_rules! language_item_table {
79105
self.items[it as usize].ok_or_else(|| format!("requires `{}` lang_item", it.name()))
80106
}
81107

108+
pub fn group(&self, group: LangItemGroup) -> &[DefId] {
109+
self.groups[group as usize].as_ref()
110+
}
111+
82112
$(
83113
/// Returns the corresponding `DefId` for the lang item
84114
#[doc = $name]
@@ -171,30 +201,30 @@ language_item_table! {
171201
CoerceUnsizedTraitLangItem, "coerce_unsized", coerce_unsized_trait, Target::Trait;
172202
DispatchFromDynTraitLangItem,"dispatch_from_dyn", dispatch_from_dyn_trait, Target::Trait;
173203

174-
AddTraitLangItem, "add", add_trait, Target::Trait;
175-
SubTraitLangItem, "sub", sub_trait, Target::Trait;
176-
MulTraitLangItem, "mul", mul_trait, Target::Trait;
177-
DivTraitLangItem, "div", div_trait, Target::Trait;
178-
RemTraitLangItem, "rem", rem_trait, Target::Trait;
179-
NegTraitLangItem, "neg", neg_trait, Target::Trait;
180-
NotTraitLangItem, "not", not_trait, Target::Trait;
181-
BitXorTraitLangItem, "bitxor", bitxor_trait, Target::Trait;
182-
BitAndTraitLangItem, "bitand", bitand_trait, Target::Trait;
183-
BitOrTraitLangItem, "bitor", bitor_trait, Target::Trait;
184-
ShlTraitLangItem, "shl", shl_trait, Target::Trait;
185-
ShrTraitLangItem, "shr", shr_trait, Target::Trait;
186-
AddAssignTraitLangItem, "add_assign", add_assign_trait, Target::Trait;
187-
SubAssignTraitLangItem, "sub_assign", sub_assign_trait, Target::Trait;
188-
MulAssignTraitLangItem, "mul_assign", mul_assign_trait, Target::Trait;
189-
DivAssignTraitLangItem, "div_assign", div_assign_trait, Target::Trait;
190-
RemAssignTraitLangItem, "rem_assign", rem_assign_trait, Target::Trait;
191-
BitXorAssignTraitLangItem, "bitxor_assign", bitxor_assign_trait, Target::Trait;
192-
BitAndAssignTraitLangItem, "bitand_assign", bitand_assign_trait, Target::Trait;
193-
BitOrAssignTraitLangItem, "bitor_assign", bitor_assign_trait, Target::Trait;
194-
ShlAssignTraitLangItem, "shl_assign", shl_assign_trait, Target::Trait;
195-
ShrAssignTraitLangItem, "shr_assign", shr_assign_trait, Target::Trait;
196-
IndexTraitLangItem, "index", index_trait, Target::Trait;
197-
IndexMutTraitLangItem, "index_mut", index_mut_trait, Target::Trait;
204+
AddTraitLangItem(Op), "add", add_trait, Target::Trait;
205+
SubTraitLangItem(Op), "sub", sub_trait, Target::Trait;
206+
MulTraitLangItem(Op), "mul", mul_trait, Target::Trait;
207+
DivTraitLangItem(Op), "div", div_trait, Target::Trait;
208+
RemTraitLangItem(Op), "rem", rem_trait, Target::Trait;
209+
NegTraitLangItem(Op), "neg", neg_trait, Target::Trait;
210+
NotTraitLangItem(Op), "not", not_trait, Target::Trait;
211+
BitXorTraitLangItem(Op), "bitxor", bitxor_trait, Target::Trait;
212+
BitAndTraitLangItem(Op), "bitand", bitand_trait, Target::Trait;
213+
BitOrTraitLangItem(Op), "bitor", bitor_trait, Target::Trait;
214+
ShlTraitLangItem(Op), "shl", shl_trait, Target::Trait;
215+
ShrTraitLangItem(Op), "shr", shr_trait, Target::Trait;
216+
AddAssignTraitLangItem(Op), "add_assign", add_assign_trait, Target::Trait;
217+
SubAssignTraitLangItem(Op), "sub_assign", sub_assign_trait, Target::Trait;
218+
MulAssignTraitLangItem(Op), "mul_assign", mul_assign_trait, Target::Trait;
219+
DivAssignTraitLangItem(Op), "div_assign", div_assign_trait, Target::Trait;
220+
RemAssignTraitLangItem(Op), "rem_assign", rem_assign_trait, Target::Trait;
221+
BitXorAssignTraitLangItem(Op),"bitxor_assign", bitxor_assign_trait, Target::Trait;
222+
BitAndAssignTraitLangItem(Op),"bitand_assign", bitand_assign_trait, Target::Trait;
223+
BitOrAssignTraitLangItem(Op),"bitor_assign", bitor_assign_trait, Target::Trait;
224+
ShlAssignTraitLangItem(Op), "shl_assign", shl_assign_trait, Target::Trait;
225+
ShrAssignTraitLangItem(Op), "shr_assign", shr_assign_trait, Target::Trait;
226+
IndexTraitLangItem(Op), "index", index_trait, Target::Trait;
227+
IndexMutTraitLangItem(Op), "index_mut", index_mut_trait, Target::Trait;
198228

199229
UnsafeCellTypeLangItem, "unsafe_cell", unsafe_cell_type, Target::Struct;
200230
VaListTypeLangItem, "va_list", va_list, Target::Struct;

src/librustc_infer/infer/error_reporting/need_type_info.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
468468
let msg = if let Some(simple_ident) = pattern.simple_ident() {
469469
match pattern.span.desugaring_kind() {
470470
None => format!("consider giving `{}` {}", simple_ident, suffix),
471-
Some(DesugaringKind::ForLoop) => {
471+
Some(DesugaringKind::ForLoop(_)) => {
472472
"the element type for this iterator is not specified".to_string()
473473
}
474474
_ => format!("this needs {}", suffix),

0 commit comments

Comments
 (0)