Skip to content

Rollup of 10 pull requests #91486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7430b22
Make `Option::expect` const
lilasta Oct 25, 2021
f99e358
Merge commit 'ea199bacef07213dbe008841b89c450e3bf0c638' into rustfmt-…
calebcartwright Nov 8, 2021
e6d1bf5
Link tracking issues in Configurations.md (#4096)
Mar 31, 2020
34b7566
Type can be unsized and uninhabited
sanxiyn Nov 13, 2021
eee8f04
refactor: cleanup duplicative Impl handling code
calebcartwright Nov 17, 2021
0023abf
tests: add cases for type alias issues
calebcartwright Nov 18, 2021
2c442cc
fix: correct some type alias issues
calebcartwright Nov 18, 2021
196e676
Preserve normalized comments after last list item
mujpao Nov 19, 2021
826eba8
Add a few missing tracking issues in Configurations.md (#5084)
karyon Nov 20, 2021
4389a4c
fix: do not wrap reference-style doc links
domodwyer Nov 19, 2021
4198fac
Preload the most commonly used fonts.
jsha Nov 24, 2021
f99469d
Change how the fn params span is calculated
estebank Nov 24, 2021
243cec7
Update README.md
bluenote10 Nov 24, 2021
0da3a0f
Fix ICE #91268 by checking that the snippet ends with a `)`
Badel2 Nov 26, 2021
ea042b9
Add more tests for comments in lists
mujpao Nov 24, 2021
67fd9ec
Run Windows, Linux, and Mac CI tests with nightly and stable channels
ytmimi Nov 24, 2021
a21f1b6
Conditionally compile tests based on CFG_RELEASE_CHANNEL env var
ytmimi Nov 27, 2021
0fc846f
refactor: maintain more AST info when formatting a RHS
calebcartwright Nov 28, 2021
1f28683
Update nightly only test with #[nightly_only_test] attribute
ytmimi Nov 29, 2021
41e2a53
Android: -ldl must appear after -lgcc when linking
Amanieu Nov 30, 2021
ec46ffd
Determine when new comment lines are needed for itemized blocks
ytmimi Nov 19, 2021
7a14525
Document Windows TLS drop behaviour
ChrisDenton Dec 2, 2021
41e21aa
Implement write() method for Box<MaybeUninit<T>>
Kixunil Sep 13, 2021
0fdb109
suppress warning about set_errno being unused on DragonFly
rtzoeller Dec 2, 2021
a11994e
use try_normalize_erasing_regions in needs_drop
b-naber Dec 2, 2021
e305322
Merge remote-tracking branch 'upstream/master' into subtree-sync-2021…
calebcartwright Dec 3, 2021
8da8371
Merge pull request #5121 from calebcartwright/subtree-sync-2021-12-02
calebcartwright Dec 3, 2021
f6ade7c
Merge commit '8da837185714cefbb261e93e9846afb11c1dc60e' into sync-rus…
calebcartwright Dec 3, 2021
31003a3
Rollup merge of #88906 - Kixunil:box-maybe-uninit-write, r=dtolnay
matthiaskrgr Dec 3, 2021
94cd025
Rollup merge of #90269 - woppopo:const_option_expect, r=yaahc
matthiaskrgr Dec 3, 2021
570dc70
Rollup merge of #90854 - sanxiyn:unsized-and-uninhabited, r=estebank
matthiaskrgr Dec 3, 2021
0ccd566
Rollup merge of #91170 - jsha:preload-fonts, r=GuillaumeGomez
matthiaskrgr Dec 3, 2021
a5ee722
Rollup merge of #91273 - Badel2:ice-index-str, r=estebank
matthiaskrgr Dec 3, 2021
63da52a
Rollup merge of #91381 - Amanieu:android_libdl, r=petrochenkov
matthiaskrgr Dec 3, 2021
25474ed
Rollup merge of #91453 - ChrisDenton:doc-win-tls-dtors, r=dtolnay
matthiaskrgr Dec 3, 2021
f056f0d
Rollup merge of #91462 - b-naber:use-try-normalize-erasing-regions, r…
matthiaskrgr Dec 3, 2021
aa6f2d9
Rollup merge of #91474 - rtzoeller:dfly_set_errno, r=cuviper
matthiaskrgr Dec 3, 2021
a216060
Rollup merge of #91483 - calebcartwright:sync-rustfmt-subtree, r=cale…
matthiaskrgr Dec 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions compiler/rustc_ast_lowering/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,19 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
if let Ok(snippet) = self.sess.source_map().span_to_snippet(data.span) {
// Do not suggest going from `Trait()` to `Trait<>`
if !data.inputs.is_empty() {
if let Some(split) = snippet.find('(') {
let trait_name = &snippet[0..split];
let args = &snippet[split + 1..snippet.len() - 1];
err.span_suggestion(
data.span,
"use angle brackets instead",
format!("{}<{}>", trait_name, args),
Applicability::MaybeIncorrect,
);
// Suggest replacing `(` and `)` with `<` and `>`
// The snippet may be missing the closing `)`, skip that case
if snippet.ends_with(')') {
if let Some(split) = snippet.find('(') {
let trait_name = &snippet[0..split];
let args = &snippet[split + 1..snippet.len() - 1];
err.span_suggestion(
data.span,
"use angle brackets instead",
format!("{}<{}>", trait_name, args),
Applicability::MaybeIncorrect,
);
}
}
}
};
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_data_structures/src/functor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ impl<T> IdFunctor for Box<T> {
let value = raw.read();
// SAFETY: Converts `Box<T>` to `Box<MaybeUninit<T>>` which is the
// inverse of `Box::assume_init()` and should be safe.
let mut raw: Box<mem::MaybeUninit<T>> = Box::from_raw(raw.cast());
let raw: Box<mem::MaybeUninit<T>> = Box::from_raw(raw.cast());
// SAFETY: Write the mapped value back into the `Box`.
raw.write(f(value)?);
// SAFETY: We just initialized `raw`.
raw.assume_init()
Box::write(raw, f(value)?)
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
}
}

if sized && fields.iter().any(|f| f.abi.is_uninhabited()) {
if fields.iter().any(|f| f.abi.is_uninhabited()) {
abi = Abi::Uninhabited;
}

Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_middle/src/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,10 +788,14 @@ impl<'tcx> ty::TyS<'tcx> {
[component_ty] => component_ty,
_ => self,
};

// This doesn't depend on regions, so try to minimize distinct
// query keys used.
let erased = tcx.normalize_erasing_regions(param_env, query_ty);
tcx.needs_drop_raw(param_env.and(erased))
// If normalization fails, we just use `query_ty`.
let query_ty =
tcx.try_normalize_erasing_regions(param_env, query_ty).unwrap_or(query_ty);

tcx.needs_drop_raw(param_env.and(query_ty))
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_ty_utils/src/needs_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ where
Ok(tys) => tys,
};
for required_ty in tys {
let required =
tcx.normalize_erasing_regions(self.param_env, required_ty);
let required = tcx
.try_normalize_erasing_regions(self.param_env, required_ty)
.unwrap_or(required_ty);

queue_type(self, required);
}
}
Expand Down
36 changes: 36 additions & 0 deletions library/alloc/src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,42 @@ impl<T, A: Allocator> Box<mem::MaybeUninit<T>, A> {
let (raw, alloc) = Box::into_raw_with_allocator(self);
unsafe { Box::from_raw_in(raw as *mut T, alloc) }
}

/// Writes the value and converts to `Box<T, A>`.
///
/// This method converts the box similarly to [`Box::assume_init`] but
/// writes `value` into it before conversion thus guaranteeing safety.
/// In some scenarios use of this method may improve performance because
/// the compiler may be able to optimize copying from stack.
///
/// # Examples
///
/// ```
/// #![feature(new_uninit)]
///
/// let big_box = Box::<[usize; 1024]>::new_uninit();
///
/// let mut array = [0; 1024];
/// for (i, place) in array.iter_mut().enumerate() {
/// *place = i;
/// }
///
/// // The optimizer may be able to elide this copy, so previous code writes
/// // to heap directly.
/// let big_box = Box::write(big_box, array);
///
/// for (i, x) in big_box.iter().enumerate() {
/// assert_eq!(*x, i);
/// }
/// ```
#[unstable(feature = "new_uninit", issue = "63291")]
#[inline]
pub fn write(mut boxed: Self, value: T) -> Box<T, A> {
unsafe {
(*boxed).write(value);
boxed.assume_init()
}
}
}

impl<T, A: Allocator> Box<[mem::MaybeUninit<T>], A> {
Expand Down
5 changes: 3 additions & 2 deletions library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,8 @@ impl<T> Option<T> {
#[inline]
#[track_caller]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn expect(self, msg: &str) -> T {
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
pub const fn expect(self, msg: &str) -> T {
match self {
Some(val) => val,
None => expect_failed(msg),
Expand Down Expand Up @@ -1658,7 +1659,7 @@ impl<T, E> Option<Result<T, E>> {
#[inline(never)]
#[cold]
#[track_caller]
fn expect_failed(msg: &str) -> ! {
const fn expect_failed(msg: &str) -> ! {
panic!("{}", msg)
}

Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub fn errno() -> i32 {
}

#[cfg(target_os = "dragonfly")]
#[allow(dead_code)]
pub fn set_errno(e: i32) {
extern "C" {
#[thread_local]
Expand Down
14 changes: 14 additions & 0 deletions library/std/src/thread/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,21 @@ use crate::fmt;
/// destroyed, but not all platforms have this guard. Those platforms that do
/// not guard typically have a synthetic limit after which point no more
/// destructors are run.
/// 3. When the process exits on Windows systems, TLS destructors may only be
/// run on the thread that causes the process to exit. This is because the
/// other threads may be forcibly terminated.
///
/// ## Synchronization in thread-local destructors
///
/// On Windows, synchronization operations (such as [`JoinHandle::join`]) in
/// thread local destructors are prone to deadlocks and so should be avoided.
/// This is because the [loader lock] is held while a destructor is run. The
/// lock is acquired whenever a thread starts or exits or when a DLL is loaded
/// or unloaded. Therefore these events are blocked for as long as a thread
/// local destructor is running.
///
/// [loader lock]: https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-best-practices
/// [`JoinHandle::join`]: crate::thread::JoinHandle::join
/// [`with`]: LocalKey::with
#[stable(feature = "rust1", since = "1.0.0")]
pub struct LocalKey<T: 'static> {
Expand Down
3 changes: 3 additions & 0 deletions library/unwind/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ fn main() {
} else {
println!("cargo:rustc-link-lib=gcc");
}

// Android's unwinding library depends on dl_iterate_phdr in `libdl`.
println!("cargo:rustc-link-lib=dl");
} else if target.contains("freebsd") {
println!("cargo:rustc-link-lib=gcc_s");
} else if target.contains("netbsd") {
Expand Down
6 changes: 6 additions & 0 deletions src/librustdoc/html/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
<meta name="description" content="{{page.description}}"> {#- -#}
<meta name="keywords" content="{{page.keywords}}"> {#- -#}
<title>{{page.title}}</title> {#- -#}
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path | safe}}SourceSerif4-Regular.ttf.woff2"> {#- -#}
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path | safe}}FiraSans-Regular.woff2"> {#- -#}
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path | safe}}FiraSans-Medium.woff2"> {#- -#}
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path | safe}}SourceCodePro-Regular.ttf.woff2"> {#- -#}
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path | safe}}SourceSerif4-Bold.ttf.woff2"> {#- -#}
<link rel="preload" as="font" type="font/woff2" crossorigin href="{{static_root_path | safe}}SourceCodePro-Semibold.ttf.woff2"> {#- -#}
<link rel="stylesheet" type="text/css" {# -#}
href="{{static_root_path | safe}}normalize{{page.resource_suffix}}.css"> {#- -#}
<link rel="stylesheet" type="text/css" {# -#}
Expand Down
21 changes: 21 additions & 0 deletions src/test/ui/issues/issue-88150.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// run-pass
// compile-flags:-C debuginfo=2
// edition:2018

use core::marker::PhantomData;

pub struct Foo<T: ?Sized, A>(
PhantomData<(A, T)>,
);

enum Never {}

impl<T: ?Sized> Foo<T, Never> {
fn new_foo() -> Foo<T, Never> {
Foo(PhantomData)
}
}

fn main() {
let _ = Foo::<[()], Never>::new_foo();
}
9 changes: 9 additions & 0 deletions src/test/ui/type/issue-91268.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// error-pattern: this file contains an unclosed delimiter
// error-pattern: cannot find type `ţ` in this scope
// error-pattern: parenthesized type parameters may only be used with a `Fn` trait
// error-pattern: type arguments are not allowed for this type
// error-pattern: mismatched types
// ignore-tidy-trailing-newlines
// `ţ` must be the last character in this file, it cannot be followed by a newline
fn main() {
0: u8(ţ
50 changes: 50 additions & 0 deletions src/test/ui/type/issue-91268.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
error: this file contains an unclosed delimiter
--> $DIR/issue-91268.rs:9:12
|
LL | fn main() {
| - unclosed delimiter
LL | 0: u8(ţ
| - ^
| |
| unclosed delimiter

error: this file contains an unclosed delimiter
--> $DIR/issue-91268.rs:9:12
|
LL | fn main() {
| - unclosed delimiter
LL | 0: u8(ţ
| - ^
| |
| unclosed delimiter

error[E0412]: cannot find type `ţ` in this scope
--> $DIR/issue-91268.rs:9:11
|
LL | 0: u8(ţ
| ^ expecting a type here because of type ascription

error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
--> $DIR/issue-91268.rs:9:8
|
LL | 0: u8(ţ
| ^^^^ only `Fn` traits may use parentheses

error[E0109]: type arguments are not allowed for this type
--> $DIR/issue-91268.rs:9:11
|
LL | 0: u8(ţ
| ^ type argument not allowed

error[E0308]: mismatched types
--> $DIR/issue-91268.rs:9:5
|
LL | fn main() {
| - expected `()` because of default return type
LL | 0: u8(ţ
| ^^^^^^^ expected `()`, found `u8`

error: aborting due to 6 previous errors

Some errors have detailed explanations: E0109, E0214, E0308, E0412.
For more information about an error, try `rustc --explain E0109`.
21 changes: 21 additions & 0 deletions src/test/ui/union/issue-81199.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#[repr(C)]
union PtrRepr<T: ?Sized> {
const_ptr: *const T,
mut_ptr: *mut T,
components: PtrComponents<T>,
//~^ ERROR the trait bound
}

#[repr(C)]
struct PtrComponents<T: Pointee + ?Sized> {
data_address: *const (),
metadata: <T as Pointee>::Metadata,
}



pub trait Pointee {
type Metadata;
}

fn main() {}
29 changes: 29 additions & 0 deletions src/test/ui/union/issue-81199.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
error[E0277]: the trait bound `T: Pointee` is not satisfied in `PtrComponents<T>`
--> $DIR/issue-81199.rs:5:17
|
LL | components: PtrComponents<T>,
| ^^^^^^^^^^^^^^^^ within `PtrComponents<T>`, the trait `Pointee` is not implemented for `T`
|
note: required because it appears within the type `PtrComponents<T>`
--> $DIR/issue-81199.rs:10:8
|
LL | struct PtrComponents<T: Pointee + ?Sized> {
| ^^^^^^^^^^^^^
= note: no field of a union may have a dynamically sized type
= help: change the field's type to have a statically known size
help: consider further restricting this bound
|
LL | union PtrRepr<T: ?Sized + Pointee> {
| +++++++++
help: borrowed types always have a statically known size
|
LL | components: &PtrComponents<T>,
| +
help: the `Box` type always has a statically known size and allocates its contents in the heap
|
LL | components: Box<PtrComponents<T>>,
| ++++ +

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
5 changes: 4 additions & 1 deletion src/tools/rustfmt/.github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ on:
jobs:
test:
runs-on: ubuntu-latest
name: (${{ matrix.target }}, nightly)
name: (${{ matrix.target }}, ${{ matrix.cfg_release_channel }})
env:
CFG_RELEASE_CHANNEL: ${{ matrix.cfg_release_channel }}
strategy:
# https://help.github.com/en/actions/getting-started-with-github-actions/about-github-actions#usage-limits
# There's a limit of 60 concurrent jobs across all repos in the rust-lang organization.
Expand All @@ -20,6 +22,7 @@ jobs:
target: [
x86_64-unknown-linux-gnu,
]
cfg_release_channel: [nightly, stable]

steps:
- name: checkout
Expand Down
5 changes: 4 additions & 1 deletion src/tools/rustfmt/.github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ jobs:
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners#supported-runners-and-hardware-resources
# macOS Catalina 10.15
runs-on: macos-latest
name: (${{ matrix.target }}, nightly)
name: (${{ matrix.target }}, ${{ matrix.cfg_release_channel }})
env:
CFG_RELEASE_CHANNEL: ${{ matrix.cfg_release_channel }}
strategy:
fail-fast: false
matrix:
target: [
x86_64-apple-darwin,
]
cfg_release_channel: [nightly, stable]

steps:
- name: checkout
Expand Down
5 changes: 4 additions & 1 deletion src/tools/rustfmt/.github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ on:
jobs:
test:
runs-on: windows-latest
name: (${{ matrix.target }}, nightly)
name: (${{ matrix.target }}, ${{ matrix.cfg_release_channel }})
env:
CFG_RELEASE_CHANNEL: ${{ matrix.cfg_release_channel }}
strategy:
# https://help.github.com/en/actions/getting-started-with-github-actions/about-github-actions#usage-limits
# There's a limit of 60 concurrent jobs across all repos in the rust-lang organization.
Expand All @@ -23,6 +25,7 @@ jobs:
x86_64-pc-windows-gnu,
x86_64-pc-windows-msvc,
]
cfg_release_channel: [nightly, stable]

steps:
# The Windows runners have autocrlf enabled by default
Expand Down
Loading