Replace enum ==
s with match
es where it makes sense
This commit is contained in:
parent
f55b0022db
commit
fd649a3cc5
16 changed files with 258 additions and 231 deletions
|
@ -58,7 +58,8 @@ pub fn beautify_doc_string(data: Symbol, kind: CommentKind) -> Symbol {
|
||||||
// In case we have doc comments like `/**` or `/*!`, we want to remove stars if they are
|
// In case we have doc comments like `/**` or `/*!`, we want to remove stars if they are
|
||||||
// present. However, we first need to strip the empty lines so they don't get in the middle
|
// present. However, we first need to strip the empty lines so they don't get in the middle
|
||||||
// when we try to compute the "horizontal trim".
|
// when we try to compute the "horizontal trim".
|
||||||
let lines = if kind == CommentKind::Block {
|
let lines = match kind {
|
||||||
|
CommentKind::Block => {
|
||||||
// Whatever happens, we skip the first line.
|
// Whatever happens, we skip the first line.
|
||||||
let mut i = lines
|
let mut i = lines
|
||||||
.get(0)
|
.get(0)
|
||||||
|
@ -73,8 +74,8 @@ pub fn beautify_doc_string(data: Symbol, kind: CommentKind) -> Symbol {
|
||||||
j -= 1;
|
j -= 1;
|
||||||
}
|
}
|
||||||
&lines[i..j]
|
&lines[i..j]
|
||||||
} else {
|
}
|
||||||
lines
|
CommentKind::Line => lines,
|
||||||
};
|
};
|
||||||
|
|
||||||
for line in lines {
|
for line in lines {
|
||||||
|
|
|
@ -622,10 +622,9 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
|
||||||
let alloc = alloc.inner();
|
let alloc = alloc.inner();
|
||||||
if is_write {
|
if is_write {
|
||||||
// Write access. These are never allowed, but we give a targeted error message.
|
// Write access. These are never allowed, but we give a targeted error message.
|
||||||
if alloc.mutability == Mutability::Not {
|
match alloc.mutability {
|
||||||
Err(err_ub!(WriteToReadOnly(alloc_id)).into())
|
Mutability::Not => Err(err_ub!(WriteToReadOnly(alloc_id)).into()),
|
||||||
} else {
|
Mutability::Mut => Err(ConstEvalErrKind::ModifiedGlobal.into()),
|
||||||
Err(ConstEvalErrKind::ModifiedGlobal.into())
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Read access. These are usually allowed, with some exceptions.
|
// Read access. These are usually allowed, with some exceptions.
|
||||||
|
|
|
@ -2113,9 +2113,11 @@ impl EmitterWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for sugg in suggestions {
|
for sugg in suggestions {
|
||||||
if sugg.style == SuggestionStyle::CompletelyHidden {
|
match sugg.style {
|
||||||
|
SuggestionStyle::CompletelyHidden => {
|
||||||
// do not display this suggestion, it is meant only for tools
|
// do not display this suggestion, it is meant only for tools
|
||||||
} else if sugg.style == SuggestionStyle::HideCodeAlways {
|
}
|
||||||
|
SuggestionStyle::HideCodeAlways => {
|
||||||
if let Err(e) = self.emit_message_default(
|
if let Err(e) = self.emit_message_default(
|
||||||
&MultiSpan::new(),
|
&MultiSpan::new(),
|
||||||
&[(sugg.msg.to_owned(), Style::HeaderMsg)],
|
&[(sugg.msg.to_owned(), Style::HeaderMsg)],
|
||||||
|
@ -2128,7 +2130,11 @@ impl EmitterWriter {
|
||||||
) {
|
) {
|
||||||
panic!("failed to emit error: {}", e);
|
panic!("failed to emit error: {}", e);
|
||||||
}
|
}
|
||||||
} else if let Err(e) = self.emit_suggestion_default(
|
}
|
||||||
|
SuggestionStyle::HideCodeInline
|
||||||
|
| SuggestionStyle::ShowCode
|
||||||
|
| SuggestionStyle::ShowAlways => {
|
||||||
|
if let Err(e) = self.emit_suggestion_default(
|
||||||
span,
|
span,
|
||||||
sugg,
|
sugg,
|
||||||
args,
|
args,
|
||||||
|
@ -2136,7 +2142,9 @@ impl EmitterWriter {
|
||||||
max_line_num_len,
|
max_line_num_len,
|
||||||
) {
|
) {
|
||||||
panic!("failed to emit error: {}", e);
|
panic!("failed to emit error: {}", e);
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -385,10 +385,9 @@ pub fn check_generic_arg_count_for_call(
|
||||||
) -> GenericArgCountResult {
|
) -> GenericArgCountResult {
|
||||||
let empty_args = hir::GenericArgs::none();
|
let empty_args = hir::GenericArgs::none();
|
||||||
let gen_args = seg.args.unwrap_or(&empty_args);
|
let gen_args = seg.args.unwrap_or(&empty_args);
|
||||||
let gen_pos = if is_method_call == IsMethodCall::Yes {
|
let gen_pos = match is_method_call {
|
||||||
GenericArgPosition::MethodCall
|
IsMethodCall::Yes => GenericArgPosition::MethodCall,
|
||||||
} else {
|
IsMethodCall::No => GenericArgPosition::Value,
|
||||||
GenericArgPosition::Value
|
|
||||||
};
|
};
|
||||||
let has_self = generics.parent.is_none() && generics.has_self;
|
let has_self = generics.parent.is_none() && generics.has_self;
|
||||||
|
|
||||||
|
|
|
@ -605,23 +605,29 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) {
|
||||||
};
|
};
|
||||||
check_abi(tcx, it.hir_id(), it.span, abi);
|
check_abi(tcx, it.hir_id(), it.span, abi);
|
||||||
|
|
||||||
if abi == Abi::RustIntrinsic {
|
match abi {
|
||||||
|
Abi::RustIntrinsic => {
|
||||||
for item in items {
|
for item in items {
|
||||||
let item = tcx.hir().foreign_item(item.id);
|
let item = tcx.hir().foreign_item(item.id);
|
||||||
intrinsic::check_intrinsic_type(tcx, item);
|
intrinsic::check_intrinsic_type(tcx, item);
|
||||||
}
|
}
|
||||||
} else if abi == Abi::PlatformIntrinsic {
|
}
|
||||||
|
|
||||||
|
Abi::PlatformIntrinsic => {
|
||||||
for item in items {
|
for item in items {
|
||||||
let item = tcx.hir().foreign_item(item.id);
|
let item = tcx.hir().foreign_item(item.id);
|
||||||
intrinsic::check_platform_intrinsic_type(tcx, item);
|
intrinsic::check_platform_intrinsic_type(tcx, item);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
_ => {
|
||||||
for item in items {
|
for item in items {
|
||||||
let def_id = item.id.owner_id.def_id;
|
let def_id = item.id.owner_id.def_id;
|
||||||
let generics = tcx.generics_of(def_id);
|
let generics = tcx.generics_of(def_id);
|
||||||
let own_counts = generics.own_counts();
|
let own_counts = generics.own_counts();
|
||||||
if generics.params.len() - own_counts.lifetimes != 0 {
|
if generics.params.len() - own_counts.lifetimes != 0 {
|
||||||
let (kinds, kinds_pl, egs) = match (own_counts.types, own_counts.consts) {
|
let (kinds, kinds_pl, egs) = match (own_counts.types, own_counts.consts)
|
||||||
|
{
|
||||||
(_, 0) => ("type", "types", Some("u32")),
|
(_, 0) => ("type", "types", Some("u32")),
|
||||||
// We don't specify an example value, because we can't generate
|
// We don't specify an example value, because we can't generate
|
||||||
// a valid value for any type.
|
// a valid value for any type.
|
||||||
|
@ -662,6 +668,7 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
DefKind::GlobalAsm => {
|
DefKind::GlobalAsm => {
|
||||||
let it = tcx.hir().item(id);
|
let it = tcx.hir().item(id);
|
||||||
let hir::ItemKind::GlobalAsm(asm) = it.kind else { span_bug!(it.span, "DefKind::GlobalAsm but got {:#?}", it) };
|
let hir::ItemKind::GlobalAsm(asm) = it.kind else { span_bug!(it.span, "DefKind::GlobalAsm but got {:#?}", it) };
|
||||||
|
|
|
@ -1354,13 +1354,12 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||||
return Some(Err(MethodError::Ambiguity(sources)));
|
return Some(Err(MethodError::Ambiguity(sources)));
|
||||||
}
|
}
|
||||||
|
|
||||||
applicable_candidates.pop().map(|(probe, status)| {
|
applicable_candidates.pop().map(|(probe, status)| match status {
|
||||||
if status == ProbeResult::Match {
|
ProbeResult::Match => {
|
||||||
Ok(probe
|
Ok(probe
|
||||||
.to_unadjusted_pick(self_ty, unstable_candidates.cloned().unwrap_or_default()))
|
.to_unadjusted_pick(self_ty, unstable_candidates.cloned().unwrap_or_default()))
|
||||||
} else {
|
|
||||||
Err(MethodError::BadReturnType)
|
|
||||||
}
|
}
|
||||||
|
ProbeResult::NoMatch | ProbeResult::BadReturnType => Err(MethodError::BadReturnType),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -580,14 +580,14 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_impl_item(&mut self, cx: &LateContext<'_>, impl_item: &hir::ImplItem<'_>) {
|
fn check_impl_item(&mut self, cx: &LateContext<'_>, impl_item: &hir::ImplItem<'_>) {
|
||||||
// If the method is an impl for a trait, don't doc.
|
|
||||||
let context = method_context(cx, impl_item.owner_id.def_id);
|
let context = method_context(cx, impl_item.owner_id.def_id);
|
||||||
if context == MethodLateContext::TraitImpl {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
match context {
|
||||||
|
// If the method is an impl for a trait, don't doc.
|
||||||
|
MethodLateContext::TraitImpl => return,
|
||||||
|
MethodLateContext::TraitAutoImpl => {}
|
||||||
// If the method is an impl for an item with docs_hidden, don't doc.
|
// If the method is an impl for an item with docs_hidden, don't doc.
|
||||||
if context == MethodLateContext::PlainImpl {
|
MethodLateContext::PlainImpl => {
|
||||||
let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id());
|
let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id());
|
||||||
let impl_ty = cx.tcx.type_of(parent);
|
let impl_ty = cx.tcx.type_of(parent);
|
||||||
let outerdef = match impl_ty.kind() {
|
let outerdef = match impl_ty.kind() {
|
||||||
|
@ -603,6 +603,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let (article, desc) = cx.tcx.article_and_description(impl_item.owner_id.to_def_id());
|
let (article, desc) = cx.tcx.article_and_description(impl_item.owner_id.to_def_id());
|
||||||
self.check_missing_docs_attrs(cx, impl_item.owner_id.def_id, article, desc);
|
self.check_missing_docs_attrs(cx, impl_item.owner_id.def_id, article, desc);
|
||||||
|
|
|
@ -113,12 +113,10 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
|
||||||
CrateType::Staticlib => Linkage::Static,
|
CrateType::Staticlib => Linkage::Static,
|
||||||
};
|
};
|
||||||
|
|
||||||
if preferred_linkage == Linkage::NotLinked {
|
match preferred_linkage {
|
||||||
// If the crate is not linked, there are no link-time dependencies.
|
// If the crate is not linked, there are no link-time dependencies.
|
||||||
return Vec::new();
|
Linkage::NotLinked => return Vec::new(),
|
||||||
}
|
Linkage::Static => {
|
||||||
|
|
||||||
if preferred_linkage == Linkage::Static {
|
|
||||||
// Attempt static linkage first. For dylibs and executables, we may be
|
// Attempt static linkage first. For dylibs and executables, we may be
|
||||||
// able to retry below with dynamic linkage.
|
// able to retry below with dynamic linkage.
|
||||||
if let Some(v) = attempt_static(tcx) {
|
if let Some(v) = attempt_static(tcx) {
|
||||||
|
@ -145,6 +143,8 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Linkage::Dynamic | Linkage::IncludedFromDylib => {}
|
||||||
|
}
|
||||||
|
|
||||||
let mut formats = FxHashMap::default();
|
let mut formats = FxHashMap::default();
|
||||||
|
|
||||||
|
@ -283,12 +283,9 @@ fn attempt_static(tcx: TyCtxt<'_>) -> Option<DependencyList> {
|
||||||
let mut ret = tcx
|
let mut ret = tcx
|
||||||
.crates(())
|
.crates(())
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&cnum| {
|
.map(|&cnum| match tcx.dep_kind(cnum) {
|
||||||
if tcx.dep_kind(cnum) == CrateDepKind::Explicit {
|
CrateDepKind::Explicit => Linkage::Static,
|
||||||
Linkage::Static
|
CrateDepKind::MacrosOnly | CrateDepKind::Implicit => Linkage::NotLinked,
|
||||||
} else {
|
|
||||||
Linkage::NotLinked
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,10 @@ impl Debug for CoverageKind {
|
||||||
"Expression({:?}) = {} {} {}",
|
"Expression({:?}) = {} {} {}",
|
||||||
id.index(),
|
id.index(),
|
||||||
lhs.index(),
|
lhs.index(),
|
||||||
if *op == Op::Add { "+" } else { "-" },
|
match op {
|
||||||
|
Op::Add => "+",
|
||||||
|
Op::Subtract => "-",
|
||||||
|
},
|
||||||
rhs.index(),
|
rhs.index(),
|
||||||
),
|
),
|
||||||
Unreachable => write!(fmt, "Unreachable"),
|
Unreachable => write!(fmt, "Unreachable"),
|
||||||
|
|
|
@ -323,7 +323,10 @@ impl DebugCounters {
|
||||||
String::new()
|
String::new()
|
||||||
},
|
},
|
||||||
self.format_operand(lhs),
|
self.format_operand(lhs),
|
||||||
if op == Op::Add { "+" } else { "-" },
|
match op {
|
||||||
|
Op::Add => "+",
|
||||||
|
Op::Subtract => "-",
|
||||||
|
},
|
||||||
self.format_operand(rhs),
|
self.format_operand(rhs),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,11 +93,12 @@ impl<'a> Parser<'a> {
|
||||||
// or `auto trait` items. We aim to parse an arbitrary path `a::b` but not something
|
// or `auto trait` items. We aim to parse an arbitrary path `a::b` but not something
|
||||||
// that starts like a path (1 token), but it fact not a path.
|
// that starts like a path (1 token), but it fact not a path.
|
||||||
// Also, we avoid stealing syntax from `parse_item_`.
|
// Also, we avoid stealing syntax from `parse_item_`.
|
||||||
if force_collect == ForceCollect::Yes {
|
match force_collect {
|
||||||
self.collect_tokens_no_attrs(|this| this.parse_stmt_path_start(lo, attrs))
|
ForceCollect::Yes => {
|
||||||
} else {
|
self.collect_tokens_no_attrs(|this| this.parse_stmt_path_start(lo, attrs))?
|
||||||
self.parse_stmt_path_start(lo, attrs)
|
}
|
||||||
}?
|
ForceCollect::No => self.parse_stmt_path_start(lo, attrs)?,
|
||||||
|
}
|
||||||
} else if let Some(item) = self.parse_item_common(
|
} else if let Some(item) = self.parse_item_common(
|
||||||
attrs.clone(),
|
attrs.clone(),
|
||||||
false,
|
false,
|
||||||
|
@ -113,13 +114,12 @@ impl<'a> Parser<'a> {
|
||||||
self.mk_stmt(lo, StmtKind::Empty)
|
self.mk_stmt(lo, StmtKind::Empty)
|
||||||
} else if self.token != token::CloseDelim(Delimiter::Brace) {
|
} else if self.token != token::CloseDelim(Delimiter::Brace) {
|
||||||
// Remainder are line-expr stmts.
|
// Remainder are line-expr stmts.
|
||||||
let e = if force_collect == ForceCollect::Yes {
|
let e = match force_collect {
|
||||||
self.collect_tokens_no_attrs(|this| {
|
ForceCollect::Yes => self.collect_tokens_no_attrs(|this| {
|
||||||
this.parse_expr_res(Restrictions::STMT_EXPR, Some(attrs))
|
this.parse_expr_res(Restrictions::STMT_EXPR, Some(attrs))
|
||||||
})
|
})?,
|
||||||
} else {
|
ForceCollect::No => self.parse_expr_res(Restrictions::STMT_EXPR, Some(attrs))?,
|
||||||
self.parse_expr_res(Restrictions::STMT_EXPR, Some(attrs))
|
};
|
||||||
}?;
|
|
||||||
if matches!(e.kind, ExprKind::Assign(..)) && self.eat_keyword(kw::Else) {
|
if matches!(e.kind, ExprKind::Assign(..)) && self.eat_keyword(kw::Else) {
|
||||||
let bl = self.parse_block()?;
|
let bl = self.parse_block()?;
|
||||||
// Destructuring assignment ... else.
|
// Destructuring assignment ... else.
|
||||||
|
|
|
@ -323,14 +323,15 @@ impl<'a> Parser<'a> {
|
||||||
} else if self.can_begin_bound() {
|
} else if self.can_begin_bound() {
|
||||||
self.parse_bare_trait_object(lo, allow_plus)?
|
self.parse_bare_trait_object(lo, allow_plus)?
|
||||||
} else if self.eat(&token::DotDotDot) {
|
} else if self.eat(&token::DotDotDot) {
|
||||||
if allow_c_variadic == AllowCVariadic::Yes {
|
match allow_c_variadic {
|
||||||
TyKind::CVarArgs
|
AllowCVariadic::Yes => TyKind::CVarArgs,
|
||||||
} else {
|
AllowCVariadic::No => {
|
||||||
// FIXME(Centril): Should we just allow `...` syntactically
|
// FIXME(Centril): Should we just allow `...` syntactically
|
||||||
// anywhere in a type and use semantic restrictions instead?
|
// anywhere in a type and use semantic restrictions instead?
|
||||||
self.error_illegal_c_varadic_ty(lo);
|
self.error_illegal_c_varadic_ty(lo);
|
||||||
TyKind::Err
|
TyKind::Err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let msg = format!("expected type, found {}", super::token_descr(&self.token));
|
let msg = format!("expected type, found {}", super::token_descr(&self.token));
|
||||||
let mut err = self.struct_span_err(self.token.span, &msg);
|
let mut err = self.struct_span_err(self.token.span, &msg);
|
||||||
|
@ -343,10 +344,9 @@ impl<'a> Parser<'a> {
|
||||||
let mut ty = self.mk_ty(span, kind);
|
let mut ty = self.mk_ty(span, kind);
|
||||||
|
|
||||||
// Try to recover from use of `+` with incorrect priority.
|
// Try to recover from use of `+` with incorrect priority.
|
||||||
if allow_plus == AllowPlus::Yes {
|
match allow_plus {
|
||||||
self.maybe_recover_from_bad_type_plus(&ty)?;
|
AllowPlus::Yes => self.maybe_recover_from_bad_type_plus(&ty)?,
|
||||||
} else {
|
AllowPlus::No => self.maybe_report_ambiguous_plus(impl_dyn_multi, &ty),
|
||||||
self.maybe_report_ambiguous_plus(impl_dyn_multi, &ty);
|
|
||||||
}
|
}
|
||||||
if RecoverQuestionMark::Yes == recover_question_mark {
|
if RecoverQuestionMark::Yes == recover_question_mark {
|
||||||
ty = self.maybe_recover_from_question_mark(ty);
|
ty = self.maybe_recover_from_question_mark(ty);
|
||||||
|
|
|
@ -864,13 +864,17 @@ impl CheckAttrVisitor<'_> {
|
||||||
target: Target,
|
target: Target,
|
||||||
specified_inline: &mut Option<(bool, Span)>,
|
specified_inline: &mut Option<(bool, Span)>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if target == Target::Use || target == Target::ExternCrate {
|
match target {
|
||||||
|
Target::Use | Target::ExternCrate => {
|
||||||
let do_inline = meta.name_or_empty() == sym::inline;
|
let do_inline = meta.name_or_empty() == sym::inline;
|
||||||
if let Some((prev_inline, prev_span)) = *specified_inline {
|
if let Some((prev_inline, prev_span)) = *specified_inline {
|
||||||
if do_inline != prev_inline {
|
if do_inline != prev_inline {
|
||||||
let mut spans = MultiSpan::from_spans(vec![prev_span, meta.span()]);
|
let mut spans = MultiSpan::from_spans(vec![prev_span, meta.span()]);
|
||||||
spans.push_span_label(prev_span, fluent::passes_doc_inline_conflict_first);
|
spans.push_span_label(prev_span, fluent::passes_doc_inline_conflict_first);
|
||||||
spans.push_span_label(meta.span(), fluent::passes_doc_inline_conflict_second);
|
spans.push_span_label(
|
||||||
|
meta.span(),
|
||||||
|
fluent::passes_doc_inline_conflict_second,
|
||||||
|
);
|
||||||
self.tcx.sess.emit_err(errors::DocKeywordConflict { spans });
|
self.tcx.sess.emit_err(errors::DocKeywordConflict { spans });
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -879,7 +883,8 @@ impl CheckAttrVisitor<'_> {
|
||||||
*specified_inline = Some((do_inline, meta.span()));
|
*specified_inline = Some((do_inline, meta.span()));
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
_ => {
|
||||||
self.tcx.emit_spanned_lint(
|
self.tcx.emit_spanned_lint(
|
||||||
INVALID_DOC_ATTRIBUTES,
|
INVALID_DOC_ATTRIBUTES,
|
||||||
hir_id,
|
hir_id,
|
||||||
|
@ -893,6 +898,7 @@ impl CheckAttrVisitor<'_> {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Checks that an attribute is *not* used at the crate level. Returns `true` if valid.
|
/// Checks that an attribute is *not* used at the crate level. Returns `true` if valid.
|
||||||
fn check_attr_not_crate_level(
|
fn check_attr_not_crate_level(
|
||||||
|
@ -1137,7 +1143,7 @@ impl CheckAttrVisitor<'_> {
|
||||||
errors::DocTestUnknownInclude {
|
errors::DocTestUnknownInclude {
|
||||||
path,
|
path,
|
||||||
value: value.to_string(),
|
value: value.to_string(),
|
||||||
inner: if attr.style == AttrStyle::Inner { "!" } else { "" },
|
inner: match attr.style { AttrStyle::Inner=> "!" , AttrStyle::Outer => "" },
|
||||||
sugg: (attr.meta().unwrap().span, applicability),
|
sugg: (attr.meta().unwrap().span, applicability),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -298,9 +298,9 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
||||||
self.r.record_partial_res(id, PartialRes::new(res));
|
self.r.record_partial_res(id, PartialRes::new(res));
|
||||||
}
|
}
|
||||||
if module.is_normal() {
|
if module.is_normal() {
|
||||||
if res == Res::Err {
|
match res {
|
||||||
Ok(ty::Visibility::Public)
|
Res::Err => Ok(ty::Visibility::Public),
|
||||||
} else {
|
_ => {
|
||||||
let vis = ty::Visibility::Restricted(res.def_id());
|
let vis = ty::Visibility::Restricted(res.def_id());
|
||||||
if self.r.is_accessible_from(vis, parent_scope.module) {
|
if self.r.is_accessible_from(vis, parent_scope.module) {
|
||||||
Ok(vis.expect_local())
|
Ok(vis.expect_local())
|
||||||
|
@ -308,6 +308,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
||||||
Err(VisResolutionError::AncestorOnly(path.span))
|
Err(VisResolutionError::AncestorOnly(path.span))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
expected_found_error(res)
|
expected_found_error(res)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1552,12 +1552,12 @@ impl<'a> Resolver<'a> {
|
||||||
if b.is_extern_crate() && ident.span.rust_2018() {
|
if b.is_extern_crate() && ident.span.rust_2018() {
|
||||||
help_msgs.push(format!("use `::{ident}` to refer to this {thing} unambiguously"))
|
help_msgs.push(format!("use `::{ident}` to refer to this {thing} unambiguously"))
|
||||||
}
|
}
|
||||||
if misc == AmbiguityErrorMisc::SuggestCrate {
|
match misc {
|
||||||
help_msgs
|
AmbiguityErrorMisc::SuggestCrate => help_msgs
|
||||||
.push(format!("use `crate::{ident}` to refer to this {thing} unambiguously"))
|
.push(format!("use `crate::{ident}` to refer to this {thing} unambiguously")),
|
||||||
} else if misc == AmbiguityErrorMisc::SuggestSelf {
|
AmbiguityErrorMisc::SuggestSelf => help_msgs
|
||||||
help_msgs
|
.push(format!("use `self::{ident}` to refer to this {thing} unambiguously")),
|
||||||
.push(format!("use `self::{ident}` to refer to this {thing} unambiguously"))
|
AmbiguityErrorMisc::FromPrelude | AmbiguityErrorMisc::None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
err.span_note(b.span, ¬e_msg);
|
err.span_note(b.span, ¬e_msg);
|
||||||
|
|
|
@ -1230,14 +1230,16 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::PredicateKind::WellFormed(ty) => {
|
ty::PredicateKind::WellFormed(ty) => {
|
||||||
if self.tcx.sess.opts.unstable_opts.trait_solver == TraitSolver::Classic {
|
match self.tcx.sess.opts.unstable_opts.trait_solver {
|
||||||
|
TraitSolver::Classic => {
|
||||||
// WF predicates cannot themselves make
|
// WF predicates cannot themselves make
|
||||||
// errors. They can only block due to
|
// errors. They can only block due to
|
||||||
// ambiguity; otherwise, they always
|
// ambiguity; otherwise, they always
|
||||||
// degenerate into other obligations
|
// degenerate into other obligations
|
||||||
// (which may fail).
|
// (which may fail).
|
||||||
span_bug!(span, "WF predicate not satisfied for {:?}", ty);
|
span_bug!(span, "WF predicate not satisfied for {:?}", ty);
|
||||||
} else {
|
}
|
||||||
|
TraitSolver::Chalk | TraitSolver::Next => {
|
||||||
// FIXME: we'll need a better message which takes into account
|
// FIXME: we'll need a better message which takes into account
|
||||||
// which bounds actually failed to hold.
|
// which bounds actually failed to hold.
|
||||||
self.tcx.sess.struct_span_err(
|
self.tcx.sess.struct_span_err(
|
||||||
|
@ -1246,6 +1248,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ty::PredicateKind::ConstEvaluatable(..) => {
|
ty::PredicateKind::ConstEvaluatable(..) => {
|
||||||
// Errors for `ConstEvaluatable` predicates show up as
|
// Errors for `ConstEvaluatable` predicates show up as
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue