提交 3e1cef70 编写于 作者: E Eduard-Mihai Burtescu

rustc: pass Option<&Substs> and Namespace around in ty::item_path.

上级 ed2be6fa
use crate::hir::def::Namespace;
use crate::hir::map::DefPathData; use crate::hir::map::DefPathData;
use crate::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use crate::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
use crate::ty::{self, DefIdTree, Ty, TyCtxt}; use crate::ty::{self, DefIdTree, Ty, TyCtxt};
use crate::ty::print::PrintCx;
use crate::ty::subst::{Subst, Substs};
use crate::middle::cstore::{ExternCrate, ExternCrateSource}; use crate::middle::cstore::{ExternCrate, ExternCrateSource};
use ty::print::PrintCx;
use syntax::ast; use syntax::ast;
use syntax::symbol::{keywords, Symbol}; use syntax::symbol::{keywords, Symbol};
...@@ -54,18 +56,48 @@ pub fn with_crate_prefix<F: FnOnce() -> R, R>(f: F) -> R { ...@@ -54,18 +56,48 @@ pub fn with_crate_prefix<F: FnOnce() -> R, R>(f: F) -> R {
} }
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
// HACK(eddyb) get rid of `item_path_str` and/or pass `Namespace` explicitly always
// (but also some things just print a `DefId` generally so maybe we need this?)
fn guess_def_namespace(self, def_id: DefId) -> Namespace {
match self.def_key(def_id).disambiguated_data.data {
DefPathData::ValueNs(..) |
DefPathData::EnumVariant(..) |
DefPathData::Field(..) |
DefPathData::AnonConst |
DefPathData::ClosureExpr |
DefPathData::StructCtor => Namespace::ValueNS,
DefPathData::MacroDef(..) => Namespace::MacroNS,
_ => Namespace::TypeNS,
}
}
/// Returns a string identifying this `DefId`. This string is /// Returns a string identifying this `DefId`. This string is
/// suitable for user output. It is relative to the current crate /// suitable for user output. It is relative to the current crate
/// root, unless with_forced_absolute_paths was used. /// root, unless with_forced_absolute_paths was used.
pub fn item_path_str(self, def_id: DefId) -> String { pub fn item_path_str_with_substs_and_ns(
debug!("item_path_str: def_id={:?}", def_id); self,
def_id: DefId,
substs: Option<&Substs<'tcx>>,
ns: Namespace,
) -> String {
debug!("item_path_str: def_id={:?}, substs={:?}, ns={:?}", def_id, substs, ns);
if FORCE_ABSOLUTE.with(|force| force.get()) { if FORCE_ABSOLUTE.with(|force| force.get()) {
PrintCx::new(self, AbsolutePathPrinter).print_item_path(def_id) PrintCx::new(self, AbsolutePathPrinter).print_item_path(def_id, substs, ns)
} else { } else {
PrintCx::new(self, LocalPathPrinter).print_item_path(def_id) PrintCx::new(self, LocalPathPrinter).print_item_path(def_id, substs, ns)
} }
} }
/// Returns a string identifying this def-id. This string is
/// suitable for user output. It is relative to the current crate
/// root, unless with_forced_absolute_paths was used.
pub fn item_path_str(self, def_id: DefId) -> String {
let ns = self.guess_def_namespace(def_id);
self.item_path_str_with_substs_and_ns(def_id, None, ns)
}
/// Returns a string identifying this local node-id. /// Returns a string identifying this local node-id.
pub fn node_path_str(self, id: ast::NodeId) -> String { pub fn node_path_str(self, id: ast::NodeId) -> String {
self.item_path_str(self.hir().local_def_id(id)) self.item_path_str(self.hir().local_def_id(id))
...@@ -75,13 +107,19 @@ pub fn node_path_str(self, id: ast::NodeId) -> String { ...@@ -75,13 +107,19 @@ pub fn node_path_str(self, id: ast::NodeId) -> String {
/// suitable for user output. It always begins with a crate identifier. /// suitable for user output. It always begins with a crate identifier.
pub fn absolute_item_path_str(self, def_id: DefId) -> String { pub fn absolute_item_path_str(self, def_id: DefId) -> String {
debug!("absolute_item_path_str: def_id={:?}", def_id); debug!("absolute_item_path_str: def_id={:?}", def_id);
PrintCx::new(self, AbsolutePathPrinter).print_item_path(def_id) let ns = self.guess_def_namespace(def_id);
PrintCx::new(self, AbsolutePathPrinter).print_item_path(def_id, None, ns)
} }
} }
impl<P: ItemPathPrinter> PrintCx<'a, 'gcx, 'tcx, P> { impl<P: ItemPathPrinter> PrintCx<'a, 'gcx, 'tcx, P> {
pub fn default_print_item_path(&mut self, def_id: DefId) -> P::Path { pub fn default_print_item_path(
debug!("default_print_item_path: def_id={:?}", def_id); &mut self,
def_id: DefId,
substs: Option<&Substs<'tcx>>,
ns: Namespace,
) -> P::Path {
debug!("default_print_item_path: def_id={:?}, substs={:?}, ns={:?}", def_id, substs, ns);
let key = self.tcx.def_key(def_id); let key = self.tcx.def_key(def_id);
debug!("default_print_item_path: key={:?}", key); debug!("default_print_item_path: key={:?}", key);
match key.disambiguated_data.data { match key.disambiguated_data.data {
...@@ -91,7 +129,7 @@ pub fn default_print_item_path(&mut self, def_id: DefId) -> P::Path { ...@@ -91,7 +129,7 @@ pub fn default_print_item_path(&mut self, def_id: DefId) -> P::Path {
} }
DefPathData::Impl => { DefPathData::Impl => {
self.print_impl_path(def_id) self.print_impl_path(def_id, substs, ns)
} }
// Unclear if there is any value in distinguishing these. // Unclear if there is any value in distinguishing these.
...@@ -117,18 +155,23 @@ pub fn default_print_item_path(&mut self, def_id: DefId) -> P::Path { ...@@ -117,18 +155,23 @@ pub fn default_print_item_path(&mut self, def_id: DefId) -> P::Path {
data @ DefPathData::ImplTrait | data @ DefPathData::ImplTrait |
data @ DefPathData::GlobalMetaData(..) => { data @ DefPathData::GlobalMetaData(..) => {
let parent_did = self.tcx.parent_def_id(def_id).unwrap(); let parent_did = self.tcx.parent_def_id(def_id).unwrap();
let path = self.print_item_path(parent_did); let path = self.print_item_path(parent_did, None, ns);
self.path_append(path, &data.as_interned_str().as_symbol().as_str()) self.path_append(path, &data.as_interned_str().as_symbol().as_str())
}, },
DefPathData::StructCtor => { // present `X` instead of `X::{{constructor}}` DefPathData::StructCtor => { // present `X` instead of `X::{{constructor}}`
let parent_def_id = self.tcx.parent_def_id(def_id).unwrap(); let parent_def_id = self.tcx.parent_def_id(def_id).unwrap();
self.print_item_path(parent_def_id) self.print_item_path(parent_def_id, substs, ns)
} }
} }
} }
fn default_print_impl_path(&mut self, impl_def_id: DefId) -> P::Path { fn default_print_impl_path(
&mut self,
impl_def_id: DefId,
substs: Option<&Substs<'tcx>>,
ns: Namespace,
) -> P::Path {
debug!("default_print_impl_path: impl_def_id={:?}", impl_def_id); debug!("default_print_impl_path: impl_def_id={:?}", impl_def_id);
let parent_def_id = self.tcx.parent_def_id(impl_def_id).unwrap(); let parent_def_id = self.tcx.parent_def_id(impl_def_id).unwrap();
...@@ -137,13 +180,19 @@ fn default_print_impl_path(&mut self, impl_def_id: DefId) -> P::Path { ...@@ -137,13 +180,19 @@ fn default_print_impl_path(&mut self, impl_def_id: DefId) -> P::Path {
// users may find it useful. Currently, we omit the parent if // users may find it useful. Currently, we omit the parent if
// the impl is either in the same module as the self-type or // the impl is either in the same module as the self-type or
// as the trait. // as the trait.
let self_ty = self.tcx.type_of(impl_def_id); let mut self_ty = self.tcx.type_of(impl_def_id);
if let Some(substs) = substs {
self_ty = self_ty.subst(self.tcx, substs);
}
let in_self_mod = match characteristic_def_id_of_type(self_ty) { let in_self_mod = match characteristic_def_id_of_type(self_ty) {
None => false, None => false,
Some(ty_def_id) => self.tcx.parent_def_id(ty_def_id) == Some(parent_def_id), Some(ty_def_id) => self.tcx.parent_def_id(ty_def_id) == Some(parent_def_id),
}; };
let impl_trait_ref = self.tcx.impl_trait_ref(impl_def_id); let mut impl_trait_ref = self.tcx.impl_trait_ref(impl_def_id);
if let Some(substs) = substs {
impl_trait_ref = impl_trait_ref.subst(self.tcx, substs);
}
let in_trait_mod = match impl_trait_ref { let in_trait_mod = match impl_trait_ref {
None => false, None => false,
Some(trait_ref) => self.tcx.parent_def_id(trait_ref.def_id) == Some(parent_def_id), Some(trait_ref) => self.tcx.parent_def_id(trait_ref.def_id) == Some(parent_def_id),
...@@ -153,7 +202,7 @@ fn default_print_impl_path(&mut self, impl_def_id: DefId) -> P::Path { ...@@ -153,7 +202,7 @@ fn default_print_impl_path(&mut self, impl_def_id: DefId) -> P::Path {
// If the impl is not co-located with either self-type or // If the impl is not co-located with either self-type or
// trait-type, then fallback to a format that identifies // trait-type, then fallback to a format that identifies
// the module more clearly. // the module more clearly.
let path = self.print_item_path(parent_def_id); let path = self.print_item_path(parent_def_id, None, ns);
if let Some(trait_ref) = impl_trait_ref { if let Some(trait_ref) = impl_trait_ref {
return self.path_append(path, &format!("<impl {} for {}>", trait_ref, self_ty)); return self.path_append(path, &format!("<impl {} for {}>", trait_ref, self_ty));
} else { } else {
...@@ -174,15 +223,14 @@ fn default_print_impl_path(&mut self, impl_def_id: DefId) -> P::Path { ...@@ -174,15 +223,14 @@ fn default_print_impl_path(&mut self, impl_def_id: DefId) -> P::Path {
// anything other than a simple path. // anything other than a simple path.
match self_ty.sty { match self_ty.sty {
ty::Adt(adt_def, substs) => { ty::Adt(adt_def, substs) => {
// FIXME(eddyb) always print without <> here. // FIXME(eddyb) this should recurse to build the path piecewise.
if substs.types().next().is_none() { // ignore regions // self.print_item_path(adt_def.did, Some(substs), ns)
self.print_item_path(adt_def.did) let mut s = String::new();
} else { crate::util::ppaux::parameterized(&mut s, adt_def.did, substs, ns).unwrap();
self.path_impl(&format!("<{}>", self_ty)) self.path_impl(&s)
}
} }
ty::Foreign(did) => self.print_item_path(did), ty::Foreign(did) => self.print_item_path(did, None, ns),
ty::Bool | ty::Bool |
ty::Char | ty::Char |
...@@ -263,11 +311,21 @@ pub fn characteristic_def_id_of_type(ty: Ty<'_>) -> Option<DefId> { ...@@ -263,11 +311,21 @@ pub fn characteristic_def_id_of_type(ty: Ty<'_>) -> Option<DefId> {
pub trait ItemPathPrinter: Sized { pub trait ItemPathPrinter: Sized {
type Path; type Path;
fn print_item_path(self: &mut PrintCx<'_, '_, '_, Self>, def_id: DefId) -> Self::Path { fn print_item_path(
self.default_print_item_path(def_id) self: &mut PrintCx<'_, '_, 'tcx, Self>,
def_id: DefId,
substs: Option<&Substs<'tcx>>,
ns: Namespace,
) -> Self::Path {
self.default_print_item_path(def_id, substs, ns)
} }
fn print_impl_path(self: &mut PrintCx<'_, '_, '_, Self>, impl_def_id: DefId) -> Self::Path { fn print_impl_path(
self.default_print_impl_path(impl_def_id) self: &mut PrintCx<'_, '_, 'tcx, Self>,
impl_def_id: DefId,
substs: Option<&Substs<'tcx>>,
ns: Namespace,
) -> Self::Path {
self.default_print_impl_path(impl_def_id, substs, ns)
} }
fn path_crate(self: &mut PrintCx<'_, '_, '_, Self>, cnum: CrateNum) -> Self::Path; fn path_crate(self: &mut PrintCx<'_, '_, '_, Self>, cnum: CrateNum) -> Self::Path;
...@@ -312,6 +370,7 @@ impl LocalPathPrinter { ...@@ -312,6 +370,7 @@ impl LocalPathPrinter {
fn try_print_visible_item_path( fn try_print_visible_item_path(
self: &mut PrintCx<'_, '_, '_, Self>, self: &mut PrintCx<'_, '_, '_, Self>,
def_id: DefId, def_id: DefId,
ns: Namespace,
) -> Option<<Self as ItemPathPrinter>::Path> { ) -> Option<<Self as ItemPathPrinter>::Path> {
debug!("try_print_visible_item_path: def_id={:?}", def_id); debug!("try_print_visible_item_path: def_id={:?}", def_id);
...@@ -343,7 +402,7 @@ fn try_print_visible_item_path( ...@@ -343,7 +402,7 @@ fn try_print_visible_item_path(
}) => { }) => {
debug!("try_print_visible_item_path: def_id={:?}", def_id); debug!("try_print_visible_item_path: def_id={:?}", def_id);
let path = if !span.is_dummy() { let path = if !span.is_dummy() {
self.print_item_path(def_id) self.print_item_path(def_id, None, ns)
} else { } else {
self.path_crate(cnum) self.path_crate(cnum)
}; };
...@@ -376,7 +435,7 @@ fn try_print_visible_item_path( ...@@ -376,7 +435,7 @@ fn try_print_visible_item_path(
} }
let visible_parent = visible_parent_map.get(&def_id).cloned()?; let visible_parent = visible_parent_map.get(&def_id).cloned()?;
let path = self.try_print_visible_item_path(visible_parent)?; let path = self.try_print_visible_item_path(visible_parent, ns)?;
let actual_parent = self.tcx.parent(def_id); let actual_parent = self.tcx.parent(def_id);
let data = cur_def_key.disambiguated_data.data; let data = cur_def_key.disambiguated_data.data;
...@@ -444,11 +503,21 @@ fn try_print_visible_item_path( ...@@ -444,11 +503,21 @@ fn try_print_visible_item_path(
impl ItemPathPrinter for LocalPathPrinter { impl ItemPathPrinter for LocalPathPrinter {
type Path = String; type Path = String;
fn print_item_path(self: &mut PrintCx<'_, '_, '_, Self>, def_id: DefId) -> Self::Path { fn print_item_path(
self.try_print_visible_item_path(def_id) self: &mut PrintCx<'_, '_, 'tcx, Self>,
.unwrap_or_else(|| self.default_print_item_path(def_id)) def_id: DefId,
} substs: Option<&Substs<'tcx>>,
fn print_impl_path(self: &mut PrintCx<'_, '_, '_, Self>, impl_def_id: DefId) -> Self::Path { ns: Namespace,
) -> Self::Path {
self.try_print_visible_item_path(def_id, ns)
.unwrap_or_else(|| self.default_print_item_path(def_id, substs, ns))
}
fn print_impl_path(
self: &mut PrintCx<'_, '_, 'tcx, Self>,
impl_def_id: DefId,
substs: Option<&Substs<'tcx>>,
ns: Namespace,
) -> Self::Path {
// Always use types for non-local impls, where types are always // Always use types for non-local impls, where types are always
// available, and filename/line-number is mostly uninteresting. // available, and filename/line-number is mostly uninteresting.
let use_types = !impl_def_id.is_local() || { let use_types = !impl_def_id.is_local() || {
...@@ -463,12 +532,12 @@ fn print_impl_path(self: &mut PrintCx<'_, '_, '_, Self>, impl_def_id: DefId) -> ...@@ -463,12 +532,12 @@ fn print_impl_path(self: &mut PrintCx<'_, '_, '_, Self>, impl_def_id: DefId) ->
// only occur very early in the compiler pipeline. // only occur very early in the compiler pipeline.
// FIXME(eddyb) this should just be using `tcx.def_span(impl_def_id)` // FIXME(eddyb) this should just be using `tcx.def_span(impl_def_id)`
let parent_def_id = self.tcx.parent_def_id(impl_def_id).unwrap(); let parent_def_id = self.tcx.parent_def_id(impl_def_id).unwrap();
let path = self.print_item_path(parent_def_id); let path = self.print_item_path(parent_def_id, None, ns);
let span = self.tcx.def_span(impl_def_id); let span = self.tcx.def_span(impl_def_id);
return self.path_append(path, &format!("<impl at {:?}>", span)); return self.path_append(path, &format!("<impl at {:?}>", span));
} }
self.default_print_impl_path(impl_def_id) self.default_print_impl_path(impl_def_id, substs, ns)
} }
fn path_crate(self: &mut PrintCx<'_, '_, '_, Self>, cnum: CrateNum) -> Self::Path { fn path_crate(self: &mut PrintCx<'_, '_, '_, Self>, cnum: CrateNum) -> Self::Path {
......
...@@ -317,23 +317,15 @@ fn parameterized( ...@@ -317,23 +317,15 @@ fn parameterized(
} }
} }
} else { } else {
// Try to print `impl`s more like how you'd refer to their associated items. // FIXME(eddyb) recurse through printing a path via `self`, instead
if let DefPathData::Impl = key.disambiguated_data.data { // instead of using the `tcx` method that produces a `String`.
if let Some(trait_ref) = self.tcx.impl_trait_ref(def_id) { print!(self, write("{}",
// HACK(eddyb) this is in lieu of more specific disambiguation. self.tcx.item_path_str_with_substs_and_ns(def_id, Some(substs), ns)))?;
print!(self, write("{}", self.tcx.item_path_str(def_id)))?;
let trait_ref = trait_ref.subst(self.tcx, substs); // For impls, the above call already prints relevant generics args.
print!(self, print_debug(trait_ref))?; if let DefPathData::Impl = key.disambiguated_data.data {
} else {
let self_ty = self.tcx.type_of(def_id).subst(self.tcx, substs);
// FIXME(eddyb) omit the <> where possible.
print!(self, write("<"), print(self_ty), write(">"))?;
}
return Ok(()); return Ok(());
} }
print!(self, write("{}", self.tcx.item_path_str(def_id)))?;
} }
let mut empty = true; let mut empty = true;
......
...@@ -87,6 +87,7 @@ ...@@ -87,6 +87,7 @@
//! virtually impossible. Thus, symbol hash generation exclusively relies on //! virtually impossible. Thus, symbol hash generation exclusively relies on
//! DefPaths which are much more robust in the face of changes to the code base. //! DefPaths which are much more robust in the face of changes to the code base.
use rustc::hir::def::Namespace;
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc::hir::Node; use rustc::hir::Node;
use rustc::hir::CodegenFnAttrFlags; use rustc::hir::CodegenFnAttrFlags;
...@@ -225,7 +226,9 @@ fn get_symbol_hash<'a, 'tcx>( ...@@ -225,7 +226,9 @@ fn get_symbol_hash<'a, 'tcx>(
fn def_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::SymbolName { fn def_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::SymbolName {
item_path::with_forced_absolute_paths(|| { item_path::with_forced_absolute_paths(|| {
PrintCx::new(tcx, SymbolPathPrinter).print_item_path(def_id).into_interned() PrintCx::new(tcx, SymbolPathPrinter)
.print_item_path(def_id, None, Namespace::ValueNS)
.into_interned()
}) })
} }
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
use rustc::middle::stability; use rustc::middle::stability;
use rustc::mir::interpret::GlobalId; use rustc::mir::interpret::GlobalId;
use rustc::hir::{self, GenericArg, HirVec}; use rustc::hir::{self, GenericArg, HirVec};
use rustc::hir::def::{self, Def, CtorKind}; use rustc::hir::def::{self, Def, CtorKind, Namespace};
use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
use rustc::ty::subst::{InternalSubsts, SubstsRef}; use rustc::ty::subst::{InternalSubsts, SubstsRef};
use rustc::ty::{self, TyCtxt, Region, RegionVid, Ty, AdtKind}; use rustc::ty::{self, TyCtxt, Region, RegionVid, Ty, AdtKind};
...@@ -4249,7 +4249,8 @@ fn path_append( ...@@ -4249,7 +4249,8 @@ fn path_append(
} }
} }
let names = PrintCx::new(tcx, AbsolutePathPrinter).print_item_path(def_id); let names = PrintCx::new(tcx, AbsolutePathPrinter)
.print_item_path(def_id, None, Namespace::TypeNS);
hir::Path { hir::Path {
span: DUMMY_SP, span: DUMMY_SP,
......
...@@ -32,7 +32,7 @@ pub fn bar() ({ ...@@ -32,7 +32,7 @@ pub fn bar() ({
(($crate::fmt::format as (($crate::fmt::format as
for<'r> fn(std::fmt::Arguments<'r>) -> std::string::String {std::fmt::format})(((<$crate::fmt::Arguments>::new_v1 for<'r> fn(std::fmt::Arguments<'r>) -> std::string::String {std::fmt::format})(((<$crate::fmt::Arguments>::new_v1
as as
fn(&[&str], &[std::fmt::ArgumentV1<'_>]) -> std::fmt::Arguments<'_> {std::fmt::Arguments<'_>::new_v1})((&([("test" fn(&[&str], &[std::fmt::ArgumentV1<'_>]) -> std::fmt::Arguments<'_> {std::fmt::Arguments::<'_>::new_v1})((&([("test"
as as
&'static str)] &'static str)]
as as
......
...@@ -22,7 +22,7 @@ LL | let x: Vec<Trait + Sized> = Vec::new(); ...@@ -22,7 +22,7 @@ LL | let x: Vec<Trait + Sized> = Vec::new();
| |
= help: the trait `std::marker::Sized` is not implemented for `dyn Trait` = help: the trait `std::marker::Sized` is not implemented for `dyn Trait`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = 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 by `<std::vec::Vec<T>>::new` = note: required by `std::vec::Vec::<T>::new`
error: aborting due to 3 previous errors error: aborting due to 3 previous errors
......
...@@ -4,7 +4,7 @@ error[E0493]: destructors cannot be evaluated at compile-time ...@@ -4,7 +4,7 @@ error[E0493]: destructors cannot be evaluated at compile-time
LL | const F: u32 = (U::X, 42).1; LL | const F: u32 = (U::X, 42).1;
| ^^^^^^^^^^ constants cannot evaluate destructors | ^^^^^^^^^^ constants cannot evaluate destructors
error: `<std::vec::Vec<T>>::new` is not yet stable as a const fn error: `std::vec::Vec::<T>::new` is not yet stable as a const fn
--> $DIR/feature-gate-unleash_the_miri_inside_of_you.rs:18:25 --> $DIR/feature-gate-unleash_the_miri_inside_of_you.rs:18:25
| |
LL | const X: Vec<u32> = Vec::new(); LL | const X: Vec<u32> = Vec::new();
......
...@@ -9,7 +9,7 @@ fn f(&self) {} ...@@ -9,7 +9,7 @@ fn f(&self) {}
} }
pub macro m() { pub macro m() {
let _: () = S.f(); //~ ERROR type `for<'r> fn(&'r foo::S) {<foo::S>::f}` is private let _: () = S.f(); //~ ERROR type `for<'r> fn(&'r foo::S) {foo::S::f}` is private
} }
} }
......
error: type `for<'r> fn(&'r foo::S) {<foo::S>::f}` is private error: type `for<'r> fn(&'r foo::S) {foo::S::f}` is private
--> $DIR/impl_items.rs:12:23 --> $DIR/impl_items.rs:12:23
| |
LL | let _: () = S.f(); LL | let _: () = S.f();
......
...@@ -6,7 +6,7 @@ LL | (|| Box::new(*(&[0][..])))(); ...@@ -6,7 +6,7 @@ LL | (|| Box::new(*(&[0][..])))();
| |
= help: the trait `std::marker::Sized` is not implemented for `[{integer}]` = help: the trait `std::marker::Sized` is not implemented for `[{integer}]`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = 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 by `<std::boxed::Box<T>>::new` = note: required by `std::boxed::Box::<T>::new`
error: aborting due to previous error error: aborting due to previous error
......
...@@ -50,7 +50,7 @@ pub fn matches<F: Fn()>(&self, f: &F) { ...@@ -50,7 +50,7 @@ pub fn matches<F: Fn()>(&self, f: &F) {
impl D { impl D {
pub fn matches<F: Fn()>(&self, f: &F) { pub fn matches<F: Fn()>(&self, f: &F) {
//~^ ERROR reached the type-length limit while instantiating `<D>::matches::<[closure //~^ ERROR reached the type-length limit while instantiating `D::matches::<[closure
let &D(ref a) = self; let &D(ref a) = self;
a.matches(f) a.matches(f)
} }
......
error: reached the type-length limit while instantiating `<D>::matches::$CLOSURE` error: reached the type-length limit while instantiating `D::matches::$CLOSURE`
--> $DIR/issue-22638.rs:52:5 --> $DIR/issue-22638.rs:52:5
| |
LL | / pub fn matches<F: Fn()>(&self, f: &F) { LL | / pub fn matches<F: Fn()>(&self, f: &F) {
......
...@@ -5,7 +5,7 @@ LL | let x: &fn(&B) -> u32 = &B::func; ...@@ -5,7 +5,7 @@ LL | let x: &fn(&B) -> u32 = &B::func;
| ^^^^^^^^ expected fn pointer, found fn item | ^^^^^^^^ expected fn pointer, found fn item
| |
= note: expected type `&for<'r> fn(&'r B) -> u32` = note: expected type `&for<'r> fn(&'r B) -> u32`
found type `&for<'r> fn(&'r B) -> u32 {<B>::func}` found type `&for<'r> fn(&'r B) -> u32 {B::func}`
error: aborting due to previous error error: aborting due to previous error
......
...@@ -13,7 +13,7 @@ fn func() -> Ret { ...@@ -13,7 +13,7 @@ fn func() -> Ret {
fn main() { fn main() {
Obj::func.x(); Obj::func.x();
//~^ ERROR no method named `x` found for type `fn() -> Ret {<Obj>::func}` in the current scope //~^ ERROR no method named `x` found for type `fn() -> Ret {Obj::func}` in the current scope
func.x(); func.x();
//~^ ERROR no method named `x` found for type `fn() -> Ret {func}` in the current scope //~^ ERROR no method named `x` found for type `fn() -> Ret {func}` in the current scope
} }
error[E0599]: no method named `x` found for type `fn() -> Ret {<Obj>::func}` in the current scope error[E0599]: no method named `x` found for type `fn() -> Ret {Obj::func}` in the current scope
--> $DIR/issue-29124.rs:15:15 --> $DIR/issue-29124.rs:15:15
| |
LL | Obj::func.x(); LL | Obj::func.x();
......
error: reached the type-length limit while instantiating `<T as Foo><(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(), &()), &(&()...` error: reached the type-length limit while instantiating `<(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(&(), &()), &(&(), &())), &...`
--> $DIR/issue-37311.rs:13:5 --> $DIR/issue-37311.rs:13:5
| |
LL | / fn recurse(&self) { LL | / fn recurse(&self) {
......
...@@ -8,7 +8,7 @@ error[E0080]: evaluation of constant value failed ...@@ -8,7 +8,7 @@ error[E0080]: evaluation of constant value failed
--> $DIR/issue-39559-2.rs:14:24 --> $DIR/issue-39559-2.rs:14:24
| |
LL | let array: [usize; Dim3::dim()] LL | let array: [usize; Dim3::dim()]
| ^^^^^^^^^^^ calling non-const function `<Dim3 as Dim><Dim3 as Dim>::dim` | ^^^^^^^^^^^ calling non-const function `<Dim3 as Dim>::dim`
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
--> $DIR/issue-39559-2.rs:17:15 --> $DIR/issue-39559-2.rs:17:15
...@@ -20,7 +20,7 @@ error[E0080]: evaluation of constant value failed ...@@ -20,7 +20,7 @@ error[E0080]: evaluation of constant value failed
--> $DIR/issue-39559-2.rs:17:15 --> $DIR/issue-39559-2.rs:17:15
| |
LL | = [0; Dim3::dim()]; LL | = [0; Dim3::dim()];
| ^^^^^^^^^^^ calling non-const function `<Dim3 as Dim><Dim3 as Dim>::dim` | ^^^^^^^^^^^ calling non-const function `<Dim3 as Dim>::dim`
error: aborting due to 4 previous errors error: aborting due to 4 previous errors
......
...@@ -11,11 +11,11 @@ fn method(&self) {} ...@@ -11,11 +11,11 @@ fn method(&self) {}
pub macro mac() { pub macro mac() {
let value = Pub::method; let value = Pub::method;
//~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {<priv_nominal::Pub>::method}` is private //~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private
value; value;
//~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {<priv_nominal::Pub>::method}` is private //~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private
Pub.method(); Pub.method();
//~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {<priv_nominal::Pub>::method}` is private //~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private
Pub::CONST; Pub::CONST;
//~^ ERROR associated constant `CONST` is private //~^ ERROR associated constant `CONST` is private
// let _: Pub::AssocTy; // let _: Pub::AssocTy;
......
error: type `for<'r> fn(&'r priv_nominal::Pub) {<priv_nominal::Pub>::method}` is private error: type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private
--> $DIR/associated-item-privacy-inherent.rs:13:21 --> $DIR/associated-item-privacy-inherent.rs:13:21
| |
LL | let value = Pub::method; LL | let value = Pub::method;
...@@ -7,7 +7,7 @@ LL | let value = Pub::method; ...@@ -7,7 +7,7 @@ LL | let value = Pub::method;
LL | priv_nominal::mac!(); LL | priv_nominal::mac!();
| --------------------- in this macro invocation | --------------------- in this macro invocation
error: type `for<'r> fn(&'r priv_nominal::Pub) {<priv_nominal::Pub>::method}` is private error: type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private
--> $DIR/associated-item-privacy-inherent.rs:15:9 --> $DIR/associated-item-privacy-inherent.rs:15:9
| |
LL | value; LL | value;
...@@ -16,7 +16,7 @@ LL | value; ...@@ -16,7 +16,7 @@ LL | value;
LL | priv_nominal::mac!(); LL | priv_nominal::mac!();
| --------------------- in this macro invocation | --------------------- in this macro invocation
error: type `for<'r> fn(&'r priv_nominal::Pub) {<priv_nominal::Pub>::method}` is private error: type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private
--> $DIR/associated-item-privacy-inherent.rs:17:13 --> $DIR/associated-item-privacy-inherent.rs:17:13
| |
LL | Pub.method(); LL | Pub.method();
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// error-pattern:type `fn() {<u8 as ext::PrivTrait>::method}` is private // error-pattern:type `fn() {<u8 as ext::PrivTrait>::method}` is private
// error-pattern:type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct}` is private // error-pattern:type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct}` is private
// error-pattern:type `fn(u8) -> ext::PubTupleStruct {ext::PubTupleStruct}` is private // error-pattern:type `fn(u8) -> ext::PubTupleStruct {ext::PubTupleStruct}` is private
// error-pattern:type `for<'r> fn(&'r ext::Pub<u8>) {<ext::Pub<u8>>::priv_method}` is private // error-pattern:type `for<'r> fn(&'r ext::Pub<u8>) {ext::Pub::<u8>::priv_method}` is private
#![feature(decl_macro)] #![feature(decl_macro)]
......
...@@ -46,7 +46,7 @@ LL | ext::m!(); ...@@ -46,7 +46,7 @@ LL | ext::m!();
| |
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) = 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: type `for<'r> fn(&'r ext::Pub<u8>) {<ext::Pub<u8>>::priv_method}` is private error: type `for<'r> fn(&'r ext::Pub<u8>) {ext::Pub::<u8>::priv_method}` is private
--> $DIR/private-inferred-type-3.rs:16:5 --> $DIR/private-inferred-type-3.rs:16:5
| |
LL | ext::m!(); LL | ext::m!();
......
...@@ -47,7 +47,7 @@ impl TraitWithAssocConst for Priv {} ...@@ -47,7 +47,7 @@ impl TraitWithAssocConst for Priv {}
PubTupleStruct; PubTupleStruct;
//~^ ERROR type `fn(u8) -> m::PubTupleStruct {m::PubTupleStruct}` is private //~^ ERROR type `fn(u8) -> m::PubTupleStruct {m::PubTupleStruct}` is private
Pub(0u8).priv_method(); Pub(0u8).priv_method();
//~^ ERROR type `for<'r> fn(&'r m::Pub<u8>) {<m::Pub<u8>>::priv_method}` is private //~^ ERROR type `for<'r> fn(&'r m::Pub<u8>) {m::Pub::<u8>::priv_method}` is private
} }
trait Trait {} trait Trait {}
......
...@@ -151,7 +151,7 @@ LL | PubTupleStruct; ...@@ -151,7 +151,7 @@ LL | PubTupleStruct;
LL | m::m!(); LL | m::m!();
| -------- in this macro invocation | -------- in this macro invocation
error: type `for<'r> fn(&'r m::Pub<u8>) {<m::Pub<u8>>::priv_method}` is private error: type `for<'r> fn(&'r m::Pub<u8>) {m::Pub::<u8>::priv_method}` is private
--> $DIR/private-inferred-type.rs:49:18 --> $DIR/private-inferred-type.rs:49:18
| |
LL | Pub(0u8).priv_method(); LL | Pub(0u8).priv_method();
......
...@@ -11,7 +11,7 @@ LL | 0 ..= <S as Tr>::A::f::<u8> => {} ...@@ -11,7 +11,7 @@ LL | 0 ..= <S as Tr>::A::f::<u8> => {}
| ^^^^^^^^^^^^^^^^^^^^^ ranges require char or numeric types | ^^^^^^^^^^^^^^^^^^^^^ ranges require char or numeric types
| |
= note: start type: {integer} = note: start type: {integer}
= note: end type: fn() {<S>::f::<u8>} = note: end type: fn() {S::f::<u8>}
error: aborting due to 2 previous errors error: aborting due to 2 previous errors
......
...@@ -5,7 +5,7 @@ mod foo { ...@@ -5,7 +5,7 @@ mod foo {
pub struct Foo { x: u32 } pub struct Foo { x: u32 }
impl Foo { impl Foo {
#[rustc_symbol_name] //~ ERROR _ZN5impl13foo3Foo3bar #[rustc_symbol_name] //~ ERROR _ZN15impl1..foo..Foo3bar
#[rustc_item_path] //~ ERROR item-path(foo::Foo::bar) #[rustc_item_path] //~ ERROR item-path(foo::Foo::bar)
fn bar() { } fn bar() { }
} }
......
error: symbol-name(_ZN5impl13foo3Foo3bar17hc487d6ec13fe9124E) error: symbol-name(_ZN15impl1..foo..Foo3bar17hc487d6ec13fe9124E)
--> $DIR/impl1.rs:8:9 --> $DIR/impl1.rs:8:9
| |
LL | #[rustc_symbol_name] LL | #[rustc_symbol_name]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册