Skip to content

Commit 1bd4fdc

Browse files
committed
Auto merge of rust-lang#92811 - matthiaskrgr:rollup-wrctcef, r=matthiaskrgr
Rollup of 14 pull requests Successful merges: - rust-lang#92328 (Tweak sentence in `transmute` docs) - rust-lang#92432 (Error when selected impl is not const in constck) - rust-lang#92506 (Document Box<T> FFI guarantee in 1.41.0 release notes) - rust-lang#92699 (rustdoc: Display "private fields" instead of "fields omitted") - rust-lang#92703 (RELEASES.md: Add 1.58 release note for `File::options` stabilization) - rust-lang#92707 (Extended the note on the use of `no_run` attribute) - rust-lang#92709 (Improve documentation for File::options to give a more likely example) - rust-lang#92720 (Fix doc formatting for time.rs) - rust-lang#92732 (Add note about upstream commit musl-patch-configure.diff is derived from) - rust-lang#92742 (Add missing suffix for sidebar-items script path) - rust-lang#92748 (Eliminate "boxed" wording in `std::error::Error` documentation) - rust-lang#92754 (Update AsmArgs field visibility for rustfmt) - rust-lang#92756 (:arrow_up: rust-analyzer) - rust-lang#92764 (Fix rust logo style) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 72e74d7 + 05dd1e4 commit 1bd4fdc

File tree

22 files changed

+158
-36
lines changed

22 files changed

+158
-36
lines changed

RELEASES.md

+8
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Stabilized APIs
4444
- [`Result::unwrap_unchecked`]
4545
- [`Result::unwrap_err_unchecked`]
4646
- [`NonZero{unsigned}::is_power_of_two`]
47+
- [`File::options`]
4748

4849
These APIs are now usable in const contexts:
4950

@@ -141,6 +142,7 @@ and related tools.
141142
[`Result::unwrap_unchecked`]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.unwrap_unchecked
142143
[`Result::unwrap_err_unchecked`]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.unwrap_err_unchecked
143144
[`NonZero{unsigned}::is_power_of_two`]: https://doc.rust-lang.org/stable/std/num/struct.NonZeroU8.html#method.is_power_of_two
145+
[`File::options`]: https://doc.rust-lang.org/stable/std/fs/struct.File.html#method.options
144146
[`unix::process::ExitStatusExt::core_dumped`]: https://doc.rust-lang.org/stable/std/os/unix/process/trait.ExitStatusExt.html#tymethod.core_dumped
145147
[`unix::process::ExitStatusExt::stopped_signal`]: https://doc.rust-lang.org/stable/std/os/unix/process/trait.ExitStatusExt.html#tymethod.stopped_signal
146148
[`unix::process::ExitStatusExt::continued`]: https://doc.rust-lang.org/stable/std/os/unix/process/trait.ExitStatusExt.html#tymethod.continued
@@ -2588,6 +2590,11 @@ Language
25882590
- [Visibility modifiers (e.g. `pub`) are now syntactically allowed on trait items and
25892591
enum variants.][66183] These are still rejected semantically, but
25902592
can be seen and parsed by procedural macros and conditional compilation.
2593+
- [You can now define a Rust `extern "C"` function with `Box<T>` and use `T*` as the corresponding
2594+
type on the C side.][62514] Please see [the documentation][box-memory-layout] for more information,
2595+
including the important caveat about preferring to avoid `Box<T>` in Rust signatures for functions defined in C.
2596+
2597+
[box-memory-layout]: https://doc.rust-lang.org/std/boxed/index.html#memory-layout
25912598

25922599
Compiler
25932600
--------
@@ -2662,6 +2669,7 @@ Compatibility Notes
26622669

26632670
[54733]: https://github.com/rust-lang/rust/pull/54733/
26642671
[61351]: https://github.com/rust-lang/rust/pull/61351/
2672+
[62514]: https://github.com/rust-lang/rust/pull/62514/
26652673
[67255]: https://github.com/rust-lang/rust/pull/67255/
26662674
[66661]: https://github.com/rust-lang/rust/pull/66661/
26672675
[66771]: https://github.com/rust-lang/rust/pull/66771/

compiler/rustc_builtin_macros/src/asm.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ use rustc_target::asm::InlineAsmArch;
1616
use smallvec::smallvec;
1717

1818
pub struct AsmArgs {
19-
templates: Vec<P<ast::Expr>>,
20-
operands: Vec<(ast::InlineAsmOperand, Span)>,
19+
pub templates: Vec<P<ast::Expr>>,
20+
pub operands: Vec<(ast::InlineAsmOperand, Span)>,
2121
named_args: FxHashMap<Symbol, usize>,
2222
reg_args: FxHashSet<usize>,
23-
clobber_abis: Vec<(Symbol, Span)>,
23+
pub clobber_abis: Vec<(Symbol, Span)>,
2424
options: ast::InlineAsmOptions,
25-
options_spans: Vec<Span>,
25+
pub options_spans: Vec<Span>,
2626
}
2727

2828
fn parse_args<'a>(

compiler/rustc_const_eval/src/transform/check_consts/check.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
810810
param_env,
811811
Binder::dummy(TraitPredicate {
812812
trait_ref,
813-
constness: ty::BoundConstness::ConstIfConst,
813+
constness: ty::BoundConstness::NotConst,
814814
polarity: ty::ImplPolarity::Positive,
815815
}),
816816
);
@@ -829,6 +829,10 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
829829
return;
830830
}
831831
Ok(Some(ImplSource::UserDefined(data))) => {
832+
if let hir::Constness::NotConst = tcx.impl_constness(data.impl_def_id) {
833+
self.check_op(ops::FnCallNonConst(None));
834+
return;
835+
}
832836
let callee_name = tcx.item_name(callee);
833837
if let Some(&did) = tcx
834838
.associated_item_def_ids(data.impl_def_id)

library/core/src/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ extern "rust-intrinsic" {
961961
/// Below are common applications of `transmute` which can be replaced with safer
962962
/// constructs.
963963
///
964-
/// Turning raw bytes(`&[u8]`) to `u32`, `f64`, etc.:
964+
/// Turning raw bytes (`&[u8]`) into `u32`, `f64`, etc.:
965965
///
966966
/// ```
967967
/// let raw_bytes = [0x78, 0x56, 0x34, 0x12];

library/std/src/error.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -606,21 +606,21 @@ impl Error for time::FromSecsError {}
606606

607607
// Copied from `any.rs`.
608608
impl dyn Error + 'static {
609-
/// Returns `true` if the boxed type is the same as `T`
609+
/// Returns `true` if the inner type is the same as `T`.
610610
#[stable(feature = "error_downcast", since = "1.3.0")]
611611
#[inline]
612612
pub fn is<T: Error + 'static>(&self) -> bool {
613613
// Get `TypeId` of the type this function is instantiated with.
614614
let t = TypeId::of::<T>();
615615

616-
// Get `TypeId` of the type in the trait object.
617-
let boxed = self.type_id(private::Internal);
616+
// Get `TypeId` of the type in the trait object (`self`).
617+
let concrete = self.type_id(private::Internal);
618618

619619
// Compare both `TypeId`s on equality.
620-
t == boxed
620+
t == concrete
621621
}
622622

623-
/// Returns some reference to the boxed value if it is of type `T`, or
623+
/// Returns some reference to the inner value if it is of type `T`, or
624624
/// `None` if it isn't.
625625
#[stable(feature = "error_downcast", since = "1.3.0")]
626626
#[inline]
@@ -632,7 +632,7 @@ impl dyn Error + 'static {
632632
}
633633
}
634634

635-
/// Returns some mutable reference to the boxed value if it is of type `T`, or
635+
/// Returns some mutable reference to the inner value if it is of type `T`, or
636636
/// `None` if it isn't.
637637
#[stable(feature = "error_downcast", since = "1.3.0")]
638638
#[inline]

library/std/src/fs.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,10 @@ impl File {
356356
/// open or create a file with specific options if `open()` or `create()`
357357
/// are not appropriate.
358358
///
359-
/// It is equivalent to `OpenOptions::new()` but allows you to write more
360-
/// readable code. Instead of `OpenOptions::new().read(true).open("foo.txt")`
361-
/// you can write `File::options().read(true).open("foo.txt")`. This
359+
/// It is equivalent to `OpenOptions::new()`, but allows you to write more
360+
/// readable code. Instead of
361+
/// `OpenOptions::new().append(true).open("example.log")`,
362+
/// you can write `File::options().append(true).open("example.log")`. This
362363
/// also avoids the need to import `OpenOptions`.
363364
///
364365
/// See the [`OpenOptions::new`] function for more details.
@@ -369,7 +370,7 @@ impl File {
369370
/// use std::fs::File;
370371
///
371372
/// fn main() -> std::io::Result<()> {
372-
/// let mut f = File::options().read(true).open("foo.txt")?;
373+
/// let mut f = File::options().append(true).open("example.log")?;
373374
/// Ok(())
374375
/// }
375376
/// ```

library/std/src/time.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub use core::time::FromSecsError;
5454
/// instant when created, and are often useful for tasks such as measuring
5555
/// benchmarks or timing how long an operation takes.
5656
///
57-
/// Note, however, that instants are not guaranteed to be **steady**. In other
57+
/// Note, however, that instants are **not** guaranteed to be **steady**. In other
5858
/// words, each tick of the underlying clock might not be the same length (e.g.
5959
/// some seconds may be longer than others). An instant may jump forwards or
6060
/// experience time dilation (slow down or speed up), but it will never go

src/ci/docker/scripts/musl-toolchain.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ cd musl-cross-make
4848
git checkout a54eb56f33f255dfca60be045f12a5cfaf5a72a9
4949

5050
# Fix the cfi detection script in musl's configure so cfi is generated
51-
# when debug info is asked for.
51+
# when debug info is asked for. This patch is derived from
52+
# https://git.musl-libc.org/cgit/musl/commit/?id=c4d4028dde90562f631edf559fbc42d8ec1b29de.
53+
# When we upgrade to a version that includes this commit, we can remove the patch.
5254
mkdir patches/musl-1.1.24
5355
cp ../musl-patch-configure.diff patches/musl-1.1.24/0001-fix-cfi-detection.diff
5456

src/doc/rustdoc/src/documentation-tests.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@ panic during execution. If the code doesn't panic, the test will fail.
335335
The `no_run` attribute will compile your code but not run it. This is
336336
important for examples such as "Here's how to retrieve a web page,"
337337
which you would want to ensure compiles, but might be run in a test
338-
environment that has no network access.
338+
environment that has no network access. This attribute can also be
339+
used to demonstrate code snippets that can cause Undefined Behavior.
339340

340341
```rust
341342
/// ```no_run

src/librustdoc/html/render/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
665665
_ => unreachable!(),
666666
};
667667
let items = self.build_sidebar_items(module);
668-
let js_dst = self.dst.join("sidebar-items.js");
668+
let js_dst = self.dst.join(&format!("sidebar-items{}.js", self.shared.resource_suffix));
669669
let v = format!("initSidebarItems({});", serde_json::to_string(&items).unwrap());
670670
scx.fs.write(js_dst, v)?;
671671
}

src/librustdoc/html/render/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,11 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
18271827
ty = it.type_(),
18281828
path = relpath
18291829
);
1830-
write!(buffer, "<script defer src=\"{}sidebar-items.js\"></script>", relpath);
1830+
write!(
1831+
buffer,
1832+
"<script defer src=\"{}sidebar-items{}.js\"></script>",
1833+
relpath, cx.shared.resource_suffix
1834+
);
18311835
// Closes sidebar-elems div.
18321836
buffer.write_str("</div>");
18331837
}

src/librustdoc/html/render/print_item.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,7 @@ fn render_union(
15571557
}
15581558

15591559
if it.has_stripped_fields().unwrap() {
1560-
write!(w, " // some fields omitted\n{}", tab);
1560+
write!(w, " /* private fields */\n{}", tab);
15611561
}
15621562
if toggle {
15631563
toggle_close(w);
@@ -1613,13 +1613,11 @@ fn render_struct(
16131613

16141614
if has_visible_fields {
16151615
if it.has_stripped_fields().unwrap() {
1616-
write!(w, "\n{} // some fields omitted", tab);
1616+
write!(w, "\n{} /* private fields */", tab);
16171617
}
16181618
write!(w, "\n{}", tab);
16191619
} else if it.has_stripped_fields().unwrap() {
1620-
// If there are no visible fields we can just display
1621-
// `{ /* fields omitted */ }` to save space.
1622-
write!(w, " /* fields omitted */ ");
1620+
write!(w, " /* private fields */ ");
16231621
}
16241622
if toggle {
16251623
toggle_close(w);

src/librustdoc/html/static/css/themes/ayu.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pre, .rustdoc.source .example-wrap {
6161
background-color: #14191f;
6262
}
6363

64-
.rust-logo > img {
64+
.rust-logo {
6565
filter: drop-shadow(1px 0 0px #fff)
6666
drop-shadow(0 1px 0 #fff)
6767
drop-shadow(-1px 0 0 #fff)

src/librustdoc/html/static/css/themes/dark.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pre, .rustdoc.source .example-wrap {
3232
background-color: #505050;
3333
}
3434

35-
.rust-logo > img {
35+
.rust-logo {
3636
filter: drop-shadow(1px 0 0px #fff)
3737
drop-shadow(0 1px 0 #fff)
3838
drop-shadow(-1px 0 0 #fff)

src/librustdoc/html/static/css/themes/light.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pre, .rustdoc.source .example-wrap {
4343
scrollbar-color: rgba(36, 37, 39, 0.6) #d9d9d9;
4444
}
4545

46-
.rust-logo > img {
46+
.rust-logo {
4747
/* No need for a border in here! */
4848
}
4949

src/test/rustdoc-gui/rust-logo.goml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// This test ensures that the correct style is applied to the rust logo in the sidebar.
2+
goto: file://|DOC_PATH|/test_docs/index.html
3+
4+
// First we start with the dark theme.
5+
local-storage: {
6+
"rustdoc-theme": "dark",
7+
"rustdoc-preferred-dark-theme": "dark",
8+
"rustdoc-use-system-theme": "false",
9+
}
10+
reload:
11+
12+
assert-css: (
13+
".rust-logo",
14+
{"filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"},
15+
)
16+
17+
// In the source view page now.
18+
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html
19+
20+
local-storage: {
21+
"rustdoc-theme": "dark",
22+
"rustdoc-preferred-dark-theme": "dark",
23+
"rustdoc-use-system-theme": "false",
24+
}
25+
reload:
26+
27+
assert-css: (
28+
".rust-logo",
29+
{"filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"},
30+
)
31+
32+
// Then with the ayu theme.
33+
local-storage: {
34+
"rustdoc-theme": "ayu",
35+
"rustdoc-preferred-dark-theme": "ayu",
36+
"rustdoc-use-system-theme": "false",
37+
}
38+
reload:
39+
40+
assert-css: (
41+
".rust-logo",
42+
{"filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"},
43+
)
44+
45+
// In the source view page now.
46+
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html
47+
48+
local-storage: {
49+
"rustdoc-theme": "ayu",
50+
"rustdoc-preferred-dark-theme": "ayu",
51+
"rustdoc-use-system-theme": "false",
52+
}
53+
reload:
54+
55+
assert-css: (
56+
".rust-logo",
57+
{"filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"},
58+
)
59+
60+
// And finally with the light theme.
61+
local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
62+
reload:
63+
64+
assert-css: (
65+
".rust-logo",
66+
{"filter": "none"},
67+
)
68+
69+
// In the source view page now.
70+
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html
71+
72+
local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
73+
reload:
74+
75+
assert-css: (
76+
".rust-logo",
77+
{"filter": "none"},
78+
)

src/test/rustdoc/structfields.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pub struct Foo {
33
// @has - //pre "pub a: ()"
44
pub a: (),
5-
// @has - //pre "// some fields omitted"
5+
// @has - //pre "/* private fields */"
66
// @!has - //pre "b: ()"
77
b: (),
88
// @!has - //pre "c: usize"
@@ -16,7 +16,7 @@ pub struct Foo {
1616
pub struct Bar {
1717
// @has - //pre "pub a: ()"
1818
pub a: (),
19-
// @!has - //pre "// some fields omitted"
19+
// @!has - //pre "/* private fields */"
2020
}
2121

2222
// @has structfields/enum.Qux.html
@@ -29,11 +29,11 @@ pub enum Qux {
2929
b: (),
3030
// @has - //pre "c: usize"
3131
c: usize,
32-
// @has - //pre "// some fields omitted"
32+
// @has - //pre "/* private fields */"
3333
},
3434
}
3535

36-
// @has structfields/struct.Baz.html //pre "pub struct Baz { /* fields omitted */ }"
36+
// @has structfields/struct.Baz.html //pre "pub struct Baz { /* private fields */ }"
3737
pub struct Baz {
3838
x: u8,
3939
#[doc(hidden)]

src/test/rustdoc/toggle-item-contents.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub union Union {
5555

5656
// @has 'toggle_item_contents/struct.PrivStruct.html'
5757
// @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 0
58-
// @has - '//div[@class="docblock item-decl"]' 'fields omitted'
58+
// @has - '//div[@class="docblock item-decl"]' '/* private fields */'
5959
pub struct PrivStruct {
6060
a: usize,
6161
b: usize,

src/test/rustdoc/union.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pub union U {
33
// @has - //pre "pub a: u8"
44
pub a: u8,
5-
// @has - //pre "// some fields omitted"
5+
// @has - //pre "/* private fields */"
66
// @!has - //pre "b: u16"
77
b: u16,
88
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#![feature(const_fn_trait_bound)]
2+
#![feature(const_trait_impl)]
3+
4+
pub trait Tr {
5+
#[default_method_body_is_const]
6+
fn a(&self) {}
7+
8+
#[default_method_body_is_const]
9+
fn b(&self) {
10+
().a()
11+
//~^ ERROR calls in constant functions are limited
12+
}
13+
}
14+
15+
impl Tr for () {}
16+
17+
fn main() {}

0 commit comments

Comments
 (0)