Skip to content

Commit 561b5de

Browse files
committedMay 3, 2024
Auto merge of #124646 - matthiaskrgr:rollup-crlsvg5, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #123480 (deref patterns: impl `DerefPure` for more std types) - #124412 (io safety: update Unix explanation to use `Arc`) - #124441 (String.truncate comment microfix (greater or equal)) - #124594 (run-make-support: preserve tooks.mk behavior for EXTRACXXFLAGS) - #124604 (library/std: Remove unused `gimli-symbolize` feature) - #124607 (`rustc_expand` cleanups) - #124609 (variable-precision float operations can differ depending on optimization levels) - #124610 (Tweak `consts_may_unify`) - #124626 (const_eval_select: add tracking issue) - #124637 (AST pretty: Use `builtin_syntax` for type ascription) Failed merges: - #124638 (Move some tests from `rustc_expand` to `rustc_parse`.) r? `@ghost` `@rustbot` modify labels: rollup
·
1.90.01.80.0
2 parents 79734f1 + e6c82d9 commit 561b5de

File tree

26 files changed

+376
-323
lines changed

26 files changed

+376
-323
lines changed
 

‎compiler/rustc_ast/src/ast.rs‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ pub struct StructExpr {
13901390
// Adding a new variant? Please update `test_expr` in `tests/ui/macros/stringify.rs`.
13911391
#[derive(Clone, Encodable, Decodable, Debug)]
13921392
pub enum ExprKind {
1393-
/// An array (`[a, b, c, d]`)
1393+
/// An array (e.g, `[a, b, c, d]`).
13941394
Array(ThinVec<P<Expr>>),
13951395
/// Allow anonymous constants from an inline `const` block
13961396
ConstBlock(AnonConst),
@@ -1401,7 +1401,7 @@ pub enum ExprKind {
14011401
/// This also represents calling the constructor of
14021402
/// tuple-like ADTs such as tuple structs and enum variants.
14031403
Call(P<Expr>, ThinVec<P<Expr>>),
1404-
/// A method call (e.g. `x.foo::<Bar, Baz>(a, b, c)`).
1404+
/// A method call (e.g., `x.foo::<Bar, Baz>(a, b, c)`).
14051405
MethodCall(Box<MethodCall>),
14061406
/// A tuple (e.g., `(a, b, c, d)`).
14071407
Tup(ThinVec<P<Expr>>),
@@ -1413,7 +1413,10 @@ pub enum ExprKind {
14131413
Lit(token::Lit),
14141414
/// A cast (e.g., `foo as f64`).
14151415
Cast(P<Expr>, P<Ty>),
1416-
/// A type ascription (e.g., `42: usize`).
1416+
/// A type ascription (e.g., `builtin # type_ascribe(42, usize)`).
1417+
///
1418+
/// Usually not written directly in user code but
1419+
/// indirectly via the macro `type_ascribe!(...)`.
14171420
Type(P<Expr>, P<Ty>),
14181421
/// A `let pat = expr` expression that is only semantically allowed in the condition
14191422
/// of `if` / `while` expressions. (e.g., `if let 0 = x { .. }`).
@@ -1488,7 +1491,10 @@ pub enum ExprKind {
14881491
/// Output of the `asm!()` macro.
14891492
InlineAsm(P<InlineAsm>),
14901493

1491-
/// Output of the `offset_of!()` macro.
1494+
/// An `offset_of` expression (e.g., `builtin # offset_of(Struct, field)`).
1495+
///
1496+
/// Usually not written directly in user code but
1497+
/// indirectly via the macro `core::mem::offset_of!(...)`.
14921498
OffsetOf(P<Ty>, P<[Ident]>),
14931499

14941500
/// A macro invocation; pre-expansion.

‎compiler/rustc_ast_pretty/src/pprust/state/expr.rs‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ impl<'a> State<'a> {
422422
self.print_type(ty);
423423
}
424424
ast::ExprKind::Type(expr, ty) => {
425-
self.word("type_ascribe!(");
425+
self.word("builtin # type_ascribe");
426+
self.popen();
426427
self.ibox(0);
427428
self.print_expr(expr, FixupContext::default());
428429

@@ -431,7 +432,7 @@ impl<'a> State<'a> {
431432
self.print_type(ty);
432433

433434
self.end();
434-
self.word(")");
435+
self.pclose();
435436
}
436437
ast::ExprKind::Let(pat, scrutinee, _, _) => {
437438
self.print_let(pat, scrutinee, fixup);
@@ -657,15 +658,15 @@ impl<'a> State<'a> {
657658
);
658659
}
659660
ast::ExprKind::InlineAsm(a) => {
660-
// FIXME: This should have its own syntax, distinct from a macro invocation.
661+
// FIXME: Print `builtin # asm` once macro `asm` uses `builtin_syntax`.
661662
self.word("asm!");
662663
self.print_inline_asm(a);
663664
}
664665
ast::ExprKind::FormatArgs(fmt) => {
665-
// FIXME: This should have its own syntax, distinct from a macro invocation.
666+
// FIXME: Print `builtin # format_args` once macro `format_args` uses `builtin_syntax`.
666667
self.word("format_args!");
667668
self.popen();
668-
self.rbox(0, Inconsistent);
669+
self.ibox(0);
669670
self.word(reconstruct_format_args_template_string(&fmt.template));
670671
for arg in fmt.arguments.all_args() {
671672
self.word_space(",");
@@ -677,7 +678,7 @@ impl<'a> State<'a> {
677678
ast::ExprKind::OffsetOf(container, fields) => {
678679
self.word("builtin # offset_of");
679680
self.popen();
680-
self.rbox(0, Inconsistent);
681+
self.ibox(0);
681682
self.print_type(container);
682683
self.word(",");
683684
self.space();
@@ -690,8 +691,8 @@ impl<'a> State<'a> {
690691
self.print_ident(field);
691692
}
692693
}
693-
self.pclose();
694694
self.end();
695+
self.pclose();
695696
}
696697
ast::ExprKind::MacCall(m) => self.print_mac(m),
697698
ast::ExprKind::Paren(e) => {

‎compiler/rustc_ast_pretty/src/pprust/state/item.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ impl<'a> State<'a> {
238238
self.bclose(item.span, empty);
239239
}
240240
ast::ItemKind::GlobalAsm(asm) => {
241+
// FIXME: Print `builtin # global_asm` once macro `global_asm` uses `builtin_syntax`.
241242
self.head(visibility_qualified(&item.vis, "global_asm!"));
242243
self.print_inline_asm(asm);
243244
self.word(";");

‎compiler/rustc_expand/src/base.rs‎

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_session::config::CollapseMacroDebuginfo;
2121
use rustc_session::{parse::ParseSess, Limit, Session};
2222
use rustc_span::def_id::{CrateNum, DefId, LocalDefId};
2323
use rustc_span::edition::Edition;
24-
use rustc_span::hygiene::{AstPass, ExpnData, ExpnKind, LocalExpnId};
24+
use rustc_span::hygiene::{AstPass, ExpnData, ExpnKind, LocalExpnId, MacroKind};
2525
use rustc_span::source_map::SourceMap;
2626
use rustc_span::symbol::{kw, sym, Ident, Symbol};
2727
use rustc_span::{FileName, Span, DUMMY_SP};
@@ -32,8 +32,6 @@ use std::path::{Path, PathBuf};
3232
use std::rc::Rc;
3333
use thin_vec::ThinVec;
3434

35-
pub(crate) use rustc_span::hygiene::MacroKind;
36-
3735
// When adding new variants, make sure to
3836
// adjust the `visit_*` / `flat_map_*` calls in `InvocationCollector`
3937
// to use `assign_id!`
@@ -573,35 +571,6 @@ impl DummyResult {
573571
tokens: None,
574572
})
575573
}
576-
577-
/// A plain dummy pattern.
578-
pub fn raw_pat(sp: Span) -> ast::Pat {
579-
ast::Pat { id: ast::DUMMY_NODE_ID, kind: PatKind::Wild, span: sp, tokens: None }
580-
}
581-
582-
/// A plain dummy type.
583-
pub fn raw_ty(sp: Span) -> P<ast::Ty> {
584-
// FIXME(nnethercote): you might expect `ast::TyKind::Dummy` to be used here, but some
585-
// values produced here end up being lowered to HIR, which `ast::TyKind::Dummy` does not
586-
// support, so we use an empty tuple instead.
587-
P(ast::Ty {
588-
id: ast::DUMMY_NODE_ID,
589-
kind: ast::TyKind::Tup(ThinVec::new()),
590-
span: sp,
591-
tokens: None,
592-
})
593-
}
594-
595-
/// A plain dummy crate.
596-
pub fn raw_crate() -> ast::Crate {
597-
ast::Crate {
598-
attrs: Default::default(),
599-
items: Default::default(),
600-
spans: Default::default(),
601-
id: ast::DUMMY_NODE_ID,
602-
is_placeholder: Default::default(),
603-
}
604-
}
605574
}
606575

607576
impl MacResult for DummyResult {
@@ -610,7 +579,12 @@ impl MacResult for DummyResult {
610579
}
611580

612581
fn make_pat(self: Box<DummyResult>) -> Option<P<ast::Pat>> {
613-
Some(P(DummyResult::raw_pat(self.span)))
582+
Some(P(ast::Pat {
583+
id: ast::DUMMY_NODE_ID,
584+
kind: PatKind::Wild,
585+
span: self.span,
586+
tokens: None,
587+
}))
614588
}
615589

616590
fn make_items(self: Box<DummyResult>) -> Option<SmallVec<[P<ast::Item>; 1]>> {
@@ -638,7 +612,15 @@ impl MacResult for DummyResult {
638612
}
639613

640614
fn make_ty(self: Box<DummyResult>) -> Option<P<ast::Ty>> {
641-
Some(DummyResult::raw_ty(self.span))
615+
// FIXME(nnethercote): you might expect `ast::TyKind::Dummy` to be used here, but some
616+
// values produced here end up being lowered to HIR, which `ast::TyKind::Dummy` does not
617+
// support, so we use an empty tuple instead.
618+
Some(P(ast::Ty {
619+
id: ast::DUMMY_NODE_ID,
620+
kind: ast::TyKind::Tup(ThinVec::new()),
621+
span: self.span,
622+
tokens: None,
623+
}))
642624
}
643625

644626
fn make_arms(self: Box<DummyResult>) -> Option<SmallVec<[ast::Arm; 1]>> {
@@ -670,7 +652,13 @@ impl MacResult for DummyResult {
670652
}
671653

672654
fn make_crate(self: Box<DummyResult>) -> Option<ast::Crate> {
673-
Some(DummyResult::raw_crate())
655+
Some(ast::Crate {
656+
attrs: Default::default(),
657+
items: Default::default(),
658+
spans: Default::default(),
659+
id: ast::DUMMY_NODE_ID,
660+
is_placeholder: Default::default(),
661+
})
674662
}
675663
}
676664

‎compiler/rustc_expand/src/build.rs‎

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,6 @@ impl<'a> ExtCtxt<'a> {
175175
ast::Stmt { id: ast::DUMMY_NODE_ID, span: expr.span, kind: ast::StmtKind::Expr(expr) }
176176
}
177177

178-
pub fn stmt_let_pat(&self, sp: Span, pat: P<ast::Pat>, ex: P<ast::Expr>) -> ast::Stmt {
179-
let local = P(ast::Local {
180-
pat,
181-
ty: None,
182-
id: ast::DUMMY_NODE_ID,
183-
kind: LocalKind::Init(ex),
184-
span: sp,
185-
colon_sp: None,
186-
attrs: AttrVec::new(),
187-
tokens: None,
188-
});
189-
self.stmt_local(local, sp)
190-
}
191-
192178
pub fn stmt_let(&self, sp: Span, mutbl: bool, ident: Ident, ex: P<ast::Expr>) -> ast::Stmt {
193179
self.stmt_let_ty(sp, mutbl, ident, None, ex)
194180
}
@@ -278,10 +264,6 @@ impl<'a> ExtCtxt<'a> {
278264
self.expr_ident(span, Ident::with_dummy_span(kw::SelfLower))
279265
}
280266

281-
pub fn expr_field(&self, span: Span, expr: P<Expr>, field: Ident) -> P<ast::Expr> {
282-
self.expr(span, ast::ExprKind::Field(expr, field))
283-
}
284-
285267
pub fn expr_macro_call(&self, span: Span, call: P<ast::MacCall>) -> P<ast::Expr> {
286268
self.expr(span, ast::ExprKind::MacCall(call))
287269
}
@@ -394,11 +376,6 @@ impl<'a> ExtCtxt<'a> {
394376
self.expr(span, ast::ExprKind::Lit(lit))
395377
}
396378

397-
pub fn expr_char(&self, span: Span, ch: char) -> P<ast::Expr> {
398-
let lit = token::Lit::new(token::Char, literal::escape_char_symbol(ch), None);
399-
self.expr(span, ast::ExprKind::Lit(lit))
400-
}
401-
402379
pub fn expr_byte_str(&self, span: Span, bytes: Vec<u8>) -> P<ast::Expr> {
403380
let lit = token::Lit::new(token::ByteStr, literal::escape_byte_str_symbol(&bytes), None);
404381
self.expr(span, ast::ExprKind::Lit(lit))
@@ -414,10 +391,6 @@ impl<'a> ExtCtxt<'a> {
414391
self.expr_addr_of(sp, self.expr_array(sp, exprs))
415392
}
416393

417-
pub fn expr_cast(&self, sp: Span, expr: P<ast::Expr>, ty: P<ast::Ty>) -> P<ast::Expr> {
418-
self.expr(sp, ast::ExprKind::Cast(expr, ty))
419-
}
420-
421394
pub fn expr_some(&self, sp: Span, expr: P<ast::Expr>) -> P<ast::Expr> {
422395
let some = self.std_path(&[sym::option, sym::Option, sym::Some]);
423396
self.expr_call_global(sp, some, thin_vec![expr])

‎compiler/rustc_expand/src/config.rs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,11 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) -
9999
// If the declared feature is unstable, record it.
100100
if let Some(f) = UNSTABLE_FEATURES.iter().find(|f| name == f.feature.name) {
101101
(f.set_enabled)(&mut features);
102-
// When the ICE comes from core, alloc or std (approximation of the standard library), there's a chance
103-
// that the person hitting the ICE may be using -Zbuild-std or similar with an untested target.
104-
// The bug is probably in the standard library and not the compiler in that case, but that doesn't
105-
// really matter - we want a bug report.
102+
// When the ICE comes from core, alloc or std (approximation of the standard
103+
// library), there's a chance that the person hitting the ICE may be using
104+
// -Zbuild-std or similar with an untested target. The bug is probably in the
105+
// standard library and not the compiler in that case, but that doesn't really
106+
// matter - we want a bug report.
106107
if features.internal(name)
107108
&& ![sym::core, sym::alloc, sym::std].contains(&crate_name)
108109
{

‎compiler/rustc_expand/src/expand.rs‎

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::errors::{
44
IncompleteParse, RecursionLimitReached, RemoveExprNotSupported, RemoveNodeNotSupported,
55
UnsupportedKeyValue, WrongFragmentKind,
66
};
7-
use crate::hygiene::SyntaxContext;
87
use crate::mbe::diagnostics::annotate_err_with_kind;
98
use crate::module::{mod_dir_path, parse_external_mod, DirOwnership, ParsedExternalMod};
109
use crate::placeholders::{placeholder, PlaceholderExpander};
@@ -32,6 +31,7 @@ use rustc_session::lint::builtin::{UNUSED_ATTRIBUTES, UNUSED_DOC_COMMENTS};
3231
use rustc_session::lint::BuiltinLintDiag;
3332
use rustc_session::parse::feature_err;
3433
use rustc_session::{Limit, Session};
34+
use rustc_span::hygiene::SyntaxContext;
3535
use rustc_span::symbol::{sym, Ident};
3636
use rustc_span::{ErrorGuaranteed, FileName, LocalExpnId, Span};
3737

@@ -87,7 +87,7 @@ macro_rules! ast_fragments {
8787
}
8888

8989
impl AstFragment {
90-
pub fn add_placeholders(&mut self, placeholders: &[NodeId]) {
90+
fn add_placeholders(&mut self, placeholders: &[NodeId]) {
9191
if placeholders.is_empty() {
9292
return;
9393
}
@@ -100,14 +100,14 @@ macro_rules! ast_fragments {
100100
}
101101
}
102102

103-
pub fn make_opt_expr(self) -> Option<P<ast::Expr>> {
103+
pub(crate) fn make_opt_expr(self) -> Option<P<ast::Expr>> {
104104
match self {
105105
AstFragment::OptExpr(expr) => expr,
106106
_ => panic!("AstFragment::make_* called on the wrong kind of fragment"),
107107
}
108108
}
109109

110-
pub fn make_method_receiver_expr(self) -> P<ast::Expr> {
110+
pub(crate) fn make_method_receiver_expr(self) -> P<ast::Expr> {
111111
match self {
112112
AstFragment::MethodReceiverExpr(expr) => expr,
113113
_ => panic!("AstFragment::make_* called on the wrong kind of fragment"),
@@ -125,7 +125,7 @@ macro_rules! ast_fragments {
125125
T::fragment_to_output(self)
126126
}
127127

128-
pub fn mut_visit_with<F: MutVisitor>(&mut self, vis: &mut F) {
128+
pub(crate) fn mut_visit_with<F: MutVisitor>(&mut self, vis: &mut F) {
129129
match self {
130130
AstFragment::OptExpr(opt_expr) => {
131131
visit_clobber(opt_expr, |opt_expr| {
@@ -372,6 +372,14 @@ impl Invocation {
372372
InvocationKind::Derive { path, .. } => path.span,
373373
}
374374
}
375+
376+
fn span_mut(&mut self) -> &mut Span {
377+
match &mut self.kind {
378+
InvocationKind::Bang { span, .. } => span,
379+
InvocationKind::Attr { attr, .. } => &mut attr.span,
380+
InvocationKind::Derive { path, .. } => &mut path.span,
381+
}
382+
}
375383
}
376384

377385
pub struct MacroExpander<'a, 'b> {
@@ -432,7 +440,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
432440
break;
433441
}
434442
invocations = mem::take(&mut undetermined_invocations);
435-
force = !mem::replace(&mut progress, false);
443+
force = !progress;
444+
progress = false;
436445
if force && self.monotonic {
437446
self.cx.dcx().span_delayed_bug(
438447
invocations.last().unwrap().0.span(),
@@ -471,7 +480,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
471480
self.cx.force_mode = force;
472481

473482
let fragment_kind = invoc.fragment_kind;
474-
let (expanded_fragment, new_invocations) = match self.expand_invoc(invoc, &ext.kind) {
483+
match self.expand_invoc(invoc, &ext.kind) {
475484
ExpandResult::Ready(fragment) => {
476485
let mut derive_invocations = Vec::new();
477486
let derive_placeholders = self
@@ -503,12 +512,19 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
503512
})
504513
.unwrap_or_default();
505514

506-
let (fragment, collected_invocations) =
515+
let (expanded_fragment, collected_invocations) =
507516
self.collect_invocations(fragment, &derive_placeholders);
508-
// We choose to expand any derive invocations associated with this macro invocation
509-
// *before* any macro invocations collected from the output fragment
517+
// We choose to expand any derive invocations associated with this macro
518+
// invocation *before* any macro invocations collected from the output
519+
// fragment.
510520
derive_invocations.extend(collected_invocations);
511-
(fragment, derive_invocations)
521+
522+
progress = true;
523+
if expanded_fragments.len() < depth {
524+
expanded_fragments.push(Vec::new());
525+
}
526+
expanded_fragments[depth - 1].push((expn_id, expanded_fragment));
527+
invocations.extend(derive_invocations.into_iter().rev());
512528
}
513529
ExpandResult::Retry(invoc) => {
514530
if force {
@@ -519,17 +535,9 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
519535
} else {
520536
// Cannot expand, will retry this invocation later.
521537
undetermined_invocations.push((invoc, Some(ext)));
522-
continue;
523538
}
524539
}
525-
};
526-
527-
progress = true;
528-
if expanded_fragments.len() < depth {
529-
expanded_fragments.push(Vec::new());
530540
}
531-
expanded_fragments[depth - 1].push((expn_id, expanded_fragment));
532-
invocations.extend(new_invocations.into_iter().rev());
533541
}
534542

535543
self.cx.current_expansion = orig_expansion_data;
@@ -590,11 +598,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
590598
for (invoc, _) in invocations.iter_mut() {
591599
let expn_id = invoc.expansion_data.id;
592600
let parent_def = self.cx.resolver.invocation_parent(expn_id);
593-
let span = match &mut invoc.kind {
594-
InvocationKind::Bang { span, .. } => span,
595-
InvocationKind::Attr { attr, .. } => &mut attr.span,
596-
InvocationKind::Derive { path, .. } => &mut path.span,
597-
};
601+
let span = invoc.span_mut();
598602
*span = span.with_parent(Some(parent_def));
599603
}
600604
}
@@ -957,7 +961,7 @@ pub fn parse_ast_fragment<'a>(
957961
})
958962
}
959963

960-
pub fn ensure_complete_parse<'a>(
964+
pub(crate) fn ensure_complete_parse<'a>(
961965
parser: &Parser<'a>,
962966
macro_path: &ast::Path,
963967
kind_name: &str,

‎compiler/rustc_expand/src/lib.rs‎

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,39 @@
1+
// tidy-alphabetical-start
2+
#![allow(internal_features)]
3+
#![allow(rustc::diagnostic_outside_of_impl)]
14
#![doc(rust_logo)]
2-
#![feature(rustdoc_internals)]
35
#![feature(array_windows)]
46
#![feature(associated_type_defaults)]
57
#![feature(if_let_guard)]
68
#![feature(let_chains)]
7-
#![feature(lint_reasons)]
89
#![feature(macro_metavar_expr)]
910
#![feature(map_try_insert)]
1011
#![feature(proc_macro_diagnostic)]
1112
#![feature(proc_macro_internals)]
12-
#![feature(proc_macro_span)]
13+
#![feature(rustdoc_internals)]
1314
#![feature(try_blocks)]
1415
#![feature(yeet_expr)]
15-
#![allow(rustc::diagnostic_outside_of_impl)]
16-
#![allow(internal_features)]
16+
// tidy-alphabetical-end
1717

1818
extern crate proc_macro as pm;
1919

20+
mod build;
21+
mod errors;
22+
// FIXME(Nilstrieb) Translate macro_rules diagnostics
23+
#[allow(rustc::untranslatable_diagnostic)]
24+
mod mbe;
2025
mod placeholders;
2126
mod proc_macro_server;
2227

2328
pub use mbe::macro_rules::compile_declarative_macro;
24-
pub(crate) use rustc_span::hygiene;
2529
pub mod base;
26-
pub mod build;
27-
#[macro_use]
2830
pub mod config;
29-
pub mod errors;
3031
pub mod expand;
3132
pub mod module;
32-
3333
// FIXME(Nilstrieb) Translate proc_macro diagnostics
3434
#[allow(rustc::untranslatable_diagnostic)]
3535
pub mod proc_macro;
3636

37-
// FIXME(Nilstrieb) Translate macro_rules diagnostics
38-
#[allow(rustc::untranslatable_diagnostic)]
39-
pub(crate) mod mbe;
40-
4137
// HACK(Centril, #64197): These shouldn't really be here.
4238
// Rather, they should be with their respective modules which are defined in other crates.
4339
// However, since for now constructing a `ParseSess` sorta requires `config` from this crate,

‎compiler/rustc_expand/src/mbe.rs‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
//! official terminology: "declarative macros".
55
66
pub(crate) mod diagnostics;
7-
pub(crate) mod macro_check;
8-
pub(crate) mod macro_parser;
97
pub(crate) mod macro_rules;
10-
pub(crate) mod metavar_expr;
11-
pub(crate) mod quoted;
12-
pub(crate) mod transcribe;
8+
9+
mod macro_check;
10+
mod macro_parser;
11+
mod metavar_expr;
12+
mod quoted;
13+
mod transcribe;
1314

1415
use metavar_expr::MetaVarExpr;
1516
use rustc_ast::token::{Delimiter, NonterminalKind, Token, TokenKind};

‎compiler/rustc_expand/src/mbe/diagnostics.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ pub(super) fn failed_to_match_macro<'cx>(
2828
) -> Box<dyn MacResult + 'cx> {
2929
let psess = &cx.sess.psess;
3030

31-
// An error occurred, try the expansion again, tracking the expansion closely for better diagnostics.
31+
// An error occurred, try the expansion again, tracking the expansion closely for better
32+
// diagnostics.
3233
let mut tracker = CollectTrackerAndEmitter::new(cx, sp);
3334

3435
let try_success_result = try_match_macro(psess, name, &arg, lhses, &mut tracker);

‎compiler/rustc_expand/src/mbe/macro_rules.rs‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ pub(super) trait Tracker<'matcher> {
157157
/// This is called before trying to match next MatcherLoc on the current token.
158158
fn before_match_loc(&mut self, _parser: &TtParser, _matcher: &'matcher MatcherLoc) {}
159159

160-
/// This is called after an arm has been parsed, either successfully or unsuccessfully. When this is called,
161-
/// `before_match_loc` was called at least once (with a `MatcherLoc::Eof`).
160+
/// This is called after an arm has been parsed, either successfully or unsuccessfully. When
161+
/// this is called, `before_match_loc` was called at least once (with a `MatcherLoc::Eof`).
162162
fn after_arm(&mut self, _result: &NamedParseResult<Self::Failure>) {}
163163

164164
/// For tracing.
@@ -169,7 +169,8 @@ pub(super) trait Tracker<'matcher> {
169169
}
170170
}
171171

172-
/// A noop tracker that is used in the hot path of the expansion, has zero overhead thanks to monomorphization.
172+
/// A noop tracker that is used in the hot path of the expansion, has zero overhead thanks to
173+
/// monomorphization.
173174
pub(super) struct NoopTracker;
174175

175176
impl<'matcher> Tracker<'matcher> for NoopTracker {
@@ -492,7 +493,7 @@ pub fn compile_declarative_macro(
492493
.pop()
493494
.unwrap();
494495
// We don't handle errors here, the driver will abort
495-
// after parsing/expansion. we can report every error in every macro this way.
496+
// after parsing/expansion. We can report every error in every macro this way.
496497
check_emission(check_lhs_nt_follows(sess, def, &tt));
497498
return tt;
498499
}
@@ -528,7 +529,7 @@ pub fn compile_declarative_macro(
528529
check_emission(check_rhs(sess, rhs));
529530
}
530531

531-
// don't abort iteration early, so that errors for multiple lhses can be reported
532+
// Don't abort iteration early, so that errors for multiple lhses can be reported.
532533
for lhs in &lhses {
533534
check_emission(check_lhs_no_empty_seq(sess, slice::from_ref(lhs)));
534535
}

‎compiler/rustc_expand/src/mbe/transcribe.rs‎

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -39,40 +39,42 @@ impl MutVisitor for Marker {
3939
}
4040

4141
/// An iterator over the token trees in a delimited token tree (`{ ... }`) or a sequence (`$(...)`).
42-
enum Frame<'a> {
43-
Delimited {
44-
tts: &'a [mbe::TokenTree],
45-
idx: usize,
46-
delim: Delimiter,
47-
span: DelimSpan,
48-
spacing: DelimSpacing,
49-
},
50-
Sequence {
51-
tts: &'a [mbe::TokenTree],
52-
idx: usize,
53-
sep: Option<Token>,
54-
kleene_op: KleeneOp,
55-
},
42+
struct Frame<'a> {
43+
tts: &'a [mbe::TokenTree],
44+
idx: usize,
45+
kind: FrameKind,
46+
}
47+
48+
enum FrameKind {
49+
Delimited { delim: Delimiter, span: DelimSpan, spacing: DelimSpacing },
50+
Sequence { sep: Option<Token>, kleene_op: KleeneOp },
5651
}
5752

5853
impl<'a> Frame<'a> {
59-
/// Construct a new frame around the delimited set of tokens.
60-
fn new(src: &'a mbe::Delimited, span: DelimSpan, spacing: DelimSpacing) -> Frame<'a> {
61-
Frame::Delimited { tts: &src.tts, idx: 0, delim: src.delim, span, spacing }
54+
fn new_delimited(src: &'a mbe::Delimited, span: DelimSpan, spacing: DelimSpacing) -> Frame<'a> {
55+
Frame {
56+
tts: &src.tts,
57+
idx: 0,
58+
kind: FrameKind::Delimited { delim: src.delim, span, spacing },
59+
}
60+
}
61+
62+
fn new_sequence(
63+
src: &'a mbe::SequenceRepetition,
64+
sep: Option<Token>,
65+
kleene_op: KleeneOp,
66+
) -> Frame<'a> {
67+
Frame { tts: &src.tts, idx: 0, kind: FrameKind::Sequence { sep, kleene_op } }
6268
}
6369
}
6470

6571
impl<'a> Iterator for Frame<'a> {
6672
type Item = &'a mbe::TokenTree;
6773

6874
fn next(&mut self) -> Option<&'a mbe::TokenTree> {
69-
match self {
70-
Frame::Delimited { tts, idx, .. } | Frame::Sequence { tts, idx, .. } => {
71-
let res = tts.get(*idx);
72-
*idx += 1;
73-
res
74-
}
75-
}
75+
let res = self.tts.get(self.idx);
76+
self.idx += 1;
77+
res
7678
}
7779
}
7880

@@ -111,13 +113,16 @@ pub(super) fn transcribe<'a>(
111113
// We descend into the RHS (`src`), expanding things as we go. This stack contains the things
112114
// we have yet to expand/are still expanding. We start the stack off with the whole RHS. The
113115
// choice of spacing values doesn't matter.
114-
let mut stack: SmallVec<[Frame<'_>; 1]> =
115-
smallvec![Frame::new(src, src_span, DelimSpacing::new(Spacing::Alone, Spacing::Alone))];
116+
let mut stack: SmallVec<[Frame<'_>; 1]> = smallvec![Frame::new_delimited(
117+
src,
118+
src_span,
119+
DelimSpacing::new(Spacing::Alone, Spacing::Alone)
120+
)];
116121

117122
// As we descend in the RHS, we will need to be able to match nested sequences of matchers.
118123
// `repeats` keeps track of where we are in matching at each level, with the last element being
119124
// the most deeply nested sequence. This is used as a stack.
120-
let mut repeats = Vec::new();
125+
let mut repeats: Vec<(usize, usize)> = Vec::new();
121126

122127
// `result` contains resulting token stream from the TokenTree we just finished processing. At
123128
// the end, this will contain the full result of transcription, but at arbitrary points during
@@ -142,11 +147,12 @@ pub(super) fn transcribe<'a>(
142147

143148
// Otherwise, if we have just reached the end of a sequence and we can keep repeating,
144149
// go back to the beginning of the sequence.
145-
if let Frame::Sequence { idx, sep, .. } = stack.last_mut().unwrap() {
150+
let frame = stack.last_mut().unwrap();
151+
if let FrameKind::Sequence { sep, .. } = &frame.kind {
146152
let (repeat_idx, repeat_len) = repeats.last_mut().unwrap();
147153
*repeat_idx += 1;
148154
if repeat_idx < repeat_len {
149-
*idx = 0;
155+
frame.idx = 0;
150156
if let Some(sep) = sep {
151157
result.push(TokenTree::Token(sep.clone(), Spacing::Alone));
152158
}
@@ -157,16 +163,16 @@ pub(super) fn transcribe<'a>(
157163
// We are done with the top of the stack. Pop it. Depending on what it was, we do
158164
// different things. Note that the outermost item must be the delimited, wrapped RHS
159165
// that was passed in originally to `transcribe`.
160-
match stack.pop().unwrap() {
166+
match stack.pop().unwrap().kind {
161167
// Done with a sequence. Pop from repeats.
162-
Frame::Sequence { .. } => {
168+
FrameKind::Sequence { .. } => {
163169
repeats.pop();
164170
}
165171

166172
// We are done processing a Delimited. If this is the top-level delimited, we are
167173
// done. Otherwise, we unwind the result_stack to append what we have produced to
168174
// any previous results.
169-
Frame::Delimited { delim, span, mut spacing, .. } => {
175+
FrameKind::Delimited { delim, span, mut spacing, .. } => {
170176
// Hack to force-insert a space after `]` in certain case.
171177
// See discussion of the `hex-literal` crate in #114571.
172178
if delim == Delimiter::Bracket {
@@ -192,7 +198,7 @@ pub(super) fn transcribe<'a>(
192198
// We are descending into a sequence. We first make sure that the matchers in the RHS
193199
// and the matches in `interp` have the same shape. Otherwise, either the caller or the
194200
// macro writer has made a mistake.
195-
seq @ mbe::TokenTree::Sequence(_, delimited) => {
201+
seq @ mbe::TokenTree::Sequence(_, seq_rep) => {
196202
match lockstep_iter_size(seq, interp, &repeats) {
197203
LockstepIterSize::Unconstrained => {
198204
return Err(cx
@@ -233,12 +239,11 @@ pub(super) fn transcribe<'a>(
233239
// The first time we encounter the sequence we push it to the stack. It
234240
// then gets reused (see the beginning of the loop) until we are done
235241
// repeating.
236-
stack.push(Frame::Sequence {
237-
idx: 0,
238-
sep: seq.separator.clone(),
239-
tts: &delimited.tts,
240-
kleene_op: seq.kleene.op,
241-
});
242+
stack.push(Frame::new_sequence(
243+
seq_rep,
244+
seq.separator.clone(),
245+
seq.kleene.op,
246+
));
242247
}
243248
}
244249
}
@@ -294,13 +299,7 @@ pub(super) fn transcribe<'a>(
294299
// the previous results (from outside the Delimited).
295300
mbe::TokenTree::Delimited(mut span, spacing, delimited) => {
296301
mut_visit::visit_delim_span(&mut span, &mut marker);
297-
stack.push(Frame::Delimited {
298-
tts: &delimited.tts,
299-
delim: delimited.delim,
300-
idx: 0,
301-
span,
302-
spacing: *spacing,
303-
});
302+
stack.push(Frame::new_delimited(delimited, span, *spacing));
304303
result_stack.push(mem::take(&mut result));
305304
}
306305

@@ -358,10 +357,13 @@ fn maybe_use_metavar_location(
358357
) -> TokenTree {
359358
let undelimited_seq = matches!(
360359
stack.last(),
361-
Some(Frame::Sequence {
360+
Some(Frame {
362361
tts: [_],
363-
sep: None,
364-
kleene_op: KleeneOp::ZeroOrMore | KleeneOp::OneOrMore,
362+
kind: FrameKind::Sequence {
363+
sep: None,
364+
kleene_op: KleeneOp::ZeroOrMore | KleeneOp::OneOrMore,
365+
..
366+
},
365367
..
366368
})
367369
);

‎compiler/rustc_expand/src/placeholders.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_span::DUMMY_SP;
99
use smallvec::{smallvec, SmallVec};
1010
use thin_vec::ThinVec;
1111

12-
pub fn placeholder(
12+
pub(crate) fn placeholder(
1313
kind: AstFragmentKind,
1414
id: ast::NodeId,
1515
vis: Option<ast::Visibility>,

‎compiler/rustc_middle/src/ty/fast_reject.rs‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,20 +330,19 @@ impl DeepRejectCtxt {
330330
}
331331

332332
pub fn consts_may_unify(self, obligation_ct: ty::Const<'_>, impl_ct: ty::Const<'_>) -> bool {
333-
match impl_ct.kind() {
333+
let impl_val = match impl_ct.kind() {
334334
ty::ConstKind::Expr(_)
335335
| ty::ConstKind::Param(_)
336336
| ty::ConstKind::Unevaluated(_)
337337
| ty::ConstKind::Error(_) => {
338338
return true;
339339
}
340-
ty::ConstKind::Value(_) => {}
340+
ty::ConstKind::Value(impl_val) => impl_val,
341341
ty::ConstKind::Infer(_) | ty::ConstKind::Bound(..) | ty::ConstKind::Placeholder(_) => {
342342
bug!("unexpected impl arg: {:?}", impl_ct)
343343
}
344-
}
344+
};
345345

346-
let k = impl_ct.kind();
347346
match obligation_ct.kind() {
348347
ty::ConstKind::Param(_) => match self.treat_obligation_params {
349348
TreatParams::ForLookup => false,
@@ -358,10 +357,7 @@ impl DeepRejectCtxt {
358357
ty::ConstKind::Expr(_) | ty::ConstKind::Unevaluated(_) | ty::ConstKind::Error(_) => {
359358
true
360359
}
361-
ty::ConstKind::Value(obl) => match k {
362-
ty::ConstKind::Value(imp) => obl == imp,
363-
_ => true,
364-
},
360+
ty::ConstKind::Value(obl_val) => obl_val == impl_val,
365361

366362
ty::ConstKind::Infer(_) => true,
367363

‎library/alloc/src/borrow.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
use core::cmp::Ordering;
66
use core::hash::{Hash, Hasher};
7-
use core::ops::Deref;
87
#[cfg(not(no_global_oom_handling))]
98
use core::ops::{Add, AddAssign};
9+
use core::ops::{Deref, DerefPure};
1010

1111
#[stable(feature = "rust1", since = "1.0.0")]
1212
pub use core::borrow::{Borrow, BorrowMut};
@@ -343,6 +343,9 @@ where
343343
}
344344
}
345345

346+
#[unstable(feature = "deref_pure_trait", issue = "87121")]
347+
unsafe impl<B: ?Sized + ToOwned> DerefPure for Cow<'_, B> where B::Owned: Borrow<B> {}
348+
346349
#[stable(feature = "rust1", since = "1.0.0")]
347350
impl<B: ?Sized> Eq for Cow<'_, B> where B: Eq + ToOwned {}
348351

‎library/alloc/src/string.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ impl String {
13821382

13831383
/// Shortens this `String` to the specified length.
13841384
///
1385-
/// If `new_len` is greater than the string's current length, this has no
1385+
/// If `new_len` is greater than or equal to the string's current length, this has no
13861386
/// effect.
13871387
///
13881388
/// Note that this method has no effect on the allocated capacity

‎library/core/src/cell.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ use crate::cmp::Ordering;
239239
use crate::fmt::{self, Debug, Display};
240240
use crate::marker::{PhantomData, Unsize};
241241
use crate::mem::{self, size_of};
242-
use crate::ops::{CoerceUnsized, Deref, DerefMut, DispatchFromDyn};
242+
use crate::ops::{CoerceUnsized, Deref, DerefMut, DerefPure, DispatchFromDyn};
243243
use crate::ptr::{self, NonNull};
244244

245245
mod lazy;
@@ -1452,6 +1452,9 @@ impl<T: ?Sized> Deref for Ref<'_, T> {
14521452
}
14531453
}
14541454

1455+
#[unstable(feature = "deref_pure_trait", issue = "87121")]
1456+
unsafe impl<T: ?Sized> DerefPure for Ref<'_, T> {}
1457+
14551458
impl<'b, T: ?Sized> Ref<'b, T> {
14561459
/// Copies a `Ref`.
14571460
///
@@ -1844,6 +1847,9 @@ impl<T: ?Sized> DerefMut for RefMut<'_, T> {
18441847
}
18451848
}
18461849

1850+
#[unstable(feature = "deref_pure_trait", issue = "87121")]
1851+
unsafe impl<T: ?Sized> DerefPure for RefMut<'_, T> {}
1852+
18471853
#[unstable(feature = "coerce_unsized", issue = "18598")]
18481854
impl<'b, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<RefMut<'b, U>> for RefMut<'b, T> {}
18491855

‎library/core/src/intrinsics.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2578,8 +2578,7 @@ extern "rust-intrinsic" {
25782578
///
25792579
/// Currently such an assertion would always succeed; until Rust decides
25802580
/// otherwise, that principle should not be violated.
2581-
#[rustc_const_unstable(feature = "const_eval_select", issue = "none")]
2582-
#[unstable(feature = "core_intrinsics", issue = "none")]
2581+
#[rustc_const_unstable(feature = "const_eval_select", issue = "124625")]
25832582
#[rustc_intrinsic]
25842583
#[rustc_intrinsic_must_be_overridden]
25852584
pub const fn const_eval_select<ARG: Tuple, F, G, RET>(

‎library/core/src/mem/manually_drop.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::ops::{Deref, DerefMut};
1+
use crate::ops::{Deref, DerefMut, DerefPure};
22
use crate::ptr;
33

44
/// A wrapper to inhibit compiler from automatically calling `T`’s destructor.
@@ -161,3 +161,6 @@ impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
161161
&mut self.value
162162
}
163163
}
164+
165+
#[unstable(feature = "deref_pure_trait", issue = "87121")]
166+
unsafe impl<T: ?Sized> DerefPure for ManuallyDrop<T> {}

‎library/core/src/pin.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@
923923
use crate::cmp;
924924
use crate::fmt;
925925
use crate::hash::{Hash, Hasher};
926-
use crate::ops::{CoerceUnsized, Deref, DerefMut, DispatchFromDyn, Receiver};
926+
use crate::ops::{CoerceUnsized, Deref, DerefMut, DerefPure, DispatchFromDyn, Receiver};
927927

928928
#[allow(unused_imports)]
929929
use crate::{
@@ -1684,6 +1684,9 @@ impl<Ptr: DerefMut<Target: Unpin>> DerefMut for Pin<Ptr> {
16841684
}
16851685
}
16861686

1687+
#[unstable(feature = "deref_pure_trait", issue = "87121")]
1688+
unsafe impl<Ptr: DerefPure> DerefPure for Pin<Ptr> {}
1689+
16871690
#[unstable(feature = "receiver_trait", issue = "none")]
16881691
impl<Ptr: Receiver> Receiver for Pin<Ptr> {}
16891692

‎library/std/Cargo.toml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,10 @@ r-efi-alloc = { version = "1.0.0", features = ['rustc-dep-of-std'] }
6464

6565
[features]
6666
backtrace = [
67-
"gimli-symbolize",
6867
'addr2line/rustc-dep-of-std',
6968
'object/rustc-dep-of-std',
7069
'miniz_oxide/rustc-dep-of-std',
7170
]
72-
gimli-symbolize = []
7371

7472
panic-unwind = ["panic_unwind"]
7573
profiler = ["profiler_builtins"]

‎library/std/src/f32.rs‎

Lines changed: 87 additions & 58 deletions
Large diffs are not rendered by default.

‎library/std/src/f64.rs‎

Lines changed: 87 additions & 58 deletions
Large diffs are not rendered by default.

‎library/std/src/io/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266
//! its file descriptors with no operations being performed by any other part of the program.
267267
//!
268268
//! Note that exclusive ownership of a file descriptor does *not* imply exclusive ownership of the
269-
//! underlying kernel object that the file descriptor references (also called "file description" on
269+
//! underlying kernel object that the file descriptor references (also called "open file description" on
270270
//! some operating systems). File descriptors basically work like [`Arc`]: when you receive an owned
271271
//! file descriptor, you cannot know whether there are any other file descriptors that reference the
272272
//! same kernel object. However, when you create a new kernel object, you know that you are holding

‎library/std/src/os/unix/io/mod.rs‎

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
//! | Type | Analogous to |
1313
//! | ------------------ | ------------ |
1414
//! | [`RawFd`] | `*const _` |
15-
//! | [`BorrowedFd<'a>`] | `&'a _` |
16-
//! | [`OwnedFd`] | `Box<_>` |
15+
//! | [`BorrowedFd<'a>`] | `&'a Arc<_>` |
16+
//! | [`OwnedFd`] | `Arc<_>` |
1717
//!
1818
//! Like raw pointers, `RawFd` values are primitive values. And in new code,
1919
//! they should be considered unsafe to do I/O on (analogous to dereferencing
@@ -23,22 +23,31 @@
2323
//! either by adding `unsafe` to APIs that dereference `RawFd` values, or by
2424
//! using to `BorrowedFd` or `OwnedFd` instead.
2525
//!
26+
//! The use of `Arc` for borrowed/owned file descriptors may be surprising. Unix file descriptors
27+
//! are mere references to internal kernel objects called "open file descriptions", and the same
28+
//! open file description can be referenced by multiple file descriptors (e.g. if `dup` is used).
29+
//! State such as the offset within the file is shared among all file descriptors that refer to the
30+
//! same open file description, and the kernel internally does reference-counting to only close the
31+
//! underlying resource once all file descriptors referencing it are closed. That's why `Arc` (and
32+
//! not `Box`) is the closest Rust analogy to an "owned" file descriptor.
33+
//!
2634
//! Like references, `BorrowedFd` values are tied to a lifetime, to ensure
2735
//! that they don't outlive the resource they point to. These are safe to
2836
//! use. `BorrowedFd` values may be used in APIs which provide safe access to
2937
//! any system call except for:
3038
//!
3139
//! - `close`, because that would end the dynamic lifetime of the resource
32-
//! without ending the lifetime of the file descriptor.
40+
//! without ending the lifetime of the file descriptor. (Equivalently:
41+
//! an `&Arc<_>` cannot be `drop`ed.)
3342
//!
3443
//! - `dup2`/`dup3`, in the second argument, because this argument is
35-
//! closed and assigned a new resource, which may break the assumptions
44+
//! closed and assigned a new resource, which may break the assumptions of
3645
//! other code using that file descriptor.
3746
//!
38-
//! `BorrowedFd` values may be used in APIs which provide safe access to `dup`
39-
//! system calls, so types implementing `AsFd` or `From<OwnedFd>` should not
40-
//! assume they always have exclusive access to the underlying file
41-
//! description.
47+
//! `BorrowedFd` values may be used in APIs which provide safe access to `dup` system calls, so code
48+
//! working with `OwnedFd` cannot assume to have exclusive access to the underlying open file
49+
//! description. (Equivalently: `&Arc` may be used in APIs that provide safe access to `clone`, so
50+
//! code working with an `Arc` cannot assume that the reference count is 1.)
4251
//!
4352
//! `BorrowedFd` values may also be used with `mmap`, since `mmap` uses the
4453
//! provided file descriptor in a manner similar to `dup` and does not require
@@ -52,8 +61,10 @@
5261
//! take full responsibility for ensuring that safe Rust code cannot evoke
5362
//! undefined behavior through it.
5463
//!
55-
//! Like boxes, `OwnedFd` values conceptually own the resource they point to,
56-
//! and free (close) it when they are dropped.
64+
//! Like `Arc`, `OwnedFd` values conceptually own one reference to the resource they point to,
65+
//! and decrement the reference count when they are dropped (by calling `close`).
66+
//! When the reference count reaches 0, the underlying open file description will be freed
67+
//! by the kernel.
5768
//!
5869
//! See the [`io` module docs][io-safety] for a general explanation of I/O safety.
5970
//!

‎src/tools/run-make-support/src/cc.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,9 @@ pub fn extra_cxx_flags() -> Vec<&'static str> {
161161
if is_windows() {
162162
if is_msvc() { vec![] } else { vec!["-lstdc++"] }
163163
} else {
164-
match uname() {
165-
n if n.contains("Darwin") => vec!["-lc++"],
164+
match &uname()[..] {
165+
"Darwin" => vec!["-lc++"],
166+
"FreeBSD" | "SunOS" | "OpenBSD" => vec![],
166167
_ => vec!["-lstdc++"],
167168
}
168169
}

0 commit comments

Comments
 (0)
Please sign in to comment.