diff --git a/compiler/rustc_expand/src/parse/tests.rs b/compiler/rustc_expand/src/parse/tests.rs
index 8b37728b60fea..e133501c5d0a8 100644
--- a/compiler/rustc_expand/src/parse/tests.rs
+++ b/compiler/rustc_expand/src/parse/tests.rs
@@ -1,4 +1,6 @@
-use crate::tests::{matches_codepattern, string_to_stream, with_error_checking_parse};
+use crate::tests::{
+ matches_codepattern, string_to_stream, with_error_checking_parse, with_expected_parse_error,
+};
use rustc_ast::ptr::P;
use rustc_ast::token::{self, Delimiter, Token};
@@ -51,11 +53,15 @@ fn string_to_item(source_str: String) -> Option
> {
with_error_checking_parse(source_str, &sess(), |p| p.parse_item(ForceCollect::No))
}
-#[should_panic]
#[test]
fn bad_path_expr_1() {
+ // This should trigger error: expected identifier, found keyword `return`
create_default_session_globals_then(|| {
- string_to_expr("::abc::def::return".to_string());
+ with_expected_parse_error(
+ "::abc::def::return",
+ "expected identifier, found keyword `return`",
+ |p| p.parse_expr(),
+ );
})
}
diff --git a/compiler/rustc_expand/src/tests.rs b/compiler/rustc_expand/src/tests.rs
index aec0a1c6d8e2a..30fa5fea40769 100644
--- a/compiler/rustc_expand/src/tests.rs
+++ b/compiler/rustc_expand/src/tests.rs
@@ -22,6 +22,33 @@ fn string_to_parser(ps: &ParseSess, source_str: String) -> Parser<'_> {
new_parser_from_source_str(ps, PathBuf::from("bogofile").into(), source_str)
}
+fn create_test_handler() -> (Handler, Lrc, Arc>>) {
+ let output = Arc::new(Mutex::new(Vec::new()));
+ let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty()));
+ let fallback_bundle = rustc_errors::fallback_fluent_bundle(
+ vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE],
+ false,
+ );
+ let emitter = EmitterWriter::new(
+ Box::new(Shared { data: output.clone() }),
+ Some(source_map.clone()),
+ None,
+ fallback_bundle,
+ false,
+ false,
+ false,
+ Some(140),
+ false,
+ false,
+ TerminalUrl::No,
+ );
+ let handler = Handler::with_emitter(Box::new(emitter));
+ (handler, source_map, output)
+}
+
+/// Returns the result of parsing the given string via the given callback.
+///
+/// If there are any errors, this will panic.
pub(crate) fn with_error_checking_parse<'a, T, F>(s: String, ps: &'a ParseSess, f: F) -> T
where
F: FnOnce(&mut Parser<'a>) -> PResult<'a, T>,
@@ -32,6 +59,26 @@ where
x
}
+/// Verifies that parsing the given string using the given callback will
+/// generate an error that contains the given text.
+pub(crate) fn with_expected_parse_error(source_str: &str, expected_output: &str, f: F)
+where
+ F: for<'a> FnOnce(&mut Parser<'a>) -> PResult<'a, T>,
+{
+ let (handler, source_map, output) = create_test_handler();
+ let ps = ParseSess::with_span_handler(handler, source_map);
+ let mut p = string_to_parser(&ps, source_str.to_string());
+ let result = f(&mut p);
+ assert!(result.is_ok());
+
+ let bytes = output.lock().unwrap();
+ let actual_output = str::from_utf8(&bytes).unwrap();
+ println!("expected output:\n------\n{}------", expected_output);
+ println!("actual output:\n------\n{}------", actual_output);
+
+ assert!(actual_output.contains(expected_output))
+}
+
/// Maps a string to tts, using a made-up filename.
pub(crate) fn string_to_stream(source_str: String) -> TokenStream {
let ps = ParseSess::new(
@@ -130,13 +177,7 @@ impl Write for Shared {
fn test_harness(file_text: &str, span_labels: Vec, expected_output: &str) {
create_default_session_if_not_set_then(|_| {
- let output = Arc::new(Mutex::new(Vec::new()));
-
- let fallback_bundle = rustc_errors::fallback_fluent_bundle(
- vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE],
- false,
- );
- let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty()));
+ let (handler, source_map, output) = create_test_handler();
source_map.new_source_file(Path::new("test.rs").to_owned().into(), file_text.to_owned());
let primary_span = make_span(&file_text, &span_labels[0].start, &span_labels[0].end);
@@ -148,20 +189,6 @@ fn test_harness(file_text: &str, span_labels: Vec, expected_output: &
println!("text: {:?}", source_map.span_to_snippet(span));
}
- let emitter = EmitterWriter::new(
- Box::new(Shared { data: output.clone() }),
- Some(source_map.clone()),
- None,
- fallback_bundle,
- false,
- false,
- false,
- None,
- false,
- false,
- TerminalUrl::No,
- );
- let handler = Handler::with_emitter(Box::new(emitter));
#[allow(rustc::untranslatable_diagnostic)]
handler.span_err(msp, "foo");
diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs
index c19c2d1dc9e25..4a535f80b8ac5 100644
--- a/compiler/rustc_session/src/options.rs
+++ b/compiler/rustc_session/src/options.rs
@@ -1433,8 +1433,6 @@ options! {
dep_tasks: bool = (false, parse_bool, [UNTRACKED],
"print tasks that execute and the color their dep node gets (requires debug build) \
(default: no)"),
- diagnostic_width: Option = (None, parse_opt_number, [UNTRACKED],
- "set the current output width for diagnostic truncation"),
dont_buffer_diagnostics: bool = (false, parse_bool, [UNTRACKED],
"emit diagnostics rather than buffering (breaks NLL error downgrading, sorting) \
(default: no)"),
diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs
index 044e2f8f32569..cefcab1e18f59 100644
--- a/compiler/rustc_smir/src/rustc_smir/mod.rs
+++ b/compiler/rustc_smir/src/rustc_smir/mod.rs
@@ -825,8 +825,10 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
ty::Alias(alias_kind, alias_ty) => {
TyKind::Alias(alias_kind.stable(tables), alias_ty.stable(tables))
}
- ty::Param(_) => todo!(),
- ty::Bound(_, _) => todo!(),
+ ty::Param(param_ty) => TyKind::Param(param_ty.stable(tables)),
+ ty::Bound(debruijn_idx, bound_ty) => {
+ TyKind::Bound(debruijn_idx.as_usize(), bound_ty.stable(tables))
+ }
ty::Placeholder(..)
| ty::GeneratorWitness(_)
| ty::GeneratorWitnessMIR(_, _)
@@ -837,3 +839,19 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
}
}
}
+
+impl<'tcx> Stable<'tcx> for rustc_middle::ty::ParamTy {
+ type T = stable_mir::ty::ParamTy;
+ fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
+ use stable_mir::ty::ParamTy;
+ ParamTy { index: self.index, name: self.name.to_string() }
+ }
+}
+
+impl<'tcx> Stable<'tcx> for rustc_middle::ty::BoundTy {
+ type T = stable_mir::ty::BoundTy;
+ fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
+ use stable_mir::ty::BoundTy;
+ BoundTy { var: self.var.as_usize(), kind: self.kind.stable(tables) }
+ }
+}
diff --git a/compiler/rustc_smir/src/stable_mir/ty.rs b/compiler/rustc_smir/src/stable_mir/ty.rs
index 7b4747a7fe29e..7a72afd666cf1 100644
--- a/compiler/rustc_smir/src/stable_mir/ty.rs
+++ b/compiler/rustc_smir/src/stable_mir/ty.rs
@@ -18,6 +18,8 @@ type Span = Opaque;
pub enum TyKind {
RigidTy(RigidTy),
Alias(AliasKind, AliasTy),
+ Param(ParamTy),
+ Bound(usize, BoundTy),
}
#[derive(Clone, Debug)]
@@ -228,3 +230,15 @@ pub struct ExistentialProjection {
pub generic_args: GenericArgs,
pub term: TermKind,
}
+
+#[derive(Clone, Debug)]
+pub struct ParamTy {
+ pub index: u32,
+ pub name: String,
+}
+
+#[derive(Clone, Debug)]
+pub struct BoundTy {
+ pub var: usize,
+ pub kind: BoundTyKind,
+}
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index 08925761b393c..54eb7bef5f205 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -372,6 +372,7 @@ symbols! {
arm_target_feature,
array,
arrays,
+ as_mut_ptr,
as_ptr,
as_ref,
as_str,
@@ -858,6 +859,7 @@ symbols! {
item,
item_like_imports,
iter,
+ iter_mut,
iter_repeat,
iterator_collect_fn,
kcfi,
diff --git a/library/std/src/sys/unix/rand.rs b/library/std/src/sys/unix/rand.rs
index d471be33ed559..fbf158f56fcc0 100644
--- a/library/std/src/sys/unix/rand.rs
+++ b/library/std/src/sys/unix/rand.rs
@@ -17,7 +17,6 @@ pub fn hashmap_random_keys() -> (u64, u64) {
not(target_os = "tvos"),
not(target_os = "watchos"),
not(target_os = "openbsd"),
- not(target_os = "freebsd"),
not(target_os = "netbsd"),
not(target_os = "fuchsia"),
not(target_os = "redox"),
@@ -68,11 +67,25 @@ mod imp {
unsafe { libc::getrandom(buf.as_mut_ptr().cast(), buf.len(), 0) }
}
+ #[cfg(target_os = "freebsd")]
+ fn getrandom(buf: &mut [u8]) -> libc::ssize_t {
+ // FIXME: using the above when libary std's libc is updated
+ extern "C" {
+ fn getrandom(
+ buffer: *mut libc::c_void,
+ length: libc::size_t,
+ flags: libc::c_uint,
+ ) -> libc::ssize_t;
+ }
+ unsafe { getrandom(buf.as_mut_ptr().cast(), buf.len(), 0) }
+ }
+
#[cfg(not(any(
target_os = "linux",
target_os = "android",
target_os = "espidf",
- target_os = "horizon"
+ target_os = "horizon",
+ target_os = "freebsd"
)))]
fn getrandom_fill_bytes(_buf: &mut [u8]) -> bool {
false
@@ -82,7 +95,8 @@ mod imp {
target_os = "linux",
target_os = "android",
target_os = "espidf",
- target_os = "horizon"
+ target_os = "horizon",
+ target_os = "freebsd"
))]
fn getrandom_fill_bytes(v: &mut [u8]) -> bool {
use crate::sync::atomic::{AtomicBool, Ordering};
@@ -222,7 +236,7 @@ mod imp {
}
}
-#[cfg(any(target_os = "freebsd", target_os = "netbsd"))]
+#[cfg(target_os = "netbsd")]
mod imp {
use crate::ptr;
diff --git a/src/bootstrap/download-ci-llvm-stamp b/src/bootstrap/download-ci-llvm-stamp
index 120b3c9c4d28a..ffc38057900ad 100644
--- a/src/bootstrap/download-ci-llvm-stamp
+++ b/src/bootstrap/download-ci-llvm-stamp
@@ -1,4 +1,4 @@
Change this file to make users of the `download-ci-llvm` configuration download
a new version of LLVM from CI, even if the LLVM submodule hasn’t changed.
-Last change is for: https://github.com/rust-lang/rust/pull/112931
+Last change is for: https://github.com/rust-lang/rust/pull/113996
diff --git a/src/bootstrap/llvm.rs b/src/bootstrap/llvm.rs
index 07719a711788e..02fef4b3e8302 100644
--- a/src/bootstrap/llvm.rs
+++ b/src/bootstrap/llvm.rs
@@ -559,6 +559,8 @@ fn configure_cmake(
if target.contains("netbsd") {
cfg.define("CMAKE_SYSTEM_NAME", "NetBSD");
+ } else if target.contains("dragonfly") {
+ cfg.define("CMAKE_SYSTEM_NAME", "DragonFly");
} else if target.contains("freebsd") {
cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD");
} else if target.contains("windows") {
@@ -569,7 +571,12 @@ fn configure_cmake(
cfg.define("CMAKE_SYSTEM_NAME", "SunOS");
} else if target.contains("linux") {
cfg.define("CMAKE_SYSTEM_NAME", "Linux");
+ } else {
+ builder.info(
+ "could not determine CMAKE_SYSTEM_NAME from the target `{target}`, build may fail",
+ );
}
+
// When cross-compiling we should also set CMAKE_SYSTEM_VERSION, but in
// that case like CMake we cannot easily determine system version either.
//
diff --git a/src/tools/clippy/clippy_lints/src/methods/bytecount.rs b/src/tools/clippy/clippy_lints/src/methods/bytecount.rs
index fef90f6eba495..f490a71755407 100644
--- a/src/tools/clippy/clippy_lints/src/methods/bytecount.rs
+++ b/src/tools/clippy/clippy_lints/src/methods/bytecount.rs
@@ -45,7 +45,7 @@ pub(super) fn check<'tcx>(
let haystack = if let ExprKind::MethodCall(path, receiver, [], _) =
filter_recv.kind {
let p = path.ident.name;
- if p == sym::iter || p == sym!(iter_mut) {
+ if p == sym::iter || p == sym::iter_mut {
receiver
} else {
filter_recv
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index 4ae2249097f65..269d9384376f9 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -6,7 +6,6 @@ use std::io::BufReader;
use std::path::{Path, PathBuf};
use std::process::Command;
-use build_helper::ci::CiEnv;
use tracing::*;
use crate::common::{Config, Debugger, FailMode, Mode, PassMode};
@@ -298,13 +297,6 @@ impl TestProps {
/// `//[foo]`), then the property is ignored unless `cfg` is
/// `Some("foo")`.
fn load_from(&mut self, testfile: &Path, cfg: Option<&str>, config: &Config) {
- // In CI, we've sometimes encountered non-determinism related to truncating very long paths.
- // Set a consistent (short) prefix to avoid issues, but only in CI to avoid regressing the
- // contributor experience.
- if CiEnv::is_ci() {
- self.remap_src_base = config.mode == Mode::Ui && !config.suite.contains("rustdoc");
- }
-
let mut has_edition = false;
if !testfile.is_dir() {
let file = File::open(testfile).unwrap();
diff --git a/tests/ui/proc-macro/meta-macro-hygiene.stdout b/tests/ui/proc-macro/meta-macro-hygiene.stdout
index 17b69daa4f0e8..4a2200091b27e 100644
--- a/tests/ui/proc-macro/meta-macro-hygiene.stdout
+++ b/tests/ui/proc-macro/meta-macro-hygiene.stdout
@@ -18,7 +18,7 @@ Respanned: TokenStream [Ident { ident: "$crate", span: $DIR/auxiliary/make-macro
use core /* 0#1 */::prelude /* 0#1 */::rust_2018 /* 0#1 */::*;
#[macro_use /* 0#1 */]
extern crate core /* 0#1 */;
-extern crate compiler_builtins /* 442 */ as _ /* 0#1 */;
+extern crate compiler_builtins /* 443 */ as _ /* 0#1 */;
// Don't load unnecessary hygiene information from std
extern crate std /* 0#0 */;
diff --git a/tests/ui/proc-macro/nonterminal-token-hygiene.stdout b/tests/ui/proc-macro/nonterminal-token-hygiene.stdout
index 76d54ab2f1386..077a728a7a6ba 100644
--- a/tests/ui/proc-macro/nonterminal-token-hygiene.stdout
+++ b/tests/ui/proc-macro/nonterminal-token-hygiene.stdout
@@ -39,7 +39,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [
use ::core /* 0#1 */::prelude /* 0#1 */::rust_2015 /* 0#1 */::*;
#[macro_use /* 0#1 */]
extern crate core /* 0#2 */;
-extern crate compiler_builtins /* 442 */ as _ /* 0#2 */;
+extern crate compiler_builtins /* 443 */ as _ /* 0#2 */;
// Don't load unnecessary hygiene information from std
extern crate std /* 0#0 */;