Auto merge of #111076 - notriddle:notriddle/silence-private-dep-trait-impl-suggestions, r=cjgillot
diagnostics: exclude indirect private deps from trait impl suggest Fixes #88696
This commit is contained in:
commit
ad8304a0d5
21 changed files with 136 additions and 31 deletions
|
@ -139,9 +139,14 @@ cfg_if! {
|
||||||
|
|
||||||
impl Atomic<bool> {
|
impl Atomic<bool> {
|
||||||
pub fn fetch_or(&self, val: bool, _: Ordering) -> bool {
|
pub fn fetch_or(&self, val: bool, _: Ordering) -> bool {
|
||||||
let result = self.0.get() | val;
|
let old = self.0.get();
|
||||||
self.0.set(val);
|
self.0.set(val | old);
|
||||||
result
|
old
|
||||||
|
}
|
||||||
|
pub fn fetch_and(&self, val: bool, _: Ordering) -> bool {
|
||||||
|
let old = self.0.get();
|
||||||
|
self.0.set(val & old);
|
||||||
|
old
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -365,6 +365,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
||||||
lib: Library,
|
lib: Library,
|
||||||
dep_kind: CrateDepKind,
|
dep_kind: CrateDepKind,
|
||||||
name: Symbol,
|
name: Symbol,
|
||||||
|
private_dep: Option<bool>,
|
||||||
) -> Result<CrateNum, CrateError> {
|
) -> Result<CrateNum, CrateError> {
|
||||||
let _prof_timer = self.sess.prof.generic_activity("metadata_register_crate");
|
let _prof_timer = self.sess.prof.generic_activity("metadata_register_crate");
|
||||||
|
|
||||||
|
@ -372,8 +373,13 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
||||||
let crate_root = metadata.get_root();
|
let crate_root = metadata.get_root();
|
||||||
let host_hash = host_lib.as_ref().map(|lib| lib.metadata.get_root().hash());
|
let host_hash = host_lib.as_ref().map(|lib| lib.metadata.get_root().hash());
|
||||||
|
|
||||||
let private_dep =
|
let private_dep = self
|
||||||
self.sess.opts.externs.get(name.as_str()).is_some_and(|e| e.is_private_dep);
|
.sess
|
||||||
|
.opts
|
||||||
|
.externs
|
||||||
|
.get(name.as_str())
|
||||||
|
.map_or(private_dep.unwrap_or(false), |e| e.is_private_dep)
|
||||||
|
&& private_dep.unwrap_or(true);
|
||||||
|
|
||||||
// Claim this crate number and cache it
|
// Claim this crate number and cache it
|
||||||
let cnum = self.cstore.intern_stable_crate_id(&crate_root)?;
|
let cnum = self.cstore.intern_stable_crate_id(&crate_root)?;
|
||||||
|
@ -518,15 +524,16 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
||||||
if !name.as_str().is_ascii() {
|
if !name.as_str().is_ascii() {
|
||||||
return Err(CrateError::NonAsciiName(name));
|
return Err(CrateError::NonAsciiName(name));
|
||||||
}
|
}
|
||||||
let (root, hash, host_hash, extra_filename, path_kind) = match dep {
|
let (root, hash, host_hash, extra_filename, path_kind, private_dep) = match dep {
|
||||||
Some((root, dep)) => (
|
Some((root, dep)) => (
|
||||||
Some(root),
|
Some(root),
|
||||||
Some(dep.hash),
|
Some(dep.hash),
|
||||||
dep.host_hash,
|
dep.host_hash,
|
||||||
Some(&dep.extra_filename[..]),
|
Some(&dep.extra_filename[..]),
|
||||||
PathKind::Dependency,
|
PathKind::Dependency,
|
||||||
|
Some(dep.is_private),
|
||||||
),
|
),
|
||||||
None => (None, None, None, None, PathKind::Crate),
|
None => (None, None, None, None, PathKind::Crate, None),
|
||||||
};
|
};
|
||||||
let result = if let Some(cnum) = self.existing_match(name, hash, path_kind) {
|
let result = if let Some(cnum) = self.existing_match(name, hash, path_kind) {
|
||||||
(LoadResult::Previous(cnum), None)
|
(LoadResult::Previous(cnum), None)
|
||||||
|
@ -562,10 +569,13 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
||||||
dep_kind = CrateDepKind::MacrosOnly;
|
dep_kind = CrateDepKind::MacrosOnly;
|
||||||
}
|
}
|
||||||
data.update_dep_kind(|data_dep_kind| cmp::max(data_dep_kind, dep_kind));
|
data.update_dep_kind(|data_dep_kind| cmp::max(data_dep_kind, dep_kind));
|
||||||
|
if let Some(private_dep) = private_dep {
|
||||||
|
data.update_and_private_dep(private_dep);
|
||||||
|
}
|
||||||
Ok(cnum)
|
Ok(cnum)
|
||||||
}
|
}
|
||||||
(LoadResult::Loaded(library), host_library) => {
|
(LoadResult::Loaded(library), host_library) => {
|
||||||
self.register_crate(host_library, root, library, dep_kind, name)
|
self.register_crate(host_library, root, library, dep_kind, name, private_dep)
|
||||||
}
|
}
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ use rustc_data_structures::captures::Captures;
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_data_structures::owned_slice::OwnedSlice;
|
use rustc_data_structures::owned_slice::OwnedSlice;
|
||||||
use rustc_data_structures::svh::Svh;
|
use rustc_data_structures::svh::Svh;
|
||||||
use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc, OnceCell};
|
use rustc_data_structures::sync::{AppendOnlyVec, AtomicBool, Lock, Lrc, OnceCell};
|
||||||
use rustc_data_structures::unhash::UnhashMap;
|
use rustc_data_structures::unhash::UnhashMap;
|
||||||
use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
|
use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
|
||||||
use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, DeriveProcMacro};
|
use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, DeriveProcMacro};
|
||||||
|
@ -40,6 +40,7 @@ use proc_macro::bridge::client::ProcMacro;
|
||||||
use std::iter::TrustedLen;
|
use std::iter::TrustedLen;
|
||||||
use std::num::NonZeroUsize;
|
use std::num::NonZeroUsize;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use std::sync::atomic::Ordering;
|
||||||
use std::{io, iter, mem};
|
use std::{io, iter, mem};
|
||||||
|
|
||||||
pub(super) use cstore_impl::provide;
|
pub(super) use cstore_impl::provide;
|
||||||
|
@ -112,9 +113,10 @@ pub(crate) struct CrateMetadata {
|
||||||
dep_kind: Lock<CrateDepKind>,
|
dep_kind: Lock<CrateDepKind>,
|
||||||
/// Filesystem location of this crate.
|
/// Filesystem location of this crate.
|
||||||
source: Lrc<CrateSource>,
|
source: Lrc<CrateSource>,
|
||||||
/// Whether or not this crate should be consider a private dependency
|
/// Whether or not this crate should be consider a private dependency.
|
||||||
/// for purposes of the 'exported_private_dependencies' lint
|
/// Used by the 'exported_private_dependencies' lint, and for determining
|
||||||
private_dep: bool,
|
/// whether to emit suggestions that reference this crate.
|
||||||
|
private_dep: AtomicBool,
|
||||||
/// The hash for the host proc macro. Used to support `-Z dual-proc-macro`.
|
/// The hash for the host proc macro. Used to support `-Z dual-proc-macro`.
|
||||||
host_hash: Option<Svh>,
|
host_hash: Option<Svh>,
|
||||||
|
|
||||||
|
@ -701,12 +703,13 @@ impl MetadataBlob {
|
||||||
writeln!(out, "=External Dependencies=")?;
|
writeln!(out, "=External Dependencies=")?;
|
||||||
|
|
||||||
for (i, dep) in root.crate_deps.decode(self).enumerate() {
|
for (i, dep) in root.crate_deps.decode(self).enumerate() {
|
||||||
let CrateDep { name, extra_filename, hash, host_hash, kind } = dep;
|
let CrateDep { name, extra_filename, hash, host_hash, kind, is_private } = dep;
|
||||||
let number = i + 1;
|
let number = i + 1;
|
||||||
|
|
||||||
writeln!(
|
writeln!(
|
||||||
out,
|
out,
|
||||||
"{number} {name}{extra_filename} hash {hash} host_hash {host_hash:?} kind {kind:?}"
|
"{number} {name}{extra_filename} hash {hash} host_hash {host_hash:?} kind {kind:?} {privacy}",
|
||||||
|
privacy = if is_private { "private" } else { "public" }
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
write!(out, "\n")?;
|
write!(out, "\n")?;
|
||||||
|
@ -1624,7 +1627,7 @@ impl CrateMetadata {
|
||||||
dependencies,
|
dependencies,
|
||||||
dep_kind: Lock::new(dep_kind),
|
dep_kind: Lock::new(dep_kind),
|
||||||
source: Lrc::new(source),
|
source: Lrc::new(source),
|
||||||
private_dep,
|
private_dep: AtomicBool::new(private_dep),
|
||||||
host_hash,
|
host_hash,
|
||||||
extern_crate: Lock::new(None),
|
extern_crate: Lock::new(None),
|
||||||
hygiene_context: Default::default(),
|
hygiene_context: Default::default(),
|
||||||
|
@ -1672,6 +1675,10 @@ impl CrateMetadata {
|
||||||
self.dep_kind.with_lock(|dep_kind| *dep_kind = f(*dep_kind))
|
self.dep_kind.with_lock(|dep_kind| *dep_kind = f(*dep_kind))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn update_and_private_dep(&self, private_dep: bool) {
|
||||||
|
self.private_dep.fetch_and(private_dep, Ordering::SeqCst);
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn required_panic_strategy(&self) -> Option<PanicStrategy> {
|
pub(crate) fn required_panic_strategy(&self) -> Option<PanicStrategy> {
|
||||||
self.root.required_panic_strategy
|
self.root.required_panic_strategy
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,7 +285,13 @@ provide! { tcx, def_id, other, cdata,
|
||||||
is_ctfe_mir_available => { cdata.is_ctfe_mir_available(def_id.index) }
|
is_ctfe_mir_available => { cdata.is_ctfe_mir_available(def_id.index) }
|
||||||
|
|
||||||
dylib_dependency_formats => { cdata.get_dylib_dependency_formats(tcx) }
|
dylib_dependency_formats => { cdata.get_dylib_dependency_formats(tcx) }
|
||||||
is_private_dep => { cdata.private_dep }
|
is_private_dep => {
|
||||||
|
// Parallel compiler needs to synchronize type checking and linting (which use this flag)
|
||||||
|
// so that they happen strictly crate loading. Otherwise, the full list of available
|
||||||
|
// impls aren't loaded yet.
|
||||||
|
use std::sync::atomic::Ordering;
|
||||||
|
cdata.private_dep.load(Ordering::Acquire)
|
||||||
|
}
|
||||||
is_panic_runtime => { cdata.root.panic_runtime }
|
is_panic_runtime => { cdata.root.panic_runtime }
|
||||||
is_compiler_builtins => { cdata.root.compiler_builtins }
|
is_compiler_builtins => { cdata.root.compiler_builtins }
|
||||||
has_global_allocator => { cdata.root.has_global_allocator }
|
has_global_allocator => { cdata.root.has_global_allocator }
|
||||||
|
|
|
@ -1883,6 +1883,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
host_hash: self.tcx.crate_host_hash(cnum),
|
host_hash: self.tcx.crate_host_hash(cnum),
|
||||||
kind: self.tcx.dep_kind(cnum),
|
kind: self.tcx.dep_kind(cnum),
|
||||||
extra_filename: self.tcx.extra_filename(cnum).clone(),
|
extra_filename: self.tcx.extra_filename(cnum).clone(),
|
||||||
|
is_private: self.tcx.is_private_dep(cnum),
|
||||||
};
|
};
|
||||||
(cnum, dep)
|
(cnum, dep)
|
||||||
})
|
})
|
||||||
|
|
|
@ -322,6 +322,7 @@ pub(crate) struct CrateDep {
|
||||||
pub host_hash: Option<Svh>,
|
pub host_hash: Option<Svh>,
|
||||||
pub kind: CrateDepKind,
|
pub kind: CrateDepKind,
|
||||||
pub extra_filename: String,
|
pub extra_filename: String,
|
||||||
|
pub is_private: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(MetadataEncodable, MetadataDecodable)]
|
#[derive(MetadataEncodable, MetadataDecodable)]
|
||||||
|
|
|
@ -15,7 +15,7 @@ use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher};
|
||||||
use rustc_errors::ErrorGuaranteed;
|
use rustc_errors::ErrorGuaranteed;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{CtorOf, DefKind, Res};
|
use rustc_hir::def::{CtorOf, DefKind, Res};
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId};
|
||||||
use rustc_index::bit_set::GrowableBitSet;
|
use rustc_index::bit_set::GrowableBitSet;
|
||||||
use rustc_index::{Idx, IndexVec};
|
use rustc_index::{Idx, IndexVec};
|
||||||
use rustc_macros::HashStable;
|
use rustc_macros::HashStable;
|
||||||
|
@ -857,6 +857,26 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
_ => def_kind.article(),
|
_ => def_kind.article(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return `true` if the supplied `CrateNum` is "user-visible," meaning either a [public]
|
||||||
|
/// dependency, or a [direct] private dependency. This is used to decide whether the crate can
|
||||||
|
/// be shown in `impl` suggestions.
|
||||||
|
///
|
||||||
|
/// [public]: TyCtxt::is_private_dep
|
||||||
|
/// [direct]: rustc_session::cstore::ExternCrate::is_direct
|
||||||
|
pub fn is_user_visible_dep(self, key: CrateNum) -> bool {
|
||||||
|
// | Private | Direct | Visible | |
|
||||||
|
// |---------|--------|---------|--------------------|
|
||||||
|
// | Yes | Yes | Yes | !true || true |
|
||||||
|
// | No | Yes | Yes | !false || true |
|
||||||
|
// | Yes | No | No | !true || false |
|
||||||
|
// | No | No | Yes | !false || false |
|
||||||
|
!self.is_private_dep(key)
|
||||||
|
// If `extern_crate` is `None`, then the crate was injected (e.g., by the allocator).
|
||||||
|
// Treat that kind of crate as "indirect", since it's an implementation detail of
|
||||||
|
// the language.
|
||||||
|
|| self.extern_crate(key.as_def_id()).map_or(false, |e| e.is_direct())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct OpaqueTypeExpander<'tcx> {
|
struct OpaqueTypeExpander<'tcx> {
|
||||||
|
|
|
@ -1776,6 +1776,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||||
|| !trait_pred
|
|| !trait_pred
|
||||||
.skip_binder()
|
.skip_binder()
|
||||||
.is_constness_satisfied_by(self.tcx.constness(def_id))
|
.is_constness_satisfied_by(self.tcx.constness(def_id))
|
||||||
|
|| !self.tcx.is_user_visible_dep(def_id.krate)
|
||||||
{
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
cargo-features = ["public-dependency"]
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "std"
|
name = "std"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
|
@ -10,12 +12,12 @@ edition = "2021"
|
||||||
crate-type = ["dylib", "rlib"]
|
crate-type = ["dylib", "rlib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
alloc = { path = "../alloc" }
|
alloc = { path = "../alloc", public = true }
|
||||||
cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
|
cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
|
||||||
panic_unwind = { path = "../panic_unwind", optional = true }
|
panic_unwind = { path = "../panic_unwind", optional = true }
|
||||||
panic_abort = { path = "../panic_abort" }
|
panic_abort = { path = "../panic_abort" }
|
||||||
core = { path = "../core" }
|
core = { path = "../core", public = true }
|
||||||
libc = { version = "0.2.143", default-features = false, features = ['rustc-dep-of-std'] }
|
libc = { version = "0.2.143", default-features = false, features = ['rustc-dep-of-std'], public = true }
|
||||||
compiler_builtins = { version = "0.1.92" }
|
compiler_builtins = { version = "0.1.92" }
|
||||||
profiler_builtins = { path = "../profiler_builtins", optional = true }
|
profiler_builtins = { path = "../profiler_builtins", optional = true }
|
||||||
unwind = { path = "../unwind" }
|
unwind = { path = "../unwind" }
|
||||||
|
@ -25,7 +27,7 @@ std_detect = { path = "../stdarch/crates/std_detect", default-features = false,
|
||||||
# Dependencies of the `backtrace` crate
|
# Dependencies of the `backtrace` crate
|
||||||
addr2line = { version = "0.19.0", optional = true, default-features = false }
|
addr2line = { version = "0.19.0", optional = true, default-features = false }
|
||||||
rustc-demangle = { version = "0.1.21", features = ['rustc-dep-of-std'] }
|
rustc-demangle = { version = "0.1.21", features = ['rustc-dep-of-std'] }
|
||||||
miniz_oxide = { version = "0.6.0", optional = true, default-features = false }
|
miniz_oxide = { version = "0.6.0", optional = true, default-features = false, public = false }
|
||||||
[dependencies.object]
|
[dependencies.object]
|
||||||
version = "0.30.0"
|
version = "0.30.0"
|
||||||
optional = true
|
optional = true
|
||||||
|
@ -40,7 +42,7 @@ rand_xorshift = "0.3.0"
|
||||||
dlmalloc = { version = "0.2.3", features = ['rustc-dep-of-std'] }
|
dlmalloc = { version = "0.2.3", features = ['rustc-dep-of-std'] }
|
||||||
|
|
||||||
[target.x86_64-fortanix-unknown-sgx.dependencies]
|
[target.x86_64-fortanix-unknown-sgx.dependencies]
|
||||||
fortanix-sgx-abi = { version = "0.5.0", features = ['rustc-dep-of-std'] }
|
fortanix-sgx-abi = { version = "0.5.0", features = ['rustc-dep-of-std'], public = true }
|
||||||
|
|
||||||
[target.'cfg(target_os = "hermit")'.dependencies]
|
[target.'cfg(target_os = "hermit")'.dependencies]
|
||||||
hermit-abi = { version = "0.3.0", features = ['rustc-dep-of-std'] }
|
hermit-abi = { version = "0.3.0", features = ['rustc-dep-of-std'] }
|
||||||
|
|
|
@ -96,7 +96,7 @@ impl WasiFd {
|
||||||
unsafe { wasi::fd_sync(self.as_raw_fd() as wasi::Fd).map_err(err2io) }
|
unsafe { wasi::fd_sync(self.as_raw_fd() as wasi::Fd).map_err(err2io) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn advise(&self, offset: u64, len: u64, advice: wasi::Advice) -> io::Result<()> {
|
pub(crate) fn advise(&self, offset: u64, len: u64, advice: wasi::Advice) -> io::Result<()> {
|
||||||
unsafe {
|
unsafe {
|
||||||
wasi::fd_advise(self.as_raw_fd() as wasi::Fd, offset, len, advice).map_err(err2io)
|
wasi::fd_advise(self.as_raw_fd() as wasi::Fd, offset, len, advice).map_err(err2io)
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ impl WasiFd {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn filestat_get(&self) -> io::Result<wasi::Filestat> {
|
pub(crate) fn filestat_get(&self) -> io::Result<wasi::Filestat> {
|
||||||
unsafe { wasi::fd_filestat_get(self.as_raw_fd() as wasi::Fd).map_err(err2io) }
|
unsafe { wasi::fd_filestat_get(self.as_raw_fd() as wasi::Fd).map_err(err2io) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ impl WasiFd {
|
||||||
unsafe { wasi::fd_filestat_set_size(self.as_raw_fd() as wasi::Fd, size).map_err(err2io) }
|
unsafe { wasi::fd_filestat_set_size(self.as_raw_fd() as wasi::Fd, size).map_err(err2io) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn path_filestat_get(
|
pub(crate) fn path_filestat_get(
|
||||||
&self,
|
&self,
|
||||||
flags: wasi::Lookupflags,
|
flags: wasi::Lookupflags,
|
||||||
path: &str,
|
path: &str,
|
||||||
|
|
|
@ -104,7 +104,7 @@ impl FileAttr {
|
||||||
Ok(SystemTime::from_wasi_timestamp(self.meta.ctim))
|
Ok(SystemTime::from_wasi_timestamp(self.meta.ctim))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_wasi(&self) -> &wasi::Filestat {
|
pub(crate) fn as_wasi(&self) -> &wasi::Filestat {
|
||||||
&self.meta
|
&self.meta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ impl FileType {
|
||||||
self.bits == wasi::FILETYPE_SYMBOLIC_LINK
|
self.bits == wasi::FILETYPE_SYMBOLIC_LINK
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bits(&self) -> wasi::Filetype {
|
pub(crate) fn bits(&self) -> wasi::Filetype {
|
||||||
self.bits
|
self.bits
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,15 +20,15 @@ pub(crate) fn test_rng() -> rand_xorshift::XorShiftRng {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copied from std::sys_common::io
|
// Copied from std::sys_common::io
|
||||||
pub struct TempDir(PathBuf);
|
pub(crate) struct TempDir(PathBuf);
|
||||||
|
|
||||||
impl TempDir {
|
impl TempDir {
|
||||||
pub fn join(&self, path: &str) -> PathBuf {
|
pub(crate) fn join(&self, path: &str) -> PathBuf {
|
||||||
let TempDir(ref p) = *self;
|
let TempDir(ref p) = *self;
|
||||||
p.join(path)
|
p.join(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn path(&self) -> &Path {
|
pub(crate) fn path(&self) -> &Path {
|
||||||
let TempDir(ref p) = *self;
|
let TempDir(ref p) = *self;
|
||||||
p
|
p
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ impl Drop for TempDir {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller] // for `test_rng`
|
#[track_caller] // for `test_rng`
|
||||||
pub fn tmpdir() -> TempDir {
|
pub(crate) fn tmpdir() -> TempDir {
|
||||||
let p = env::temp_dir();
|
let p = env::temp_dir();
|
||||||
let mut r = test_rng();
|
let mut r = test_rng();
|
||||||
let ret = p.join(&format!("rust-{}", r.next_u32()));
|
let ret = p.join(&format!("rust-{}", r.next_u32()));
|
||||||
|
|
|
@ -1009,6 +1009,9 @@ impl Step for PlainSourceTarball {
|
||||||
.arg(builder.src.join("./compiler/rustc_codegen_cranelift/Cargo.toml"))
|
.arg(builder.src.join("./compiler/rustc_codegen_cranelift/Cargo.toml"))
|
||||||
.arg("--sync")
|
.arg("--sync")
|
||||||
.arg(builder.src.join("./src/bootstrap/Cargo.toml"))
|
.arg(builder.src.join("./src/bootstrap/Cargo.toml"))
|
||||||
|
// Will read the libstd Cargo.toml
|
||||||
|
// which uses the unstable `public-dependency` feature.
|
||||||
|
.env("RUSTC_BOOTSTRAP", "1")
|
||||||
.current_dir(&plain_dst_src);
|
.current_dir(&plain_dst_src);
|
||||||
|
|
||||||
let config = if !builder.config.dry_run() {
|
let config = if !builder.config.dry_run() {
|
||||||
|
|
|
@ -74,6 +74,9 @@ fn workspace_members(build: &Build) -> impl Iterator<Item = Package> {
|
||||||
let collect_metadata = |manifest_path| {
|
let collect_metadata = |manifest_path| {
|
||||||
let mut cargo = Command::new(&build.initial_cargo);
|
let mut cargo = Command::new(&build.initial_cargo);
|
||||||
cargo
|
cargo
|
||||||
|
// Will read the libstd Cargo.toml
|
||||||
|
// which uses the unstable `public-dependency` feature.
|
||||||
|
.env("RUSTC_BOOTSTRAP", "1")
|
||||||
.arg("metadata")
|
.arg("metadata")
|
||||||
.arg("--format-version")
|
.arg("--format-version")
|
||||||
.arg("1")
|
.arg("1")
|
||||||
|
|
|
@ -2499,6 +2499,9 @@ impl Step for Distcheck {
|
||||||
let toml = dir.join("rust-src/lib/rustlib/src/rust/library/std/Cargo.toml");
|
let toml = dir.join("rust-src/lib/rustlib/src/rust/library/std/Cargo.toml");
|
||||||
builder.run(
|
builder.run(
|
||||||
Command::new(&builder.initial_cargo)
|
Command::new(&builder.initial_cargo)
|
||||||
|
// Will read the libstd Cargo.toml
|
||||||
|
// which uses the unstable `public-dependency` feature.
|
||||||
|
.env("RUSTC_BOOTSTRAP", "1")
|
||||||
.arg("generate-lockfile")
|
.arg("generate-lockfile")
|
||||||
.arg("--manifest-path")
|
.arg("--manifest-path")
|
||||||
.arg(&toml)
|
.arg(&toml)
|
||||||
|
|
|
@ -11,5 +11,9 @@ abs_path() {
|
||||||
(unset CDPATH && cd "$path" > /dev/null && pwd)
|
(unset CDPATH && cd "$path" > /dev/null && pwd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Running cargo will read the libstd Cargo.toml
|
||||||
|
# which uses the unstable `public-dependency` feature.
|
||||||
|
export RUSTC_BOOTSTRAP=1
|
||||||
|
|
||||||
src_dir="$(abs_path $(dirname "$0"))"
|
src_dir="$(abs_path $(dirname "$0"))"
|
||||||
$CARGO run --manifest-path="$src_dir/Cargo.toml" -- combine "$@"
|
$CARGO run --manifest-path="$src_dir/Cargo.toml" -- combine "$@"
|
||||||
|
|
|
@ -11,5 +11,9 @@ abs_path() {
|
||||||
(unset CDPATH && cd "$path" > /dev/null && pwd)
|
(unset CDPATH && cd "$path" > /dev/null && pwd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Running cargo will read the libstd Cargo.toml
|
||||||
|
# which uses the unstable `public-dependency` feature.
|
||||||
|
export RUSTC_BOOTSTRAP=1
|
||||||
|
|
||||||
src_dir="$(abs_path $(dirname "$0"))"
|
src_dir="$(abs_path $(dirname "$0"))"
|
||||||
$CARGO run --manifest-path="$src_dir/Cargo.toml" -- generate "$@"
|
$CARGO run --manifest-path="$src_dir/Cargo.toml" -- generate "$@"
|
||||||
|
|
|
@ -11,5 +11,9 @@ abs_path() {
|
||||||
(unset CDPATH && cd "$path" > /dev/null && pwd)
|
(unset CDPATH && cd "$path" > /dev/null && pwd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Running cargo will read the libstd Cargo.toml
|
||||||
|
# which uses the unstable `public-dependency` feature.
|
||||||
|
export RUSTC_BOOTSTRAP=1
|
||||||
|
|
||||||
src_dir="$(abs_path $(dirname "$0"))"
|
src_dir="$(abs_path $(dirname "$0"))"
|
||||||
$CARGO run --manifest-path="$src_dir/Cargo.toml" -- tarball "$@"
|
$CARGO run --manifest-path="$src_dir/Cargo.toml" -- tarball "$@"
|
||||||
|
|
|
@ -16,6 +16,12 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::thread::{self, scope, ScopedJoinHandle};
|
use std::thread::{self, scope, ScopedJoinHandle};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
// Running Cargo will read the libstd Cargo.toml
|
||||||
|
// which uses the unstable `public-dependency` feature.
|
||||||
|
//
|
||||||
|
// `setenv` might not be thread safe, so run it before using multiple threads.
|
||||||
|
env::set_var("RUSTC_BOOTSTRAP", "1");
|
||||||
|
|
||||||
let root_path: PathBuf = env::args_os().nth(1).expect("need path to root of repo").into();
|
let root_path: PathBuf = env::args_os().nth(1).expect("need path to root of repo").into();
|
||||||
let cargo: PathBuf = env::args_os().nth(2).expect("need path to cargo").into();
|
let cargo: PathBuf = env::args_os().nth(2).expect("need path to cargo").into();
|
||||||
let output_directory: PathBuf =
|
let output_directory: PathBuf =
|
||||||
|
|
14
tests/ui/suggestions/issue-88696.rs
Normal file
14
tests/ui/suggestions/issue-88696.rs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
// This test case should ensure that miniz_oxide isn't
|
||||||
|
// suggested, since it's not a direct dependency.
|
||||||
|
|
||||||
|
fn a() -> Result<u64, i32> {
|
||||||
|
Err(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn b() -> Result<u32, i32> {
|
||||||
|
a().into() //~ERROR [E0277]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _ = dbg!(b());
|
||||||
|
}
|
11
tests/ui/suggestions/issue-88696.stderr
Normal file
11
tests/ui/suggestions/issue-88696.stderr
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
error[E0277]: the trait bound `Result<u32, i32>: From<Result<u64, i32>>` is not satisfied
|
||||||
|
--> $DIR/issue-88696.rs:9:9
|
||||||
|
|
|
||||||
|
LL | a().into()
|
||||||
|
| ^^^^ the trait `From<Result<u64, i32>>` is not implemented for `Result<u32, i32>`
|
||||||
|
|
|
||||||
|
= note: required for `Result<u64, i32>` to implement `Into<Result<u32, i32>>`
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0277`.
|
Loading…
Add table
Add a link
Reference in a new issue