Skip to content

Commit 6c2ee88

Browse files
committed
Ensure that queries only return Copy types.
1 parent bf242bb commit 6c2ee88

File tree

31 files changed

+141
-96
lines changed

31 files changed

+141
-96
lines changed

compiler/rustc_attr/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ pub fn eval_condition(
604604
}
605605
}
606606

607-
#[derive(Debug, Encodable, Decodable, Clone, HashStable_Generic)]
607+
#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable_Generic)]
608608
pub struct Deprecation {
609609
pub since: Option<Symbol>,
610610
/// The note to issue a reason.

compiler/rustc_codegen_cranelift/src/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for FunctionCx<'_, '_, 'tcx> {
274274
#[inline]
275275
fn handle_fn_abi_err(
276276
&self,
277-
err: FnAbiError<'tcx>,
277+
err: &'tcx FnAbiError<'tcx>,
278278
span: Span,
279279
fn_abi_request: FnAbiRequest<'tcx>,
280280
) -> ! {
@@ -396,7 +396,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> {
396396
#[inline]
397397
fn handle_fn_abi_err(
398398
&self,
399-
err: FnAbiError<'tcx>,
399+
err: &'tcx FnAbiError<'tcx>,
400400
span: Span,
401401
fn_abi_request: FnAbiRequest<'tcx>,
402402
) -> ! {

compiler/rustc_codegen_gcc/src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for Builder<'_, '_, 'tcx> {
354354
#[inline]
355355
fn handle_fn_abi_err(
356356
&self,
357-
err: FnAbiError<'tcx>,
357+
err: &'tcx FnAbiError<'tcx>,
358358
span: Span,
359359
fn_abi_request: FnAbiRequest<'tcx>,
360360
) -> ! {

compiler/rustc_codegen_gcc/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ impl<'gcc, 'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
397397
#[inline]
398398
fn handle_fn_abi_err(
399399
&self,
400-
err: FnAbiError<'tcx>,
400+
err: &'tcx FnAbiError<'tcx>,
401401
span: Span,
402402
fn_abi_request: FnAbiRequest<'tcx>,
403403
) -> ! {

compiler/rustc_codegen_llvm/src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for Builder<'_, '_, 'tcx> {
105105
#[inline]
106106
fn handle_fn_abi_err(
107107
&self,
108-
err: FnAbiError<'tcx>,
108+
err: &'tcx FnAbiError<'tcx>,
109109
span: Span,
110110
fn_abi_request: FnAbiRequest<'tcx>,
111111
) -> ! {

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'_, 'tcx> {
920920
#[inline]
921921
fn handle_fn_abi_err(
922922
&self,
923-
err: FnAbiError<'tcx>,
923+
err: &'tcx FnAbiError<'tcx>,
924924
span: Span,
925925
fn_abi_request: FnAbiRequest<'tcx>,
926926
) -> ! {

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
477477
codegen_worker_receive,
478478
shared_emitter_main,
479479
future: coordinator_thread,
480-
output_filenames: tcx.output_filenames(()),
480+
output_filenames: tcx.output_filenames(()).clone(),
481481
}
482482
}
483483

@@ -1050,7 +1050,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
10501050
cgu_reuse_tracker: sess.cgu_reuse_tracker.clone(),
10511051
coordinator_send,
10521052
diag_emitter: shared_emitter.clone(),
1053-
output_filenames: tcx.output_filenames(()),
1053+
output_filenames: tcx.output_filenames(()).clone(),
10541054
regular_module_config: regular_config,
10551055
metadata_module_config: metadata_config,
10561056
allocator_module_config: allocator_config,

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ impl CrateInfo {
843843
used_crate_source: Default::default(),
844844
lang_item_to_crate: Default::default(),
845845
missing_lang_items: Default::default(),
846-
dependency_formats: tcx.dependency_formats(()),
846+
dependency_formats: tcx.dependency_formats(()).clone(),
847847
windows_subsystem,
848848
};
849849
let lang_items = tcx.lang_items();
@@ -860,7 +860,7 @@ impl CrateInfo {
860860
info.native_libraries
861861
.insert(cnum, tcx.native_libraries(cnum).iter().map(Into::into).collect());
862862
info.crate_name.insert(cnum, tcx.crate_name(cnum).to_string());
863-
info.used_crate_source.insert(cnum, tcx.used_crate_source(cnum));
863+
info.used_crate_source.insert(cnum, tcx.used_crate_source(cnum).clone());
864864
if tcx.is_compiler_builtins(cnum) {
865865
info.compiler_builtins = Some(cnum);
866866
}

compiler/rustc_const_eval/src/interpret/eval_context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> FnAbiOfHelpers<'tcx> for InterpCx
341341

342342
fn handle_fn_abi_err(
343343
&self,
344-
err: FnAbiError<'tcx>,
344+
err: &'tcx FnAbiError<'tcx>,
345345
_span: Span,
346346
_fn_abi_request: FnAbiRequest<'tcx>,
347347
) -> InterpErrorInfo<'tcx> {
348348
match err {
349-
FnAbiError::Layout(err) => err_inval!(Layout(err)).into(),
349+
FnAbiError::Layout(err) => err_inval!(Layout(*err)).into(),
350350
FnAbiError::AdjustForForeignAbi(err) => {
351351
err_inval!(FnAbiAdjustForForeignAbi(err)).into()
352352
}

compiler/rustc_interface/src/passes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,13 +658,13 @@ fn write_out_deps(
658658
boxed_resolver.borrow_mut().access(|resolver| {
659659
for cnum in resolver.cstore().crates_untracked() {
660660
let source = resolver.cstore().crate_source_untracked(cnum);
661-
if let Some((path, _)) = source.dylib {
661+
if let Some((path, _)) = &source.dylib {
662662
files.push(escape_dep_filename(&path.display().to_string()));
663663
}
664-
if let Some((path, _)) = source.rlib {
664+
if let Some((path, _)) = &source.rlib {
665665
files.push(escape_dep_filename(&path.display().to_string()));
666666
}
667-
if let Some((path, _)) = source.rmeta {
667+
if let Some((path, _)) = &source.rmeta {
668668
files.push(escape_dep_filename(&path.display().to_string()));
669669
}
670670
}

compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ crate struct CrateMetadata {
120120
/// How to link (or not link) this crate to the currently compiled crate.
121121
dep_kind: Lock<CrateDepKind>,
122122
/// Filesystem location of this crate.
123-
source: CrateSource,
123+
source: Lrc<CrateSource>,
124124
/// Whether or not this crate should be consider a private dependency
125125
/// for purposes of the 'exported_private_dependencies' lint
126126
private_dep: bool,
@@ -1875,7 +1875,7 @@ impl CrateMetadata {
18751875
cnum_map,
18761876
dependencies,
18771877
dep_kind: Lock::new(dep_kind),
1878-
source,
1878+
source: Lrc::new(source),
18791879
private_dep,
18801880
host_hash,
18811881
extern_crate: Lock::new(None),
@@ -1903,7 +1903,7 @@ impl CrateMetadata {
19031903
}
19041904

19051905
crate fn source(&self) -> &CrateSource {
1906-
&self.source
1906+
&*self.source
19071907
}
19081908

19091909
crate fn dep_kind(&self) -> CrateDepKind {

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::foreign_modules;
33
use crate::native_libs;
44

55
use rustc_ast as ast;
6-
use rustc_data_structures::stable_map::FxHashMap;
76
use rustc_hir::def::{CtorKind, DefKind, Res};
87
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, CRATE_DEF_INDEX, LOCAL_CRATE};
98
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
@@ -13,7 +12,7 @@ use rustc_middle::middle::stability::DeprecationEntry;
1312
use rustc_middle::ty::fast_reject::SimplifiedType;
1413
use rustc_middle::ty::query::{ExternProviders, Providers};
1514
use rustc_middle::ty::{self, TyCtxt, Visibility};
16-
use rustc_session::cstore::{CrateSource, CrateStore, ForeignModule};
15+
use rustc_session::cstore::{CrateSource, CrateStore};
1716
use rustc_session::utils::NativeLibKind;
1817
use rustc_session::{Session, StableCrateId};
1918
use rustc_span::hygiene::{ExpnHash, ExpnId};
@@ -179,10 +178,8 @@ provide! { <'tcx> tcx, def_id, other, cdata,
179178

180179
reachable_non_generics
181180
}
182-
native_libraries => { Lrc::new(cdata.get_native_libraries(tcx.sess).collect()) }
183-
foreign_modules => {
184-
Lrc::new(cdata.get_foreign_modules(tcx.sess).map(|m| (m.def_id, m)).collect())
185-
}
181+
native_libraries => { cdata.get_native_libraries(tcx.sess).collect() }
182+
foreign_modules => { cdata.get_foreign_modules(tcx.sess).map(|m| (m.def_id, m)).collect() }
186183
crate_hash => { cdata.root.hash }
187184
crate_host_hash => { cdata.host_hash }
188185
crate_name => { cdata.root.name }
@@ -212,7 +209,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
212209
r
213210
}
214211

215-
used_crate_source => { Lrc::new(cdata.source.clone()) }
212+
used_crate_source => { Lrc::clone(&cdata.source) }
216213

217214
exported_symbols => {
218215
let syms = cdata.exported_symbols(tcx);
@@ -266,13 +263,11 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
266263
},
267264
native_libraries: |tcx, cnum| {
268265
assert_eq!(cnum, LOCAL_CRATE);
269-
Lrc::new(native_libs::collect(tcx))
266+
native_libs::collect(tcx)
270267
},
271268
foreign_modules: |tcx, cnum| {
272269
assert_eq!(cnum, LOCAL_CRATE);
273-
let modules: FxHashMap<DefId, ForeignModule> =
274-
foreign_modules::collect(tcx).into_iter().map(|m| (m.def_id, m)).collect();
275-
Lrc::new(modules)
270+
foreign_modules::collect(tcx).into_iter().map(|m| (m.def_id, m)).collect()
276271
},
277272

278273
// Returns a map from a sufficiently visible external item (i.e., an
@@ -354,7 +349,7 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
354349
visible_parent_map.entry(child).or_insert(parent);
355350
}
356351

357-
Lrc::new(visible_parent_map)
352+
visible_parent_map
358353
},
359354

360355
dependency_formats: |tcx, ()| Lrc::new(crate::dependency_format::calculate(tcx)),
@@ -438,7 +433,7 @@ impl CStore {
438433
self.get_crate_data(def.krate).get_fn_has_self_parameter(def.index)
439434
}
440435

441-
pub fn crate_source_untracked(&self, cnum: CrateNum) -> CrateSource {
436+
pub fn crate_source_untracked(&self, cnum: CrateNum) -> Lrc<CrateSource> {
442437
self.get_crate_data(cnum).source.clone()
443438
}
444439

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
17421742
hash: self.tcx.crate_hash(cnum),
17431743
host_hash: self.tcx.crate_host_hash(cnum),
17441744
kind: self.tcx.dep_kind(cnum),
1745-
extra_filename: self.tcx.extra_filename(cnum),
1745+
extra_filename: self.tcx.extra_filename(cnum).clone(),
17461746
};
17471747
(cnum, dep)
17481748
})

compiler/rustc_middle/src/arena.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ macro_rules! arena_types {
5252
Vec<rustc_middle::traits::query::OutlivesBound<'tcx>>
5353
>
5454
>,
55+
[] dtorck_constraint: rustc_middle::traits::query::DtorckConstraint<'tcx>,
56+
[] candidate_step: rustc_middle::traits::query::CandidateStep<'tcx>,
57+
[] autoderef_bad_ty: rustc_middle::traits::query::MethodAutoderefBadTy<'tcx>,
5558
[] type_op_subtype:
5659
rustc_middle::infer::canonical::Canonical<'tcx,
5760
rustc_middle::infer::canonical::QueryResponse<'tcx, ()>
@@ -95,6 +98,7 @@ macro_rules! arena_types {
9598
// This is used to decode the &'tcx [Span] for InlineAsm's line_spans.
9699
[decode] span: rustc_span::Span,
97100
[decode] used_trait_imports: rustc_data_structures::fx::FxHashSet<rustc_hir::def_id::LocalDefId>,
101+
[decode] impl_source: rustc_middle::traits::ImplSource<'tcx, ()>,
98102

99103
[] dep_kind: rustc_middle::dep_graph::DepKindStruct,
100104
]);

compiler/rustc_middle/src/middle/stability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub enum StabilityLevel {
2929
}
3030

3131
/// An entry in the `depr_map`.
32-
#[derive(Clone, HashStable, Debug)]
32+
#[derive(Copy, Clone, HashStable, Debug)]
3333
pub struct DeprecationEntry {
3434
/// The metadata of the attribute associated with this entry.
3535
pub attr: Deprecation,

compiler/rustc_middle/src/mir/interpret/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pub enum InvalidProgramInfo<'tcx> {
144144
/// An error occurred during FnAbi computation: the passed --target lacks FFI support
145145
/// (which unfortunately typeck does not reject).
146146
/// Not using `FnAbiError` as that contains a nested `LayoutError`.
147-
FnAbiAdjustForForeignAbi(call::AdjustForForeignAbiError),
147+
FnAbiAdjustForForeignAbi(&'tcx call::AdjustForForeignAbiError),
148148
/// An invalid transmute happened.
149149
TransmuteSizeDiff(Ty<'tcx>, Ty<'tcx>),
150150
/// SizeOf of unsized type was requested.

0 commit comments

Comments
 (0)