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 8 pull requests #82550

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c28f2a8
Stabilize str_split_once
jhpratt Feb 9, 2021
4c70372
Make ItemKind::ExternCrate looks like hir::ItemKind::ExternCrate to m…
GuillaumeGomez Feb 15, 2021
5ff1be1
replaced some unwrap_or with unwrap_or_else
klensy Feb 23, 2021
c75c4a5
replaced some map_or with map_or_else
klensy Feb 23, 2021
6d5c0c1
Consider inexpensive inlining criteria first
tmiasko Feb 24, 2021
08b1e80
fix review
klensy Feb 25, 2021
fb24a10
Properly account for non-shorthand pattern field in unused variable lint
estebank Feb 25, 2021
9d3739d
Set codegen thread names
wesleywiser Feb 18, 2021
c47903f
Add optional woff2 versions of FiraSans.
jsha Feb 26, 2021
ad7ed13
Embed woff2 files in rustdoc binary.
jsha Feb 26, 2021
b0dc39e
Revert "Update normalize.css to 8.0.1"
GuillaumeGomez Feb 26, 2021
36aa36b
Rollup merge of #80845 - GuillaumeGomez:item-kind-transition, r=jyn514
GuillaumeGomez Feb 26, 2021
99d4d41
Rollup merge of #81940 - jhpratt:stabilize-str_split_once, r=m-ou-se
GuillaumeGomez Feb 26, 2021
72aa8b1
Rollup merge of #82456 - klensy:or-else, r=estebank
GuillaumeGomez Feb 26, 2021
dd9ef93
Rollup merge of #82491 - tmiasko:i, r=lcnr
GuillaumeGomez Feb 26, 2021
c21341b
Rollup merge of #82506 - estebank:unused_variable_lint, r=lcnr
GuillaumeGomez Feb 26, 2021
0d7f5a0
Rollup merge of #82535 - wesleywiser:wip_codegen_thread_names, r=nagisa
GuillaumeGomez Feb 26, 2021
97efb53
Rollup merge of #82545 - jsha:woff2, r=GuillaumeGomez
GuillaumeGomez Feb 26, 2021
4afd98c
Rollup merge of #82549 - rust-lang:revert-82313-update-normalize-css,…
GuillaumeGomez Feb 26, 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
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_cranelift/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
associated_type_bounds,
never_type,
try_blocks,
hash_drain_filter,
str_split_once
hash_drain_filter
)]
#![warn(rust_2018_idioms)]
#![warn(unused_lifetimes)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2372,7 +2372,7 @@ fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> &'ll DIAr
fn get_parameter_names(cx: &CodegenCx<'_, '_>, generics: &ty::Generics) -> Vec<Symbol> {
let mut names = generics
.parent
.map_or(vec![], |def_id| get_parameter_names(cx, cx.tcx.generics_of(def_id)));
.map_or_else(Vec::new, |def_id| get_parameter_names(cx, cx.tcx.generics_of(def_id)));
names.extend(generics.params.iter().map(|param| param.name));
names
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,9 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
}

fn get_parameter_names(cx: &CodegenCx<'_, '_>, generics: &ty::Generics) -> Vec<Symbol> {
let mut names = generics
.parent
.map_or(vec![], |def_id| get_parameter_names(cx, cx.tcx.generics_of(def_id)));
let mut names = generics.parent.map_or_else(Vec::new, |def_id| {
get_parameter_names(cx, cx.tcx.generics_of(def_id))
});
names.extend(generics.params.iter().map(|param| param.name));
names
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_llvm/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ fn search_meta_section<'a>(
while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
let mut name_buf = None;
let name_len = llvm::LLVMRustGetSectionName(si.llsi, &mut name_buf);
let name = name_buf.map_or(
String::new(), // We got a NULL ptr, ignore `name_len`.
let name = name_buf.map_or_else(
String::new, // We got a NULL ptr, ignore `name_len`.
|buf| {
String::from_utf8(
slice::from_raw_parts(buf.as_ptr() as *const u8, name_len as usize)
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
let filestem = cratepath.file_stem().unwrap().to_str().unwrap();
cmd.link_rust_dylib(
Symbol::intern(&unlib(&sess.target, filestem)),
parent.unwrap_or(Path::new("")),
parent.unwrap_or_else(|| Path::new("")),
);
}
}
Expand Down
124 changes: 77 additions & 47 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,33 @@ impl<B: WriteBackendMethods> WorkItem<B> {
}
}
}

/// Generate a short description of this work item suitable for use as a thread name.
fn short_description(&self) -> String {
// `pthread_setname()` on *nix is limited to 15 characters and longer names are ignored.
// Use very short descriptions in this case to maximize the space available for the module name.
// Windows does not have that limitation so use slightly more descriptive names there.
match self {
WorkItem::Optimize(m) => {
#[cfg(windows)]
return format!("optimize module {}", m.name);
#[cfg(not(windows))]
return format!("opt {}", m.name);
}
WorkItem::CopyPostLtoArtifacts(m) => {
#[cfg(windows)]
return format!("copy LTO artifacts for {}", m.name);
#[cfg(not(windows))]
return format!("copy {}", m.name);
}
WorkItem::LTO(m) => {
#[cfg(windows)]
return format!("LTO module {}", m.name());
#[cfg(not(windows))]
return format!("LTO {}", m.name());
}
}
}
}

enum WorkItemResult<B: WriteBackendMethods> {
Expand Down Expand Up @@ -1609,56 +1636,59 @@ fn start_executing_work<B: ExtraBackendMethods>(
pub struct WorkerFatalError;

fn spawn_work<B: ExtraBackendMethods>(cgcx: CodegenContext<B>, work: WorkItem<B>) {
thread::spawn(move || {
// Set up a destructor which will fire off a message that we're done as
// we exit.
struct Bomb<B: ExtraBackendMethods> {
coordinator_send: Sender<Box<dyn Any + Send>>,
result: Option<Result<WorkItemResult<B>, FatalError>>,
worker_id: usize,
}
impl<B: ExtraBackendMethods> Drop for Bomb<B> {
fn drop(&mut self) {
let worker_id = self.worker_id;
let msg = match self.result.take() {
Some(Ok(WorkItemResult::Compiled(m))) => {
Message::Done::<B> { result: Ok(m), worker_id }
}
Some(Ok(WorkItemResult::NeedsLink(m))) => {
Message::NeedsLink::<B> { module: m, worker_id }
}
Some(Ok(WorkItemResult::NeedsFatLTO(m))) => {
Message::NeedsFatLTO::<B> { result: m, worker_id }
}
Some(Ok(WorkItemResult::NeedsThinLTO(name, thin_buffer))) => {
Message::NeedsThinLTO::<B> { name, thin_buffer, worker_id }
}
Some(Err(FatalError)) => {
Message::Done::<B> { result: Err(Some(WorkerFatalError)), worker_id }
}
None => Message::Done::<B> { result: Err(None), worker_id },
};
drop(self.coordinator_send.send(Box::new(msg)));
let builder = thread::Builder::new().name(work.short_description());
builder
.spawn(move || {
// Set up a destructor which will fire off a message that we're done as
// we exit.
struct Bomb<B: ExtraBackendMethods> {
coordinator_send: Sender<Box<dyn Any + Send>>,
result: Option<Result<WorkItemResult<B>, FatalError>>,
worker_id: usize,
}
impl<B: ExtraBackendMethods> Drop for Bomb<B> {
fn drop(&mut self) {
let worker_id = self.worker_id;
let msg = match self.result.take() {
Some(Ok(WorkItemResult::Compiled(m))) => {
Message::Done::<B> { result: Ok(m), worker_id }
}
Some(Ok(WorkItemResult::NeedsLink(m))) => {
Message::NeedsLink::<B> { module: m, worker_id }
}
Some(Ok(WorkItemResult::NeedsFatLTO(m))) => {
Message::NeedsFatLTO::<B> { result: m, worker_id }
}
Some(Ok(WorkItemResult::NeedsThinLTO(name, thin_buffer))) => {
Message::NeedsThinLTO::<B> { name, thin_buffer, worker_id }
}
Some(Err(FatalError)) => {
Message::Done::<B> { result: Err(Some(WorkerFatalError)), worker_id }
}
None => Message::Done::<B> { result: Err(None), worker_id },
};
drop(self.coordinator_send.send(Box::new(msg)));
}
}
}

let mut bomb = Bomb::<B> {
coordinator_send: cgcx.coordinator_send.clone(),
result: None,
worker_id: cgcx.worker,
};
let mut bomb = Bomb::<B> {
coordinator_send: cgcx.coordinator_send.clone(),
result: None,
worker_id: cgcx.worker,
};

// Execute the work itself, and if it finishes successfully then flag
// ourselves as a success as well.
//
// Note that we ignore any `FatalError` coming out of `execute_work_item`,
// as a diagnostic was already sent off to the main thread - just
// surface that there was an error in this worker.
bomb.result = {
let _prof_timer = work.start_profiling(&cgcx);
Some(execute_work_item(&cgcx, work))
};
});
// Execute the work itself, and if it finishes successfully then flag
// ourselves as a success as well.
//
// Note that we ignore any `FatalError` coming out of `execute_work_item`,
// as a diagnostic was already sent off to the main thread - just
// surface that there was an error in this worker.
bomb.result = {
let _prof_timer = work.start_profiling(&cgcx);
Some(execute_work_item(&cgcx, work))
};
})
.expect("failed to spawn thread");
}

enum SharedEmitterMessage {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/non_fmt_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ fn check_panic_str<'tcx>(
Some(v) if v.len() == 1 => "panic message contains a brace",
_ => "panic message contains braces",
};
cx.struct_span_lint(NON_FMT_PANIC, brace_spans.unwrap_or(vec![span]), |lint| {
cx.struct_span_lint(NON_FMT_PANIC, brace_spans.unwrap_or_else(|| vec![span]), |lint| {
let mut l = lint.build(msg);
l.note("this message is not used as a format string, but will be in Rust 2021");
if span.contains(arg.span) {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_macros/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,14 @@ fn add_query_description_impl(
let t = &(t.0).0;
quote! { #t }
})
.unwrap_or(quote! { _ });
.unwrap_or_else(|| quote! { _ });
let value = args
.as_ref()
.map(|t| {
let t = &(t.1).0;
quote! { #t }
})
.unwrap_or(quote! { _ });
.unwrap_or_else(|| quote! { _ });
// expr is a `Block`, meaning that `{ #expr }` gets expanded
// to `{ { stmts... } }`, which triggers the `unused_braces` lint.
quote! {
Expand All @@ -409,7 +409,7 @@ fn add_query_description_impl(
};

let (tcx, desc) = modifiers.desc;
let tcx = tcx.as_ref().map_or(quote! { _ }, |t| quote! { #t });
let tcx = tcx.as_ref().map_or_else(|| quote! { _ }, |t| quote! { #t });

let desc = quote! {
#[allow(unused_variables)]
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_macros/src/session_diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,9 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
.map(
|applicability_idx| quote!(#binding.#applicability_idx),
)
.unwrap_or(quote!(
rustc_errors::Applicability::Unspecified
));
.unwrap_or_else(|| {
quote!(rustc_errors::Applicability::Unspecified)
});
return Ok((span, applicability));
}
throw_span_err!(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/const_eval/eval_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(

let name =
with_no_trimmed_paths(|| ty::tls::with(|tcx| tcx.def_path_str(cid.instance.def_id())));
let prom = cid.promoted.map_or(String::new(), |p| format!("::promoted[{:?}]", p));
let prom = cid.promoted.map_or_else(String::new, |p| format!("::promoted[{:?}]", p));
trace!("eval_body_using_ecx: pushing stack frame for global: {}{}", name, prom);

ecx.push_stack_frame(
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_mir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Rust MIR: a lowered representation of Rust.
#![feature(or_patterns)]
#![feature(once_cell)]
#![feature(control_flow_enum)]
#![feature(str_split_once)]
#![recursion_limit = "256"]

#[macro_use]
Expand Down
Loading