Skip to content

Commit 4c57de4

Browse files
committed
Auto merge of rust-lang#120448 - matthiaskrgr:rollup-j30dzmw, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#116677 (References refer to allocated objects) - rust-lang#118533 (Suppress unhelpful diagnostics for unresolved top level attributes) - rust-lang#119991 (Reject infinitely-sized reads from io::Repeat) - rust-lang#120232 (Add support for custom JSON targets when using build-std.) - rust-lang#120358 (Bump Fuchsia, build tests, and use 8 core bots) - rust-lang#120424 (raw pointer metadata API: data address -> data pointer) - rust-lang#120434 (Revert outdated version of "Add the wasm32-wasi-preview2 target") - rust-lang#120443 (Fixes footnote handling in rustdoc) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6351247 + 1ff326d commit 4c57de4

File tree

66 files changed

+357
-601
lines changed

Some content is hidden

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

66 files changed

+357
-601
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ jobs:
291291
- name: x86_64-gnu-integration
292292
env:
293293
CI_ONLY_WHEN_CHANNEL: nightly
294-
os: ubuntu-20.04-16core-64gb
294+
os: ubuntu-20.04-8core-32gb
295295
- name: x86_64-gnu-debug
296296
os: ubuntu-20.04-8core-32gb
297297
env: {}

Cargo.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -3004,11 +3004,11 @@ dependencies = [
30043004

30053005
[[package]]
30063006
name = "pulldown-cmark"
3007-
version = "0.9.3"
3007+
version = "0.9.5"
30083008
source = "registry+https://github.com/rust-lang/crates.io-index"
3009-
checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998"
3009+
checksum = "80eb9f69aec5cd8828765a75f739383fbbe3e8b9d84370bde1cc90487700794a"
30103010
dependencies = [
3011-
"bitflags 1.3.2",
3011+
"bitflags 2.4.1",
30123012
"memchr",
30133013
"unicase",
30143014
]

compiler/rustc_errors/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ pub enum StashKey {
509509
MaybeForgetReturn,
510510
/// Query cycle detected, stashing in favor of a better error.
511511
Cycle,
512+
UndeterminedMacroResolution,
512513
}
513514

514515
fn default_track_diagnostic(diag: Diagnostic, f: &mut dyn FnMut(Diagnostic)) {

compiler/rustc_passes/src/check_attr.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
//! item.
66
77
use crate::{errors, fluent_generated as fluent};
8-
use rustc_ast::{ast, AttrStyle, Attribute, LitKind, MetaItemKind, MetaItemLit, NestedMetaItem};
8+
use rustc_ast::{ast, AttrKind, AttrStyle, Attribute, LitKind};
9+
use rustc_ast::{MetaItemKind, MetaItemLit, NestedMetaItem};
910
use rustc_data_structures::fx::FxHashMap;
11+
use rustc_errors::StashKey;
1012
use rustc_errors::{Applicability, DiagCtxt, IntoDiagnosticArg, MultiSpan};
1113
use rustc_feature::{AttributeDuplicates, AttributeType, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP};
1214
use rustc_hir as hir;
@@ -2530,6 +2532,14 @@ fn check_invalid_crate_level_attr(tcx: TyCtxt<'_>, attrs: &[Attribute]) {
25302532
if attr.style == AttrStyle::Inner {
25312533
for attr_to_check in ATTRS_TO_CHECK {
25322534
if attr.has_name(*attr_to_check) {
2535+
if let AttrKind::Normal(ref p) = attr.kind
2536+
&& let Some(diag) = tcx.dcx().steal_diagnostic(
2537+
p.item.path.span,
2538+
StashKey::UndeterminedMacroResolution,
2539+
)
2540+
{
2541+
diag.cancel();
2542+
}
25332543
let item = tcx
25342544
.hir()
25352545
.items()

compiler/rustc_resolve/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
[dependencies]
77
# tidy-alphabetical-start
88
bitflags = "2.4.1"
9-
pulldown-cmark = { version = "0.9.3", default-features = false }
9+
pulldown-cmark = { version = "0.9.5", default-features = false }
1010
rustc_arena = { path = "../rustc_arena" }
1111
rustc_ast = { path = "../rustc_ast" }
1212
rustc_ast_pretty = { path = "../rustc_ast_pretty" }

compiler/rustc_resolve/src/macros.rs

+15-16
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
//! A bunch of methods and structures more or less related to resolving macros and
22
//! interface provided by `Resolver` to macro expander.
33
4-
use crate::errors::{
5-
self, AddAsNonDerive, CannotDetermineMacroResolution, CannotFindIdentInThisScope,
6-
MacroExpectedFound, RemoveSurroundingDerive,
7-
};
4+
use crate::errors::CannotDetermineMacroResolution;
5+
use crate::errors::{self, AddAsNonDerive, CannotFindIdentInThisScope};
6+
use crate::errors::{MacroExpectedFound, RemoveSurroundingDerive};
87
use crate::Namespace::*;
98
use crate::{BuiltinMacroState, Determinacy, MacroData};
109
use crate::{DeriveData, Finalize, ParentScope, ResolutionError, Resolver, ScopeSet};
@@ -15,6 +14,7 @@ use rustc_ast_pretty::pprust;
1514
use rustc_attr::StabilityLevel;
1615
use rustc_data_structures::intern::Interned;
1716
use rustc_data_structures::sync::Lrc;
17+
use rustc_errors::StashKey;
1818
use rustc_errors::{struct_span_code_err, Applicability};
1919
use rustc_expand::base::{Annotatable, DeriveResolutions, Indeterminate, ResolverExpand};
2020
use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
@@ -25,9 +25,8 @@ use rustc_hir::def_id::{CrateNum, DefId, LocalDefId};
2525
use rustc_middle::middle::stability;
2626
use rustc_middle::ty::RegisteredTools;
2727
use rustc_middle::ty::{TyCtxt, Visibility};
28-
use rustc_session::lint::builtin::{
29-
LEGACY_DERIVE_HELPERS, SOFT_UNSTABLE, UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
30-
};
28+
use rustc_session::lint::builtin::UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES;
29+
use rustc_session::lint::builtin::{LEGACY_DERIVE_HELPERS, SOFT_UNSTABLE};
3130
use rustc_session::lint::builtin::{UNUSED_MACROS, UNUSED_MACRO_RULES};
3231
use rustc_session::lint::BuiltinLintDiagnostics;
3332
use rustc_session::parse::feature_err;
@@ -703,21 +702,21 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
703702
// situations should be reported as errors, so this is a bug.
704703
this.dcx().span_delayed_bug(span, "inconsistent resolution for a macro");
705704
}
706-
} else {
705+
} else if this.tcx.dcx().has_errors().is_none() && this.privacy_errors.is_empty() {
707706
// It's possible that the macro was unresolved (indeterminate) and silently
708707
// expanded into a dummy fragment for recovery during expansion.
709708
// Now, post-expansion, the resolution may succeed, but we can't change the
710709
// past and need to report an error.
711710
// However, non-speculative `resolve_path` can successfully return private items
712711
// even if speculative `resolve_path` returned nothing previously, so we skip this
713-
// less informative error if the privacy error is reported elsewhere.
714-
if this.privacy_errors.is_empty() {
715-
this.dcx().emit_err(CannotDetermineMacroResolution {
716-
span,
717-
kind: kind.descr(),
718-
path: Segment::names_to_string(path),
719-
});
720-
}
712+
// less informative error if no other error is reported elsewhere.
713+
714+
let err = this.dcx().create_err(CannotDetermineMacroResolution {
715+
span,
716+
kind: kind.descr(),
717+
path: Segment::names_to_string(path),
718+
});
719+
err.stash(span, StashKey::UndeterminedMacroResolution);
721720
}
722721
};
723722

compiler/rustc_span/src/symbol.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1799,7 +1799,6 @@ symbols! {
17991799
warn,
18001800
wasm_abi,
18011801
wasm_import_module,
1802-
wasm_preview2,
18031802
wasm_target_feature,
18041803
while_let,
18051804
windows,

compiler/rustc_target/src/spec/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,6 @@ supported_targets! {
15741574
("wasm32-unknown-emscripten", wasm32_unknown_emscripten),
15751575
("wasm32-unknown-unknown", wasm32_unknown_unknown),
15761576
("wasm32-wasi", wasm32_wasi),
1577-
("wasm32-wasi-preview2", wasm32_wasi_preview2),
15781577
("wasm32-wasi-preview1-threads", wasm32_wasi_preview1_threads),
15791578
("wasm64-unknown-unknown", wasm64_unknown_unknown),
15801579

compiler/rustc_target/src/spec/targets/wasm32_wasi_preview1_threads.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,11 @@
7272
//! best we can with this target. Don't start relying on too much here unless
7373
//! you know what you're getting in to!
7474
75-
use crate::spec::{base, crt_objects, cvs, Cc, LinkSelfContainedDefault, LinkerFlavor, Target};
75+
use crate::spec::{base, crt_objects, Cc, LinkSelfContainedDefault, LinkerFlavor, Target};
7676

7777
pub fn target() -> Target {
7878
let mut options = base::wasm::options();
7979

80-
options.families = cvs!["wasm", "wasi"];
8180
options.os = "wasi".into();
8281

8382
options.add_pre_link_args(

compiler/rustc_target/src/spec/targets/wasm32_wasi_preview2.rs

-64
This file was deleted.

library/core/src/primitive_docs.rs

+24
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,30 @@ mod prim_usize {}
13841384
/// work on references as well as they do on owned values! The implementations described here are
13851385
/// meant for generic contexts, where the final type `T` is a type parameter or otherwise not
13861386
/// locally known.
1387+
///
1388+
/// # Safety
1389+
///
1390+
/// For all types, `T: ?Sized`, and for all `t: &T` or `t: &mut T`, when such values cross an API
1391+
/// boundary, the following invariants must generally be upheld:
1392+
///
1393+
/// * `t` is aligned to `align_of_val(t)`
1394+
/// * `t` is dereferenceable for `size_of_val(t)` many bytes
1395+
///
1396+
/// If `t` points at address `a`, being "dereferenceable" for N bytes means that the memory range
1397+
/// `[a, a + N)` is all contained within a single [allocated object].
1398+
///
1399+
/// For instance, this means that unsafe code in a safe function may assume these invariants are
1400+
/// ensured of arguments passed by the caller, and it may assume that these invariants are ensured
1401+
/// of return values from any safe functions it calls. In most cases, the inverse is also true:
1402+
/// unsafe code must not violate these invariants when passing arguments to safe functions or
1403+
/// returning values from safe functions; such violations may result in undefined behavior. Where
1404+
/// exceptions to this latter requirement exist, they will be called out explicitly in documentation.
1405+
///
1406+
/// It is not decided yet whether unsafe code may violate these invariants temporarily on internal
1407+
/// data. As a consequence, unsafe code which violates these invariants temporarily on internal data
1408+
/// may become unsound in future versions of Rust depending on how this question is decided.
1409+
///
1410+
/// [allocated object]: ptr#allocated-object
13871411
#[stable(feature = "rust1", since = "1.0.0")]
13881412
mod prim_ref {}
13891413

library/core/src/ptr/const_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl<T: ?Sized> *const T {
285285
self.with_addr(f(self.addr()))
286286
}
287287

288-
/// Decompose a (possibly wide) pointer into its address and metadata components.
288+
/// Decompose a (possibly wide) pointer into its data pointer and metadata components.
289289
///
290290
/// The pointer can be later reconstructed with [`from_raw_parts`].
291291
#[unstable(feature = "ptr_metadata", issue = "81513")]

library/core/src/ptr/metadata.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ use crate::hash::{Hash, Hasher};
3939
///
4040
/// # Usage
4141
///
42-
/// Raw pointers can be decomposed into the data address and metadata components
42+
/// Raw pointers can be decomposed into the data pointer and metadata components
4343
/// with their [`to_raw_parts`] method.
4444
///
4545
/// Alternatively, metadata alone can be extracted with the [`metadata`] function.
4646
/// A reference can be passed to [`metadata`] and implicitly coerced.
4747
///
48-
/// A (possibly-wide) pointer can be put back together from its address and metadata
48+
/// A (possibly-wide) pointer can be put back together from its data pointer and metadata
4949
/// with [`from_raw_parts`] or [`from_raw_parts_mut`].
5050
///
5151
/// [`to_raw_parts`]: *const::to_raw_parts
@@ -98,7 +98,7 @@ pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata {
9898
unsafe { PtrRepr { const_ptr: ptr }.components.metadata }
9999
}
100100

101-
/// Forms a (possibly-wide) raw pointer from a data address and metadata.
101+
/// Forms a (possibly-wide) raw pointer from a data pointer and metadata.
102102
///
103103
/// This function is safe but the returned pointer is not necessarily safe to dereference.
104104
/// For slices, see the documentation of [`slice::from_raw_parts`] for safety requirements.
@@ -109,13 +109,13 @@ pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata {
109109
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
110110
#[inline]
111111
pub const fn from_raw_parts<T: ?Sized>(
112-
data_address: *const (),
112+
data_pointer: *const (),
113113
metadata: <T as Pointee>::Metadata,
114114
) -> *const T {
115115
// SAFETY: Accessing the value from the `PtrRepr` union is safe since *const T
116116
// and PtrComponents<T> have the same memory layouts. Only std can make this
117117
// guarantee.
118-
unsafe { PtrRepr { components: PtrComponents { data_address, metadata } }.const_ptr }
118+
unsafe { PtrRepr { components: PtrComponents { data_pointer, metadata } }.const_ptr }
119119
}
120120

121121
/// Performs the same functionality as [`from_raw_parts`], except that a
@@ -126,13 +126,13 @@ pub const fn from_raw_parts<T: ?Sized>(
126126
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
127127
#[inline]
128128
pub const fn from_raw_parts_mut<T: ?Sized>(
129-
data_address: *mut (),
129+
data_pointer: *mut (),
130130
metadata: <T as Pointee>::Metadata,
131131
) -> *mut T {
132132
// SAFETY: Accessing the value from the `PtrRepr` union is safe since *const T
133133
// and PtrComponents<T> have the same memory layouts. Only std can make this
134134
// guarantee.
135-
unsafe { PtrRepr { components: PtrComponents { data_address, metadata } }.mut_ptr }
135+
unsafe { PtrRepr { components: PtrComponents { data_pointer, metadata } }.mut_ptr }
136136
}
137137

138138
#[repr(C)]
@@ -144,7 +144,7 @@ union PtrRepr<T: ?Sized> {
144144

145145
#[repr(C)]
146146
struct PtrComponents<T: ?Sized> {
147-
data_address: *const (),
147+
data_pointer: *const (),
148148
metadata: <T as Pointee>::Metadata,
149149
}
150150

library/core/src/ptr/mut_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ impl<T: ?Sized> *mut T {
292292
self.with_addr(f(self.addr()))
293293
}
294294

295-
/// Decompose a (possibly wide) pointer into its address and metadata components.
295+
/// Decompose a (possibly wide) pointer into its data pointer and metadata components.
296296
///
297297
/// The pointer can be later reconstructed with [`from_raw_parts_mut`].
298298
#[unstable(feature = "ptr_metadata", issue = "81513")]

library/core/src/ptr/non_null.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -259,16 +259,16 @@ impl<T: ?Sized> NonNull<T> {
259259
#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")]
260260
#[inline]
261261
pub const fn from_raw_parts(
262-
data_address: NonNull<()>,
262+
data_pointer: NonNull<()>,
263263
metadata: <T as super::Pointee>::Metadata,
264264
) -> NonNull<T> {
265-
// SAFETY: The result of `ptr::from::raw_parts_mut` is non-null because `data_address` is.
265+
// SAFETY: The result of `ptr::from::raw_parts_mut` is non-null because `data_pointer` is.
266266
unsafe {
267-
NonNull::new_unchecked(super::from_raw_parts_mut(data_address.as_ptr(), metadata))
267+
NonNull::new_unchecked(super::from_raw_parts_mut(data_pointer.as_ptr(), metadata))
268268
}
269269
}
270270

271-
/// Decompose a (possibly wide) pointer into its address and metadata components.
271+
/// Decompose a (possibly wide) pointer into its data pointer and metadata components.
272272
///
273273
/// The pointer can be later reconstructed with [`NonNull::from_raw_parts`].
274274
#[unstable(feature = "ptr_metadata", issue = "81513")]

library/profiler_builtins/build.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ fn main() {
1212
return;
1313
}
1414

15-
let target = env::var("TARGET").expect("TARGET was not set");
15+
let target_os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS was not set");
16+
let target_env = env::var("CARGO_CFG_TARGET_ENV").expect("CARGO_CFG_TARGET_ENV was not set");
1617
let cfg = &mut cc::Build::new();
1718

1819
// FIXME: `rerun-if-changed` directives are not currently emitted and the build script
@@ -40,7 +41,7 @@ fn main() {
4041
"InstrProfilingBiasVar.c",
4142
];
4243

43-
if target.contains("msvc") {
44+
if target_env == "msvc" {
4445
// Don't pull in extra libraries on MSVC
4546
cfg.flag("/Zl");
4647
profile_sources.push("WindowsMMap.c");
@@ -55,7 +56,7 @@ fn main() {
5556
cfg.flag("-fno-builtin");
5657
cfg.flag("-fomit-frame-pointer");
5758
cfg.define("VISIBILITY_HIDDEN", None);
58-
if !target.contains("windows") {
59+
if target_os != "windows" {
5960
cfg.flag("-fvisibility=hidden");
6061
cfg.define("COMPILER_RT_HAS_UNAME", Some("1"));
6162
} else {

0 commit comments

Comments
 (0)