mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-14 07:53:24 +00:00
Auto merge of #90000 - matthiaskrgr:rollup-vj7wwur, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #89950 (bootstrap: tweak verbosity settings) - #89965 (Fix ICE with `let...else` and `ref mut`) - #89974 (Nicer error message if the user attempts to do let...else if) - #89987 (Check implementing type for `#[doc(hidden)]`) - #89989 (rustdoc: Add static size assertion for `clean::Type`) - #89990 (rustc_span: `Ident::invalid` -> `Ident::empty`) - #89993 (Remove dead code from `compiletest::json`) - #89996 (Bump backtrace) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
5dab47dcd8
@ -62,7 +62,7 @@ impl NestedMetaItem {
|
|||||||
self.meta_item().and_then(|meta_item| meta_item.ident())
|
self.meta_item().and_then(|meta_item| meta_item.ident())
|
||||||
}
|
}
|
||||||
pub fn name_or_empty(&self) -> Symbol {
|
pub fn name_or_empty(&self) -> Symbol {
|
||||||
self.ident().unwrap_or_else(Ident::invalid).name
|
self.ident().unwrap_or_else(Ident::empty).name
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the string value if `self` is a `MetaItem` and the `MetaItem` is a
|
/// Gets the string value if `self` is a `MetaItem` and the `MetaItem` is a
|
||||||
@ -131,7 +131,7 @@ impl Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn name_or_empty(&self) -> Symbol {
|
pub fn name_or_empty(&self) -> Symbol {
|
||||||
self.ident().unwrap_or_else(Ident::invalid).name
|
self.ident().unwrap_or_else(Ident::empty).name
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn value_str(&self) -> Option<Symbol> {
|
pub fn value_str(&self) -> Option<Symbol> {
|
||||||
@ -166,7 +166,7 @@ impl MetaItem {
|
|||||||
if self.path.segments.len() == 1 { Some(self.path.segments[0].ident) } else { None }
|
if self.path.segments.len() == 1 { Some(self.path.segments[0].ident) } else { None }
|
||||||
}
|
}
|
||||||
pub fn name_or_empty(&self) -> Symbol {
|
pub fn name_or_empty(&self) -> Symbol {
|
||||||
self.ident().unwrap_or_else(Ident::invalid).name
|
self.ident().unwrap_or_else(Ident::empty).name
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example:
|
// Example:
|
||||||
|
@ -1060,7 +1060,7 @@ pub fn noop_visit_crate<T: MutVisitor>(krate: &mut Crate, vis: &mut T) {
|
|||||||
let item_vis =
|
let item_vis =
|
||||||
Visibility { kind: VisibilityKind::Public, span: span.shrink_to_lo(), tokens: None };
|
Visibility { kind: VisibilityKind::Public, span: span.shrink_to_lo(), tokens: None };
|
||||||
let item = P(Item {
|
let item = P(Item {
|
||||||
ident: Ident::invalid(),
|
ident: Ident::empty(),
|
||||||
attrs,
|
attrs,
|
||||||
id: DUMMY_NODE_ID,
|
id: DUMMY_NODE_ID,
|
||||||
vis: item_vis,
|
vis: item_vis,
|
||||||
|
@ -1435,7 +1435,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
trace!("registering opaque type with id {:#?}", opaque_ty_id);
|
trace!("registering opaque type with id {:#?}", opaque_ty_id);
|
||||||
let opaque_ty_item = hir::Item {
|
let opaque_ty_item = hir::Item {
|
||||||
def_id: opaque_ty_id,
|
def_id: opaque_ty_id,
|
||||||
ident: Ident::invalid(),
|
ident: Ident::empty(),
|
||||||
kind: opaque_ty_item_kind,
|
kind: opaque_ty_item_kind,
|
||||||
vis: respan(self.lower_span(span.shrink_to_lo()), hir::VisibilityKind::Inherited),
|
vis: respan(self.lower_span(span.shrink_to_lo()), hir::VisibilityKind::Inherited),
|
||||||
span: self.lower_span(opaque_ty_span),
|
span: self.lower_span(opaque_ty_span),
|
||||||
|
@ -45,12 +45,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||||||
let item_msg;
|
let item_msg;
|
||||||
let reason;
|
let reason;
|
||||||
let mut opt_source = None;
|
let mut opt_source = None;
|
||||||
let access_place_desc = self.describe_place(access_place.as_ref());
|
let access_place_desc = self.describe_any_place(access_place.as_ref());
|
||||||
debug!("report_mutability_error: access_place_desc={:?}", access_place_desc);
|
debug!("report_mutability_error: access_place_desc={:?}", access_place_desc);
|
||||||
|
|
||||||
match the_place_err {
|
match the_place_err {
|
||||||
PlaceRef { local, projection: [] } => {
|
PlaceRef { local, projection: [] } => {
|
||||||
item_msg = format!("`{}`", access_place_desc.unwrap());
|
item_msg = access_place_desc;
|
||||||
if access_place.as_local().is_some() {
|
if access_place.as_local().is_some() {
|
||||||
reason = ", as it is not declared as mutable".to_string();
|
reason = ", as it is not declared as mutable".to_string();
|
||||||
} else {
|
} else {
|
||||||
@ -83,7 +83,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||||||
// If we deref an immutable ref then the suggestion here doesn't help.
|
// If we deref an immutable ref then the suggestion here doesn't help.
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
item_msg = format!("`{}`", access_place_desc.unwrap());
|
item_msg = access_place_desc;
|
||||||
if self.is_upvar_field_projection(access_place.as_ref()).is_some() {
|
if self.is_upvar_field_projection(access_place.as_ref()).is_some() {
|
||||||
reason = ", as it is not declared as mutable".to_string();
|
reason = ", as it is not declared as mutable".to_string();
|
||||||
} else {
|
} else {
|
||||||
@ -96,17 +96,17 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||||||
PlaceRef { local, projection: [ProjectionElem::Deref] }
|
PlaceRef { local, projection: [ProjectionElem::Deref] }
|
||||||
if self.body.local_decls[local].is_ref_for_guard() =>
|
if self.body.local_decls[local].is_ref_for_guard() =>
|
||||||
{
|
{
|
||||||
item_msg = format!("`{}`", access_place_desc.unwrap());
|
item_msg = access_place_desc;
|
||||||
reason = ", as it is immutable for the pattern guard".to_string();
|
reason = ", as it is immutable for the pattern guard".to_string();
|
||||||
}
|
}
|
||||||
PlaceRef { local, projection: [ProjectionElem::Deref] }
|
PlaceRef { local, projection: [ProjectionElem::Deref] }
|
||||||
if self.body.local_decls[local].is_ref_to_static() =>
|
if self.body.local_decls[local].is_ref_to_static() =>
|
||||||
{
|
{
|
||||||
if access_place.projection.len() == 1 {
|
if access_place.projection.len() == 1 {
|
||||||
item_msg = format!("immutable static item `{}`", access_place_desc.unwrap());
|
item_msg = format!("immutable static item {}", access_place_desc);
|
||||||
reason = String::new();
|
reason = String::new();
|
||||||
} else {
|
} else {
|
||||||
item_msg = format!("`{}`", access_place_desc.unwrap());
|
item_msg = access_place_desc;
|
||||||
let local_info = &self.body.local_decls[local].local_info;
|
let local_info = &self.body.local_decls[local].local_info;
|
||||||
if let Some(box LocalInfo::StaticRef { def_id, .. }) = *local_info {
|
if let Some(box LocalInfo::StaticRef { def_id, .. }) = *local_info {
|
||||||
let static_name = &self.infcx.tcx.item_name(def_id);
|
let static_name = &self.infcx.tcx.item_name(def_id);
|
||||||
@ -121,7 +121,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||||||
&& proj_base.is_empty()
|
&& proj_base.is_empty()
|
||||||
&& !self.upvars.is_empty()
|
&& !self.upvars.is_empty()
|
||||||
{
|
{
|
||||||
item_msg = format!("`{}`", access_place_desc.unwrap());
|
item_msg = access_place_desc;
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
self.body.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty.is_region_ptr()
|
self.body.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty.is_region_ptr()
|
||||||
);
|
);
|
||||||
@ -147,7 +147,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||||||
});
|
});
|
||||||
let pointer_type = source.describe_for_immutable_place(self.infcx.tcx);
|
let pointer_type = source.describe_for_immutable_place(self.infcx.tcx);
|
||||||
opt_source = Some(source);
|
opt_source = Some(source);
|
||||||
if let Some(desc) = access_place_desc {
|
if let Some(desc) = self.describe_place(access_place.as_ref()) {
|
||||||
item_msg = format!("`{}`", desc);
|
item_msg = format!("`{}`", desc);
|
||||||
reason = match error_access {
|
reason = match error_access {
|
||||||
AccessKind::Mutate => format!(", which is behind {}", pointer_type),
|
AccessKind::Mutate => format!(", which is behind {}", pointer_type),
|
||||||
|
@ -812,7 +812,7 @@ pub fn expand_global_asm<'cx>(
|
|||||||
Ok(args) => {
|
Ok(args) => {
|
||||||
if let Some(inline_asm) = expand_preparsed_asm(ecx, args) {
|
if let Some(inline_asm) = expand_preparsed_asm(ecx, args) {
|
||||||
MacEager::items(smallvec![P(ast::Item {
|
MacEager::items(smallvec![P(ast::Item {
|
||||||
ident: Ident::invalid(),
|
ident: Ident::empty(),
|
||||||
attrs: Vec::new(),
|
attrs: Vec::new(),
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
kind: ast::ItemKind::GlobalAsm(inline_asm),
|
kind: ast::ItemKind::GlobalAsm(inline_asm),
|
||||||
|
@ -85,7 +85,7 @@ impl MultiItemModifier for Expander {
|
|||||||
fn dummy_annotatable() -> Annotatable {
|
fn dummy_annotatable() -> Annotatable {
|
||||||
Annotatable::GenericParam(ast::GenericParam {
|
Annotatable::GenericParam(ast::GenericParam {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
ident: Ident::invalid(),
|
ident: Ident::empty(),
|
||||||
attrs: Default::default(),
|
attrs: Default::default(),
|
||||||
bounds: Default::default(),
|
bounds: Default::default(),
|
||||||
is_placeholder: false,
|
is_placeholder: false,
|
||||||
|
@ -724,7 +724,7 @@ impl<'a> TraitDef<'a> {
|
|||||||
|
|
||||||
cx.item(
|
cx.item(
|
||||||
self.span,
|
self.span,
|
||||||
Ident::invalid(),
|
Ident::empty(),
|
||||||
a,
|
a,
|
||||||
ast::ItemKind::Impl(Box::new(ast::ImplKind {
|
ast::ItemKind::Impl(Box::new(ast::ImplKind {
|
||||||
unsafety,
|
unsafety,
|
||||||
|
@ -178,7 +178,7 @@ fn inject_impl_of_structural_trait(
|
|||||||
|
|
||||||
let newitem = cx.item(
|
let newitem = cx.item(
|
||||||
span,
|
span,
|
||||||
Ident::invalid(),
|
Ident::empty(),
|
||||||
attrs,
|
attrs,
|
||||||
ItemKind::Impl(Box::new(ImplKind {
|
ItemKind::Impl(Box::new(ImplKind {
|
||||||
unsafety: ast::Unsafe::No,
|
unsafety: ast::Unsafe::No,
|
||||||
|
@ -77,7 +77,7 @@ pub fn inject(
|
|||||||
|
|
||||||
let use_item = cx.item(
|
let use_item = cx.item(
|
||||||
span,
|
span,
|
||||||
Ident::invalid(),
|
Ident::empty(),
|
||||||
vec![cx.attribute(cx.meta_word(span, sym::prelude_import))],
|
vec![cx.attribute(cx.meta_word(span, sym::prelude_import))],
|
||||||
ast::ItemKind::Use(ast::UseTree {
|
ast::ItemKind::Use(ast::UseTree {
|
||||||
prefix: cx.path(span, import_path),
|
prefix: cx.path(span, import_path),
|
||||||
|
@ -383,7 +383,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||||||
Unsafe::No,
|
Unsafe::No,
|
||||||
ModKind::Loaded(krate.items, Inline::Yes, krate.span)
|
ModKind::Loaded(krate.items, Inline::Yes, krate.span)
|
||||||
),
|
),
|
||||||
ident: Ident::invalid(),
|
ident: Ident::empty(),
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
vis: ast::Visibility {
|
vis: ast::Visibility {
|
||||||
span: krate.span.shrink_to_lo(),
|
span: krate.span.shrink_to_lo(),
|
||||||
@ -1426,7 +1426,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
|
|||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
ast::ItemKind::Mod(_, ref mut mod_kind) if ident != Ident::invalid() => {
|
ast::ItemKind::Mod(_, ref mut mod_kind) if ident != Ident::empty() => {
|
||||||
let (file_path, dir_path, dir_ownership) = match mod_kind {
|
let (file_path, dir_path, dir_ownership) = match mod_kind {
|
||||||
ModKind::Loaded(_, inline, _) => {
|
ModKind::Loaded(_, inline, _) => {
|
||||||
// Inline `mod foo { ... }`, but we still need to push directories.
|
// Inline `mod foo { ... }`, but we still need to push directories.
|
||||||
@ -1508,7 +1508,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
|
|||||||
_ => {
|
_ => {
|
||||||
item.attrs = attrs;
|
item.attrs = attrs;
|
||||||
// The crate root is special - don't assign an ID to it.
|
// The crate root is special - don't assign an ID to it.
|
||||||
if !(matches!(item.kind, ast::ItemKind::Mod(..)) && ident == Ident::invalid()) {
|
if !(matches!(item.kind, ast::ItemKind::Mod(..)) && ident == Ident::empty()) {
|
||||||
assign_id!(self, &mut item.id, || noop_flat_map_item(item, self))
|
assign_id!(self, &mut item.id, || noop_flat_map_item(item, self))
|
||||||
} else {
|
} else {
|
||||||
noop_flat_map_item(item, self)
|
noop_flat_map_item(item, self)
|
||||||
|
@ -204,7 +204,7 @@ fn parse_tree(
|
|||||||
pprust::token_to_string(&token),
|
pprust::token_to_string(&token),
|
||||||
);
|
);
|
||||||
sess.span_diagnostic.span_err(token.span, &msg);
|
sess.span_diagnostic.span_err(token.span, &msg);
|
||||||
TokenTree::MetaVar(token.span, Ident::invalid())
|
TokenTree::MetaVar(token.span, Ident::empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
// There are no more tokens. Just return the `$` we already have.
|
// There are no more tokens. Just return the `$` we already have.
|
||||||
|
@ -23,7 +23,7 @@ pub fn placeholder(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let ident = Ident::invalid();
|
let ident = Ident::empty();
|
||||||
let attrs = Vec::new();
|
let attrs = Vec::new();
|
||||||
let vis = vis.unwrap_or(ast::Visibility {
|
let vis = vis.unwrap_or(ast::Visibility {
|
||||||
span: DUMMY_SP,
|
span: DUMMY_SP,
|
||||||
|
@ -121,7 +121,7 @@ impl LifetimeName {
|
|||||||
match *self {
|
match *self {
|
||||||
LifetimeName::ImplicitObjectLifetimeDefault
|
LifetimeName::ImplicitObjectLifetimeDefault
|
||||||
| LifetimeName::Implicit
|
| LifetimeName::Implicit
|
||||||
| LifetimeName::Error => Ident::invalid(),
|
| LifetimeName::Error => Ident::empty(),
|
||||||
LifetimeName::Underscore => Ident::with_dummy_span(kw::UnderscoreLifetime),
|
LifetimeName::Underscore => Ident::with_dummy_span(kw::UnderscoreLifetime),
|
||||||
LifetimeName::Static => Ident::with_dummy_span(kw::StaticLifetime),
|
LifetimeName::Static => Ident::with_dummy_span(kw::StaticLifetime),
|
||||||
LifetimeName::Param(param_name) => param_name.ident(),
|
LifetimeName::Param(param_name) => param_name.ident(),
|
||||||
@ -233,7 +233,7 @@ impl<'hir> PathSegment<'hir> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn invalid() -> Self {
|
pub fn invalid() -> Self {
|
||||||
Self::from_ident(Ident::invalid())
|
Self::from_ident(Ident::empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn args(&self) -> &GenericArgs<'hir> {
|
pub fn args(&self) -> &GenericArgs<'hir> {
|
||||||
@ -310,7 +310,7 @@ impl GenericArg<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_synthetic(&self) -> bool {
|
pub fn is_synthetic(&self) -> bool {
|
||||||
matches!(self, GenericArg::Lifetime(lifetime) if lifetime.name.ident() == Ident::invalid())
|
matches!(self, GenericArg::Lifetime(lifetime) if lifetime.name.ident() == Ident::empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn descr(&self) -> &'static str {
|
pub fn descr(&self) -> &'static str {
|
||||||
|
@ -657,6 +657,24 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the method is an impl for an item with docs_hidden, don't doc.
|
||||||
|
if method_context(cx, impl_item.hir_id()) == MethodLateContext::PlainImpl {
|
||||||
|
let parent = cx.tcx.hir().get_parent_did(impl_item.hir_id());
|
||||||
|
let impl_ty = cx.tcx.type_of(parent);
|
||||||
|
let outerdef = match impl_ty.kind() {
|
||||||
|
ty::Adt(def, _) => Some(def.did),
|
||||||
|
ty::Foreign(def_id) => Some(*def_id),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
let is_hidden = match outerdef {
|
||||||
|
Some(id) => cx.tcx.is_doc_hidden(id),
|
||||||
|
None => false,
|
||||||
|
};
|
||||||
|
if is_hidden {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let (article, desc) = cx.tcx.article_and_description(impl_item.def_id.to_def_id());
|
let (article, desc) = cx.tcx.article_and_description(impl_item.def_id.to_def_id());
|
||||||
self.check_missing_docs_attrs(cx, impl_item.def_id, impl_item.span, article, desc);
|
self.check_missing_docs_attrs(cx, impl_item.def_id, impl_item.span, article, desc);
|
||||||
}
|
}
|
||||||
|
@ -443,7 +443,7 @@ impl<'hir> Map<'hir> {
|
|||||||
pub fn body_param_names(&self, id: BodyId) -> impl Iterator<Item = Ident> + 'hir {
|
pub fn body_param_names(&self, id: BodyId) -> impl Iterator<Item = Ident> + 'hir {
|
||||||
self.body(id).params.iter().map(|arg| match arg.pat.kind {
|
self.body(id).params.iter().map(|arg| match arg.pat.kind {
|
||||||
PatKind::Binding(_, _, ident, _) => ident,
|
PatKind::Binding(_, _, ident, _) => ident,
|
||||||
_ => Ident::new(kw::Empty, rustc_span::DUMMY_SP),
|
_ => Ident::empty(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ impl<'a> Parser<'a> {
|
|||||||
return Err(e);
|
return Err(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
(Ident::invalid(), ItemKind::Use(tree))
|
(Ident::empty(), ItemKind::Use(tree))
|
||||||
} else if self.check_fn_front_matter(def_final) {
|
} else if self.check_fn_front_matter(def_final) {
|
||||||
// FUNCTION ITEM
|
// FUNCTION ITEM
|
||||||
let (ident, sig, generics, body) = self.parse_fn(attrs, req_name, lo)?;
|
let (ident, sig, generics, body) = self.parse_fn(attrs, req_name, lo)?;
|
||||||
@ -287,7 +287,7 @@ impl<'a> Parser<'a> {
|
|||||||
return Ok(None);
|
return Ok(None);
|
||||||
} else if macros_allowed && self.check_path() {
|
} else if macros_allowed && self.check_path() {
|
||||||
// MACRO INVOCATION ITEM
|
// MACRO INVOCATION ITEM
|
||||||
(Ident::invalid(), ItemKind::MacCall(self.parse_item_macro(vis)?))
|
(Ident::empty(), ItemKind::MacCall(self.parse_item_macro(vis)?))
|
||||||
} else {
|
} else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
@ -586,7 +586,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok((Ident::invalid(), item_kind))
|
Ok((Ident::empty(), item_kind))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_item_list<T>(
|
fn parse_item_list<T>(
|
||||||
@ -933,7 +933,7 @@ impl<'a> Parser<'a> {
|
|||||||
let abi = self.parse_abi(); // ABI?
|
let abi = self.parse_abi(); // ABI?
|
||||||
let items = self.parse_item_list(attrs, |p| p.parse_foreign_item(ForceCollect::No))?;
|
let items = self.parse_item_list(attrs, |p| p.parse_foreign_item(ForceCollect::No))?;
|
||||||
let module = ast::ForeignMod { unsafety, abi, items };
|
let module = ast::ForeignMod { unsafety, abi, items };
|
||||||
Ok((Ident::invalid(), ItemKind::ForeignMod(module)))
|
Ok((Ident::empty(), ItemKind::ForeignMod(module)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses a foreign item (one in an `extern { ... }` block).
|
/// Parses a foreign item (one in an `extern { ... }` block).
|
||||||
|
@ -16,7 +16,7 @@ use rustc_ast::{
|
|||||||
};
|
};
|
||||||
use rustc_ast::{Block, BlockCheckMode, Expr, ExprKind, Local, Stmt};
|
use rustc_ast::{Block, BlockCheckMode, Expr, ExprKind, Local, Stmt};
|
||||||
use rustc_ast::{StmtKind, DUMMY_NODE_ID};
|
use rustc_ast::{StmtKind, DUMMY_NODE_ID};
|
||||||
use rustc_errors::{Applicability, PResult};
|
use rustc_errors::{Applicability, DiagnosticBuilder, PResult};
|
||||||
use rustc_span::source_map::{BytePos, Span};
|
use rustc_span::source_map::{BytePos, Span};
|
||||||
use rustc_span::symbol::{kw, sym};
|
use rustc_span::symbol::{kw, sym};
|
||||||
|
|
||||||
@ -300,6 +300,12 @@ impl<'a> Parser<'a> {
|
|||||||
None => LocalKind::Decl,
|
None => LocalKind::Decl,
|
||||||
Some(init) => {
|
Some(init) => {
|
||||||
if self.eat_keyword(kw::Else) {
|
if self.eat_keyword(kw::Else) {
|
||||||
|
if self.token.is_keyword(kw::If) {
|
||||||
|
// `let...else if`. Emit the same error that `parse_block()` would,
|
||||||
|
// but explicitly point out that this pattern is not allowed.
|
||||||
|
let msg = "conditional `else if` is not supported for `let...else`";
|
||||||
|
return Err(self.error_block_no_opening_brace_msg(msg));
|
||||||
|
}
|
||||||
let els = self.parse_block()?;
|
let els = self.parse_block()?;
|
||||||
self.check_let_else_init_bool_expr(&init);
|
self.check_let_else_init_bool_expr(&init);
|
||||||
self.check_let_else_init_trailing_brace(&init);
|
self.check_let_else_init_trailing_brace(&init);
|
||||||
@ -392,10 +398,9 @@ impl<'a> Parser<'a> {
|
|||||||
Ok(block)
|
Ok(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn error_block_no_opening_brace<T>(&mut self) -> PResult<'a, T> {
|
fn error_block_no_opening_brace_msg(&mut self, msg: &str) -> DiagnosticBuilder<'a> {
|
||||||
let sp = self.token.span;
|
let sp = self.token.span;
|
||||||
let tok = super::token_descr(&self.token);
|
let mut e = self.struct_span_err(sp, msg);
|
||||||
let mut e = self.struct_span_err(sp, &format!("expected `{{`, found {}", tok));
|
|
||||||
let do_not_suggest_help = self.token.is_keyword(kw::In) || self.token == token::Colon;
|
let do_not_suggest_help = self.token.is_keyword(kw::In) || self.token == token::Colon;
|
||||||
|
|
||||||
// Check to see if the user has written something like
|
// Check to see if the user has written something like
|
||||||
@ -435,7 +440,13 @@ impl<'a> Parser<'a> {
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
e.span_label(sp, "expected `{`");
|
e.span_label(sp, "expected `{`");
|
||||||
Err(e)
|
e
|
||||||
|
}
|
||||||
|
|
||||||
|
fn error_block_no_opening_brace<T>(&mut self) -> PResult<'a, T> {
|
||||||
|
let tok = super::token_descr(&self.token);
|
||||||
|
let msg = format!("expected `{{`, found {}", tok);
|
||||||
|
Err(self.error_block_no_opening_brace_msg(&msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses a block. Inner attributes are allowed.
|
/// Parses a block. Inner attributes are allowed.
|
||||||
|
@ -1327,7 +1327,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
|
|||||||
if fst.ident.span.rust_2018() && !fst.ident.is_path_segment_keyword() =>
|
if fst.ident.span.rust_2018() && !fst.ident.is_path_segment_keyword() =>
|
||||||
{
|
{
|
||||||
// Insert a placeholder that's later replaced by `self`/`super`/etc.
|
// Insert a placeholder that's later replaced by `self`/`super`/etc.
|
||||||
path.insert(0, Segment::from_ident(Ident::invalid()));
|
path.insert(0, Segment::from_ident(Ident::empty()));
|
||||||
}
|
}
|
||||||
_ => return None,
|
_ => return None,
|
||||||
}
|
}
|
||||||
|
@ -978,7 +978,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
|
|||||||
// HACK(eddyb) `lint_if_path_starts_with_module` needs at least
|
// HACK(eddyb) `lint_if_path_starts_with_module` needs at least
|
||||||
// 2 segments, so the `resolve_path` above won't trigger it.
|
// 2 segments, so the `resolve_path` above won't trigger it.
|
||||||
let mut full_path = import.module_path.clone();
|
let mut full_path = import.module_path.clone();
|
||||||
full_path.push(Segment::from_ident(Ident::invalid()));
|
full_path.push(Segment::from_ident(Ident::empty()));
|
||||||
self.r.lint_if_path_starts_with_module(
|
self.r.lint_if_path_starts_with_module(
|
||||||
import.crate_lint(),
|
import.crate_lint(),
|
||||||
&full_path,
|
&full_path,
|
||||||
|
@ -1453,7 +1453,7 @@ impl Ident {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn invalid() -> Ident {
|
pub fn empty() -> Ident {
|
||||||
Ident::with_dummy_span(kw::Empty)
|
Ident::with_dummy_span(kw::Empty)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit cc89bb66f91b2b4a640b0b525ca5d753e3346d7e
|
Subproject commit 7f14f76c8ba6945c052fab77022e6e768b58e0b4
|
@ -146,7 +146,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let is_test = args.iter().any(|a| a == "--test");
|
let is_test = args.iter().any(|a| a == "--test");
|
||||||
if verbose > 1 {
|
if verbose > 2 {
|
||||||
let rust_env_vars =
|
let rust_env_vars =
|
||||||
env::vars().filter(|(k, _)| k.starts_with("RUST") || k.starts_with("CARGO"));
|
env::vars().filter(|(k, _)| k.starts_with("RUST") || k.starts_with("CARGO"));
|
||||||
let prefix = if is_test { "[RUSTC-SHIM] rustc --test" } else { "[RUSTC-SHIM] rustc" };
|
let prefix = if is_test { "[RUSTC-SHIM] rustc --test" } else { "[RUSTC-SHIM] rustc" };
|
||||||
|
@ -980,7 +980,7 @@ class RustBuild(object):
|
|||||||
self.cargo()))
|
self.cargo()))
|
||||||
args = [self.cargo(), "build", "--manifest-path",
|
args = [self.cargo(), "build", "--manifest-path",
|
||||||
os.path.join(self.rust_root, "src/bootstrap/Cargo.toml")]
|
os.path.join(self.rust_root, "src/bootstrap/Cargo.toml")]
|
||||||
for _ in range(1, self.verbose):
|
for _ in range(0, self.verbose):
|
||||||
args.append("--verbose")
|
args.append("--verbose")
|
||||||
if self.use_locked_deps:
|
if self.use_locked_deps:
|
||||||
args.append("--locked")
|
args.append("--locked")
|
||||||
|
@ -1483,7 +1483,7 @@ impl<'a> Builder<'a> {
|
|||||||
cargo.env("WINAPI_NO_BUNDLED_LIBRARIES", "1");
|
cargo.env("WINAPI_NO_BUNDLED_LIBRARIES", "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
for _ in 1..self.verbosity {
|
for _ in 0..self.verbosity {
|
||||||
cargo.arg("-v");
|
cargo.arg("-v");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1450,6 +1450,10 @@ crate enum Type {
|
|||||||
ImplTrait(Vec<GenericBound>),
|
ImplTrait(Vec<GenericBound>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// `Type` is used a lot. Make sure it doesn't unintentionally get bigger.
|
||||||
|
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||||
|
rustc_data_structures::static_assert_size!(Type, 72);
|
||||||
|
|
||||||
crate trait GetDefId {
|
crate trait GetDefId {
|
||||||
/// Use this method to get the [`DefId`] of a [`clean`] AST node.
|
/// Use this method to get the [`DefId`] of a [`clean`] AST node.
|
||||||
/// This will return [`None`] when called on a primitive [`clean::Type`].
|
/// This will return [`None`] when called on a primitive [`clean::Type`].
|
||||||
|
15
src/test/ui/hidden-doc-associated-item.rs
Normal file
15
src/test/ui/hidden-doc-associated-item.rs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// check-pass
|
||||||
|
// See issue #85526.
|
||||||
|
// This test should produce no warnings.
|
||||||
|
|
||||||
|
#![deny(missing_docs)]
|
||||||
|
//! Crate docs
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub struct Foo;
|
||||||
|
|
||||||
|
impl Foo {
|
||||||
|
pub fn bar() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
7
src/test/ui/let-else/issue-89960.rs
Normal file
7
src/test/ui/let-else/issue-89960.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#![feature(let_else)]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// FIXME: more precise diagnostics
|
||||||
|
let Some(ref mut meow) = Some(()) else { return };
|
||||||
|
//~^ ERROR: cannot borrow value as mutable, as `val` is not declared as mutable
|
||||||
|
}
|
12
src/test/ui/let-else/issue-89960.stderr
Normal file
12
src/test/ui/let-else/issue-89960.stderr
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
error[E0596]: cannot borrow value as mutable, as `val` is not declared as mutable
|
||||||
|
--> $DIR/issue-89960.rs:5:14
|
||||||
|
|
|
||||||
|
LL | let Some(ref mut meow) = Some(()) else { return };
|
||||||
|
| ---------^^^^^^^^^^^^-----------------------------
|
||||||
|
| | |
|
||||||
|
| | cannot borrow as mutable
|
||||||
|
| help: consider changing this to be mutable: `mut val`
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0596`.
|
10
src/test/ui/let-else/let-else-if.rs
Normal file
10
src/test/ui/let-else/let-else-if.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#![feature(let_else)]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let Some(_) = Some(()) else if true {
|
||||||
|
//~^ ERROR conditional `else if` is not supported for `let...else`
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
}
|
18
src/test/ui/let-else/let-else-if.stderr
Normal file
18
src/test/ui/let-else/let-else-if.stderr
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
error: conditional `else if` is not supported for `let...else`
|
||||||
|
--> $DIR/let-else-if.rs:4:33
|
||||||
|
|
|
||||||
|
LL | let Some(_) = Some(()) else if true {
|
||||||
|
| ^^ expected `{`
|
||||||
|
|
|
||||||
|
help: try placing this code inside a block
|
||||||
|
|
|
||||||
|
LL ~ let Some(_) = Some(()) else { if true {
|
||||||
|
LL +
|
||||||
|
LL + return;
|
||||||
|
LL + } else {
|
||||||
|
LL + return;
|
||||||
|
LL ~ } };
|
||||||
|
|
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
@ -11,6 +11,6 @@ fn main() {
|
|||||||
Symbol::intern("foo") == rustc_span::sym::clippy;
|
Symbol::intern("foo") == rustc_span::sym::clippy;
|
||||||
Symbol::intern("foo") == rustc_span::symbol::kw::SelfLower;
|
Symbol::intern("foo") == rustc_span::symbol::kw::SelfLower;
|
||||||
Symbol::intern("foo") != rustc_span::symbol::kw::SelfUpper;
|
Symbol::intern("foo") != rustc_span::symbol::kw::SelfUpper;
|
||||||
Ident::invalid().name == rustc_span::sym::clippy;
|
Ident::empty().name == rustc_span::sym::clippy;
|
||||||
rustc_span::sym::clippy == Ident::invalid().name;
|
rustc_span::sym::clippy == Ident::empty().name;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,6 @@ fn main() {
|
|||||||
Symbol::intern("foo").as_str() == "clippy";
|
Symbol::intern("foo").as_str() == "clippy";
|
||||||
Symbol::intern("foo").to_string() == "self";
|
Symbol::intern("foo").to_string() == "self";
|
||||||
Symbol::intern("foo").to_ident_string() != "Self";
|
Symbol::intern("foo").to_ident_string() != "Self";
|
||||||
&*Ident::invalid().as_str() == "clippy";
|
&*Ident::empty().as_str() == "clippy";
|
||||||
"clippy" == Ident::invalid().to_string();
|
"clippy" == Ident::empty().to_string();
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,13 @@ LL | Symbol::intern("foo").to_ident_string() != "Self";
|
|||||||
error: unnecessary `Symbol` to string conversion
|
error: unnecessary `Symbol` to string conversion
|
||||||
--> $DIR/unnecessary_symbol_str.rs:14:5
|
--> $DIR/unnecessary_symbol_str.rs:14:5
|
||||||
|
|
|
|
||||||
LL | &*Ident::invalid().as_str() == "clippy";
|
LL | &*Ident::empty().as_str() == "clippy";
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Ident::invalid().name == rustc_span::sym::clippy`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Ident::empty().name == rustc_span::sym::clippy`
|
||||||
|
|
||||||
error: unnecessary `Symbol` to string conversion
|
error: unnecessary `Symbol` to string conversion
|
||||||
--> $DIR/unnecessary_symbol_str.rs:15:5
|
--> $DIR/unnecessary_symbol_str.rs:15:5
|
||||||
|
|
|
|
||||||
LL | "clippy" == Ident::invalid().to_string();
|
LL | "clippy" == Ident::empty().to_string();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::clippy == Ident::invalid().name`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::clippy == Ident::empty().name`
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
|
@ -74,8 +74,6 @@ struct DiagnosticSpanMacroExpansion {
|
|||||||
struct DiagnosticCode {
|
struct DiagnosticCode {
|
||||||
/// The code itself.
|
/// The code itself.
|
||||||
code: String,
|
code: String,
|
||||||
/// An explanation for the code.
|
|
||||||
explanation: Option<String>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rustfix_diagnostics_only(output: &str) -> String {
|
pub fn rustfix_diagnostics_only(output: &str) -> String {
|
||||||
|
Loading…
Reference in New Issue
Block a user