mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
Auto merge of #93891 - matthiaskrgr:rollup-xadut8w, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #92242 (Erase regions before calculating layout for packed field capture) - #93443 (Add comment on stable_hash_impl for OwnerNodes) - #93742 (Drop rustc-docs from complete profile) - #93852 (rustdoc: remove support for multi-query search) - #93853 (Make all `hir::Map` methods consistently by-value) - #93861 (Fix ICE if no trait assoc const eq) - #93862 (Split x86_64-apple builder into two) - #93864 (Remove ArchiveBuilder::update_symbols) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
78450d2d60
15
.github/workflows/ci.yml
vendored
15
.github/workflows/ci.yml
vendored
@ -319,9 +319,20 @@ jobs:
|
||||
NO_DEBUG_ASSERTIONS: 1
|
||||
NO_OVERFLOW_CHECKS: 1
|
||||
os: macos-latest
|
||||
- name: x86_64-apple
|
||||
- name: x86_64-apple-1
|
||||
env:
|
||||
SCRIPT: "./x.py --stage 2 test"
|
||||
SCRIPT: "./x.py --stage 2 test --exclude src/test/ui --exclude src/test/rustdoc --exclude src/test/run-make-fulldeps"
|
||||
RUST_CONFIGURE_ARGS: "--build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false"
|
||||
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
|
||||
MACOSX_DEPLOYMENT_TARGET: 10.8
|
||||
MACOSX_STD_DEPLOYMENT_TARGET: 10.7
|
||||
NO_LLVM_ASSERTIONS: 1
|
||||
NO_DEBUG_ASSERTIONS: 1
|
||||
NO_OVERFLOW_CHECKS: 1
|
||||
os: macos-latest
|
||||
- name: x86_64-apple-2
|
||||
env:
|
||||
SCRIPT: "./x.py --stage 2 test src/test/ui src/test/rustdoc src/test/run-make-fulldeps"
|
||||
RUST_CONFIGURE_ARGS: "--build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false"
|
||||
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
|
||||
MACOSX_DEPLOYMENT_TARGET: 10.8
|
||||
|
@ -763,7 +763,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
HirId, ImplItem, ImplItemKind, Item, ItemKind,
|
||||
};
|
||||
|
||||
fn maybe_body_id_of_fn(hir_map: &Map<'_>, id: HirId) -> Option<BodyId> {
|
||||
fn maybe_body_id_of_fn(hir_map: Map<'_>, id: HirId) -> Option<BodyId> {
|
||||
match hir_map.find(id) {
|
||||
Some(Node::Item(Item { kind: ItemKind::Fn(_, _, body_id), .. }))
|
||||
| Some(Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(_, body_id), .. })) => {
|
||||
@ -774,7 +774,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
}
|
||||
let hir_map = self.infcx.tcx.hir();
|
||||
let mir_body_hir_id = self.mir_hir_id();
|
||||
if let Some(fn_body_id) = maybe_body_id_of_fn(&hir_map, mir_body_hir_id) {
|
||||
if let Some(fn_body_id) = maybe_body_id_of_fn(hir_map, mir_body_hir_id) {
|
||||
if let Block(
|
||||
hir::Block {
|
||||
expr:
|
||||
|
@ -105,8 +105,6 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn update_symbols(&mut self) {}
|
||||
|
||||
fn build(mut self) {
|
||||
enum BuilderKind {
|
||||
Bsd(ar::Builder<File>),
|
||||
|
@ -113,9 +113,6 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn update_symbols(&mut self) {
|
||||
}
|
||||
|
||||
fn build(mut self) {
|
||||
use std::process::Command;
|
||||
|
||||
|
@ -27,7 +27,6 @@ pub struct LlvmArchiveBuilder<'a> {
|
||||
config: ArchiveConfig<'a>,
|
||||
removals: Vec<String>,
|
||||
additions: Vec<Addition>,
|
||||
should_update_symbols: bool,
|
||||
src_archive: Option<Option<ArchiveRO>>,
|
||||
}
|
||||
|
||||
@ -75,7 +74,6 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
|
||||
config,
|
||||
removals: Vec::new(),
|
||||
additions: Vec::new(),
|
||||
should_update_symbols: false,
|
||||
src_archive: None,
|
||||
}
|
||||
}
|
||||
@ -129,12 +127,6 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
|
||||
.push(Addition::File { path: file.to_path_buf(), name_in_archive: name.to_owned() });
|
||||
}
|
||||
|
||||
/// Indicate that the next call to `build` should update all symbols in
|
||||
/// the archive (equivalent to running 'ar s' over it).
|
||||
fn update_symbols(&mut self) {
|
||||
self.should_update_symbols = true;
|
||||
}
|
||||
|
||||
/// Combine the provided files, rlibs, and native libraries into a single
|
||||
/// `Archive`.
|
||||
fn build(mut self) {
|
||||
@ -313,7 +305,6 @@ impl<'a> LlvmArchiveBuilder<'a> {
|
||||
let mut members = Vec::new();
|
||||
|
||||
let dst = CString::new(self.config.dst.to_str().unwrap())?;
|
||||
let should_update_symbols = self.should_update_symbols;
|
||||
|
||||
unsafe {
|
||||
if let Some(archive) = self.src_archive() {
|
||||
@ -385,7 +376,7 @@ impl<'a> LlvmArchiveBuilder<'a> {
|
||||
dst.as_ptr(),
|
||||
members.len() as libc::size_t,
|
||||
members.as_ptr() as *const &_,
|
||||
should_update_symbols,
|
||||
true,
|
||||
kind,
|
||||
);
|
||||
let ret = if r.into_result().is_err() {
|
||||
|
@ -51,7 +51,6 @@ pub trait ArchiveBuilder<'a> {
|
||||
fn add_archive<F>(&mut self, archive: &Path, skip: F) -> io::Result<()>
|
||||
where
|
||||
F: FnMut(&str) -> bool + 'static;
|
||||
fn update_symbols(&mut self);
|
||||
|
||||
fn build(self);
|
||||
|
||||
|
@ -333,10 +333,6 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
|
||||
ab.inject_dll_import_lib(&raw_dylib_name, &raw_dylib_imports, tmpdir);
|
||||
}
|
||||
|
||||
// After adding all files to the archive, we need to update the
|
||||
// symbol table of the archive.
|
||||
ab.update_symbols();
|
||||
|
||||
// Note that it is important that we add all of our non-object "magical
|
||||
// files" *after* all of the object files in the archive. The reason for
|
||||
// this is as follows:
|
||||
@ -365,13 +361,6 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
|
||||
// normal linkers for the platform.
|
||||
let metadata = create_rmeta_file(sess, codegen_results.metadata.raw_data());
|
||||
ab.add_file(&emit_metadata(sess, &metadata, tmpdir));
|
||||
|
||||
// After adding all files to the archive, we need to update the
|
||||
// symbol table of the archive. This currently dies on macOS (see
|
||||
// #11162), and isn't necessary there anyway
|
||||
if !sess.target.is_like_osx {
|
||||
ab.update_symbols();
|
||||
}
|
||||
}
|
||||
|
||||
RlibFlavor::StaticlibBase => {
|
||||
@ -381,6 +370,7 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(ab);
|
||||
}
|
||||
|
||||
@ -509,7 +499,6 @@ fn link_staticlib<'a, B: ArchiveBuilder<'a>>(
|
||||
sess.fatal(&e);
|
||||
}
|
||||
|
||||
ab.update_symbols();
|
||||
ab.build();
|
||||
|
||||
if !all_native_libs.is_empty() {
|
||||
@ -2310,7 +2299,6 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
|
||||
|
||||
sess.prof.generic_activity_with_arg("link_altering_rlib", name).run(|| {
|
||||
let mut archive = <B as ArchiveBuilder>::new(sess, &dst, Some(cratepath));
|
||||
archive.update_symbols();
|
||||
|
||||
let mut any_objects = false;
|
||||
for f in archive.src_files() {
|
||||
|
@ -141,22 +141,22 @@ pub trait Map<'hir> {
|
||||
// Used when no map is actually available, forcing manual implementation of nested visitors.
|
||||
impl<'hir> Map<'hir> for ! {
|
||||
fn find(&self, _: HirId) -> Option<Node<'hir>> {
|
||||
unreachable!()
|
||||
*self;
|
||||
}
|
||||
fn body(&self, _: BodyId) -> &'hir Body<'hir> {
|
||||
unreachable!()
|
||||
*self;
|
||||
}
|
||||
fn item(&self, _: ItemId) -> &'hir Item<'hir> {
|
||||
unreachable!()
|
||||
*self;
|
||||
}
|
||||
fn trait_item(&self, _: TraitItemId) -> &'hir TraitItem<'hir> {
|
||||
unreachable!()
|
||||
*self;
|
||||
}
|
||||
fn impl_item(&self, _: ImplItemId) -> &'hir ImplItem<'hir> {
|
||||
unreachable!()
|
||||
*self;
|
||||
}
|
||||
fn foreign_item(&self, _: ForeignItemId) -> &'hir ForeignItem<'hir> {
|
||||
unreachable!()
|
||||
*self;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,6 +206,9 @@ impl<'tcx, HirCtx: crate::HashStableContext> HashStable<HirCtx> for OwnerNodes<'
|
||||
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
|
||||
// We ignore the `nodes` and `bodies` fields since these refer to information included in
|
||||
// `hash` which is hashed in the collector and used for the crate hash.
|
||||
// `local_id_to_def_id` is also ignored because is dependent on the body, then just hashing
|
||||
// the body satisfies the condition of two nodes being different have different
|
||||
// `hash_stable` results.
|
||||
let OwnerNodes {
|
||||
hash_including_bodies,
|
||||
hash_without_bodies: _,
|
||||
|
@ -2226,7 +2226,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
bound_kind: GenericKind<'tcx>,
|
||||
sub: Region<'tcx>,
|
||||
) -> DiagnosticBuilder<'a> {
|
||||
let hir = &self.tcx.hir();
|
||||
let hir = self.tcx.hir();
|
||||
// Attempt to obtain the span of the parameter so we can
|
||||
// suggest adding an explicit lifetime bound to it.
|
||||
let generics = self
|
||||
|
@ -149,18 +149,18 @@ impl<'hir> Iterator for ParentOwnerIterator<'hir> {
|
||||
}
|
||||
|
||||
impl<'hir> Map<'hir> {
|
||||
pub fn krate(&self) -> &'hir Crate<'hir> {
|
||||
pub fn krate(self) -> &'hir Crate<'hir> {
|
||||
self.tcx.hir_crate(())
|
||||
}
|
||||
|
||||
pub fn root_module(&self) -> &'hir Mod<'hir> {
|
||||
pub fn root_module(self) -> &'hir Mod<'hir> {
|
||||
match self.tcx.hir_owner(CRATE_DEF_ID).map(|o| o.node) {
|
||||
Some(OwnerNode::Crate(item)) => item,
|
||||
_ => bug!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn items(&self) -> impl Iterator<Item = &'hir Item<'hir>> + 'hir {
|
||||
pub fn items(self) -> impl Iterator<Item = &'hir Item<'hir>> + 'hir {
|
||||
let krate = self.krate();
|
||||
krate.owners.iter().filter_map(|owner| match owner.as_owner()?.node() {
|
||||
OwnerNode::Item(item) => Some(item),
|
||||
@ -168,16 +168,16 @@ impl<'hir> Map<'hir> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn def_key(&self, def_id: LocalDefId) -> DefKey {
|
||||
pub fn def_key(self, def_id: LocalDefId) -> DefKey {
|
||||
// Accessing the DefKey is ok, since it is part of DefPathHash.
|
||||
self.tcx.untracked_resolutions.definitions.def_key(def_id)
|
||||
}
|
||||
|
||||
pub fn def_path_from_hir_id(&self, id: HirId) -> Option<DefPath> {
|
||||
pub fn def_path_from_hir_id(self, id: HirId) -> Option<DefPath> {
|
||||
self.opt_local_def_id(id).map(|def_id| self.def_path(def_id))
|
||||
}
|
||||
|
||||
pub fn def_path(&self, def_id: LocalDefId) -> DefPath {
|
||||
pub fn def_path(self, def_id: LocalDefId) -> DefPath {
|
||||
// Accessing the DefPath is ok, since it is part of DefPathHash.
|
||||
self.tcx.untracked_resolutions.definitions.def_path(def_id)
|
||||
}
|
||||
@ -189,7 +189,7 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn local_def_id(&self, hir_id: HirId) -> LocalDefId {
|
||||
pub fn local_def_id(self, hir_id: HirId) -> LocalDefId {
|
||||
self.opt_local_def_id(hir_id).unwrap_or_else(|| {
|
||||
bug!(
|
||||
"local_def_id: no entry for `{:?}`, which has a map of `{:?}`",
|
||||
@ -200,7 +200,7 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn opt_local_def_id(&self, hir_id: HirId) -> Option<LocalDefId> {
|
||||
pub fn opt_local_def_id(self, hir_id: HirId) -> Option<LocalDefId> {
|
||||
if hir_id.local_id == ItemLocalId::new(0) {
|
||||
Some(hir_id.owner)
|
||||
} else {
|
||||
@ -214,18 +214,18 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn local_def_id_to_hir_id(&self, def_id: LocalDefId) -> HirId {
|
||||
pub fn local_def_id_to_hir_id(self, def_id: LocalDefId) -> HirId {
|
||||
self.tcx.local_def_id_to_hir_id(def_id)
|
||||
}
|
||||
|
||||
pub fn iter_local_def_id(&self) -> impl Iterator<Item = LocalDefId> + '_ {
|
||||
pub fn iter_local_def_id(self) -> impl Iterator<Item = LocalDefId> + 'hir {
|
||||
// Create a dependency to the crate to be sure we reexcute this when the amount of
|
||||
// definitions change.
|
||||
self.tcx.ensure().hir_crate(());
|
||||
self.tcx.untracked_resolutions.definitions.iter_local_def_id()
|
||||
}
|
||||
|
||||
pub fn opt_def_kind(&self, local_def_id: LocalDefId) -> Option<DefKind> {
|
||||
pub fn opt_def_kind(self, local_def_id: LocalDefId) -> Option<DefKind> {
|
||||
let hir_id = self.local_def_id_to_hir_id(local_def_id);
|
||||
let def_kind = match self.find(hir_id)? {
|
||||
Node::Item(item) => match item.kind {
|
||||
@ -312,12 +312,12 @@ impl<'hir> Map<'hir> {
|
||||
Some(def_kind)
|
||||
}
|
||||
|
||||
pub fn def_kind(&self, local_def_id: LocalDefId) -> DefKind {
|
||||
pub fn def_kind(self, local_def_id: LocalDefId) -> DefKind {
|
||||
self.opt_def_kind(local_def_id)
|
||||
.unwrap_or_else(|| bug!("def_kind: unsupported node: {:?}", local_def_id))
|
||||
}
|
||||
|
||||
pub fn find_parent_node(&self, id: HirId) -> Option<HirId> {
|
||||
pub fn find_parent_node(self, id: HirId) -> Option<HirId> {
|
||||
if id.local_id == ItemLocalId::from_u32(0) {
|
||||
Some(self.tcx.hir_owner_parent(id.owner))
|
||||
} else {
|
||||
@ -328,12 +328,12 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_parent_node(&self, hir_id: HirId) -> HirId {
|
||||
pub fn get_parent_node(self, hir_id: HirId) -> HirId {
|
||||
self.find_parent_node(hir_id).unwrap()
|
||||
}
|
||||
|
||||
/// Retrieves the `Node` corresponding to `id`, returning `None` if cannot be found.
|
||||
pub fn find(&self, id: HirId) -> Option<Node<'hir>> {
|
||||
pub fn find(self, id: HirId) -> Option<Node<'hir>> {
|
||||
if id.local_id == ItemLocalId::from_u32(0) {
|
||||
let owner = self.tcx.hir_owner(id.owner)?;
|
||||
Some(owner.node.into())
|
||||
@ -346,26 +346,26 @@ impl<'hir> Map<'hir> {
|
||||
|
||||
/// Retrieves the `Node` corresponding to `id`, returning `None` if cannot be found.
|
||||
#[inline]
|
||||
pub fn find_by_def_id(&self, id: LocalDefId) -> Option<Node<'hir>> {
|
||||
pub fn find_by_def_id(self, id: LocalDefId) -> Option<Node<'hir>> {
|
||||
self.find(self.local_def_id_to_hir_id(id))
|
||||
}
|
||||
|
||||
/// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
|
||||
pub fn get(&self, id: HirId) -> Node<'hir> {
|
||||
pub fn get(self, id: HirId) -> Node<'hir> {
|
||||
self.find(id).unwrap_or_else(|| bug!("couldn't find hir id {} in the HIR map", id))
|
||||
}
|
||||
|
||||
/// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
|
||||
#[inline]
|
||||
pub fn get_by_def_id(&self, id: LocalDefId) -> Node<'hir> {
|
||||
pub fn get_by_def_id(self, id: LocalDefId) -> Node<'hir> {
|
||||
self.find_by_def_id(id).unwrap_or_else(|| bug!("couldn't find {:?} in the HIR map", id))
|
||||
}
|
||||
|
||||
pub fn get_if_local(&self, id: DefId) -> Option<Node<'hir>> {
|
||||
pub fn get_if_local(self, id: DefId) -> Option<Node<'hir>> {
|
||||
id.as_local().and_then(|id| self.find(self.local_def_id_to_hir_id(id)))
|
||||
}
|
||||
|
||||
pub fn get_generics(&self, id: LocalDefId) -> Option<&'hir Generics<'hir>> {
|
||||
pub fn get_generics(self, id: LocalDefId) -> Option<&'hir Generics<'hir>> {
|
||||
let node = self.tcx.hir_owner(id)?;
|
||||
match node.node {
|
||||
OwnerNode::ImplItem(impl_item) => Some(&impl_item.generics),
|
||||
@ -386,27 +386,27 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn item(&self, id: ItemId) -> &'hir Item<'hir> {
|
||||
pub fn item(self, id: ItemId) -> &'hir Item<'hir> {
|
||||
self.tcx.hir_owner(id.def_id).unwrap().node.expect_item()
|
||||
}
|
||||
|
||||
pub fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir> {
|
||||
pub fn trait_item(self, id: TraitItemId) -> &'hir TraitItem<'hir> {
|
||||
self.tcx.hir_owner(id.def_id).unwrap().node.expect_trait_item()
|
||||
}
|
||||
|
||||
pub fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir> {
|
||||
pub fn impl_item(self, id: ImplItemId) -> &'hir ImplItem<'hir> {
|
||||
self.tcx.hir_owner(id.def_id).unwrap().node.expect_impl_item()
|
||||
}
|
||||
|
||||
pub fn foreign_item(&self, id: ForeignItemId) -> &'hir ForeignItem<'hir> {
|
||||
pub fn foreign_item(self, id: ForeignItemId) -> &'hir ForeignItem<'hir> {
|
||||
self.tcx.hir_owner(id.def_id).unwrap().node.expect_foreign_item()
|
||||
}
|
||||
|
||||
pub fn body(&self, id: BodyId) -> &'hir Body<'hir> {
|
||||
pub fn body(self, id: BodyId) -> &'hir Body<'hir> {
|
||||
self.tcx.hir_owner_nodes(id.hir_id.owner).unwrap().bodies[&id.hir_id.local_id]
|
||||
}
|
||||
|
||||
pub fn fn_decl_by_hir_id(&self, hir_id: HirId) -> Option<&'hir FnDecl<'hir>> {
|
||||
pub fn fn_decl_by_hir_id(self, hir_id: HirId) -> Option<&'hir FnDecl<'hir>> {
|
||||
if let Some(node) = self.find(hir_id) {
|
||||
fn_decl(node)
|
||||
} else {
|
||||
@ -414,7 +414,7 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fn_sig_by_hir_id(&self, hir_id: HirId) -> Option<&'hir FnSig<'hir>> {
|
||||
pub fn fn_sig_by_hir_id(self, hir_id: HirId) -> Option<&'hir FnSig<'hir>> {
|
||||
if let Some(node) = self.find(hir_id) {
|
||||
fn_sig(node)
|
||||
} else {
|
||||
@ -422,7 +422,7 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enclosing_body_owner(&self, hir_id: HirId) -> HirId {
|
||||
pub fn enclosing_body_owner(self, hir_id: HirId) -> HirId {
|
||||
for (parent, _) in self.parent_iter(hir_id) {
|
||||
if let Some(body) = self.maybe_body_owned_by(parent) {
|
||||
return self.body_owner(body);
|
||||
@ -435,24 +435,24 @@ impl<'hir> Map<'hir> {
|
||||
/// Returns the `HirId` that corresponds to the definition of
|
||||
/// which this is the body of, i.e., a `fn`, `const` or `static`
|
||||
/// item (possibly associated), a closure, or a `hir::AnonConst`.
|
||||
pub fn body_owner(&self, BodyId { hir_id }: BodyId) -> HirId {
|
||||
pub fn body_owner(self, BodyId { hir_id }: BodyId) -> HirId {
|
||||
let parent = self.get_parent_node(hir_id);
|
||||
assert!(self.find(parent).map_or(false, |n| is_body_owner(n, hir_id)));
|
||||
parent
|
||||
}
|
||||
|
||||
pub fn body_owner_def_id(&self, id: BodyId) -> LocalDefId {
|
||||
pub fn body_owner_def_id(self, id: BodyId) -> LocalDefId {
|
||||
self.local_def_id(self.body_owner(id))
|
||||
}
|
||||
|
||||
/// Given a `HirId`, returns the `BodyId` associated with it,
|
||||
/// if the node is a body owner, otherwise returns `None`.
|
||||
pub fn maybe_body_owned_by(&self, hir_id: HirId) -> Option<BodyId> {
|
||||
pub fn maybe_body_owned_by(self, hir_id: HirId) -> Option<BodyId> {
|
||||
self.find(hir_id).map(associated_body).flatten()
|
||||
}
|
||||
|
||||
/// Given a body owner's id, returns the `BodyId` associated with it.
|
||||
pub fn body_owned_by(&self, id: HirId) -> BodyId {
|
||||
pub fn body_owned_by(self, id: HirId) -> BodyId {
|
||||
self.maybe_body_owned_by(id).unwrap_or_else(|| {
|
||||
span_bug!(
|
||||
self.span(id),
|
||||
@ -462,7 +462,7 @@ impl<'hir> Map<'hir> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn body_param_names(&self, id: BodyId) -> impl Iterator<Item = Ident> + 'hir {
|
||||
pub fn body_param_names(self, id: BodyId) -> impl Iterator<Item = Ident> + 'hir {
|
||||
self.body(id).params.iter().map(|arg| match arg.pat.kind {
|
||||
PatKind::Binding(_, _, ident, _) => ident,
|
||||
_ => Ident::empty(),
|
||||
@ -472,7 +472,7 @@ impl<'hir> Map<'hir> {
|
||||
/// Returns the `BodyOwnerKind` of this `LocalDefId`.
|
||||
///
|
||||
/// Panics if `LocalDefId` does not have an associated body.
|
||||
pub fn body_owner_kind(&self, id: HirId) -> BodyOwnerKind {
|
||||
pub fn body_owner_kind(self, id: HirId) -> BodyOwnerKind {
|
||||
match self.get(id) {
|
||||
Node::Item(&Item { kind: ItemKind::Const(..), .. })
|
||||
| Node::TraitItem(&TraitItem { kind: TraitItemKind::Const(..), .. })
|
||||
@ -495,7 +495,7 @@ impl<'hir> Map<'hir> {
|
||||
/// This should only be used for determining the context of a body, a return
|
||||
/// value of `Some` does not always suggest that the owner of the body is `const`,
|
||||
/// just that it has to be checked as if it were.
|
||||
pub fn body_const_context(&self, did: LocalDefId) -> Option<ConstContext> {
|
||||
pub fn body_const_context(self, did: LocalDefId) -> Option<ConstContext> {
|
||||
let hir_id = self.local_def_id_to_hir_id(did);
|
||||
let ccx = match self.body_owner_kind(hir_id) {
|
||||
BodyOwnerKind::Const => ConstContext::Const,
|
||||
@ -549,7 +549,7 @@ impl<'hir> Map<'hir> {
|
||||
});
|
||||
}
|
||||
|
||||
pub fn ty_param_owner(&self, id: HirId) -> LocalDefId {
|
||||
pub fn ty_param_owner(self, id: HirId) -> LocalDefId {
|
||||
match self.get(id) {
|
||||
Node::Item(&Item { kind: ItemKind::Trait(..) | ItemKind::TraitAlias(..), .. }) => {
|
||||
id.expect_owner()
|
||||
@ -559,7 +559,7 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ty_param_name(&self, id: HirId) -> Symbol {
|
||||
pub fn ty_param_name(self, id: HirId) -> Symbol {
|
||||
match self.get(id) {
|
||||
Node::Item(&Item { kind: ItemKind::Trait(..) | ItemKind::TraitAlias(..), .. }) => {
|
||||
kw::SelfUpper
|
||||
@ -569,18 +569,18 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn trait_impls(&self, trait_did: DefId) -> &'hir [LocalDefId] {
|
||||
pub fn trait_impls(self, trait_did: DefId) -> &'hir [LocalDefId] {
|
||||
self.tcx.all_local_trait_impls(()).get(&trait_did).map_or(&[], |xs| &xs[..])
|
||||
}
|
||||
|
||||
/// Gets the attributes on the crate. This is preferable to
|
||||
/// invoking `krate.attrs` because it registers a tighter
|
||||
/// dep-graph access.
|
||||
pub fn krate_attrs(&self) -> &'hir [ast::Attribute] {
|
||||
pub fn krate_attrs(self) -> &'hir [ast::Attribute] {
|
||||
self.attrs(CRATE_HIR_ID)
|
||||
}
|
||||
|
||||
pub fn get_module(&self, module: LocalDefId) -> (&'hir Mod<'hir>, Span, HirId) {
|
||||
pub fn get_module(self, module: LocalDefId) -> (&'hir Mod<'hir>, Span, HirId) {
|
||||
let hir_id = HirId::make_owner(module);
|
||||
match self.tcx.hir_owner(module).map(|o| o.node) {
|
||||
Some(OwnerNode::Item(&Item { span, kind: ItemKind::Mod(ref m), .. })) => {
|
||||
@ -620,7 +620,7 @@ impl<'hir> Map<'hir> {
|
||||
/// follows lexical scoping rules -- then you want a different
|
||||
/// approach. You should override `visit_nested_item` in your
|
||||
/// visitor and then call `intravisit::walk_crate` instead.
|
||||
pub fn visit_all_item_likes<V>(&self, visitor: &mut V)
|
||||
pub fn visit_all_item_likes<V>(self, visitor: &mut V)
|
||||
where
|
||||
V: itemlikevisit::ItemLikeVisitor<'hir>,
|
||||
{
|
||||
@ -637,7 +637,7 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
|
||||
/// A parallel version of `visit_all_item_likes`.
|
||||
pub fn par_visit_all_item_likes<V>(&self, visitor: &V)
|
||||
pub fn par_visit_all_item_likes<V>(self, visitor: &V)
|
||||
where
|
||||
V: itemlikevisit::ParItemLikeVisitor<'hir> + Sync + Send,
|
||||
{
|
||||
@ -653,7 +653,7 @@ impl<'hir> Map<'hir> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn visit_item_likes_in_module<V>(&self, module: LocalDefId, visitor: &mut V)
|
||||
pub fn visit_item_likes_in_module<V>(self, module: LocalDefId, visitor: &mut V)
|
||||
where
|
||||
V: ItemLikeVisitor<'hir>,
|
||||
{
|
||||
@ -676,7 +676,7 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn for_each_module(&self, f: impl Fn(LocalDefId)) {
|
||||
pub fn for_each_module(self, f: impl Fn(LocalDefId)) {
|
||||
let mut queue = VecDeque::new();
|
||||
queue.push_back(CRATE_DEF_ID);
|
||||
|
||||
@ -689,12 +689,12 @@ impl<'hir> Map<'hir> {
|
||||
|
||||
#[cfg(not(parallel_compiler))]
|
||||
#[inline]
|
||||
pub fn par_for_each_module(&self, f: impl Fn(LocalDefId)) {
|
||||
pub fn par_for_each_module(self, f: impl Fn(LocalDefId)) {
|
||||
self.for_each_module(f)
|
||||
}
|
||||
|
||||
#[cfg(parallel_compiler)]
|
||||
pub fn par_for_each_module(&self, f: impl Fn(LocalDefId) + Sync) {
|
||||
pub fn par_for_each_module(self, f: impl Fn(LocalDefId) + Sync) {
|
||||
use rustc_data_structures::sync::{par_iter, ParallelIterator};
|
||||
par_iter_submodules(self.tcx, CRATE_DEF_ID, &f);
|
||||
|
||||
@ -721,7 +721,7 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
|
||||
/// Checks if the node is left-hand side of an assignment.
|
||||
pub fn is_lhs(&self, id: HirId) -> bool {
|
||||
pub fn is_lhs(self, id: HirId) -> bool {
|
||||
match self.find(self.get_parent_node(id)) {
|
||||
Some(Node::Expr(expr)) => match expr.kind {
|
||||
ExprKind::Assign(lhs, _rhs, _span) => lhs.hir_id == id,
|
||||
@ -733,7 +733,7 @@ impl<'hir> Map<'hir> {
|
||||
|
||||
/// Whether the expression pointed at by `hir_id` belongs to a `const` evaluation context.
|
||||
/// Used exclusively for diagnostics, to avoid suggestion function calls.
|
||||
pub fn is_inside_const_context(&self, hir_id: HirId) -> bool {
|
||||
pub fn is_inside_const_context(self, hir_id: HirId) -> bool {
|
||||
self.body_const_context(self.local_def_id(self.enclosing_body_owner(hir_id))).is_some()
|
||||
}
|
||||
|
||||
@ -759,7 +759,7 @@ impl<'hir> Map<'hir> {
|
||||
/// false
|
||||
/// }
|
||||
/// ```
|
||||
pub fn get_return_block(&self, id: HirId) -> Option<HirId> {
|
||||
pub fn get_return_block(self, id: HirId) -> Option<HirId> {
|
||||
let mut iter = self.parent_iter(id).peekable();
|
||||
let mut ignore_tail = false;
|
||||
if let Some(node) = self.find(id) {
|
||||
@ -799,7 +799,7 @@ impl<'hir> Map<'hir> {
|
||||
/// parent item is in this map. The "parent item" is the closest parent node
|
||||
/// in the HIR which is recorded by the map and is an item, either an item
|
||||
/// in a module, trait, or impl.
|
||||
pub fn get_parent_item(&self, hir_id: HirId) -> LocalDefId {
|
||||
pub fn get_parent_item(self, hir_id: HirId) -> LocalDefId {
|
||||
if let Some((def_id, _node)) = self.parent_owner_iter(hir_id).next() {
|
||||
def_id
|
||||
} else {
|
||||
@ -809,7 +809,7 @@ impl<'hir> Map<'hir> {
|
||||
|
||||
/// Returns the `HirId` of `id`'s nearest module parent, or `id` itself if no
|
||||
/// module parent is in this map.
|
||||
pub(super) fn get_module_parent_node(&self, hir_id: HirId) -> LocalDefId {
|
||||
pub(super) fn get_module_parent_node(self, hir_id: HirId) -> LocalDefId {
|
||||
for (def_id, node) in self.parent_owner_iter(hir_id) {
|
||||
if let OwnerNode::Item(&Item { kind: ItemKind::Mod(_), .. }) = node {
|
||||
return def_id;
|
||||
@ -823,7 +823,7 @@ impl<'hir> Map<'hir> {
|
||||
///
|
||||
/// Used by error reporting when there's a type error in an if or match arm caused by the
|
||||
/// expression needing to be unit.
|
||||
pub fn get_if_cause(&self, hir_id: HirId) -> Option<&'hir Expr<'hir>> {
|
||||
pub fn get_if_cause(self, hir_id: HirId) -> Option<&'hir Expr<'hir>> {
|
||||
for (_, node) in self.parent_iter(hir_id) {
|
||||
match node {
|
||||
Node::Item(_)
|
||||
@ -841,7 +841,7 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
|
||||
/// Returns the nearest enclosing scope. A scope is roughly an item or block.
|
||||
pub fn get_enclosing_scope(&self, hir_id: HirId) -> Option<HirId> {
|
||||
pub fn get_enclosing_scope(self, hir_id: HirId) -> Option<HirId> {
|
||||
for (hir_id, node) in self.parent_iter(hir_id) {
|
||||
if let Node::Item(Item {
|
||||
kind:
|
||||
@ -868,7 +868,7 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
|
||||
/// Returns the defining scope for an opaque type definition.
|
||||
pub fn get_defining_scope(&self, id: HirId) -> HirId {
|
||||
pub fn get_defining_scope(self, id: HirId) -> HirId {
|
||||
let mut scope = id;
|
||||
loop {
|
||||
scope = self.get_enclosing_scope(scope).unwrap_or(CRATE_HIR_ID);
|
||||
@ -878,7 +878,7 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_foreign_abi(&self, hir_id: HirId) -> Abi {
|
||||
pub fn get_foreign_abi(self, hir_id: HirId) -> Abi {
|
||||
let parent = self.get_parent_item(hir_id);
|
||||
if let Some(node) = self.tcx.hir_owner(parent) {
|
||||
if let OwnerNode::Item(Item { kind: ItemKind::ForeignMod { abi, .. }, .. }) = node.node
|
||||
@ -892,35 +892,35 @@ impl<'hir> Map<'hir> {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn expect_item(&self, id: LocalDefId) -> &'hir Item<'hir> {
|
||||
pub fn expect_item(self, id: LocalDefId) -> &'hir Item<'hir> {
|
||||
match self.tcx.hir_owner(id) {
|
||||
Some(Owner { node: OwnerNode::Item(item), .. }) => item,
|
||||
_ => bug!("expected item, found {}", self.node_to_string(HirId::make_owner(id))),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_impl_item(&self, id: LocalDefId) -> &'hir ImplItem<'hir> {
|
||||
pub fn expect_impl_item(self, id: LocalDefId) -> &'hir ImplItem<'hir> {
|
||||
match self.tcx.hir_owner(id) {
|
||||
Some(Owner { node: OwnerNode::ImplItem(item), .. }) => item,
|
||||
_ => bug!("expected impl item, found {}", self.node_to_string(HirId::make_owner(id))),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_trait_item(&self, id: LocalDefId) -> &'hir TraitItem<'hir> {
|
||||
pub fn expect_trait_item(self, id: LocalDefId) -> &'hir TraitItem<'hir> {
|
||||
match self.tcx.hir_owner(id) {
|
||||
Some(Owner { node: OwnerNode::TraitItem(item), .. }) => item,
|
||||
_ => bug!("expected trait item, found {}", self.node_to_string(HirId::make_owner(id))),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_variant(&self, id: HirId) -> &'hir Variant<'hir> {
|
||||
pub fn expect_variant(self, id: HirId) -> &'hir Variant<'hir> {
|
||||
match self.find(id) {
|
||||
Some(Node::Variant(variant)) => variant,
|
||||
_ => bug!("expected variant, found {}", self.node_to_string(id)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_foreign_item(&self, id: LocalDefId) -> &'hir ForeignItem<'hir> {
|
||||
pub fn expect_foreign_item(self, id: LocalDefId) -> &'hir ForeignItem<'hir> {
|
||||
match self.tcx.hir_owner(id) {
|
||||
Some(Owner { node: OwnerNode::ForeignItem(item), .. }) => item,
|
||||
_ => {
|
||||
@ -929,14 +929,14 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_expr(&self, id: HirId) -> &'hir Expr<'hir> {
|
||||
pub fn expect_expr(self, id: HirId) -> &'hir Expr<'hir> {
|
||||
match self.find(id) {
|
||||
Some(Node::Expr(expr)) => expr,
|
||||
_ => bug!("expected expr, found {}", self.node_to_string(id)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn opt_name(&self, id: HirId) -> Option<Symbol> {
|
||||
pub fn opt_name(self, id: HirId) -> Option<Symbol> {
|
||||
Some(match self.get(id) {
|
||||
Node::Item(i) => i.ident.name,
|
||||
Node::ForeignItem(fi) => fi.ident.name,
|
||||
@ -952,7 +952,7 @@ impl<'hir> Map<'hir> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn name(&self, id: HirId) -> Symbol {
|
||||
pub fn name(self, id: HirId) -> Symbol {
|
||||
match self.opt_name(id) {
|
||||
Some(name) => name,
|
||||
None => bug!("no name for {}", self.node_to_string(id)),
|
||||
@ -961,18 +961,18 @@ impl<'hir> Map<'hir> {
|
||||
|
||||
/// Given a node ID, gets a list of attributes associated with the AST
|
||||
/// corresponding to the node-ID.
|
||||
pub fn attrs(&self, id: HirId) -> &'hir [ast::Attribute] {
|
||||
pub fn attrs(self, id: HirId) -> &'hir [ast::Attribute] {
|
||||
self.tcx.hir_attrs(id.owner).get(id.local_id)
|
||||
}
|
||||
|
||||
/// Gets the span of the definition of the specified HIR node.
|
||||
/// This is used by `tcx.get_span`
|
||||
pub fn span(&self, hir_id: HirId) -> Span {
|
||||
pub fn span(self, hir_id: HirId) -> Span {
|
||||
self.opt_span(hir_id)
|
||||
.unwrap_or_else(|| bug!("hir::map::Map::span: id not in map: {:?}", hir_id))
|
||||
}
|
||||
|
||||
pub fn opt_span(&self, hir_id: HirId) -> Option<Span> {
|
||||
pub fn opt_span(self, hir_id: HirId) -> Option<Span> {
|
||||
let span = match self.find(hir_id)? {
|
||||
Node::Param(param) => param.span,
|
||||
Node::Item(item) => match &item.kind {
|
||||
@ -1021,7 +1021,7 @@ impl<'hir> Map<'hir> {
|
||||
|
||||
/// Like `hir.span()`, but includes the body of function items
|
||||
/// (instead of just the function header)
|
||||
pub fn span_with_body(&self, hir_id: HirId) -> Span {
|
||||
pub fn span_with_body(self, hir_id: HirId) -> Span {
|
||||
match self.find(hir_id) {
|
||||
Some(Node::TraitItem(item)) => item.span,
|
||||
Some(Node::ImplItem(impl_item)) => impl_item.span,
|
||||
@ -1031,11 +1031,11 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn span_if_local(&self, id: DefId) -> Option<Span> {
|
||||
pub fn span_if_local(self, id: DefId) -> Option<Span> {
|
||||
id.as_local().and_then(|id| self.opt_span(self.local_def_id_to_hir_id(id)))
|
||||
}
|
||||
|
||||
pub fn res_span(&self, res: Res) -> Option<Span> {
|
||||
pub fn res_span(self, res: Res) -> Option<Span> {
|
||||
match res {
|
||||
Res::Err => None,
|
||||
Res::Local(id) => Some(self.span(id)),
|
||||
@ -1045,13 +1045,13 @@ impl<'hir> Map<'hir> {
|
||||
|
||||
/// Get a representation of this `id` for debugging purposes.
|
||||
/// NOTE: Do NOT use this in diagnostics!
|
||||
pub fn node_to_string(&self, id: HirId) -> String {
|
||||
pub fn node_to_string(self, id: HirId) -> String {
|
||||
hir_id_to_string(self, id)
|
||||
}
|
||||
|
||||
/// Returns the HirId of `N` in `struct Foo<const N: usize = { ... }>` when
|
||||
/// called with the HirId for the `{ ... }` anon const
|
||||
pub fn opt_const_param_default_param_hir_id(&self, anon_const: HirId) -> Option<HirId> {
|
||||
pub fn opt_const_param_default_param_hir_id(self, anon_const: HirId) -> Option<HirId> {
|
||||
match self.get(self.get_parent_node(anon_const)) {
|
||||
Node::GenericParam(GenericParam {
|
||||
hir_id: param_id,
|
||||
@ -1065,27 +1065,27 @@ impl<'hir> Map<'hir> {
|
||||
|
||||
impl<'hir> intravisit::Map<'hir> for Map<'hir> {
|
||||
fn find(&self, hir_id: HirId) -> Option<Node<'hir>> {
|
||||
self.find(hir_id)
|
||||
(*self).find(hir_id)
|
||||
}
|
||||
|
||||
fn body(&self, id: BodyId) -> &'hir Body<'hir> {
|
||||
self.body(id)
|
||||
(*self).body(id)
|
||||
}
|
||||
|
||||
fn item(&self, id: ItemId) -> &'hir Item<'hir> {
|
||||
self.item(id)
|
||||
(*self).item(id)
|
||||
}
|
||||
|
||||
fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir> {
|
||||
self.trait_item(id)
|
||||
(*self).trait_item(id)
|
||||
}
|
||||
|
||||
fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir> {
|
||||
self.impl_item(id)
|
||||
(*self).impl_item(id)
|
||||
}
|
||||
|
||||
fn foreign_item(&self, id: ForeignItemId) -> &'hir ForeignItem<'hir> {
|
||||
self.foreign_item(id)
|
||||
(*self).foreign_item(id)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1154,7 +1154,7 @@ fn upstream_crates(tcx: TyCtxt<'_>) -> Vec<(StableCrateId, Svh)> {
|
||||
upstream_crates
|
||||
}
|
||||
|
||||
fn hir_id_to_string(map: &Map<'_>, id: HirId) -> String {
|
||||
fn hir_id_to_string(map: Map<'_>, id: HirId) -> String {
|
||||
let id_str = format!(" (hir_id={})", id);
|
||||
|
||||
let path_str = || {
|
||||
|
@ -41,9 +41,9 @@ pub enum LifetimeUseSet<'tcx> {
|
||||
}
|
||||
|
||||
trait RegionExt {
|
||||
fn early(hir_map: &Map<'_>, index: &mut u32, param: &GenericParam<'_>) -> (ParamName, Region);
|
||||
fn early(hir_map: Map<'_>, index: &mut u32, param: &GenericParam<'_>) -> (ParamName, Region);
|
||||
|
||||
fn late(index: u32, hir_map: &Map<'_>, param: &GenericParam<'_>) -> (ParamName, Region);
|
||||
fn late(index: u32, hir_map: Map<'_>, param: &GenericParam<'_>) -> (ParamName, Region);
|
||||
|
||||
fn late_anon(named_late_bound_vars: u32, index: &Cell<u32>) -> Region;
|
||||
|
||||
@ -59,7 +59,7 @@ trait RegionExt {
|
||||
}
|
||||
|
||||
impl RegionExt for Region {
|
||||
fn early(hir_map: &Map<'_>, index: &mut u32, param: &GenericParam<'_>) -> (ParamName, Region) {
|
||||
fn early(hir_map: Map<'_>, index: &mut u32, param: &GenericParam<'_>) -> (ParamName, Region) {
|
||||
let i = *index;
|
||||
*index += 1;
|
||||
let def_id = hir_map.local_def_id(param.hir_id);
|
||||
@ -68,7 +68,7 @@ impl RegionExt for Region {
|
||||
(param.name.normalize_to_macros_2_0(), Region::EarlyBound(i, def_id.to_def_id(), origin))
|
||||
}
|
||||
|
||||
fn late(idx: u32, hir_map: &Map<'_>, param: &GenericParam<'_>) -> (ParamName, Region) {
|
||||
fn late(idx: u32, hir_map: Map<'_>, param: &GenericParam<'_>) -> (ParamName, Region) {
|
||||
let depth = ty::INNERMOST;
|
||||
let def_id = hir_map.local_def_id(param.hir_id);
|
||||
let origin = LifetimeDefOrigin::from_param(param);
|
||||
@ -817,7 +817,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
.iter()
|
||||
.filter_map(|param| match param.kind {
|
||||
GenericParamKind::Lifetime { .. } => {
|
||||
Some(Region::early(&self.tcx.hir(), &mut index, param))
|
||||
Some(Region::early(self.tcx.hir(), &mut index, param))
|
||||
}
|
||||
GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => {
|
||||
non_lifetime_count += 1;
|
||||
@ -888,7 +888,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
.filter(|param| matches!(param.kind, GenericParamKind::Lifetime { .. }))
|
||||
.enumerate()
|
||||
.map(|(late_bound_idx, param)| {
|
||||
let pair = Region::late(late_bound_idx as u32, &self.tcx.hir(), param);
|
||||
let pair = Region::late(late_bound_idx as u32, self.tcx.hir(), param);
|
||||
let r = late_region_as_bound_region(self.tcx, &pair.1);
|
||||
(pair, r)
|
||||
})
|
||||
@ -1045,7 +1045,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
for param in generics.params {
|
||||
match param.kind {
|
||||
GenericParamKind::Lifetime { .. } => {
|
||||
let (name, reg) = Region::early(&self.tcx.hir(), &mut index, ¶m);
|
||||
let (name, reg) = Region::early(self.tcx.hir(), &mut index, ¶m);
|
||||
let Region::EarlyBound(_, def_id, _) = reg else {
|
||||
bug!();
|
||||
};
|
||||
@ -1145,7 +1145,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
.iter()
|
||||
.filter_map(|param| match param.kind {
|
||||
GenericParamKind::Lifetime { .. } => {
|
||||
Some(Region::early(&self.tcx.hir(), &mut index, param))
|
||||
Some(Region::early(self.tcx.hir(), &mut index, param))
|
||||
}
|
||||
GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => {
|
||||
non_lifetime_count += 1;
|
||||
@ -1214,7 +1214,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
.iter()
|
||||
.filter_map(|param| match param.kind {
|
||||
GenericParamKind::Lifetime { .. } => {
|
||||
Some(Region::early(&self.tcx.hir(), &mut index, param))
|
||||
Some(Region::early(self.tcx.hir(), &mut index, param))
|
||||
}
|
||||
GenericParamKind::Const { .. } | GenericParamKind::Type { .. } => {
|
||||
non_lifetime_count += 1;
|
||||
@ -1368,7 +1368,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
.enumerate()
|
||||
.map(|(late_bound_idx, param)| {
|
||||
let pair =
|
||||
Region::late(late_bound_idx as u32, &this.tcx.hir(), param);
|
||||
Region::late(late_bound_idx as u32, this.tcx.hir(), param);
|
||||
let r = late_region_as_bound_region(this.tcx, &pair.1);
|
||||
(pair, r)
|
||||
})
|
||||
@ -1463,11 +1463,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
.filter(|param| matches!(param.kind, GenericParamKind::Lifetime { .. }))
|
||||
.enumerate()
|
||||
.map(|(late_bound_idx, param)| {
|
||||
let pair = Region::late(
|
||||
initial_bound_vars + late_bound_idx as u32,
|
||||
&self.tcx.hir(),
|
||||
param,
|
||||
);
|
||||
let pair =
|
||||
Region::late(initial_bound_vars + late_bound_idx as u32, self.tcx.hir(), param);
|
||||
let r = late_region_as_bound_region(self.tcx, &pair.1);
|
||||
lifetimes.insert(pair.0, pair.1);
|
||||
r
|
||||
@ -2194,9 +2191,9 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
if self.map.late_bound.contains(¶m.hir_id) {
|
||||
let late_bound_idx = named_late_bound_vars;
|
||||
named_late_bound_vars += 1;
|
||||
Some(Region::late(late_bound_idx, &self.tcx.hir(), param))
|
||||
Some(Region::late(late_bound_idx, self.tcx.hir(), param))
|
||||
} else {
|
||||
Some(Region::early(&self.tcx.hir(), &mut next_early_index, param))
|
||||
Some(Region::early(self.tcx.hir(), &mut next_early_index, param))
|
||||
}
|
||||
}
|
||||
GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => {
|
||||
@ -2216,7 +2213,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
})
|
||||
.enumerate()
|
||||
.map(|(late_bound_idx, param)| {
|
||||
let pair = Region::late(late_bound_idx as u32, &self.tcx.hir(), param);
|
||||
let pair = Region::late(late_bound_idx as u32, self.tcx.hir(), param);
|
||||
late_region_as_bound_region(self.tcx, &pair.1)
|
||||
})
|
||||
.collect();
|
||||
|
@ -262,7 +262,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
||||
) {
|
||||
debug!("process_method: {:?}:{}", def_id, ident);
|
||||
|
||||
let map = &self.tcx.hir();
|
||||
let map = self.tcx.hir();
|
||||
let hir_id = map.local_def_id_to_hir_id(def_id);
|
||||
self.nest_typeck_results(def_id, |v| {
|
||||
if let Some(mut method_data) = v.save_ctxt.get_method_data(hir_id, ident, span) {
|
||||
@ -361,7 +361,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
||||
ty_params: &'tcx hir::Generics<'tcx>,
|
||||
body: hir::BodyId,
|
||||
) {
|
||||
let map = &self.tcx.hir();
|
||||
let map = self.tcx.hir();
|
||||
self.nest_typeck_results(item.def_id, |v| {
|
||||
let body = map.body(body);
|
||||
if let Some(fn_data) = v.save_ctxt.get_item_data(item) {
|
||||
@ -626,7 +626,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
let map = &self.tcx.hir();
|
||||
let map = self.tcx.hir();
|
||||
self.nest_typeck_results(item.def_id, |v| {
|
||||
v.visit_ty(&impl_.self_ty);
|
||||
if let Some(trait_ref) = &impl_.of_trait {
|
||||
@ -716,7 +716,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
||||
// walk generics and methods
|
||||
self.process_generic_params(generics, &qualname, item.hir_id());
|
||||
for method in methods {
|
||||
let map = &self.tcx.hir();
|
||||
let map = self.tcx.hir();
|
||||
self.process_trait_item(map.trait_item(method.id), item.def_id.to_def_id())
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
/// 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 hir = self.tcx.hir();
|
||||
let node = hir.find(hir_id)?;
|
||||
match &node {
|
||||
hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(sig, _, body_id), .. }) => {
|
||||
|
@ -1663,7 +1663,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
let table_owner = table.borrow().hir_owner;
|
||||
let generics = self.tcx.generics_of(table_owner.to_def_id());
|
||||
let type_param = generics.type_param(param, self.tcx);
|
||||
let hir = &self.tcx.hir();
|
||||
let hir = self.tcx.hir();
|
||||
if let Some(def_id) = type_param.def_id.as_local() {
|
||||
let id = hir.local_def_id_to_hir_id(def_id);
|
||||
// Get the `hir::Param` to verify whether it already has any bounds.
|
||||
|
@ -1648,7 +1648,8 @@ fn restrict_repr_packed_field_ref_capture<'tcx>(
|
||||
match p.kind {
|
||||
ProjectionKind::Field(..) => match ty.kind() {
|
||||
ty::Adt(def, _) if def.repr.packed() => {
|
||||
match tcx.layout_of(param_env.and(p.ty)) {
|
||||
// We erase regions here because they cannot be hashed
|
||||
match tcx.layout_of(param_env.and(tcx.erase_regions(p.ty))) {
|
||||
Ok(layout) if layout.align.abi.bytes() == 1 => {
|
||||
// if the alignment is 1, the type can't be further
|
||||
// disaligned.
|
||||
|
@ -508,8 +508,9 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
|
||||
})
|
||||
}) =>
|
||||
{
|
||||
// FIXME(associated_const_equality) when does this unwrap fail? I have no idea what case it would.
|
||||
let trait_def_id = trait_ref.trait_def_id().unwrap();
|
||||
let Some(trait_def_id) = trait_ref.trait_def_id() else {
|
||||
return tcx.ty_error_with_message(DUMMY_SP, "Could not find trait");
|
||||
};
|
||||
let assoc_items = tcx.associated_items(trait_def_id);
|
||||
let assoc_item = assoc_items.find_by_name_and_kind(
|
||||
tcx, binding.ident, ty::AssocKind::Const, def_id.to_def_id(),
|
||||
|
@ -486,9 +486,9 @@ jobs:
|
||||
NO_OVERFLOW_CHECKS: 1
|
||||
<<: *job-macos-xl
|
||||
|
||||
- name: x86_64-apple
|
||||
env:
|
||||
SCRIPT: ./x.py --stage 2 test
|
||||
- name: x86_64-apple-1
|
||||
env: &env-x86_64-apple-tests
|
||||
SCRIPT: ./x.py --stage 2 test --exclude src/test/ui --exclude src/test/rustdoc --exclude src/test/run-make-fulldeps
|
||||
RUST_CONFIGURE_ARGS: --build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false
|
||||
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
|
||||
MACOSX_DEPLOYMENT_TARGET: 10.8
|
||||
@ -498,6 +498,12 @@ jobs:
|
||||
NO_OVERFLOW_CHECKS: 1
|
||||
<<: *job-macos-xl
|
||||
|
||||
- name: x86_64-apple-2
|
||||
env:
|
||||
SCRIPT: ./x.py --stage 2 test src/test/ui src/test/rustdoc src/test/run-make-fulldeps
|
||||
<<: *env-x86_64-apple-tests
|
||||
<<: *job-macos-xl
|
||||
|
||||
# This target only needs to support 11.0 and up as nothing else supports the hardware
|
||||
- name: dist-aarch64-apple
|
||||
env:
|
||||
|
@ -1197,96 +1197,13 @@ window.initSearch = function(rawSearchIndex) {
|
||||
}
|
||||
|
||||
function execSearch(query, searchWords, filterCrates) {
|
||||
function getSmallest(arrays, positions, notDuplicates) {
|
||||
var start = null;
|
||||
|
||||
for (var it = 0, len = positions.length; it < len; ++it) {
|
||||
if (arrays[it].length > positions[it] &&
|
||||
(start === null || start > arrays[it][positions[it]].lev) &&
|
||||
!notDuplicates[arrays[it][positions[it]].fullPath]) {
|
||||
start = arrays[it][positions[it]].lev;
|
||||
}
|
||||
}
|
||||
return start;
|
||||
}
|
||||
|
||||
function mergeArrays(arrays) {
|
||||
var ret = [];
|
||||
var positions = [];
|
||||
var notDuplicates = {};
|
||||
|
||||
for (var x = 0, arrays_len = arrays.length; x < arrays_len; ++x) {
|
||||
positions.push(0);
|
||||
}
|
||||
while (ret.length < MAX_RESULTS) {
|
||||
var smallest = getSmallest(arrays, positions, notDuplicates);
|
||||
|
||||
if (smallest === null) {
|
||||
break;
|
||||
}
|
||||
for (x = 0; x < arrays_len && ret.length < MAX_RESULTS; ++x) {
|
||||
if (arrays[x].length > positions[x] &&
|
||||
arrays[x][positions[x]].lev === smallest &&
|
||||
!notDuplicates[arrays[x][positions[x]].fullPath]) {
|
||||
ret.push(arrays[x][positions[x]]);
|
||||
notDuplicates[arrays[x][positions[x]].fullPath] = true;
|
||||
positions[x] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Split search query by ",", while respecting angle bracket nesting.
|
||||
// Since "<" is an alias for the Ord family of traits, it also uses
|
||||
// lookahead to distinguish "<"-as-less-than from "<"-as-angle-bracket.
|
||||
//
|
||||
// tokenizeQuery("A<B, C>, D") == ["A<B, C>", "D"]
|
||||
// tokenizeQuery("A<B, C, D") == ["A<B", "C", "D"]
|
||||
function tokenizeQuery(raw) {
|
||||
var i, matched;
|
||||
var l = raw.length;
|
||||
var depth = 0;
|
||||
var nextAngle = /(<|>)/g;
|
||||
var ret = [];
|
||||
var start = 0;
|
||||
for (i = 0; i < l; ++i) {
|
||||
switch (raw[i]) {
|
||||
case "<":
|
||||
nextAngle.lastIndex = i + 1;
|
||||
matched = nextAngle.exec(raw);
|
||||
if (matched && matched[1] === '>') {
|
||||
depth += 1;
|
||||
}
|
||||
break;
|
||||
case ">":
|
||||
if (depth > 0) {
|
||||
depth -= 1;
|
||||
}
|
||||
break;
|
||||
case ",":
|
||||
if (depth === 0) {
|
||||
ret.push(raw.substring(start, i));
|
||||
start = i + 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (start !== i) {
|
||||
ret.push(raw.substring(start, i));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
var queries = tokenizeQuery(query.raw);
|
||||
query = query.raw.trim();
|
||||
var results = {
|
||||
"in_args": [],
|
||||
"returned": [],
|
||||
"others": [],
|
||||
};
|
||||
|
||||
for (var i = 0, len = queries.length; i < len; ++i) {
|
||||
query = queries[i].trim();
|
||||
if (query.length !== 0) {
|
||||
var tmp = execQuery(getQuery(query), searchWords, filterCrates);
|
||||
|
||||
@ -1294,14 +1211,6 @@ window.initSearch = function(rawSearchIndex) {
|
||||
results.returned.push(tmp.returned);
|
||||
results.others.push(tmp.others);
|
||||
}
|
||||
}
|
||||
if (queries.length > 1) {
|
||||
return {
|
||||
"in_args": mergeArrays(results.in_args),
|
||||
"returned": mergeArrays(results.returned),
|
||||
"others": mergeArrays(results.others),
|
||||
};
|
||||
}
|
||||
return {
|
||||
"in_args": results.in_args[0],
|
||||
"returned": results.returned[0],
|
||||
|
@ -1,10 +0,0 @@
|
||||
const QUERY = 'str,u8';
|
||||
|
||||
const EXPECTED = {
|
||||
'others': [
|
||||
{ 'path': 'std', 'name': 'str', 'href': '../std/primitive.str.html' },
|
||||
{ 'path': 'std', 'name': 'u8', 'href': '../std/primitive.u8.html' },
|
||||
{ 'path': 'std', 'name': 'str', 'href': '../std/str/index.html' },
|
||||
{ 'path': 'std', 'name': 'u8', 'href': '../std/u8/index.html' },
|
||||
],
|
||||
};
|
10
src/test/ui/associated-consts/issue-93835.rs
Normal file
10
src/test/ui/associated-consts/issue-93835.rs
Normal file
@ -0,0 +1,10 @@
|
||||
fn e() {
|
||||
p:a<p:p<e=6>>
|
||||
//~^ ERROR comparison operators
|
||||
//~| ERROR cannot find value
|
||||
//~| ERROR associated const equality
|
||||
//~| ERROR associated const equality
|
||||
//~| ERROR associated type bounds
|
||||
}
|
||||
|
||||
fn main() {}
|
66
src/test/ui/associated-consts/issue-93835.stderr
Normal file
66
src/test/ui/associated-consts/issue-93835.stderr
Normal file
@ -0,0 +1,66 @@
|
||||
error: comparison operators cannot be chained
|
||||
--> $DIR/issue-93835.rs:2:8
|
||||
|
|
||||
LL | fn e() {
|
||||
| - while parsing this struct
|
||||
LL | p:a<p:p<e=6>>
|
||||
| ^ ^
|
||||
|
|
||||
= help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
|
||||
= help: or use `(...)` if you meant to specify fn arguments
|
||||
|
||||
error[E0425]: cannot find value `p` in this scope
|
||||
--> $DIR/issue-93835.rs:2:5
|
||||
|
|
||||
LL | p:a<p:p<e=6>>
|
||||
| ^ not found in this scope
|
||||
|
|
||||
help: you might have meant to write a `struct` literal
|
||||
|
|
||||
LL ~ fn e() { SomeStruct {
|
||||
LL | p:a<p:p<e=6>>
|
||||
LL |
|
||||
LL |
|
||||
LL |
|
||||
LL |
|
||||
...
|
||||
help: maybe you meant to write a path separator here
|
||||
|
|
||||
LL | p::a<p:p<e=6>>
|
||||
| ~~
|
||||
help: maybe you meant to write an assignment here
|
||||
|
|
||||
LL | let p:a<p:p<e=6>>
|
||||
| ~~~~~
|
||||
|
||||
error[E0658]: associated const equality is incomplete
|
||||
--> $DIR/issue-93835.rs:2:13
|
||||
|
|
||||
LL | p:a<p:p<e=6>>
|
||||
| ^^^
|
||||
|
|
||||
= note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information
|
||||
= help: add `#![feature(associated_const_equality)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: associated const equality is incomplete
|
||||
--> $DIR/issue-93835.rs:2:13
|
||||
|
|
||||
LL | p:a<p:p<e=6>>
|
||||
| ^^^
|
||||
|
|
||||
= note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information
|
||||
= help: add `#![feature(associated_const_equality)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: associated type bounds are unstable
|
||||
--> $DIR/issue-93835.rs:2:9
|
||||
|
|
||||
LL | p:a<p:p<e=6>>
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
|
||||
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0425, E0658.
|
||||
For more information about an error, try `rustc --explain E0425`.
|
@ -386,7 +386,10 @@ impl Builder {
|
||||
// for users to install the additional component manually, if needed.
|
||||
if self.versions.channel() == "nightly" {
|
||||
self.extend_profile("complete", &mut manifest.profiles, &["rustc-dev"]);
|
||||
self.extend_profile("complete", &mut manifest.profiles, &["rustc-docs"]);
|
||||
// Do not include the rustc-docs component for now, as it causes
|
||||
// conflicts with the rust-docs component when installed. See
|
||||
// #75833.
|
||||
// self.extend_profile("complete", &mut manifest.profiles, &["rustc-docs"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user