Skip to content

Commit 704934d

Browse files
committed
Auto merge of #86006 - JohnTitor:rollup-97iuoi3, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #83653 (Remove unused code from `rustc_data_structures::sync`) - #84466 (rustdoc: Remove `PrimitiveType::{to_url_str, as_str}`) - #84880 (Make match in `register_res` easier to read) - #84942 (rustdoc: link to stable/beta docs consistently in documentation) - #85853 (Warn against boxed DST in `improper_ctypes_definitions` lint) - #85939 (Fix suggestion for removing &mut from &mut macro!().) - #85966 (wasm: Make simd types passed via indirection again) - #85979 (don't suggest unsized indirection in where-clauses) - #85983 (Update to semver 1.0.3) - #85988 (Note that `ninja = false` goes under `[llvm]`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents c79419a + 062e789 commit 704934d

Some content is hidden

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

59 files changed

+360
-283
lines changed

Cargo.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ dependencies = [
294294
"rand 0.8.3",
295295
"rustc-workspace-hack",
296296
"rustfix",
297-
"semver 1.0.1",
297+
"semver 1.0.3",
298298
"serde",
299299
"serde_ignored",
300300
"serde_json",
@@ -4692,9 +4692,9 @@ dependencies = [
46924692

46934693
[[package]]
46944694
name = "semver"
4695-
version = "1.0.1"
4695+
version = "1.0.3"
46964696
source = "registry+https://github.com/rust-lang/crates.io-index"
4697-
checksum = "d023dabf011d5dcb5ac64e3685d97d3b0ef412911077a2851455c6098524a723"
4697+
checksum = "5f3aac57ee7f3272d8395c6e4f502f434f0e289fcd62876f70daa008c20dcabe"
46984698
dependencies = [
46994699
"serde",
47004700
]

compiler/rustc_data_structures/src/sync.rs

+2-60
Original file line numberDiff line numberDiff line change
@@ -43,49 +43,9 @@ cfg_if! {
4343
use std::ops::Add;
4444
use std::panic::{resume_unwind, catch_unwind, AssertUnwindSafe};
4545

46-
/// This is a single threaded variant of AtomicCell provided by crossbeam.
47-
/// Unlike `Atomic` this is intended for all `Copy` types,
48-
/// but it lacks the explicit ordering arguments.
49-
#[derive(Debug)]
50-
pub struct AtomicCell<T: Copy>(Cell<T>);
51-
52-
impl<T: Copy> AtomicCell<T> {
53-
#[inline]
54-
pub fn new(v: T) -> Self {
55-
AtomicCell(Cell::new(v))
56-
}
57-
58-
#[inline]
59-
pub fn get_mut(&mut self) -> &mut T {
60-
self.0.get_mut()
61-
}
62-
}
63-
64-
impl<T: Copy> AtomicCell<T> {
65-
#[inline]
66-
pub fn into_inner(self) -> T {
67-
self.0.into_inner()
68-
}
69-
70-
#[inline]
71-
pub fn load(&self) -> T {
72-
self.0.get()
73-
}
74-
75-
#[inline]
76-
pub fn store(&self, val: T) {
77-
self.0.set(val)
78-
}
79-
80-
#[inline]
81-
pub fn swap(&self, val: T) -> T {
82-
self.0.replace(val)
83-
}
84-
}
85-
8646
/// This is a single threaded variant of `AtomicU64`, `AtomicUsize`, etc.
87-
/// It differs from `AtomicCell` in that it has explicit ordering arguments
88-
/// and is only intended for use with the native atomic types.
47+
/// It has explicit ordering arguments and is only intended for use with
48+
/// the native atomic types.
8949
/// You should use this type through the `AtomicU64`, `AtomicUsize`, etc, type aliases
9050
/// as it's not intended to be used separately.
9151
#[derive(Debug)]
@@ -159,22 +119,6 @@ cfg_if! {
159119
(oper_a(), oper_b())
160120
}
161121

162-
pub struct SerialScope;
163-
164-
impl SerialScope {
165-
pub fn spawn<F>(&self, f: F)
166-
where F: FnOnce(&SerialScope)
167-
{
168-
f(self)
169-
}
170-
}
171-
172-
pub fn scope<F, R>(f: F) -> R
173-
where F: FnOnce(&SerialScope) -> R
174-
{
175-
f(&SerialScope)
176-
}
177-
178122
#[macro_export]
179123
macro_rules! parallel {
180124
($($blocks:tt),*) => {
@@ -318,8 +262,6 @@ cfg_if! {
318262

319263
pub use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU32, AtomicU64};
320264

321-
pub use crossbeam_utils::atomic::AtomicCell;
322-
323265
pub use std::sync::Arc as Lrc;
324266
pub use std::sync::Weak as Weak;
325267

compiler/rustc_lint/src/types.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -909,11 +909,18 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
909909
}
910910

911911
match *ty.kind() {
912-
ty::Adt(def, _) if def.is_box() && matches!(self.mode, CItemKind::Definition) => {
913-
FfiSafe
914-
}
915-
916912
ty::Adt(def, substs) => {
913+
if def.is_box() && matches!(self.mode, CItemKind::Definition) {
914+
if ty.boxed_ty().is_sized(tcx.at(DUMMY_SP), self.cx.param_env) {
915+
return FfiSafe;
916+
} else {
917+
return FfiUnsafe {
918+
ty,
919+
reason: format!("box cannot be represented as a single pointer"),
920+
help: None,
921+
};
922+
}
923+
}
917924
if def.is_phantom_data() {
918925
return FfiPhantom(ty);
919926
}

compiler/rustc_target/src/spec/wasm_base.rs

-6
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,6 @@ pub fn options() -> TargetOptions {
103103
linker: Some("rust-lld".to_owned()),
104104
lld_flavor: LldFlavor::Wasm,
105105

106-
// No need for indirection here, simd types can always be passed by
107-
// value as the whole module either has simd or not, which is different
108-
// from x86 (for example) where programs can have functions that don't
109-
// enable simd features.
110-
simd_types_indirect: false,
111-
112106
pre_link_args,
113107

114108
crt_objects_fallback: Some(CrtObjectsFallback::Wasm),

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1878,6 +1878,10 @@ impl<'v> Visitor<'v> for FindTypeParam {
18781878
hir::intravisit::NestedVisitorMap::None
18791879
}
18801880

1881+
fn visit_where_predicate(&mut self, _: &'v hir::WherePredicate<'v>) {
1882+
// Skip where-clauses, to avoid suggesting indirection for type parameters found there.
1883+
}
1884+
18811885
fn visit_ty(&mut self, ty: &hir::Ty<'_>) {
18821886
// We collect the spans of all uses of the "bare" type param, like in `field: T` or
18831887
// `field: (T, T)` where we could make `T: ?Sized` while skipping cases that are known to be

compiler/rustc_typeck/src/check/demand.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use rustc_span::Span;
1717
use super::method::probe;
1818

1919
use std::fmt;
20+
use std::iter;
2021

2122
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2223
pub fn emit_coerce_suggestions(
@@ -573,12 +574,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
573574
// We have `&T`, check if what was expected was `T`. If so,
574575
// we may want to suggest removing a `&`.
575576
if sm.is_imported(expr.span) {
576-
if let Ok(src) = sm.span_to_snippet(sp) {
577-
if let Some(src) = src.strip_prefix('&') {
577+
// Go through the spans from which this span was expanded,
578+
// and find the one that's pointing inside `sp`.
579+
//
580+
// E.g. for `&format!("")`, where we want the span to the
581+
// `format!()` invocation instead of its expansion.
582+
if let Some(call_span) =
583+
iter::successors(Some(expr.span), |s| s.parent()).find(|&s| sp.contains(s))
584+
{
585+
if let Ok(code) = sm.span_to_snippet(call_span) {
578586
return Some((
579587
sp,
580588
"consider removing the borrow",
581-
src.to_string(),
589+
code,
582590
Applicability::MachineApplicable,
583591
));
584592
}

library/alloc/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
#![allow(unused_attributes)]
6060
#![stable(feature = "alloc", since = "1.36.0")]
6161
#![doc(
62-
html_root_url = "https://doc.rust-lang.org/nightly/",
6362
html_playground_url = "https://play.rust-lang.org/",
6463
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
6564
test(no_crate_inject, attr(allow(unused_variables), deny(warnings)))

library/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
#![cfg(not(test))]
5252
#![stable(feature = "core", since = "1.6.0")]
5353
#![doc(
54-
html_root_url = "https://doc.rust-lang.org/nightly/",
5554
html_playground_url = "https://play.rust-lang.org/",
5655
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
5756
test(no_crate_inject, attr(deny(warnings))),

library/panic_abort/src/lib.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
66
#![no_std]
77
#![unstable(feature = "panic_abort", issue = "32837")]
8-
#![doc(
9-
html_root_url = "https://doc.rust-lang.org/nightly/",
10-
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/"
11-
)]
8+
#![doc(issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
129
#![panic_runtime]
1310
#![allow(unused_features)]
1411
#![feature(core_intrinsics)]

library/panic_unwind/src/lib.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313
1414
#![no_std]
1515
#![unstable(feature = "panic_unwind", issue = "32837")]
16-
#![doc(
17-
html_root_url = "https://doc.rust-lang.org/nightly/",
18-
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/"
19-
)]
16+
#![doc(issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
2017
#![feature(core_intrinsics)]
2118
#![feature(lang_items)]
2219
#![feature(nll)]

library/proc_macro/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#![stable(feature = "proc_macro_lib", since = "1.15.0")]
1313
#![deny(missing_docs)]
1414
#![doc(
15-
html_root_url = "https://doc.rust-lang.org/nightly/",
1615
html_playground_url = "https://play.rust-lang.org/",
1716
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
1817
test(no_crate_inject, attr(deny(warnings))),

library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@
190190
#![cfg_attr(not(feature = "restricted-std"), stable(feature = "rust1", since = "1.0.0"))]
191191
#![cfg_attr(feature = "restricted-std", unstable(feature = "restricted_std", issue = "none"))]
192192
#![doc(
193-
html_root_url = "https://doc.rust-lang.org/nightly/",
194193
html_playground_url = "https://play.rust-lang.org/",
195194
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
196195
test(no_crate_inject, attr(deny(warnings))),

library/term/src/lib.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@
3030
//! [win]: https://docs.microsoft.com/en-us/windows/console/character-mode-applications
3131
//! [ti]: https://en.wikipedia.org/wiki/Terminfo
3232
33-
#![doc(
34-
html_root_url = "https://doc.rust-lang.org/nightly/",
35-
html_playground_url = "https://play.rust-lang.org/",
36-
test(attr(deny(warnings)))
37-
)]
33+
#![doc(html_playground_url = "https://play.rust-lang.org/", test(attr(deny(warnings))))]
3834
#![deny(missing_docs)]
3935
#![cfg_attr(windows, feature(libc))]
4036

library/test/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#![crate_name = "test"]
2121
#![unstable(feature = "test", issue = "50297")]
22-
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))]
22+
#![doc(test(attr(deny(warnings))))]
2323
#![cfg_attr(unix, feature(libc))]
2424
#![feature(rustc_private)]
2525
#![feature(nll)]

src/bootstrap/builder.rs

+12
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,18 @@ impl<'a> Builder<'a> {
574574
self.run_step_descriptions(&Builder::get_step_descriptions(Kind::Doc), paths);
575575
}
576576

577+
/// NOTE: keep this in sync with `rustdoc::clean::utils::doc_rust_lang_org_channel`, or tests will fail on beta/stable.
578+
pub fn doc_rust_lang_org_channel(&self) -> String {
579+
let channel = match &*self.config.channel {
580+
"stable" => &self.version,
581+
"beta" => "beta",
582+
"nightly" | "dev" => "nightly",
583+
// custom build of rustdoc maybe? link to the latest stable docs just in case
584+
_ => "stable",
585+
};
586+
"https://doc.rust-lang.org/".to_owned() + channel
587+
}
588+
577589
fn run_step_descriptions(&self, v: &[StepDescription], paths: &[PathBuf]) {
578590
StepDescription::run(v, self, paths);
579591
}

src/bootstrap/compile.rs

+5
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car
326326
if target.contains("riscv") {
327327
cargo.rustflag("-Cforce-unwind-tables=yes");
328328
}
329+
330+
let html_root =
331+
format!("-Zcrate-attr=doc(html_root_url=\"{}/\")", builder.doc_rust_lang_org_channel(),);
332+
cargo.rustflag(&html_root);
333+
cargo.rustdocflag(&html_root);
329334
}
330335

331336
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]

src/bootstrap/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ impl Build {
13661366
eprintln!(
13671367
"
13681368
Couldn't find required command: ninja
1369-
You should install ninja, or set ninja=false in config.toml
1369+
You should install ninja, or set `ninja=false` in config.toml in the `[llvm]` section.
13701370
"
13711371
);
13721372
std::process::exit(1);

src/bootstrap/test.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
14861486
}
14871487
}
14881488
cmd.env("RUSTC_BOOTSTRAP", "1");
1489+
cmd.env("DOC_RUST_LANG_ORG_CHANNEL", builder.doc_rust_lang_org_channel());
14891490
builder.add_rust_test_threads(&mut cmd);
14901491

14911492
if builder.config.sanitizers_enabled(target) {

src/bootstrap/tool.rs

+1
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ pub fn prepare_tool_cargo(
263263
cargo.env("CFG_RELEASE_CHANNEL", &builder.config.channel);
264264
cargo.env("CFG_VERSION", builder.rust_version());
265265
cargo.env("CFG_RELEASE_NUM", &builder.version);
266+
cargo.env("DOC_RUST_LANG_ORG_CHANNEL", builder.doc_rust_lang_org_channel());
266267

267268
let info = GitInfo::new(builder.config.ignore_git, &dir);
268269
if let Some(sha) = info.sha() {

src/etc/htmldocck.py

+4
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@
135135
unichr = chr
136136

137137

138+
channel = os.environ["DOC_RUST_LANG_ORG_CHANNEL"]
139+
138140
class CustomHTMLParser(HTMLParser):
139141
"""simplified HTML parser.
140142
@@ -270,6 +272,7 @@ def flatten(node):
270272

271273

272274
def normalize_xpath(path):
275+
path = path.replace("{{channel}}", channel)
273276
if path.startswith('//'):
274277
return '.' + path # avoid warnings
275278
elif path.startswith('.//'):
@@ -334,6 +337,7 @@ def get_dir(self, path):
334337

335338

336339
def check_string(data, pat, regexp):
340+
pat = pat.replace("{{channel}}", channel)
337341
if not pat:
338342
return True # special case a presence testing
339343
elif regexp:

src/librustdoc/clean/types.rs

+1-36
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ impl Item {
499499
format!("{}/std/", s.trim_end_matches('/'))
500500
}
501501
Some(ExternalLocation::Unknown) | None => {
502-
"https://doc.rust-lang.org/nightly/std/".to_string()
502+
format!("{}/std/", crate::DOC_RUST_LANG_ORG_CHANNEL)
503503
}
504504
};
505505
// This is a primitive so the url is done "by hand".
@@ -1767,37 +1767,6 @@ impl PrimitiveType {
17671767
}
17681768
}
17691769

1770-
crate fn as_str(&self) -> &'static str {
1771-
use self::PrimitiveType::*;
1772-
match *self {
1773-
Isize => "isize",
1774-
I8 => "i8",
1775-
I16 => "i16",
1776-
I32 => "i32",
1777-
I64 => "i64",
1778-
I128 => "i128",
1779-
Usize => "usize",
1780-
U8 => "u8",
1781-
U16 => "u16",
1782-
U32 => "u32",
1783-
U64 => "u64",
1784-
U128 => "u128",
1785-
F32 => "f32",
1786-
F64 => "f64",
1787-
Str => "str",
1788-
Bool => "bool",
1789-
Char => "char",
1790-
Array => "array",
1791-
Slice => "slice",
1792-
Tuple => "tuple",
1793-
Unit => "unit",
1794-
RawPointer => "pointer",
1795-
Reference => "reference",
1796-
Fn => "fn",
1797-
Never => "never",
1798-
}
1799-
}
1800-
18011770
crate fn impls(&self, tcx: TyCtxt<'_>) -> &'static ArrayVec<DefId, 4> {
18021771
Self::all_impls(tcx).get(self).expect("missing impl for primitive type")
18031772
}
@@ -1860,10 +1829,6 @@ impl PrimitiveType {
18601829
})
18611830
}
18621831

1863-
crate fn to_url_str(&self) -> &'static str {
1864-
self.as_str()
1865-
}
1866-
18671832
crate fn as_sym(&self) -> Symbol {
18681833
use PrimitiveType::*;
18691834
match self {

0 commit comments

Comments
 (0)