Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit eec3d92

Browse files
committedAug 29, 2024
Auto merge of rust-lang#129729 - workingjubilee:rollup-p1j437c, r=workingjubilee
Rollup of 9 pull requests Successful merges: - rust-lang#120221 (Don't make statement nonterminals match pattern nonterminals) - rust-lang#127912 (std: make `thread::current` available in all `thread_local!` destructors) - rust-lang#128166 (Improved `checked_isqrt` and `isqrt` methods) - rust-lang#129123 (rustdoc-json: Add test for `Self` type) - rust-lang#129366 (linker: Synchronize native library search in rustc and linker) - rust-lang#129527 (Don't use `TyKind` in a lint) - rust-lang#129534 (Deny `wasm_c_abi` lint to nudge the last 25%) - rust-lang#129640 (Re-enable android tests/benches in alloc/core) - rust-lang#129675 (allow BufReader::peek to be called on unsized types) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6cf068d + 6027230 commit eec3d92

File tree

56 files changed

+1502
-355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1502
-355
lines changed
 

‎compiler/rustc_ast/src/token.rs

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,9 @@ impl Token {
486486
}
487487

488488
/// Returns `true` if the token can appear at the start of an expression.
489+
///
490+
/// **NB**: Take care when modifying this function, since it will change
491+
/// the stable set of tokens that are allowed to match an expr nonterminal.
489492
pub fn can_begin_expr(&self) -> bool {
490493
match self.uninterpolate().kind {
491494
Ident(name, is_raw) =>
@@ -504,34 +507,46 @@ impl Token {
504507
PathSep | // global path
505508
Lifetime(..) | // labeled loop
506509
Pound => true, // expression attributes
507-
Interpolated(ref nt) => matches!(&**nt, NtLiteral(..) |
508-
NtExpr(..) |
509-
NtBlock(..) |
510-
NtPath(..)),
510+
Interpolated(ref nt) =>
511+
matches!(&**nt,
512+
NtBlock(..) |
513+
NtExpr(..) |
514+
NtLiteral(..) |
515+
NtPath(..)
516+
),
511517
_ => false,
512518
}
513519
}
514520

515521
/// Returns `true` if the token can appear at the start of a pattern.
516522
///
517523
/// Shamelessly borrowed from `can_begin_expr`, only used for diagnostics right now.
518-
pub fn can_begin_pattern(&self) -> bool {
519-
match self.uninterpolate().kind {
520-
Ident(name, is_raw) =>
521-
ident_can_begin_expr(name, self.span, is_raw), // value name or keyword
522-
| OpenDelim(Delimiter::Bracket | Delimiter::Parenthesis) // tuple or array
523-
| Literal(..) // literal
524-
| BinOp(Minus) // unary minus
525-
| BinOp(And) // reference
526-
| AndAnd // double reference
527-
// DotDotDot is no longer supported
528-
| DotDot | DotDotDot | DotDotEq // ranges
529-
| Lt | BinOp(Shl) // associated path
530-
| PathSep => true, // global path
531-
Interpolated(ref nt) => matches!(&**nt, NtLiteral(..) |
532-
NtPat(..) |
533-
NtBlock(..) |
534-
NtPath(..)),
524+
pub fn can_begin_pattern(&self, pat_kind: NtPatKind) -> bool {
525+
match &self.uninterpolate().kind {
526+
// box, ref, mut, and other identifiers (can stricten)
527+
Ident(..) | NtIdent(..) |
528+
OpenDelim(Delimiter::Parenthesis) | // tuple pattern
529+
OpenDelim(Delimiter::Bracket) | // slice pattern
530+
BinOp(And) | // reference
531+
BinOp(Minus) | // negative literal
532+
AndAnd | // double reference
533+
Literal(_) | // literal
534+
DotDot | // range pattern (future compat)
535+
DotDotDot | // range pattern (future compat)
536+
PathSep | // path
537+
Lt | // path (UFCS constant)
538+
BinOp(Shl) => true, // path (double UFCS)
539+
// leading vert `|` or-pattern
540+
BinOp(Or) => matches!(pat_kind, PatWithOr),
541+
Interpolated(nt) =>
542+
matches!(&**nt,
543+
| NtExpr(..)
544+
| NtLiteral(..)
545+
| NtMeta(..)
546+
| NtPat(..)
547+
| NtPath(..)
548+
| NtTy(..)
549+
),
535550
_ => false,
536551
}
537552
}

‎compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 15 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::collections::BTreeSet;
22
use std::ffi::OsString;
33
use std::fs::{read, File, OpenOptions};
44
use std::io::{BufWriter, Write};
5-
use std::ops::Deref;
5+
use std::ops::{ControlFlow, Deref};
66
use std::path::{Path, PathBuf};
77
use std::process::{ExitStatus, Output, Stdio};
88
use std::{env, fmt, fs, io, mem, str};
@@ -18,8 +18,8 @@ use rustc_data_structures::temp_dir::MaybeTempDir;
1818
use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, FatalError};
1919
use rustc_fs_util::{fix_windows_verbatim_for_gcc, try_canonicalize};
2020
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
21-
use rustc_metadata::find_native_static_library;
2221
use rustc_metadata::fs::{copy_to_stdout, emit_wrapper_file, METADATA_FILENAME};
22+
use rustc_metadata::{find_native_static_library, walk_native_lib_search_dirs};
2323
use rustc_middle::bug;
2424
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
2525
use rustc_middle::middle::dependency_format::Linkage;
@@ -2110,50 +2110,19 @@ fn add_library_search_dirs(
21102110
return;
21112111
}
21122112

2113-
// Library search paths explicitly supplied by user (`-L` on the command line).
2114-
for search_path in sess.target_filesearch(PathKind::Native).cli_search_paths() {
2115-
cmd.include_path(&fix_windows_verbatim_for_gcc(&search_path.dir));
2116-
}
2117-
for search_path in sess.target_filesearch(PathKind::Framework).cli_search_paths() {
2118-
// Contrary to the `-L` docs only framework-specific paths are considered here.
2119-
if search_path.kind != PathKind::All {
2120-
cmd.framework_path(&search_path.dir);
2121-
}
2122-
}
2123-
2124-
// The toolchain ships some native library components and self-contained linking was enabled.
2125-
// Add the self-contained library directory to search paths.
2126-
if self_contained_components.intersects(
2127-
LinkSelfContainedComponents::LIBC
2128-
| LinkSelfContainedComponents::UNWIND
2129-
| LinkSelfContainedComponents::MINGW,
2130-
) {
2131-
let lib_path = sess.target_tlib_path.dir.join("self-contained");
2132-
cmd.include_path(&fix_windows_verbatim_for_gcc(&lib_path));
2133-
}
2134-
2135-
// Toolchains for some targets may ship `libunwind.a`, but place it into the main sysroot
2136-
// library directory instead of the self-contained directories.
2137-
// Sanitizer libraries have the same issue and are also linked by name on Apple targets.
2138-
// The targets here should be in sync with `copy_third_party_objects` in bootstrap.
2139-
// FIXME: implement `-Clink-self-contained=+/-unwind,+/-sanitizers`, move the shipped libunwind
2140-
// and sanitizers to self-contained directory, and stop adding this search path.
2141-
if sess.target.vendor == "fortanix"
2142-
|| sess.target.os == "linux"
2143-
|| sess.target.os == "fuchsia"
2144-
|| sess.target.is_like_osx && !sess.opts.unstable_opts.sanitizer.is_empty()
2145-
{
2146-
cmd.include_path(&fix_windows_verbatim_for_gcc(&sess.target_tlib_path.dir));
2147-
}
2148-
2149-
// Mac Catalyst uses the macOS SDK, but to link to iOS-specific frameworks
2150-
// we must have the support library stubs in the library search path (#121430).
2151-
if let Some(sdk_root) = apple_sdk_root
2152-
&& sess.target.llvm_target.contains("macabi")
2153-
{
2154-
cmd.include_path(&sdk_root.join("System/iOSSupport/usr/lib"));
2155-
cmd.framework_path(&sdk_root.join("System/iOSSupport/System/Library/Frameworks"));
2156-
}
2113+
walk_native_lib_search_dirs(
2114+
sess,
2115+
self_contained_components,
2116+
apple_sdk_root,
2117+
|dir, is_framework| {
2118+
if is_framework {
2119+
cmd.framework_path(dir);
2120+
} else {
2121+
cmd.include_path(&fix_windows_verbatim_for_gcc(dir));
2122+
}
2123+
ControlFlow::<()>::Continue(())
2124+
},
2125+
);
21572126
}
21582127

21592128
/// Add options making relocation sections in the produced ELF files read-only

0 commit comments

Comments
 (0)