Auto merge of #68305 - Dylan-DPC:rollup-aoohsz8, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #67956 (Detail transitive containment in E0588 diagnostic)
 - #68153 (resolve: Point at the private item definitions in privacy errors)
 - #68195 (Account for common `impl Trait`/`dyn Trait` return type errors)
 - #68288 (Fix some of the rustfmt fallout in Miri)
 - #68292 (don't clone types that are copy)
 - #68301 (Don't propagate __RUST_TEST_INVOKE to subprocess)

Failed merges:

r? @ghost
This commit is contained in:
bors 2020-01-17 09:17:18 +00:00
commit 2480c9eac1
121 changed files with 5522 additions and 3442 deletions

View file

@ -2008,7 +2008,7 @@ impl<'tcx> ObligationCause<'tcx> {
TypeError::IntrinsicCast => {
Error0308("cannot coerce intrinsics to function pointers")
}
TypeError::ObjectUnsafeCoercion(did) => Error0038(did.clone()),
TypeError::ObjectUnsafeCoercion(did) => Error0038(*did),
_ => Error0308("mismatched types"),
},
}

View file

@ -33,7 +33,7 @@ impl ErrorHandled {
ErrorHandled::Reported => {}
ErrorHandled::TooGeneric => bug!(
"MIR interpretation failed without reporting an error \
even though it was fully monomorphized"
even though it was fully monomorphized"
),
}
}

View file

@ -403,8 +403,8 @@ impl<'tcx> AllocMap<'tcx> {
let next = self.next_id;
self.next_id.0 = self.next_id.0.checked_add(1).expect(
"You overflowed a u64 by incrementing by 1... \
You've just earned yourself a free drink if we ever meet. \
Seriously, how did you do that?!",
You've just earned yourself a free drink if we ever meet. \
Seriously, how did you do that?!",
);
next
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,199 @@
use super::{
ObligationCauseCode, OnUnimplementedDirective, OnUnimplementedNote, PredicateObligation,
};
use crate::infer::InferCtxt;
use crate::ty::subst::Subst;
use crate::ty::{self, GenericParamDefKind};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_span::symbol::sym;
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
fn impl_similar_to(
&self,
trait_ref: ty::PolyTraitRef<'tcx>,
obligation: &PredicateObligation<'tcx>,
) -> Option<DefId> {
let tcx = self.tcx;
let param_env = obligation.param_env;
let trait_ref = tcx.erase_late_bound_regions(&trait_ref);
let trait_self_ty = trait_ref.self_ty();
let mut self_match_impls = vec![];
let mut fuzzy_match_impls = vec![];
self.tcx.for_each_relevant_impl(trait_ref.def_id, trait_self_ty, |def_id| {
let impl_substs = self.fresh_substs_for_item(obligation.cause.span, def_id);
let impl_trait_ref = tcx.impl_trait_ref(def_id).unwrap().subst(tcx, impl_substs);
let impl_self_ty = impl_trait_ref.self_ty();
if let Ok(..) = self.can_eq(param_env, trait_self_ty, impl_self_ty) {
self_match_impls.push(def_id);
if trait_ref
.substs
.types()
.skip(1)
.zip(impl_trait_ref.substs.types().skip(1))
.all(|(u, v)| self.fuzzy_match_tys(u, v))
{
fuzzy_match_impls.push(def_id);
}
}
});
let impl_def_id = if self_match_impls.len() == 1 {
self_match_impls[0]
} else if fuzzy_match_impls.len() == 1 {
fuzzy_match_impls[0]
} else {
return None;
};
tcx.has_attr(impl_def_id, sym::rustc_on_unimplemented).then_some(impl_def_id)
}
/// Used to set on_unimplemented's `ItemContext`
/// to be the enclosing (async) block/function/closure
fn describe_enclosure(&self, hir_id: hir::HirId) -> Option<&'static str> {
let hir = &self.tcx.hir();
let node = hir.find(hir_id)?;
if let hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(sig, _, body_id), .. }) = &node {
self.describe_generator(*body_id).or_else(|| {
Some(if let hir::FnHeader { asyncness: hir::IsAsync::Async, .. } = sig.header {
"an async function"
} else {
"a function"
})
})
} else if let hir::Node::Expr(hir::Expr {
kind: hir::ExprKind::Closure(_is_move, _, body_id, _, gen_movability),
..
}) = &node
{
self.describe_generator(*body_id).or_else(|| {
Some(if gen_movability.is_some() { "an async closure" } else { "a closure" })
})
} else if let hir::Node::Expr(hir::Expr { .. }) = &node {
let parent_hid = hir.get_parent_node(hir_id);
if parent_hid != hir_id {
return self.describe_enclosure(parent_hid);
} else {
None
}
} else {
None
}
}
crate fn on_unimplemented_note(
&self,
trait_ref: ty::PolyTraitRef<'tcx>,
obligation: &PredicateObligation<'tcx>,
) -> OnUnimplementedNote {
let def_id =
self.impl_similar_to(trait_ref, obligation).unwrap_or_else(|| trait_ref.def_id());
let trait_ref = *trait_ref.skip_binder();
let mut flags = vec![];
flags.push((
sym::item_context,
self.describe_enclosure(obligation.cause.body_id).map(|s| s.to_owned()),
));
match obligation.cause.code {
ObligationCauseCode::BuiltinDerivedObligation(..)
| ObligationCauseCode::ImplDerivedObligation(..) => {}
_ => {
// this is a "direct", user-specified, rather than derived,
// obligation.
flags.push((sym::direct, None));
}
}
if let ObligationCauseCode::ItemObligation(item) = obligation.cause.code {
// FIXME: maybe also have some way of handling methods
// from other traits? That would require name resolution,
// which we might want to be some sort of hygienic.
//
// Currently I'm leaving it for what I need for `try`.
if self.tcx.trait_of_item(item) == Some(trait_ref.def_id) {
let method = self.tcx.item_name(item);
flags.push((sym::from_method, None));
flags.push((sym::from_method, Some(method.to_string())));
}
}
if let Some((t, _)) = self.get_parent_trait_ref(&obligation.cause.code) {
flags.push((sym::parent_trait, Some(t)));
}
if let Some(k) = obligation.cause.span.desugaring_kind() {
flags.push((sym::from_desugaring, None));
flags.push((sym::from_desugaring, Some(format!("{:?}", k))));
}
let generics = self.tcx.generics_of(def_id);
let self_ty = trait_ref.self_ty();
// This is also included through the generics list as `Self`,
// but the parser won't allow you to use it
flags.push((sym::_Self, Some(self_ty.to_string())));
if let Some(def) = self_ty.ty_adt_def() {
// We also want to be able to select self's original
// signature with no type arguments resolved
flags.push((sym::_Self, Some(self.tcx.type_of(def.did).to_string())));
}
for param in generics.params.iter() {
let value = match param.kind {
GenericParamDefKind::Type { .. } | GenericParamDefKind::Const => {
trait_ref.substs[param.index as usize].to_string()
}
GenericParamDefKind::Lifetime => continue,
};
let name = param.name;
flags.push((name, Some(value)));
}
if let Some(true) = self_ty.ty_adt_def().map(|def| def.did.is_local()) {
flags.push((sym::crate_local, None));
}
// Allow targeting all integers using `{integral}`, even if the exact type was resolved
if self_ty.is_integral() {
flags.push((sym::_Self, Some("{integral}".to_owned())));
}
if let ty::Array(aty, len) = self_ty.kind {
flags.push((sym::_Self, Some("[]".to_owned())));
flags.push((sym::_Self, Some(format!("[{}]", aty))));
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
flags.push((
sym::_Self,
Some(format!("[{}]", self.tcx.type_of(def.did).to_string())),
));
let tcx = self.tcx;
if let Some(len) = len.try_eval_usize(tcx, ty::ParamEnv::empty()) {
flags.push((
sym::_Self,
Some(format!("[{}; {}]", self.tcx.type_of(def.did).to_string(), len)),
));
} else {
flags.push((
sym::_Self,
Some(format!("[{}; _]", self.tcx.type_of(def.did).to_string())),
));
}
}
}
if let Ok(Some(command)) =
OnUnimplementedDirective::of_item(self.tcx, trait_ref.def_id, def_id)
{
command.evaluate(self.tcx, trait_ref, &flags[..])
} else {
OnUnimplementedNote::default()
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -155,8 +155,8 @@ pub struct ObligationCause<'tcx> {
pub code: ObligationCauseCode<'tcx>,
}
impl<'tcx> ObligationCause<'tcx> {
pub fn span(&self, tcx: TyCtxt<'tcx>) -> Span {
impl ObligationCause<'_> {
pub fn span(&self, tcx: TyCtxt<'_>) -> Span {
match self.code {
ObligationCauseCode::CompareImplMethodObligation { .. }
| ObligationCauseCode::MainFunctionType
@ -1171,6 +1171,17 @@ impl<'tcx> ObligationCause<'tcx> {
}
}
impl ObligationCauseCode<'_> {
// Return the base obligation, ignoring derived obligations.
pub fn peel_derives(&self) -> &Self {
let mut base_cause = self;
while let BuiltinDerivedObligation(cause) | ImplDerivedObligation(cause) = base_cause {
base_cause = &cause.parent_code;
}
base_cause
}
}
impl<'tcx, N> Vtable<'tcx, N> {
pub fn nested_obligations(self) -> Vec<N> {
match self {

View file

@ -244,9 +244,9 @@ impl<'tcx> ty::TyS<'tcx> {
ty::FnPtr(_) => "fn pointer".into(),
ty::Dynamic(ref inner, ..) => {
if let Some(principal) = inner.principal() {
format!("trait `{}`", tcx.def_path_str(principal.def_id())).into()
format!("trait object `dyn {}`", tcx.def_path_str(principal.def_id())).into()
} else {
"trait".into()
"trait object".into()
}
}
ty::Closure(..) => "closure".into(),

View file

@ -909,18 +909,18 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn lower_expr_asm(&mut self, asm: &InlineAsm) -> hir::ExprKind<'hir> {
let inner = hir::InlineAsmInner {
inputs: asm.inputs.iter().map(|&(ref c, _)| c.clone()).collect(),
inputs: asm.inputs.iter().map(|&(c, _)| c).collect(),
outputs: asm
.outputs
.iter()
.map(|out| hir::InlineAsmOutput {
constraint: out.constraint.clone(),
constraint: out.constraint,
is_rw: out.is_rw,
is_indirect: out.is_indirect,
span: out.expr.span,
})
.collect(),
asm: asm.asm.clone(),
asm: asm.asm,
asm_str_style: asm.asm_str_style,
clobbers: asm.clobbers.clone().into(),
volatile: asm.volatile,

View file

@ -1608,7 +1608,7 @@ impl<'a> TraitDef<'a> {
} else {
ast::BindingMode::ByRef(mutbl)
};
cx.pat(path.span, PatKind::Ident(binding_mode, (*path).clone(), None))
cx.pat(path.span, PatKind::Ident(binding_mode, *path, None))
})
.collect()
}

View file

@ -414,6 +414,7 @@ E0742: include_str!("./error_codes/E0742.md"),
E0743: include_str!("./error_codes/E0743.md"),
E0744: include_str!("./error_codes/E0744.md"),
E0745: include_str!("./error_codes/E0745.md"),
E0746: include_str!("./error_codes/E0746.md"),
;
// E0006, // merged with E0005
// E0008, // cannot bind by-move into a pattern guard

View file

@ -0,0 +1,138 @@
Return types cannot be `dyn Trait`s as they must be `Sized`.
Erroneous code example:
```compile_fail,E0277
# // FIXME: after E0746 is in beta, change the above
trait T {
fn bar(&self);
}
struct S(usize);
impl T for S {
fn bar(&self) {}
}
// Having the trait `T` as return type is invalid because
// unboxed trait objects do not have a statically known size:
fn foo() -> dyn T {
S(42)
}
```
To avoid the error there are a couple of options.
If there is a single type involved, you can use [`impl Trait`]:
```
# trait T {
# fn bar(&self);
# }
# struct S(usize);
# impl T for S {
# fn bar(&self) {}
# }
// The compiler will select `S(usize)` as the materialized return type of this
// function, but callers will only know that the return type implements `T`.
fn foo() -> impl T {
S(42)
}
```
If there are multiple types involved, the only way you care to interact with
them is through the trait's interface, and having to rely on dynamic dispatch
is acceptable, then you can use [trait objects] with `Box`, or other container
types like `Rc` or `Arc`:
```
# trait T {
# fn bar(&self);
# }
# struct S(usize);
# impl T for S {
# fn bar(&self) {}
# }
struct O(&'static str);
impl T for O {
fn bar(&self) {}
}
// This now returns a "trait object" and callers are only be able to access
// associated items from `T`.
fn foo(x: bool) -> Box<dyn T> {
if x {
Box::new(S(42))
} else {
Box::new(O("val"))
}
}
```
Finally, if you wish to still be able to access the original type, you can
create a new `enum` with a variant for each type:
```
# trait T {
# fn bar(&self);
# }
# struct S(usize);
# impl T for S {
# fn bar(&self) {}
# }
# struct O(&'static str);
# impl T for O {
# fn bar(&self) {}
# }
enum E {
S(S),
O(O),
}
// The caller can access the original types directly, but it needs to match on
// the returned `enum E`.
fn foo(x: bool) -> E {
if x {
E::S(S(42))
} else {
E::O(O("val"))
}
}
```
You can even implement the `trait` on the returned `enum` so the callers
*don't* have to match on the returned value to invoke the associated items:
```
# trait T {
# fn bar(&self);
# }
# struct S(usize);
# impl T for S {
# fn bar(&self) {}
# }
# struct O(&'static str);
# impl T for O {
# fn bar(&self) {}
# }
# enum E {
# S(S),
# O(O),
# }
impl T for E {
fn bar(&self) {
match self {
E::S(s) => s.bar(),
E::O(o) => o.bar(),
}
}
}
```
If you decide to use trait objects, be aware that these rely on
[dynamic dispatch], which has performance implications, as the compiler needs
to emit code that will figure out which method to call *at runtime* instead of
during compilation. Using trait objects we are trading flexibility for
performance.
[`impl Trait`]: https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits
[trait objects]: https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types
[dynamic dispatch]: https://doc.rust-lang.org/book/ch17-02-trait-objects.html#trait-objects-perform-dynamic-dispatch

View file

@ -196,7 +196,7 @@ impl AnnotateSnippetEmitterWriter {
) {
let converter = DiagnosticConverter {
source_map: self.source_map.clone(),
level: level.clone(),
level: *level,
message,
code: code.clone(),
msp: msp.clone(),

View file

@ -377,6 +377,13 @@ pub enum GenericBound<'hir> {
}
impl GenericBound<'_> {
pub fn trait_def_id(&self) -> Option<DefId> {
match self {
GenericBound::Trait(data, _) => Some(data.trait_ref.trait_def_id()),
_ => None,
}
}
pub fn span(&self) -> Span {
match self {
&GenericBound::Trait(ref t, ..) => t.span,

View file

@ -236,7 +236,7 @@ fn encode_work_product_index(
let serialized_products: Vec<_> = work_products
.iter()
.map(|(id, work_product)| SerializedWorkProduct {
id: id.clone(),
id: *id,
work_product: work_product.clone(),
})
.collect();

View file

@ -245,7 +245,7 @@ impl LintStore {
pub fn register_renamed(&mut self, old_name: &str, new_name: &str) {
let target = match self.by_name.get(new_name) {
Some(&Id(lint_id)) => lint_id.clone(),
Some(&Id(lint_id)) => lint_id,
_ => bug!("invalid lint renaming of {} to {}", old_name, new_name),
};
self.by_name.insert(old_name.to_string(), Renamed(new_name.to_string(), target));

View file

@ -840,7 +840,7 @@ impl<'a, 'tcx> CrateMetadata {
fn get_stability(&self, id: DefIndex) -> Option<attr::Stability> {
match self.is_proc_macro(id) {
true => self.root.proc_macro_stability.clone(),
true => self.root.proc_macro_stability,
false => self.root.per_def.stability.get(self, id).map(|stab| stab.decode(self)),
}
}

View file

@ -504,7 +504,7 @@ impl<'tcx> EncodeContext<'tcx> {
},
proc_macro_data,
proc_macro_stability: if is_proc_macro {
tcx.lookup_stability(DefId::local(CRATE_DEF_INDEX)).map(|stab| stab.clone())
tcx.lookup_stability(DefId::local(CRATE_DEF_INDEX)).map(|stab| *stab)
} else {
None
},

View file

@ -200,8 +200,8 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'tcx> {
region,
reserve_location: location,
activation_location: TwoPhaseActivation::NotTwoPhase,
borrowed_place: borrowed_place.clone(),
assigned_place: assigned_place.clone(),
borrowed_place: *borrowed_place,
assigned_place: *assigned_place,
};
let idx = self.idx_vec.push(borrow);
self.location_map.insert(location, idx);

View file

@ -580,10 +580,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
let layout = self.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap();
Ok((layout.size, layout.align.abi))
}
Some(GlobalAlloc::Memory(alloc)) =>
// Need to duplicate the logic here, because the global allocations have
// different associated types than the interpreter-local ones.
{
Some(GlobalAlloc::Memory(alloc)) => {
// Need to duplicate the logic here, because the global allocations have
// different associated types than the interpreter-local ones.
Ok((alloc.size, alloc.align))
}
Some(GlobalAlloc::Function(_)) => bug!("We already checked function pointers above"),

View file

@ -684,16 +684,14 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let variant_index = variants_start
.checked_add(variant_index_relative)
.expect("oveflow computing absolute variant idx");
assert!(
(variant_index as usize)
< rval
.layout
.ty
.ty_adt_def()
.expect("tagged layout for non adt")
.variants
.len()
);
let variants_len = rval
.layout
.ty
.ty_adt_def()
.expect("tagged layout for non adt")
.variants
.len();
assert!((variant_index as usize) < variants_len);
(u128::from(variant_index), VariantIdx::from_u32(variant_index))
} else {
(u128::from(dataful_variant.as_u32()), dataful_variant)

View file

@ -432,12 +432,11 @@ where
// happens at run-time so that's okay.
let align = match self.size_and_align_of(base.meta, field_layout)? {
Some((_, align)) => align,
None if offset == Size::ZERO =>
// An extern type at offset 0, we fall back to its static alignment.
// FIXME: Once we have made decisions for how to handle size and alignment
// of `extern type`, this should be adapted. It is just a temporary hack
// to get some code to work that probably ought to work.
{
None if offset == Size::ZERO => {
// An extern type at offset 0, we fall back to its static alignment.
// FIXME: Once we have made decisions for how to handle size and alignment
// of `extern type`, this should be adapted. It is just a temporary hack
// to get some code to work that probably ought to work.
field_layout.align.abi
}
None => bug!("Cannot compute offset for extern type field at non-0 offset"),

View file

@ -114,14 +114,11 @@ fn write_path(out: &mut String, path: &Vec<PathElem>) {
ClosureVar(name) => write!(out, ".<closure-var({})>", name),
TupleElem(idx) => write!(out, ".{}", idx),
ArrayElem(idx) => write!(out, "[{}]", idx),
Deref =>
// This does not match Rust syntax, but it is more readable for long paths -- and
// `.<deref>` does not match Rust syntax, but it is more readable for long paths -- and
// some of the other items here also are not Rust syntax. Actually we can't
// even use the usual syntax because we are just showing the projections,
// not the root.
{
write!(out, ".<deref>")
}
Deref => write!(out, ".<deref>"),
Tag => write!(out, ".<enum-tag>"),
DynDowncast => write!(out, ".<dyn-downcast>"),
}
@ -206,9 +203,8 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M
ty::Adt(def, ..) if def.is_enum() => {
// we might be projecting *to* a variant, or to a field *in*a variant.
match layout.variants {
layout::Variants::Single { index } =>
// Inside a variant
{
layout::Variants::Single { index } => {
// Inside a variant
PathElem::Field(def.variants[index].fields[field].ident.name)
}
_ => bug!(),

View file

@ -65,7 +65,7 @@ fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> BodyAndCache<'_> {
} else if cx.body_owner_kind.is_fn_or_closure() {
// fetch the fully liberated fn signature (that is, all bound
// types/lifetimes replaced)
let fn_sig = cx.tables().liberated_fn_sigs()[id].clone();
let fn_sig = cx.tables().liberated_fn_sigs()[id];
let fn_def_id = tcx.hir().local_def_id(id);
let ty = tcx.type_of(fn_def_id);

View file

@ -91,7 +91,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
// deprecated_since and its reason.
if let Some(parent_stab) = self.parent_stab {
if parent_stab.rustc_depr.is_some() && stab.rustc_depr.is_none() {
stab.rustc_depr = parent_stab.rustc_depr.clone()
stab.rustc_depr = parent_stab.rustc_depr
}
}

View file

@ -8,7 +8,7 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
use rustc_feature::BUILTIN_ATTRIBUTES;
use rustc_hir::def::Namespace::{self, *};
use rustc_hir::def::{self, DefKind, NonMacroAttrKind};
use rustc_hir::def::{self, CtorKind, CtorOf, DefKind, NonMacroAttrKind};
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
use rustc_span::hygiene::MacroKind;
use rustc_span::source_map::SourceMap;
@ -20,8 +20,9 @@ use syntax::util::lev_distance::find_best_match_for_name;
use crate::imports::{ImportDirective, ImportDirectiveSubclass, ImportResolver};
use crate::path_names_to_string;
use crate::VisResolutionError;
use crate::{AmbiguityError, AmbiguityErrorMisc, AmbiguityKind};
use crate::{BindingError, CrateLint, HasGenericParams, LegacyScope, Module, ModuleOrUniformRoot};
use crate::{NameBinding, NameBindingKind, PrivacyError, VisResolutionError};
use crate::{ParentScope, PathResult, ResolutionError, Resolver, Scope, ScopeSet, Segment};
use rustc_error_codes::*;
@ -802,6 +803,163 @@ impl<'a> Resolver<'a> {
}
false
}
fn binding_description(&self, b: &NameBinding<'_>, ident: Ident, from_prelude: bool) -> String {
let res = b.res();
if b.span.is_dummy() {
let add_built_in = match b.res() {
// These already contain the "built-in" prefix or look bad with it.
Res::NonMacroAttr(..) | Res::PrimTy(..) | Res::ToolMod => false,
_ => true,
};
let (built_in, from) = if from_prelude {
("", " from prelude")
} else if b.is_extern_crate()
&& !b.is_import()
&& self.session.opts.externs.get(&ident.as_str()).is_some()
{
("", " passed with `--extern`")
} else if add_built_in {
(" built-in", "")
} else {
("", "")
};
let article = if built_in.is_empty() { res.article() } else { "a" };
format!(
"{a}{built_in} {thing}{from}",
a = article,
thing = res.descr(),
built_in = built_in,
from = from
)
} else {
let introduced = if b.is_import() { "imported" } else { "defined" };
format!("the {thing} {introduced} here", thing = res.descr(), introduced = introduced)
}
}
crate fn report_ambiguity_error(&self, ambiguity_error: &AmbiguityError<'_>) {
let AmbiguityError { kind, ident, b1, b2, misc1, misc2 } = *ambiguity_error;
let (b1, b2, misc1, misc2, swapped) = if b2.span.is_dummy() && !b1.span.is_dummy() {
// We have to print the span-less alternative first, otherwise formatting looks bad.
(b2, b1, misc2, misc1, true)
} else {
(b1, b2, misc1, misc2, false)
};
let mut err = struct_span_err!(
self.session,
ident.span,
E0659,
"`{ident}` is ambiguous ({why})",
ident = ident,
why = kind.descr()
);
err.span_label(ident.span, "ambiguous name");
let mut could_refer_to = |b: &NameBinding<'_>, misc: AmbiguityErrorMisc, also: &str| {
let what = self.binding_description(b, ident, misc == AmbiguityErrorMisc::FromPrelude);
let note_msg = format!(
"`{ident}` could{also} refer to {what}",
ident = ident,
also = also,
what = what
);
let thing = b.res().descr();
let mut help_msgs = Vec::new();
if b.is_glob_import()
&& (kind == AmbiguityKind::GlobVsGlob
|| kind == AmbiguityKind::GlobVsExpanded
|| kind == AmbiguityKind::GlobVsOuter && swapped != also.is_empty())
{
help_msgs.push(format!(
"consider adding an explicit import of \
`{ident}` to disambiguate",
ident = ident
))
}
if b.is_extern_crate() && ident.span.rust_2018() {
help_msgs.push(format!(
"use `::{ident}` to refer to this {thing} unambiguously",
ident = ident,
thing = thing,
))
}
if misc == AmbiguityErrorMisc::SuggestCrate {
help_msgs.push(format!(
"use `crate::{ident}` to refer to this {thing} unambiguously",
ident = ident,
thing = thing,
))
} else if misc == AmbiguityErrorMisc::SuggestSelf {
help_msgs.push(format!(
"use `self::{ident}` to refer to this {thing} unambiguously",
ident = ident,
thing = thing,
))
}
err.span_note(b.span, &note_msg);
for (i, help_msg) in help_msgs.iter().enumerate() {
let or = if i == 0 { "" } else { "or " };
err.help(&format!("{}{}", or, help_msg));
}
};
could_refer_to(b1, misc1, "");
could_refer_to(b2, misc2, " also");
err.emit();
}
crate fn report_privacy_error(&self, privacy_error: &PrivacyError<'_>) {
let PrivacyError { ident, binding, .. } = *privacy_error;
let session = &self.session;
let mk_struct_span_error = |is_constructor| {
let mut descr = binding.res().descr().to_string();
if is_constructor {
descr += " constructor";
}
if binding.is_import() {
descr += " import";
}
let mut err =
struct_span_err!(session, ident.span, E0603, "{} `{}` is private", descr, ident);
err.span_label(ident.span, &format!("this {} is private", descr));
err.span_note(
session.source_map().def_span(binding.span),
&format!("the {} `{}` is defined here", descr, ident),
);
err
};
let mut err = if let NameBindingKind::Res(
Res::Def(DefKind::Ctor(CtorOf::Struct, CtorKind::Fn), ctor_def_id),
_,
) = binding.kind
{
let def_id = (&*self).parent(ctor_def_id).expect("no parent for a constructor");
if let Some(fields) = self.field_names.get(&def_id) {
let mut err = mk_struct_span_error(true);
let first_field = fields.first().expect("empty field list in the map");
err.span_label(
fields.iter().fold(first_field.span, |acc, field| acc.to(field.span)),
"a constructor is private if any of the fields is private",
);
err
} else {
mk_struct_span_error(false)
}
} else {
mk_struct_span_error(false)
};
err.emit();
}
}
impl<'a, 'b> ImportResolver<'a, 'b> {

View file

@ -319,7 +319,11 @@ impl<'a> Resolver<'a> {
// Remove this together with `PUB_USE_OF_PRIVATE_EXTERN_CRATE`
!(self.last_import_segment && binding.is_extern_crate())
{
self.privacy_errors.push(PrivacyError(path_span, ident, binding));
self.privacy_errors.push(PrivacyError {
ident,
binding,
dedup_span: path_span,
});
}
Ok(binding)

View file

@ -2,12 +2,9 @@
//!
//! Module structure of the crate is built here.
//! Paths in macros, imports, expressions, types, patterns are resolved here.
//! Label names are resolved here as well.
//! Label and lifetime names are resolved here as well.
//!
//! Type-relative name resolution (methods, fields, associated items) happens in `librustc_typeck`.
//! Lifetime names are resolved in `librustc/middle/resolve_lifetime.rs`.
// ignore-tidy-filelength
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(bool_to_option)]
@ -33,7 +30,7 @@ use rustc_data_structures::sync::Lrc;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
use rustc_expand::base::SyntaxExtension;
use rustc_hir::def::Namespace::*;
use rustc_hir::def::{self, CtorKind, CtorOf, DefKind, NonMacroAttrKind, PartialRes};
use rustc_hir::def::{self, CtorOf, DefKind, NonMacroAttrKind, PartialRes};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, CRATE_DEF_INDEX, LOCAL_CRATE};
use rustc_hir::PrimTy::{self, Bool, Char, Float, Int, Str, Uint};
use rustc_hir::{GlobMap, TraitMap};
@ -604,7 +601,11 @@ impl<'a> NameBindingKind<'a> {
}
}
struct PrivacyError<'a>(Span, Ident, &'a NameBinding<'a>);
struct PrivacyError<'a> {
ident: Ident,
binding: &'a NameBinding<'a>,
dedup_span: Span,
}
struct UseError<'a> {
err: DiagnosticBuilder<'a>,
@ -2446,115 +2447,6 @@ impl<'a> Resolver<'a> {
}
}
fn binding_description(&self, b: &NameBinding<'_>, ident: Ident, from_prelude: bool) -> String {
let res = b.res();
if b.span.is_dummy() {
let add_built_in = match b.res() {
// These already contain the "built-in" prefix or look bad with it.
Res::NonMacroAttr(..) | Res::PrimTy(..) | Res::ToolMod => false,
_ => true,
};
let (built_in, from) = if from_prelude {
("", " from prelude")
} else if b.is_extern_crate()
&& !b.is_import()
&& self.session.opts.externs.get(&ident.as_str()).is_some()
{
("", " passed with `--extern`")
} else if add_built_in {
(" built-in", "")
} else {
("", "")
};
let article = if built_in.is_empty() { res.article() } else { "a" };
format!(
"{a}{built_in} {thing}{from}",
a = article,
thing = res.descr(),
built_in = built_in,
from = from
)
} else {
let introduced = if b.is_import() { "imported" } else { "defined" };
format!("the {thing} {introduced} here", thing = res.descr(), introduced = introduced)
}
}
fn report_ambiguity_error(&self, ambiguity_error: &AmbiguityError<'_>) {
let AmbiguityError { kind, ident, b1, b2, misc1, misc2 } = *ambiguity_error;
let (b1, b2, misc1, misc2, swapped) = if b2.span.is_dummy() && !b1.span.is_dummy() {
// We have to print the span-less alternative first, otherwise formatting looks bad.
(b2, b1, misc2, misc1, true)
} else {
(b1, b2, misc1, misc2, false)
};
let mut err = struct_span_err!(
self.session,
ident.span,
E0659,
"`{ident}` is ambiguous ({why})",
ident = ident,
why = kind.descr()
);
err.span_label(ident.span, "ambiguous name");
let mut could_refer_to = |b: &NameBinding<'_>, misc: AmbiguityErrorMisc, also: &str| {
let what = self.binding_description(b, ident, misc == AmbiguityErrorMisc::FromPrelude);
let note_msg = format!(
"`{ident}` could{also} refer to {what}",
ident = ident,
also = also,
what = what
);
let thing = b.res().descr();
let mut help_msgs = Vec::new();
if b.is_glob_import()
&& (kind == AmbiguityKind::GlobVsGlob
|| kind == AmbiguityKind::GlobVsExpanded
|| kind == AmbiguityKind::GlobVsOuter && swapped != also.is_empty())
{
help_msgs.push(format!(
"consider adding an explicit import of \
`{ident}` to disambiguate",
ident = ident
))
}
if b.is_extern_crate() && ident.span.rust_2018() {
help_msgs.push(format!(
"use `::{ident}` to refer to this {thing} unambiguously",
ident = ident,
thing = thing,
))
}
if misc == AmbiguityErrorMisc::SuggestCrate {
help_msgs.push(format!(
"use `crate::{ident}` to refer to this {thing} unambiguously",
ident = ident,
thing = thing,
))
} else if misc == AmbiguityErrorMisc::SuggestSelf {
help_msgs.push(format!(
"use `self::{ident}` to refer to this {thing} unambiguously",
ident = ident,
thing = thing,
))
}
err.span_note(b.span, &note_msg);
for (i, help_msg) in help_msgs.iter().enumerate() {
let or = if i == 0 { "" } else { "or " };
err.help(&format!("{}{}", or, help_msg));
}
};
could_refer_to(b1, misc1, "");
could_refer_to(b2, misc2, " also");
err.emit();
}
fn report_errors(&mut self, krate: &Crate) {
self.report_with_use_injections(krate);
@ -2575,43 +2467,9 @@ impl<'a> Resolver<'a> {
}
let mut reported_spans = FxHashSet::default();
for &PrivacyError(dedup_span, ident, binding) in &self.privacy_errors {
if reported_spans.insert(dedup_span) {
let session = &self.session;
let mk_struct_span_error = |is_constructor| {
struct_span_err!(
session,
ident.span,
E0603,
"{}{} `{}` is private",
binding.res().descr(),
if is_constructor { " constructor" } else { "" },
ident.name,
)
};
let mut err = if let NameBindingKind::Res(
Res::Def(DefKind::Ctor(CtorOf::Struct, CtorKind::Fn), ctor_def_id),
_,
) = binding.kind
{
let def_id = (&*self).parent(ctor_def_id).expect("no parent for a constructor");
if let Some(fields) = self.field_names.get(&def_id) {
let mut err = mk_struct_span_error(true);
let first_field = fields.first().expect("empty field list in the map");
err.span_label(
fields.iter().fold(first_field.span, |acc, field| acc.to(field.span)),
"a constructor is private if any of the fields is private",
);
err
} else {
mk_struct_span_error(false)
}
} else {
mk_struct_span_error(false)
};
err.emit();
for error in &self.privacy_errors {
if reported_spans.insert(error.dedup_span) {
self.report_privacy_error(error);
}
}
}

View file

@ -400,7 +400,7 @@ impl context::UnificationOps<ChalkArenas<'tcx>, ChalkArenas<'tcx>>
&mut self,
value: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>,
) -> (Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>, UniverseMap) {
(value.clone(), UniverseMap)
(*value, UniverseMap)
}
fn invert_goal(

View file

@ -175,7 +175,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
ty::Infer(ty::TyVar(vid)) => self.deduce_expectations_from_obligations(vid),
ty::FnPtr(sig) => {
let expected_sig = ExpectedSig { cause_span: None, sig: sig.skip_binder().clone() };
let expected_sig = ExpectedSig { cause_span: None, sig: *sig.skip_binder() };
(Some(expected_sig), Some(ty::ClosureKind::Fn))
}
_ => (None, None),

View file

@ -50,10 +50,12 @@
//! sort of a minor point so I've opted to leave it for later -- after all,
//! we may want to adjust precisely when coercions occur.
use crate::astconv::AstConv;
use crate::check::{FnCtxt, Needs};
use rustc::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc::infer::{Coercion, InferOk, InferResult};
use rustc::session::parse::feature_err;
use rustc::traits::object_safety_violations;
use rustc::traits::{self, ObligationCause, ObligationCauseCode};
use rustc::ty::adjustment::{
Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, PointerCast,
@ -67,8 +69,8 @@ use rustc_error_codes::*;
use rustc_errors::{struct_span_err, DiagnosticBuilder};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_span;
use rustc_span::symbol::sym;
use rustc_span::{self, Span};
use rustc_target::spec::abi::Abi;
use smallvec::{smallvec, SmallVec};
use std::ops::Deref;
@ -1222,6 +1224,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
};
let mut err;
let mut unsized_return = false;
match cause.code {
ObligationCauseCode::ReturnNoExpression => {
err = struct_span_err!(
@ -1243,6 +1246,9 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
parent_id,
expression.map(|expr| (expr, blk_id)),
);
if !fcx.tcx.features().unsized_locals {
unsized_return = self.is_return_ty_unsized(fcx, blk_id);
}
}
ObligationCauseCode::ReturnValue(id) => {
err = self.report_return_mismatched_types(
@ -1254,6 +1260,10 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
id,
None,
);
if !fcx.tcx.features().unsized_locals {
let id = fcx.tcx.hir().get_parent_node(id);
unsized_return = self.is_return_ty_unsized(fcx, id);
}
}
_ => {
err = fcx.report_mismatched_types(cause, expected, found, coercion_error);
@ -1282,7 +1292,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
.filter(|e| fcx.is_assign_to_bool(e, self.expected_ty()))
.is_some();
err.emit_unless(assign_to_bool);
err.emit_unless(assign_to_bool || unsized_return);
self.final_ty = Some(fcx.tcx.types.err);
}
@ -1302,7 +1312,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
let mut err = fcx.report_mismatched_types(cause, expected, found, ty_err);
let mut pointing_at_return_type = false;
let mut return_sp = None;
let mut fn_output = None;
// Verify that this is a tail expression of a function, otherwise the
// label pointing out the cause for the type coercion will be wrong
@ -1339,19 +1349,98 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
);
}
if !pointing_at_return_type {
return_sp = Some(fn_decl.output.span()); // `impl Trait` return type
fn_output = Some(&fn_decl.output); // `impl Trait` return type
}
}
if let (Some(sp), Some(return_sp)) = (fcx.ret_coercion_span.borrow().as_ref(), return_sp) {
err.span_label(return_sp, "expected because this return type...");
err.span_label( *sp, format!(
"...is found to be `{}` here",
fcx.resolve_vars_with_obligations(expected),
));
if let (Some(sp), Some(fn_output)) = (fcx.ret_coercion_span.borrow().as_ref(), fn_output) {
self.add_impl_trait_explanation(&mut err, fcx, expected, *sp, fn_output);
}
err
}
fn add_impl_trait_explanation<'a>(
&self,
err: &mut DiagnosticBuilder<'a>,
fcx: &FnCtxt<'a, 'tcx>,
expected: Ty<'tcx>,
sp: Span,
fn_output: &hir::FunctionRetTy<'_>,
) {
let return_sp = fn_output.span();
err.span_label(return_sp, "expected because this return type...");
err.span_label(
sp,
format!("...is found to be `{}` here", fcx.resolve_vars_with_obligations(expected)),
);
let impl_trait_msg = "for information on `impl Trait`, see \
<https://doc.rust-lang.org/book/ch10-02-traits.html\
#returning-types-that-implement-traits>";
let trait_obj_msg = "for information on trait objects, see \
<https://doc.rust-lang.org/book/ch17-02-trait-objects.html\
#using-trait-objects-that-allow-for-values-of-different-types>";
err.note("to return `impl Trait`, all returned values must be of the same type");
err.note(impl_trait_msg);
let snippet = fcx
.tcx
.sess
.source_map()
.span_to_snippet(return_sp)
.unwrap_or_else(|_| "dyn Trait".to_string());
let mut snippet_iter = snippet.split_whitespace();
let has_impl = snippet_iter.next().map_or(false, |s| s == "impl");
// Only suggest `Box<dyn Trait>` if `Trait` in `impl Trait` is object safe.
let mut is_object_safe = false;
if let hir::FunctionRetTy::Return(ty) = fn_output {
// Get the return type.
if let hir::TyKind::Def(..) = ty.kind {
let ty = AstConv::ast_ty_to_ty(fcx, ty);
// Get the `impl Trait`'s `DefId`.
if let ty::Opaque(def_id, _) = ty.kind {
let hir_id = fcx.tcx.hir().as_local_hir_id(def_id).unwrap();
// Get the `impl Trait`'s `Item` so that we can get its trait bounds and
// get the `Trait`'s `DefId`.
if let hir::ItemKind::OpaqueTy(hir::OpaqueTy { bounds, .. }) =
fcx.tcx.hir().expect_item(hir_id).kind
{
// Are of this `impl Trait`'s traits object safe?
is_object_safe = bounds.iter().all(|bound| {
bound.trait_def_id().map_or(false, |def_id| {
object_safety_violations(fcx.tcx, def_id).is_empty()
})
})
}
}
}
};
if has_impl {
if is_object_safe {
err.help(&format!(
"you can instead return a boxed trait object using `Box<dyn {}>`",
&snippet[5..]
));
} else {
err.help(&format!(
"if the trait `{}` were object safe, you could return a boxed trait object",
&snippet[5..]
));
}
err.note(trait_obj_msg);
}
err.help("alternatively, create a new `enum` with a variant for each returned type");
}
fn is_return_ty_unsized(&self, fcx: &FnCtxt<'a, 'tcx>, blk_id: hir::HirId) -> bool {
if let Some((fn_decl, _)) = fcx.get_fn_decl(blk_id) {
if let hir::FunctionRetTy::Return(ty) = fn_decl.output {
let ty = AstConv::ast_ty_to_ty(fcx, ty);
if let ty::Dynamic(..) = ty.kind {
return true;
}
}
}
false
}
pub fn complete<'a>(self, fcx: &FnCtxt<'a, 'tcx>) -> Ty<'tcx> {
if let Some(final_ty) = self.final_ty {
final_ty

View file

@ -122,7 +122,7 @@ use rustc_hir::def::{CtorOf, DefKind, Res};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LOCAL_CRATE};
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::itemlikevisit::ItemLikeVisitor;
use rustc_hir::{ExprKind, GenericArg, HirIdMap, ItemKind, Node, PatKind, QPath};
use rustc_hir::{ExprKind, GenericArg, HirIdMap, Item, ItemKind, Node, PatKind, QPath};
use rustc_index::vec::Idx;
use rustc_span::hygiene::DesugaringKind;
use rustc_span::source_map::{original_sp, DUMMY_SP};
@ -2312,44 +2312,81 @@ fn check_packed(tcx: TyCtxt<'_>, sp: Span, def_id: DefId) {
"type has conflicting packed and align representation hints"
)
.emit();
} else if check_packed_inner(tcx, def_id, &mut Vec::new()) {
struct_span_err!(
tcx.sess,
sp,
E0588,
"packed type cannot transitively contain a `[repr(align)]` type"
)
.emit();
} else {
if let Some(def_spans) = check_packed_inner(tcx, def_id, &mut vec![]) {
let mut err = struct_span_err!(
tcx.sess,
sp,
E0588,
"packed type cannot transitively contain a `#[repr(align)]` type"
);
let hir = tcx.hir();
if let Some(hir_id) = hir.as_local_hir_id(def_spans[0].0) {
if let Node::Item(Item { ident, .. }) = hir.get(hir_id) {
err.span_note(
tcx.def_span(def_spans[0].0),
&format!("`{}` has a `#[repr(align)]` attribute", ident),
);
}
}
if def_spans.len() > 2 {
let mut first = true;
for (adt_def, span) in def_spans.iter().skip(1).rev() {
if let Some(hir_id) = hir.as_local_hir_id(*adt_def) {
if let Node::Item(Item { ident, .. }) = hir.get(hir_id) {
err.span_note(
*span,
&if first {
format!(
"`{}` contains a field of type `{}`",
tcx.type_of(def_id),
ident
)
} else {
format!("...which contains a field of type `{}`", ident)
},
);
first = false;
}
}
}
}
err.emit();
}
}
}
}
fn check_packed_inner(tcx: TyCtxt<'_>, def_id: DefId, stack: &mut Vec<DefId>) -> bool {
let t = tcx.type_of(def_id);
if stack.contains(&def_id) {
debug!("check_packed_inner: {:?} is recursive", t);
return false;
}
if let ty::Adt(def, substs) = t.kind {
fn check_packed_inner(
tcx: TyCtxt<'_>,
def_id: DefId,
stack: &mut Vec<DefId>,
) -> Option<Vec<(DefId, Span)>> {
if let ty::Adt(def, substs) = tcx.type_of(def_id).kind {
if def.is_struct() || def.is_union() {
if tcx.adt_def(def.did).repr.align.is_some() {
return true;
if def.repr.align.is_some() {
return Some(vec![(def.did, DUMMY_SP)]);
}
// push struct def_id before checking fields
stack.push(def_id);
for field in &def.non_enum_variant().fields {
let f = field.ty(tcx, substs);
if let ty::Adt(def, _) = f.kind {
if check_packed_inner(tcx, def.did, stack) {
return true;
if let ty::Adt(def, _) = field.ty(tcx, substs).kind {
if !stack.contains(&def.did) {
if let Some(mut defs) = check_packed_inner(tcx, def.did, stack) {
defs.push((def.did, field.ident.span));
return Some(defs);
}
}
}
}
// only need to pop if not early out
stack.pop();
}
}
false
None
}
/// Emit an error when encountering more or less than one variant in a transparent enum.

View file

@ -239,7 +239,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
// constraint, and add it to our list. Since we make sure to never re-add
// deleted items, this process will always finish.
while !vid_map.is_empty() {
let target = vid_map.keys().next().expect("Keys somehow empty").clone();
let target = *vid_map.keys().next().expect("Keys somehow empty");
let deps = vid_map.remove(&target).expect("Entry somehow missing");
for smaller in deps.smaller.iter() {

View file

@ -153,12 +153,13 @@ pub fn test_main_static_abort(tests: &[&TestDescAndFn]) {
// If we're being run in SpawnedSecondary mode, run the test here. run_test
// will then exit the process.
if let Ok(name) = env::var(SECONDARY_TEST_INVOKER_VAR) {
env::remove_var(SECONDARY_TEST_INVOKER_VAR);
let test = tests
.iter()
.filter(|test| test.desc.name.as_slice() == name)
.map(make_owned_test)
.next()
.expect("couldn't find a test with the provided name");
.expect(&format!("couldn't find a test with the provided name '{}'", name));
let TestDescAndFn { desc, testfn } = test;
let testfn = match testfn {
StaticTestFn(f) => f,
@ -485,9 +486,7 @@ pub fn run_test(
}
StaticBenchFn(benchfn) => {
// Benchmarks aren't expected to panic, so we run them all in-process.
crate::bench::benchmark(desc, monitor_ch, opts.nocapture, |harness| {
(benchfn.clone())(harness)
});
crate::bench::benchmark(desc, monitor_ch, opts.nocapture, benchfn);
}
DynTestFn(f) => {
match strategy {

View file

@ -1,8 +1,17 @@
error: future cannot be sent between threads safely
--> $DIR/issue-64130-4-async-move.rs:15:17
|
LL | pub fn foo() -> impl Future + Send {
| ^^^^^^^^^^^^^^^^^^ future returned by `foo` is not `Send`
LL | pub fn foo() -> impl Future + Send {
| ^^^^^^^^^^^^^^^^^^ future returned by `foo` is not `Send`
...
LL | / async move {
LL | | match client.status() {
LL | | 200 => {
LL | | let _x = get().await;
... |
LL | | }
LL | | }
| |_____- this returned value is of type `impl std::future::Future`
|
= help: the trait `std::marker::Sync` is not implemented for `(dyn std::any::Any + std::marker::Send + 'static)`
note: future is not `Send` as this value is used across an await

View file

@ -29,7 +29,7 @@ error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:13:13
|
LL | let _ = box { |x| (x as u8) }: Box<dyn Fn(i32) -> _>;
| ^^^^^^^^^^^^^^^^^^^^^ expected trait `std::ops::Fn`, found closure
| ^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn std::ops::Fn`, found closure
|
= note: expected struct `std::boxed::Box<dyn std::ops::Fn(i32) -> u8>`
found struct `std::boxed::Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:13:19: 13:32]>`
@ -38,7 +38,7 @@ error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:14:13
|
LL | let _ = box if true { false } else { true }: Box<dyn Debug>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait `std::fmt::Debug`, found `bool`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn std::fmt::Debug`, found `bool`
|
= note: expected struct `std::boxed::Box<dyn std::fmt::Debug>`
found struct `std::boxed::Box<bool>`
@ -47,7 +47,7 @@ error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:15:13
|
LL | let _ = box match true { true => 'a', false => 'b' }: Box<dyn Debug>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait `std::fmt::Debug`, found `char`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn std::fmt::Debug`, found `char`
|
= note: expected struct `std::boxed::Box<dyn std::fmt::Debug>`
found struct `std::boxed::Box<char>`
@ -83,7 +83,7 @@ error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:21:13
|
LL | let _ = &{ |x| (x as u8) }: &dyn Fn(i32) -> _;
| ^^^^^^^^^^^^^^^^^^ expected trait `std::ops::Fn`, found closure
| ^^^^^^^^^^^^^^^^^^ expected trait object `dyn std::ops::Fn`, found closure
|
= note: expected reference `&dyn std::ops::Fn(i32) -> u8`
found reference `&[closure@$DIR/coerce-expect-unsized-ascribed.rs:21:16: 21:29]`
@ -92,7 +92,7 @@ error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:22:13
|
LL | let _ = &if true { false } else { true }: &dyn Debug;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait `std::fmt::Debug`, found `bool`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn std::fmt::Debug`, found `bool`
|
= note: expected reference `&dyn std::fmt::Debug`
found reference `&bool`
@ -101,7 +101,7 @@ error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:23:13
|
LL | let _ = &match true { true => 'a', false => 'b' }: &dyn Debug;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait `std::fmt::Debug`, found `char`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn std::fmt::Debug`, found `char`
|
= note: expected reference `&dyn std::fmt::Debug`
found reference `&char`
@ -119,7 +119,7 @@ error[E0308]: mismatched types
--> $DIR/coerce-expect-unsized-ascribed.rs:26:13
|
LL | let _ = Box::new(|x| (x as u8)): Box<dyn Fn(i32) -> _>;
| ^^^^^^^^^^^^^^^^^^^^^^^ expected trait `std::ops::Fn`, found closure
| ^^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn std::ops::Fn`, found closure
|
= note: expected struct `std::boxed::Box<dyn std::ops::Fn(i32) -> _>`
found struct `std::boxed::Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:26:22: 26:35]>`

View file

@ -3,6 +3,9 @@ error[E0277]: arrays only have std trait implementations for lengths 0..=32
|
LL | pub fn no_vec_partial_eq_array<A, B>() -> impl PartialEq<[B; 33]>
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[B; 33]`
...
LL | Vec::<A>::new()
| --------------- this returned value is of type `std::vec::Vec<A>`
|
= note: required because of the requirements on the impl of `std::cmp::PartialEq<[B; 33]>` for `std::vec::Vec<A>`
= note: the return type of a function must have a statically known size
@ -12,6 +15,9 @@ error[E0277]: arrays only have std trait implementations for lengths 0..=32
|
LL | pub fn no_vec_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 33]>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[B; 33]`
...
LL | Vec::<A>::new()
| --------------- this returned value is of type `std::vec::Vec<A>`
|
= note: required because of the requirements on the impl of `std::cmp::PartialEq<&'a [B; 33]>` for `std::vec::Vec<A>`
= note: the return type of a function must have a statically known size
@ -21,6 +27,9 @@ error[E0277]: arrays only have std trait implementations for lengths 0..=32
|
LL | pub fn no_vecdeque_partial_eq_array<A, B>() -> impl PartialEq<[B; 33]>
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[B; 33]`
...
LL | VecDeque::<A>::new()
| -------------------- this returned value is of type `std::collections::VecDeque<A>`
|
= note: required because of the requirements on the impl of `std::cmp::PartialEq<[B; 33]>` for `std::collections::VecDeque<A>`
= note: the return type of a function must have a statically known size
@ -30,6 +39,9 @@ error[E0277]: arrays only have std trait implementations for lengths 0..=32
|
LL | pub fn no_vecdeque_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 33]>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[B; 33]`
...
LL | VecDeque::<A>::new()
| -------------------- this returned value is of type `std::collections::VecDeque<A>`
|
= note: required because of the requirements on the impl of `std::cmp::PartialEq<&'a [B; 33]>` for `std::collections::VecDeque<A>`
= note: the return type of a function must have a statically known size
@ -39,6 +51,9 @@ error[E0277]: arrays only have std trait implementations for lengths 0..=32
|
LL | pub fn no_vecdeque_partial_eq_ref_mut_array<'a, A, B>() -> impl PartialEq<&'a mut [B; 33]>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[B; 33]`
...
LL | VecDeque::<A>::new()
| -------------------- this returned value is of type `std::collections::VecDeque<A>`
|
= note: required because of the requirements on the impl of `std::cmp::PartialEq<&'a mut [B; 33]>` for `std::collections::VecDeque<A>`
= note: the return type of a function must have a statically known size

View file

@ -11,6 +11,9 @@ error[E0277]: arrays only have std trait implementations for lengths 0..=32
|
LL | pub fn no_iterator() -> impl Iterator<Item = i32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
LL |
LL | IntoIter::new([0i32; 33])
| ------------------------- this returned value is of type `std::array::IntoIter<i32, 33usize>`
|
= note: required because of the requirements on the impl of `std::iter::Iterator` for `std::array::IntoIter<i32, 33usize>`
= note: the return type of a function must have a statically known size
@ -28,6 +31,9 @@ error[E0277]: arrays only have std trait implementations for lengths 0..=32
|
LL | pub fn no_double_ended_iterator() -> impl DoubleEndedIterator {
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
LL |
LL | IntoIter::new([0i32; 33])
| ------------------------- this returned value is of type `std::array::IntoIter<i32, 33usize>`
|
= note: required because of the requirements on the impl of `std::iter::DoubleEndedIterator` for `std::array::IntoIter<i32, 33usize>`
= note: the return type of a function must have a statically known size
@ -45,6 +51,9 @@ error[E0277]: arrays only have std trait implementations for lengths 0..=32
|
LL | pub fn no_exact_size_iterator() -> impl ExactSizeIterator {
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
LL |
LL | IntoIter::new([0i32; 33])
| ------------------------- this returned value is of type `std::array::IntoIter<i32, 33usize>`
|
= note: required because of the requirements on the impl of `std::iter::ExactSizeIterator` for `std::array::IntoIter<i32, 33usize>`
= note: the return type of a function must have a statically known size
@ -62,6 +71,9 @@ error[E0277]: arrays only have std trait implementations for lengths 0..=32
|
LL | pub fn no_fused_iterator() -> impl FusedIterator {
| ^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
LL |
LL | IntoIter::new([0i32; 33])
| ------------------------- this returned value is of type `std::array::IntoIter<i32, 33usize>`
|
= note: required because of the requirements on the impl of `std::iter::FusedIterator` for `std::array::IntoIter<i32, 33usize>`
= note: the return type of a function must have a statically known size
@ -79,6 +91,9 @@ error[E0277]: arrays only have std trait implementations for lengths 0..=32
|
LL | pub fn no_trusted_len() -> impl TrustedLen {
| ^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
LL |
LL | IntoIter::new([0i32; 33])
| ------------------------- this returned value is of type `std::array::IntoIter<i32, 33usize>`
|
= note: required because of the requirements on the impl of `std::iter::TrustedLen` for `std::array::IntoIter<i32, 33usize>`
= note: the return type of a function must have a statically known size
@ -96,6 +111,9 @@ error[E0277]: arrays only have std trait implementations for lengths 0..=32
|
LL | pub fn no_clone() -> impl Clone {
| ^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
LL |
LL | IntoIter::new([0i32; 33])
| ------------------------- this returned value is of type `std::array::IntoIter<i32, 33usize>`
|
= note: required because of the requirements on the impl of `std::clone::Clone` for `std::array::IntoIter<i32, 33usize>`
= note: the return type of a function must have a statically known size
@ -113,6 +131,9 @@ error[E0277]: arrays only have std trait implementations for lengths 0..=32
|
LL | pub fn no_debug() -> impl Debug {
| ^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
LL |
LL | IntoIter::new([0i32; 33])
| ------------------------- this returned value is of type `std::array::IntoIter<i32, 33usize>`
|
= note: required because of the requirements on the impl of `std::fmt::Debug` for `std::array::IntoIter<i32, 33usize>`
= note: the return type of a function must have a statically known size

View file

@ -33,12 +33,10 @@ fn main() {
//~^ ERROR mismatched types
//~| expected trait object `dyn T`
//~| found reference `&_`
//~| expected trait `T`, found reference
let &&&x = &(&1isize as &dyn T);
//~^ ERROR mismatched types
//~| expected trait object `dyn T`
//~| found reference `&_`
//~| expected trait `T`, found reference
let box box x = box 1isize as Box<dyn T>;
//~^ ERROR mismatched types
//~| expected trait object `dyn T`

View file

@ -22,31 +22,31 @@ error[E0308]: mismatched types
LL | let &&x = &1isize as &dyn T;
| ^^
| |
| expected trait `T`, found reference
| expected trait object `dyn T`, found reference
| help: you can probably remove the explicit borrow: `x`
|
= note: expected trait object `dyn T`
found reference `&_`
error[E0308]: mismatched types
--> $DIR/destructure-trait-ref.rs:37:11
--> $DIR/destructure-trait-ref.rs:36:11
|
LL | let &&&x = &(&1isize as &dyn T);
| ^^
| |
| expected trait `T`, found reference
| expected trait object `dyn T`, found reference
| help: you can probably remove the explicit borrow: `x`
|
= note: expected trait object `dyn T`
found reference `&_`
error[E0308]: mismatched types
--> $DIR/destructure-trait-ref.rs:42:13
--> $DIR/destructure-trait-ref.rs:40:13
|
LL | let box box x = box 1isize as Box<dyn T>;
| ^^^^^ ------------------------ this expression has type `std::boxed::Box<dyn T>`
| |
| expected trait `T`, found struct `std::boxed::Box`
| expected trait object `dyn T`, found struct `std::boxed::Box`
|
= note: expected trait object `dyn T`
found struct `std::boxed::Box<_>`

View file

@ -32,7 +32,7 @@ pub fn main() {
let z: Box<dyn ToBar> = Box::new(Bar1 {f: 36});
f5.2 = Bar1 {f: 36};
//~^ ERROR mismatched types
//~| expected trait `ToBar`, found struct `Bar1`
//~| expected trait object `dyn ToBar`, found struct `Bar1`
//~| expected trait object `dyn ToBar`
//~| found struct `Bar1`
//~| ERROR the size for values of type

View file

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/dst-bad-assign-3.rs:33:12
|
LL | f5.2 = Bar1 {f: 36};
| ^^^^^^^^^^^^ expected trait `ToBar`, found struct `Bar1`
| ^^^^^^^^^^^^ expected trait object `dyn ToBar`, found struct `Bar1`
|
= note: expected trait object `dyn ToBar`
found struct `Bar1`

View file

@ -34,7 +34,7 @@ pub fn main() {
let z: Box<dyn ToBar> = Box::new(Bar1 {f: 36});
f5.ptr = Bar1 {f: 36};
//~^ ERROR mismatched types
//~| expected trait `ToBar`, found struct `Bar1`
//~| expected trait object `dyn ToBar`, found struct `Bar1`
//~| expected trait object `dyn ToBar`
//~| found struct `Bar1`
//~| ERROR the size for values of type

View file

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/dst-bad-assign.rs:35:14
|
LL | f5.ptr = Bar1 {f: 36};
| ^^^^^^^^^^^^ expected trait `ToBar`, found struct `Bar1`
| ^^^^^^^^^^^^ expected trait object `dyn ToBar`, found struct `Bar1`
|
= note: expected trait object `dyn ToBar`
found struct `Bar1`

View file

@ -2,7 +2,13 @@ error[E0603]: constant `PRIVATE` is private
--> $DIR/E0603.rs:6:17
|
LL | SomeModule::PRIVATE;
| ^^^^^^^
| ^^^^^^^ this constant is private
|
note: the constant `PRIVATE` is defined here
--> $DIR/E0603.rs:2:5
|
LL | const PRIVATE: u32 = 0x_a_bad_1dea_u32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,18 @@
// run-rustfix
#![allow(dead_code)]
struct Struct;
trait Trait {}
impl Trait for Struct {}
impl Trait for u32 {}
fn foo() -> impl Trait { Struct }
//~^ ERROR E0746
fn bar() -> impl Trait { //~ ERROR E0746
if true {
return 0;
}
42
}
fn main() {}

View file

@ -0,0 +1,18 @@
// run-rustfix
#![allow(dead_code)]
struct Struct;
trait Trait {}
impl Trait for Struct {}
impl Trait for u32 {}
fn foo() -> dyn Trait { Struct }
//~^ ERROR E0746
fn bar() -> dyn Trait { //~ ERROR E0746
if true {
return 0;
}
42
}
fn main() {}

View file

@ -0,0 +1,27 @@
error[E0746]: return type cannot have an unboxed trait object
--> $DIR/E0746.rs:8:13
|
LL | fn foo() -> dyn Trait { Struct }
| ^^^^^^^^^ doesn't have a size known at compile-time
|
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
help: return `impl Trait` instead, as all return paths are of type `Struct`, which implements `Trait`
|
LL | fn foo() -> impl Trait { Struct }
| ^^^^^^^^^^
error[E0746]: return type cannot have an unboxed trait object
--> $DIR/E0746.rs:11:13
|
LL | fn bar() -> dyn Trait {
| ^^^^^^^^^ doesn't have a size known at compile-time
|
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
help: return `impl Trait` instead, as all return paths are of type `{integer}`, which implements `Trait`
|
LL | fn bar() -> impl Trait {
| ^^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0746`.

View file

@ -8,7 +8,13 @@ error[E0603]: constant `FOO` is private
--> $DIR/error-festival.rs:22:10
|
LL | foo::FOO;
| ^^^
| ^^^ this constant is private
|
note: the constant `FOO` is defined here
--> $DIR/error-festival.rs:7:5
|
LL | const FOO: u32 = 0;
| ^^^^^^^^^^^^^^^^^^^
error[E0368]: binary assignment operation `+=` cannot be applied to type `&str`
--> $DIR/error-festival.rs:12:5

View file

@ -2,7 +2,13 @@ error[E0603]: function `unexported` is private
--> $DIR/export-import.rs:1:8
|
LL | use m::unexported;
| ^^^^^^^^^^
| ^^^^^^^^^^ this function is private
|
note: the function `unexported` is defined here
--> $DIR/export-import.rs:7:5
|
LL | fn unexported() { }
| ^^^^^^^^^^^^^^^
error: aborting due to previous error

View file

@ -2,7 +2,13 @@ error[E0603]: enum `Y` is private
--> $DIR/export-tag-variant.rs:7:26
|
LL | fn main() { let z = foo::Y::Y1; }
| ^
| ^ this enum is private
|
note: the enum `Y` is defined here
--> $DIR/export-tag-variant.rs:4:5
|
LL | enum Y { Y1 }
| ^^^^^^
error: aborting due to previous error

View file

@ -26,7 +26,13 @@ error[E0603]: function `z` is private
--> $DIR/export.rs:10:18
|
LL | fn main() { foo::z(10); }
| ^
| ^ this function is private
|
note: the function `z` is defined here
--> $DIR/export.rs:5:5
|
LL | fn z(y: isize) { log(debug, y); }
| ^^^^^^^^^^^^^^
error: aborting due to 5 previous errors

View file

@ -3,10 +3,10 @@ mod foo {
}
// Check that private crates can be used from outside their modules, albeit with warnings
use foo::core::cell; //~ ERROR crate `core` is private
use foo::core::cell; //~ ERROR crate import `core` is private
fn f() {
foo::core::cell::Cell::new(0); //~ ERROR crate `core` is private
foo::core::cell::Cell::new(0); //~ ERROR crate import `core` is private
use foo::*;
mod core {} // Check that private crates are not glob imported

View file

@ -1,14 +1,26 @@
error[E0603]: crate `core` is private
error[E0603]: crate import `core` is private
--> $DIR/extern-crate-visibility.rs:6:10
|
LL | use foo::core::cell;
| ^^^^
| ^^^^ this crate import is private
|
note: the crate import `core` is defined here
--> $DIR/extern-crate-visibility.rs:2:5
|
LL | extern crate core;
| ^^^^^^^^^^^^^^^^^^
error[E0603]: crate `core` is private
error[E0603]: crate import `core` is private
--> $DIR/extern-crate-visibility.rs:9:10
|
LL | foo::core::cell::Cell::new(0);
| ^^^^
| ^^^^ this crate import is private
|
note: the crate import `core` is defined here
--> $DIR/extern-crate-visibility.rs:2:5
|
LL | extern crate core;
| ^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View file

@ -38,7 +38,7 @@ LL | type C where Self: Copy = String;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
|
= note: required because of the requirements on the impl of `std::marker::Copy` for `Fooy<T>`
= note: the requirement `Fooy<T>: std::marker::Copy` appears on the associated impl typebut not on the corresponding associated trait type
= note: the requirement `Fooy<T>: std::marker::Copy` appears on the associated impl type but not on the corresponding associated trait type
error: aborting due to 3 previous errors

View file

@ -2,7 +2,13 @@ error[E0603]: function `f` is private
--> $DIR/privacy.rs:16:14
|
LL | foo::f()
| ^
| ^ this function is private
|
note: the function `f` is defined here
--> $DIR/privacy.rs:4:5
|
LL | fn f() {}
| ^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,34 @@
#![allow(bare_trait_objects)]
struct Struct;
trait Trait {}
impl Trait for Struct {}
impl Trait for u32 {}
fn fuz() -> (usize, Trait) { (42, Struct) }
//~^ ERROR E0277
//~| ERROR E0308
fn bar() -> (usize, dyn Trait) { (42, Struct) }
//~^ ERROR E0277
//~| ERROR E0308
fn bap() -> Trait { Struct }
//~^ ERROR E0746
fn ban() -> dyn Trait { Struct }
//~^ ERROR E0746
fn bak() -> dyn Trait { unimplemented!() } //~ ERROR E0277
// Suggest using `Box<dyn Trait>`
fn bal() -> dyn Trait { //~ ERROR E0746
if true {
return Struct;
}
42
}
// Suggest using `impl Trait`
fn bat() -> dyn Trait { //~ ERROR E0746
if true {
return 0;
}
42
}
fn main() {}

View file

@ -0,0 +1,113 @@
error[E0308]: mismatched types
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:7:35
|
LL | fn fuz() -> (usize, Trait) { (42, Struct) }
| ^^^^^^ expected trait object `dyn Trait`, found struct `Struct`
|
= note: expected trait object `(dyn Trait + 'static)`
found struct `Struct`
error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:7:13
|
LL | fn fuz() -> (usize, Trait) { (42, Struct) }
| ^^^^^^^^^^^^^^ ------------ this returned value is of type `(usize, (dyn Trait + 'static))`
| |
| doesn't have a size known at compile-time
|
= help: within `(usize, (dyn Trait + 'static))`, the trait `std::marker::Sized` is not implemented for `(dyn Trait + 'static)`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required because it appears within the type `(usize, (dyn Trait + 'static))`
= note: the return type of a function must have a statically known size
error[E0308]: mismatched types
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:10:39
|
LL | fn bar() -> (usize, dyn Trait) { (42, Struct) }
| ^^^^^^ expected trait object `dyn Trait`, found struct `Struct`
|
= note: expected trait object `(dyn Trait + 'static)`
found struct `Struct`
error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:10:13
|
LL | fn bar() -> (usize, dyn Trait) { (42, Struct) }
| ^^^^^^^^^^^^^^^^^^ ------------ this returned value is of type `(usize, (dyn Trait + 'static))`
| |
| doesn't have a size known at compile-time
|
= help: within `(usize, (dyn Trait + 'static))`, the trait `std::marker::Sized` is not implemented for `(dyn Trait + 'static)`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required because it appears within the type `(usize, (dyn Trait + 'static))`
= note: the return type of a function must have a statically known size
error[E0746]: return type cannot have an unboxed trait object
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:13:13
|
LL | fn bap() -> Trait { Struct }
| ^^^^^ doesn't have a size known at compile-time
|
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
help: return `impl Trait` instead, as all return paths are of type `Struct`, which implements `Trait`
|
LL | fn bap() -> impl Trait { Struct }
| ^^^^^^^^^^
error[E0746]: return type cannot have an unboxed trait object
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:15:13
|
LL | fn ban() -> dyn Trait { Struct }
| ^^^^^^^^^ doesn't have a size known at compile-time
|
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
help: return `impl Trait` instead, as all return paths are of type `Struct`, which implements `Trait`
|
LL | fn ban() -> impl Trait { Struct }
| ^^^^^^^^^^
error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:17:13
|
LL | fn bak() -> dyn Trait { unimplemented!() }
| ^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `(dyn Trait + 'static)`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: the return type of a function must have a statically known size
error[E0746]: return type cannot have an unboxed trait object
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:19:13
|
LL | fn bal() -> dyn Trait {
| ^^^^^^^^^ doesn't have a size known at compile-time
|
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
= note: if all the returned values were of the same type you could use `impl Trait` as the return type
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
= note: you can create a new `enum` with a variant for each returned type
help: return a boxed trait object instead
|
LL | fn bal() -> Box<dyn Trait> {
LL | if true {
LL | return Box::new(Struct);
LL | }
LL | Box::new(42)
|
error[E0746]: return type cannot have an unboxed trait object
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:27:13
|
LL | fn bat() -> dyn Trait {
| ^^^^^^^^^ doesn't have a size known at compile-time
|
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
help: return `impl Trait` instead, as all return paths are of type `{integer}`, which implements `Trait`
|
LL | fn bat() -> impl Trait {
| ^^^^^^^^^^
error: aborting due to 9 previous errors
Some errors have detailed explanations: E0277, E0308, E0746.
For more information about an error, try `rustc --explain E0277`.

View file

@ -9,6 +9,12 @@ LL | return 1_i32;
LL | }
LL | 0_u32
| ^^^^^ expected `i32`, found `u32`
|
= note: to return `impl Trait`, all returned values must be of the same type
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
= help: if the trait `Foo` were object safe, you could return a boxed trait object
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
= help: alternatively, create a new `enum` with a variant for each returned type
error[E0277]: cannot add `impl Foo` to `u32`
--> $DIR/equality.rs:24:11

View file

@ -0,0 +1,35 @@
#![allow(bare_trait_objects)]
trait NotObjectSafe {
fn foo() -> Self;
}
struct A;
struct B;
impl NotObjectSafe for A {
fn foo() -> Self {
A
}
}
impl NotObjectSafe for B {
fn foo() -> Self {
B
}
}
fn car() -> dyn NotObjectSafe { //~ ERROR the trait `NotObjectSafe` cannot be made into an object
if true {
return A;
}
B
}
fn cat() -> Box<dyn NotObjectSafe> { //~ ERROR the trait `NotObjectSafe` cannot be made into an
if true {
return Box::new(A);
}
Box::new(B)
}
fn main() {}

View file

@ -0,0 +1,21 @@
error[E0038]: the trait `NotObjectSafe` cannot be made into an object
--> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:21:1
|
LL | fn foo() -> Self;
| --- associated function `foo` has no `self` parameter
...
LL | fn car() -> dyn NotObjectSafe {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object
error[E0038]: the trait `NotObjectSafe` cannot be made into an object
--> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:28:1
|
LL | fn foo() -> Self;
| --- associated function `foo` has no `self` parameter
...
LL | fn cat() -> Box<dyn NotObjectSafe> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0038`.

View file

@ -0,0 +1,46 @@
trait NotObjectSafe {
fn foo() -> Self;
}
trait ObjectSafe {
fn bar(&self);
}
struct A;
struct B;
impl NotObjectSafe for A {
fn foo() -> Self {
A
}
}
impl NotObjectSafe for B {
fn foo() -> Self {
B
}
}
impl ObjectSafe for A {
fn bar(&self) {}
}
impl ObjectSafe for B {
fn bar(&self) {}
}
fn can() -> impl NotObjectSafe {
if true {
return A;
}
B //~ ERROR mismatched types
}
fn cat() -> impl ObjectSafe {
if true {
return A;
}
B //~ ERROR mismatched types
}
fn main() {}

View file

@ -0,0 +1,39 @@
error[E0308]: mismatched types
--> $DIR/object-unsafe-trait-in-return-position-impl-trait.rs:36:5
|
LL | fn can() -> impl NotObjectSafe {
| ------------------ expected because this return type...
LL | if true {
LL | return A;
| - ...is found to be `A` here
LL | }
LL | B
| ^ expected struct `A`, found struct `B`
|
= note: to return `impl Trait`, all returned values must be of the same type
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
= help: if the trait `NotObjectSafe` were object safe, you could return a boxed trait object
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
= help: alternatively, create a new `enum` with a variant for each returned type
error[E0308]: mismatched types
--> $DIR/object-unsafe-trait-in-return-position-impl-trait.rs:43:5
|
LL | fn cat() -> impl ObjectSafe {
| --------------- expected because this return type...
LL | if true {
LL | return A;
| - ...is found to be `A` here
LL | }
LL | B
| ^ expected struct `A`, found struct `B`
|
= note: to return `impl Trait`, all returned values must be of the same type
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
= help: you can instead return a boxed trait object using `Box<dyn ObjectSafe>`
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
= help: alternatively, create a new `enum` with a variant for each returned type
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.

View file

@ -13,11 +13,17 @@ error[E0432]: unresolved import `foo`
LL | use foo;
| ^^^ no `foo` in the root
error[E0603]: unresolved item `foo` is private
error[E0603]: unresolved item import `foo` is private
--> $DIR/import.rs:15:10
|
LL | zed::foo();
| ^^^
| ^^^ this unresolved item import is private
|
note: the unresolved item import `foo` is defined here
--> $DIR/import.rs:10:9
|
LL | use foo;
| ^^^
error: aborting due to 3 previous errors

View file

@ -9,6 +9,6 @@ mod parser {
use ParseOptions;
}
pub use parser::ParseOptions; //~ ERROR struct `ParseOptions` is private
pub use parser::ParseOptions; //~ ERROR struct import `ParseOptions` is private
fn main() {}

View file

@ -1,8 +1,14 @@
error[E0603]: struct `ParseOptions` is private
error[E0603]: struct import `ParseOptions` is private
--> $DIR/issue-55884-2.rs:12:17
|
LL | pub use parser::ParseOptions;
| ^^^^^^^^^^^^
| ^^^^^^^^^^^^ this struct import is private
|
note: the struct import `ParseOptions` is defined here
--> $DIR/issue-55884-2.rs:9:9
|
LL | use ParseOptions;
| ^^^^^^^^^^^^
error: aborting due to previous error

View file

@ -10,17 +10,29 @@ note: consider marking `foo` as `pub` in the imported module
LL | pub use super::foo;
| ^^^^^^^^^^
error[E0603]: module `foo` is private
error[E0603]: module import `foo` is private
--> $DIR/reexports.rs:33:15
|
LL | use b::a::foo::S;
| ^^^
| ^^^ this module import is private
|
note: the module import `foo` is defined here
--> $DIR/reexports.rs:21:17
|
LL | pub use super::foo; // This is OK since the value `foo` is visible enough.
| ^^^^^^^^^^
error[E0603]: module `foo` is private
error[E0603]: module import `foo` is private
--> $DIR/reexports.rs:34:15
|
LL | use b::b::foo::S as T;
| ^^^
| ^^^ this module import is private
|
note: the module import `foo` is defined here
--> $DIR/reexports.rs:26:17
|
LL | pub use super::*; // This is also OK since the value `foo` is visible enough.
| ^^^^^^^^
warning: glob import doesn't reexport anything because no candidate is public enough
--> $DIR/reexports.rs:9:17

View file

@ -38,7 +38,13 @@ error[E0603]: function `quz` is private
--> $DIR/unresolved-imports-used.rs:9:10
|
LL | use qux::quz;
| ^^^
| ^^^ this function is private
|
note: the function `quz` is defined here
--> $DIR/unresolved-imports-used.rs:5:4
|
LL | fn quz() {}
| ^^^^^^^^
error: unused import: `qux::quy`
--> $DIR/unresolved-imports-used.rs:16:5

View file

@ -2,7 +2,13 @@ error[E0603]: struct `S` is private
--> $DIR/issue-10545.rs:6:14
|
LL | fn foo(_: a::S) {
| ^
| ^ this struct is private
|
note: the struct `S` is defined here
--> $DIR/issue-10545.rs:2:5
|
LL | struct S;
| ^^^^^^^^^
error: aborting due to previous error

View file

@ -2,7 +2,13 @@ error[E0603]: trait `Foo` is private
--> $DIR/issue-11593.rs:7:24
|
LL | impl private_trait_xc::Foo for Bar {}
| ^^^
| ^^^ this trait is private
|
note: the trait `Foo` is defined here
--> $DIR/auxiliary/private-trait-xc.rs:1:1
|
LL | trait Foo {}
| ^^^^^^^^^
error: aborting due to previous error

View file

@ -2,13 +2,25 @@ error[E0603]: enum `Foo` is private
--> $DIR/issue-11680.rs:6:21
|
LL | let _b = other::Foo::Bar(1);
| ^^^
| ^^^ this enum is private
|
note: the enum `Foo` is defined here
--> $DIR/auxiliary/issue-11680.rs:1:1
|
LL | enum Foo {
| ^^^^^^^^
error[E0603]: enum `Foo` is private
--> $DIR/issue-11680.rs:9:27
|
LL | let _b = other::test::Foo::Bar(1);
| ^^^
| ^^^ this enum is private
|
note: the enum `Foo` is defined here
--> $DIR/auxiliary/issue-11680.rs:6:5
|
LL | enum Foo {
| ^^^^^^^^
error: aborting due to 2 previous errors

View file

@ -2,7 +2,13 @@ error[E0603]: unit struct `C` is private
--> $DIR/issue-13407.rs:6:8
|
LL | A::C = 1;
| ^
| ^ this unit struct is private
|
note: the unit struct `C` is defined here
--> $DIR/issue-13407.rs:2:5
|
LL | struct C;
| ^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/issue-13407.rs:6:12

View file

@ -2,13 +2,25 @@ error[E0603]: struct `Foo` is private
--> $DIR/issue-13641.rs:9:8
|
LL | a::Foo::new();
| ^^^
| ^^^ this struct is private
|
note: the struct `Foo` is defined here
--> $DIR/issue-13641.rs:2:5
|
LL | struct Foo;
| ^^^^^^^^^^^
error[E0603]: enum `Bar` is private
--> $DIR/issue-13641.rs:11:8
|
LL | a::Bar::new();
| ^^^
| ^^^ this enum is private
|
note: the enum `Bar` is defined here
--> $DIR/issue-13641.rs:4:5
|
LL | enum Bar {}
| ^^^^^^^^
error: aborting due to 2 previous errors

View file

@ -2,7 +2,13 @@ error[E0603]: function `bar` is private
--> $DIR/issue-16725.rs:6:19
|
LL | unsafe { foo::bar(); }
| ^^^
| ^^^ this function is private
|
note: the function `bar` is defined here
--> $DIR/auxiliary/issue-16725.rs:2:5
|
LL | fn bar();
| ^^^^^^^^^
error: aborting due to previous error

View file

@ -2,13 +2,25 @@ error[E0603]: constant `B` is private
--> $DIR/issue-17718-const-privacy.rs:5:8
|
LL | use a::B;
| ^
| ^ this constant is private
|
note: the constant `B` is defined here
--> $DIR/issue-17718-const-privacy.rs:13:5
|
LL | const B: usize = 3;
| ^^^^^^^^^^^^^^^^^^^
error[E0603]: constant `BAR` is private
--> $DIR/issue-17718-const-privacy.rs:8:5
|
LL | BAR,
| ^^^
| ^^^ this constant is private
|
note: the constant `BAR` is defined here
--> $DIR/auxiliary/issue-17718-const-privacy.rs:4:1
|
LL | const BAR: usize = 3;
| ^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View file

@ -2,7 +2,13 @@ error[E0603]: module `n` is private
--> $DIR/issue-28388-2.rs:7:8
|
LL | use m::n::{};
| ^
| ^ this module is private
|
note: the module `n` is defined here
--> $DIR/issue-28388-2.rs:4:5
|
LL | mod n {}
| ^^^^^
error: aborting due to previous error

View file

@ -8,7 +8,13 @@ error[E0603]: struct `A` is private
--> $DIR/issue-29161.rs:13:8
|
LL | a::A::default();
| ^
| ^ this struct is private
|
note: the struct `A` is defined here
--> $DIR/issue-29161.rs:2:5
|
LL | struct A;
| ^^^^^^^^^
error: aborting due to 2 previous errors

View file

@ -1,3 +1,8 @@
// FIXME: missing sysroot spans (#53081)
// ignore-i586-unknown-linux-gnu
// ignore-i586-unknown-linux-musl
// ignore-i686-unknown-linux-musl
fn main() {
let a = std::sys::imp::process::process_common::StdioPipes { ..panic!() };
//~^ ERROR failed to resolve: could not find `imp` in `sys` [E0433]

View file

@ -1,14 +1,20 @@
error[E0433]: failed to resolve: could not find `imp` in `sys`
--> $DIR/issue-38857.rs:2:23
--> $DIR/issue-38857.rs:7:23
|
LL | let a = std::sys::imp::process::process_common::StdioPipes { ..panic!() };
| ^^^ could not find `imp` in `sys`
error[E0603]: module `sys` is private
--> $DIR/issue-38857.rs:2:18
--> $DIR/issue-38857.rs:7:18
|
LL | let a = std::sys::imp::process::process_common::StdioPipes { ..panic!() };
| ^^^
| ^^^ this module is private
|
note: the module `sys` is defined here
--> $SRC_DIR/libstd/lib.rs:LL:COL
|
LL | mod sys;
| ^^^^^^^^
error: aborting due to 2 previous errors

View file

@ -2,7 +2,13 @@ error[E0603]: function `fly` is private
--> $DIR/issue-3993.rs:1:10
|
LL | use zoo::fly;
| ^^^
| ^^^ this function is private
|
note: the function `fly` is defined here
--> $DIR/issue-3993.rs:4:5
|
LL | fn fly() {}
| ^^^^^^^^
error: aborting due to previous error

View file

@ -3,6 +3,9 @@ error[E0277]: the trait bound `impl Trait<<u32 as std::ops::Add>::Output>: Trait
|
LL | ) -> Either<impl Trait<<u32 as Add<u32>>::Output>, impl Trait<<u32 as Add<u32>>::Output>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<u32>` is not implemented for `impl Trait<<u32 as std::ops::Add>::Output>`
...
LL | add_generic(value, 1u32)
| ------------------------ this returned value is of type `Either<impl Trait<<u32 as std::ops::Add>::Output>, impl Trait<<u32 as std::ops::Add>::Output>>`
|
= note: the return type of a function must have a statically known size
@ -11,6 +14,9 @@ error[E0277]: the trait bound `impl Trait<<u32 as std::ops::Add>::Output>: Trait
|
LL | ) -> Either<impl Trait<<u32 as Add<u32>>::Output>, impl Trait<<u32 as Add<u32>>::Output>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<u32>` is not implemented for `impl Trait<<u32 as std::ops::Add>::Output>`
...
LL | add_generic(value, 1u32)
| ------------------------ this returned value is of type `Either<impl Trait<<u32 as std::ops::Add>::Output>, impl Trait<<u32 as std::ops::Add>::Output>>`
|
= note: the return type of a function must have a statically known size

View file

@ -14,6 +14,9 @@ error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at
|
LL | -> Struct {
| ^^^^^^ doesn't have a size known at compile-time
LL |
LL | Struct { r: r }
| --------------- this returned value is of type `Struct`
|
= help: within `Struct`, the trait `std::marker::Sized` is not implemented for `(dyn A + 'static)`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>

View file

@ -3,6 +3,9 @@ error[E0277]: the trait bound `std::result::Result<(), _>: Future` is not satisf
|
LL | fn foo() -> impl Future<Item=(), Error=Box<dyn Error>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Future` is not implemented for `std::result::Result<(), _>`
LL |
LL | Ok(())
| ------ this returned value is of type `std::result::Result<(), _>`
|
= note: the return type of a function must have a statically known size

View file

@ -2,7 +2,14 @@ error[E0603]: constant `baz` is private
--> $DIR/macro-local-data-key-priv.rs:8:10
|
LL | bar::baz.with(|_| ());
| ^^^
| ^^^ this constant is private
|
note: the constant `baz` is defined here
--> $DIR/macro-local-data-key-priv.rs:4:5
|
LL | thread_local!(static baz: f64 = 0.0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error

View file

@ -3,8 +3,12 @@ error[E0277]: the trait bound `(): T` is not satisfied
|
LL | fn should_ret_unit() -> impl T {
| ^^^^^^ the trait `T` is not implemented for `()`
LL |
LL | panic!()
| -------- this returned value is of type `()`
|
= note: the return type of a function must have a statically known size
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error

View file

@ -13,7 +13,16 @@ error[E0603]: static `x` is private
--> $DIR/pub-item-macro.rs:17:23
|
LL | let y: u32 = foo::x;
| ^
| ^ this static is private
|
note: the static `x` is defined here
--> $DIR/pub-item-macro.rs:4:5
|
LL | static x: u32 = 0;
| ^^^^^^^^^^^^^^^^^^
...
LL | pub_x!();
| --------- in this macro invocation
error: aborting due to 2 previous errors

View file

@ -9,6 +9,12 @@ LL | return 0i32;
LL | }
LL | 1u32
| ^^^^ expected `i32`, found `u32`
|
= note: to return `impl Trait`, all returned values must be of the same type
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
= help: you can instead return a boxed trait object using `Box<dyn std::fmt::Display>`
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
= help: alternatively, create a new `enum` with a variant for each returned type
error[E0308]: mismatched types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:13:16
@ -21,6 +27,12 @@ LL | return 0i32;
LL | } else {
LL | return 1u32;
| ^^^^ expected `i32`, found `u32`
|
= note: to return `impl Trait`, all returned values must be of the same type
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
= help: you can instead return a boxed trait object using `Box<dyn std::fmt::Display>`
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
= help: alternatively, create a new `enum` with a variant for each returned type
error[E0308]: mismatched types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:22:9
@ -33,6 +45,12 @@ LL | return 0i32;
LL | } else {
LL | 1u32
| ^^^^ expected `i32`, found `u32`
|
= note: to return `impl Trait`, all returned values must be of the same type
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
= help: you can instead return a boxed trait object using `Box<dyn std::fmt::Display>`
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
= help: alternatively, create a new `enum` with a variant for each returned type
error[E0308]: `if` and `else` have incompatible types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:31:9
@ -57,6 +75,12 @@ LL | 0 => return 0i32,
| ---- ...is found to be `i32` here
LL | _ => 1u32,
| ^^^^ expected `i32`, found `u32`
|
= note: to return `impl Trait`, all returned values must be of the same type
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
= help: you can instead return a boxed trait object using `Box<dyn std::fmt::Display>`
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
= help: alternatively, create a new `enum` with a variant for each returned type
error[E0308]: mismatched types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:45:5
@ -71,6 +95,12 @@ LL | | 1 => 1u32,
LL | | _ => 2u32,
LL | | }
| |_____^ expected `i32`, found `u32`
|
= note: to return `impl Trait`, all returned values must be of the same type
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
= help: you can instead return a boxed trait object using `Box<dyn std::fmt::Display>`
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
= help: alternatively, create a new `enum` with a variant for each returned type
error[E0308]: mismatched types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:59:13
@ -83,6 +113,12 @@ LL | return 0i32;
...
LL | 1u32
| ^^^^ expected `i32`, found `u32`
|
= note: to return `impl Trait`, all returned values must be of the same type
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
= help: you can instead return a boxed trait object using `Box<dyn std::fmt::Display>`
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
= help: alternatively, create a new `enum` with a variant for each returned type
error: aborting due to 7 previous errors

View file

@ -2,7 +2,13 @@ error[E0603]: macro `mac` is private
--> $DIR/decl-macro.rs:8:8
|
LL | m::mac!();
| ^^^
| ^^^ this macro is private
|
note: the macro `mac` is defined here
--> $DIR/decl-macro.rs:4:5
|
LL | macro mac() {}
| ^^^^^^^^^^^
error: aborting due to previous error

View file

@ -2,19 +2,37 @@ error[E0603]: module `bar` is private
--> $DIR/privacy-in-paths.rs:24:16
|
LL | ::foo::bar::baz::f();
| ^^^
| ^^^ this module is private
|
note: the module `bar` is defined here
--> $DIR/privacy-in-paths.rs:3:5
|
LL | mod bar {
| ^^^^^^^
error[E0603]: module `bar` is private
--> $DIR/privacy-in-paths.rs:25:16
|
LL | ::foo::bar::S::f();
| ^^^
| ^^^ this module is private
|
note: the module `bar` is defined here
--> $DIR/privacy-in-paths.rs:3:5
|
LL | mod bar {
| ^^^^^^^
error[E0603]: trait `T` is private
--> $DIR/privacy-in-paths.rs:26:23
|
LL | <() as ::foo::T>::Assoc::f();
| ^
| ^ this trait is private
|
note: the trait `T` is defined here
--> $DIR/privacy-in-paths.rs:8:5
|
LL | trait T {
| ^^^^^^^
error: aborting due to 3 previous errors

View file

@ -58,19 +58,37 @@ error[E0603]: trait `Bar` is private
--> $DIR/privacy-ns2.rs:63:15
|
LL | use foo3::Bar;
| ^^^
| ^^^ this trait is private
|
note: the trait `Bar` is defined here
--> $DIR/privacy-ns2.rs:55:5
|
LL | trait Bar {
| ^^^^^^^^^
error[E0603]: trait `Bar` is private
--> $DIR/privacy-ns2.rs:67:15
|
LL | use foo3::Bar;
| ^^^
| ^^^ this trait is private
|
note: the trait `Bar` is defined here
--> $DIR/privacy-ns2.rs:55:5
|
LL | trait Bar {
| ^^^^^^^^^
error[E0603]: trait `Bar` is private
--> $DIR/privacy-ns2.rs:74:16
|
LL | use foo3::{Bar,Baz};
| ^^^
| ^^^ this trait is private
|
note: the trait `Bar` is defined here
--> $DIR/privacy-ns2.rs:55:5
|
LL | trait Bar {
| ^^^^^^^^^
error[E0107]: wrong number of const arguments: expected 0, found 1
--> $DIR/privacy-ns2.rs:41:18

View file

@ -2,7 +2,13 @@ error[E0603]: trait `Bar` is private
--> $DIR/privacy-ufcs.rs:12:20
|
LL | <i32 as ::foo::Bar>::baz();
| ^^^
| ^^^ this trait is private
|
note: the trait `Bar` is defined here
--> $DIR/privacy-ufcs.rs:4:5
|
LL | trait Bar {
| ^^^^^^^^^
error: aborting due to previous error

View file

@ -2,79 +2,157 @@ error[E0603]: module `baz` is private
--> $DIR/privacy1.rs:132:18
|
LL | use bar::baz::{foo, bar};
| ^^^
| ^^^ this module is private
|
note: the module `baz` is defined here
--> $DIR/privacy1.rs:50:5
|
LL | mod baz {
| ^^^^^^^
error[E0603]: module `baz` is private
--> $DIR/privacy1.rs:132:18
|
LL | use bar::baz::{foo, bar};
| ^^^
| ^^^ this module is private
|
note: the module `baz` is defined here
--> $DIR/privacy1.rs:50:5
|
LL | mod baz {
| ^^^^^^^
error[E0603]: module `baz` is private
--> $DIR/privacy1.rs:141:18
|
LL | use bar::baz;
| ^^^
| ^^^ this module is private
|
note: the module `baz` is defined here
--> $DIR/privacy1.rs:50:5
|
LL | mod baz {
| ^^^^^^^
error[E0603]: module `i` is private
--> $DIR/privacy1.rs:165:20
|
LL | use self::foo::i::A;
| ^
| ^ this module is private
|
note: the module `i` is defined here
--> $DIR/privacy1.rs:170:9
|
LL | mod i {
| ^^^^^
error[E0603]: module `baz` is private
--> $DIR/privacy1.rs:104:16
|
LL | ::bar::baz::A::foo();
| ^^^
| ^^^ this module is private
|
note: the module `baz` is defined here
--> $DIR/privacy1.rs:50:5
|
LL | mod baz {
| ^^^^^^^
error[E0603]: module `baz` is private
--> $DIR/privacy1.rs:105:16
|
LL | ::bar::baz::A::bar();
| ^^^
| ^^^ this module is private
|
note: the module `baz` is defined here
--> $DIR/privacy1.rs:50:5
|
LL | mod baz {
| ^^^^^^^
error[E0603]: module `baz` is private
--> $DIR/privacy1.rs:107:16
|
LL | ::bar::baz::A.foo2();
| ^^^
| ^^^ this module is private
|
note: the module `baz` is defined here
--> $DIR/privacy1.rs:50:5
|
LL | mod baz {
| ^^^^^^^
error[E0603]: module `baz` is private
--> $DIR/privacy1.rs:108:16
|
LL | ::bar::baz::A.bar2();
| ^^^
| ^^^ this module is private
|
note: the module `baz` is defined here
--> $DIR/privacy1.rs:50:5
|
LL | mod baz {
| ^^^^^^^
error[E0603]: trait `B` is private
--> $DIR/privacy1.rs:112:16
|
LL | ::bar::B::foo();
| ^
| ^ this trait is private
|
note: the trait `B` is defined here
--> $DIR/privacy1.rs:40:5
|
LL | trait B {
| ^^^^^^^
error[E0603]: function `epriv` is private
--> $DIR/privacy1.rs:118:20
|
LL | ::bar::epriv();
| ^^^^^
| ^^^^^ this function is private
|
note: the function `epriv` is defined here
--> $DIR/privacy1.rs:65:9
|
LL | fn epriv();
| ^^^^^^^^^^^
error[E0603]: module `baz` is private
--> $DIR/privacy1.rs:127:16
|
LL | ::bar::baz::foo();
| ^^^
| ^^^ this module is private
|
note: the module `baz` is defined here
--> $DIR/privacy1.rs:50:5
|
LL | mod baz {
| ^^^^^^^
error[E0603]: module `baz` is private
--> $DIR/privacy1.rs:128:16
|
LL | ::bar::baz::bar();
| ^^^
| ^^^ this module is private
|
note: the module `baz` is defined here
--> $DIR/privacy1.rs:50:5
|
LL | mod baz {
| ^^^^^^^
error[E0603]: trait `B` is private
--> $DIR/privacy1.rs:157:17
|
LL | impl ::bar::B for f32 { fn foo() -> f32 { 1.0 } }
| ^
| ^ this trait is private
|
note: the trait `B` is defined here
--> $DIR/privacy1.rs:40:5
|
LL | trait B {
| ^^^^^^^
error[E0624]: method `bar` is private
--> $DIR/privacy1.rs:77:9

View file

@ -4,11 +4,17 @@ error[E0432]: unresolved import `bar::foo`
LL | use bar::foo;
| ^^^^^^^^ no `foo` in `bar`
error[E0603]: function `foo` is private
error[E0603]: function import `foo` is private
--> $DIR/privacy2.rs:23:20
|
LL | use bar::glob::foo;
| ^^^
| ^^^ this function import is private
|
note: the function import `foo` is defined here
--> $DIR/privacy2.rs:10:13
|
LL | use foo;
| ^^^
error: requires `sized` lang_item

View file

@ -2,7 +2,13 @@ error[E0603]: module `glob` is private
--> $DIR/privacy4.rs:21:14
|
LL | use bar::glob::gpriv;
| ^^^^
| ^^^^ this module is private
|
note: the module `glob` is defined here
--> $DIR/privacy4.rs:13:5
|
LL | mod glob {
| ^^^^^^^^
error: aborting due to previous error

View file

@ -5,7 +5,13 @@ LL | pub struct A(());
| -- a constructor is private if any of the fields is private
...
LL | let a = a::A(());
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `A` is defined here
--> $DIR/privacy5.rs:6:5
|
LL | pub struct A(());
| ^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `B` is private
--> $DIR/privacy5.rs:52:16
@ -14,7 +20,13 @@ LL | pub struct B(isize);
| ----- a constructor is private if any of the fields is private
...
LL | let b = a::B(2);
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `B` is defined here
--> $DIR/privacy5.rs:7:5
|
LL | pub struct B(isize);
| ^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:53:16
@ -23,7 +35,13 @@ LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
...
LL | let c = a::C(2, 3);
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/privacy5.rs:8:5
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `A` is private
--> $DIR/privacy5.rs:56:12
@ -32,7 +50,13 @@ LL | pub struct A(());
| -- a constructor is private if any of the fields is private
...
LL | let a::A(()) = a;
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `A` is defined here
--> $DIR/privacy5.rs:6:5
|
LL | pub struct A(());
| ^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `A` is private
--> $DIR/privacy5.rs:57:12
@ -41,7 +65,13 @@ LL | pub struct A(());
| -- a constructor is private if any of the fields is private
...
LL | let a::A(_) = a;
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `A` is defined here
--> $DIR/privacy5.rs:6:5
|
LL | pub struct A(());
| ^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `A` is private
--> $DIR/privacy5.rs:58:18
@ -50,7 +80,13 @@ LL | pub struct A(());
| -- a constructor is private if any of the fields is private
...
LL | match a { a::A(()) => {} }
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `A` is defined here
--> $DIR/privacy5.rs:6:5
|
LL | pub struct A(());
| ^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `A` is private
--> $DIR/privacy5.rs:59:18
@ -59,7 +95,13 @@ LL | pub struct A(());
| -- a constructor is private if any of the fields is private
...
LL | match a { a::A(_) => {} }
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `A` is defined here
--> $DIR/privacy5.rs:6:5
|
LL | pub struct A(());
| ^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `B` is private
--> $DIR/privacy5.rs:61:12
@ -68,7 +110,13 @@ LL | pub struct B(isize);
| ----- a constructor is private if any of the fields is private
...
LL | let a::B(_) = b;
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `B` is defined here
--> $DIR/privacy5.rs:7:5
|
LL | pub struct B(isize);
| ^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `B` is private
--> $DIR/privacy5.rs:62:12
@ -77,7 +125,13 @@ LL | pub struct B(isize);
| ----- a constructor is private if any of the fields is private
...
LL | let a::B(_b) = b;
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `B` is defined here
--> $DIR/privacy5.rs:7:5
|
LL | pub struct B(isize);
| ^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `B` is private
--> $DIR/privacy5.rs:63:18
@ -86,7 +140,13 @@ LL | pub struct B(isize);
| ----- a constructor is private if any of the fields is private
...
LL | match b { a::B(_) => {} }
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `B` is defined here
--> $DIR/privacy5.rs:7:5
|
LL | pub struct B(isize);
| ^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `B` is private
--> $DIR/privacy5.rs:64:18
@ -95,7 +155,13 @@ LL | pub struct B(isize);
| ----- a constructor is private if any of the fields is private
...
LL | match b { a::B(_b) => {} }
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `B` is defined here
--> $DIR/privacy5.rs:7:5
|
LL | pub struct B(isize);
| ^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `B` is private
--> $DIR/privacy5.rs:65:18
@ -104,7 +170,13 @@ LL | pub struct B(isize);
| ----- a constructor is private if any of the fields is private
...
LL | match b { a::B(1) => {} a::B(_) => {} }
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `B` is defined here
--> $DIR/privacy5.rs:7:5
|
LL | pub struct B(isize);
| ^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `B` is private
--> $DIR/privacy5.rs:65:32
@ -113,7 +185,13 @@ LL | pub struct B(isize);
| ----- a constructor is private if any of the fields is private
...
LL | match b { a::B(1) => {} a::B(_) => {} }
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `B` is defined here
--> $DIR/privacy5.rs:7:5
|
LL | pub struct B(isize);
| ^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:68:12
@ -122,7 +200,13 @@ LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
...
LL | let a::C(_, _) = c;
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/privacy5.rs:8:5
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:69:12
@ -131,7 +215,13 @@ LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
...
LL | let a::C(_a, _) = c;
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/privacy5.rs:8:5
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:70:12
@ -140,7 +230,13 @@ LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
...
LL | let a::C(_, _b) = c;
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/privacy5.rs:8:5
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:71:12
@ -149,7 +245,13 @@ LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
...
LL | let a::C(_a, _b) = c;
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/privacy5.rs:8:5
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:72:18
@ -158,7 +260,13 @@ LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
...
LL | match c { a::C(_, _) => {} }
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/privacy5.rs:8:5
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:73:18
@ -167,7 +275,13 @@ LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
...
LL | match c { a::C(_a, _) => {} }
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/privacy5.rs:8:5
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:74:18
@ -176,7 +290,13 @@ LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
...
LL | match c { a::C(_, _b) => {} }
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/privacy5.rs:8:5
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:75:18
@ -185,7 +305,13 @@ LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
...
LL | match c { a::C(_a, _b) => {} }
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/privacy5.rs:8:5
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `A` is private
--> $DIR/privacy5.rs:83:17
@ -194,7 +320,13 @@ LL | pub struct A(());
| -- a constructor is private if any of the fields is private
...
LL | let a2 = a::A;
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `A` is defined here
--> $DIR/privacy5.rs:6:5
|
LL | pub struct A(());
| ^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `B` is private
--> $DIR/privacy5.rs:84:17
@ -203,7 +335,13 @@ LL | pub struct B(isize);
| ----- a constructor is private if any of the fields is private
...
LL | let b2 = a::B;
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `B` is defined here
--> $DIR/privacy5.rs:7:5
|
LL | pub struct B(isize);
| ^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:85:17
@ -212,271 +350,421 @@ LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
...
LL | let c2 = a::C;
| ^
| ^ this tuple struct constructor is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/privacy5.rs:8:5
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `A` is private
--> $DIR/privacy5.rs:90:20
|
LL | let a = other::A(());
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:1:14
|
LL | pub struct A(());
| -- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `A` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:1:1
|
LL | pub struct A(());
| ^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `B` is private
--> $DIR/privacy5.rs:91:20
|
LL | let b = other::B(2);
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14
|
LL | pub struct B(isize);
| ----- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `B` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:2:1
|
LL | pub struct B(isize);
| ^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:92:20
|
LL | let c = other::C(2, 3);
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14
|
LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:3:1
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `A` is private
--> $DIR/privacy5.rs:95:16
|
LL | let other::A(()) = a;
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:1:14
|
LL | pub struct A(());
| -- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `A` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:1:1
|
LL | pub struct A(());
| ^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `A` is private
--> $DIR/privacy5.rs:96:16
|
LL | let other::A(_) = a;
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:1:14
|
LL | pub struct A(());
| -- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `A` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:1:1
|
LL | pub struct A(());
| ^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `A` is private
--> $DIR/privacy5.rs:97:22
|
LL | match a { other::A(()) => {} }
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:1:14
|
LL | pub struct A(());
| -- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `A` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:1:1
|
LL | pub struct A(());
| ^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `A` is private
--> $DIR/privacy5.rs:98:22
|
LL | match a { other::A(_) => {} }
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:1:14
|
LL | pub struct A(());
| -- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `A` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:1:1
|
LL | pub struct A(());
| ^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `B` is private
--> $DIR/privacy5.rs:100:16
|
LL | let other::B(_) = b;
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14
|
LL | pub struct B(isize);
| ----- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `B` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:2:1
|
LL | pub struct B(isize);
| ^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `B` is private
--> $DIR/privacy5.rs:101:16
|
LL | let other::B(_b) = b;
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14
|
LL | pub struct B(isize);
| ----- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `B` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:2:1
|
LL | pub struct B(isize);
| ^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `B` is private
--> $DIR/privacy5.rs:102:22
|
LL | match b { other::B(_) => {} }
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14
|
LL | pub struct B(isize);
| ----- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `B` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:2:1
|
LL | pub struct B(isize);
| ^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `B` is private
--> $DIR/privacy5.rs:103:22
|
LL | match b { other::B(_b) => {} }
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14
|
LL | pub struct B(isize);
| ----- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `B` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:2:1
|
LL | pub struct B(isize);
| ^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `B` is private
--> $DIR/privacy5.rs:104:22
|
LL | match b { other::B(1) => {}
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14
|
LL | pub struct B(isize);
| ----- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `B` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:2:1
|
LL | pub struct B(isize);
| ^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `B` is private
--> $DIR/privacy5.rs:105:16
|
LL | other::B(_) => {} }
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14
|
LL | pub struct B(isize);
| ----- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `B` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:2:1
|
LL | pub struct B(isize);
| ^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:107:16
|
LL | let other::C(_, _) = c;
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14
|
LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:3:1
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:108:16
|
LL | let other::C(_a, _) = c;
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14
|
LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:3:1
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:109:16
|
LL | let other::C(_, _b) = c;
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14
|
LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:3:1
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:110:16
|
LL | let other::C(_a, _b) = c;
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14
|
LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:3:1
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:111:22
|
LL | match c { other::C(_, _) => {} }
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14
|
LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:3:1
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:112:22
|
LL | match c { other::C(_a, _) => {} }
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14
|
LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:3:1
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:113:22
|
LL | match c { other::C(_, _b) => {} }
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14
|
LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:3:1
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:114:22
|
LL | match c { other::C(_a, _b) => {} }
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14
|
LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:3:1
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `A` is private
--> $DIR/privacy5.rs:122:21
|
LL | let a2 = other::A;
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:1:14
|
LL | pub struct A(());
| -- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `A` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:1:1
|
LL | pub struct A(());
| ^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `B` is private
--> $DIR/privacy5.rs:123:21
|
LL | let b2 = other::B;
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:2:14
|
LL | pub struct B(isize);
| ----- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `B` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:2:1
|
LL | pub struct B(isize);
| ^^^^^^^^^^^^^^^^^^^^
error[E0603]: tuple struct constructor `C` is private
--> $DIR/privacy5.rs:124:21
|
LL | let c2 = other::C;
| ^
| ^ this tuple struct constructor is private
|
::: $DIR/auxiliary/privacy_tuple_struct.rs:3:14
|
LL | pub struct C(pub isize, isize);
| ---------------- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `C` is defined here
--> $DIR/auxiliary/privacy_tuple_struct.rs:3:1
|
LL | pub struct C(pub isize, isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 48 previous errors

View file

@ -2,7 +2,13 @@ error[E0603]: function `f` is private
--> $DIR/private-item-simple.rs:6:8
|
LL | a::f();
| ^
| ^ this function is private
|
note: the function `f` is defined here
--> $DIR/private-item-simple.rs:2:5
|
LL | fn f() {}
| ^^^^^^
error: aborting due to previous error

View file

@ -26,13 +26,25 @@ error[E0603]: struct `Crate` is private
--> $DIR/test.rs:38:25
|
LL | use pub_restricted::Crate;
| ^^^^^
| ^^^^^ this struct is private
|
note: the struct `Crate` is defined here
--> $DIR/auxiliary/pub_restricted.rs:3:1
|
LL | pub(crate) struct Crate;
| ^^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: function `f` is private
--> $DIR/test.rs:30:19
|
LL | use foo::bar::f;
| ^
| ^ this function is private
|
note: the function `f` is defined here
--> $DIR/test.rs:8:9
|
LL | pub(super) fn f() {}
| ^^^^^^^^^^^^^^^^^
error[E0616]: field `x` of struct `foo::bar::S` is private
--> $DIR/test.rs:31:5

View file

@ -8,7 +8,7 @@ extern crate test_macros;
mod m {
use test_macros::Empty;
}
use m::Empty; //~ ERROR derive macro `Empty` is private
use m::Empty; //~ ERROR derive macro import `Empty` is private
// To resolve `empty_helper` we need to resolve `Empty`.
// During initial resolution `use m::Empty` introduces no entries, so we proceed to `macro_use`,

View file

@ -4,11 +4,17 @@ error: cannot find attribute `empty_helper` in this scope
LL | #[empty_helper]
| ^^^^^^^^^^^^
error[E0603]: derive macro `Empty` is private
error[E0603]: derive macro import `Empty` is private
--> $DIR/disappearing-resolution.rs:11:8
|
LL | use m::Empty;
| ^^^^^
| ^^^^^ this derive macro import is private
|
note: the derive macro import `Empty` is defined here
--> $DIR/disappearing-resolution.rs:9:9
|
LL | use test_macros::Empty;
| ^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

Some files were not shown because too many files have changed in this diff Show more