Skip to content
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

Rollup of 10 pull requests #77797

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e4943ac
Link to documentation-specific guidelines.
follower Sep 25, 2020
176b965
Link Vec leak doc to Box
pickfire Oct 8, 2020
bd49ded
Noticed a potential bug in `eat_while()`: it doesn't account for numb…
Oct 9, 2020
6cd9b88
fix __rust_alloc_error_handler comment
RalfJung Oct 9, 2020
1911d21
also extend global allocator comment
RalfJung Oct 9, 2020
b6bedc8
rename __default_lib_allocator -> __default_alloc_error_handler
RalfJung Oct 9, 2020
0c97c24
Remove some dead code in windows-gnu std
mati865 Oct 8, 2020
8818fda
Remove useless `all` in cfg
mati865 Oct 8, 2020
19e7095
require `Reveal::All` in `normalize_erasing_regions`
lcnr Oct 9, 2020
f200c1e
doc: disambiguate stat in MetadataExt::as_raw_stat
cuviper Oct 10, 2020
55e92f9
Fix typo in error code description
naoki-hayama Oct 10, 2020
d2ca0c4
Update `changelog-seen` in config.toml.example
jyn514 Oct 10, 2020
66369a6
Alloc vec doc mention cannot undo leak
pickfire Oct 10, 2020
8688fa8
Improve vec leak wording
pickfire Oct 10, 2020
2224e26
Clarify the debug-related values should take boolean
JohnTitor Oct 9, 2020
9f28bd6
Rollup merge of #77195 - follower:patch-2, r=jyn514
JohnTitor Oct 10, 2020
094c25a
Rollup merge of #77629 - Julian-Wollersberger:recomputeRawStrError, r…
JohnTitor Oct 10, 2020
b8d39e1
Rollup merge of #77709 - pickfire:patch-1, r=jyn514
JohnTitor Oct 10, 2020
21e2a17
Rollup merge of #77738 - RalfJung:alloc-error-handler-comment, r=Amanieu
JohnTitor Oct 10, 2020
5e61a07
Rollup merge of #77748 - mati865:dead-code-cleanup, r=petrochenkov
JohnTitor Oct 10, 2020
52db1e9
Rollup merge of #77752 - lcnr:normalize-assert, r=oli-obk
JohnTitor Oct 10, 2020
991583e
Rollup merge of #77766 - JohnTitor:fix-debug-config, r=jyn514
JohnTitor Oct 10, 2020
e93bfae
Rollup merge of #77777 - cuviper:doc-stat, r=jonas-schievink
JohnTitor Oct 10, 2020
9e7e0e7
Rollup merge of #77782 - nhayama:fix-typo, r=jonas-schievink
JohnTitor Oct 10, 2020
bf15d18
Rollup merge of #77787 - jyn514:consistent-versions, r=spastorino
JohnTitor Oct 10, 2020
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
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes/E0424.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl Foo {
The `self` keyword can only be used inside methods, which are associated
functions (functions defined inside of a `trait` or `impl` block) that have a
`self` receiver as its first parameter, like `self`, `&self`, `&mut self` or
`self: &mut Pin<Self>` (this last one is an example of an ["abitrary `self`
`self: &mut Pin<Self>` (this last one is an example of an ["arbitrary `self`
type"](https://github.com/rust-lang/rust/issues/44874)).

Check if the associated function's parameter list should have contained a `self`
Expand Down
34 changes: 14 additions & 20 deletions compiler/rustc_lexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl Token {
}

/// Enum representing common lexeme types.
// perf note: Changing all `usize` to `u32` doesn't change performance. See #77629
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum TokenKind {
// Multi-char tokens:
Expand Down Expand Up @@ -160,6 +161,7 @@ pub enum LiteralKind {
/// - `r##~"abcde"##`: `InvalidStarter`
/// - `r###"abcde"##`: `NoTerminator { expected: 3, found: 2, possible_terminator_offset: Some(11)`
/// - Too many `#`s (>65535): `TooManyDelimiters`
// perf note: It doesn't matter that this makes `Token` 36 bytes bigger. See #77629
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum RawStrError {
/// Non `#` characters exist between `r` and `"` eg. `r#~"..`
Expand Down Expand Up @@ -689,7 +691,12 @@ impl Cursor<'_> {
let mut max_hashes = 0;

// Count opening '#' symbols.
let n_start_hashes = self.eat_while(|c| c == '#');
let mut eaten = 0;
while self.first() == '#' {
eaten += 1;
self.bump();
}
let n_start_hashes = eaten;

// Check that string is started.
match self.bump() {
Expand Down Expand Up @@ -724,16 +731,11 @@ impl Cursor<'_> {
// Note that this will not consume extra trailing `#` characters:
// `r###"abcde"####` is lexed as a `RawStr { n_hashes: 3 }`
// followed by a `#` token.
let mut hashes_left = n_start_hashes;
let is_closing_hash = |c| {
if c == '#' && hashes_left != 0 {
hashes_left -= 1;
true
} else {
false
}
};
let n_end_hashes = self.eat_while(is_closing_hash);
let mut n_end_hashes = 0;
while self.first() == '#' && n_end_hashes < n_start_hashes {
n_end_hashes += 1;
self.bump();
}

if n_end_hashes == n_start_hashes {
return (n_start_hashes, None);
Expand Down Expand Up @@ -807,17 +809,9 @@ impl Cursor<'_> {
}

/// Eats symbols while predicate returns true or until the end of file is reached.
/// Returns amount of eaten symbols.
fn eat_while<F>(&mut self, mut predicate: F) -> usize
where
F: FnMut(char) -> bool,
{
let mut eaten: usize = 0;
fn eat_while(&mut self, mut predicate: impl FnMut(char) -> bool) {
while predicate(self.first()) && !self.is_eof() {
eaten += 1;
self.bump();
}

eaten
}
}
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/ty/normalize_erasing_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ impl<'tcx> TyCtxt<'tcx> {
value,
param_env,
);
debug_assert_eq!(param_env.reveal(), ty::Reveal::All);

// Erase first before we do the real query -- this keeps the
// cache from being too polluted.
Expand Down
8 changes: 4 additions & 4 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# If it does not match the version that is currently running,
# `x.py` will prompt you to update it and read the changelog.
# See `src/bootstrap/CHANGELOG.md` for more information.
changelog-seen = 1
changelog-seen = 2

# =============================================================================
# Global Settings
Expand Down Expand Up @@ -370,13 +370,13 @@ changelog-seen = 1
# binary, otherwise they are omitted.
#
# Defaults to rust.debug value
#debug-assertions = debug
#debug-assertions = rust.debug (boolean)

# Whether or not debug assertions are enabled for the standard library.
# Overrides the `debug-assertions` option, if defined.
#
# Defaults to rust.debug-assertions value
#debug-assertions-std = debug-assertions
#debug-assertions-std = rust.debug-assertions (boolean)

# Whether or not to leave debug! and trace! calls in the rust binary.
# Overrides the `debug-assertions` option, if defined.
Expand All @@ -386,7 +386,7 @@ changelog-seen = 1
# If you see a message from `tracing` saying
# `max_level_info` is enabled and means logging won't be shown,
# set this value to `true`.
#debug-logging = debug-assertions
#debug-logging = rust.debug-assertions (boolean)

# Debuginfo level for most of Rust code, corresponds to the `-C debuginfo=N` option of `rustc`.
# `0` - no debug info
Expand Down
19 changes: 14 additions & 5 deletions library/alloc/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ mod tests;

extern "Rust" {
// These are the magic symbols to call the global allocator. rustc generates
// them from the `#[global_allocator]` attribute if there is one, or uses the
// default implementations in libstd (`__rdl_alloc` etc in `src/libstd/alloc.rs`)
// them to call `__rg_alloc` etc if there is a `#[global_allocator]` attribute
// (the code expanding that attribute macro generates those functions), or to call
// the default implementations in libstd (`__rdl_alloc` etc in `src/libstd/alloc.rs`)
// otherwise.
#[rustc_allocator]
#[rustc_allocator_nounwind]
Expand All @@ -26,8 +27,6 @@ extern "Rust" {
fn __rust_realloc(ptr: *mut u8, old_size: usize, align: usize, new_size: usize) -> *mut u8;
#[rustc_allocator_nounwind]
fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8;
#[rustc_allocator_nounwind]
fn __rust_alloc_error_handler(size: usize, align: usize) -> !;
}

/// The global memory allocator.
Expand Down Expand Up @@ -323,6 +322,16 @@ pub(crate) unsafe fn box_free<T: ?Sized>(ptr: Unique<T>) {
}
}

// # Allocation error handler

extern "Rust" {
// This is the magic symbol to call the global alloc error handler. rustc generates
// it to call `__rg_oom` if there is a `#[alloc_error_handler]`, or to call the
// default implementations below (`__rdl_oom`) otherwise.
#[rustc_allocator_nounwind]
fn __rust_alloc_error_handler(size: usize, align: usize) -> !;
}

/// Abort on memory allocation error or failure.
///
/// Callers of memory allocation APIs wishing to abort computation
Expand Down Expand Up @@ -367,7 +376,7 @@ pub fn handle_alloc_error(layout: Layout) -> ! {
#[doc(hidden)]
#[allow(unused_attributes)]
#[unstable(feature = "alloc_internals", issue = "none")]
pub mod __default_lib_allocator {
pub mod __alloc_error_handler {
use crate::alloc::Layout;

// called via generated `__rust_alloc_error_handler`
Expand Down
3 changes: 2 additions & 1 deletion library/alloc/src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,8 @@ impl<T> Vec<T> {
/// `'a`. If the type has only static references, or none at all, then this
/// may be chosen to be `'static`.
///
/// This function is similar to the `leak` function on `Box`.
/// This function is similar to the [`leak`][Box::leak] function on [`Box`]
/// except that there is no way to recover the leaked memory.
///
/// This function is mainly useful for data that lives for the remainder of
/// the program's life. Dropping the returned reference will cause a memory
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
//! # Contributing changes to the documentation
//!
//! Check out the rust contribution guidelines [here](
//! https://rustc-dev-guide.rust-lang.org/getting-started.html).
//! https://rustc-dev-guide.rust-lang.org/contributing.html#writing-documentation).
//! The source for this documentation can be found on
//! [GitHub](https://github.com/rust-lang/rust).
//! To contribute changes, make sure you read the guidelines first, then submit
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/os/linux/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub trait MetadataExt {
/// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
/// cross-Unix abstractions contained within the raw stat.
///
/// [`stat`]: crate::os::linux::raw::stat
/// [`stat`]: struct@crate::os::linux::raw::stat
///
/// # Examples
///
Expand Down
11 changes: 0 additions & 11 deletions library/std/src/sys/windows/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ pub type LPWCH = *mut WCHAR;
pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW;
pub type LPWSADATA = *mut WSADATA;
pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO;
pub type LPSTR = *mut CHAR;
pub type LPWSTR = *mut WCHAR;
pub type LPFILETIME = *mut FILETIME;
pub type LPWSABUF = *mut WSABUF;
Expand Down Expand Up @@ -876,16 +875,6 @@ extern "system" {
pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL;
pub fn GetCurrentDirectoryW(nBufferLength: DWORD, lpBuffer: LPWSTR) -> DWORD;
pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL;
pub fn WideCharToMultiByte(
CodePage: UINT,
dwFlags: DWORD,
lpWideCharStr: LPCWSTR,
cchWideChar: c_int,
lpMultiByteStr: LPSTR,
cbMultiByte: c_int,
lpDefaultChar: LPCSTR,
lpUsedDefaultChar: LPBOOL,
) -> c_int;

pub fn closesocket(socket: SOCKET) -> c_int;
pub fn recv(socket: SOCKET, buf: *mut c_void, len: c_int, flags: c_int) -> c_int;
Expand Down
53 changes: 0 additions & 53 deletions library/std/src/sys/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::ffi::{OsStr, OsString};
use crate::io::ErrorKind;
use crate::os::windows::ffi::{OsStrExt, OsStringExt};
use crate::path::PathBuf;
use crate::ptr;
use crate::time::Duration;

pub use self::rand::hashmap_random_keys;
Expand Down Expand Up @@ -206,58 +205,6 @@ fn os2path(s: &[u16]) -> PathBuf {
PathBuf::from(OsString::from_wide(s))
}

#[allow(dead_code)] // Only used in backtrace::gnu::get_executable_filename()
fn wide_char_to_multi_byte(
code_page: u32,
flags: u32,
s: &[u16],
no_default_char: bool,
) -> crate::io::Result<Vec<i8>> {
unsafe {
let mut size = c::WideCharToMultiByte(
code_page,
flags,
s.as_ptr(),
s.len() as i32,
ptr::null_mut(),
0,
ptr::null(),
ptr::null_mut(),
);
if size == 0 {
return Err(crate::io::Error::last_os_error());
}

let mut buf = Vec::with_capacity(size as usize);
buf.set_len(size as usize);

let mut used_default_char = c::FALSE;
size = c::WideCharToMultiByte(
code_page,
flags,
s.as_ptr(),
s.len() as i32,
buf.as_mut_ptr(),
buf.len() as i32,
ptr::null(),
if no_default_char { &mut used_default_char } else { ptr::null_mut() },
);
if size == 0 {
return Err(crate::io::Error::last_os_error());
}
if no_default_char && used_default_char == c::TRUE {
return Err(crate::io::Error::new(
crate::io::ErrorKind::InvalidData,
"string cannot be converted to requested code page",
));
}

buf.set_len(size as usize);

Ok(buf)
}
}

pub fn truncate_utf16_at_nul(v: &[u16]) -> &[u16] {
match unrolled_find_u16s(0, v) {
// don't include the 0
Expand Down
2 changes: 1 addition & 1 deletion library/unwind/src/libunwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ extern "C" {
}

cfg_if::cfg_if! {
if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm"))))] {
if #[cfg(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm")))] {
// Not ARM EHABI
#[repr(C)]
#[derive(Copy, Clone, PartialEq)]
Expand Down