Auto merge of #98123 - JohnTitor:rollup-rfg1a4s, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #97822 (Filter out intrinsics if we have other import candidates to suggest)
 - #98026 (Move some tests to more reasonable directories)
 - #98067 (compiler: remove unused deps)
 - #98078 (Use unchecked mul to compute slice sizes)
 - #98083 (Rename rustc_serialize::opaque::Encoder as MemEncoder.)
 - #98087 (Suggest adding a `#[macro_export]` to a private macro)
 - #98113 (Fix misspelling of "constraint" as "contraint")

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2022-06-15 05:39:29 +00:00
commit 389352c4bb
69 changed files with 322 additions and 206 deletions

View File

@ -3678,7 +3678,6 @@ dependencies = [
"libloading",
"measureme 10.0.0",
"rustc-demangle",
"rustc_arena",
"rustc_ast",
"rustc_attr",
"rustc_codegen_ssa",
@ -3801,7 +3800,6 @@ dependencies = [
"rustc_ast",
"rustc_ast_pretty",
"rustc_codegen_ssa",
"rustc_const_eval",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
@ -3816,7 +3814,6 @@ dependencies = [
"rustc_parse",
"rustc_plugin_impl",
"rustc_save_analysis",
"rustc_serialize",
"rustc_session",
"rustc_span",
"rustc_target",
@ -3912,7 +3909,6 @@ dependencies = [
"rustc_ast",
"rustc_data_structures",
"rustc_error_messages",
"rustc_feature",
"rustc_index",
"rustc_macros",
"rustc_serialize",
@ -3973,7 +3969,6 @@ dependencies = [
"rustc_macros",
"rustc_middle",
"rustc_serialize",
"rustc_session",
"rustc_span",
"rustc_target",
"smallvec",
@ -4207,7 +4202,6 @@ dependencies = [
"rustc_index",
"rustc_middle",
"rustc_serialize",
"rustc_session",
"rustc_span",
"rustc_target",
"smallvec",
@ -4229,7 +4223,6 @@ dependencies = [
"rustc_index",
"rustc_middle",
"rustc_mir_dataflow",
"rustc_query_system",
"rustc_serialize",
"rustc_session",
"rustc_span",
@ -4244,7 +4237,6 @@ name = "rustc_monomorphize"
version = "0.0.0"
dependencies = [
"rustc_data_structures",
"rustc_errors",
"rustc_hir",
"rustc_index",
"rustc_middle",
@ -4296,7 +4288,6 @@ dependencies = [
"rustc_index",
"rustc_lexer",
"rustc_middle",
"rustc_parse",
"rustc_serialize",
"rustc_session",
"rustc_span",
@ -4311,10 +4302,8 @@ dependencies = [
"libloading",
"rustc_ast",
"rustc_errors",
"rustc_hir",
"rustc_lint",
"rustc_metadata",
"rustc_middle",
"rustc_session",
"rustc_span",
]
@ -4353,7 +4342,6 @@ dependencies = [
"rustc_serialize",
"rustc_session",
"rustc_span",
"rustc_type_ir",
"tracing",
]
@ -4375,7 +4363,6 @@ dependencies = [
"rustc_session",
"rustc_span",
"rustc_target",
"rustc_type_ir",
"smallvec",
"tracing",
]
@ -4495,7 +4482,6 @@ dependencies = [
"rustc_data_structures",
"rustc_hir",
"rustc_middle",
"rustc_query_system",
"rustc_session",
"rustc_span",
"rustc_target",

View File

@ -31,7 +31,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::thin_vec::ThinVec;
use rustc_macros::HashStable_Generic;
use rustc_serialize::{self, Decoder, Encoder};
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use rustc_span::source_map::{respan, Spanned};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
@ -2488,11 +2488,11 @@ rustc_index::newtype_index! {
}
}
impl<S: Encoder> rustc_serialize::Encodable<S> for AttrId {
impl<S: Encoder> Encodable<S> for AttrId {
fn encode(&self, _s: &mut S) {}
}
impl<D: Decoder> rustc_serialize::Decodable<D> for AttrId {
impl<D: Decoder> Decodable<D> for AttrId {
fn decode(_: &mut D) -> AttrId {
crate::attr::mk_attr_id()
}

View File

@ -871,7 +871,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
self.lower_angle_bracketed_parameter_data(data, ParamMode::Explicit, itctx).0
}
GenericArgs::Parenthesized(ref data) => {
self.assoc_ty_contraint_param_error_emit(data);
self.emit_bad_parenthesized_trait_in_assoc_ty(data);
self.lower_angle_bracketed_parameter_data(
&data.as_angle_bracketed_args(),
ParamMode::Explicit,
@ -982,7 +982,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
}
fn assoc_ty_contraint_param_error_emit(&self, data: &ParenthesizedArgs) -> () {
fn emit_bad_parenthesized_trait_in_assoc_ty(&self, data: &ParenthesizedArgs) {
let mut err = self.sess.struct_span_err(
data.span,
"parenthesized generic arguments cannot be used in associated type constraints",

View File

@ -16,7 +16,6 @@ measureme = "10.0.0"
tracing = "0.1"
rustc_middle = { path = "../rustc_middle" }
rustc-demangle = "0.1.21"
rustc_arena = { path = "../rustc_arena" }
rustc_attr = { path = "../rustc_attr" }
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
rustc_symbol_mangling = { path = "../rustc_symbol_mangling" }

View File

@ -39,7 +39,12 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
// The info in this case is the length of the str, so the size is that
// times the unit size.
(
bx.mul(info.unwrap(), bx.const_usize(unit.size.bytes())),
// All slice sizes must fit into `isize`, so this multiplication cannot (signed) wrap.
// NOTE: ideally, we want the effects of both `unchecked_smul` and `unchecked_umul`
// (resulting in `mul nsw nuw` in LLVM IR), since we know that the multiplication
// cannot signed wrap, and that both operands are non-negative. But at the time of writing,
// `BuilderMethods` can't do this, and it doesn't seem to enable any further optimizations.
bx.unchecked_smul(info.unwrap(), bx.const_usize(unit.size.bytes())),
bx.const_usize(unit.align.abi.bytes()),
)
}

View File

@ -29,7 +29,8 @@ use rustc_middle::dep_graph::WorkProduct;
use rustc_middle::middle::dependency_format::Dependencies;
use rustc_middle::middle::exported_symbols::SymbolExportKind;
use rustc_middle::ty::query::{ExternProviders, Providers};
use rustc_serialize::{opaque, Decodable, Decoder, Encodable, Encoder};
use rustc_serialize::opaque::{MemDecoder, MemEncoder};
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use rustc_session::config::{CrateType, OutputFilenames, OutputType, RUST_CGU_EXT};
use rustc_session::cstore::{self, CrateSource};
use rustc_session::utils::NativeLibKind;
@ -203,7 +204,7 @@ const RUSTC_VERSION: Option<&str> = option_env!("CFG_VERSION");
impl CodegenResults {
pub fn serialize_rlink(codegen_results: &CodegenResults) -> Vec<u8> {
let mut encoder = opaque::Encoder::new();
let mut encoder = MemEncoder::new();
encoder.emit_raw_bytes(RLINK_MAGIC);
// `emit_raw_bytes` is used to make sure that the version representation does not depend on
// Encoder's inner representation of `u32`.
@ -230,7 +231,7 @@ impl CodegenResults {
return Err(".rlink file was produced with encoding version {version_array}, but the current version is {RLINK_VERSION}".to_string());
}
let mut decoder = opaque::Decoder::new(&data[4..], 0);
let mut decoder = MemDecoder::new(&data[4..], 0);
let rustc_version = decoder.read_str();
let current_version = RUSTC_VERSION.unwrap();
if rustc_version != current_version {

View File

@ -1,5 +1,5 @@
use crate::stable_hasher;
use rustc_serialize::{Decodable, Encodable};
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use std::convert::TryInto;
use std::hash::{Hash, Hasher};
@ -142,14 +142,14 @@ impl stable_hasher::StableHasherResult for Fingerprint {
impl_stable_hash_via_hash!(Fingerprint);
impl<E: rustc_serialize::Encoder> Encodable<E> for Fingerprint {
impl<E: Encoder> Encodable<E> for Fingerprint {
#[inline]
fn encode(&self, s: &mut E) {
s.emit_raw_bytes(&self.to_le_bytes());
}
}
impl<D: rustc_serialize::Decoder> Decodable<D> for Fingerprint {
impl<D: Decoder> Decodable<D> for Fingerprint {
#[inline]
fn decode(d: &mut D) -> Self {
Fingerprint::from_le_bytes(d.read_raw_bytes(16).try_into().unwrap())
@ -184,7 +184,7 @@ impl std::fmt::Display for PackedFingerprint {
}
}
impl<E: rustc_serialize::Encoder> Encodable<E> for PackedFingerprint {
impl<E: Encoder> Encodable<E> for PackedFingerprint {
#[inline]
fn encode(&self, s: &mut E) {
// Copy to avoid taking reference to packed field.
@ -193,7 +193,7 @@ impl<E: rustc_serialize::Encoder> Encodable<E> for PackedFingerprint {
}
}
impl<D: rustc_serialize::Decoder> Decodable<D> for PackedFingerprint {
impl<D: Decoder> Decodable<D> for PackedFingerprint {
#[inline]
fn decode(d: &mut D) -> Self {
Self(Fingerprint::decode(d))

View File

@ -7,7 +7,6 @@ edition = "2021"
crate-type = ["dylib"]
[dependencies]
libc = "0.2"
tracing = { version = "0.1.28" }
serde_json = "1.0.59"
rustc_log = { path = "../rustc_log" }
@ -21,7 +20,6 @@ rustc_feature = { path = "../rustc_feature" }
rustc_hir = { path = "../rustc_hir" }
rustc_hir_pretty = { path = "../rustc_hir_pretty" }
rustc_metadata = { path = "../rustc_metadata" }
rustc_const_eval = { path = "../rustc_const_eval" }
rustc_parse = { path = "../rustc_parse" }
rustc_plugin_impl = { path = "../rustc_plugin_impl" }
rustc_save_analysis = { path = "../rustc_save_analysis" }
@ -29,11 +27,13 @@ rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
rustc_session = { path = "../rustc_session" }
rustc_error_codes = { path = "../rustc_error_codes" }
rustc_interface = { path = "../rustc_interface" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_ast = { path = "../rustc_ast" }
rustc_span = { path = "../rustc_span" }
rustc_typeck = { path = "../rustc_typeck" }
[target.'cfg(unix)'.dependencies]
libc = "0.2"
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["consoleapi", "debugapi", "processenv"] }

View File

@ -8,7 +8,6 @@ doctest = false
[dependencies]
rustc_target = { path = "../rustc_target" }
rustc_feature = { path = "../rustc_feature" }
rustc_macros = { path = "../rustc_macros" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_error_messages = { path = "../rustc_error_messages" }

View File

@ -4,7 +4,7 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::memmap::Mmap;
use rustc_middle::dep_graph::{SerializedDepGraph, WorkProduct, WorkProductId};
use rustc_middle::ty::OnDiskCache;
use rustc_serialize::opaque::Decoder;
use rustc_serialize::opaque::MemDecoder;
use rustc_serialize::Decodable;
use rustc_session::config::IncrementalStateAssertion;
use rustc_session::Session;
@ -156,7 +156,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
if let LoadResult::Ok { data: (work_products_data, start_pos) } = load_result {
// Decode the list of work_products
let mut work_product_decoder = Decoder::new(&work_products_data[..], start_pos);
let mut work_product_decoder = MemDecoder::new(&work_products_data[..], start_pos);
let work_products: Vec<SerializedWorkProduct> =
Decodable::decode(&mut work_product_decoder);
@ -193,7 +193,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
LoadResult::DataOutOfDate => LoadResult::DataOutOfDate,
LoadResult::Error { message } => LoadResult::Error { message },
LoadResult::Ok { data: (bytes, start_pos) } => {
let mut decoder = Decoder::new(&bytes, start_pos);
let mut decoder = MemDecoder::new(&bytes, start_pos);
let prev_commandline_args_hash = u64::decode(&mut decoder);
if prev_commandline_args_hash != expected_hash {

View File

@ -14,7 +14,6 @@ rustc_errors = { path = "../rustc_errors" }
rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" }
rustc_macros = { path = "../rustc_macros" }
rustc_session = { path = "../rustc_session" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_span = { path = "../rustc_span" }
rustc_target = { path = "../rustc_target" }

View File

@ -7,7 +7,6 @@ edition = "2021"
doctest = false
[dependencies]
libc = "0.2"
libloading = "0.7.1"
tracing = "0.1"
rustc-rayon-core = { version = "0.4.0", optional = true }
@ -49,6 +48,9 @@ rustc_trait_selection = { path = "../rustc_trait_selection" }
rustc_ty_utils = { path = "../rustc_ty_utils" }
tempfile = "3.2"
[target.'cfg(unix)'.dependencies]
libc = "0.2"
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["libloaderapi"] }

View File

@ -26,7 +26,8 @@ use rustc_middle::ty::codec::TyDecoder;
use rustc_middle::ty::fast_reject::SimplifiedType;
use rustc_middle::ty::GeneratorDiagnosticData;
use rustc_middle::ty::{self, ParameterizedOverTcx, Ty, TyCtxt, Visibility};
use rustc_serialize::{opaque, Decodable, Decoder};
use rustc_serialize::opaque::MemDecoder;
use rustc_serialize::{Decodable, Decoder};
use rustc_session::cstore::{
CrateSource, ExternCrate, ForeignModule, LinkagePreference, NativeLib,
};
@ -154,7 +155,7 @@ struct ImportedSourceFile {
}
pub(super) struct DecodeContext<'a, 'tcx> {
opaque: opaque::Decoder<'a>,
opaque: MemDecoder<'a>,
cdata: Option<CrateMetadataRef<'a>>,
blob: &'a MetadataBlob,
sess: Option<&'tcx Session>,
@ -186,7 +187,7 @@ pub(super) trait Metadata<'a, 'tcx>: Copy {
fn decoder(self, pos: usize) -> DecodeContext<'a, 'tcx> {
let tcx = self.tcx();
DecodeContext {
opaque: opaque::Decoder::new(self.blob(), pos),
opaque: MemDecoder::new(self.blob(), pos),
cdata: self.cdata(),
blob: self.blob(),
sess: self.sess().or(tcx.map(|tcx| tcx.sess)),
@ -418,7 +419,7 @@ impl<'a, 'tcx> TyDecoder for DecodeContext<'a, 'tcx> {
where
F: FnOnce(&mut Self) -> R,
{
let new_opaque = opaque::Decoder::new(self.opaque.data, pos);
let new_opaque = MemDecoder::new(self.opaque.data, pos);
let old_opaque = mem::replace(&mut self.opaque, new_opaque);
let old_state = mem::replace(&mut self.lazy_state, LazyState::NoNode);
let r = f(self);

View File

@ -27,7 +27,8 @@ use rustc_middle::ty::codec::TyEncoder;
use rustc_middle::ty::fast_reject::{self, SimplifiedType, TreatParams};
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self, SymbolName, Ty, TyCtxt};
use rustc_serialize::{opaque, Encodable, Encoder};
use rustc_serialize::opaque::MemEncoder;
use rustc_serialize::{Encodable, Encoder};
use rustc_session::config::CrateType;
use rustc_session::cstore::{ForeignModule, LinkagePreference, NativeLib};
use rustc_span::hygiene::{ExpnIndex, HygieneEncodeContext, MacroKind};
@ -43,7 +44,7 @@ use std::num::NonZeroUsize;
use tracing::{debug, trace};
pub(super) struct EncodeContext<'a, 'tcx> {
opaque: opaque::Encoder,
opaque: MemEncoder,
tcx: TyCtxt<'tcx>,
feat: &'tcx rustc_feature::Features,
@ -93,8 +94,8 @@ macro_rules! encoder_methods {
}
impl<'a, 'tcx> Encoder for EncodeContext<'a, 'tcx> {
type Ok = <opaque::Encoder as Encoder>::Ok;
type Err = <opaque::Encoder as Encoder>::Err;
type Ok = <MemEncoder as Encoder>::Ok;
type Err = <MemEncoder as Encoder>::Err;
encoder_methods! {
emit_usize(usize);
@ -2180,7 +2181,7 @@ pub fn encode_metadata(tcx: TyCtxt<'_>) -> EncodedMetadata {
}
fn encode_metadata_impl(tcx: TyCtxt<'_>) -> EncodedMetadata {
let mut encoder = opaque::Encoder::new();
let mut encoder = MemEncoder::new();
encoder.emit_raw_bytes(METADATA_HEADER);
// Will be filled with the root position after encoding everything.

View File

@ -22,7 +22,7 @@ use rustc_middle::ty::fast_reject::SimplifiedType;
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self, ReprOptions, Ty};
use rustc_middle::ty::{GeneratorDiagnosticData, ParameterizedOverTcx, TyCtxt};
use rustc_serialize::opaque::Encoder;
use rustc_serialize::opaque::MemEncoder;
use rustc_session::config::SymbolManglingVersion;
use rustc_session::cstore::{CrateDepKind, ForeignModule, LinkagePreference, NativeLib};
use rustc_span::edition::Edition;
@ -323,7 +323,7 @@ macro_rules! define_tables {
}
impl TableBuilders {
fn encode(&self, buf: &mut Encoder) -> LazyTables {
fn encode(&self, buf: &mut MemEncoder) -> LazyTables {
LazyTables {
$($name: self.$name.encode(buf)),+
}

View File

@ -4,8 +4,8 @@ use rustc_data_structures::fingerprint::Fingerprint;
use rustc_hir::def::{CtorKind, CtorOf};
use rustc_index::vec::Idx;
use rustc_middle::ty::ParameterizedOverTcx;
use rustc_serialize::opaque::Encoder;
use rustc_serialize::Encoder as _;
use rustc_serialize::opaque::MemEncoder;
use rustc_serialize::Encoder;
use rustc_span::hygiene::MacroKind;
use std::convert::TryInto;
use std::marker::PhantomData;
@ -281,7 +281,7 @@ where
Some(value).write_to_bytes(&mut self.blocks[i]);
}
pub(crate) fn encode<const N: usize>(&self, buf: &mut Encoder) -> LazyTable<I, T>
pub(crate) fn encode<const N: usize>(&self, buf: &mut MemEncoder) -> LazyTable<I, T>
where
Option<T>: FixedSizeEncoding<ByteArray = [u8; N]>,
{

View File

@ -3,7 +3,7 @@ use rustc_data_structures::graph::{
};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::OnceCell;
use rustc_serialize as serialize;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
/// Helper type to cache the result of `graph::is_cyclic`.
#[derive(Clone, Debug)]
@ -36,17 +36,17 @@ impl GraphIsCyclicCache {
}
}
impl<S: serialize::Encoder> serialize::Encodable<S> for GraphIsCyclicCache {
impl<S: Encoder> Encodable<S> for GraphIsCyclicCache {
#[inline]
fn encode(&self, s: &mut S) {
serialize::Encodable::encode(&(), s);
Encodable::encode(&(), s);
}
}
impl<D: serialize::Decoder> serialize::Decodable<D> for GraphIsCyclicCache {
impl<D: Decoder> Decodable<D> for GraphIsCyclicCache {
#[inline]
fn decode(d: &mut D) -> Self {
let () = serialize::Decodable::decode(d);
let () = Decodable::decode(d);
Self::new()
}
}

View File

@ -3,7 +3,7 @@
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::OnceCell;
use rustc_index::vec::IndexVec;
use rustc_serialize as serialize;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use smallvec::SmallVec;
use crate::mir::{BasicBlock, BasicBlockData};
@ -54,12 +54,12 @@ impl PredecessorCache {
}
}
impl<S: serialize::Encoder> serialize::Encodable<S> for PredecessorCache {
impl<S: Encoder> Encodable<S> for PredecessorCache {
#[inline]
fn encode(&self, _s: &mut S) {}
}
impl<D: serialize::Decoder> serialize::Decodable<D> for PredecessorCache {
impl<D: Decoder> Decodable<D> for PredecessorCache {
#[inline]
fn decode(_: &mut D) -> Self {
Self::new()

View File

@ -5,7 +5,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::stable_map::FxHashMap;
use rustc_data_structures::sync::OnceCell;
use rustc_index::vec::IndexVec;
use rustc_serialize as serialize;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use smallvec::SmallVec;
use crate::mir::{BasicBlock, BasicBlockData, Terminator, TerminatorKind};
@ -54,12 +54,12 @@ impl SwitchSourceCache {
}
}
impl<S: serialize::Encoder> serialize::Encodable<S> for SwitchSourceCache {
impl<S: Encoder> Encodable<S> for SwitchSourceCache {
#[inline]
fn encode(&self, _s: &mut S) {}
}
impl<D: serialize::Decoder> serialize::Decodable<D> for SwitchSourceCache {
impl<D: Decoder> Decodable<D> for SwitchSourceCache {
#[inline]
fn decode(_: &mut D) -> Self {
Self::new()

View File

@ -1,7 +1,7 @@
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::OnceCell;
use rustc_index::bit_set::BitSet;
use rustc_serialize as serialize;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use super::*;
@ -365,12 +365,12 @@ impl PostorderCache {
}
}
impl<S: serialize::Encoder> serialize::Encodable<S> for PostorderCache {
impl<S: Encoder> Encodable<S> for PostorderCache {
#[inline]
fn encode(&self, _s: &mut S) {}
}
impl<D: serialize::Decoder> serialize::Decodable<D> for PostorderCache {
impl<D: Decoder> Decodable<D> for PostorderCache {
#[inline]
fn decode(_: &mut D) -> Self {
Self::new()

View File

@ -18,6 +18,5 @@ rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" }
rustc_middle = { path = "../rustc_middle" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_session = { path = "../rustc_session" }
rustc_target = { path = "../rustc_target" }
rustc_span = { path = "../rustc_span" }

View File

@ -19,7 +19,6 @@ rustc_index = { path = "../rustc_index" }
rustc_middle = { path = "../rustc_middle" }
rustc_const_eval = { path = "../rustc_const_eval" }
rustc_mir_dataflow = { path = "../rustc_mir_dataflow" }
rustc_query_system = { path = "../rustc_query_system" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_session = { path = "../rustc_session" }
rustc_target = { path = "../rustc_target" }

View File

@ -10,7 +10,6 @@ doctest = false
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
tracing = "0.1"
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" }
rustc_middle = { path = "../rustc_middle" }

View File

@ -12,7 +12,6 @@ rustc_errors = { path = "../rustc_errors" }
rustc_expand = { path = "../rustc_expand" }
rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" }
rustc_parse = { path = "../rustc_parse" }
rustc_session = { path = "../rustc_session" }
rustc_target = { path = "../rustc_target" }
rustc_ast = { path = "../rustc_ast" }

View File

@ -9,9 +9,7 @@ doctest = false
[dependencies]
libloading = "0.7.1"
rustc_middle = { path = "../rustc_middle" }
rustc_errors = { path = "../rustc_errors" }
rustc_hir = { path = "../rustc_hir" }
rustc_lint = { path = "../rustc_lint" }
rustc_metadata = { path = "../rustc_metadata" }
rustc_ast = { path = "../rustc_ast" }

View File

@ -20,7 +20,6 @@ rustc_query_system = { path = "../rustc_query_system" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
rustc_type_ir = { path = "../rustc_type_ir" }
tracing = "0.1"
[features]

View File

@ -15,7 +15,7 @@ use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_query_system::dep_graph::DepContext;
use rustc_query_system::query::{QueryCache, QueryContext, QuerySideEffects};
use rustc_serialize::{
opaque::{self, FileEncodeResult, FileEncoder, IntEncodedWithFixedSize},
opaque::{FileEncodeResult, FileEncoder, IntEncodedWithFixedSize, MemDecoder},
Decodable, Decoder, Encodable, Encoder,
};
use rustc_session::Session;
@ -158,7 +158,7 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {
// Wrap in a scope so we can borrow `data`.
let footer: Footer = {
let mut decoder = opaque::Decoder::new(&data, start_pos);
let mut decoder = MemDecoder::new(&data, start_pos);
// Decode the *position* of the footer, which can be found in the
// last 8 bytes of the file.
@ -437,7 +437,7 @@ impl<'sess> OnDiskCache<'sess> {
let serialized_data = self.serialized_data.read();
let mut decoder = CacheDecoder {
tcx,
opaque: opaque::Decoder::new(serialized_data.as_deref().unwrap_or(&[]), pos.to_usize()),
opaque: MemDecoder::new(serialized_data.as_deref().unwrap_or(&[]), pos.to_usize()),
source_map: self.source_map,
file_index_to_file: &self.file_index_to_file,
file_index_to_stable_id: &self.file_index_to_stable_id,
@ -458,7 +458,7 @@ impl<'sess> OnDiskCache<'sess> {
/// will also handle things that contain `Ty` instances.
pub struct CacheDecoder<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
opaque: opaque::Decoder<'a>,
opaque: MemDecoder<'a>,
source_map: &'a SourceMap,
file_index_to_file: &'a Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>,
file_index_to_stable_id: &'a FxHashMap<SourceFileIndex, EncodedSourceFileId>,
@ -510,7 +510,7 @@ trait DecoderWithPosition: Decoder {
fn position(&self) -> usize;
}
impl<'a> DecoderWithPosition for opaque::Decoder<'a> {
impl<'a> DecoderWithPosition for MemDecoder<'a> {
fn position(&self) -> usize {
self.position()
}
@ -586,7 +586,7 @@ impl<'a, 'tcx> TyDecoder for CacheDecoder<'a, 'tcx> {
{
debug_assert!(pos < self.opaque.data.len());
let new_opaque = opaque::Decoder::new(self.opaque.data, pos);
let new_opaque = MemDecoder::new(self.opaque.data, pos);
let old_opaque = mem::replace(&mut self.opaque, new_opaque);
let r = f(self);
self.opaque = old_opaque;

View File

@ -21,7 +21,6 @@ rustc_serialize = { path = "../rustc_serialize" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
rustc_target = { path = "../rustc_target" }
rustc_type_ir = { path = "../rustc_type_ir" }
parking_lot = "0.11"
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }

View File

@ -19,7 +19,7 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::profiling::SelfProfilerRef;
use rustc_data_structures::sync::Lock;
use rustc_index::vec::{Idx, IndexVec};
use rustc_serialize::opaque::{self, FileEncodeResult, FileEncoder, IntEncodedWithFixedSize};
use rustc_serialize::opaque::{FileEncodeResult, FileEncoder, IntEncodedWithFixedSize, MemDecoder};
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use smallvec::SmallVec;
use std::convert::TryInto;
@ -96,11 +96,11 @@ impl<K: DepKind> SerializedDepGraph<K> {
}
}
impl<'a, K: DepKind + Decodable<opaque::Decoder<'a>>> Decodable<opaque::Decoder<'a>>
impl<'a, K: DepKind + Decodable<MemDecoder<'a>>> Decodable<MemDecoder<'a>>
for SerializedDepGraph<K>
{
#[instrument(level = "debug", skip(d))]
fn decode(d: &mut opaque::Decoder<'a>) -> SerializedDepGraph<K> {
fn decode(d: &mut MemDecoder<'a>) -> SerializedDepGraph<K> {
let start_position = d.position();
// The last 16 bytes are the node count and edge count.

View File

@ -10,7 +10,9 @@ use crate::imports::{Import, ImportKind};
use crate::macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef};
use crate::Namespace::{self, MacroNS, TypeNS, ValueNS};
use crate::{Determinacy, ExternPreludeEntry, Finalize, Module, ModuleKind, ModuleOrUniformRoot};
use crate::{NameBinding, NameBindingKind, ParentScope, PathResult, PerNS, ResolutionError};
use crate::{
MacroData, NameBinding, NameBindingKind, ParentScope, PathResult, PerNS, ResolutionError,
};
use crate::{Resolver, ResolverArenas, Segment, ToNameBinding, VisResolutionError};
use rustc_ast::visit::{self, AssocCtxt, Visitor};
@ -20,7 +22,6 @@ use rustc_ast_lowering::ResolverAstLowering;
use rustc_attr as attr;
use rustc_data_structures::sync::Lrc;
use rustc_errors::{struct_span_err, Applicability};
use rustc_expand::base::SyntaxExtension;
use rustc_expand::expand::AstFragment;
use rustc_hir::def::{self, *};
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID};
@ -180,26 +181,32 @@ impl<'a> Resolver<'a> {
}
}
pub(crate) fn get_macro(&mut self, res: Res) -> Option<Lrc<SyntaxExtension>> {
pub(crate) fn get_macro(&mut self, res: Res) -> Option<MacroData> {
match res {
Res::Def(DefKind::Macro(..), def_id) => Some(self.get_macro_by_def_id(def_id)),
Res::NonMacroAttr(_) => Some(self.non_macro_attr.clone()),
Res::NonMacroAttr(_) => {
Some(MacroData { ext: self.non_macro_attr.clone(), macro_rules: false })
}
_ => None,
}
}
pub(crate) fn get_macro_by_def_id(&mut self, def_id: DefId) -> Lrc<SyntaxExtension> {
if let Some(ext) = self.macro_map.get(&def_id) {
return ext.clone();
pub(crate) fn get_macro_by_def_id(&mut self, def_id: DefId) -> MacroData {
if let Some(macro_data) = self.macro_map.get(&def_id) {
return macro_data.clone();
}
let ext = Lrc::new(match self.cstore().load_macro_untracked(def_id, &self.session) {
LoadedMacro::MacroDef(item, edition) => self.compile_macro(&item, edition).0,
LoadedMacro::ProcMacro(ext) => ext,
});
let (ext, macro_rules) = match self.cstore().load_macro_untracked(def_id, &self.session) {
LoadedMacro::MacroDef(item, edition) => (
Lrc::new(self.compile_macro(&item, edition).0),
matches!(item.kind, ItemKind::MacroDef(def) if def.macro_rules),
),
LoadedMacro::ProcMacro(extz) => (Lrc::new(extz), false),
};
self.macro_map.insert(def_id, ext.clone());
ext
let macro_data = MacroData { ext, macro_rules };
self.macro_map.insert(def_id, macro_data.clone());
macro_data
}
pub(crate) fn build_reduced_graph(
@ -1251,7 +1258,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
};
let res = Res::Def(DefKind::Macro(ext.macro_kind()), def_id.to_def_id());
self.r.macro_map.insert(def_id.to_def_id(), ext);
self.r.macro_map.insert(def_id.to_def_id(), MacroData { ext, macro_rules });
self.r.local_macro_def_scopes.insert(def_id, parent_scope.module);
if macro_rules {

View File

@ -241,7 +241,7 @@ impl<'a> Resolver<'a> {
{
// The macro is a proc macro derive
if let Some(def_id) = module.expansion.expn_data().macro_def_id {
let ext = self.get_macro_by_def_id(def_id);
let ext = self.get_macro_by_def_id(def_id).ext;
if ext.builtin_name.is_none()
&& ext.macro_kind() == MacroKind::Derive
&& parent.expansion.outer_expn_is_descendant_of(*ctxt)

View File

@ -12,7 +12,7 @@ use rustc_ast::NodeId;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::intern::Interned;
use rustc_errors::{pluralize, struct_span_err, Applicability, MultiSpan};
use rustc_hir::def::{self, PartialRes};
use rustc_hir::def::{self, DefKind, PartialRes};
use rustc_middle::metadata::ModChild;
use rustc_middle::span_bug;
use rustc_middle::ty;
@ -922,11 +922,28 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
.note(&format!("consider declaring type or module `{}` with `pub`", ident))
.emit();
} else {
let note_msg =
format!("consider marking `{}` as `pub` in the imported module", ident);
struct_span_err!(self.r.session, import.span, E0364, "{}", error_msg)
.span_note(import.span, &note_msg)
.emit();
let mut err =
struct_span_err!(self.r.session, import.span, E0364, "{error_msg}");
match binding.kind {
NameBindingKind::Res(Res::Def(DefKind::Macro(_), def_id), _)
// exclude decl_macro
if self.r.get_macro_by_def_id(def_id).macro_rules =>
{
err.span_help(
binding.span,
"consider adding a `#[macro_export]` to the macro in the imported module",
);
}
_ => {
err.span_note(
import.span,
&format!(
"consider marking `{ident}` as `pub` in the imported module"
),
);
}
}
err.emit();
}
}
}

View File

@ -396,7 +396,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
// Try to lookup name in more relaxed fashion for better error reporting.
let ident = path.last().unwrap().ident;
let candidates = self
let mut candidates = self
.r
.lookup_import_candidates(ident, ns, &self.parent_scope, is_expected)
.into_iter()
@ -408,6 +408,18 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
})
.collect::<Vec<_>>();
let crate_def_id = CRATE_DEF_ID.to_def_id();
// Try to filter out intrinsics candidates, as long as we have
// some other candidates to suggest.
let intrinsic_candidates: Vec<_> = candidates
.drain_filter(|sugg| {
let path = path_names_to_string(&sugg.path);
path.starts_with("core::intrinsics::") || path.starts_with("std::intrinsics::")
})
.collect();
if candidates.is_empty() {
// Put them back if we have no more candidates to suggest...
candidates.extend(intrinsic_candidates);
}
if candidates.is_empty() && is_expected(Res::Def(DefKind::Enum, crate_def_id)) {
let mut enum_candidates: Vec<_> = self
.r

View File

@ -866,6 +866,12 @@ struct DeriveData {
has_derive_copy: bool,
}
#[derive(Clone)]
struct MacroData {
ext: Lrc<SyntaxExtension>,
macro_rules: bool,
}
/// The main resolver class.
///
/// This is the visitor that walks the whole crate.
@ -965,7 +971,7 @@ pub struct Resolver<'a> {
registered_attrs: FxHashSet<Ident>,
registered_tools: RegisteredTools,
macro_use_prelude: FxHashMap<Symbol, &'a NameBinding<'a>>,
macro_map: FxHashMap<DefId, Lrc<SyntaxExtension>>,
macro_map: FxHashMap<DefId, MacroData>,
dummy_ext_bang: Lrc<SyntaxExtension>,
dummy_ext_derive: Lrc<SyntaxExtension>,
non_macro_attr: Lrc<SyntaxExtension>,
@ -1522,7 +1528,7 @@ impl<'a> Resolver<'a> {
}
fn is_builtin_macro(&mut self, res: Res) -> bool {
self.get_macro(res).map_or(false, |ext| ext.builtin_name.is_some())
self.get_macro(res).map_or(false, |macro_data| macro_data.ext.builtin_name.is_some())
}
fn macro_def(&self, mut ctxt: SyntaxContext) -> DefId {

View File

@ -658,7 +658,7 @@ impl<'a> Resolver<'a> {
res
};
res.map(|res| (self.get_macro(res), res))
res.map(|res| (self.get_macro(res).map(|macro_data| macro_data.ext), res))
}
pub(crate) fn finalize_macro_resolutions(&mut self) {
@ -853,7 +853,7 @@ impl<'a> Resolver<'a> {
// Reserve some names that are not quite covered by the general check
// performed on `Resolver::builtin_attrs`.
if ident.name == sym::cfg || ident.name == sym::cfg_attr {
let macro_kind = self.get_macro(res).map(|ext| ext.macro_kind());
let macro_kind = self.get_macro(res).map(|macro_data| macro_data.ext.macro_kind());
if macro_kind.is_some() && sub_namespace_match(macro_kind, Some(MacroKind::Attr)) {
self.session.span_err(
ident.span,

View File

@ -1,5 +1,5 @@
use crate::leb128::{self, max_leb128_len};
use crate::serialize::{self, Decoder as _, Encoder as _};
use crate::serialize::{Decodable, Decoder, Encodable, Encoder};
use std::convert::TryInto;
use std::fs::File;
use std::io::{self, Write};
@ -11,13 +11,13 @@ use std::ptr;
// Encoder
// -----------------------------------------------------------------------------
pub struct Encoder {
pub struct MemEncoder {
pub data: Vec<u8>,
}
impl Encoder {
pub fn new() -> Encoder {
Encoder { data: vec![] }
impl MemEncoder {
pub fn new() -> MemEncoder {
MemEncoder { data: vec![] }
}
#[inline]
@ -53,7 +53,7 @@ macro_rules! write_leb128 {
/// [utf8]: https://en.wikipedia.org/w/index.php?title=UTF-8&oldid=1058865525#Codepage_layout
const STR_SENTINEL: u8 = 0xC1;
impl serialize::Encoder for Encoder {
impl Encoder for MemEncoder {
type Ok = Vec<u8>;
type Err = !;
@ -161,7 +161,7 @@ pub type FileEncodeResult = Result<usize, io::Error>;
// `FileEncoder` encodes data to file via fixed-size buffer.
//
// When encoding large amounts of data to a file, using `FileEncoder` may be
// preferred over using `Encoder` to encode to a `Vec`, and then writing the
// preferred over using `MemEncoder` to encode to a `Vec`, and then writing the
// `Vec` to file, as the latter uses as much memory as there is encoded data,
// while the former uses the fixed amount of memory allocated to the buffer.
// `FileEncoder` also has the advantage of not needing to reallocate as data
@ -425,7 +425,7 @@ macro_rules! file_encoder_write_leb128 {
}};
}
impl serialize::Encoder for FileEncoder {
impl Encoder for FileEncoder {
type Ok = usize;
type Err = io::Error;
@ -535,15 +535,15 @@ impl serialize::Encoder for FileEncoder {
// Decoder
// -----------------------------------------------------------------------------
pub struct Decoder<'a> {
pub struct MemDecoder<'a> {
pub data: &'a [u8],
position: usize,
}
impl<'a> Decoder<'a> {
impl<'a> MemDecoder<'a> {
#[inline]
pub fn new(data: &'a [u8], position: usize) -> Decoder<'a> {
Decoder { data, position }
pub fn new(data: &'a [u8], position: usize) -> MemDecoder<'a> {
MemDecoder { data, position }
}
#[inline]
@ -566,7 +566,7 @@ macro_rules! read_leb128 {
($dec:expr, $fun:ident) => {{ leb128::$fun($dec.data, &mut $dec.position) }};
}
impl<'a> serialize::Decoder for Decoder<'a> {
impl<'a> Decoder for MemDecoder<'a> {
#[inline]
fn read_u128(&mut self) -> u128 {
read_leb128!(self, read_u128_leb128)
@ -688,25 +688,25 @@ impl<'a> serialize::Decoder for Decoder<'a> {
// Specialize encoding byte slices. This specialization also applies to encoding `Vec<u8>`s, etc.,
// since the default implementations call `encode` on their slices internally.
impl serialize::Encodable<Encoder> for [u8] {
fn encode(&self, e: &mut Encoder) {
serialize::Encoder::emit_usize(e, self.len());
impl Encodable<MemEncoder> for [u8] {
fn encode(&self, e: &mut MemEncoder) {
Encoder::emit_usize(e, self.len());
e.emit_raw_bytes(self);
}
}
impl serialize::Encodable<FileEncoder> for [u8] {
impl Encodable<FileEncoder> for [u8] {
fn encode(&self, e: &mut FileEncoder) {
serialize::Encoder::emit_usize(e, self.len());
Encoder::emit_usize(e, self.len());
e.emit_raw_bytes(self);
}
}
// Specialize decoding `Vec<u8>`. This specialization also applies to decoding `Box<[u8]>`s, etc.,
// since the default implementations call `decode` to produce a `Vec<u8>` internally.
impl<'a> serialize::Decodable<Decoder<'a>> for Vec<u8> {
fn decode(d: &mut Decoder<'a>) -> Self {
let len = serialize::Decoder::read_usize(d);
impl<'a> Decodable<MemDecoder<'a>> for Vec<u8> {
fn decode(d: &mut MemDecoder<'a>) -> Self {
let len = Decoder::read_usize(d);
d.read_raw_bytes(len).to_owned()
}
}
@ -718,9 +718,9 @@ impl IntEncodedWithFixedSize {
pub const ENCODED_SIZE: usize = 8;
}
impl serialize::Encodable<Encoder> for IntEncodedWithFixedSize {
impl Encodable<MemEncoder> for IntEncodedWithFixedSize {
#[inline]
fn encode(&self, e: &mut Encoder) {
fn encode(&self, e: &mut MemEncoder) {
let _start_pos = e.position();
e.emit_raw_bytes(&self.0.to_le_bytes());
let _end_pos = e.position();
@ -728,7 +728,7 @@ impl serialize::Encodable<Encoder> for IntEncodedWithFixedSize {
}
}
impl serialize::Encodable<FileEncoder> for IntEncodedWithFixedSize {
impl Encodable<FileEncoder> for IntEncodedWithFixedSize {
#[inline]
fn encode(&self, e: &mut FileEncoder) {
let _start_pos = e.position();
@ -738,9 +738,9 @@ impl serialize::Encodable<FileEncoder> for IntEncodedWithFixedSize {
}
}
impl<'a> serialize::Decodable<Decoder<'a>> for IntEncodedWithFixedSize {
impl<'a> Decodable<MemDecoder<'a>> for IntEncodedWithFixedSize {
#[inline]
fn decode(decoder: &mut Decoder<'a>) -> IntEncodedWithFixedSize {
fn decode(decoder: &mut MemDecoder<'a>) -> IntEncodedWithFixedSize {
let _start_pos = decoder.position();
let bytes = decoder.read_raw_bytes(IntEncodedWithFixedSize::ENCODED_SIZE);
let value = u64::from_le_bytes(bytes.try_into().unwrap());

View File

@ -1,7 +1,7 @@
#![allow(rustc::internal)]
use rustc_macros::{Decodable, Encodable};
use rustc_serialize::opaque::{Decoder, Encoder};
use rustc_serialize::opaque::{MemDecoder, MemEncoder};
use rustc_serialize::{Decodable, Encodable, Encoder as EncoderTrait};
use std::fmt::Debug;
@ -28,16 +28,18 @@ struct Struct {
q: Option<u32>,
}
fn check_round_trip<T: Encodable<Encoder> + for<'a> Decodable<Decoder<'a>> + PartialEq + Debug>(
fn check_round_trip<
T: Encodable<MemEncoder> + for<'a> Decodable<MemDecoder<'a>> + PartialEq + Debug,
>(
values: Vec<T>,
) {
let mut encoder = Encoder::new();
let mut encoder = MemEncoder::new();
for value in &values {
Encodable::encode(value, &mut encoder);
}
let data = encoder.finish().unwrap();
let mut decoder = Decoder::new(&data[..], 0);
let mut decoder = MemDecoder::new(&data[..], 0);
for value in values {
let decoded = Decodable::decode(&mut decoder);

View File

@ -1911,13 +1911,13 @@ impl_pos! {
pub struct CharPos(pub usize);
}
impl<S: rustc_serialize::Encoder> Encodable<S> for BytePos {
impl<S: Encoder> Encodable<S> for BytePos {
fn encode(&self, s: &mut S) {
s.emit_u32(self.0);
}
}
impl<D: rustc_serialize::Decoder> Decodable<D> for BytePos {
impl<D: Decoder> Decodable<D> for BytePos {
fn decode(d: &mut D) -> BytePos {
BytePos(d.read_u32())
}

View File

@ -16,5 +16,4 @@ rustc_middle = { path = "../rustc_middle" }
rustc_hir = { path = "../rustc_hir" }
rustc_target = { path = "../rustc_target" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_query_system = { path = "../rustc_query_system" }
rustc_session = { path = "../rustc_session" }

View File

@ -14,7 +14,7 @@ use crate::UintTy;
use self::TyKind::*;
use rustc_data_structures::stable_hasher::HashStable;
use rustc_serialize::{Decodable, Encodable};
use rustc_serialize::{Decodable, Decoder, Encodable};
/// Defines the kinds of types used by the type system.
///
@ -833,56 +833,34 @@ where
I::AllocId: Decodable<D>,
{
fn decode(d: &mut D) -> Self {
match rustc_serialize::Decoder::read_usize(d) {
match Decoder::read_usize(d) {
0 => Bool,
1 => Char,
2 => Int(rustc_serialize::Decodable::decode(d)),
3 => Uint(rustc_serialize::Decodable::decode(d)),
4 => Float(rustc_serialize::Decodable::decode(d)),
5 => Adt(rustc_serialize::Decodable::decode(d), rustc_serialize::Decodable::decode(d)),
6 => Foreign(rustc_serialize::Decodable::decode(d)),
2 => Int(Decodable::decode(d)),
3 => Uint(Decodable::decode(d)),
4 => Float(Decodable::decode(d)),
5 => Adt(Decodable::decode(d), Decodable::decode(d)),
6 => Foreign(Decodable::decode(d)),
7 => Str,
8 => {
Array(rustc_serialize::Decodable::decode(d), rustc_serialize::Decodable::decode(d))
}
9 => Slice(rustc_serialize::Decodable::decode(d)),
10 => RawPtr(rustc_serialize::Decodable::decode(d)),
11 => Ref(
rustc_serialize::Decodable::decode(d),
rustc_serialize::Decodable::decode(d),
rustc_serialize::Decodable::decode(d),
),
12 => {
FnDef(rustc_serialize::Decodable::decode(d), rustc_serialize::Decodable::decode(d))
}
13 => FnPtr(rustc_serialize::Decodable::decode(d)),
14 => Dynamic(
rustc_serialize::Decodable::decode(d),
rustc_serialize::Decodable::decode(d),
),
15 => Closure(
rustc_serialize::Decodable::decode(d),
rustc_serialize::Decodable::decode(d),
),
16 => Generator(
rustc_serialize::Decodable::decode(d),
rustc_serialize::Decodable::decode(d),
rustc_serialize::Decodable::decode(d),
),
17 => GeneratorWitness(rustc_serialize::Decodable::decode(d)),
8 => Array(Decodable::decode(d), Decodable::decode(d)),
9 => Slice(Decodable::decode(d)),
10 => RawPtr(Decodable::decode(d)),
11 => Ref(Decodable::decode(d), Decodable::decode(d), Decodable::decode(d)),
12 => FnDef(Decodable::decode(d), Decodable::decode(d)),
13 => FnPtr(Decodable::decode(d)),
14 => Dynamic(Decodable::decode(d), Decodable::decode(d)),
15 => Closure(Decodable::decode(d), Decodable::decode(d)),
16 => Generator(Decodable::decode(d), Decodable::decode(d), Decodable::decode(d)),
17 => GeneratorWitness(Decodable::decode(d)),
18 => Never,
19 => Tuple(rustc_serialize::Decodable::decode(d)),
20 => Projection(rustc_serialize::Decodable::decode(d)),
21 => {
Opaque(rustc_serialize::Decodable::decode(d), rustc_serialize::Decodable::decode(d))
}
22 => Param(rustc_serialize::Decodable::decode(d)),
23 => {
Bound(rustc_serialize::Decodable::decode(d), rustc_serialize::Decodable::decode(d))
}
24 => Placeholder(rustc_serialize::Decodable::decode(d)),
25 => Infer(rustc_serialize::Decodable::decode(d)),
26 => Error(rustc_serialize::Decodable::decode(d)),
19 => Tuple(Decodable::decode(d)),
20 => Projection(Decodable::decode(d)),
21 => Opaque(Decodable::decode(d), Decodable::decode(d)),
22 => Param(Decodable::decode(d)),
23 => Bound(Decodable::decode(d), Decodable::decode(d)),
24 => Placeholder(Decodable::decode(d)),
25 => Infer(Decodable::decode(d)),
26 => Error(Decodable::decode(d)),
_ => panic!(
"{}",
format!(

View File

@ -17,7 +17,7 @@ use rustc_middle::hir::map::Map;
use rustc_middle::hir::nested_filter;
use rustc_middle::ty::{self, TyCtxt};
use rustc_serialize::{
opaque::{Decoder, FileEncoder},
opaque::{FileEncoder, MemDecoder},
Decodable, Encodable, Encoder,
};
use rustc_session::getopts;
@ -336,7 +336,7 @@ pub(crate) fn load_call_locations(
let mut all_calls: AllCallLocations = FxHashMap::default();
for path in with_examples {
let bytes = fs::read(&path).map_err(|e| format!("{} (for path {})", e, path))?;
let mut decoder = Decoder::new(&bytes, 0);
let mut decoder = MemDecoder::new(&bytes, 0);
let calls = AllCallLocations::decode(&mut decoder);
for (function, fn_calls) in calls.into_iter() {

View File

@ -0,0 +1,29 @@
// This test case checks that LLVM is aware that computing the size of a slice cannot wrap.
// The possibility of wrapping results in an additional branch when dropping boxed slices
// in some situations, see https://github.com/rust-lang/rust/issues/96497#issuecomment-1112865218
// compile-flags: -O
// min-llvm-version: 14.0
#![crate_type="lib"]
// CHECK-LABEL: @simple_size_of_nowrap
#[no_mangle]
pub fn simple_size_of_nowrap(x: &[u32]) -> usize {
// Make sure the shift used to compute the size has a nowrap flag.
// CHECK: [[A:%.*]] = shl nsw {{.*}}, 2
// CHECK-NEXT: ret {{.*}} [[A]]
core::mem::size_of_val(x)
}
// CHECK-LABEL: @drop_write
#[no_mangle]
pub fn drop_write(mut x: Box<[u32]>) {
// Check that this write is optimized out.
// This depends on the size calculation not wrapping,
// since otherwise LLVM can't tell that the memory is always deallocated if the slice len > 0.
// CHECK-NOT: store i32 42
x[1] = 42;
}

View File

@ -7,7 +7,7 @@ extern crate rustc_macros;
extern crate rustc_serialize;
use rustc_macros::{Decodable, Encodable};
use rustc_serialize::opaque;
use rustc_serialize::opaque::{MemDecoder, MemEncoder};
use rustc_serialize::{Decodable, Encodable, Encoder};
#[derive(Encodable, Decodable)]
@ -18,11 +18,11 @@ struct A {
fn main() {
let obj = A { foo: Box::new([true, false]) };
let mut encoder = opaque::Encoder::new();
let mut encoder = MemEncoder::new();
obj.encode(&mut encoder);
let data = encoder.finish().unwrap();
let mut decoder = opaque::Decoder::new(&data, 0);
let mut decoder = MemDecoder::new(&data, 0);
let obj2 = A::decode(&mut decoder);
assert_eq!(obj.foo, obj2.foo);

View File

@ -9,7 +9,7 @@ extern crate rustc_macros;
extern crate rustc_serialize;
use rustc_macros::{Decodable, Encodable};
use rustc_serialize::opaque;
use rustc_serialize::opaque::{MemDecoder, MemEncoder};
use rustc_serialize::{Decodable, Encodable, Encoder};
use std::cell::{Cell, RefCell};
@ -27,11 +27,11 @@ struct B {
fn main() {
let obj = B { foo: Cell::new(true), bar: RefCell::new(A { baz: 2 }) };
let mut encoder = opaque::Encoder::new();
let mut encoder = MemEncoder::new();
obj.encode(&mut encoder);
let data = encoder.finish().unwrap();
let mut decoder = opaque::Decoder::new(&data, 0);
let mut decoder = MemDecoder::new(&data, 0);
let obj2 = B::decode(&mut decoder);
assert_eq!(obj.foo.get(), obj2.foo.get());

View File

@ -8,7 +8,7 @@ extern crate rustc_macros;
extern crate rustc_serialize;
use rustc_macros::{Decodable, Encodable};
use rustc_serialize::opaque;
use rustc_serialize::opaque::{MemDecoder, MemEncoder};
use rustc_serialize::{Decodable, Encodable, Encoder};
#[derive(Encodable, Decodable, PartialEq, Debug)]
@ -17,11 +17,11 @@ struct UnitLikeStruct;
pub fn main() {
let obj = UnitLikeStruct;
let mut encoder = opaque::Encoder::new();
let mut encoder = MemEncoder::new();
obj.encode(&mut encoder);
let data = encoder.finish().unwrap();
let mut decoder = opaque::Decoder::new(&data, 0);
let mut decoder = MemDecoder::new(&data, 0);
let obj2 = UnitLikeStruct::decode(&mut decoder);
assert_eq!(obj, obj2);

View File

@ -0,0 +1,17 @@
// edition:2021
#![feature(decl_macro)]
mod foo {
macro_rules! bar {
() => {};
}
pub use bar as _; //~ ERROR `bar` is only public within the crate, and cannot be re-exported outside
macro baz() {}
pub use baz as _; //~ ERROR `baz` is private, and cannot be re-exported
}
fn main() {}

View File

@ -0,0 +1,29 @@
error[E0364]: `bar` is only public within the crate, and cannot be re-exported outside
--> $DIR/macro-private-reexport.rs:10:13
|
LL | pub use bar as _;
| ^^^^^^^^
|
help: consider adding a `#[macro_export]` to the macro in the imported module
--> $DIR/macro-private-reexport.rs:6:5
|
LL | / macro_rules! bar {
LL | | () => {};
LL | | }
| |_____^
error[E0364]: `baz` is private, and cannot be re-exported
--> $DIR/macro-private-reexport.rs:14:13
|
LL | pub use baz as _;
| ^^^^^^^^
|
note: consider marking `baz` as `pub` in the imported module
--> $DIR/macro-private-reexport.rs:14:13
|
LL | pub use baz as _;
| ^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0364`.

View File

@ -0,0 +1,10 @@
fn main() {
// Should suggest only `std::mem::size_of`
let _ = size_of::<usize>();
//~^ ERROR cannot find
// Should suggest `std::intrinsics::fabsf64`,
// since there is no non-intrinsic to suggest.
let _ = fabsf64(1.0);
//~^ ERROR cannot find
}

View File

@ -0,0 +1,25 @@
error[E0425]: cannot find function `size_of` in this scope
--> $DIR/filter-intrinsics.rs:3:13
|
LL | let _ = size_of::<usize>();
| ^^^^^^^ not found in this scope
|
help: consider importing this function
|
LL | use std::mem::size_of;
|
error[E0425]: cannot find function `fabsf64` in this scope
--> $DIR/filter-intrinsics.rs:8:13
|
LL | let _ = fabsf64(1.0);
| ^^^^^^^ not found in this scope
|
help: consider importing this function
|
LL | use std::intrinsics::fabsf64;
|
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0425`.

View File

@ -4,11 +4,11 @@ error[E0364]: `legacy_macro` is only public within the crate, and cannot be re-e
LL | pub use legacy_macro as _;
| ^^^^^^^^^^^^^^^^^
|
note: consider marking `legacy_macro` as `pub` in the imported module
--> $DIR/macro-rules.rs:11:13
help: consider adding a `#[macro_export]` to the macro in the imported module
--> $DIR/macro-rules.rs:7:5
|
LL | pub use legacy_macro as _;
| ^^^^^^^^^^^^^^^^^
LL | macro_rules! legacy_macro { () => () }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0659]: `legacy_macro` is ambiguous
--> $DIR/macro-rules.rs:31:13

View File

@ -7,8 +7,8 @@ use std::path::Path;
const ENTRY_LIMIT: usize = 1000;
// FIXME: The following limits should be reduced eventually.
const ROOT_ENTRY_LIMIT: usize = 969;
const ISSUES_ENTRY_LIMIT: usize = 2211;
const ROOT_ENTRY_LIMIT: usize = 968;
const ISSUES_ENTRY_LIMIT: usize = 2179;
fn check_entries(path: &Path, bad: &mut bool) {
let dirs = walkdir::WalkDir::new(&path.join("test/ui"))