Skip to content

Commit

Permalink
Auto merge of #92811 - matthiaskrgr:rollup-wrctcef, r=matthiaskrgr
Browse files Browse the repository at this point in the history
Rollup of 14 pull requests

Successful merges:

 - #92328 (Tweak sentence in `transmute` docs)
 - #92432 (Error when selected impl is not const in constck)
 - #92506 (Document Box<T> FFI guarantee in 1.41.0 release notes)
 - #92699 (rustdoc: Display "private fields" instead of "fields omitted")
 - #92703 (RELEASES.md: Add 1.58 release note for `File::options` stabilization)
 - #92707 (Extended the note on the use of `no_run` attribute)
 - #92709 (Improve documentation for File::options to give a more likely example)
 - #92720 (Fix doc formatting for time.rs)
 - #92732 (Add note about upstream commit musl-patch-configure.diff is derived from)
 - #92742 (Add missing suffix for sidebar-items script path)
 - #92748 (Eliminate "boxed" wording in `std::error::Error` documentation)
 - #92754 (Update AsmArgs field visibility for rustfmt)
 - #92756 (:arrow_up: rust-analyzer)
 - #92764 (Fix rust logo style)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Jan 12, 2022
2 parents 72e74d7 + 05dd1e4 commit 1bd4fdc
Show file tree
Hide file tree
Showing 22 changed files with 158 additions and 36 deletions.
8 changes: 8 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Stabilized APIs
- [`Result::unwrap_unchecked`]
- [`Result::unwrap_err_unchecked`]
- [`NonZero{unsigned}::is_power_of_two`]
- [`File::options`]

These APIs are now usable in const contexts:

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

[box-memory-layout]: https://doc.rust-lang.org/std/boxed/index.html#memory-layout

Compiler
--------
Expand Down Expand Up @@ -2662,6 +2669,7 @@ Compatibility Notes

[54733]: https://github.com/rust-lang/rust/pull/54733/
[61351]: https://github.com/rust-lang/rust/pull/61351/
[62514]: https://github.com/rust-lang/rust/pull/62514/
[67255]: https://github.com/rust-lang/rust/pull/67255/
[66661]: https://github.com/rust-lang/rust/pull/66661/
[66771]: https://github.com/rust-lang/rust/pull/66771/
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_builtin_macros/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ use rustc_target::asm::InlineAsmArch;
use smallvec::smallvec;

pub struct AsmArgs {
templates: Vec<P<ast::Expr>>,
operands: Vec<(ast::InlineAsmOperand, Span)>,
pub templates: Vec<P<ast::Expr>>,
pub operands: Vec<(ast::InlineAsmOperand, Span)>,
named_args: FxHashMap<Symbol, usize>,
reg_args: FxHashSet<usize>,
clobber_abis: Vec<(Symbol, Span)>,
pub clobber_abis: Vec<(Symbol, Span)>,
options: ast::InlineAsmOptions,
options_spans: Vec<Span>,
pub options_spans: Vec<Span>,
}

fn parse_args<'a>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
param_env,
Binder::dummy(TraitPredicate {
trait_ref,
constness: ty::BoundConstness::ConstIfConst,
constness: ty::BoundConstness::NotConst,
polarity: ty::ImplPolarity::Positive,
}),
);
Expand All @@ -829,6 +829,10 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
return;
}
Ok(Some(ImplSource::UserDefined(data))) => {
if let hir::Constness::NotConst = tcx.impl_constness(data.impl_def_id) {
self.check_op(ops::FnCallNonConst(None));
return;
}
let callee_name = tcx.item_name(callee);
if let Some(&did) = tcx
.associated_item_def_ids(data.impl_def_id)
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ extern "rust-intrinsic" {
/// Below are common applications of `transmute` which can be replaced with safer
/// constructs.
///
/// Turning raw bytes(`&[u8]`) to `u32`, `f64`, etc.:
/// Turning raw bytes (`&[u8]`) into `u32`, `f64`, etc.:
///
/// ```
/// let raw_bytes = [0x78, 0x56, 0x34, 0x12];
Expand Down
12 changes: 6 additions & 6 deletions library/std/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,21 +606,21 @@ impl Error for time::FromSecsError {}

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

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

// Compare both `TypeId`s on equality.
t == boxed
t == concrete
}

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

/// Returns some mutable reference to the boxed value if it is of type `T`, or
/// Returns some mutable reference to the inner value if it is of type `T`, or
/// `None` if it isn't.
#[stable(feature = "error_downcast", since = "1.3.0")]
#[inline]
Expand Down
9 changes: 5 additions & 4 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,10 @@ impl File {
/// open or create a file with specific options if `open()` or `create()`
/// are not appropriate.
///
/// It is equivalent to `OpenOptions::new()` but allows you to write more
/// readable code. Instead of `OpenOptions::new().read(true).open("foo.txt")`
/// you can write `File::options().read(true).open("foo.txt")`. This
/// It is equivalent to `OpenOptions::new()`, but allows you to write more
/// readable code. Instead of
/// `OpenOptions::new().append(true).open("example.log")`,
/// you can write `File::options().append(true).open("example.log")`. This
/// also avoids the need to import `OpenOptions`.
///
/// See the [`OpenOptions::new`] function for more details.
Expand All @@ -369,7 +370,7 @@ impl File {
/// use std::fs::File;
///
/// fn main() -> std::io::Result<()> {
/// let mut f = File::options().read(true).open("foo.txt")?;
/// let mut f = File::options().append(true).open("example.log")?;
/// Ok(())
/// }
/// ```
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub use core::time::FromSecsError;
/// instant when created, and are often useful for tasks such as measuring
/// benchmarks or timing how long an operation takes.
///
/// Note, however, that instants are not guaranteed to be **steady**. In other
/// Note, however, that instants are **not** guaranteed to be **steady**. In other
/// words, each tick of the underlying clock might not be the same length (e.g.
/// some seconds may be longer than others). An instant may jump forwards or
/// experience time dilation (slow down or speed up), but it will never go
Expand Down
4 changes: 3 additions & 1 deletion src/ci/docker/scripts/musl-toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ cd musl-cross-make
git checkout a54eb56f33f255dfca60be045f12a5cfaf5a72a9

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

Expand Down
3 changes: 2 additions & 1 deletion src/doc/rustdoc/src/documentation-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ panic during execution. If the code doesn't panic, the test will fail.
The `no_run` attribute will compile your code but not run it. This is
important for examples such as "Here's how to retrieve a web page,"
which you would want to ensure compiles, but might be run in a test
environment that has no network access.
environment that has no network access. This attribute can also be
used to demonstrate code snippets that can cause Undefined Behavior.
```rust
/// ```no_run
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
_ => unreachable!(),
};
let items = self.build_sidebar_items(module);
let js_dst = self.dst.join("sidebar-items.js");
let js_dst = self.dst.join(&format!("sidebar-items{}.js", self.shared.resource_suffix));
let v = format!("initSidebarItems({});", serde_json::to_string(&items).unwrap());
scx.fs.write(js_dst, v)?;
}
Expand Down
6 changes: 5 additions & 1 deletion src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1827,7 +1827,11 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
ty = it.type_(),
path = relpath
);
write!(buffer, "<script defer src=\"{}sidebar-items.js\"></script>", relpath);
write!(
buffer,
"<script defer src=\"{}sidebar-items{}.js\"></script>",
relpath, cx.shared.resource_suffix
);
// Closes sidebar-elems div.
buffer.write_str("</div>");
}
Expand Down
8 changes: 3 additions & 5 deletions src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,7 @@ fn render_union(
}

if it.has_stripped_fields().unwrap() {
write!(w, " // some fields omitted\n{}", tab);
write!(w, " /* private fields */\n{}", tab);
}
if toggle {
toggle_close(w);
Expand Down Expand Up @@ -1613,13 +1613,11 @@ fn render_struct(

if has_visible_fields {
if it.has_stripped_fields().unwrap() {
write!(w, "\n{} // some fields omitted", tab);
write!(w, "\n{} /* private fields */", tab);
}
write!(w, "\n{}", tab);
} else if it.has_stripped_fields().unwrap() {
// If there are no visible fields we can just display
// `{ /* fields omitted */ }` to save space.
write!(w, " /* fields omitted */ ");
write!(w, " /* private fields */ ");
}
if toggle {
toggle_close(w);
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pre, .rustdoc.source .example-wrap {
background-color: #14191f;
}

.rust-logo > img {
.rust-logo {
filter: drop-shadow(1px 0 0px #fff)
drop-shadow(0 1px 0 #fff)
drop-shadow(-1px 0 0 #fff)
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pre, .rustdoc.source .example-wrap {
background-color: #505050;
}

.rust-logo > img {
.rust-logo {
filter: drop-shadow(1px 0 0px #fff)
drop-shadow(0 1px 0 #fff)
drop-shadow(-1px 0 0 #fff)
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pre, .rustdoc.source .example-wrap {
scrollbar-color: rgba(36, 37, 39, 0.6) #d9d9d9;
}

.rust-logo > img {
.rust-logo {
/* No need for a border in here! */
}

Expand Down
78 changes: 78 additions & 0 deletions src/test/rustdoc-gui/rust-logo.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// This test ensures that the correct style is applied to the rust logo in the sidebar.
goto: file://|DOC_PATH|/test_docs/index.html

// First we start with the dark theme.
local-storage: {
"rustdoc-theme": "dark",
"rustdoc-preferred-dark-theme": "dark",
"rustdoc-use-system-theme": "false",
}
reload:

assert-css: (
".rust-logo",
{"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)"},
)

// In the source view page now.
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html

local-storage: {
"rustdoc-theme": "dark",
"rustdoc-preferred-dark-theme": "dark",
"rustdoc-use-system-theme": "false",
}
reload:

assert-css: (
".rust-logo",
{"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)"},
)

// Then with the ayu theme.
local-storage: {
"rustdoc-theme": "ayu",
"rustdoc-preferred-dark-theme": "ayu",
"rustdoc-use-system-theme": "false",
}
reload:

assert-css: (
".rust-logo",
{"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)"},
)

// In the source view page now.
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html

local-storage: {
"rustdoc-theme": "ayu",
"rustdoc-preferred-dark-theme": "ayu",
"rustdoc-use-system-theme": "false",
}
reload:

assert-css: (
".rust-logo",
{"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)"},
)

// And finally with the light theme.
local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
reload:

assert-css: (
".rust-logo",
{"filter": "none"},
)

// In the source view page now.
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html

local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
reload:

assert-css: (
".rust-logo",
{"filter": "none"},
)
8 changes: 4 additions & 4 deletions src/test/rustdoc/structfields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pub struct Foo {
// @has - //pre "pub a: ()"
pub a: (),
// @has - //pre "// some fields omitted"
// @has - //pre "/* private fields */"
// @!has - //pre "b: ()"
b: (),
// @!has - //pre "c: usize"
Expand All @@ -16,7 +16,7 @@ pub struct Foo {
pub struct Bar {
// @has - //pre "pub a: ()"
pub a: (),
// @!has - //pre "// some fields omitted"
// @!has - //pre "/* private fields */"
}

// @has structfields/enum.Qux.html
Expand All @@ -29,11 +29,11 @@ pub enum Qux {
b: (),
// @has - //pre "c: usize"
c: usize,
// @has - //pre "// some fields omitted"
// @has - //pre "/* private fields */"
},
}

// @has structfields/struct.Baz.html //pre "pub struct Baz { /* fields omitted */ }"
// @has structfields/struct.Baz.html //pre "pub struct Baz { /* private fields */ }"
pub struct Baz {
x: u8,
#[doc(hidden)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/toggle-item-contents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub union Union {

// @has 'toggle_item_contents/struct.PrivStruct.html'
// @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 0
// @has - '//div[@class="docblock item-decl"]' 'fields omitted'
// @has - '//div[@class="docblock item-decl"]' '/* private fields */'
pub struct PrivStruct {
a: usize,
b: usize,
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pub union U {
// @has - //pre "pub a: u8"
pub a: u8,
// @has - //pre "// some fields omitted"
// @has - //pre "/* private fields */"
// @!has - //pre "b: u16"
b: u16,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#![feature(const_fn_trait_bound)]
#![feature(const_trait_impl)]

pub trait Tr {
#[default_method_body_is_const]
fn a(&self) {}

#[default_method_body_is_const]
fn b(&self) {
().a()
//~^ ERROR calls in constant functions are limited
}
}

impl Tr for () {}

fn main() {}
Loading

0 comments on commit 1bd4fdc

Please sign in to comment.