Auto merge of #114103 - matthiaskrgr:rollup-01m6l2w, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #101994 (rand: freebsd update, using getrandom.) - #113930 (Add Param and Bound ty to SMIR) - #113942 (Squelch a noisy rustc_expand unittest) - #113996 (Define CMAKE_SYSTEM_NAME on a cross build targeting DragonFly.) - #114070 (Add `sym::iter_mut` + `sym::as_mut_ptr` for Clippy) - #114073 (Remove -Z diagnostic-width) - #114090 (compiletest: remove ci-specific remap-path-prefix) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
fb7e6d078d
@ -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<P<ast::Item>> {
|
||||
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(),
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -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<SourceMap>, Arc<Mutex<Vec<u8>>>) {
|
||||
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<T, F>(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<T: Write> Write for Shared<T> {
|
||||
|
||||
fn test_harness(file_text: &str, span_labels: Vec<SpanLabel>, 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<SpanLabel>, 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");
|
||||
|
||||
|
@ -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<usize> = (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)"),
|
||||
|
@ -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) }
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
//
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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 */;
|
||||
|
||||
|
@ -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 */;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user