Skip to content

Commit fb7e6d0

Browse files
committed
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
2 parents 6908c73 + a1956e2 commit fb7e6d0

File tree

13 files changed

+122
-44
lines changed

13 files changed

+122
-44
lines changed

compiler/rustc_expand/src/parse/tests.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use crate::tests::{matches_codepattern, string_to_stream, with_error_checking_parse};
1+
use crate::tests::{
2+
matches_codepattern, string_to_stream, with_error_checking_parse, with_expected_parse_error,
3+
};
24

35
use rustc_ast::ptr::P;
46
use rustc_ast::token::{self, Delimiter, Token};
@@ -51,11 +53,15 @@ fn string_to_item(source_str: String) -> Option<P<ast::Item>> {
5153
with_error_checking_parse(source_str, &sess(), |p| p.parse_item(ForceCollect::No))
5254
}
5355

54-
#[should_panic]
5556
#[test]
5657
fn bad_path_expr_1() {
58+
// This should trigger error: expected identifier, found keyword `return`
5759
create_default_session_globals_then(|| {
58-
string_to_expr("::abc::def::return".to_string());
60+
with_expected_parse_error(
61+
"::abc::def::return",
62+
"expected identifier, found keyword `return`",
63+
|p| p.parse_expr(),
64+
);
5965
})
6066
}
6167

compiler/rustc_expand/src/tests.rs

+48-21
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,33 @@ fn string_to_parser(ps: &ParseSess, source_str: String) -> Parser<'_> {
2222
new_parser_from_source_str(ps, PathBuf::from("bogofile").into(), source_str)
2323
}
2424

25+
fn create_test_handler() -> (Handler, Lrc<SourceMap>, Arc<Mutex<Vec<u8>>>) {
26+
let output = Arc::new(Mutex::new(Vec::new()));
27+
let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty()));
28+
let fallback_bundle = rustc_errors::fallback_fluent_bundle(
29+
vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE],
30+
false,
31+
);
32+
let emitter = EmitterWriter::new(
33+
Box::new(Shared { data: output.clone() }),
34+
Some(source_map.clone()),
35+
None,
36+
fallback_bundle,
37+
false,
38+
false,
39+
false,
40+
Some(140),
41+
false,
42+
false,
43+
TerminalUrl::No,
44+
);
45+
let handler = Handler::with_emitter(Box::new(emitter));
46+
(handler, source_map, output)
47+
}
48+
49+
/// Returns the result of parsing the given string via the given callback.
50+
///
51+
/// If there are any errors, this will panic.
2552
pub(crate) fn with_error_checking_parse<'a, T, F>(s: String, ps: &'a ParseSess, f: F) -> T
2653
where
2754
F: FnOnce(&mut Parser<'a>) -> PResult<'a, T>,
@@ -32,6 +59,26 @@ where
3259
x
3360
}
3461

62+
/// Verifies that parsing the given string using the given callback will
63+
/// generate an error that contains the given text.
64+
pub(crate) fn with_expected_parse_error<T, F>(source_str: &str, expected_output: &str, f: F)
65+
where
66+
F: for<'a> FnOnce(&mut Parser<'a>) -> PResult<'a, T>,
67+
{
68+
let (handler, source_map, output) = create_test_handler();
69+
let ps = ParseSess::with_span_handler(handler, source_map);
70+
let mut p = string_to_parser(&ps, source_str.to_string());
71+
let result = f(&mut p);
72+
assert!(result.is_ok());
73+
74+
let bytes = output.lock().unwrap();
75+
let actual_output = str::from_utf8(&bytes).unwrap();
76+
println!("expected output:\n------\n{}------", expected_output);
77+
println!("actual output:\n------\n{}------", actual_output);
78+
79+
assert!(actual_output.contains(expected_output))
80+
}
81+
3582
/// Maps a string to tts, using a made-up filename.
3683
pub(crate) fn string_to_stream(source_str: String) -> TokenStream {
3784
let ps = ParseSess::new(
@@ -130,13 +177,7 @@ impl<T: Write> Write for Shared<T> {
130177

131178
fn test_harness(file_text: &str, span_labels: Vec<SpanLabel>, expected_output: &str) {
132179
create_default_session_if_not_set_then(|_| {
133-
let output = Arc::new(Mutex::new(Vec::new()));
134-
135-
let fallback_bundle = rustc_errors::fallback_fluent_bundle(
136-
vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE],
137-
false,
138-
);
139-
let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty()));
180+
let (handler, source_map, output) = create_test_handler();
140181
source_map.new_source_file(Path::new("test.rs").to_owned().into(), file_text.to_owned());
141182

142183
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: &
148189
println!("text: {:?}", source_map.span_to_snippet(span));
149190
}
150191

151-
let emitter = EmitterWriter::new(
152-
Box::new(Shared { data: output.clone() }),
153-
Some(source_map.clone()),
154-
None,
155-
fallback_bundle,
156-
false,
157-
false,
158-
false,
159-
None,
160-
false,
161-
false,
162-
TerminalUrl::No,
163-
);
164-
let handler = Handler::with_emitter(Box::new(emitter));
165192
#[allow(rustc::untranslatable_diagnostic)]
166193
handler.span_err(msp, "foo");
167194

compiler/rustc_session/src/options.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1433,8 +1433,6 @@ options! {
14331433
dep_tasks: bool = (false, parse_bool, [UNTRACKED],
14341434
"print tasks that execute and the color their dep node gets (requires debug build) \
14351435
(default: no)"),
1436-
diagnostic_width: Option<usize> = (None, parse_opt_number, [UNTRACKED],
1437-
"set the current output width for diagnostic truncation"),
14381436
dont_buffer_diagnostics: bool = (false, parse_bool, [UNTRACKED],
14391437
"emit diagnostics rather than buffering (breaks NLL error downgrading, sorting) \
14401438
(default: no)"),

compiler/rustc_smir/src/rustc_smir/mod.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,10 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
825825
ty::Alias(alias_kind, alias_ty) => {
826826
TyKind::Alias(alias_kind.stable(tables), alias_ty.stable(tables))
827827
}
828-
ty::Param(_) => todo!(),
829-
ty::Bound(_, _) => todo!(),
828+
ty::Param(param_ty) => TyKind::Param(param_ty.stable(tables)),
829+
ty::Bound(debruijn_idx, bound_ty) => {
830+
TyKind::Bound(debruijn_idx.as_usize(), bound_ty.stable(tables))
831+
}
830832
ty::Placeholder(..)
831833
| ty::GeneratorWitness(_)
832834
| ty::GeneratorWitnessMIR(_, _)
@@ -837,3 +839,19 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
837839
}
838840
}
839841
}
842+
843+
impl<'tcx> Stable<'tcx> for rustc_middle::ty::ParamTy {
844+
type T = stable_mir::ty::ParamTy;
845+
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
846+
use stable_mir::ty::ParamTy;
847+
ParamTy { index: self.index, name: self.name.to_string() }
848+
}
849+
}
850+
851+
impl<'tcx> Stable<'tcx> for rustc_middle::ty::BoundTy {
852+
type T = stable_mir::ty::BoundTy;
853+
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
854+
use stable_mir::ty::BoundTy;
855+
BoundTy { var: self.var.as_usize(), kind: self.kind.stable(tables) }
856+
}
857+
}

compiler/rustc_smir/src/stable_mir/ty.rs

+14
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ type Span = Opaque;
1818
pub enum TyKind {
1919
RigidTy(RigidTy),
2020
Alias(AliasKind, AliasTy),
21+
Param(ParamTy),
22+
Bound(usize, BoundTy),
2123
}
2224

2325
#[derive(Clone, Debug)]
@@ -228,3 +230,15 @@ pub struct ExistentialProjection {
228230
pub generic_args: GenericArgs,
229231
pub term: TermKind,
230232
}
233+
234+
#[derive(Clone, Debug)]
235+
pub struct ParamTy {
236+
pub index: u32,
237+
pub name: String,
238+
}
239+
240+
#[derive(Clone, Debug)]
241+
pub struct BoundTy {
242+
pub var: usize,
243+
pub kind: BoundTyKind,
244+
}

compiler/rustc_span/src/symbol.rs

+2
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ symbols! {
372372
arm_target_feature,
373373
array,
374374
arrays,
375+
as_mut_ptr,
375376
as_ptr,
376377
as_ref,
377378
as_str,
@@ -858,6 +859,7 @@ symbols! {
858859
item,
859860
item_like_imports,
860861
iter,
862+
iter_mut,
861863
iter_repeat,
862864
iterator_collect_fn,
863865
kcfi,

library/std/src/sys/unix/rand.rs

+18-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ pub fn hashmap_random_keys() -> (u64, u64) {
1717
not(target_os = "tvos"),
1818
not(target_os = "watchos"),
1919
not(target_os = "openbsd"),
20-
not(target_os = "freebsd"),
2120
not(target_os = "netbsd"),
2221
not(target_os = "fuchsia"),
2322
not(target_os = "redox"),
@@ -68,11 +67,25 @@ mod imp {
6867
unsafe { libc::getrandom(buf.as_mut_ptr().cast(), buf.len(), 0) }
6968
}
7069

70+
#[cfg(target_os = "freebsd")]
71+
fn getrandom(buf: &mut [u8]) -> libc::ssize_t {
72+
// FIXME: using the above when libary std's libc is updated
73+
extern "C" {
74+
fn getrandom(
75+
buffer: *mut libc::c_void,
76+
length: libc::size_t,
77+
flags: libc::c_uint,
78+
) -> libc::ssize_t;
79+
}
80+
unsafe { getrandom(buf.as_mut_ptr().cast(), buf.len(), 0) }
81+
}
82+
7183
#[cfg(not(any(
7284
target_os = "linux",
7385
target_os = "android",
7486
target_os = "espidf",
75-
target_os = "horizon"
87+
target_os = "horizon",
88+
target_os = "freebsd"
7689
)))]
7790
fn getrandom_fill_bytes(_buf: &mut [u8]) -> bool {
7891
false
@@ -82,7 +95,8 @@ mod imp {
8295
target_os = "linux",
8396
target_os = "android",
8497
target_os = "espidf",
85-
target_os = "horizon"
98+
target_os = "horizon",
99+
target_os = "freebsd"
86100
))]
87101
fn getrandom_fill_bytes(v: &mut [u8]) -> bool {
88102
use crate::sync::atomic::{AtomicBool, Ordering};
@@ -222,7 +236,7 @@ mod imp {
222236
}
223237
}
224238

225-
#[cfg(any(target_os = "freebsd", target_os = "netbsd"))]
239+
#[cfg(target_os = "netbsd")]
226240
mod imp {
227241
use crate::ptr;
228242

src/bootstrap/download-ci-llvm-stamp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Change this file to make users of the `download-ci-llvm` configuration download
22
a new version of LLVM from CI, even if the LLVM submodule hasn’t changed.
33

4-
Last change is for: https://github.com/rust-lang/rust/pull/112931
4+
Last change is for: https://github.com/rust-lang/rust/pull/113996

src/bootstrap/llvm.rs

+7
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,8 @@ fn configure_cmake(
559559

560560
if target.contains("netbsd") {
561561
cfg.define("CMAKE_SYSTEM_NAME", "NetBSD");
562+
} else if target.contains("dragonfly") {
563+
cfg.define("CMAKE_SYSTEM_NAME", "DragonFly");
562564
} else if target.contains("freebsd") {
563565
cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD");
564566
} else if target.contains("windows") {
@@ -569,7 +571,12 @@ fn configure_cmake(
569571
cfg.define("CMAKE_SYSTEM_NAME", "SunOS");
570572
} else if target.contains("linux") {
571573
cfg.define("CMAKE_SYSTEM_NAME", "Linux");
574+
} else {
575+
builder.info(
576+
"could not determine CMAKE_SYSTEM_NAME from the target `{target}`, build may fail",
577+
);
572578
}
579+
573580
// When cross-compiling we should also set CMAKE_SYSTEM_VERSION, but in
574581
// that case like CMake we cannot easily determine system version either.
575582
//

src/tools/clippy/clippy_lints/src/methods/bytecount.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub(super) fn check<'tcx>(
4545
let haystack = if let ExprKind::MethodCall(path, receiver, [], _) =
4646
filter_recv.kind {
4747
let p = path.ident.name;
48-
if p == sym::iter || p == sym!(iter_mut) {
48+
if p == sym::iter || p == sym::iter_mut {
4949
receiver
5050
} else {
5151
filter_recv

src/tools/compiletest/src/header.rs

-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::io::BufReader;
66
use std::path::{Path, PathBuf};
77
use std::process::Command;
88

9-
use build_helper::ci::CiEnv;
109
use tracing::*;
1110

1211
use crate::common::{Config, Debugger, FailMode, Mode, PassMode};
@@ -298,13 +297,6 @@ impl TestProps {
298297
/// `//[foo]`), then the property is ignored unless `cfg` is
299298
/// `Some("foo")`.
300299
fn load_from(&mut self, testfile: &Path, cfg: Option<&str>, config: &Config) {
301-
// In CI, we've sometimes encountered non-determinism related to truncating very long paths.
302-
// Set a consistent (short) prefix to avoid issues, but only in CI to avoid regressing the
303-
// contributor experience.
304-
if CiEnv::is_ci() {
305-
self.remap_src_base = config.mode == Mode::Ui && !config.suite.contains("rustdoc");
306-
}
307-
308300
let mut has_edition = false;
309301
if !testfile.is_dir() {
310302
let file = File::open(testfile).unwrap();

tests/ui/proc-macro/meta-macro-hygiene.stdout

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Respanned: TokenStream [Ident { ident: "$crate", span: $DIR/auxiliary/make-macro
1818
use core /* 0#1 */::prelude /* 0#1 */::rust_2018 /* 0#1 */::*;
1919
#[macro_use /* 0#1 */]
2020
extern crate core /* 0#1 */;
21-
extern crate compiler_builtins /* 442 */ as _ /* 0#1 */;
21+
extern crate compiler_builtins /* 443 */ as _ /* 0#1 */;
2222
// Don't load unnecessary hygiene information from std
2323
extern crate std /* 0#0 */;
2424

tests/ui/proc-macro/nonterminal-token-hygiene.stdout

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [
3939
use ::core /* 0#1 */::prelude /* 0#1 */::rust_2015 /* 0#1 */::*;
4040
#[macro_use /* 0#1 */]
4141
extern crate core /* 0#2 */;
42-
extern crate compiler_builtins /* 442 */ as _ /* 0#2 */;
42+
extern crate compiler_builtins /* 443 */ as _ /* 0#2 */;
4343
// Don't load unnecessary hygiene information from std
4444
extern crate std /* 0#0 */;
4545

0 commit comments

Comments
 (0)