Skip to content

Commit 7d6f948

Browse files
committed
Auto merge of #92556 - matthiaskrgr:rollup-s9vopuj, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #91754 (Modifications to `std::io::Stdin` on Windows so that there is no longer a 4-byte buffer minimum in read().) - #91884 (Constify `Box<T, A>` methods) - #92107 (Actually set IMAGE_SCN_LNK_REMOVE for .rmeta) - #92456 (Make the documentation of builtin macro attributes accessible) - #92507 (Suggest single quotes when char expected, str provided) - #92525 (intra-doc: Make `Receiver::into_iter` into a clickable link) - #92532 (revert #92254 "Bump gsgdt to 0.1.3") Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2b681ac + 76c0271 commit 7d6f948

File tree

24 files changed

+458
-86
lines changed

24 files changed

+458
-86
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1505,9 +1505,9 @@ dependencies = [
15051505

15061506
[[package]]
15071507
name = "gsgdt"
1508-
version = "0.1.3"
1508+
version = "0.1.2"
15091509
source = "registry+https://github.com/rust-lang/crates.io-index"
1510-
checksum = "cb958139bb971f37d2f5423436f137768f88b9c616b4c21d4f634dd129508d60"
1510+
checksum = "a0d876ce7262df96262a2a19531da6ff9a86048224d49580a585fc5c04617825"
15111511
dependencies = [
15121512
"serde",
15131513
]

compiler/rustc_codegen_ssa/src/back/metadata.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use std::path::Path;
66

77
use object::write::{self, StandardSegment, Symbol, SymbolSection};
88
use object::{
9-
elf, Architecture, BinaryFormat, Endianness, FileFlags, Object, ObjectSection, SectionFlags,
10-
SectionKind, SymbolFlags, SymbolKind, SymbolScope,
9+
elf, pe, Architecture, BinaryFormat, Endianness, FileFlags, Object, ObjectSection,
10+
SectionFlags, SectionKind, SymbolFlags, SymbolKind, SymbolScope,
1111
};
1212

1313
use snap::write::FrameEncoder;
@@ -216,13 +216,12 @@ pub fn create_rmeta_file(sess: &Session, metadata: &[u8]) -> Vec<u8> {
216216
);
217217
match file.format() {
218218
BinaryFormat::Coff => {
219-
const IMAGE_SCN_LNK_REMOVE: u32 = 0;
220219
file.section_mut(section).flags =
221-
SectionFlags::Coff { characteristics: IMAGE_SCN_LNK_REMOVE };
220+
SectionFlags::Coff { characteristics: pe::IMAGE_SCN_LNK_REMOVE };
222221
}
223222
BinaryFormat::Elf => {
224-
const SHF_EXCLUDE: u64 = 0x80000000;
225-
file.section_mut(section).flags = SectionFlags::Elf { sh_flags: SHF_EXCLUDE };
223+
file.section_mut(section).flags =
224+
SectionFlags::Elf { sh_flags: elf::SHF_EXCLUDE as u64 };
226225
}
227226
_ => {}
228227
};

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+38-3
Original file line numberDiff line numberDiff line change
@@ -2041,11 +2041,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
20412041
if let ValuePairs::Types(ty::error::ExpectedFound { expected, found }) =
20422042
trace.values
20432043
{
2044-
// If a tuple of length one was expected and the found expression has
2045-
// parentheses around it, perhaps the user meant to write `(expr,)` to
2046-
// build a tuple (issue #86100)
20472044
match (expected.kind(), found.kind()) {
20482045
(ty::Tuple(_), ty::Tuple(_)) => {}
2046+
// If a tuple of length one was expected and the found expression has
2047+
// parentheses around it, perhaps the user meant to write `(expr,)` to
2048+
// build a tuple (issue #86100)
20492049
(ty::Tuple(_), _) if expected.tuple_fields().count() == 1 => {
20502050
if let Ok(code) = self.tcx.sess().source_map().span_to_snippet(span) {
20512051
if let Some(code) =
@@ -2060,6 +2060,41 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
20602060
}
20612061
}
20622062
}
2063+
// If a character was expected and the found expression is a string literal
2064+
// containing a single character, perhaps the user meant to write `'c'` to
2065+
// specify a character literal (issue #92479)
2066+
(ty::Char, ty::Ref(_, r, _)) if r.is_str() => {
2067+
if let Ok(code) = self.tcx.sess().source_map().span_to_snippet(span) {
2068+
if let Some(code) =
2069+
code.strip_prefix('"').and_then(|s| s.strip_suffix('"'))
2070+
{
2071+
if code.chars().nth(1).is_none() {
2072+
err.span_suggestion(
2073+
span,
2074+
"if you meant to write a `char` literal, use single quotes",
2075+
format!("'{}'", code),
2076+
Applicability::MachineApplicable,
2077+
);
2078+
}
2079+
}
2080+
}
2081+
}
2082+
// If a string was expected and the found expression is a character literal,
2083+
// perhaps the user meant to write `"s"` to specify a string literal.
2084+
(ty::Ref(_, r, _), ty::Char) if r.is_str() => {
2085+
if let Ok(code) = self.tcx.sess().source_map().span_to_snippet(span) {
2086+
if let Some(code) =
2087+
code.strip_prefix('\'').and_then(|s| s.strip_suffix('\''))
2088+
{
2089+
err.span_suggestion(
2090+
span,
2091+
"if you meant to write a `str` literal, use double quotes",
2092+
format!("\"{}\"", code),
2093+
Applicability::MachineApplicable,
2094+
);
2095+
}
2096+
}
2097+
}
20632098
_ => {}
20642099
}
20652100
}

compiler/rustc_middle/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ doctest = false
1010
rustc_arena = { path = "../rustc_arena" }
1111
bitflags = "1.2.1"
1212
either = "1.5.0"
13-
gsgdt = "0.1.3"
13+
gsgdt = "0.1.2"
1414
tracing = "0.1"
1515
rustc-rayon = "0.3.1"
1616
rustc-rayon-core = "0.3.1"

compiler/rustc_middle/src/mir/generic_graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn bb_to_graph_node(block: BasicBlock, body: &Body<'_>, dark_mode: bool) -> Node
5555
data.terminator().kind.fmt_head(&mut terminator_head).unwrap();
5656
stmts.push(terminator_head);
5757

58-
Node::from_list(stmts, label, title, style)
58+
Node::new(stmts, label, title, style)
5959
}
6060

6161
// Must match `[0-9A-Za-z_]*`. This does not appear in the rendered graph, so

library/alloc/src/alloc.rs

+18-5
Original file line numberDiff line numberDiff line change
@@ -323,17 +323,21 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
323323

324324
#[cfg_attr(not(test), lang = "box_free")]
325325
#[inline]
326+
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
326327
// This signature has to be the same as `Box`, otherwise an ICE will happen.
327328
// When an additional parameter to `Box` is added (like `A: Allocator`), this has to be added here as
328329
// well.
329330
// For example if `Box` is changed to `struct Box<T: ?Sized, A: Allocator>(Unique<T>, A)`,
330331
// this function has to be changed to `fn box_free<T: ?Sized, A: Allocator>(Unique<T>, A)` as well.
331-
pub(crate) unsafe fn box_free<T: ?Sized, A: Allocator>(ptr: Unique<T>, alloc: A) {
332+
pub(crate) const unsafe fn box_free<T: ?Sized, A: ~const Allocator + ~const Drop>(
333+
ptr: Unique<T>,
334+
alloc: A,
335+
) {
332336
unsafe {
333337
let size = size_of_val(ptr.as_ref());
334338
let align = min_align_of_val(ptr.as_ref());
335339
let layout = Layout::from_size_align_unchecked(size, align);
336-
alloc.deallocate(ptr.cast().into(), layout)
340+
alloc.deallocate(From::from(ptr.cast()), layout)
337341
}
338342
}
339343

@@ -361,13 +365,22 @@ extern "Rust" {
361365
/// [`set_alloc_error_hook`]: ../../std/alloc/fn.set_alloc_error_hook.html
362366
/// [`take_alloc_error_hook`]: ../../std/alloc/fn.take_alloc_error_hook.html
363367
#[stable(feature = "global_alloc", since = "1.28.0")]
368+
#[rustc_const_unstable(feature = "const_alloc_error", issue = "92523")]
364369
#[cfg(all(not(no_global_oom_handling), not(test)))]
365370
#[rustc_allocator_nounwind]
366371
#[cold]
367-
pub fn handle_alloc_error(layout: Layout) -> ! {
368-
unsafe {
369-
__rust_alloc_error_handler(layout.size(), layout.align());
372+
pub const fn handle_alloc_error(layout: Layout) -> ! {
373+
const fn ct_error(_: Layout) -> ! {
374+
panic!("allocation failed");
370375
}
376+
377+
fn rt_error(layout: Layout) -> ! {
378+
unsafe {
379+
__rust_alloc_error_handler(layout.size(), layout.align());
380+
}
381+
}
382+
383+
unsafe { core::intrinsics::const_eval_select((layout,), ct_error, rt_error) }
371384
}
372385

373386
// For alloc test `std::alloc::handle_alloc_error` can be used directly.

0 commit comments

Comments
 (0)