Skip to content

Rollup of 11 pull requests #129691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d7e7886
docs: correct panic conditions for rem_euclid and similar functions
lolbinarycat Aug 23, 2024
a772db4
ub_checks intrinsics: fall back to cfg(ub_checks)
RalfJung Aug 25, 2024
7ea2981
const-eval: do not make UbChecks behavior depend on current crate's f…
RalfJung Aug 26, 2024
7a290fc
interpret: do not make const-eval query result depend on tcx.sess
RalfJung Aug 26, 2024
a1746b4
rustdoc: fix missing resource suffix on `crates.js`
notriddle Aug 27, 2024
1ad218f
safe transmute: Rename `BikeshedIntrinsicFrom` to `TransmuteFrom`
jswrenn Aug 27, 2024
c3000ad
add repr to the allowlist for naked functions, and test that it works
jdonszelmann Aug 22, 2024
a507ec6
add uitest for naked functions and the repr attr on functions
jdonszelmann Aug 27, 2024
e17be95
interpret: add missing alignment check in raw_eq
RalfJung Aug 27, 2024
0d6c915
Fix Pin::set bounds regression
coolreader18 Aug 27, 2024
ddcb073
replace is_some() -> unwrap with if let
Aug 27, 2024
b218623
cleanup make_input
Aug 27, 2024
a007d34
clarify a few things
Aug 27, 2024
c35e01e
clarify what term can be
Aug 27, 2024
f61f34f
coverage: `CodeRegion` is never stored in an arena
Zalathar Aug 28, 2024
5e162a8
coverage: Simplify some debug logging
Zalathar Aug 28, 2024
46e1b5b
coverage: Rename `CodeRegion` to `SourceRegion`
Zalathar Aug 28, 2024
99453ce
Rollup merge of #129421 - jdonszelmann:naked-repr-align-functions, r=…
matthiaskrgr Aug 28, 2024
56ca2e2
Rollup merge of #129480 - lolbinarycat:euclid-docs, r=joboet
matthiaskrgr Aug 28, 2024
0156208
Rollup merge of #129551 - RalfJung:ub-checks-fallback, r=saethlin
matthiaskrgr Aug 28, 2024
3456b1d
Rollup merge of #129608 - RalfJung:const-eval-ub-checks, r=saethlin
matthiaskrgr Aug 28, 2024
39e840f
Rollup merge of #129613 - RalfJung:interpret-target-feat, r=saethlin
matthiaskrgr Aug 28, 2024
5725119
Rollup merge of #129641 - notriddle:notriddle/missing-crates-js-resou…
matthiaskrgr Aug 28, 2024
29188a5
Rollup merge of #129657 - jswrenn:transmute-name, r=compiler-errors
matthiaskrgr Aug 28, 2024
5c2996d
Rollup merge of #129666 - RalfJung:raw-eq-align, r=compiler-errors
matthiaskrgr Aug 28, 2024
472c964
Rollup merge of #129667 - dev-ardi:rustc_driver-cleanup, r=michaelwoe…
matthiaskrgr Aug 28, 2024
27d7fb0
Rollup merge of #129668 - coolreader18:fix-pin-set-regr, r=dtolnay
matthiaskrgr Aug 28, 2024
4854fa7
Rollup merge of #129686 - Zalathar:source-region, r=compiler-errors
matthiaskrgr Aug 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 36 additions & 29 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,17 @@ fn run_compiler(

let linker = compiler.enter(|queries| {
let early_exit = || early_exit().map(|_| None);

// Parse the crate root source code (doesn't parse submodules yet)
// Everything else is parsed during macro expansion.
queries.parse()?;

if let Some(ppm) = &sess.opts.pretty {
if ppm.needs_ast_map() {
// If pretty printing is requested: Figure out the representation, print it and exit
if let Some(pp_mode) = sess.opts.pretty {
if pp_mode.needs_ast_map() {
queries.global_ctxt()?.enter(|tcx| {
tcx.ensure().early_lint_checks(());
pretty::print(sess, *ppm, pretty::PrintExtra::NeedsAstMap { tcx });
pretty::print(sess, pp_mode, pretty::PrintExtra::NeedsAstMap { tcx });
Ok(())
})?;

Expand All @@ -410,7 +414,7 @@ fn run_compiler(
let krate = queries.parse()?;
pretty::print(
sess,
*ppm,
pp_mode,
pretty::PrintExtra::AfterParsing { krate: &*krate.borrow() },
);
}
Expand Down Expand Up @@ -465,12 +469,8 @@ fn run_compiler(
linker.link(sess, codegen_backend)?
}

if sess.opts.unstable_opts.print_fuel.is_some() {
eprintln!(
"Fuel used by {}: {}",
sess.opts.unstable_opts.print_fuel.as_ref().unwrap(),
sess.print_fuel.load(Ordering::SeqCst)
);
if let Some(fuel) = sess.opts.unstable_opts.print_fuel.as_deref() {
eprintln!("Fuel used by {}: {}", fuel, sess.print_fuel.load(Ordering::SeqCst));
}

Ok(())
Expand All @@ -487,36 +487,43 @@ fn make_output(matches: &getopts::Matches) -> (Option<PathBuf>, Option<OutFileNa
(odir, ofile)
}

// Extract input (string or file and optional path) from matches.
/// Extract input (string or file and optional path) from matches.
/// This handles reading from stdin if `-` is provided.
fn make_input(
early_dcx: &EarlyDiagCtxt,
free_matches: &[String],
) -> Result<Option<Input>, ErrorGuaranteed> {
let [ifile] = free_matches else { return Ok(None) };
if ifile == "-" {
let mut src = String::new();
if io::stdin().read_to_string(&mut src).is_err() {
// Immediately stop compilation if there was an issue reading
// the input (for example if the input stream is not UTF-8).
let reported =
early_dcx.early_err("couldn't read from stdin, as it did not contain valid UTF-8");
return Err(reported);
}
if let Ok(path) = env::var("UNSTABLE_RUSTDOC_TEST_PATH") {
let [input_file] = free_matches else { return Ok(None) };

if input_file != "-" {
// Normal `Input::File`
return Ok(Some(Input::File(PathBuf::from(input_file))));
}

// read from stdin as `Input::Str`
let mut input = String::new();
if io::stdin().read_to_string(&mut input).is_err() {
// Immediately stop compilation if there was an issue reading
// the input (for example if the input stream is not UTF-8).
let reported =
early_dcx.early_err("couldn't read from stdin, as it did not contain valid UTF-8");
return Err(reported);
}

let name = match env::var("UNSTABLE_RUSTDOC_TEST_PATH") {
Ok(path) => {
let line = env::var("UNSTABLE_RUSTDOC_TEST_LINE").expect(
"when UNSTABLE_RUSTDOC_TEST_PATH is set \
UNSTABLE_RUSTDOC_TEST_LINE also needs to be set",
);
let line = isize::from_str_radix(&line, 10)
.expect("UNSTABLE_RUSTDOC_TEST_LINE needs to be an number");
let file_name = FileName::doc_test_source_code(PathBuf::from(path), line);
Ok(Some(Input::Str { name: file_name, input: src }))
} else {
Ok(Some(Input::Str { name: FileName::anon_source_code(&src), input: src }))
FileName::doc_test_source_code(PathBuf::from(path), line)
}
} else {
Ok(Some(Input::File(PathBuf::from(ifile))))
}
Err(_) => FileName::anon_source_code(&input),
};

Ok(Some(Input::Str { name, input }))
}

/// Whether to stop or continue compilation.
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ impl<'a> Parser<'a> {
}

/// Parses the contents of a module (inner attributes followed by module items).
/// We exit once we hit `term`
/// We exit once we hit `term` which can be either
/// - EOF (for files)
/// - `}` for mod items
pub fn parse_mod(
&mut self,
term: &TokenKind,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2893,6 +2893,7 @@ pub enum PpHirMode {
}

#[derive(Copy, Clone, PartialEq, Debug)]
/// Pretty print mode
pub enum PpMode {
/// Options that print the source code, i.e.
/// `-Zunpretty=normal` and `-Zunpretty=expanded`
Expand Down