1
Fork 0

Auto merge of #125448 - matthiaskrgr:rollup-vn6nleh, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #124297 (Allow coercing functions whose signature differs in opaque types in their defining scope into a shared function pointer type)
 - #124516 (Allow monomorphization time const eval failures if the cause is a type layout issue)
 - #124976 (rustc: Use `tcx.used_crates(())` more)
 - #125210 (Cleanup: Fix up some diagnostics)
 - #125409 (Rename `FrameworkOnlyWindows` to `RawDylibOnlyWindows`)
 - #125416 (Use correct param-env in `MissingCopyImplementations`)
 - #125421 (Rewrite `core-no-oom-handling`, `issue-24445` and `issue-38237` `run-make` tests to new `rmake.rs` format)
 - #125438 (Remove unneeded string conversion)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-05-23 12:44:13 +00:00
commit ed172dbbaf
70 changed files with 404 additions and 155 deletions

View file

@ -786,12 +786,12 @@ fn link_natively(
if matches!(flavor, LinkerFlavor::Gnu(Cc::Yes, _)) if matches!(flavor, LinkerFlavor::Gnu(Cc::Yes, _))
&& unknown_arg_regex.is_match(&out) && unknown_arg_regex.is_match(&out)
&& out.contains("-no-pie") && out.contains("-no-pie")
&& cmd.get_args().iter().any(|e| e.to_string_lossy() == "-no-pie") && cmd.get_args().iter().any(|e| e == "-no-pie")
{ {
info!("linker output: {:?}", out); info!("linker output: {:?}", out);
warn!("Linker does not support -no-pie command line option. Retrying without."); warn!("Linker does not support -no-pie command line option. Retrying without.");
for arg in cmd.take_args() { for arg in cmd.take_args() {
if arg.to_string_lossy() != "-no-pie" { if arg != "-no-pie" {
cmd.arg(arg); cmd.arg(arg);
} }
} }
@ -825,7 +825,7 @@ fn link_natively(
if matches!(flavor, LinkerFlavor::Gnu(Cc::Yes, _)) if matches!(flavor, LinkerFlavor::Gnu(Cc::Yes, _))
&& unknown_arg_regex.is_match(&out) && unknown_arg_regex.is_match(&out)
&& (out.contains("-static-pie") || out.contains("--no-dynamic-linker")) && (out.contains("-static-pie") || out.contains("--no-dynamic-linker"))
&& cmd.get_args().iter().any(|e| e.to_string_lossy() == "-static-pie") && cmd.get_args().iter().any(|e| e == "-static-pie")
{ {
info!("linker output: {:?}", out); info!("linker output: {:?}", out);
warn!( warn!(
@ -864,7 +864,7 @@ fn link_natively(
assert!(pre_objects_static.is_empty() || !pre_objects_static_pie.is_empty()); assert!(pre_objects_static.is_empty() || !pre_objects_static_pie.is_empty());
assert!(post_objects_static.is_empty() || !post_objects_static_pie.is_empty()); assert!(post_objects_static.is_empty() || !post_objects_static_pie.is_empty());
for arg in cmd.take_args() { for arg in cmd.take_args() {
if arg.to_string_lossy() == "-static-pie" { if arg == "-static-pie" {
// Replace the output kind. // Replace the output kind.
cmd.arg("-static"); cmd.arg("-static");
} else if pre_objects_static_pie.contains(&arg) { } else if pre_objects_static_pie.contains(&arg) {

View file

@ -399,7 +399,7 @@ fn upstream_monomorphizations_provider(
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
(): (), (): (),
) -> DefIdMap<UnordMap<GenericArgsRef<'_>, CrateNum>> { ) -> DefIdMap<UnordMap<GenericArgsRef<'_>, CrateNum>> {
let cnums = tcx.crates(()); let cnums = tcx.used_crates(());
let mut instances: DefIdMap<UnordMap<_, _>> = Default::default(); let mut instances: DefIdMap<UnordMap<_, _>> = Default::default();

View file

@ -539,7 +539,7 @@ pub fn collect_debugger_visualizers_transitive(
tcx.debugger_visualizers(LOCAL_CRATE) tcx.debugger_visualizers(LOCAL_CRATE)
.iter() .iter()
.chain( .chain(
tcx.crates(()) tcx.used_crates(())
.iter() .iter()
.filter(|&cnum| { .filter(|&cnum| {
let used_crate_source = tcx.used_crate_source(*cnum); let used_crate_source = tcx.used_crate_source(*cnum);
@ -849,7 +849,7 @@ impl CrateInfo {
// `compiler_builtins` are always placed last to ensure that they're linked correctly. // `compiler_builtins` are always placed last to ensure that they're linked correctly.
used_crates.extend(compiler_builtins); used_crates.extend(compiler_builtins);
let crates = tcx.crates(()); let crates = tcx.used_crates(());
let n_crates = crates.len(); let n_crates = crates.len();
let mut info = CrateInfo { let mut info = CrateInfo {
target_cpu, target_cpu,

View file

@ -2,7 +2,7 @@ use std::mem;
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, Diagnostic, IntoDiagArg}; use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, Diagnostic, IntoDiagArg};
use rustc_hir::CRATE_HIR_ID; use rustc_hir::CRATE_HIR_ID;
use rustc_middle::mir::interpret::Provenance; use rustc_middle::mir::interpret::{Provenance, ReportedErrorInfo};
use rustc_middle::mir::AssertKind; use rustc_middle::mir::AssertKind;
use rustc_middle::query::TyCtxtAt; use rustc_middle::query::TyCtxtAt;
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
@ -139,9 +139,10 @@ where
ErrorHandled::TooGeneric(span) ErrorHandled::TooGeneric(span)
} }
err_inval!(AlreadyReported(guar)) => ErrorHandled::Reported(guar, span), err_inval!(AlreadyReported(guar)) => ErrorHandled::Reported(guar, span),
err_inval!(Layout(LayoutError::ReferencesError(guar))) => { err_inval!(Layout(LayoutError::ReferencesError(guar))) => ErrorHandled::Reported(
ErrorHandled::Reported(guar.into(), span) ReportedErrorInfo::tainted_by_errors(guar),
} span,
),
// Report remaining errors. // Report remaining errors.
_ => { _ => {
let (our_span, frames) = get_span_and_frames(); let (our_span, frames) = get_span_and_frames();

View file

@ -1181,9 +1181,20 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> { ) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
M::eval_mir_constant(self, *val, span, layout, |ecx, val, span, layout| { M::eval_mir_constant(self, *val, span, layout, |ecx, val, span, layout| {
let const_val = val.eval(*ecx.tcx, ecx.param_env, span).map_err(|err| { let const_val = val.eval(*ecx.tcx, ecx.param_env, span).map_err(|err| {
if M::ALL_CONSTS_ARE_PRECHECKED && !matches!(err, ErrorHandled::TooGeneric(..)) { if M::ALL_CONSTS_ARE_PRECHECKED {
// Looks like the const is not captued by `required_consts`, that's bad. match err {
bug!("interpret const eval failure of {val:?} which is not in required_consts"); ErrorHandled::TooGeneric(..) => {},
ErrorHandled::Reported(reported, span) => {
if reported.is_tainted_by_errors() {
// const-eval will return "tainted" errors if e.g. the layout cannot
// be computed as the type references non-existing names.
// See <https://github.com/rust-lang/rust/issues/124348>.
} else {
// Looks like the const is not captued by `required_consts`, that's bad.
span_bug!(span, "interpret const eval failure of {val:?} which is not in required_consts");
}
}
}
} }
err.emit_note(*ecx.tcx); err.emit_note(*ecx.tcx);
err err

View file

@ -1159,7 +1159,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let sig = self let sig = self
.at(cause, self.param_env) .at(cause, self.param_env)
.trace(prev_ty, new_ty) .trace(prev_ty, new_ty)
.lub(DefineOpaqueTypes::No, a_sig, b_sig) .lub(DefineOpaqueTypes::Yes, a_sig, b_sig)
.map(|ok| self.register_infer_ok_obligations(ok))?; .map(|ok| self.register_infer_ok_obligations(ok))?;
// Reify both sides and return the reified fn pointer type. // Reify both sides and return the reified fn pointer type.

View file

@ -104,10 +104,10 @@ infer_compare_impl_item_obligation = ...so that the definition in impl matches t
infer_consider_specifying_length = consider specifying the actual array length infer_consider_specifying_length = consider specifying the actual array length
infer_data_flows = ...but data{$label_var1_exists -> infer_data_flows = ...but data{$label_var1_exists ->
[true] {" "}from `{$label_var1}` [true] {" "}from `{$label_var1}`
*[false] -> {""} *[false] {""}
} flows{$label_var2_exists -> } flows{$label_var2_exists ->
[true] {" "}into `{$label_var2}` [true] {" "}into `{$label_var2}`
*[false] -> {""} *[false] {""}
} here } here
infer_data_lifetime_flow = ...but data with one lifetime flows into the other here infer_data_lifetime_flow = ...but data with one lifetime flows into the other here

View file

@ -458,7 +458,7 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
} }
} }
for &cnum in tcx.crates(()) { for &cnum in tcx.crates_including_speculative(()) {
let source = tcx.used_crate_source(cnum); let source = tcx.used_crate_source(cnum);
if let Some((path, _)) = &source.dylib { if let Some((path, _)) = &source.dylib {
files.push(escape_dep_filename(&path.display().to_string())); files.push(escape_dep_filename(&path.display().to_string()));

View file

@ -627,7 +627,7 @@ lint_pattern_in_foreign = patterns aren't allowed in foreign function declaratio
.label = pattern not allowed in foreign function .label = pattern not allowed in foreign function
lint_private_extern_crate_reexport = lint_private_extern_crate_reexport =
extern crate `{$ident}` is private, and cannot be re-exported (error E0365), consider declaring with `pub` extern crate `{$ident}` is private, and cannot be re-exported, consider declaring with `pub`
lint_proc_macro_back_compat = using an old version of `{$crate_name}` lint_proc_macro_back_compat = using an old version of `{$crate_name}`
.note = older versions of the `{$crate_name}` crate will stop compiling in future versions of Rust; please update to `{$crate_name}` v{$fixed_version}, or switch to one of the `{$crate_name}` alternatives .note = older versions of the `{$crate_name}` crate will stop compiling in future versions of Rust; please update to `{$crate_name}` v{$fixed_version}, or switch to one of the `{$crate_name}` alternatives

View file

@ -674,11 +674,10 @@ impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations {
return; return;
} }
} }
let param_env = ty::ParamEnv::empty(); if ty.is_copy_modulo_regions(cx.tcx, cx.param_env) {
if ty.is_copy_modulo_regions(cx.tcx, param_env) {
return; return;
} }
if type_implements_negative_copy_modulo_regions(cx.tcx, ty, param_env) { if type_implements_negative_copy_modulo_regions(cx.tcx, ty, cx.param_env) {
return; return;
} }
if def.is_variant_list_non_exhaustive() if def.is_variant_list_non_exhaustive()
@ -694,7 +693,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations {
.tcx .tcx
.infer_ctxt() .infer_ctxt()
.build() .build()
.type_implements_trait(iter_trait, [ty], param_env) .type_implements_trait(iter_trait, [ty], cx.param_env)
.must_apply_modulo_regions() .must_apply_modulo_regions()
{ {
return; return;
@ -711,7 +710,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations {
if type_allowed_to_implement_copy( if type_allowed_to_implement_copy(
cx.tcx, cx.tcx,
param_env, cx.param_env,
ty, ty,
traits::ObligationCause::misc(item.span, item.owner_id.def_id), traits::ObligationCause::misc(item.span, item.owner_id.def_id),
) )

View file

@ -2228,7 +2228,7 @@ pub struct MacroUseDeprecated;
pub struct UnusedMacroUse; pub struct UnusedMacroUse;
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(lint_private_extern_crate_reexport)] #[diag(lint_private_extern_crate_reexport, code = E0365)]
pub struct PrivateExternCrateReexport { pub struct PrivateExternCrateReexport {
pub ident: Ident, pub ident: Ident,
} }

View file

@ -91,9 +91,6 @@ metadata_found_staticlib =
found staticlib `{$crate_name}` instead of rlib or dylib{$add_info} found staticlib `{$crate_name}` instead of rlib or dylib{$add_info}
.help = please recompile that crate using --crate-type lib .help = please recompile that crate using --crate-type lib
metadata_framework_only_windows =
link kind `raw-dylib` is only supported on Windows targets
metadata_global_alloc_required = metadata_global_alloc_required =
no global memory allocator found but one is required; link to std or add `#[global_allocator]` to a static item that implements the GlobalAlloc trait no global memory allocator found but one is required; link to std or add `#[global_allocator]` to a static item that implements the GlobalAlloc trait
@ -233,6 +230,9 @@ metadata_profiler_builtins_needs_core =
metadata_raw_dylib_no_nul = metadata_raw_dylib_no_nul =
link name must not contain NUL characters if link kind is `raw-dylib` link name must not contain NUL characters if link kind is `raw-dylib`
metadata_raw_dylib_only_windows =
link kind `raw-dylib` is only supported on Windows targets
metadata_renaming_no_link = metadata_renaming_no_link =
renaming of the library `{$lib_name}` was specified, however this crate contains no `#[link(...)]` attributes referencing this library renaming of the library `{$lib_name}` was specified, however this crate contains no `#[link(...)]` attributes referencing this library

View file

@ -143,7 +143,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
&& sess.crt_static(Some(ty)) && sess.crt_static(Some(ty))
&& !sess.target.crt_static_allows_dylibs) && !sess.target.crt_static_allows_dylibs)
{ {
for &cnum in tcx.crates(()).iter() { for &cnum in tcx.used_crates(()).iter() {
if tcx.dep_kind(cnum).macros_only() { if tcx.dep_kind(cnum).macros_only() {
continue; continue;
} }
@ -164,7 +164,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
// Sweep all crates for found dylibs. Add all dylibs, as well as their // Sweep all crates for found dylibs. Add all dylibs, as well as their
// dependencies, ensuring there are no conflicts. The only valid case for a // dependencies, ensuring there are no conflicts. The only valid case for a
// dependency to be relied upon twice is for both cases to rely on a dylib. // dependency to be relied upon twice is for both cases to rely on a dylib.
for &cnum in tcx.crates(()).iter() { for &cnum in tcx.used_crates(()).iter() {
if tcx.dep_kind(cnum).macros_only() { if tcx.dep_kind(cnum).macros_only() {
continue; continue;
} }
@ -182,7 +182,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
} }
// Collect what we've got so far in the return vector. // Collect what we've got so far in the return vector.
let last_crate = tcx.crates(()).len(); let last_crate = tcx.used_crates(()).len();
let mut ret = (1..last_crate + 1) let mut ret = (1..last_crate + 1)
.map(|cnum| match formats.get(&CrateNum::new(cnum)) { .map(|cnum| match formats.get(&CrateNum::new(cnum)) {
Some(&RequireDynamic) => Linkage::Dynamic, Some(&RequireDynamic) => Linkage::Dynamic,
@ -196,7 +196,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
// //
// If the crate hasn't been included yet and it's not actually required // If the crate hasn't been included yet and it's not actually required
// (e.g., it's an allocator) then we skip it here as well. // (e.g., it's an allocator) then we skip it here as well.
for &cnum in tcx.crates(()).iter() { for &cnum in tcx.used_crates(()).iter() {
let src = tcx.used_crate_source(cnum); let src = tcx.used_crate_source(cnum);
if src.dylib.is_none() if src.dylib.is_none()
&& !formats.contains_key(&cnum) && !formats.contains_key(&cnum)
@ -284,7 +284,7 @@ fn add_library(
fn attempt_static(tcx: TyCtxt<'_>, unavailable: &mut Vec<CrateNum>) -> Option<DependencyList> { fn attempt_static(tcx: TyCtxt<'_>, unavailable: &mut Vec<CrateNum>) -> Option<DependencyList> {
let all_crates_available_as_rlib = tcx let all_crates_available_as_rlib = tcx
.crates(()) .used_crates(())
.iter() .iter()
.copied() .copied()
.filter_map(|cnum| { .filter_map(|cnum| {
@ -305,7 +305,7 @@ fn attempt_static(tcx: TyCtxt<'_>, unavailable: &mut Vec<CrateNum>) -> Option<De
// All crates are available in an rlib format, so we're just going to link // All crates are available in an rlib format, so we're just going to link
// everything in explicitly so long as it's actually required. // everything in explicitly so long as it's actually required.
let mut ret = tcx let mut ret = tcx
.crates(()) .used_crates(())
.iter() .iter()
.map(|&cnum| match tcx.dep_kind(cnum) { .map(|&cnum| match tcx.dep_kind(cnum) {
CrateDepKind::Explicit => Linkage::Static, CrateDepKind::Explicit => Linkage::Static,

View file

@ -142,8 +142,8 @@ pub struct LinkFrameworkApple {
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(metadata_framework_only_windows, code = E0455)] #[diag(metadata_raw_dylib_only_windows, code = E0455)]
pub struct FrameworkOnlyWindows { pub struct RawDylibOnlyWindows {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }

View file

@ -151,7 +151,7 @@ impl<'tcx> Collector<'tcx> {
} }
"raw-dylib" => { "raw-dylib" => {
if !sess.target.is_like_windows { if !sess.target.is_like_windows {
sess.dcx().emit_err(errors::FrameworkOnlyWindows { span }); sess.dcx().emit_err(errors::RawDylibOnlyWindows { span });
} }
NativeLibKind::RawDylib NativeLibKind::RawDylib
} }

View file

@ -435,7 +435,7 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
// traversal, but not globally minimal across all crates. // traversal, but not globally minimal across all crates.
let bfs_queue = &mut VecDeque::new(); let bfs_queue = &mut VecDeque::new();
for &cnum in tcx.crates(()) { for &cnum in tcx.crates_including_speculative(()) {
// Ignore crates without a corresponding local `extern crate` item. // Ignore crates without a corresponding local `extern crate` item.
if tcx.missing_extern_crate_item(cnum) { if tcx.missing_extern_crate_item(cnum) {
continue; continue;
@ -505,7 +505,7 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
tcx.arena tcx.arena
.alloc_slice(&CStore::from_tcx(tcx).crate_dependencies_in_postorder(LOCAL_CRATE)) .alloc_slice(&CStore::from_tcx(tcx).crate_dependencies_in_postorder(LOCAL_CRATE))
}, },
crates: |tcx, ()| { crates_including_speculative: |tcx, ()| {
// The list of loaded crates is now frozen in query cache, // The list of loaded crates is now frozen in query cache,
// so make sure cstore is not mutably accessed from here on. // so make sure cstore is not mutably accessed from here on.
tcx.untracked().cstore.freeze(); tcx.untracked().cstore.freeze();

View file

@ -1898,7 +1898,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
let deps = self let deps = self
.tcx .tcx
.crates(()) .crates_including_speculative(())
.iter() .iter()
.map(|&cnum| { .map(|&cnum| {
let dep = CrateDep { let dep = CrateDep {

View file

@ -1016,7 +1016,7 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, _: LocalCrate) -> Svh {
let krate = tcx.hir_crate(()); let krate = tcx.hir_crate(());
let hir_body_hash = krate.opt_hir_hash.expect("HIR hash missing while computing crate hash"); let hir_body_hash = krate.opt_hir_hash.expect("HIR hash missing while computing crate hash");
let upstream_crates = upstream_crates(tcx); let upstream_crates = upstream_crates_for_hashing(tcx);
let resolutions = tcx.resolutions(()); let resolutions = tcx.resolutions(());
@ -1085,9 +1085,9 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, _: LocalCrate) -> Svh {
Svh::new(crate_hash) Svh::new(crate_hash)
} }
fn upstream_crates(tcx: TyCtxt<'_>) -> Vec<(StableCrateId, Svh)> { fn upstream_crates_for_hashing(tcx: TyCtxt<'_>) -> Vec<(StableCrateId, Svh)> {
let mut upstream_crates: Vec<_> = tcx let mut upstream_crates: Vec<_> = tcx
.crates(()) .crates_including_speculative(())
.iter() .iter()
.map(|&cnum| { .map(|&cnum| {
let stable_crate_id = tcx.stable_crate_id(cnum); let stable_crate_id = tcx.stable_crate_id(cnum);

View file

@ -66,6 +66,9 @@ impl ReportedErrorInfo {
pub fn tainted_by_errors(error: ErrorGuaranteed) -> ReportedErrorInfo { pub fn tainted_by_errors(error: ErrorGuaranteed) -> ReportedErrorInfo {
ReportedErrorInfo { is_tainted_by_errors: true, error } ReportedErrorInfo { is_tainted_by_errors: true, error }
} }
pub fn is_tainted_by_errors(&self) -> bool {
self.is_tainted_by_errors
}
} }
impl From<ErrorGuaranteed> for ReportedErrorInfo { impl From<ErrorGuaranteed> for ReportedErrorInfo {

View file

@ -1860,13 +1860,22 @@ rustc_queries! {
eval_always eval_always
desc { "calculating the stability index for the local crate" } desc { "calculating the stability index for the local crate" }
} }
query crates(_: ()) -> &'tcx [CrateNum] { /// All loaded crates, including those loaded purely for doc links or diagnostics.
/// (Diagnostics include lints, so speculatively loaded crates may occur in successful
/// compilation even without doc links.)
/// Should be used when encoding crate metadata (and therefore when generating crate hash,
/// depinfo and similar things), to avoid dangling crate references in other encoded data,
/// like source maps.
/// May also be used for diagnostics - if we are loading a crate anyway we can suggest some
/// items from it as well.
/// But otherwise, `used_crates` should generally be used.
query crates_including_speculative(_: ()) -> &'tcx [CrateNum] {
eval_always eval_always
desc { "fetching all foreign CrateNum instances" } desc { "fetching all foreign CrateNum instances" }
} }
// Crates that are loaded non-speculatively (not for diagnostics or doc links). /// Crates that are loaded non-speculatively (not for diagnostics or doc links).
// FIXME: This is currently only used for collecting lang items, but should be used instead of /// Should be used to maintain observable language behavior, for example when collecting lang
// `crates` in most other cases too. /// items or impls from all crates, or collecting libraries to link.
query used_crates(_: ()) -> &'tcx [CrateNum] { query used_crates(_: ()) -> &'tcx [CrateNum] {
eval_always eval_always
desc { "fetching `CrateNum`s for all crates loaded non-speculatively" } desc { "fetching `CrateNum`s for all crates loaded non-speculatively" }

View file

@ -1611,7 +1611,7 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn all_traits(self) -> impl Iterator<Item = DefId> + 'tcx { pub fn all_traits(self) -> impl Iterator<Item = DefId> + 'tcx {
iter::once(LOCAL_CRATE) iter::once(LOCAL_CRATE)
.chain(self.crates(()).iter().copied()) .chain(self.used_crates(()).iter().copied())
.flat_map(move |cnum| self.traits(cnum).iter().copied()) .flat_map(move |cnum| self.traits(cnum).iter().copied())
} }

View file

@ -3258,7 +3258,7 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
let queue = &mut Vec::new(); let queue = &mut Vec::new();
let mut seen_defs: DefIdSet = Default::default(); let mut seen_defs: DefIdSet = Default::default();
for &cnum in tcx.crates(()).iter() { for &cnum in tcx.crates_including_speculative(()).iter() {
let def_id = cnum.as_def_id(); let def_id = cnum.as_def_id();
// Ignore crates that are not direct dependencies. // Ignore crates that are not direct dependencies.

View file

@ -205,7 +205,7 @@ pub(super) fn trait_impls_of_provider(tcx: TyCtxt<'_>, trait_id: DefId) -> Trait
// Traits defined in the current crate can't have impls in upstream // Traits defined in the current crate can't have impls in upstream
// crates, so we don't bother querying the cstore. // crates, so we don't bother querying the cstore.
if !trait_id.is_local() { if !trait_id.is_local() {
for &cnum in tcx.crates(()).iter() { for &cnum in tcx.used_crates(()).iter() {
for &(impl_def_id, simplified_self_ty) in for &(impl_def_id, simplified_self_ty) in
tcx.implementations_of_trait((cnum, trait_id)).iter() tcx.implementations_of_trait((cnum, trait_id)).iter()
{ {
@ -247,7 +247,7 @@ pub(super) fn incoherent_impls_provider(
let mut impls = Vec::new(); let mut impls = Vec::new();
let mut res = Ok(()); let mut res = Ok(());
for cnum in iter::once(LOCAL_CRATE).chain(tcx.crates(()).iter().copied()) { for cnum in iter::once(LOCAL_CRATE).chain(tcx.used_crates(()).iter().copied()) {
let incoherent_impls = match tcx.crate_incoherent_impls((cnum, simp)) { let incoherent_impls = match tcx.crate_incoherent_impls((cnum, simp)) {
Ok(impls) => impls, Ok(impls) => impls,
Err(e) => { Err(e) => {

View file

@ -335,12 +335,12 @@ mir_build_unsafe_fn_safe_body = an unsafe function restricts its caller, but its
mir_build_unsafe_not_inherited = items do not inherit unsafety from separate enclosing items mir_build_unsafe_not_inherited = items do not inherit unsafety from separate enclosing items
mir_build_unsafe_op_in_unsafe_fn_borrow_of_layout_constrained_field_requires_unsafe = mir_build_unsafe_op_in_unsafe_fn_borrow_of_layout_constrained_field_requires_unsafe =
borrow of layout constrained field with interior mutability is unsafe and requires unsafe block (error E0133) borrow of layout constrained field with interior mutability is unsafe and requires unsafe block
.note = references to fields of layout constrained fields lose the constraints. Coupled with interior mutability, the field can be changed to invalid values .note = references to fields of layout constrained fields lose the constraints. Coupled with interior mutability, the field can be changed to invalid values
.label = borrow of layout constrained field with interior mutability .label = borrow of layout constrained field with interior mutability
mir_build_unsafe_op_in_unsafe_fn_call_to_fn_with_requires_unsafe = mir_build_unsafe_op_in_unsafe_fn_call_to_fn_with_requires_unsafe =
call to function `{$function}` with `#[target_feature]` is unsafe and requires unsafe block (error E0133) call to function `{$function}` with `#[target_feature]` is unsafe and requires unsafe block
.help = in order for the call to be safe, the context requires the following additional target {$missing_target_features_count -> .help = in order for the call to be safe, the context requires the following additional target {$missing_target_features_count ->
[1] feature [1] feature
*[count] features *[count] features
@ -355,48 +355,47 @@ mir_build_unsafe_op_in_unsafe_fn_call_to_fn_with_requires_unsafe =
.label = call to function with `#[target_feature]` .label = call to function with `#[target_feature]`
mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe = mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe =
call to unsafe function `{$function}` is unsafe and requires unsafe block (error E0133) call to unsafe function `{$function}` is unsafe and requires unsafe block
.note = consult the function's documentation for information on how to avoid undefined behavior .note = consult the function's documentation for information on how to avoid undefined behavior
.label = call to unsafe function .label = call to unsafe function
mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe_nameless = mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe_nameless =
call to unsafe function is unsafe and requires unsafe block (error E0133) call to unsafe function is unsafe and requires unsafe block
.note = consult the function's documentation for information on how to avoid undefined behavior .note = consult the function's documentation for information on how to avoid undefined behavior
.label = call to unsafe function .label = call to unsafe function
mir_build_unsafe_op_in_unsafe_fn_deref_raw_pointer_requires_unsafe = mir_build_unsafe_op_in_unsafe_fn_deref_raw_pointer_requires_unsafe =
dereference of raw pointer is unsafe and requires unsafe block (error E0133) dereference of raw pointer is unsafe and requires unsafe block
.note = raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior .note = raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
.label = dereference of raw pointer .label = dereference of raw pointer
mir_build_unsafe_op_in_unsafe_fn_extern_static_requires_unsafe = mir_build_unsafe_op_in_unsafe_fn_extern_static_requires_unsafe =
use of extern static is unsafe and requires unsafe block (error E0133) use of extern static is unsafe and requires unsafe block
.note = extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior .note = extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
.label = use of extern static .label = use of extern static
mir_build_unsafe_op_in_unsafe_fn_initializing_type_with_requires_unsafe = mir_build_unsafe_op_in_unsafe_fn_initializing_type_with_requires_unsafe =
initializing type with `rustc_layout_scalar_valid_range` attr is unsafe and requires unsafe initializing type with `rustc_layout_scalar_valid_range` attr is unsafe and requires unsafe block
block (error E0133)
.note = initializing a layout restricted type's field with a value outside the valid range is undefined behavior .note = initializing a layout restricted type's field with a value outside the valid range is undefined behavior
.label = initializing type with `rustc_layout_scalar_valid_range` attr .label = initializing type with `rustc_layout_scalar_valid_range` attr
mir_build_unsafe_op_in_unsafe_fn_inline_assembly_requires_unsafe = mir_build_unsafe_op_in_unsafe_fn_inline_assembly_requires_unsafe =
use of inline assembly is unsafe and requires unsafe block (error E0133) use of inline assembly is unsafe and requires unsafe block
.note = inline assembly is entirely unchecked and can cause undefined behavior .note = inline assembly is entirely unchecked and can cause undefined behavior
.label = use of inline assembly .label = use of inline assembly
mir_build_unsafe_op_in_unsafe_fn_mutable_static_requires_unsafe = mir_build_unsafe_op_in_unsafe_fn_mutable_static_requires_unsafe =
use of mutable static is unsafe and requires unsafe block (error E0133) use of mutable static is unsafe and requires unsafe block
.note = mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior .note = mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
.label = use of mutable static .label = use of mutable static
mir_build_unsafe_op_in_unsafe_fn_mutation_of_layout_constrained_field_requires_unsafe = mir_build_unsafe_op_in_unsafe_fn_mutation_of_layout_constrained_field_requires_unsafe =
mutation of layout constrained field is unsafe and requires unsafe block (error E0133) mutation of layout constrained field is unsafe and requires unsafe block
.note = mutating layout constrained fields cannot statically be checked for valid values .note = mutating layout constrained fields cannot statically be checked for valid values
.label = mutation of layout constrained field .label = mutation of layout constrained field
mir_build_unsafe_op_in_unsafe_fn_union_field_requires_unsafe = mir_build_unsafe_op_in_unsafe_fn_union_field_requires_unsafe =
access to union field is unsafe and requires unsafe block (error E0133) access to union field is unsafe and requires unsafe block
.note = the field may not be properly initialized: using uninitialized data will cause undefined behavior .note = the field may not be properly initialized: using uninitialized data will cause undefined behavior
.label = access to union field .label = access to union field

View file

@ -21,7 +21,7 @@ pub struct UnconditionalRecursion {
} }
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe)] #[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe, code = E0133)]
#[note] #[note]
pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe { pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe {
#[label] #[label]
@ -32,7 +32,7 @@ pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe {
} }
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe_nameless)] #[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe_nameless, code = E0133)]
#[note] #[note]
pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafeNameless { pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafeNameless {
#[label] #[label]
@ -42,7 +42,7 @@ pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafeNameless {
} }
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_inline_assembly_requires_unsafe)] #[diag(mir_build_unsafe_op_in_unsafe_fn_inline_assembly_requires_unsafe, code = E0133)]
#[note] #[note]
pub struct UnsafeOpInUnsafeFnUseOfInlineAssemblyRequiresUnsafe { pub struct UnsafeOpInUnsafeFnUseOfInlineAssemblyRequiresUnsafe {
#[label] #[label]
@ -52,7 +52,7 @@ pub struct UnsafeOpInUnsafeFnUseOfInlineAssemblyRequiresUnsafe {
} }
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_initializing_type_with_requires_unsafe)] #[diag(mir_build_unsafe_op_in_unsafe_fn_initializing_type_with_requires_unsafe, code = E0133)]
#[note] #[note]
pub struct UnsafeOpInUnsafeFnInitializingTypeWithRequiresUnsafe { pub struct UnsafeOpInUnsafeFnInitializingTypeWithRequiresUnsafe {
#[label] #[label]
@ -62,7 +62,7 @@ pub struct UnsafeOpInUnsafeFnInitializingTypeWithRequiresUnsafe {
} }
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_mutable_static_requires_unsafe)] #[diag(mir_build_unsafe_op_in_unsafe_fn_mutable_static_requires_unsafe, code = E0133)]
#[note] #[note]
pub struct UnsafeOpInUnsafeFnUseOfMutableStaticRequiresUnsafe { pub struct UnsafeOpInUnsafeFnUseOfMutableStaticRequiresUnsafe {
#[label] #[label]
@ -72,7 +72,7 @@ pub struct UnsafeOpInUnsafeFnUseOfMutableStaticRequiresUnsafe {
} }
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_extern_static_requires_unsafe)] #[diag(mir_build_unsafe_op_in_unsafe_fn_extern_static_requires_unsafe, code = E0133)]
#[note] #[note]
pub struct UnsafeOpInUnsafeFnUseOfExternStaticRequiresUnsafe { pub struct UnsafeOpInUnsafeFnUseOfExternStaticRequiresUnsafe {
#[label] #[label]
@ -82,7 +82,7 @@ pub struct UnsafeOpInUnsafeFnUseOfExternStaticRequiresUnsafe {
} }
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_deref_raw_pointer_requires_unsafe)] #[diag(mir_build_unsafe_op_in_unsafe_fn_deref_raw_pointer_requires_unsafe, code = E0133)]
#[note] #[note]
pub struct UnsafeOpInUnsafeFnDerefOfRawPointerRequiresUnsafe { pub struct UnsafeOpInUnsafeFnDerefOfRawPointerRequiresUnsafe {
#[label] #[label]
@ -92,7 +92,7 @@ pub struct UnsafeOpInUnsafeFnDerefOfRawPointerRequiresUnsafe {
} }
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_union_field_requires_unsafe)] #[diag(mir_build_unsafe_op_in_unsafe_fn_union_field_requires_unsafe, code = E0133)]
#[note] #[note]
pub struct UnsafeOpInUnsafeFnAccessToUnionFieldRequiresUnsafe { pub struct UnsafeOpInUnsafeFnAccessToUnionFieldRequiresUnsafe {
#[label] #[label]
@ -102,7 +102,10 @@ pub struct UnsafeOpInUnsafeFnAccessToUnionFieldRequiresUnsafe {
} }
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_mutation_of_layout_constrained_field_requires_unsafe)] #[diag(
mir_build_unsafe_op_in_unsafe_fn_mutation_of_layout_constrained_field_requires_unsafe,
code = E0133
)]
#[note] #[note]
pub struct UnsafeOpInUnsafeFnMutationOfLayoutConstrainedFieldRequiresUnsafe { pub struct UnsafeOpInUnsafeFnMutationOfLayoutConstrainedFieldRequiresUnsafe {
#[label] #[label]
@ -112,7 +115,10 @@ pub struct UnsafeOpInUnsafeFnMutationOfLayoutConstrainedFieldRequiresUnsafe {
} }
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_borrow_of_layout_constrained_field_requires_unsafe)] #[diag(
mir_build_unsafe_op_in_unsafe_fn_borrow_of_layout_constrained_field_requires_unsafe,
code = E0133,
)]
pub struct UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe { pub struct UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe {
#[label] #[label]
pub span: Span, pub span: Span,
@ -121,7 +127,7 @@ pub struct UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe {
} }
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_fn_with_requires_unsafe)] #[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_fn_with_requires_unsafe, code = E0133)]
#[help] #[help]
pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe { pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe {
#[label] #[label]

View file

@ -82,7 +82,7 @@ fn all_diagnostic_items(tcx: TyCtxt<'_>, (): ()) -> DiagnosticItems {
let mut items = DiagnosticItems::default(); let mut items = DiagnosticItems::default();
// Collect diagnostic items in other crates. // Collect diagnostic items in other crates.
for &cnum in tcx.crates(()).iter().chain(std::iter::once(&LOCAL_CRATE)) { for &cnum in tcx.crates_including_speculative(()).iter().chain(std::iter::once(&LOCAL_CRATE)) {
for (&name, &def_id) in &tcx.diagnostic_items(cnum).name_to_id { for (&name, &def_id) in &tcx.diagnostic_items(cnum).name_to_id {
collect_item(tcx, &mut items, name, def_id); collect_item(tcx, &mut items, name, def_id);
} }

View file

@ -1020,7 +1020,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
// stabilization diagnostic, but it can be avoided when there are no // stabilization diagnostic, but it can be avoided when there are no
// `remaining_lib_features`. // `remaining_lib_features`.
let mut all_implications = remaining_implications.clone(); let mut all_implications = remaining_implications.clone();
for &cnum in tcx.crates(()) { for &cnum in tcx.used_crates(()) {
all_implications all_implications
.extend_unord(tcx.stability_implications(cnum).items().map(|(k, v)| (*k, *v))); .extend_unord(tcx.stability_implications(cnum).items().map(|(k, v)| (*k, *v)));
} }
@ -1033,7 +1033,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
&all_implications, &all_implications,
); );
for &cnum in tcx.crates(()) { for &cnum in tcx.used_crates(()) {
if remaining_lib_features.is_empty() && remaining_implications.is_empty() { if remaining_lib_features.is_empty() && remaining_implications.is_empty() {
break; break;
} }

View file

@ -68,7 +68,7 @@ fn verify(tcx: TyCtxt<'_>, items: &lang_items::LanguageItems) {
} }
let mut missing = FxHashSet::default(); let mut missing = FxHashSet::default();
for &cnum in tcx.crates(()).iter() { for &cnum in tcx.used_crates(()).iter() {
for &item in tcx.missing_lang_items(cnum).iter() { for &item in tcx.missing_lang_items(cnum).iter() {
missing.insert(item); missing.insert(item);
} }

View file

@ -126,7 +126,7 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
let mut tables = self.0.borrow_mut(); let mut tables = self.0.borrow_mut();
let tcx = tables.tcx; let tcx = tables.tcx;
iter::once(LOCAL_CRATE) iter::once(LOCAL_CRATE)
.chain(tables.tcx.crates(()).iter().copied()) .chain(tables.tcx.used_crates(()).iter().copied())
.flat_map(|cnum| tcx.trait_impls_in_crate(cnum).iter()) .flat_map(|cnum| tcx.trait_impls_in_crate(cnum).iter())
.map(|impl_def_id| tables.impl_def(*impl_def_id)) .map(|impl_def_id| tables.impl_def(*impl_def_id))
.collect() .collect()
@ -201,14 +201,19 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
fn external_crates(&self) -> Vec<stable_mir::Crate> { fn external_crates(&self) -> Vec<stable_mir::Crate> {
let tables = self.0.borrow(); let tables = self.0.borrow();
tables.tcx.crates(()).iter().map(|crate_num| smir_crate(tables.tcx, *crate_num)).collect() tables
.tcx
.used_crates(())
.iter()
.map(|crate_num| smir_crate(tables.tcx, *crate_num))
.collect()
} }
fn find_crates(&self, name: &str) -> Vec<stable_mir::Crate> { fn find_crates(&self, name: &str) -> Vec<stable_mir::Crate> {
let tables = self.0.borrow(); let tables = self.0.borrow();
let crates: Vec<stable_mir::Crate> = [LOCAL_CRATE] let crates: Vec<stable_mir::Crate> = [LOCAL_CRATE]
.iter() .iter()
.chain(tables.tcx.crates(()).iter()) .chain(tables.tcx.used_crates(()).iter())
.filter_map(|crate_num| { .filter_map(|crate_num| {
let crate_name = tables.tcx.crate_name(*crate_num).to_string(); let crate_name = tables.tcx.crate_name(*crate_num).to_string();
(name == crate_name).then(|| smir_crate(tables.tcx, *crate_num)) (name == crate_name).then(|| smir_crate(tables.tcx, *crate_num))

View file

@ -1937,7 +1937,7 @@ impl PrimitiveType {
let mut primitive_locations = FxHashMap::default(); let mut primitive_locations = FxHashMap::default();
// NOTE: technically this misses crates that are only passed with `--extern` and not loaded when checking the crate. // NOTE: technically this misses crates that are only passed with `--extern` and not loaded when checking the crate.
// This is a degenerate case that I don't plan to support. // This is a degenerate case that I don't plan to support.
for &crate_num in tcx.crates(()) { for &crate_num in tcx.crates_including_speculative(()) {
let e = ExternalCrate { crate_num }; let e = ExternalCrate { crate_num };
let crate_name = e.name(tcx); let crate_name = e.name(tcx);
debug!(?crate_num, ?crate_name); debug!(?crate_num, ?crate_name);

View file

@ -347,7 +347,7 @@ pub(crate) fn run_global_ctxt(
show_coverage, show_coverage,
}; };
for cnum in tcx.crates(()) { for cnum in tcx.crates_including_speculative(()) {
crate::visit_lib::lib_embargo_visit_item(&mut ctxt, cnum.as_def_id()); crate::visit_lib::lib_embargo_visit_item(&mut ctxt, cnum.as_def_id());
} }

View file

@ -155,7 +155,7 @@ impl Cache {
// Cache where all our extern crates are located // Cache where all our extern crates are located
// FIXME: this part is specific to HTML so it'd be nice to remove it from the common code // FIXME: this part is specific to HTML so it'd be nice to remove it from the common code
for &crate_num in tcx.crates(()) { for &crate_num in tcx.crates_including_speculative(()) {
let e = ExternalCrate { crate_num }; let e = ExternalCrate { crate_num };
let name = e.name(tcx); let name = e.name(tcx);

View file

@ -47,7 +47,7 @@ pub(crate) fn collect_trait_impls(mut krate: Crate, cx: &mut DocContext<'_>) ->
// External trait impls. // External trait impls.
{ {
let _prof_timer = tcx.sess.prof.generic_activity("build_extern_trait_impls"); let _prof_timer = tcx.sess.prof.generic_activity("build_extern_trait_impls");
for &cnum in tcx.crates(()) { for &cnum in tcx.crates_including_speculative(()) {
for &impl_def_id in tcx.trait_impls_in_crate(cnum) { for &impl_def_id in tcx.trait_impls_in_crate(cnum) {
cx.with_param_env(impl_def_id, |cx| { cx.with_param_env(impl_def_id, |cx| {
inline::build_impl(cx, impl_def_id, None, &mut new_items_external); inline::build_impl(cx, impl_def_id, None, &mut new_items_external);

View file

@ -283,7 +283,7 @@ pub(crate) fn run(
// Collect CrateIds corresponding to provided target crates // Collect CrateIds corresponding to provided target crates
// If two different versions of the crate in the dependency tree, then examples will be collected from both. // If two different versions of the crate in the dependency tree, then examples will be collected from both.
let all_crates = tcx let all_crates = tcx
.crates(()) .crates_including_speculative(())
.iter() .iter()
.chain([&LOCAL_CRATE]) .chain([&LOCAL_CRATE])
.map(|crate_num| (crate_num, tcx.crate_name(*crate_num))) .map(|crate_num| (crate_num, tcx.crate_name(*crate_num)))

View file

@ -647,7 +647,7 @@ fn item_children_by_name(tcx: TyCtxt<'_>, def_id: DefId, name: Symbol) -> Vec<Re
/// This function is expensive and should be used sparingly. /// This function is expensive and should be used sparingly.
pub fn def_path_res(cx: &LateContext<'_>, path: &[&str]) -> Vec<Res> { pub fn def_path_res(cx: &LateContext<'_>, path: &[&str]) -> Vec<Res> {
fn find_crates(tcx: TyCtxt<'_>, name: Symbol) -> impl Iterator<Item = DefId> + '_ { fn find_crates(tcx: TyCtxt<'_>, name: Symbol) -> impl Iterator<Item = DefId> + '_ {
tcx.crates(()) tcx.crates_including_speculative(())
.iter() .iter()
.copied() .copied()
.filter(move |&num| tcx.crate_name(num) == name) .filter(move |&num| tcx.crate_name(num) == name)

View file

@ -126,7 +126,7 @@ fn try_resolve_did(tcx: TyCtxt<'_>, path: &[&str], namespace: Option<Namespace>)
// the one in the sysroot and the one locally built by `cargo test`.) // the one in the sysroot and the one locally built by `cargo test`.)
// FIXME: can we prefer the one from the sysroot? // FIXME: can we prefer the one from the sysroot?
'crates: for krate in 'crates: for krate in
tcx.crates(()).iter().filter(|&&krate| tcx.crate_name(krate).as_str() == crate_name) tcx.used_crates(()).iter().filter(|&&krate| tcx.crate_name(krate).as_str() == crate_name)
{ {
let mut cur_item = DefId { krate: *krate, index: CRATE_DEF_INDEX }; let mut cur_item = DefId { krate: *krate, index: CRATE_DEF_INDEX };
// Go over the modules. // Go over the modules.
@ -1365,7 +1365,7 @@ pub fn get_local_crates(tcx: TyCtxt<'_>) -> Vec<CrateNum> {
.map(|crates| crates.split(',').map(|krate| krate.to_string()).collect::<Vec<_>>()) .map(|crates| crates.split(',').map(|krate| krate.to_string()).collect::<Vec<_>>())
.unwrap_or_default(); .unwrap_or_default();
let mut local_crates = Vec::new(); let mut local_crates = Vec::new();
for &crate_num in tcx.crates(()) { for &crate_num in tcx.crates_including_speculative(()) {
let name = tcx.crate_name(crate_num); let name = tcx.crate_name(crate_num);
let name = name.as_str(); let name = name.as_str();
if local_crate_names.iter().any(|local_name| local_name == name) { if local_crate_names.iter().any(|local_name| local_name == name) {

View file

@ -45,6 +45,14 @@ impl Cc {
self self
} }
/// Adds directories to the list that the linker searches for libraries.
/// Equivalent to `-L`.
pub fn library_search_path<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg("-L");
self.cmd.arg(path.as_ref());
self
}
/// Specify `-o` or `-Fe`/`-Fo` depending on platform/compiler. This assumes that the executable /// Specify `-o` or `-Fe`/`-Fo` depending on platform/compiler. This assumes that the executable
/// is under `$TMPDIR`. /// is under `$TMPDIR`.
pub fn out_exe(&mut self, name: &str) -> &mut Self { pub fn out_exe(&mut self, name: &str) -> &mut Self {

View file

@ -156,13 +156,20 @@ impl Rustc {
self self
} }
/// Add a directory to the library search path. Equivalent to `-L`` in rustc. /// Add a directory to the library search path. Equivalent to `-L` in rustc.
pub fn library_search_path<P: AsRef<Path>>(&mut self, path: P) -> &mut Self { pub fn library_search_path<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg("-L"); self.cmd.arg("-L");
self.cmd.arg(path.as_ref()); self.cmd.arg(path.as_ref());
self self
} }
/// Override the system root. Equivalent to `--sysroot` in rustc.
pub fn sysroot<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg("--sysroot");
self.cmd.arg(path.as_ref());
self
}
/// Specify the edition year. /// Specify the edition year.
pub fn edition(&mut self, edition: &str) -> &mut Self { pub fn edition(&mut self, edition: &str) -> &mut Self {
self.cmd.arg("--edition"); self.cmd.arg("--edition");

View file

@ -25,7 +25,6 @@ run-make/compiler-rt-works-on-mingw/Makefile
run-make/compressed-debuginfo/Makefile run-make/compressed-debuginfo/Makefile
run-make/const-prop-lint/Makefile run-make/const-prop-lint/Makefile
run-make/const_fn_mir/Makefile run-make/const_fn_mir/Makefile
run-make/core-no-oom-handling/Makefile
run-make/crate-data-smoke/Makefile run-make/crate-data-smoke/Makefile
run-make/crate-hash-rustc-version/Makefile run-make/crate-hash-rustc-version/Makefile
run-make/crate-name-priority/Makefile run-make/crate-name-priority/Makefile
@ -98,7 +97,6 @@ run-make/issue-15460/Makefile
run-make/issue-18943/Makefile run-make/issue-18943/Makefile
run-make/issue-20626/Makefile run-make/issue-20626/Makefile
run-make/issue-22131/Makefile run-make/issue-22131/Makefile
run-make/issue-24445/Makefile
run-make/issue-25581/Makefile run-make/issue-25581/Makefile
run-make/issue-26006/Makefile run-make/issue-26006/Makefile
run-make/issue-26092/Makefile run-make/issue-26092/Makefile
@ -109,7 +107,6 @@ run-make/issue-35164/Makefile
run-make/issue-36710/Makefile run-make/issue-36710/Makefile
run-make/issue-37839/Makefile run-make/issue-37839/Makefile
run-make/issue-37893/Makefile run-make/issue-37893/Makefile
run-make/issue-38237/Makefile
run-make/issue-40535/Makefile run-make/issue-40535/Makefile
run-make/issue-47384/Makefile run-make/issue-47384/Makefile
run-make/issue-47551/Makefile run-make/issue-47551/Makefile

View file

@ -243,7 +243,7 @@ pub fn is_in(full_path: &Path, parent_folder_to_find: &str, folder_to_find: &str
if parent.file_name().map_or_else( if parent.file_name().map_or_else(
|| false, || false,
|f| { |f| {
f.to_string_lossy() == folder_to_find f == folder_to_find
&& parent && parent
.parent() .parent()
.and_then(|f| f.file_name()) .and_then(|f| f.file_name())

View file

@ -1,7 +0,0 @@
//@ known-bug: #124348
enum Eek {
TheConst,
UnusedByTheConst(Sum),
}
const EEK_ZERO: &[Eek] = &[];

View file

@ -1,4 +1,4 @@
// This test checks that alloc can still compile correctly // This test checks that alloc can still compile successfully
// when the unstable no_global_oom_handling feature is turned on. // when the unstable no_global_oom_handling feature is turned on.
// See https://github.com/rust-lang/rust/pull/84266 // See https://github.com/rust-lang/rust/pull/84266

View file

@ -1,4 +1,4 @@
// This test checks that alloc can still compile correctly // This test checks that alloc can still compile successfully
// when the unstable no_rc feature is turned on. // when the unstable no_rc feature is turned on.
// See https://github.com/rust-lang/rust/pull/84266 // See https://github.com/rust-lang/rust/pull/84266

View file

@ -1,4 +1,4 @@
// This test checks that alloc can still compile correctly // This test checks that alloc can still compile successfully
// when the unstable no_sync feature is turned on. // when the unstable no_sync feature is turned on.
// See https://github.com/rust-lang/rust/pull/84266 // See https://github.com/rust-lang/rust/pull/84266

View file

@ -1,6 +0,0 @@
include ../tools.mk
FAKEROOT=$(TMPDIR)/fakeroot
all:
$(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../library/core/src/lib.rs --sysroot=$(FAKEROOT) --cfg no_global_oom_handling

View file

@ -0,0 +1,16 @@
// This test checks that the core library can still compile successfully
// when the no_global_oom_handling feature is turned on.
// See https://github.com/rust-lang/rust/pull/110649
use run_make_support::{rustc, tmp_dir};
fn main() {
rustc()
.edition("2021")
.arg("-Dwarnings")
.crate_type("rlib")
.input("../../../library/core/src/lib.rs")
.sysroot(tmp_dir().join("fakeroot"))
.cfg("no_global_oom_handling")
.run();
}

View file

@ -0,0 +1,16 @@
// A very specific set of circumstances (mainly, implementing Deref, and
// having a procedural macro and a Debug derivation in external crates) caused
// an internal compiler error (ICE) when trying to use rustdoc. This test
// reproduces the exact circumstances which caused the bug and checks
// that it does not happen again.
// See https://github.com/rust-lang/rust/issues/38237
//@ ignore-cross-compile
use run_make_support::{rustc, rustdoc, tmp_dir};
fn main() {
rustc().input("foo.rs").run();
rustc().input("bar.rs").run();
rustdoc().input("baz.rs").library_search_path(tmp_dir()).output(tmp_dir()).run();
}

View file

@ -1,11 +0,0 @@
# ignore-cross-compile
include ../tools.mk
# only-linux
all:
$(RUSTC) foo.rs
$(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -ldl -o $(TMPDIR)/foo
$(call RUN,foo)
$(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -ldl -pie -fPIC -o $(TMPDIR)/foo
$(call RUN,foo)

View file

@ -1,6 +0,0 @@
# ignore-cross-compile
include ../tools.mk
all:
$(RUSTC) foo.rs; $(RUSTC) bar.rs
$(RUSTDOC) baz.rs -L $(TMPDIR) -o $(TMPDIR)

View file

@ -0,0 +1,34 @@
// It was once required to use a position-independent executable (PIE)
// in order to use the thread_local! macro, or some symbols would contain
// a NULL address. This was fixed, and this test checks a non-PIE, then a PIE
// build to see if this bug makes a resurgence.
// See https://github.com/rust-lang/rust/pull/24448
//@ ignore-cross-compile
//@ only-linux
use run_make_support::{cc, run, rustc, tmp_dir};
fn main() {
rustc().input("foo.rs").run();
cc().input("foo.c")
.arg("-lfoo")
.library_search_path(tmp_dir())
.arg("-Wl,--gc-sections")
.arg("-lpthread")
.arg("-ldl")
.out_exe("foo")
.run();
run("foo");
cc().input("foo.c")
.arg("-lfoo")
.library_search_path(tmp_dir())
.arg("-Wl,--gc-sections")
.arg("-lpthread")
.arg("-ldl")
.arg("-pie")
.arg("-fPIC")
.out_exe("foo")
.run();
run("foo");
}

View file

@ -0,0 +1,12 @@
//! ICE test #124348
//! We should not be running const eval if the layout has errors.
enum Eek {
TheConst,
UnusedByTheConst(Sum),
//~^ ERROR cannot find type `Sum` in this scope
}
const EEK_ZERO: &[Eek] = &[];
fn main() {}

View file

@ -0,0 +1,14 @@
error[E0412]: cannot find type `Sum` in this scope
--> $DIR/erroneous_type_in_const_return_value.rs:6:22
|
LL | UnusedByTheConst(Sum),
| ^^^ not found in this scope
|
help: consider importing this trait
|
LL + use std::iter::Sum;
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0412`.

View file

@ -0,0 +1,14 @@
//! ICE test #124348
//! We should not be running const eval if the layout has errors.
enum Eek {
TheConst,
UnusedByTheConst(Sum),
//~^ ERROR cannot find type `Sum` in this scope
}
const fn foo() {
let x: &'static [Eek] = &[];
}
fn main() {}

View file

@ -0,0 +1,14 @@
error[E0412]: cannot find type `Sum` in this scope
--> $DIR/erroneous_type_in_promoted.rs:6:22
|
LL | UnusedByTheConst(Sum),
| ^^^ not found in this scope
|
help: consider importing this trait
|
LL + use std::iter::Sum;
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0412`.

View file

@ -1,13 +1,6 @@
error: extern location for std does not exist: error: extern location for std does not exist:
error: `#[panic_handler]` function required, but not found
error: unwinding panics are not supported without std
|
= help: using nightly cargo, use -Zbuild-std with panic="abort" to avoid unwinding
= note: since the core library is usually precompiled with panic="unwind", rebuilding your crate with panic="abort" may not be enough to fix the problem
error: requires `sized` lang_item error: requires `sized` lang_item
error: aborting due to 4 previous errors error: aborting due to 2 previous errors

View file

@ -0,0 +1,57 @@
//! Test that coercing between function items of different functions works,
//! as long as their signatures match. The resulting value is a function pointer.
#![feature(type_alias_impl_trait)]
fn foo<T>(t: T) -> T {
t
}
fn bar<T>(t: T) -> T {
t
}
type F = impl Sized;
fn f(a: F) {
let mut x = bar::<F>;
x = foo::<()>; //~ ERROR: mismatched types
x(a);
x(());
}
type I = impl Sized;
fn i(a: I) {
let mut x = bar::<()>;
x = foo::<I>; //~ ERROR: mismatched types
x(a);
x(());
}
type J = impl Sized;
fn j(a: J) {
let x = match true {
true => bar::<J>,
false => foo::<()>,
};
x(a);
x(());
}
fn k() -> impl Sized {
fn bind<T, F: FnOnce(T) -> T>(_: T, f: F) -> F {
f
}
let x = match true {
true => {
let f = foo;
bind(k(), f)
}
false => bar::<()>,
};
todo!()
}
fn main() {}

View file

@ -0,0 +1,38 @@
error[E0308]: mismatched types
--> $DIR/fn_def_opaque_coercion_to_fn_ptr.rs:18:9
|
LL | type F = impl Sized;
| ---------- the expected opaque type
...
LL | let mut x = bar::<F>;
| -------- expected due to this value
LL | x = foo::<()>;
| ^^^^^^^^^ expected fn item, found a different fn item
|
= note: expected fn item `fn(F) -> F {bar::<F>}`
found fn item `fn(()) {foo::<()>}`
error[E0308]: mismatched types
--> $DIR/fn_def_opaque_coercion_to_fn_ptr.rs:27:9
|
LL | fn foo<T>(t: T) -> T {
| -------------------- function `foo` defined here
...
LL | type I = impl Sized;
| ---------- the found opaque type
...
LL | let mut x = bar::<()>;
| --------- expected due to this value
LL | x = foo::<I>;
| ^^^^^^^^ expected fn item, found a different fn item
|
= note: expected fn item `fn(()) {bar::<()>}`
found fn item `fn(I) -> I {foo::<I>}`
help: use parentheses to call this function
|
LL | x = foo::<I>(/* I */);
| +++++++++
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,21 @@
//@ check-pass
#![feature(trivial_bounds)]
#![allow(trivial_bounds)]
// Make sure that we still use the where-clauses from the struct when checking
// if it may implement `Copy` unconditionally.
// Fix for <https://github.com/rust-lang/rust/issues/125394>.
pub trait Foo {
type Assoc;
}
pub struct Bar;
// This needs to be public
pub struct Baz2(<Bar as Foo>::Assoc)
where
Bar: Foo;
fn main() {}

View file

@ -22,7 +22,7 @@ note: the crate import `core` is defined here
LL | extern crate core; LL | extern crate core;
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error: extern crate `core` is private, and cannot be re-exported (error E0365), consider declaring with `pub` error[E0365]: extern crate `core` is private, and cannot be re-exported, consider declaring with `pub`
--> $DIR/pub-reexport-priv-extern-crate.rs:2:9 --> $DIR/pub-reexport-priv-extern-crate.rs:2:9
| |
LL | pub use core as reexported_core; LL | pub use core as reexported_core;
@ -34,4 +34,5 @@ LL | pub use core as reexported_core;
error: aborting due to 3 previous errors error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0603`. Some errors have detailed explanations: E0365, E0603.
For more information about an error, try `rustc --explain E0365`.

View file

@ -91,7 +91,7 @@ LL | const _: () = sse2_and_fxsr();
= help: in order for the call to be safe, the context requires the following additional target features: sse2 and fxsr = help: in order for the call to be safe, the context requires the following additional target features: sse2 and fxsr
= note: the fxsr and sse2 target features being enabled in the build configuration does not remove the requirement to list them in `#[target_feature]` = note: the fxsr and sse2 target features being enabled in the build configuration does not remove the requirement to list them in `#[target_feature]`
error: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe block (error E0133) error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe block
--> $DIR/safe-calls.rs:70:5 --> $DIR/safe-calls.rs:70:5
| |
LL | sse2(); LL | sse2();

View file

@ -1,4 +1,4 @@
warning: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133) warning[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
--> $DIR/edition-2024-unsafe_op_in_unsafe_fn.rs:10:5 --> $DIR/edition-2024-unsafe_op_in_unsafe_fn.rs:10:5
| |
LL | unsf(); LL | unsf();
@ -15,3 +15,4 @@ LL | unsafe fn foo() {
warning: 1 warning emitted warning: 1 warning emitted
For more information about this error, try `rustc --explain E0133`.

View file

@ -1,4 +1,4 @@
warning: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133) warning[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
--> $DIR/edition_2024_default.rs:13:5 --> $DIR/edition_2024_default.rs:13:5
| |
LL | unsf(); LL | unsf();
@ -15,3 +15,4 @@ LL | unsafe fn foo() {
warning: 1 warning emitted warning: 1 warning emitted
For more information about this error, try `rustc --explain E0133`.

View file

@ -1,4 +1,4 @@
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133) error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
--> $DIR/in_2024_compatibility.rs:7:5 --> $DIR/in_2024_compatibility.rs:7:5
| |
LL | unsf(); LL | unsf();
@ -20,3 +20,4 @@ LL | #![deny(rust_2024_compatibility)]
error: aborting due to 1 previous error error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0133`.

View file

@ -1,4 +1,4 @@
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133) error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:9:5 --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:9:5
| |
LL | unsf(); LL | unsf();
@ -17,7 +17,7 @@ note: the lint level is defined here
LL | #![deny(unsafe_op_in_unsafe_fn)] LL | #![deny(unsafe_op_in_unsafe_fn)]
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
error: dereference of raw pointer is unsafe and requires unsafe block (error E0133) error[E0133]: dereference of raw pointer is unsafe and requires unsafe block
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:11:5 --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:11:5
| |
LL | *PTR; LL | *PTR;
@ -26,7 +26,7 @@ LL | *PTR;
= note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668> = note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
= note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
error: use of mutable static is unsafe and requires unsafe block (error E0133) error[E0133]: use of mutable static is unsafe and requires unsafe block
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:13:5 --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:13:5
| |
LL | VOID = (); LL | VOID = ();
@ -47,7 +47,7 @@ note: the lint level is defined here
LL | #![deny(unused_unsafe)] LL | #![deny(unused_unsafe)]
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133) error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:24:5 --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:24:5
| |
LL | unsf(); LL | unsf();
@ -67,7 +67,7 @@ LL | #[deny(warnings)]
| ^^^^^^^^ | ^^^^^^^^
= note: `#[deny(unsafe_op_in_unsafe_fn)]` implied by `#[deny(warnings)]` = note: `#[deny(unsafe_op_in_unsafe_fn)]` implied by `#[deny(warnings)]`
error: dereference of raw pointer is unsafe and requires unsafe block (error E0133) error[E0133]: dereference of raw pointer is unsafe and requires unsafe block
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:26:5 --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:26:5
| |
LL | *PTR; LL | *PTR;
@ -76,7 +76,7 @@ LL | *PTR;
= note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668> = note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
= note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
error: use of mutable static is unsafe and requires unsafe block (error E0133) error[E0133]: use of mutable static is unsafe and requires unsafe block
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:28:5 --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:28:5
| |
LL | VOID = (); LL | VOID = ();

View file

@ -1,4 +1,4 @@
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133) error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
--> $DIR/wrapping-unsafe-block-sugg.rs:13:5 --> $DIR/wrapping-unsafe-block-sugg.rs:13:5
| |
LL | unsf(); LL | unsf();
@ -17,7 +17,7 @@ note: the lint level is defined here
LL | #![deny(unsafe_op_in_unsafe_fn)] LL | #![deny(unsafe_op_in_unsafe_fn)]
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133) error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
--> $DIR/wrapping-unsafe-block-sugg.rs:17:5 --> $DIR/wrapping-unsafe-block-sugg.rs:17:5
| |
LL | unsf(); LL | unsf();
@ -26,7 +26,7 @@ LL | unsf();
= note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668> = note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
= note: consult the function's documentation for information on how to avoid undefined behavior = note: consult the function's documentation for information on how to avoid undefined behavior
error: dereference of raw pointer is unsafe and requires unsafe block (error E0133) error[E0133]: dereference of raw pointer is unsafe and requires unsafe block
--> $DIR/wrapping-unsafe-block-sugg.rs:25:13 --> $DIR/wrapping-unsafe-block-sugg.rs:25:13
| |
LL | let y = *x; LL | let y = *x;
@ -40,7 +40,7 @@ note: an unsafe function restricts its caller, but its body is safe by default
LL | pub unsafe fn bar(x: *const i32) -> i32 { LL | pub unsafe fn bar(x: *const i32) -> i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: dereference of raw pointer is unsafe and requires unsafe block (error E0133) error[E0133]: dereference of raw pointer is unsafe and requires unsafe block
--> $DIR/wrapping-unsafe-block-sugg.rs:29:9 --> $DIR/wrapping-unsafe-block-sugg.rs:29:9
| |
LL | y + *x LL | y + *x
@ -49,7 +49,7 @@ LL | y + *x
= note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668> = note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
= note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
error: use of mutable static is unsafe and requires unsafe block (error E0133) error[E0133]: use of mutable static is unsafe and requires unsafe block
--> $DIR/wrapping-unsafe-block-sugg.rs:38:13 --> $DIR/wrapping-unsafe-block-sugg.rs:38:13
| |
LL | let y = BAZ; LL | let y = BAZ;
@ -63,7 +63,7 @@ note: an unsafe function restricts its caller, but its body is safe by default
LL | pub unsafe fn baz() -> i32 { LL | pub unsafe fn baz() -> i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: use of mutable static is unsafe and requires unsafe block (error E0133) error[E0133]: use of mutable static is unsafe and requires unsafe block
--> $DIR/wrapping-unsafe-block-sugg.rs:42:9 --> $DIR/wrapping-unsafe-block-sugg.rs:42:9
| |
LL | y + BAZ LL | y + BAZ
@ -72,7 +72,7 @@ LL | y + BAZ
= note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668> = note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133) error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
--> $DIR/wrapping-unsafe-block-sugg.rs:48:36 --> $DIR/wrapping-unsafe-block-sugg.rs:48:36
| |
LL | macro_rules! unsafe_macro { () => (unsf()) } LL | macro_rules! unsafe_macro { () => (unsf()) }
@ -90,7 +90,7 @@ LL | pub unsafe fn unsafe_in_macro() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `unsafe_macro` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `unsafe_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133) error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
--> $DIR/wrapping-unsafe-block-sugg.rs:48:36 --> $DIR/wrapping-unsafe-block-sugg.rs:48:36
| |
LL | macro_rules! unsafe_macro { () => (unsf()) } LL | macro_rules! unsafe_macro { () => (unsf()) }
@ -105,3 +105,4 @@ LL | unsafe_macro!();
error: aborting due to 8 previous errors error: aborting due to 8 previous errors
For more information about this error, try `rustc --explain E0133`.