fix review
This commit is contained in:
parent
c75c4a579b
commit
08b1e8004b
9 changed files with 64 additions and 70 deletions
|
@ -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> {
|
fn get_parameter_names(cx: &CodegenCx<'_, '_>, generics: &ty::Generics) -> Vec<Symbol> {
|
||||||
let mut names = generics
|
let mut names = generics
|
||||||
.parent
|
.parent
|
||||||
.map_or_else(|| 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.extend(generics.params.iter().map(|param| param.name));
|
||||||
names
|
names
|
||||||
}
|
}
|
||||||
|
|
|
@ -481,10 +481,9 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_parameter_names(cx: &CodegenCx<'_, '_>, generics: &ty::Generics) -> Vec<Symbol> {
|
fn get_parameter_names(cx: &CodegenCx<'_, '_>, generics: &ty::Generics) -> Vec<Symbol> {
|
||||||
let mut names = generics.parent.map_or_else(
|
let mut names = generics.parent.map_or_else(Vec::new, |def_id| {
|
||||||
|| vec![],
|
get_parameter_names(cx, cx.tcx.generics_of(def_id))
|
||||||
|def_id| get_parameter_names(cx, cx.tcx.generics_of(def_id)),
|
});
|
||||||
);
|
|
||||||
names.extend(generics.params.iter().map(|param| param.name));
|
names.extend(generics.params.iter().map(|param| param.name));
|
||||||
names
|
names
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ fn search_meta_section<'a>(
|
||||||
let mut name_buf = None;
|
let mut name_buf = None;
|
||||||
let name_len = llvm::LLVMRustGetSectionName(si.llsi, &mut name_buf);
|
let name_len = llvm::LLVMRustGetSectionName(si.llsi, &mut name_buf);
|
||||||
let name = name_buf.map_or_else(
|
let name = name_buf.map_or_else(
|
||||||
|| String::new(), // We got a NULL ptr, ignore `name_len`.
|
String::new, // We got a NULL ptr, ignore `name_len`.
|
||||||
|buf| {
|
|buf| {
|
||||||
String::from_utf8(
|
String::from_utf8(
|
||||||
slice::from_raw_parts(buf.as_ptr() as *const u8, name_len as usize)
|
slice::from_raw_parts(buf.as_ptr() as *const u8, name_len as usize)
|
||||||
|
|
|
@ -50,7 +50,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
|
||||||
|
|
||||||
let name =
|
let name =
|
||||||
with_no_trimmed_paths(|| ty::tls::with(|tcx| tcx.def_path_str(cid.instance.def_id())));
|
with_no_trimmed_paths(|| ty::tls::with(|tcx| tcx.def_path_str(cid.instance.def_id())));
|
||||||
let prom = cid.promoted.map_or_else(|| 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);
|
trace!("eval_body_using_ecx: pushing stack frame for global: {}{}", name, prom);
|
||||||
|
|
||||||
ecx.push_stack_frame(
|
ecx.push_stack_frame(
|
||||||
|
|
|
@ -223,7 +223,7 @@ impl<'a> Parser<'a> {
|
||||||
fn tokens_to_string(tokens: &[TokenType]) -> String {
|
fn tokens_to_string(tokens: &[TokenType]) -> String {
|
||||||
let mut i = tokens.iter();
|
let mut i = tokens.iter();
|
||||||
// This might be a sign we need a connect method on `Iterator`.
|
// This might be a sign we need a connect method on `Iterator`.
|
||||||
let b = i.next().map_or_else(|| String::new(), |t| t.to_string());
|
let b = i.next().map_or_else(String::new, |t| t.to_string());
|
||||||
i.enumerate().fold(b, |mut b, (i, a)| {
|
i.enumerate().fold(b, |mut b, (i, a)| {
|
||||||
if tokens.len() > 2 && i == tokens.len() - 2 {
|
if tokens.len() > 2 && i == tokens.len() - 2 {
|
||||||
b.push_str(", or ");
|
b.push_str(", or ");
|
||||||
|
|
|
@ -1971,9 +1971,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
// Therefore, we would compute `object_lifetime_defaults` to a
|
// Therefore, we would compute `object_lifetime_defaults` to a
|
||||||
// vector like `['x, 'static]`. Note that the vector only
|
// vector like `['x, 'static]`. Note that the vector only
|
||||||
// includes type parameters.
|
// includes type parameters.
|
||||||
let object_lifetime_defaults = type_def_id.map_or_else(
|
let object_lifetime_defaults = type_def_id.map_or_else(Vec::new, |def_id| {
|
||||||
|| vec![],
|
|
||||||
|def_id| {
|
|
||||||
let in_body = {
|
let in_body = {
|
||||||
let mut scope = self.scope;
|
let mut scope = self.scope;
|
||||||
loop {
|
loop {
|
||||||
|
@ -2031,8 +2029,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
Set1::Many => None,
|
Set1::Many => None,
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
debug!("visit_segment_args: object_lifetime_defaults={:?}", object_lifetime_defaults);
|
debug!("visit_segment_args: object_lifetime_defaults={:?}", object_lifetime_defaults);
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ pub fn get_or_default_sysroot() -> PathBuf {
|
||||||
|
|
||||||
// Check if sysroot is found using env::args().next(), and if is not found,
|
// Check if sysroot is found using env::args().next(), and if is not found,
|
||||||
// use env::current_exe() to imply sysroot.
|
// use env::current_exe() to imply sysroot.
|
||||||
from_env_args_next().unwrap_or_else(|| from_current_exe())
|
from_env_args_next().unwrap_or_else(from_current_exe)
|
||||||
}
|
}
|
||||||
|
|
||||||
// The name of the directory rustc expects libraries to be located.
|
// The name of the directory rustc expects libraries to be located.
|
||||||
|
|
|
@ -349,7 +349,7 @@ fn report_negative_positive_conflict(
|
||||||
E0751,
|
E0751,
|
||||||
"found both positive and negative implementation of trait `{}`{}:",
|
"found both positive and negative implementation of trait `{}`{}:",
|
||||||
overlap.trait_desc,
|
overlap.trait_desc,
|
||||||
overlap.self_desc.clone().map_or_else(|| String::new(), |ty| format!(" for type `{}`", ty))
|
overlap.self_desc.clone().map_or_else(String::new, |ty| format!(" for type `{}`", ty))
|
||||||
);
|
);
|
||||||
|
|
||||||
match tcx.span_of_impl(negative_impl_def_id) {
|
match tcx.span_of_impl(negative_impl_def_id) {
|
||||||
|
@ -400,7 +400,7 @@ fn report_conflicting_impls(
|
||||||
overlap
|
overlap
|
||||||
.self_desc
|
.self_desc
|
||||||
.clone()
|
.clone()
|
||||||
.map_or_else(|| String::new(), |ty| { format!(" for type `{}`", ty) }),
|
.map_or_else(String::new, |ty| { format!(" for type `{}`", ty) }),
|
||||||
match used_to_be_allowed {
|
match used_to_be_allowed {
|
||||||
Some(FutureCompatOverlapErrorKind::Issue33140) => " (E0119)",
|
Some(FutureCompatOverlapErrorKind::Issue33140) => " (E0119)",
|
||||||
_ => "",
|
_ => "",
|
||||||
|
@ -418,9 +418,7 @@ fn report_conflicting_impls(
|
||||||
impl_span,
|
impl_span,
|
||||||
format!(
|
format!(
|
||||||
"conflicting implementation{}",
|
"conflicting implementation{}",
|
||||||
overlap
|
overlap.self_desc.map_or_else(String::new, |ty| format!(" for `{}`", ty))
|
||||||
.self_desc
|
|
||||||
.map_or_else(|| String::new(), |ty| format!(" for `{}`", ty))
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1695,7 +1695,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||||
} else {
|
} else {
|
||||||
self.fcx
|
self.fcx
|
||||||
.associated_item(def_id, name, Namespace::ValueNS)
|
.associated_item(def_id, name, Namespace::ValueNS)
|
||||||
.map_or_else(|| Vec::new(), |x| vec![x])
|
.map_or_else(Vec::new, |x| vec![x])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.tcx.associated_items(def_id).in_definition_order().copied().collect()
|
self.tcx.associated_items(def_id).in_definition_order().copied().collect()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue