Auto merge of #100024 - matthiaskrgr:rollup-36ab4wx, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #99340 (Fix ICE in Definitions::create_def)
 - #99629 (Improve `cannot move out of` error message)
 - #99864 (bootstrap: don't emit warn about duplicated deps with same/different features if some of sets actually empty)
 - #99911 (Remove some uses of `guess_head_span`)
 - #99976 (Make Rustdoc exit with correct error code when scraping examples from invalid files)
 - #100003 (Improve size assertions.)
 - #100012 (Avoid `Ty` to `String` conversions)
 - #100020 (better error when python is not found in x - issue #99648)

Failed merges:

 - #99994 (Replace `guess_head_span` with `opt_span`)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2022-08-01 15:40:43 +00:00
commit c9e134e1b6
45 changed files with 422 additions and 324 deletions

View File

@ -1111,10 +1111,6 @@ pub struct Expr {
pub tokens: Option<LazyTokenStream>,
}
// `Expr` 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!(Expr, 104);
impl Expr {
/// Returns `true` if this expression would be valid somewhere that expects a value;
/// for example, an `if` condition.
@ -2883,9 +2879,6 @@ pub enum ItemKind {
MacroDef(MacroDef),
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(ItemKind, 112);
impl ItemKind {
pub fn article(&self) -> &str {
use ItemKind::*;
@ -2957,9 +2950,6 @@ pub enum AssocItemKind {
MacCall(MacCall),
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(AssocItemKind, 72);
impl AssocItemKind {
pub fn defaultness(&self) -> Defaultness {
match *self {
@ -3009,9 +2999,6 @@ pub enum ForeignItemKind {
MacCall(MacCall),
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(ForeignItemKind, 72);
impl From<ForeignItemKind> for ItemKind {
fn from(foreign_item_kind: ForeignItemKind) -> ItemKind {
match foreign_item_kind {
@ -3038,3 +3025,27 @@ fn try_from(item_kind: ItemKind) -> Result<ForeignItemKind, ItemKind> {
}
pub type ForeignItem = Item<ForeignItemKind>;
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
mod size_asserts {
use super::*;
// These are in alphabetical order, which is easy to maintain.
rustc_data_structures::static_assert_size!(AssocItemKind, 72);
rustc_data_structures::static_assert_size!(Attribute, 152);
rustc_data_structures::static_assert_size!(Block, 48);
rustc_data_structures::static_assert_size!(Expr, 104);
rustc_data_structures::static_assert_size!(Fn, 192);
rustc_data_structures::static_assert_size!(ForeignItemKind, 72);
rustc_data_structures::static_assert_size!(GenericBound, 88);
rustc_data_structures::static_assert_size!(Generics, 72);
rustc_data_structures::static_assert_size!(Impl, 200);
rustc_data_structures::static_assert_size!(Item, 200);
rustc_data_structures::static_assert_size!(ItemKind, 112);
rustc_data_structures::static_assert_size!(Lit, 48);
rustc_data_structures::static_assert_size!(Pat, 120);
rustc_data_structures::static_assert_size!(Path, 40);
rustc_data_structures::static_assert_size!(PathSegment, 24);
rustc_data_structures::static_assert_size!(Stmt, 32);
rustc_data_structures::static_assert_size!(Ty, 96);
}

View File

@ -39,7 +39,7 @@
use super::{
explain_borrow::{BorrowExplanation, LaterUseKind},
IncludingDowncast, RegionName, RegionNameSource, UseSpans,
DescribePlaceOpt, RegionName, RegionNameSource, UseSpans,
};
#[derive(Debug)]
@ -137,7 +137,10 @@ pub(crate) fn report_use_of_moved_or_uninitialized(
span,
desired_action.as_noun(),
partially_str,
self.describe_place_with_options(moved_place, IncludingDowncast(true)),
self.describe_place_with_options(
moved_place,
DescribePlaceOpt { including_downcast: true, including_tuple_field: true },
),
);
let reinit_spans = maybe_reinitialized_locations
@ -274,8 +277,10 @@ pub(crate) fn report_use_of_moved_or_uninitialized(
}
}
let opt_name =
self.describe_place_with_options(place.as_ref(), IncludingDowncast(true));
let opt_name = self.describe_place_with_options(
place.as_ref(),
DescribePlaceOpt { including_downcast: true, including_tuple_field: true },
);
let note_msg = match opt_name {
Some(ref name) => format!("`{}`", name),
None => "value".to_owned(),
@ -341,12 +346,17 @@ fn report_use_of_uninitialized(
}
}
let (name, desc) =
match self.describe_place_with_options(moved_place, IncludingDowncast(true)) {
Some(name) => (format!("`{name}`"), format!("`{name}` ")),
None => ("the variable".to_string(), String::new()),
};
let path = match self.describe_place_with_options(used_place, IncludingDowncast(true)) {
let (name, desc) = match self.describe_place_with_options(
moved_place,
DescribePlaceOpt { including_downcast: true, including_tuple_field: true },
) {
Some(name) => (format!("`{name}`"), format!("`{name}` ")),
None => ("the variable".to_string(), String::new()),
};
let path = match self.describe_place_with_options(
used_place,
DescribePlaceOpt { including_downcast: true, including_tuple_field: true },
) {
Some(name) => format!("`{name}`"),
None => "value".to_string(),
};

View File

@ -4,7 +4,7 @@
use rustc_const_eval::util::{call_kind, CallDesugaringKind};
use rustc_errors::{Applicability, Diagnostic};
use rustc_hir as hir;
use rustc_hir::def::Namespace;
use rustc_hir::def::{CtorKind, Namespace};
use rustc_hir::GeneratorKind;
use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::mir::tcx::PlaceTy;
@ -16,7 +16,7 @@
use rustc_middle::ty::{self, DefIdTree, Instance, Ty, TyCtxt};
use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult};
use rustc_span::def_id::LocalDefId;
use rustc_span::{symbol::sym, Span, DUMMY_SP};
use rustc_span::{symbol::sym, Span, Symbol, DUMMY_SP};
use rustc_target::abi::VariantIdx;
use rustc_trait_selection::traits::type_known_to_meet_bound_modulo_regions;
@ -43,7 +43,15 @@
pub(crate) use region_name::{RegionName, RegionNameSource};
pub(crate) use rustc_const_eval::util::CallKind;
pub(super) struct IncludingDowncast(pub(super) bool);
pub(super) struct DescribePlaceOpt {
pub including_downcast: bool,
/// Enable/Disable tuple fields.
/// For example `x` tuple. if it's `true` `x.0`. Otherwise `x`
pub including_tuple_field: bool,
}
pub(super) struct IncludingTupleField(pub(super) bool);
impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
/// Adds a suggestion when a closure is invoked twice with a moved variable or when a closure
@ -164,7 +172,10 @@ pub(super) fn describe_any_place(&self, place_ref: PlaceRef<'tcx>) -> String {
/// End-user visible description of `place` if one can be found.
/// If the place is a temporary for instance, `None` will be returned.
pub(super) fn describe_place(&self, place_ref: PlaceRef<'tcx>) -> Option<String> {
self.describe_place_with_options(place_ref, IncludingDowncast(false))
self.describe_place_with_options(
place_ref,
DescribePlaceOpt { including_downcast: false, including_tuple_field: true },
)
}
/// End-user visible description of `place` if one can be found. If the place is a temporary
@ -174,7 +185,7 @@ pub(super) fn describe_place(&self, place_ref: PlaceRef<'tcx>) -> Option<String>
pub(super) fn describe_place_with_options(
&self,
place: PlaceRef<'tcx>,
including_downcast: IncludingDowncast,
opt: DescribePlaceOpt,
) -> Option<String> {
let local = place.local;
let mut autoderef_index = None;
@ -224,7 +235,7 @@ pub(super) fn describe_place_with_options(
}
}
}
ProjectionElem::Downcast(..) if including_downcast.0 => return None,
ProjectionElem::Downcast(..) if opt.including_downcast => return None,
ProjectionElem::Downcast(..) => (),
ProjectionElem::Field(field, _ty) => {
// FIXME(project-rfc_2229#36): print capture precisely here.
@ -238,9 +249,12 @@ pub(super) fn describe_place_with_options(
let field_name = self.describe_field(
PlaceRef { local, projection: place.projection.split_at(index).0 },
*field,
IncludingTupleField(opt.including_tuple_field),
);
buf.push('.');
buf.push_str(&field_name);
if let Some(field_name_str) = field_name {
buf.push('.');
buf.push_str(&field_name_str);
}
}
}
ProjectionElem::Index(index) => {
@ -261,6 +275,18 @@ pub(super) fn describe_place_with_options(
ok.ok().map(|_| buf)
}
fn describe_name(&self, place: PlaceRef<'tcx>) -> Option<Symbol> {
for elem in place.projection.into_iter() {
match elem {
ProjectionElem::Downcast(Some(name), _) => {
return Some(*name);
}
_ => {}
}
}
None
}
/// Appends end-user visible description of the `local` place to `buf`. If `local` doesn't have
/// a name, or its name was generated by the compiler, then `Err` is returned
fn append_local_to_string(&self, local: Local, buf: &mut String) -> Result<(), ()> {
@ -275,7 +301,12 @@ fn append_local_to_string(&self, local: Local, buf: &mut String) -> Result<(), (
}
/// End-user visible description of the `field`nth field of `base`
fn describe_field(&self, place: PlaceRef<'tcx>, field: Field) -> String {
fn describe_field(
&self,
place: PlaceRef<'tcx>,
field: Field,
including_tuple_field: IncludingTupleField,
) -> Option<String> {
let place_ty = match place {
PlaceRef { local, projection: [] } => PlaceTy::from_ty(self.body.local_decls[local].ty),
PlaceRef { local, projection: [proj_base @ .., elem] } => match elem {
@ -289,7 +320,12 @@ fn describe_field(&self, place: PlaceRef<'tcx>, field: Field) -> String {
ProjectionElem::Field(_, field_type) => PlaceTy::from_ty(*field_type),
},
};
self.describe_field_from_ty(place_ty.ty, field, place_ty.variant_index)
self.describe_field_from_ty(
place_ty.ty,
field,
place_ty.variant_index,
including_tuple_field,
)
}
/// End-user visible description of the `field_index`nth field of `ty`
@ -298,10 +334,11 @@ fn describe_field_from_ty(
ty: Ty<'_>,
field: Field,
variant_index: Option<VariantIdx>,
) -> String {
including_tuple_field: IncludingTupleField,
) -> Option<String> {
if ty.is_box() {
// If the type is a box, the field is described from the boxed type
self.describe_field_from_ty(ty.boxed_ty(), field, variant_index)
self.describe_field_from_ty(ty.boxed_ty(), field, variant_index, including_tuple_field)
} else {
match *ty.kind() {
ty::Adt(def, _) => {
@ -311,14 +348,17 @@ fn describe_field_from_ty(
} else {
def.non_enum_variant()
};
variant.fields[field.index()].name.to_string()
if !including_tuple_field.0 && variant.ctor_kind == CtorKind::Fn {
return None;
}
Some(variant.fields[field.index()].name.to_string())
}
ty::Tuple(_) => field.index().to_string(),
ty::Tuple(_) => Some(field.index().to_string()),
ty::Ref(_, ty, _) | ty::RawPtr(ty::TypeAndMut { ty, .. }) => {
self.describe_field_from_ty(ty, field, variant_index)
self.describe_field_from_ty(ty, field, variant_index, including_tuple_field)
}
ty::Array(ty, _) | ty::Slice(ty) => {
self.describe_field_from_ty(ty, field, variant_index)
self.describe_field_from_ty(ty, field, variant_index, including_tuple_field)
}
ty::Closure(def_id, _) | ty::Generator(def_id, _, _) => {
// We won't be borrowck'ing here if the closure came from another crate,
@ -335,7 +375,7 @@ fn describe_field_from_ty(
.unwrap()
.get_root_variable();
self.infcx.tcx.hir().name(var_id).to_string()
Some(self.infcx.tcx.hir().name(var_id).to_string())
}
_ => {
// Might need a revision when the fields in trait RFC is implemented

View File

@ -6,7 +6,7 @@
};
use rustc_span::Span;
use crate::diagnostics::UseSpans;
use crate::diagnostics::{DescribePlaceOpt, UseSpans};
use crate::prefixes::PrefixSet;
use crate::MirBorrowckCtxt;
@ -368,13 +368,31 @@ fn report_cannot_move_from_borrowed_content(
}
_ => {
let source = self.borrowed_content_source(deref_base);
match (self.describe_place(move_place.as_ref()), source.describe_for_named_place())
{
(Some(place_desc), Some(source_desc)) => self.cannot_move_out_of(
let move_place_ref = move_place.as_ref();
match (
self.describe_place_with_options(
move_place_ref,
DescribePlaceOpt {
including_downcast: false,
including_tuple_field: false,
},
),
self.describe_name(move_place_ref),
source.describe_for_named_place(),
) {
(Some(place_desc), Some(name), Some(source_desc)) => self.cannot_move_out_of(
span,
&format!("`{place_desc}` as enum variant `{name}` which is behind a {source_desc}"),
),
(Some(place_desc), Some(name), None) => self.cannot_move_out_of(
span,
&format!("`{place_desc}` as enum variant `{name}`"),
),
(Some(place_desc), _, Some(source_desc)) => self.cannot_move_out_of(
span,
&format!("`{place_desc}` which is behind a {source_desc}"),
),
(_, _) => self.cannot_move_out_of(
(_, _, _) => self.cannot_move_out_of(
span,
&source.describe_for_unnamed_place(self.infcx.tcx),
),

View File

@ -37,9 +37,6 @@ pub enum Immediate<Prov: Provenance = AllocId> {
Uninit,
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(Immediate, 56);
impl<Prov: Provenance> From<ScalarMaybeUninit<Prov>> for Immediate<Prov> {
#[inline(always)]
fn from(val: ScalarMaybeUninit<Prov>) -> Self {
@ -117,9 +114,6 @@ pub struct ImmTy<'tcx, Prov: Provenance = AllocId> {
pub layout: TyAndLayout<'tcx>,
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(ImmTy<'_>, 72);
impl<Prov: Provenance> std::fmt::Display for ImmTy<'_, Prov> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
/// Helper function for printing a scalar to a FmtPrinter
@ -187,9 +181,6 @@ pub enum Operand<Prov: Provenance = AllocId> {
Indirect(MemPlace<Prov>),
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(Operand, 64);
#[derive(Clone, Debug)]
pub struct OpTy<'tcx, Prov: Provenance = AllocId> {
op: Operand<Prov>, // Keep this private; it helps enforce invariants.
@ -204,9 +195,6 @@ pub struct OpTy<'tcx, Prov: Provenance = AllocId> {
pub align: Option<Align>,
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(OpTy<'_>, 88);
impl<'tcx, Prov: Provenance> std::ops::Deref for OpTy<'tcx, Prov> {
type Target = Operand<Prov>;
#[inline(always)]
@ -830,3 +818,14 @@ pub fn read_discriminant(
})
}
}
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
mod size_asserts {
use super::*;
// These are in alphabetical order, which is easy to maintain.
rustc_data_structures::static_assert_size!(Immediate, 56);
rustc_data_structures::static_assert_size!(ImmTy<'_>, 72);
rustc_data_structures::static_assert_size!(Operand, 64);
rustc_data_structures::static_assert_size!(OpTy<'_>, 88);
}

View File

@ -25,9 +25,6 @@ pub enum MemPlaceMeta<Prov: Provenance = AllocId> {
None,
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(MemPlaceMeta, 24);
impl<Prov: Provenance> MemPlaceMeta<Prov> {
pub fn unwrap_meta(self) -> Scalar<Prov> {
match self {
@ -56,9 +53,6 @@ pub struct MemPlace<Prov: Provenance = AllocId> {
pub meta: MemPlaceMeta<Prov>,
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(MemPlace, 40);
/// A MemPlace with its layout. Constructing it is only possible in this module.
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug)]
pub struct MPlaceTy<'tcx, Prov: Provenance = AllocId> {
@ -71,9 +65,6 @@ pub struct MPlaceTy<'tcx, Prov: Provenance = AllocId> {
pub align: Align,
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(MPlaceTy<'_>, 64);
#[derive(Copy, Clone, Debug)]
pub enum Place<Prov: Provenance = AllocId> {
/// A place referring to a value allocated in the `Memory` system.
@ -84,9 +75,6 @@ pub enum Place<Prov: Provenance = AllocId> {
Local { frame: usize, local: mir::Local },
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(Place, 48);
#[derive(Clone, Debug)]
pub struct PlaceTy<'tcx, Prov: Provenance = AllocId> {
place: Place<Prov>, // Keep this private; it helps enforce invariants.
@ -98,9 +86,6 @@ pub struct PlaceTy<'tcx, Prov: Provenance = AllocId> {
pub align: Align,
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(PlaceTy<'_>, 72);
impl<'tcx, Prov: Provenance> std::ops::Deref for PlaceTy<'tcx, Prov> {
type Target = Place<Prov>;
#[inline(always)]
@ -901,3 +886,15 @@ pub(super) fn unpack_dyn_trait(
Ok(mplace)
}
}
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
mod size_asserts {
use super::*;
// These are in alphabetical order, which is easy to maintain.
rustc_data_structures::static_assert_size!(MemPlaceMeta, 24);
rustc_data_structures::static_assert_size!(MemPlace, 40);
rustc_data_structures::static_assert_size!(MPlaceTy<'_>, 64);
rustc_data_structures::static_assert_size!(Place, 48);
rustc_data_structures::static_assert_size!(PlaceTy<'_>, 72);
}

View File

@ -338,7 +338,12 @@ pub fn new(stable_crate_id: StableCrateId) -> Definitions {
/// Adds a definition with a parent definition.
pub fn create_def(&mut self, parent: LocalDefId, data: DefPathData) -> LocalDefId {
debug!("create_def(parent={:?}, data={:?})", parent, data);
// We can't use `Debug` implementation for `LocalDefId` here, since it tries to acquire a
// reference to `Definitions` and we're already holding a mutable reference.
debug!(
"create_def(parent={}, data={data:?})",
self.def_path(parent).to_string_no_crate_verbose(),
);
// The root node must be created with `create_root_def()`.
assert!(data != DefPathData::CrateRoot);

View File

@ -3489,17 +3489,18 @@ pub fn tuple_fields(&self) -> Option<&'hir [FieldDef<'hir>]> {
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
mod size_asserts {
rustc_data_structures::static_assert_size!(super::Block<'static>, 48);
rustc_data_structures::static_assert_size!(super::Expr<'static>, 56);
rustc_data_structures::static_assert_size!(super::Pat<'static>, 88);
rustc_data_structures::static_assert_size!(super::QPath<'static>, 24);
rustc_data_structures::static_assert_size!(super::Ty<'static>, 72);
rustc_data_structures::static_assert_size!(super::GenericBound<'_>, 48);
rustc_data_structures::static_assert_size!(super::Generics<'static>, 56);
rustc_data_structures::static_assert_size!(super::Impl<'static>, 80);
rustc_data_structures::static_assert_size!(super::Item<'static>, 80);
rustc_data_structures::static_assert_size!(super::TraitItem<'static>, 88);
rustc_data_structures::static_assert_size!(super::ImplItem<'static>, 80);
rustc_data_structures::static_assert_size!(super::ForeignItem<'static>, 72);
use super::*;
// These are in alphabetical order, which is easy to maintain.
rustc_data_structures::static_assert_size!(Block<'static>, 48);
rustc_data_structures::static_assert_size!(Expr<'static>, 56);
rustc_data_structures::static_assert_size!(ForeignItem<'static>, 72);
rustc_data_structures::static_assert_size!(GenericBound<'_>, 48);
rustc_data_structures::static_assert_size!(Generics<'static>, 56);
rustc_data_structures::static_assert_size!(ImplItem<'static>, 80);
rustc_data_structures::static_assert_size!(Impl<'static>, 80);
rustc_data_structures::static_assert_size!(Item<'static>, 80);
rustc_data_structures::static_assert_size!(Pat<'static>, 88);
rustc_data_structures::static_assert_size!(QPath<'static>, 24);
rustc_data_structures::static_assert_size!(TraitItem<'static>, 88);
rustc_data_structures::static_assert_size!(Ty<'static>, 72);
}

View File

@ -1364,7 +1364,6 @@ fn perform_lint(
cx: &LateContext<'_>,
what: &str,
def_id: LocalDefId,
span: Span,
vis_span: Span,
exportable: bool,
) {
@ -1373,7 +1372,7 @@ fn perform_lint(
if vis_span.from_expansion() {
applicability = Applicability::MaybeIncorrect;
}
let def_span = cx.tcx.sess.source_map().guess_head_span(span);
let def_span = cx.tcx.def_span(def_id);
cx.struct_span_lint(UNREACHABLE_PUB, def_span, |lint| {
let mut err = lint.build(fluent::lint::builtin_unreachable_pub);
err.set_arg("what", what);
@ -1399,36 +1398,22 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
if let hir::ItemKind::Use(_, hir::UseKind::ListStem) = &item.kind {
return;
}
self.perform_lint(cx, "item", item.def_id, item.span, item.vis_span, true);
self.perform_lint(cx, "item", item.def_id, item.vis_span, true);
}
fn check_foreign_item(&mut self, cx: &LateContext<'_>, foreign_item: &hir::ForeignItem<'tcx>) {
self.perform_lint(
cx,
"item",
foreign_item.def_id,
foreign_item.span,
foreign_item.vis_span,
true,
);
self.perform_lint(cx, "item", foreign_item.def_id, foreign_item.vis_span, true);
}
fn check_field_def(&mut self, cx: &LateContext<'_>, field: &hir::FieldDef<'_>) {
let def_id = cx.tcx.hir().local_def_id(field.hir_id);
self.perform_lint(cx, "field", def_id, field.span, field.vis_span, false);
self.perform_lint(cx, "field", def_id, field.vis_span, false);
}
fn check_impl_item(&mut self, cx: &LateContext<'_>, impl_item: &hir::ImplItem<'_>) {
// Only lint inherent impl items.
if cx.tcx.associated_item(impl_item.def_id).trait_item_def_id.is_none() {
self.perform_lint(
cx,
"item",
impl_item.def_id,
impl_item.span,
impl_item.vis_span,
false,
);
self.perform_lint(cx, "item", impl_item.def_id, impl_item.vis_span, false);
}
}
}

View File

@ -800,9 +800,6 @@ pub struct Place<'tcx> {
pub projection: &'tcx List<PlaceElem<'tcx>>,
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
static_assert_size!(Place<'_>, 16);
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(TyEncodable, TyDecodable, HashStable)]
pub enum ProjectionElem<V, T> {
@ -866,11 +863,6 @@ pub enum ProjectionElem<V, T> {
/// and the index is a local.
pub type PlaceElem<'tcx> = ProjectionElem<Local, Ty<'tcx>>;
// This type is fairly frequently used, so we shouldn't unintentionally increase
// its size.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
static_assert_size!(PlaceElem<'_>, 24);
///////////////////////////////////////////////////////////////////////////
// Operands
@ -913,9 +905,6 @@ pub enum Operand<'tcx> {
Constant(Box<Constant<'tcx>>),
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
static_assert_size!(Operand<'_>, 24);
///////////////////////////////////////////////////////////////////////////
// Rvalues
@ -1067,9 +1056,6 @@ pub enum Rvalue<'tcx> {
CopyForDeref(Place<'tcx>),
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
static_assert_size!(Rvalue<'_>, 40);
#[derive(Clone, Copy, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
pub enum CastKind {
/// An exposing pointer to address cast. A cast between a pointer and an integer type, or
@ -1105,9 +1091,6 @@ pub enum AggregateKind<'tcx> {
Generator(LocalDefId, SubstsRef<'tcx>, hir::Movability),
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
static_assert_size!(AggregateKind<'_>, 48);
#[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
pub enum NullOp {
/// Returns the size of a value of that type
@ -1171,3 +1154,15 @@ pub enum BinOp {
/// The `ptr.offset` operator
Offset,
}
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
mod size_asserts {
use super::*;
// These are in alphabetical order, which is easy to maintain.
static_assert_size!(AggregateKind<'_>, 48);
static_assert_size!(Operand<'_>, 24);
static_assert_size!(Place<'_>, 16);
static_assert_size!(PlaceElem<'_>, 24);
static_assert_size!(Rvalue<'_>, 40);
}

View File

@ -190,10 +190,6 @@ pub enum StmtKind<'tcx> {
},
}
// `Expr` 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!(Expr<'_>, 104);
#[derive(Clone, Debug, Copy, PartialEq, Eq, Hash, HashStable, TyEncodable, TyDecodable)]
#[derive(TypeFoldable, TypeVisitable)]
pub struct LocalVarId(pub hir::HirId);
@ -812,3 +808,14 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
}
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
mod size_asserts {
use super::*;
// These are in alphabetical order, which is easy to maintain.
rustc_data_structures::static_assert_size!(Block, 56);
rustc_data_structures::static_assert_size!(Expr<'_>, 104);
rustc_data_structures::static_assert_size!(Pat<'_>, 24);
rustc_data_structures::static_assert_size!(Stmt<'_>, 120);
}

View File

@ -1459,11 +1459,11 @@ pub fn def_path_debug_str(self, def_id: DefId) -> String {
};
format!(
"{}[{}]{}",
"{}[{:04x}]{}",
crate_name,
// Don't print the whole stable crate id. That's just
// annoying in debug output.
&(format!("{:08x}", stable_crate_id.to_u64()))[..4],
stable_crate_id.to_u64() >> 8 * 6,
self.def_path(def_id).to_string_no_crate_verbose()
)
}

View File

@ -1,7 +1,7 @@
use rustc_data_structures::graph::iterate::{
NodeStatus, TriColorDepthFirstSearch, TriColorVisitor,
};
use rustc_hir::intravisit::FnKind;
use rustc_hir::def::DefKind;
use rustc_middle::mir::{BasicBlock, BasicBlocks, Body, Operand, TerminatorKind};
use rustc_middle::ty::subst::{GenericArg, InternalSubsts};
use rustc_middle::ty::{self, AssocItem, AssocItemContainer, Instance, TyCtxt};
@ -12,12 +12,7 @@
pub(crate) fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) {
let def_id = body.source.def_id().expect_local();
if let Some(fn_kind) = tcx.hir().get_by_def_id(def_id).fn_kind() {
if let FnKind::Closure = fn_kind {
// closures can't recur, so they don't matter.
return;
}
if let DefKind::Fn | DefKind::AssocFn = tcx.def_kind(def_id) {
// If this is trait/impl method, extract the trait's substs.
let trait_substs = match tcx.opt_associated_item(def_id.to_def_id()) {
Some(AssocItem {
@ -41,8 +36,8 @@ pub(crate) fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) {
vis.reachable_recursive_calls.sort();
let sp = tcx.def_span(def_id);
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let sp = tcx.sess.source_map().guess_head_span(tcx.hir().span_with_body(hir_id));
tcx.struct_span_lint_hir(UNCONDITIONAL_RECURSION, hir_id, sp, |lint| {
let mut db = lint.build("function cannot return without recursing");
db.span_label(sp, "cannot return without recursing");

View File

@ -1754,8 +1754,7 @@ fn check_def_id(&mut self, def_id: DefId, kind: &str, descr: &dyn fmt::Display)
|| self.in_assoc_ty
|| self.tcx.resolutions(()).has_pub_restricted
{
let vis_span =
self.tcx.sess.source_map().guess_head_span(self.tcx.def_span(def_id));
let vis_span = self.tcx.def_span(def_id);
if kind == "trait" {
self.tcx.sess.emit_err(InPublicInterfaceTraits {
span,

View File

@ -1,4 +1,3 @@
use crate::dep_graph::DepContext;
use crate::query::plumbing::CycleError;
use crate::query::{QueryContext, QueryStackFrame};
use rustc_hir::def::DefKind;
@ -536,17 +535,13 @@ pub(crate) fn report_cycle<'a>(
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
assert!(!stack.is_empty());
let fix_span = |span: Span, query: &QueryStackFrame| {
sess.source_map().guess_head_span(query.default_span(span))
};
let span = fix_span(stack[1 % stack.len()].span, &stack[0].query);
let span = stack[0].query.default_span(stack[1 % stack.len()].span);
let mut err =
struct_span_err!(sess, span, E0391, "cycle detected when {}", stack[0].query.description);
for i in 1..stack.len() {
let query = &stack[i].query;
let span = fix_span(stack[(i + 1) % stack.len()].span, query);
let span = query.default_span(stack[(i + 1) % stack.len()].span);
err.span_note(span, &format!("...which requires {}...", query.description));
}
@ -577,7 +572,7 @@ pub(crate) fn report_cycle<'a>(
}
if let Some((span, query)) = usage {
err.span_note(fix_span(span, &query), &format!("cycle used when {}", query.description));
err.span_note(query.default_span(span), &format!("cycle used when {}", query.description));
}
err
@ -606,8 +601,7 @@ pub fn print_query_stack<CTX: QueryContext>(
Level::FailureNote,
&format!("#{} [{}] {}", i, query_info.query.name, query_info.query.description),
);
diag.span =
tcx.dep_context().sess().source_map().guess_head_span(query_info.job.span).into();
diag.span = query_info.job.span.into();
handler.force_print_diagnostic(diag);
current_query = query_info.job.parent;

View File

@ -1587,11 +1587,7 @@ pub(crate) fn add_typo_suggestion(
};
let def_span = suggestion.res.opt_def_id().and_then(|def_id| match def_id.krate {
LOCAL_CRATE => self.opt_span(def_id),
_ => Some(
self.session
.source_map()
.guess_head_span(self.cstore().get_span_untracked(def_id, self.session)),
),
_ => Some(self.cstore().get_span_untracked(def_id, self.session)),
});
if let Some(def_span) = def_span {
if span.overlaps(def_span) {

View File

@ -136,12 +136,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
fn def_span(&self, def_id: DefId) -> Option<Span> {
match def_id.krate {
LOCAL_CRATE => self.r.opt_span(def_id),
_ => Some(
self.r
.session
.source_map()
.guess_head_span(self.r.cstore().get_span_untracked(def_id, self.r.session)),
),
_ => Some(self.r.cstore().get_span_untracked(def_id, self.r.session)),
}
}

View File

@ -223,8 +223,7 @@ fn on_unimplemented_note(
if let Some(def) = aty.ty_adt_def() {
// We also want to be able to select the slice's type's original
// signature with no type arguments resolved
let type_string = self.tcx.type_of(def.did()).to_string();
flags.push((sym::_Self, Some(format!("[{type_string}]"))));
flags.push((sym::_Self, Some(format!("[{}]", self.tcx.type_of(def.did())))));
}
if aty.is_integral() {
flags.push((sym::_Self, Some("[{integral}]".to_string())));
@ -242,10 +241,10 @@ fn on_unimplemented_note(
if let Some(def) = aty.ty_adt_def() {
// We also want to be able to select the array's type's original
// signature with no type arguments resolved
let type_string = self.tcx.type_of(def.did()).to_string();
flags.push((sym::_Self, Some(format!("[{type_string}; _]"))));
let def_ty = self.tcx.type_of(def.did());
flags.push((sym::_Self, Some(format!("[{def_ty}; _]"))));
if let Some(n) = len {
flags.push((sym::_Self, Some(format!("[{type_string}; {n}]"))));
flags.push((sym::_Self, Some(format!("[{def_ty}; {n}]"))));
}
}
if aty.is_integral() {

View File

@ -1946,7 +1946,6 @@ fn note_obligation_cause_for_async_await(
));
let original_span = err.span.primary_span().unwrap();
let original_span = self.tcx.sess.source_map().guess_head_span(original_span);
let mut span = MultiSpan::from_span(original_span);
let message = outer_generator

View File

@ -293,6 +293,7 @@ fn maybe_get_coercion_reason(&self, hir_id: hir::HirId, sp: Span) -> Option<(Spa
pub(crate) fn if_cause(
&self,
span: Span,
cond_span: Span,
then_expr: &'tcx hir::Expr<'tcx>,
else_expr: &'tcx hir::Expr<'tcx>,
then_ty: Ty<'tcx>,
@ -355,10 +356,13 @@ pub(crate) fn if_cause(
// 6 | | };
// | |_____^ expected integer, found `()`
// ```
if block.expr.is_none() && block.stmts.is_empty()
&& let Some(outer_span) = &mut outer_span
{
*outer_span = self.tcx.sess.source_map().guess_head_span(*outer_span);
if block.expr.is_none() && block.stmts.is_empty() && outer_span.is_some() {
let sp = if let Some(cs) = cond_span.find_ancestor_inside(span) {
span.with_hi(cs.hi())
} else {
span
};
outer_span = Some(sp);
}
(self.find_block_span(block), block.hir_id)

View File

@ -1003,8 +1003,15 @@ fn check_then_else(
let else_diverges = self.diverges.get();
let opt_suggest_box_span = self.opt_suggest_box_span(else_ty, orig_expected);
let if_cause =
self.if_cause(sp, then_expr, else_expr, then_ty, else_ty, opt_suggest_box_span);
let if_cause = self.if_cause(
sp,
cond_expr.span,
then_expr,
else_expr,
then_ty,
else_ty,
opt_suggest_box_span,
);
coerce.coerce(self, &if_cause, else_expr, else_ty);

View File

@ -158,34 +158,38 @@ fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
a transitive dependency has different features activated \
than in a previous build:\n"
);
eprintln!(
"the following dependencies are duplicated although they \
have the same features enabled:"
);
let (same, different): (Vec<_>, Vec<_>) =
duplicates.into_iter().partition(|(_, cur, prev)| cur.2 == prev.2);
for (id, cur, prev) in same {
eprintln!(" {}", id);
// same features
eprintln!(" `{}` ({:?})\n `{}` ({:?})", cur.0, cur.1, prev.0, prev.1);
if !same.is_empty() {
eprintln!(
"the following dependencies are duplicated although they \
have the same features enabled:"
);
for (id, cur, prev) in same {
eprintln!(" {}", id);
// same features
eprintln!(" `{}` ({:?})\n `{}` ({:?})", cur.0, cur.1, prev.0, prev.1);
}
}
eprintln!("the following dependencies have different features:");
for (id, cur, prev) in different {
eprintln!(" {}", id);
let cur_features: HashSet<_> = cur.2.into_iter().collect();
let prev_features: HashSet<_> = prev.2.into_iter().collect();
eprintln!(
" `{}` additionally enabled features {:?} at {:?}",
cur.0,
&cur_features - &prev_features,
cur.1
);
eprintln!(
" `{}` additionally enabled features {:?} at {:?}",
prev.0,
&prev_features - &cur_features,
prev.1
);
if !different.is_empty() {
eprintln!("the following dependencies have different features:");
for (id, cur, prev) in different {
eprintln!(" {}", id);
let cur_features: HashSet<_> = cur.2.into_iter().collect();
let prev_features: HashSet<_> = prev.2.into_iter().collect();
eprintln!(
" `{}` additionally enabled features {:?} at {:?}",
cur.0,
&cur_features - &prev_features,
cur.1
);
eprintln!(
" `{}` additionally enabled features {:?} at {:?}",
prev.0,
&prev_features - &cur_features,
prev.1
);
}
}
eprintln!();
eprintln!(

View File

@ -122,10 +122,6 @@ pub(crate) struct Crate {
pub(crate) external_traits: Rc<RefCell<FxHashMap<DefId, TraitWithExtraInfo>>>,
}
// `Crate` is frequently moved by-value. Make sure it doesn't unintentionally get bigger.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(Crate, 72);
impl Crate {
pub(crate) fn name(&self, tcx: TyCtxt<'_>) -> Symbol {
ExternalCrate::LOCAL.name(tcx)
@ -389,10 +385,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
// `Item` 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!(Item, 56);
pub(crate) fn rustc_span(def_id: DefId, tcx: TyCtxt<'_>) -> Span {
Span::new(def_id.as_local().map_or_else(
|| tcx.def_span(def_id),
@ -771,10 +763,6 @@ pub(crate) enum ItemKind {
KeywordItem,
}
// `ItemKind` is an enum and large variants can bloat up memory usage even for smaller ones
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(ItemKind, 112);
impl ItemKind {
/// Some items contain others such as structs (for their fields) and Enums
/// (for their variants). This method returns those contained items.
@ -994,10 +982,6 @@ pub(crate) struct DocFragment {
pub(crate) indent: usize,
}
// `DocFragment` 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!(DocFragment, 32);
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub(crate) enum DocFragmentKind {
/// A doc fragment created from a `///` or `//!` doc comment.
@ -1382,10 +1366,6 @@ pub(crate) struct GenericParamDef {
pub(crate) kind: GenericParamDefKind,
}
// `GenericParamDef` is used in many places. Make sure it doesn't unintentionally get bigger.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(GenericParamDef, 56);
impl GenericParamDef {
pub(crate) fn is_synthetic_type_param(&self) -> bool {
match self.kind {
@ -1590,10 +1570,6 @@ pub(crate) enum Type {
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);
impl Type {
/// When comparing types for equality, it can help to ignore `&` wrapping.
pub(crate) fn without_borrowed_ref(&self) -> &Type {
@ -2230,33 +2206,18 @@ pub(crate) enum GenericArg {
Infer,
}
// `GenericArg` can occur many times in a single `Path`, so make sure it
// doesn't increase in size unexpectedly.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(GenericArg, 80);
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub(crate) enum GenericArgs {
AngleBracketed { args: Box<[GenericArg]>, bindings: ThinVec<TypeBinding> },
Parenthesized { inputs: Box<[Type]>, output: Option<Box<Type>> },
}
// `GenericArgs` is in every `PathSegment`, so its size can significantly
// affect rustdoc's memory usage.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(GenericArgs, 32);
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub(crate) struct PathSegment {
pub(crate) name: Symbol,
pub(crate) args: GenericArgs,
}
// `PathSegment` usually occurs multiple times in every `Path`, so its size can
// significantly affect rustdoc's memory usage.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(PathSegment, 40);
#[derive(Clone, Debug)]
pub(crate) struct Typedef {
pub(crate) type_: Type,
@ -2527,3 +2488,19 @@ pub(crate) fn as_lt(&self) -> Option<&Lifetime> {
if let Self::Lifetime(lt) = self { Some(lt) } else { None }
}
}
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
mod size_asserts {
use super::*;
// These are in alphabetical order, which is easy to maintain.
rustc_data_structures::static_assert_size!(Crate, 72); // frequently moved by-value
rustc_data_structures::static_assert_size!(DocFragment, 32);
rustc_data_structures::static_assert_size!(GenericArg, 80);
rustc_data_structures::static_assert_size!(GenericArgs, 32);
rustc_data_structures::static_assert_size!(GenericParamDef, 56);
rustc_data_structures::static_assert_size!(Item, 56);
rustc_data_structures::static_assert_size!(ItemKind, 112);
rustc_data_structures::static_assert_size!(PathSegment, 40);
rustc_data_structures::static_assert_size!(Type, 72);
}

View File

@ -304,6 +304,12 @@ pub(crate) fn run(
let mut finder = FindCalls { calls: &mut calls, tcx, map: tcx.hir(), cx, target_crates };
tcx.hir().visit_all_item_likes_in_crate(&mut finder);
// The visitor might have found a type error, which we need to
// promote to a fatal error
if tcx.sess.diagnostic().has_errors_or_lint_errors().is_some() {
return Err(String::from("Compilation failed, aborting rustdoc"));
}
// Sort call locations within a given file in document order
for fn_calls in calls.values_mut() {
for file_calls in fn_calls.values_mut() {

View File

@ -0,0 +1,7 @@
// check-fail
// compile-flags: -Z unstable-options --scrape-examples-output-path {{build-base}}/t.calls --scrape-examples-target-crate foobar
pub fn foo() {
INVALID_FUNC();
//~^ ERROR could not resolve path
}

View File

@ -0,0 +1,14 @@
error[E0433]: failed to resolve: could not resolve path `INVALID_FUNC`
--> $DIR/scrape-examples-fail-if-type-error.rs:5:3
|
LL | INVALID_FUNC();
| ^^^^^^^^^^^^ could not resolve path `INVALID_FUNC`
|
= note: this error was originally ignored because you are running `rustdoc`
= note: try running again with `rustc` or `cargo check` and you may get a more detailed error
error: Compilation failed, aborting rustdoc
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0433`.

View File

@ -35,7 +35,7 @@ note: cycle used when checking item types in top-level module
--> $DIR/no-const-async.rs:4:1
|
LL | pub const async fn x() {}
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View File

@ -1,4 +1,4 @@
error[E0507]: cannot move out of `s.0` which is behind a shared reference
error[E0507]: cannot move out of `s` which is behind a shared reference
--> $DIR/access-mode-in-closures.rs:8:15
|
LL | match *s { S(v) => v }

View File

@ -1,4 +1,4 @@
error[E0507]: cannot move out of `f.0` which is behind a shared reference
error[E0507]: cannot move out of `f` as enum variant `Foo1` which is behind a shared reference
--> $DIR/borrowck-move-error-with-note.rs:11:11
|
LL | match *f {

View File

@ -2,18 +2,18 @@ error[E0391]: cycle detected when evaluating type-level constant
--> $DIR/issue-44415.rs:6:17
|
LL | bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }],
| ^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: ...which requires const-evaluating + checking `Foo::bytes::{constant#0}`...
--> $DIR/issue-44415.rs:6:17
|
LL | bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }],
| ^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `Foo::bytes::{constant#0}`...
--> $DIR/issue-44415.rs:6:17
|
LL | bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }],
| ^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires computing layout of `Foo`...
= note: ...which requires computing layout of `[u8; _]`...
= note: ...which requires normalizing `[u8; _]`...

View File

@ -8,8 +8,13 @@ LL | trait Foo<X = Box<dyn Foo>> {
note: cycle used when collecting item types in top-level module
--> $DIR/cycle-trait-default-type-trait.rs:4:1
|
LL | trait Foo<X = Box<dyn Foo>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | / trait Foo<X = Box<dyn Foo>> {
LL | |
LL | |
LL | | }
LL | |
LL | | fn main() { }
| |_____________^
error[E0391]: cycle detected when computing type of `Foo::X`
--> $DIR/cycle-trait-default-type-trait.rs:4:23
@ -21,8 +26,13 @@ LL | trait Foo<X = Box<dyn Foo>> {
note: cycle used when collecting item types in top-level module
--> $DIR/cycle-trait-default-type-trait.rs:4:1
|
LL | trait Foo<X = Box<dyn Foo>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | / trait Foo<X = Box<dyn Foo>> {
LL | |
LL | |
LL | | }
LL | |
LL | | fn main() { }
| |_____________^
error: aborting due to 2 previous errors

View File

@ -13,8 +13,10 @@ LL | trait Chromosome: Chromosome {
note: cycle used when collecting item types in top-level module
--> $DIR/cycle-trait-supertrait-direct.rs:3:1
|
LL | trait Chromosome: Chromosome {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | / trait Chromosome: Chromosome {
LL | |
LL | | }
| |_^
error: aborting due to previous error

View File

@ -4,12 +4,10 @@ warning: function cannot return without recursing
LL | / fn no_hrtb<'b, T>(mut t: T)
LL | | where
LL | | T: Bar<&'b isize>,
LL | | {
... |
LL | | no_hrtb(&mut t);
| | --------------- recursive call site
LL | | }
| |_^ cannot return without recursing
| |______________________^ cannot return without recursing
...
LL | no_hrtb(&mut t);
| --------------- recursive call site
|
= note: `#[warn(unconditional_recursion)]` on by default
= help: a `loop` may express intention better if this is on purpose
@ -20,12 +18,10 @@ warning: function cannot return without recursing
LL | / fn bar_hrtb<T>(mut t: T)
LL | | where
LL | | T: for<'b> Bar<&'b isize>,
LL | | {
... |
LL | | bar_hrtb(&mut t);
| | ---------------- recursive call site
LL | | }
| |_^ cannot return without recursing
| |______________________________^ cannot return without recursing
...
LL | bar_hrtb(&mut t);
| ---------------- recursive call site
|
= help: a `loop` may express intention better if this is on purpose
@ -35,14 +31,10 @@ warning: function cannot return without recursing
LL | / fn foo_hrtb_bar_not<'b, T>(mut t: T)
LL | | where
LL | | T: for<'a> Foo<&'a isize> + Bar<&'b isize>,
LL | | {
... |
LL | | foo_hrtb_bar_not(&mut t);
| | ------------------------ recursive call site
LL | |
LL | |
LL | | }
| |_^ cannot return without recursing
| |_______________________________________________^ cannot return without recursing
...
LL | foo_hrtb_bar_not(&mut t);
| ------------------------ recursive call site
|
= help: a `loop` may express intention better if this is on purpose
@ -70,12 +62,10 @@ warning: function cannot return without recursing
LL | / fn foo_hrtb_bar_hrtb<T>(mut t: T)
LL | | where
LL | | T: for<'a> Foo<&'a isize> + for<'b> Bar<&'b isize>,
LL | | {
LL | | // OK -- now we have `T : for<'b> Bar<&'b isize>`.
LL | | foo_hrtb_bar_hrtb(&mut t);
| | ------------------------- recursive call site
LL | | }
| |_^ cannot return without recursing
| |_______________________________________________________^ cannot return without recursing
...
LL | foo_hrtb_bar_hrtb(&mut t);
| ------------------------- recursive call site
|
= help: a `loop` may express intention better if this is on purpose

View File

@ -23,8 +23,10 @@ LL | trait T2 : T1 {
note: cycle used when collecting item types in top-level module
--> $DIR/issue-12511.rs:1:1
|
LL | trait T1 : T2 {
| ^^^^^^^^^^^^^
LL | / trait T1 : T2 {
LL | |
LL | | }
| |_^
error: aborting due to previous error

View File

@ -1,8 +1,8 @@
warning: unreachable `pub` item
--> $DIR/unreachable_pub.rs:8:5
--> $DIR/unreachable_pub.rs:8:13
|
LL | pub use std::fmt;
| ---^^^^^^^^^^^^^^
| --- ^^^^^^^^
| |
| help: consider restricting its visibility: `pub(crate)`
|
@ -93,7 +93,7 @@ warning: unreachable `pub` item
--> $DIR/unreachable_pub.rs:33:5
|
LL | pub const CARBON: usize = 1;
| ---^^^^^^^^^^^^^^^^^^^^^^^^^
| ---^^^^^^^^^^^^^^^^^^^^
| |
| help: consider restricting its visibility: `pub(crate)`
|
@ -103,7 +103,7 @@ warning: unreachable `pub` item
--> $DIR/unreachable_pub.rs:34:5
|
LL | pub static NITROGEN: usize = 2;
| ---^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ---^^^^^^^^^^^^^^^^^^^^^^^
| |
| help: consider restricting its visibility: `pub(crate)`
|
@ -113,7 +113,7 @@ warning: unreachable `pub` item
--> $DIR/unreachable_pub.rs:35:5
|
LL | pub type Oxygen = bool;
| ---^^^^^^^^^^^^^^^^^^^^
| ---^^^^^^^^^^^^
| |
| help: consider restricting its visibility: `pub(crate)`
|
@ -123,7 +123,7 @@ warning: unreachable `pub` item
--> $DIR/unreachable_pub.rs:38:47
|
LL | ($visibility: vis, $name: ident) => { $visibility struct $name {} }
| ^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | define_empty_struct_with_visibility!(pub, Fluorine);
| ---------------------------------------------------
@ -138,7 +138,7 @@ warning: unreachable `pub` item
--> $DIR/unreachable_pub.rs:44:9
|
LL | pub fn catalyze() -> bool;
| ---^^^^^^^^^^^^^^^^^^^^^^^
| ---^^^^^^^^^^^^^^^^^^^^^^
| |
| help: consider restricting its visibility: `pub(crate)`
|

View File

@ -0,0 +1,9 @@
fn main() {
let x: &Option<Box<i32>> = &Some(Box::new(0));
match x {
//~^ ERROR cannot move out of `x` as enum variant `Some` which is behind a shared reference
&Some(_y) => (),
&None => (),
}
}

View File

@ -0,0 +1,16 @@
error[E0507]: cannot move out of `x` as enum variant `Some` which is behind a shared reference
--> $DIR/issue-99470-move-out-of-some.rs:4:11
|
LL | match x {
| ^
LL |
LL | &Some(_y) => (),
| ---------
| | |
| | data moved here
| | move occurs because `_y` has type `Box<i32>`, which does not implement the `Copy` trait
| help: consider removing the `&`: `Some(_y)`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.

View File

@ -1,4 +1,4 @@
error[E0507]: cannot move out of `hellothere.x.0` which is behind a shared reference
error[E0507]: cannot move out of `hellothere.x` as enum variant `Bar` which is behind a shared reference
--> $DIR/moves-based-on-type-block-bad.rs:22:19
|
LL | match hellothere.x {

View File

@ -45,7 +45,7 @@ LL | let a = [A("".to_string())][0];
| move occurs because value has type `A`, which does not implement the `Copy` trait
| help: consider borrowing here: `&[A("".to_string())][0]`
error[E0507]: cannot move out of `a.0` which is behind a shared reference
error[E0507]: cannot move out of `a` which is behind a shared reference
--> $DIR/move-errors.rs:38:16
|
LL | let A(s) = *a;
@ -134,7 +134,7 @@ LL | F(s, mut t) => (),
|
= note: move occurs because these variables have types that don't implement the `Copy` trait
error[E0507]: cannot move out of `x.0` which is behind a shared reference
error[E0507]: cannot move out of `x` as enum variant `Err` which is behind a shared reference
--> $DIR/move-errors.rs:110:11
|
LL | match *x {

View File

@ -8,8 +8,14 @@ LL | impl dyn ToNbt<Self> {}
note: cycle used when collecting item types in top-level module
--> $DIR/issue-23305.rs:1:1
|
LL | pub trait ToNbt<T> {
| ^^^^^^^^^^^^^^^^^^
LL | / pub trait ToNbt<T> {
LL | | fn new(val: T) -> Self;
LL | | }
LL | |
... |
LL | |
LL | | fn main() {}
| |____________^
error: aborting due to previous error

View File

@ -1,4 +1,4 @@
error[E0507]: cannot move out of `s.0` which is behind a shared reference
error[E0507]: cannot move out of `s` which is behind a shared reference
--> $DIR/simple.rs:38:17
|
LL | let X(_t) = *s;
@ -7,7 +7,7 @@ LL | let X(_t) = *s;
| data moved here
| move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `r.0` which is behind a shared reference
error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference
--> $DIR/simple.rs:42:30
|
LL | if let Either::One(_t) = *r { }
@ -16,7 +16,7 @@ LL | if let Either::One(_t) = *r { }
| data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `r.0` which is behind a shared reference
error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference
--> $DIR/simple.rs:46:33
|
LL | while let Either::One(_t) = *r { }
@ -25,7 +25,7 @@ LL | while let Either::One(_t) = *r { }
| data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `r.0` which is behind a shared reference
error[E0507]: cannot move out of `r` as enum variant `Two` which is behind a shared reference
--> $DIR/simple.rs:50:11
|
LL | match *r {
@ -37,7 +37,7 @@ LL | Either::One(_t)
| data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `r.0` which is behind a shared reference
error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference
--> $DIR/simple.rs:57:11
|
LL | match *r {
@ -49,7 +49,7 @@ LL | Either::One(_t) => (),
| data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `sm.0` which is behind a mutable reference
error[E0507]: cannot move out of `sm` which is behind a mutable reference
--> $DIR/simple.rs:66:17
|
LL | let X(_t) = *sm;
@ -58,7 +58,7 @@ LL | let X(_t) = *sm;
| data moved here
| move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `rm.0` which is behind a mutable reference
error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
--> $DIR/simple.rs:70:30
|
LL | if let Either::One(_t) = *rm { }
@ -67,7 +67,7 @@ LL | if let Either::One(_t) = *rm { }
| data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `rm.0` which is behind a mutable reference
error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
--> $DIR/simple.rs:74:33
|
LL | while let Either::One(_t) = *rm { }
@ -76,7 +76,7 @@ LL | while let Either::One(_t) = *rm { }
| data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `rm.0` which is behind a mutable reference
error[E0507]: cannot move out of `rm` as enum variant `Two` which is behind a mutable reference
--> $DIR/simple.rs:78:11
|
LL | match *rm {
@ -88,7 +88,7 @@ LL | Either::One(_t)
| data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `rm.0` which is behind a mutable reference
error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
--> $DIR/simple.rs:85:11
|
LL | match *rm {
@ -100,7 +100,7 @@ LL | Either::One(_t) => (),
| data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `rm.0` which is behind a mutable reference
error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
--> $DIR/simple.rs:93:11
|
LL | match *rm {
@ -226,7 +226,7 @@ LL | Either::One(_t) => (),
| data moved here
| move occurs because `_t` has type `X`, which does not implement the `Copy` trait
error[E0507]: cannot move out of `s.0` which is behind a shared reference
error[E0507]: cannot move out of `s` which is behind a shared reference
--> $DIR/simple.rs:168:18
|
LL | let &X(_t) = s;
@ -236,7 +236,7 @@ LL | let &X(_t) = s;
| | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
| help: consider removing the `&`: `X(_t)`
error[E0507]: cannot move out of `r.0` which is behind a shared reference
error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference
--> $DIR/simple.rs:172:31
|
LL | if let &Either::One(_t) = r { }
@ -246,7 +246,7 @@ LL | if let &Either::One(_t) = r { }
| | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
| help: consider removing the `&`: `Either::One(_t)`
error[E0507]: cannot move out of `r.0` which is behind a shared reference
error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference
--> $DIR/simple.rs:176:34
|
LL | while let &Either::One(_t) = r { }
@ -256,7 +256,7 @@ LL | while let &Either::One(_t) = r { }
| | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
| help: consider removing the `&`: `Either::One(_t)`
error[E0507]: cannot move out of `r.0` which is behind a shared reference
error[E0507]: cannot move out of `r` as enum variant `Two` which is behind a shared reference
--> $DIR/simple.rs:180:11
|
LL | match r {
@ -276,7 +276,7 @@ LL +
LL ~ | &Either::Two(_t) => (),
|
error[E0507]: cannot move out of `r.0` which is behind a shared reference
error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference
--> $DIR/simple.rs:188:11
|
LL | match r {
@ -289,7 +289,7 @@ LL | &Either::One(_t) => (),
| | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
| help: consider removing the `&`: `Either::One(_t)`
error[E0507]: cannot move out of `r.0` which is behind a shared reference
error[E0507]: cannot move out of `r` as enum variant `One` which is behind a shared reference
--> $DIR/simple.rs:195:11
|
LL | match r {
@ -302,7 +302,7 @@ LL | &Either::One(_t) => (),
| | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
| help: consider removing the `&`: `Either::One(_t)`
error[E0507]: cannot move out of `sm.0` which is behind a mutable reference
error[E0507]: cannot move out of `sm` which is behind a mutable reference
--> $DIR/simple.rs:207:22
|
LL | let &mut X(_t) = sm;
@ -312,7 +312,7 @@ LL | let &mut X(_t) = sm;
| | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
| help: consider removing the `&mut`: `X(_t)`
error[E0507]: cannot move out of `rm.0` which is behind a mutable reference
error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
--> $DIR/simple.rs:211:35
|
LL | if let &mut Either::One(_t) = rm { }
@ -322,7 +322,7 @@ LL | if let &mut Either::One(_t) = rm { }
| | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
| help: consider removing the `&mut`: `Either::One(_t)`
error[E0507]: cannot move out of `rm.0` which is behind a mutable reference
error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
--> $DIR/simple.rs:215:38
|
LL | while let &mut Either::One(_t) = rm { }
@ -332,7 +332,7 @@ LL | while let &mut Either::One(_t) = rm { }
| | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
| help: consider removing the `&mut`: `Either::One(_t)`
error[E0507]: cannot move out of `rm.0` which is behind a mutable reference
error[E0507]: cannot move out of `rm` as enum variant `Two` which is behind a mutable reference
--> $DIR/simple.rs:219:11
|
LL | match rm {
@ -354,7 +354,7 @@ help: consider removing the `&mut`
LL | Either::Two(_t) => (),
| ~~~~~~~~~~~~~~~
error[E0507]: cannot move out of `rm.0` which is behind a mutable reference
error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
--> $DIR/simple.rs:228:11
|
LL | match rm {
@ -367,7 +367,7 @@ LL | &mut Either::One(_t) => (),
| | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
| help: consider removing the `&mut`: `Either::One(_t)`
error[E0507]: cannot move out of `rm.0` which is behind a mutable reference
error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
--> $DIR/simple.rs:235:11
|
LL | match rm {
@ -380,7 +380,7 @@ LL | &mut Either::One(_t) => (),
| | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
| help: consider removing the `&mut`: `Either::One(_t)`
error[E0507]: cannot move out of `rm.0` which is behind a mutable reference
error[E0507]: cannot move out of `rm` as enum variant `One` which is behind a mutable reference
--> $DIR/simple.rs:242:11
|
LL | match rm {

View File

@ -4,11 +4,10 @@ warning: function cannot return without recursing
LL | / fn recurse<T>(elements: T) -> Vec<char>
LL | | where
LL | | T: Iterator<Item = ()>,
LL | | {
LL | | recurse(IteratorOfWrapped(elements).map(|t| t.0))
| | ------------------------------------------------- recursive call site
LL | | }
| |_^ cannot return without recursing
| |___________________________^ cannot return without recursing
LL | {
LL | recurse(IteratorOfWrapped(elements).map(|t| t.0))
| ------------------------------------------------- recursive call site
|
= note: `#[warn(unconditional_recursion)]` on by default
= help: a `loop` may express intention better if this is on purpose

View File

@ -14,7 +14,7 @@ note: cycle used when collecting item types in top-level module
--> $DIR/cyclic-trait-resolution.rs:1:1
|
LL | trait A: B + A {}
| ^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View File

@ -2,18 +2,18 @@ error[E0391]: cycle detected when simplifying constant for the type system `Alph
--> $DIR/self-in-enum-definition.rs:5:10
|
LL | V3 = Self::V1 {} as u8 + 2,
| ^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^
|
note: ...which requires simplifying constant for the type system `Alpha::V3::{constant#0}`...
--> $DIR/self-in-enum-definition.rs:5:10
|
LL | V3 = Self::V1 {} as u8 + 2,
| ^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `Alpha::V3::{constant#0}`...
--> $DIR/self-in-enum-definition.rs:5:10
|
LL | V3 = Self::V1 {} as u8 + 2,
| ^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires computing layout of `Alpha`...
= note: ...which again requires simplifying constant for the type system `Alpha::V3::{constant#0}`, completing the cycle
note: cycle used when collecting item types in top-level module

View File

@ -41,9 +41,9 @@ fn python() -> &'static str {
} else if python2 {
PYTHON2
} else {
// We would have returned early if we found that python is installed ...
// maybe this should panic with an error instead?
PYTHON
// Python was not found on path, so exit
eprintln!("Unable to find python in your PATH. Please check it is installed.");
process::exit(1);
}
}