Skip to content

Commit 389352c

Browse files
committed
Auto merge of rust-lang#98123 - JohnTitor:rollup-rfg1a4s, r=JohnTitor
Rollup of 7 pull requests Successful merges: - rust-lang#97822 (Filter out intrinsics if we have other import candidates to suggest) - rust-lang#98026 (Move some tests to more reasonable directories) - rust-lang#98067 (compiler: remove unused deps) - rust-lang#98078 (Use unchecked mul to compute slice sizes) - rust-lang#98083 (Rename rustc_serialize::opaque::Encoder as MemEncoder.) - rust-lang#98087 (Suggest adding a `#[macro_export]` to a private macro) - rust-lang#98113 (Fix misspelling of "constraint" as "contraint") Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents ddb6cc8 + 1b8fc2f commit 389352c

File tree

69 files changed

+322
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+322
-206
lines changed

Cargo.lock

-14
Original file line numberDiff line numberDiff line change
@@ -3678,7 +3678,6 @@ dependencies = [
36783678
"libloading",
36793679
"measureme 10.0.0",
36803680
"rustc-demangle",
3681-
"rustc_arena",
36823681
"rustc_ast",
36833682
"rustc_attr",
36843683
"rustc_codegen_ssa",
@@ -3801,7 +3800,6 @@ dependencies = [
38013800
"rustc_ast",
38023801
"rustc_ast_pretty",
38033802
"rustc_codegen_ssa",
3804-
"rustc_const_eval",
38053803
"rustc_data_structures",
38063804
"rustc_error_codes",
38073805
"rustc_errors",
@@ -3816,7 +3814,6 @@ dependencies = [
38163814
"rustc_parse",
38173815
"rustc_plugin_impl",
38183816
"rustc_save_analysis",
3819-
"rustc_serialize",
38203817
"rustc_session",
38213818
"rustc_span",
38223819
"rustc_target",
@@ -3912,7 +3909,6 @@ dependencies = [
39123909
"rustc_ast",
39133910
"rustc_data_structures",
39143911
"rustc_error_messages",
3915-
"rustc_feature",
39163912
"rustc_index",
39173913
"rustc_macros",
39183914
"rustc_serialize",
@@ -3973,7 +3969,6 @@ dependencies = [
39733969
"rustc_macros",
39743970
"rustc_middle",
39753971
"rustc_serialize",
3976-
"rustc_session",
39773972
"rustc_span",
39783973
"rustc_target",
39793974
"smallvec",
@@ -4207,7 +4202,6 @@ dependencies = [
42074202
"rustc_index",
42084203
"rustc_middle",
42094204
"rustc_serialize",
4210-
"rustc_session",
42114205
"rustc_span",
42124206
"rustc_target",
42134207
"smallvec",
@@ -4229,7 +4223,6 @@ dependencies = [
42294223
"rustc_index",
42304224
"rustc_middle",
42314225
"rustc_mir_dataflow",
4232-
"rustc_query_system",
42334226
"rustc_serialize",
42344227
"rustc_session",
42354228
"rustc_span",
@@ -4244,7 +4237,6 @@ name = "rustc_monomorphize"
42444237
version = "0.0.0"
42454238
dependencies = [
42464239
"rustc_data_structures",
4247-
"rustc_errors",
42484240
"rustc_hir",
42494241
"rustc_index",
42504242
"rustc_middle",
@@ -4296,7 +4288,6 @@ dependencies = [
42964288
"rustc_index",
42974289
"rustc_lexer",
42984290
"rustc_middle",
4299-
"rustc_parse",
43004291
"rustc_serialize",
43014292
"rustc_session",
43024293
"rustc_span",
@@ -4311,10 +4302,8 @@ dependencies = [
43114302
"libloading",
43124303
"rustc_ast",
43134304
"rustc_errors",
4314-
"rustc_hir",
43154305
"rustc_lint",
43164306
"rustc_metadata",
4317-
"rustc_middle",
43184307
"rustc_session",
43194308
"rustc_span",
43204309
]
@@ -4353,7 +4342,6 @@ dependencies = [
43534342
"rustc_serialize",
43544343
"rustc_session",
43554344
"rustc_span",
4356-
"rustc_type_ir",
43574345
"tracing",
43584346
]
43594347

@@ -4375,7 +4363,6 @@ dependencies = [
43754363
"rustc_session",
43764364
"rustc_span",
43774365
"rustc_target",
4378-
"rustc_type_ir",
43794366
"smallvec",
43804367
"tracing",
43814368
]
@@ -4495,7 +4482,6 @@ dependencies = [
44954482
"rustc_data_structures",
44964483
"rustc_hir",
44974484
"rustc_middle",
4498-
"rustc_query_system",
44994485
"rustc_session",
45004486
"rustc_span",
45014487
"rustc_target",

compiler/rustc_ast/src/ast.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
3131
use rustc_data_structures::sync::Lrc;
3232
use rustc_data_structures::thin_vec::ThinVec;
3333
use rustc_macros::HashStable_Generic;
34-
use rustc_serialize::{self, Decoder, Encoder};
34+
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
3535
use rustc_span::source_map::{respan, Spanned};
3636
use rustc_span::symbol::{kw, sym, Ident, Symbol};
3737
use rustc_span::{Span, DUMMY_SP};
@@ -2488,11 +2488,11 @@ rustc_index::newtype_index! {
24882488
}
24892489
}
24902490

2491-
impl<S: Encoder> rustc_serialize::Encodable<S> for AttrId {
2491+
impl<S: Encoder> Encodable<S> for AttrId {
24922492
fn encode(&self, _s: &mut S) {}
24932493
}
24942494

2495-
impl<D: Decoder> rustc_serialize::Decodable<D> for AttrId {
2495+
impl<D: Decoder> Decodable<D> for AttrId {
24962496
fn decode(_: &mut D) -> AttrId {
24972497
crate::attr::mk_attr_id()
24982498
}

compiler/rustc_ast_lowering/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
871871
self.lower_angle_bracketed_parameter_data(data, ParamMode::Explicit, itctx).0
872872
}
873873
GenericArgs::Parenthesized(ref data) => {
874-
self.assoc_ty_contraint_param_error_emit(data);
874+
self.emit_bad_parenthesized_trait_in_assoc_ty(data);
875875
self.lower_angle_bracketed_parameter_data(
876876
&data.as_angle_bracketed_args(),
877877
ParamMode::Explicit,
@@ -982,7 +982,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
982982
}
983983
}
984984

985-
fn assoc_ty_contraint_param_error_emit(&self, data: &ParenthesizedArgs) -> () {
985+
fn emit_bad_parenthesized_trait_in_assoc_ty(&self, data: &ParenthesizedArgs) {
986986
let mut err = self.sess.struct_span_err(
987987
data.span,
988988
"parenthesized generic arguments cannot be used in associated type constraints",

compiler/rustc_codegen_llvm/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ measureme = "10.0.0"
1616
tracing = "0.1"
1717
rustc_middle = { path = "../rustc_middle" }
1818
rustc-demangle = "0.1.21"
19-
rustc_arena = { path = "../rustc_arena" }
2019
rustc_attr = { path = "../rustc_attr" }
2120
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
2221
rustc_symbol_mangling = { path = "../rustc_symbol_mangling" }

compiler/rustc_codegen_ssa/src/glue.rs

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

compiler/rustc_codegen_ssa/src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ use rustc_middle::dep_graph::WorkProduct;
2929
use rustc_middle::middle::dependency_format::Dependencies;
3030
use rustc_middle::middle::exported_symbols::SymbolExportKind;
3131
use rustc_middle::ty::query::{ExternProviders, Providers};
32-
use rustc_serialize::{opaque, Decodable, Decoder, Encodable, Encoder};
32+
use rustc_serialize::opaque::{MemDecoder, MemEncoder};
33+
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
3334
use rustc_session::config::{CrateType, OutputFilenames, OutputType, RUST_CGU_EXT};
3435
use rustc_session::cstore::{self, CrateSource};
3536
use rustc_session::utils::NativeLibKind;
@@ -203,7 +204,7 @@ const RUSTC_VERSION: Option<&str> = option_env!("CFG_VERSION");
203204

204205
impl CodegenResults {
205206
pub fn serialize_rlink(codegen_results: &CodegenResults) -> Vec<u8> {
206-
let mut encoder = opaque::Encoder::new();
207+
let mut encoder = MemEncoder::new();
207208
encoder.emit_raw_bytes(RLINK_MAGIC);
208209
// `emit_raw_bytes` is used to make sure that the version representation does not depend on
209210
// Encoder's inner representation of `u32`.
@@ -230,7 +231,7 @@ impl CodegenResults {
230231
return Err(".rlink file was produced with encoding version {version_array}, but the current version is {RLINK_VERSION}".to_string());
231232
}
232233

233-
let mut decoder = opaque::Decoder::new(&data[4..], 0);
234+
let mut decoder = MemDecoder::new(&data[4..], 0);
234235
let rustc_version = decoder.read_str();
235236
let current_version = RUSTC_VERSION.unwrap();
236237
if rustc_version != current_version {

compiler/rustc_data_structures/src/fingerprint.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::stable_hasher;
2-
use rustc_serialize::{Decodable, Encodable};
2+
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
33
use std::convert::TryInto;
44
use std::hash::{Hash, Hasher};
55

@@ -142,14 +142,14 @@ impl stable_hasher::StableHasherResult for Fingerprint {
142142

143143
impl_stable_hash_via_hash!(Fingerprint);
144144

145-
impl<E: rustc_serialize::Encoder> Encodable<E> for Fingerprint {
145+
impl<E: Encoder> Encodable<E> for Fingerprint {
146146
#[inline]
147147
fn encode(&self, s: &mut E) {
148148
s.emit_raw_bytes(&self.to_le_bytes());
149149
}
150150
}
151151

152-
impl<D: rustc_serialize::Decoder> Decodable<D> for Fingerprint {
152+
impl<D: Decoder> Decodable<D> for Fingerprint {
153153
#[inline]
154154
fn decode(d: &mut D) -> Self {
155155
Fingerprint::from_le_bytes(d.read_raw_bytes(16).try_into().unwrap())
@@ -184,7 +184,7 @@ impl std::fmt::Display for PackedFingerprint {
184184
}
185185
}
186186

187-
impl<E: rustc_serialize::Encoder> Encodable<E> for PackedFingerprint {
187+
impl<E: Encoder> Encodable<E> for PackedFingerprint {
188188
#[inline]
189189
fn encode(&self, s: &mut E) {
190190
// Copy to avoid taking reference to packed field.
@@ -193,7 +193,7 @@ impl<E: rustc_serialize::Encoder> Encodable<E> for PackedFingerprint {
193193
}
194194
}
195195

196-
impl<D: rustc_serialize::Decoder> Decodable<D> for PackedFingerprint {
196+
impl<D: Decoder> Decodable<D> for PackedFingerprint {
197197
#[inline]
198198
fn decode(d: &mut D) -> Self {
199199
Self(Fingerprint::decode(d))

compiler/rustc_driver/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ edition = "2021"
77
crate-type = ["dylib"]
88

99
[dependencies]
10-
libc = "0.2"
1110
tracing = { version = "0.1.28" }
1211
serde_json = "1.0.59"
1312
rustc_log = { path = "../rustc_log" }
@@ -21,19 +20,20 @@ rustc_feature = { path = "../rustc_feature" }
2120
rustc_hir = { path = "../rustc_hir" }
2221
rustc_hir_pretty = { path = "../rustc_hir_pretty" }
2322
rustc_metadata = { path = "../rustc_metadata" }
24-
rustc_const_eval = { path = "../rustc_const_eval" }
2523
rustc_parse = { path = "../rustc_parse" }
2624
rustc_plugin_impl = { path = "../rustc_plugin_impl" }
2725
rustc_save_analysis = { path = "../rustc_save_analysis" }
2826
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
2927
rustc_session = { path = "../rustc_session" }
3028
rustc_error_codes = { path = "../rustc_error_codes" }
3129
rustc_interface = { path = "../rustc_interface" }
32-
rustc_serialize = { path = "../rustc_serialize" }
3330
rustc_ast = { path = "../rustc_ast" }
3431
rustc_span = { path = "../rustc_span" }
3532
rustc_typeck = { path = "../rustc_typeck" }
3633

34+
[target.'cfg(unix)'.dependencies]
35+
libc = "0.2"
36+
3737
[target.'cfg(windows)'.dependencies]
3838
winapi = { version = "0.3", features = ["consoleapi", "debugapi", "processenv"] }
3939

compiler/rustc_hir/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ doctest = false
88

99
[dependencies]
1010
rustc_target = { path = "../rustc_target" }
11-
rustc_feature = { path = "../rustc_feature" }
1211
rustc_macros = { path = "../rustc_macros" }
1312
rustc_data_structures = { path = "../rustc_data_structures" }
1413
rustc_error_messages = { path = "../rustc_error_messages" }

compiler/rustc_incremental/src/persist/load.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_data_structures::fx::FxHashMap;
44
use rustc_data_structures::memmap::Mmap;
55
use rustc_middle::dep_graph::{SerializedDepGraph, WorkProduct, WorkProductId};
66
use rustc_middle::ty::OnDiskCache;
7-
use rustc_serialize::opaque::Decoder;
7+
use rustc_serialize::opaque::MemDecoder;
88
use rustc_serialize::Decodable;
99
use rustc_session::config::IncrementalStateAssertion;
1010
use rustc_session::Session;
@@ -156,7 +156,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
156156

157157
if let LoadResult::Ok { data: (work_products_data, start_pos) } = load_result {
158158
// Decode the list of work_products
159-
let mut work_product_decoder = Decoder::new(&work_products_data[..], start_pos);
159+
let mut work_product_decoder = MemDecoder::new(&work_products_data[..], start_pos);
160160
let work_products: Vec<SerializedWorkProduct> =
161161
Decodable::decode(&mut work_product_decoder);
162162

@@ -193,7 +193,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
193193
LoadResult::DataOutOfDate => LoadResult::DataOutOfDate,
194194
LoadResult::Error { message } => LoadResult::Error { message },
195195
LoadResult::Ok { data: (bytes, start_pos) } => {
196-
let mut decoder = Decoder::new(&bytes, start_pos);
196+
let mut decoder = MemDecoder::new(&bytes, start_pos);
197197
let prev_commandline_args_hash = u64::decode(&mut decoder);
198198

199199
if prev_commandline_args_hash != expected_hash {

compiler/rustc_infer/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ rustc_errors = { path = "../rustc_errors" }
1414
rustc_hir = { path = "../rustc_hir" }
1515
rustc_index = { path = "../rustc_index" }
1616
rustc_macros = { path = "../rustc_macros" }
17-
rustc_session = { path = "../rustc_session" }
1817
rustc_serialize = { path = "../rustc_serialize" }
1918
rustc_span = { path = "../rustc_span" }
2019
rustc_target = { path = "../rustc_target" }

compiler/rustc_interface/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ edition = "2021"
77
doctest = false
88

99
[dependencies]
10-
libc = "0.2"
1110
libloading = "0.7.1"
1211
tracing = "0.1"
1312
rustc-rayon-core = { version = "0.4.0", optional = true }
@@ -49,6 +48,9 @@ rustc_trait_selection = { path = "../rustc_trait_selection" }
4948
rustc_ty_utils = { path = "../rustc_ty_utils" }
5049
tempfile = "3.2"
5150

51+
[target.'cfg(unix)'.dependencies]
52+
libc = "0.2"
53+
5254
[target.'cfg(windows)'.dependencies]
5355
winapi = { version = "0.3", features = ["libloaderapi"] }
5456

compiler/rustc_metadata/src/rmeta/decoder.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ use rustc_middle::ty::codec::TyDecoder;
2626
use rustc_middle::ty::fast_reject::SimplifiedType;
2727
use rustc_middle::ty::GeneratorDiagnosticData;
2828
use rustc_middle::ty::{self, ParameterizedOverTcx, Ty, TyCtxt, Visibility};
29-
use rustc_serialize::{opaque, Decodable, Decoder};
29+
use rustc_serialize::opaque::MemDecoder;
30+
use rustc_serialize::{Decodable, Decoder};
3031
use rustc_session::cstore::{
3132
CrateSource, ExternCrate, ForeignModule, LinkagePreference, NativeLib,
3233
};
@@ -154,7 +155,7 @@ struct ImportedSourceFile {
154155
}
155156

156157
pub(super) struct DecodeContext<'a, 'tcx> {
157-
opaque: opaque::Decoder<'a>,
158+
opaque: MemDecoder<'a>,
158159
cdata: Option<CrateMetadataRef<'a>>,
159160
blob: &'a MetadataBlob,
160161
sess: Option<&'tcx Session>,
@@ -186,7 +187,7 @@ pub(super) trait Metadata<'a, 'tcx>: Copy {
186187
fn decoder(self, pos: usize) -> DecodeContext<'a, 'tcx> {
187188
let tcx = self.tcx();
188189
DecodeContext {
189-
opaque: opaque::Decoder::new(self.blob(), pos),
190+
opaque: MemDecoder::new(self.blob(), pos),
190191
cdata: self.cdata(),
191192
blob: self.blob(),
192193
sess: self.sess().or(tcx.map(|tcx| tcx.sess)),
@@ -418,7 +419,7 @@ impl<'a, 'tcx> TyDecoder for DecodeContext<'a, 'tcx> {
418419
where
419420
F: FnOnce(&mut Self) -> R,
420421
{
421-
let new_opaque = opaque::Decoder::new(self.opaque.data, pos);
422+
let new_opaque = MemDecoder::new(self.opaque.data, pos);
422423
let old_opaque = mem::replace(&mut self.opaque, new_opaque);
423424
let old_state = mem::replace(&mut self.lazy_state, LazyState::NoNode);
424425
let r = f(self);

0 commit comments

Comments
 (0)