mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Also fix if in else
This commit is contained in:
parent
954419aab0
commit
af8d911d63
@ -45,18 +45,16 @@ pub fn entry_point_type(
|
||||
EntryPointType::Start
|
||||
} else if attr::contains_name(attrs, sym::rustc_main) {
|
||||
EntryPointType::RustcMainAttr
|
||||
} else {
|
||||
if let Some(name) = name
|
||||
&& name == sym::main
|
||||
{
|
||||
if at_root {
|
||||
// This is a top-level function so it can be `main`.
|
||||
EntryPointType::MainNamed
|
||||
} else {
|
||||
EntryPointType::OtherMain
|
||||
}
|
||||
} else if let Some(name) = name
|
||||
&& name == sym::main
|
||||
{
|
||||
if at_root {
|
||||
// This is a top-level function so it can be `main`.
|
||||
EntryPointType::MainNamed
|
||||
} else {
|
||||
EntryPointType::None
|
||||
EntryPointType::OtherMain
|
||||
}
|
||||
} else {
|
||||
EntryPointType::None
|
||||
}
|
||||
}
|
||||
|
@ -628,13 +628,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
.map_or(Const::No, |attr| Const::Yes(attr.span)),
|
||||
_ => Const::No,
|
||||
}
|
||||
} else if self.tcx.is_const_trait(def_id) {
|
||||
// FIXME(effects) span
|
||||
Const::Yes(self.tcx.def_ident_span(def_id).unwrap())
|
||||
} else {
|
||||
if self.tcx.is_const_trait(def_id) {
|
||||
// FIXME(effects) span
|
||||
Const::Yes(self.tcx.def_ident_span(def_id).unwrap())
|
||||
} else {
|
||||
Const::No
|
||||
}
|
||||
Const::No
|
||||
}
|
||||
} else {
|
||||
Const::No
|
||||
|
@ -118,10 +118,8 @@ impl LivenessValues {
|
||||
debug!("LivenessValues::add_location(region={:?}, location={:?})", region, location);
|
||||
if let Some(points) = &mut self.points {
|
||||
points.insert(region, point);
|
||||
} else {
|
||||
if self.elements.point_in_range(point) {
|
||||
self.live_regions.as_mut().unwrap().insert(region);
|
||||
}
|
||||
} else if self.elements.point_in_range(point) {
|
||||
self.live_regions.as_mut().unwrap().insert(region);
|
||||
}
|
||||
|
||||
// When available, record the loans flowing into this region as live at the given point.
|
||||
@ -137,10 +135,8 @@ impl LivenessValues {
|
||||
debug!("LivenessValues::add_points(region={:?}, points={:?})", region, points);
|
||||
if let Some(this) = &mut self.points {
|
||||
this.union_row(region, points);
|
||||
} else {
|
||||
if points.iter().any(|point| self.elements.point_in_range(point)) {
|
||||
self.live_regions.as_mut().unwrap().insert(region);
|
||||
}
|
||||
} else if points.iter().any(|point| self.elements.point_in_range(point)) {
|
||||
self.live_regions.as_mut().unwrap().insert(region);
|
||||
}
|
||||
|
||||
// When available, record the loans flowing into this region as live at the given points.
|
||||
|
@ -234,13 +234,11 @@ pub fn parse_asm_args<'a>(
|
||||
continue;
|
||||
}
|
||||
args.named_args.insert(name, slot);
|
||||
} else {
|
||||
if !args.named_args.is_empty() || !args.reg_args.is_empty() {
|
||||
let named = args.named_args.values().map(|p| args.operands[*p].1).collect();
|
||||
let explicit = args.reg_args.iter().map(|p| args.operands[p].1).collect();
|
||||
} else if !args.named_args.is_empty() || !args.reg_args.is_empty() {
|
||||
let named = args.named_args.values().map(|p| args.operands[*p].1).collect();
|
||||
let explicit = args.reg_args.iter().map(|p| args.operands[p].1).collect();
|
||||
|
||||
dcx.emit_err(errors::AsmPositionalAfter { span, named, explicit });
|
||||
}
|
||||
dcx.emit_err(errors::AsmPositionalAfter { span, named, explicit });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -281,12 +281,10 @@ pub fn each_linked_rlib(
|
||||
let used_crate_source = &info.used_crate_source[&cnum];
|
||||
if let Some((path, _)) = &used_crate_source.rlib {
|
||||
f(cnum, path);
|
||||
} else if used_crate_source.rmeta.is_some() {
|
||||
return Err(errors::LinkRlibError::OnlyRmetaFound { crate_name });
|
||||
} else {
|
||||
if used_crate_source.rmeta.is_some() {
|
||||
return Err(errors::LinkRlibError::OnlyRmetaFound { crate_name });
|
||||
} else {
|
||||
return Err(errors::LinkRlibError::NotFound { crate_name });
|
||||
}
|
||||
return Err(errors::LinkRlibError::NotFound { crate_name });
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
@ -628,12 +626,10 @@ fn link_staticlib(
|
||||
let used_crate_source = &codegen_results.crate_info.used_crate_source[&cnum];
|
||||
if let Some((path, _)) = &used_crate_source.dylib {
|
||||
all_rust_dylibs.push(&**path);
|
||||
} else if used_crate_source.rmeta.is_some() {
|
||||
sess.dcx().emit_fatal(errors::LinkRlibError::OnlyRmetaFound { crate_name });
|
||||
} else {
|
||||
if used_crate_source.rmeta.is_some() {
|
||||
sess.dcx().emit_fatal(errors::LinkRlibError::OnlyRmetaFound { crate_name });
|
||||
} else {
|
||||
sess.dcx().emit_fatal(errors::LinkRlibError::NotFound { crate_name });
|
||||
}
|
||||
sess.dcx().emit_fatal(errors::LinkRlibError::NotFound { crate_name });
|
||||
}
|
||||
}
|
||||
|
||||
@ -1972,10 +1968,8 @@ fn add_late_link_args(
|
||||
if let Some(args) = sess.target.late_link_args_dynamic.get(&flavor) {
|
||||
cmd.verbatim_args(args.iter().map(Deref::deref));
|
||||
}
|
||||
} else {
|
||||
if let Some(args) = sess.target.late_link_args_static.get(&flavor) {
|
||||
cmd.verbatim_args(args.iter().map(Deref::deref));
|
||||
}
|
||||
} else if let Some(args) = sess.target.late_link_args_static.get(&flavor) {
|
||||
cmd.verbatim_args(args.iter().map(Deref::deref));
|
||||
}
|
||||
if let Some(args) = sess.target.late_link_args.get(&flavor) {
|
||||
cmd.verbatim_args(args.iter().map(Deref::deref));
|
||||
@ -2635,10 +2629,8 @@ fn add_native_libs_from_crate(
|
||||
if link_static {
|
||||
cmd.link_staticlib_by_name(name, verbatim, false);
|
||||
}
|
||||
} else {
|
||||
if link_dynamic {
|
||||
cmd.link_dylib_by_name(name, verbatim, true);
|
||||
}
|
||||
} else if link_dynamic {
|
||||
cmd.link_dylib_by_name(name, verbatim, true);
|
||||
}
|
||||
}
|
||||
NativeLibKind::Framework { as_needed } => {
|
||||
|
@ -791,14 +791,12 @@ impl<'a> Linker for GccLinker<'a> {
|
||||
self.link_arg("-exported_symbols_list").link_arg(path);
|
||||
} else if self.sess.target.is_like_solaris {
|
||||
self.link_arg("-M").link_arg(path);
|
||||
} else if is_windows {
|
||||
self.link_arg(path);
|
||||
} else {
|
||||
if is_windows {
|
||||
self.link_arg(path);
|
||||
} else {
|
||||
let mut arg = OsString::from("--version-script=");
|
||||
arg.push(path);
|
||||
self.link_arg(arg).link_arg("--no-undefined-version");
|
||||
}
|
||||
let mut arg = OsString::from("--version-script=");
|
||||
arg.push(path);
|
||||
self.link_arg(arg).link_arg("--no-undefined-version");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,15 +236,13 @@ fn push_debuginfo_type_name<'tcx>(
|
||||
let has_enclosing_parens = if cpp_like_debuginfo {
|
||||
output.push_str("dyn$<");
|
||||
false
|
||||
} else if trait_data.len() > 1 && auto_traits.len() != 0 {
|
||||
// We need enclosing parens because there is more than one trait
|
||||
output.push_str("(dyn ");
|
||||
true
|
||||
} else {
|
||||
if trait_data.len() > 1 && auto_traits.len() != 0 {
|
||||
// We need enclosing parens because there is more than one trait
|
||||
output.push_str("(dyn ");
|
||||
true
|
||||
} else {
|
||||
output.push_str("dyn ");
|
||||
false
|
||||
}
|
||||
output.push_str("dyn ");
|
||||
false
|
||||
};
|
||||
|
||||
if let Some(principal) = trait_data.principal() {
|
||||
|
@ -1151,42 +1151,40 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
|
||||
"type has conflicting packed and align representation hints"
|
||||
)
|
||||
.emit();
|
||||
} else {
|
||||
if let Some(def_spans) = check_packed_inner(tcx, def.did(), &mut vec![]) {
|
||||
let mut err = struct_span_code_err!(
|
||||
tcx.dcx(),
|
||||
sp,
|
||||
E0588,
|
||||
"packed type cannot transitively contain a `#[repr(align)]` type"
|
||||
);
|
||||
} else if let Some(def_spans) = check_packed_inner(tcx, def.did(), &mut vec![]) {
|
||||
let mut err = struct_span_code_err!(
|
||||
tcx.dcx(),
|
||||
sp,
|
||||
E0588,
|
||||
"packed type cannot transitively contain a `#[repr(align)]` type"
|
||||
);
|
||||
|
||||
err.span_note(
|
||||
tcx.def_span(def_spans[0].0),
|
||||
format!("`{}` has a `#[repr(align)]` attribute", tcx.item_name(def_spans[0].0)),
|
||||
);
|
||||
err.span_note(
|
||||
tcx.def_span(def_spans[0].0),
|
||||
format!("`{}` has a `#[repr(align)]` attribute", tcx.item_name(def_spans[0].0)),
|
||||
);
|
||||
|
||||
if def_spans.len() > 2 {
|
||||
let mut first = true;
|
||||
for (adt_def, span) in def_spans.iter().skip(1).rev() {
|
||||
let ident = tcx.item_name(*adt_def);
|
||||
err.span_note(
|
||||
*span,
|
||||
if first {
|
||||
format!(
|
||||
"`{}` contains a field of type `{}`",
|
||||
tcx.type_of(def.did()).instantiate_identity(),
|
||||
ident
|
||||
)
|
||||
} else {
|
||||
format!("...which contains a field of type `{ident}`")
|
||||
},
|
||||
);
|
||||
first = false;
|
||||
}
|
||||
if def_spans.len() > 2 {
|
||||
let mut first = true;
|
||||
for (adt_def, span) in def_spans.iter().skip(1).rev() {
|
||||
let ident = tcx.item_name(*adt_def);
|
||||
err.span_note(
|
||||
*span,
|
||||
if first {
|
||||
format!(
|
||||
"`{}` contains a field of type `{}`",
|
||||
tcx.type_of(def.did()).instantiate_identity(),
|
||||
ident
|
||||
)
|
||||
} else {
|
||||
format!("...which contains a field of type `{ident}`")
|
||||
},
|
||||
);
|
||||
first = false;
|
||||
}
|
||||
|
||||
err.emit();
|
||||
}
|
||||
|
||||
err.emit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -381,24 +381,22 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>(
|
||||
}
|
||||
|
||||
mir_opaque_ty.ty
|
||||
} else if let Some(guar) = tables.tainted_by_errors {
|
||||
// Some error in the owner fn prevented us from populating
|
||||
// the `concrete_opaque_types` table.
|
||||
Ty::new_error(tcx, guar)
|
||||
} else {
|
||||
if let Some(guar) = tables.tainted_by_errors {
|
||||
// Some error in the owner fn prevented us from populating
|
||||
// the `concrete_opaque_types` table.
|
||||
Ty::new_error(tcx, guar)
|
||||
// Fall back to the RPIT we inferred during HIR typeck
|
||||
if let Some(hir_opaque_ty) = hir_opaque_ty {
|
||||
hir_opaque_ty.ty
|
||||
} else {
|
||||
// Fall back to the RPIT we inferred during HIR typeck
|
||||
if let Some(hir_opaque_ty) = hir_opaque_ty {
|
||||
hir_opaque_ty.ty
|
||||
} else {
|
||||
// We failed to resolve the opaque type or it
|
||||
// resolves to itself. We interpret this as the
|
||||
// no values of the hidden type ever being constructed,
|
||||
// so we can just make the hidden type be `!`.
|
||||
// For backwards compatibility reasons, we fall back to
|
||||
// `()` until we the diverging default is changed.
|
||||
Ty::new_diverging_default(tcx)
|
||||
}
|
||||
// We failed to resolve the opaque type or it
|
||||
// resolves to itself. We interpret this as the
|
||||
// no values of the hidden type ever being constructed,
|
||||
// so we can just make the hidden type be `!`.
|
||||
// For backwards compatibility reasons, we fall back to
|
||||
// `()` until we the diverging default is changed.
|
||||
Ty::new_diverging_default(tcx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -562,13 +562,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
tcx.const_param_default(param.def_id)
|
||||
.instantiate(tcx, preceding_args)
|
||||
.into()
|
||||
} else if infer_args {
|
||||
self.lowerer.ct_infer(Some(param), self.span).into()
|
||||
} else {
|
||||
if infer_args {
|
||||
self.lowerer.ct_infer(Some(param), self.span).into()
|
||||
} else {
|
||||
// We've already errored above about the mismatch.
|
||||
ty::Const::new_misc_error(tcx).into()
|
||||
}
|
||||
// We've already errored above about the mismatch.
|
||||
ty::Const::new_misc_error(tcx).into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2902,21 +2902,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
candidate_fields.iter().map(|path| format!("{unwrap}{path}")),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
} else {
|
||||
if let Some(field_name) = find_best_match_for_name(&field_names, field.name, None) {
|
||||
err.span_suggestion_verbose(
|
||||
field.span,
|
||||
"a field with a similar name exists",
|
||||
format!("{unwrap}{}", field_name),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
} else if !field_names.is_empty() {
|
||||
let is = if field_names.len() == 1 { " is" } else { "s are" };
|
||||
err.note(format!(
|
||||
"available field{is}: {}",
|
||||
self.name_series_display(field_names),
|
||||
));
|
||||
}
|
||||
} else if let Some(field_name) =
|
||||
find_best_match_for_name(&field_names, field.name, None)
|
||||
{
|
||||
err.span_suggestion_verbose(
|
||||
field.span,
|
||||
"a field with a similar name exists",
|
||||
format!("{unwrap}{}", field_name),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
} else if !field_names.is_empty() {
|
||||
let is = if field_names.len() == 1 { " is" } else { "s are" };
|
||||
err.note(
|
||||
format!("available field{is}: {}", self.name_series_display(field_names),),
|
||||
);
|
||||
}
|
||||
}
|
||||
err
|
||||
|
@ -158,14 +158,12 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if !self.fcx.tcx.features().unsized_locals {
|
||||
self.fcx.require_type_is_sized(
|
||||
var_ty,
|
||||
p.span,
|
||||
ObligationCauseCode::VariableType(p.hir_id),
|
||||
);
|
||||
}
|
||||
} else if !self.fcx.tcx.features().unsized_locals {
|
||||
self.fcx.require_type_is_sized(
|
||||
var_ty,
|
||||
p.span,
|
||||
ObligationCauseCode::VariableType(p.hir_id),
|
||||
);
|
||||
}
|
||||
|
||||
debug!(
|
||||
|
@ -417,12 +417,10 @@ fn check_config(tcx: TyCtxt<'_>, attr: &Attribute) -> bool {
|
||||
fn expect_associated_value(tcx: TyCtxt<'_>, item: &NestedMetaItem) -> Symbol {
|
||||
if let Some(value) = item.value_str() {
|
||||
value
|
||||
} else if let Some(ident) = item.ident() {
|
||||
tcx.dcx().emit_fatal(errors::AssociatedValueExpectedFor { span: item.span(), ident });
|
||||
} else {
|
||||
if let Some(ident) = item.ident() {
|
||||
tcx.dcx().emit_fatal(errors::AssociatedValueExpectedFor { span: item.span(), ident });
|
||||
} else {
|
||||
tcx.dcx().emit_fatal(errors::AssociatedValueExpected { span: item.span() });
|
||||
}
|
||||
tcx.dcx().emit_fatal(errors::AssociatedValueExpected { span: item.span() });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,12 +208,10 @@ fn dump_path<'tcx>(
|
||||
|
||||
let pass_num = if tcx.sess.opts.unstable_opts.dump_mir_exclude_pass_number {
|
||||
String::new()
|
||||
} else if pass_num {
|
||||
format!(".{:03}-{:03}", body.phase.phase_index(), body.pass_count)
|
||||
} else {
|
||||
if pass_num {
|
||||
format!(".{:03}-{:03}", body.phase.phase_index(), body.pass_count)
|
||||
} else {
|
||||
".-------".to_string()
|
||||
}
|
||||
".-------".to_string()
|
||||
};
|
||||
|
||||
let crate_name = tcx.crate_name(source.def_id().krate);
|
||||
|
@ -2554,13 +2554,12 @@ impl<'a> Parser<'a> {
|
||||
let maybe_fatarrow = self.token.clone();
|
||||
let block = if self.check(&token::OpenDelim(Delimiter::Brace)) {
|
||||
self.parse_block()?
|
||||
} else if let Some(block) = recover_block_from_condition(self) {
|
||||
block
|
||||
} else {
|
||||
if let Some(block) = recover_block_from_condition(self) {
|
||||
block
|
||||
} else {
|
||||
self.error_on_extra_if(&cond)?;
|
||||
// Parse block, which will always fail, but we can add a nice note to the error
|
||||
self.parse_block().map_err(|mut err| {
|
||||
self.error_on_extra_if(&cond)?;
|
||||
// Parse block, which will always fail, but we can add a nice note to the error
|
||||
self.parse_block().map_err(|mut err| {
|
||||
if self.prev_token == token::Semi
|
||||
&& self.token == token::AndAnd
|
||||
&& let maybe_let = self.look_ahead(1, |t| t.clone())
|
||||
@ -2592,7 +2591,6 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
err
|
||||
})?
|
||||
}
|
||||
};
|
||||
self.error_on_if_block_attrs(lo, false, block.span, attrs);
|
||||
block
|
||||
|
@ -1359,13 +1359,11 @@ impl<'a> Parser<'a> {
|
||||
fn parse_attr_args(&mut self) -> PResult<'a, AttrArgs> {
|
||||
Ok(if let Some(args) = self.parse_delim_args_inner() {
|
||||
AttrArgs::Delimited(args)
|
||||
} else if self.eat(&token::Eq) {
|
||||
let eq_span = self.prev_token.span;
|
||||
AttrArgs::Eq(eq_span, AttrArgsEq::Ast(self.parse_expr_force_collect()?))
|
||||
} else {
|
||||
if self.eat(&token::Eq) {
|
||||
let eq_span = self.prev_token.span;
|
||||
AttrArgs::Eq(eq_span, AttrArgsEq::Ast(self.parse_expr_force_collect()?))
|
||||
} else {
|
||||
AttrArgs::Empty
|
||||
}
|
||||
AttrArgs::Empty
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1336,21 +1336,19 @@ impl<'a> Parser<'a> {
|
||||
vec![(first_etc_span, String::new())],
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
} else {
|
||||
if let Some(last_non_comma_dotdot_span) = last_non_comma_dotdot_span {
|
||||
// We have `.., x`.
|
||||
err.multipart_suggestion(
|
||||
"move the `..` to the end of the field list",
|
||||
vec![
|
||||
(first_etc_span, String::new()),
|
||||
(
|
||||
self.token.span.to(last_non_comma_dotdot_span.shrink_to_hi()),
|
||||
format!("{} .. }}", if ate_comma { "" } else { "," }),
|
||||
),
|
||||
],
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
} else if let Some(last_non_comma_dotdot_span) = last_non_comma_dotdot_span {
|
||||
// We have `.., x`.
|
||||
err.multipart_suggestion(
|
||||
"move the `..` to the end of the field list",
|
||||
vec![
|
||||
(first_etc_span, String::new()),
|
||||
(
|
||||
self.token.span.to(last_non_comma_dotdot_span.shrink_to_hi()),
|
||||
format!("{} .. }}", if ate_comma { "" } else { "," }),
|
||||
),
|
||||
],
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
}
|
||||
err.emit();
|
||||
|
@ -192,13 +192,11 @@ pub fn check_attribute_safety(psess: &ParseSess, safety: AttributeSafety, attr:
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let Safety::Unsafe(unsafe_span) = attr_item.unsafety {
|
||||
psess.dcx().emit_err(errors::InvalidAttrUnsafe {
|
||||
span: unsafe_span,
|
||||
name: attr_item.path.clone(),
|
||||
});
|
||||
}
|
||||
} else if let Safety::Unsafe(unsafe_span) = attr_item.unsafety {
|
||||
psess.dcx().emit_err(errors::InvalidAttrUnsafe {
|
||||
span: unsafe_span,
|
||||
name: attr_item.path.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2172,17 +2172,13 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
||||
attr.span,
|
||||
errors::MacroExport::TooManyItems,
|
||||
);
|
||||
} else {
|
||||
if meta_item_list[0].name_or_empty() != sym::local_inner_macros {
|
||||
self.tcx.emit_node_span_lint(
|
||||
INVALID_MACRO_EXPORT_ARGUMENTS,
|
||||
hir_id,
|
||||
meta_item_list[0].span(),
|
||||
errors::MacroExport::UnknownItem {
|
||||
name: meta_item_list[0].name_or_empty(),
|
||||
},
|
||||
);
|
||||
}
|
||||
} else if meta_item_list[0].name_or_empty() != sym::local_inner_macros {
|
||||
self.tcx.emit_node_span_lint(
|
||||
INVALID_MACRO_EXPORT_ARGUMENTS,
|
||||
hir_id,
|
||||
meta_item_list[0].span(),
|
||||
errors::MacroExport::UnknownItem { name: meta_item_list[0].name_or_empty() },
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// special case when `#[macro_export]` is applied to a macro 2.0
|
||||
|
@ -1500,15 +1500,13 @@ impl<'tcx> Liveness<'_, 'tcx> {
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let Some(name) = self.should_warn(var) {
|
||||
self.ir.tcx.emit_node_span_lint(
|
||||
lint::builtin::UNUSED_VARIABLES,
|
||||
var_hir_id,
|
||||
vec![span],
|
||||
errors::UnusedVarMaybeCaptureRef { name },
|
||||
);
|
||||
}
|
||||
} else if let Some(name) = self.should_warn(var) {
|
||||
self.ir.tcx.emit_node_span_lint(
|
||||
lint::builtin::UNUSED_VARIABLES,
|
||||
var_hir_id,
|
||||
vec![span],
|
||||
errors::UnusedVarMaybeCaptureRef { name },
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1256,28 +1256,23 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
extern_crate_span: self.tcx.source_span(self.local_def_id(extern_crate_id)),
|
||||
},
|
||||
);
|
||||
} else {
|
||||
if ns == TypeNS {
|
||||
let err = if crate_private_reexport {
|
||||
self.dcx().create_err(CannotBeReexportedCratePublicNS {
|
||||
span: import.span,
|
||||
ident,
|
||||
})
|
||||
} else {
|
||||
self.dcx()
|
||||
.create_err(CannotBeReexportedPrivateNS { span: import.span, ident })
|
||||
};
|
||||
err.emit();
|
||||
} else if ns == TypeNS {
|
||||
let err = if crate_private_reexport {
|
||||
self.dcx()
|
||||
.create_err(CannotBeReexportedCratePublicNS { span: import.span, ident })
|
||||
} else {
|
||||
let mut err = if crate_private_reexport {
|
||||
self.dcx()
|
||||
.create_err(CannotBeReexportedCratePublic { span: import.span, ident })
|
||||
} else {
|
||||
self.dcx()
|
||||
.create_err(CannotBeReexportedPrivate { span: import.span, ident })
|
||||
};
|
||||
self.dcx().create_err(CannotBeReexportedPrivateNS { span: import.span, ident })
|
||||
};
|
||||
err.emit();
|
||||
} else {
|
||||
let mut err = if crate_private_reexport {
|
||||
self.dcx()
|
||||
.create_err(CannotBeReexportedCratePublic { span: import.span, ident })
|
||||
} else {
|
||||
self.dcx().create_err(CannotBeReexportedPrivate { span: import.span, ident })
|
||||
};
|
||||
|
||||
match binding.kind {
|
||||
match binding.kind {
|
||||
NameBindingKind::Res(Res::Def(DefKind::Macro(_), def_id))
|
||||
// exclude decl_macro
|
||||
if self.get_macro_by_def_id(def_id).macro_rules =>
|
||||
@ -1293,8 +1288,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
});
|
||||
}
|
||||
}
|
||||
err.emit();
|
||||
}
|
||||
err.emit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,12 +270,10 @@ fn strip_generics_from_path_segment(segment: Vec<char>) -> Result<String, Malfor
|
||||
// Give a helpful error message instead of completely ignoring the angle brackets.
|
||||
return Err(MalformedGenerics::HasFullyQualifiedSyntax);
|
||||
}
|
||||
} else if param_depth == 0 {
|
||||
stripped_segment.push(c);
|
||||
} else {
|
||||
if param_depth == 0 {
|
||||
stripped_segment.push(c);
|
||||
} else {
|
||||
latest_generics_chunk.push(c);
|
||||
}
|
||||
latest_generics_chunk.push(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,14 +207,12 @@ fn encode_fnsig<'tcx>(
|
||||
if fn_sig.c_variadic {
|
||||
s.push('z');
|
||||
}
|
||||
} else if fn_sig.c_variadic {
|
||||
s.push('z');
|
||||
} else {
|
||||
if fn_sig.c_variadic {
|
||||
s.push('z');
|
||||
} else {
|
||||
// Empty parameter lists, whether declared as () or conventionally as (void), are
|
||||
// encoded with a void parameter specifier "v".
|
||||
s.push('v')
|
||||
}
|
||||
// Empty parameter lists, whether declared as () or conventionally as (void), are
|
||||
// encoded with a void parameter specifier "v".
|
||||
s.push('v')
|
||||
}
|
||||
|
||||
// Close the "F..E" pair
|
||||
|
@ -69,29 +69,27 @@ where
|
||||
|
||||
if must_use_stack {
|
||||
arg.make_indirect_byval(None);
|
||||
} else {
|
||||
if is_xtensa_aggregate(arg) {
|
||||
// Aggregates which are <= max_size will be passed in
|
||||
// registers if possible, so coerce to integers.
|
||||
} else if is_xtensa_aggregate(arg) {
|
||||
// Aggregates which are <= max_size will be passed in
|
||||
// registers if possible, so coerce to integers.
|
||||
|
||||
// Use a single `xlen` int if possible, 2 * `xlen` if 2 * `xlen` alignment
|
||||
// is required, and a 2-element `xlen` array if only `xlen` alignment is
|
||||
// required.
|
||||
if size <= 32 {
|
||||
arg.cast_to(Reg::i32());
|
||||
} else {
|
||||
let reg = if needed_align == 2 * 32 { Reg::i64() } else { Reg::i32() };
|
||||
let total = Size::from_bits(((size + 32 - 1) / 32) * 32);
|
||||
arg.cast_to(Uniform::new(reg, total));
|
||||
}
|
||||
// Use a single `xlen` int if possible, 2 * `xlen` if 2 * `xlen` alignment
|
||||
// is required, and a 2-element `xlen` array if only `xlen` alignment is
|
||||
// required.
|
||||
if size <= 32 {
|
||||
arg.cast_to(Reg::i32());
|
||||
} else {
|
||||
// All integral types are promoted to `xlen`
|
||||
// width.
|
||||
//
|
||||
// We let the LLVM backend handle integral types >= xlen.
|
||||
if size < 32 {
|
||||
arg.extend_integer_width_to(32);
|
||||
}
|
||||
let reg = if needed_align == 2 * 32 { Reg::i64() } else { Reg::i32() };
|
||||
let total = Size::from_bits(((size + 32 - 1) / 32) * 32);
|
||||
arg.cast_to(Uniform::new(reg, total));
|
||||
}
|
||||
} else {
|
||||
// All integral types are promoted to `xlen`
|
||||
// width.
|
||||
//
|
||||
// We let the LLVM backend handle integral types >= xlen.
|
||||
if size < 32 {
|
||||
arg.extend_integer_width_to(32);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1323,23 +1323,21 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
label_or_note(span, terr.to_string(self.tcx));
|
||||
label_or_note(sp, msg);
|
||||
}
|
||||
} else {
|
||||
if let Some(values) = values
|
||||
&& let Some((e, f)) = values.ty()
|
||||
&& let TypeError::ArgumentSorts(..) | TypeError::Sorts(_) = terr
|
||||
{
|
||||
let e = self.tcx.erase_regions(e);
|
||||
let f = self.tcx.erase_regions(f);
|
||||
let expected = with_forced_trimmed_paths!(e.sort_string(self.tcx));
|
||||
let found = with_forced_trimmed_paths!(f.sort_string(self.tcx));
|
||||
if expected == found {
|
||||
label_or_note(span, terr.to_string(self.tcx));
|
||||
} else {
|
||||
label_or_note(span, Cow::from(format!("expected {expected}, found {found}")));
|
||||
}
|
||||
} else {
|
||||
} else if let Some(values) = values
|
||||
&& let Some((e, f)) = values.ty()
|
||||
&& let TypeError::ArgumentSorts(..) | TypeError::Sorts(_) = terr
|
||||
{
|
||||
let e = self.tcx.erase_regions(e);
|
||||
let f = self.tcx.erase_regions(f);
|
||||
let expected = with_forced_trimmed_paths!(e.sort_string(self.tcx));
|
||||
let found = with_forced_trimmed_paths!(f.sort_string(self.tcx));
|
||||
if expected == found {
|
||||
label_or_note(span, terr.to_string(self.tcx));
|
||||
} else {
|
||||
label_or_note(span, Cow::from(format!("expected {expected}, found {found}")));
|
||||
}
|
||||
} else {
|
||||
label_or_note(span, terr.to_string(self.tcx));
|
||||
}
|
||||
|
||||
if let Some((expected, found, path)) = expected_found {
|
||||
|
@ -3237,16 +3237,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
// then the tuple must be the one containing capture types.
|
||||
let is_upvar_tys_infer_tuple = if !matches!(ty.kind(), ty::Tuple(..)) {
|
||||
false
|
||||
} else if let ObligationCauseCode::BuiltinDerived(data) = &*data.parent_code {
|
||||
let parent_trait_ref = self.resolve_vars_if_possible(data.parent_trait_pred);
|
||||
let nested_ty = parent_trait_ref.skip_binder().self_ty();
|
||||
matches!(nested_ty.kind(), ty::Coroutine(..))
|
||||
|| matches!(nested_ty.kind(), ty::Closure(..))
|
||||
} else {
|
||||
if let ObligationCauseCode::BuiltinDerived(data) = &*data.parent_code {
|
||||
let parent_trait_ref =
|
||||
self.resolve_vars_if_possible(data.parent_trait_pred);
|
||||
let nested_ty = parent_trait_ref.skip_binder().self_ty();
|
||||
matches!(nested_ty.kind(), ty::Coroutine(..))
|
||||
|| matches!(nested_ty.kind(), ty::Closure(..))
|
||||
} else {
|
||||
false
|
||||
}
|
||||
false
|
||||
};
|
||||
|
||||
if !is_upvar_tys_infer_tuple {
|
||||
|
@ -426,13 +426,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
} else if kind == ty::ClosureKind::FnOnce {
|
||||
candidates.vec.push(ClosureCandidate { is_const });
|
||||
}
|
||||
} else if kind == ty::ClosureKind::FnOnce {
|
||||
candidates.vec.push(ClosureCandidate { is_const });
|
||||
} else {
|
||||
if kind == ty::ClosureKind::FnOnce {
|
||||
candidates.vec.push(ClosureCandidate { is_const });
|
||||
} else {
|
||||
// This stays ambiguous until kind+upvars are determined.
|
||||
candidates.ambiguous = true;
|
||||
}
|
||||
// This stays ambiguous until kind+upvars are determined.
|
||||
candidates.ambiguous = true;
|
||||
}
|
||||
}
|
||||
ty::Infer(ty::TyVar(_)) => {
|
||||
|
Loading…
Reference in New Issue
Block a user