Skip to content

Commit 077cedc

Browse files
committed
Auto merge of rust-lang#140040 - ChrisDenton:rollup-56bzfuq, r=ChrisDenton
Rollup of 8 pull requests Successful merges: - rust-lang#137454 (not lint break with label and unsafe block) - rust-lang#139297 (Deduplicate & clean up Nix shell) - rust-lang#139535 (Implement `Default` for raw pointers) - rust-lang#139919 (Make rustdoc JSON Span column 1-based, just like line numbers) - rust-lang#139922 (fix incorrect type in cstr `to_string_lossy()` docs) - rust-lang#140007 (Disable has_thread_local on i686-win7-windows-msvc) - rust-lang#140016 (std: Use fstatat() on illumos) - rust-lang#140025 (Re-remove `AdtFlags::IS_ANONYMOUS`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a7c39b6 + 9ebc73e commit 077cedc

File tree

16 files changed

+187
-69
lines changed

16 files changed

+187
-69
lines changed

compiler/rustc_middle/src/ty/adt.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ bitflags::bitflags! {
5555
const IS_UNSAFE_CELL = 1 << 9;
5656
/// Indicates whether the type is `UnsafePinned`.
5757
const IS_UNSAFE_PINNED = 1 << 10;
58-
/// Indicates whether the type is anonymous.
59-
const IS_ANONYMOUS = 1 << 11;
6058
}
6159
}
6260
rustc_data_structures::external_bitflags_debug! { AdtFlags }

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,13 +1884,15 @@ impl<'a> Parser<'a> {
18841884
let mut expr = self.parse_expr_opt()?;
18851885
if let Some(expr) = &mut expr {
18861886
if label.is_some()
1887-
&& matches!(
1888-
expr.kind,
1887+
&& match &expr.kind {
18891888
ExprKind::While(_, _, None)
1890-
| ExprKind::ForLoop { label: None, .. }
1891-
| ExprKind::Loop(_, None, _)
1892-
| ExprKind::Block(_, None)
1893-
)
1889+
| ExprKind::ForLoop { label: None, .. }
1890+
| ExprKind::Loop(_, None, _) => true,
1891+
ExprKind::Block(block, None) => {
1892+
matches!(block.rules, BlockCheckMode::Default)
1893+
}
1894+
_ => false,
1895+
}
18941896
{
18951897
self.psess.buffer_lint(
18961898
BREAK_WITH_LABEL_AND_LOOP,

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ pub(crate) fn target() -> Target {
77
base.cpu = "pentium4".into();
88
base.max_atomic_width = Some(64);
99
base.supported_sanitizers = SanitizerSet::ADDRESS;
10+
// On Windows 7 32-bit, the alignment characteristic of the TLS Directory
11+
// don't appear to be respected by the PE Loader, leading to crashes. As
12+
// a result, let's disable has_thread_local to make sure TLS goes through
13+
// the emulation layer.
14+
// See https://github.com/rust-lang/rust/issues/138903
15+
base.has_thread_local = false;
1016

1117
base.add_pre_link_args(
1218
LinkerFlavor::Msvc(Lld::No),

library/alloc/src/ffi/c_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ impl CStr {
11161116
/// with the corresponding <code>&[str]</code> slice. Otherwise, it will
11171117
/// replace any invalid UTF-8 sequences with
11181118
/// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD] and return a
1119-
/// <code>[Cow]::[Owned]\(&[str])</code> with the result.
1119+
/// <code>[Cow]::[Owned]\([String])</code> with the result.
11201120
///
11211121
/// [str]: prim@str "str"
11221122
/// [Borrowed]: Cow::Borrowed

library/core/src/ptr/const_ptr.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,3 +1739,11 @@ impl<T: ?Sized> PartialOrd for *const T {
17391739
*self >= *other
17401740
}
17411741
}
1742+
1743+
#[stable(feature = "raw_ptr_default", since = "CURRENT_RUSTC_VERSION")]
1744+
impl<T: ?Sized + Thin> Default for *const T {
1745+
/// Returns the default value of [`null()`][crate::ptr::null].
1746+
fn default() -> Self {
1747+
crate::ptr::null()
1748+
}
1749+
}

library/core/src/ptr/mut_ptr.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,3 +2156,11 @@ impl<T: ?Sized> PartialOrd for *mut T {
21562156
*self >= *other
21572157
}
21582158
}
2159+
2160+
#[stable(feature = "raw_ptr_default", since = "CURRENT_RUSTC_VERSION")]
2161+
impl<T: ?Sized + Thin> Default for *mut T {
2162+
/// Returns the default value of [`null_mut()`][crate::ptr::null_mut].
2163+
fn default() -> Self {
2164+
crate::ptr::null_mut()
2165+
}
2166+
}

library/coretests/tests/ptr.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,3 +1020,20 @@ fn test_ptr_swap_nonoverlapping_is_untyped() {
10201020
ptr_swap_nonoverlapping_is_untyped_inner();
10211021
const { ptr_swap_nonoverlapping_is_untyped_inner() };
10221022
}
1023+
1024+
#[test]
1025+
fn test_ptr_default() {
1026+
#[derive(Default)]
1027+
struct PtrDefaultTest {
1028+
ptr: *const u64,
1029+
}
1030+
let default = PtrDefaultTest::default();
1031+
assert!(default.ptr.is_null());
1032+
1033+
#[derive(Default)]
1034+
struct PtrMutDefaultTest {
1035+
ptr: *mut u64,
1036+
}
1037+
let default = PtrMutDefaultTest::default();
1038+
assert!(default.ptr.is_null());
1039+
}

library/std/src/sys/fs/unix.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ use libc::c_char;
1212
all(target_os = "linux", not(target_env = "musl")),
1313
target_os = "android",
1414
target_os = "fuchsia",
15-
target_os = "hurd"
15+
target_os = "hurd",
16+
target_os = "illumos",
1617
))]
1718
use libc::dirfd;
18-
#[cfg(target_os = "fuchsia")]
19+
#[cfg(any(target_os = "fuchsia", target_os = "illumos"))]
1920
use libc::fstatat as fstatat64;
2021
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "hurd"))]
2122
use libc::fstatat64;
@@ -892,7 +893,8 @@ impl DirEntry {
892893
all(target_os = "linux", not(target_env = "musl")),
893894
target_os = "android",
894895
target_os = "fuchsia",
895-
target_os = "hurd"
896+
target_os = "hurd",
897+
target_os = "illumos",
896898
),
897899
not(miri) // no dirfd on Miri
898900
))]
@@ -922,6 +924,7 @@ impl DirEntry {
922924
target_os = "android",
923925
target_os = "fuchsia",
924926
target_os = "hurd",
927+
target_os = "illumos",
925928
)),
926929
miri
927930
))]

src/librustdoc/json/conversions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ impl JsonRenderer<'_> {
8484
let lo = span.lo(self.sess());
8585
Some(Span {
8686
filename: local_path,
87-
begin: (lo.line, lo.col.to_usize()),
88-
end: (hi.line, hi.col.to_usize()),
87+
begin: (lo.line, lo.col.to_usize() + 1),
88+
end: (hi.line, hi.col.to_usize() + 1),
8989
})
9090
} else {
9191
None

src/rustdoc-json-types/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub type FxHashMap<K, V> = HashMap<K, V>; // re-export for use in src/librustdoc
3030
/// This integer is incremented with every breaking change to the API,
3131
/// and is returned along with the JSON blob as [`Crate::format_version`].
3232
/// Consuming code should assert that this value matches the format version(s) that it supports.
33-
pub const FORMAT_VERSION: u32 = 44;
33+
pub const FORMAT_VERSION: u32 = 45;
3434

3535
/// The root of the emitted JSON blob.
3636
///
@@ -205,9 +205,9 @@ pub struct Item {
205205
pub struct Span {
206206
/// The path to the source file for this span relative to the path `rustdoc` was invoked with.
207207
pub filename: PathBuf,
208-
/// Zero indexed Line and Column of the first character of the `Span`
208+
/// One indexed Line and Column of the first character of the `Span`.
209209
pub begin: (usize, usize),
210-
/// Zero indexed Line and Column of the last character of the `Span`
210+
/// One indexed Line and Column of the last character of the `Span`.
211211
pub end: (usize, usize),
212212
}
213213

0 commit comments

Comments
 (0)