Skip to content

Rollup of 10 pull requests #111767

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

Closed
wants to merge 21 commits into from
Closed
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
926e874
Dont check `must_use` on nested `impl Future` from fn
compiler-errors May 12, 2023
addc727
Profile MIR passes.
cjgillot May 15, 2023
d371b80
Bump `cc` for `bootstrap`
r-value May 18, 2023
e6a7fde
Give a more useful location for where a span_bug was delayed
jyn514 May 18, 2023
f577cc4
Fix doc comment for `ConstParamTy` derive
juntyr May 18, 2023
30c0e4e
Add more tests for the offset_of!() macro
est31 May 17, 2023
3e4ed61
do not overwrite obligations
lcnr May 18, 2023
0426562
very minor cleanups
jyn514 May 15, 2023
ad5955b
Migrate GUI colors test to original CSS color format
GuillaumeGomez May 18, 2023
1551495
Fix an ICE in CGU dumping code.
nnethercote May 18, 2023
1bb957e
Improve CGU partitioning debug output.
nnethercote May 18, 2023
957104b
Rollup merge of #111491 - compiler-errors:nested-fut-must-use, r=wesl…
GuillaumeGomez May 19, 2023
2d7edbe
Rollup merge of #111606 - jyn514:nightly-diagnostics, r=lcnr
GuillaumeGomez May 19, 2023
1767746
Rollup merge of #111619 - cjgillot:profile-pass, r=WaffleLapkin
GuillaumeGomez May 19, 2023
ce40bb9
Rollup merge of #111665 - est31:offset_of_tests, r=WaffleLapkin
GuillaumeGomez May 19, 2023
cb36cae
Rollup merge of #111701 - r-value:patch-1, r=jyn514
GuillaumeGomez May 19, 2023
a245a48
Rollup merge of #111708 - jyn514:delay-span-bug-msg, r=compiler-errors
GuillaumeGomez May 19, 2023
7853c25
Rollup merge of #111715 - juntyr:const-param-ty-derive-fix, r=Nilstrieb
GuillaumeGomez May 19, 2023
6bb24b1
Rollup merge of #111723 - lcnr:overwrite-obligations, r=compiler-errors
GuillaumeGomez May 19, 2023
61e1b0a
Rollup merge of #111726 - GuillaumeGomez:gui-test-migrate-color, r=no…
GuillaumeGomez May 19, 2023
cd64248
Rollup merge of #111743 - nnethercote:improve-cgu-merging-debug-outpu…
GuillaumeGomez May 19, 2023
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
3 changes: 2 additions & 1 deletion compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1250,7 +1250,8 @@ pub fn install_ice_hook(bug_report_url: &'static str, extra_info: fn(&Handler))
#[cfg(windows)]
if let Some(msg) = info.payload().downcast_ref::<String>() {
if msg.starts_with("failed printing to stdout: ") && msg.ends_with("(os error 232)") {
early_error_no_abort(ErrorOutputType::default(), msg.as_str());
// the error code is already going to be reported when the panic unwinds up the stack
let _ = early_error_no_abort(ErrorOutputType::default(), msg.as_str());
return;
}
};
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1740,7 +1740,7 @@ impl DelayedDiagnostic {
}

fn decorate(mut self) -> Diagnostic {
self.inner.note(format!("delayed at {}", self.note));
self.inner.note(format!("delayed at {}\n{}", self.inner.emitted_at, self.note));
self.inner
}
}
13 changes: 6 additions & 7 deletions compiler/rustc_infer/src/infer/opaque_types.rs
Original file line number Diff line number Diff line change
@@ -530,19 +530,18 @@ impl<'tcx> InferCtxt<'tcx> {
// these are the same span, but not in cases like `-> (impl
// Foo, impl Bar)`.
let span = cause.span;

let mut obligations = vec![];
let prev = self.inner.borrow_mut().opaque_types().register(
OpaqueTypeKey { def_id, substs },
OpaqueHiddenType { ty: hidden_ty, span },
origin,
);
if let Some(prev) = prev {
obligations = self
.at(&cause, param_env)
let mut obligations = if let Some(prev) = prev {
self.at(&cause, param_env)
.eq_exp(DefineOpaqueTypes::Yes, a_is_expected, prev, hidden_ty)?
.obligations;
}
.obligations
} else {
Vec::new()
};

let item_bounds = tcx.explicit_item_bounds(def_id);

4 changes: 3 additions & 1 deletion compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
@@ -103,8 +103,10 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
&& let ty = cx.typeck_results().expr_ty(&await_expr)
&& let ty::Alias(ty::Opaque, ty::AliasTy { def_id: future_def_id, .. }) = ty.kind()
&& cx.tcx.ty_is_opaque_future(ty)
// FIXME: This also includes non-async fns that return `impl Future`.
&& let async_fn_def_id = cx.tcx.parent(*future_def_id)
&& matches!(cx.tcx.def_kind(async_fn_def_id), DefKind::Fn | DefKind::AssocFn)
// Check that this `impl Future` actually comes from an `async fn`
&& cx.tcx.asyncness(async_fn_def_id).is_async()
&& check_must_use_def(
cx,
async_fn_def_id,
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
@@ -101,7 +101,7 @@ impl<'tcx> HasLocalDecls<'tcx> for Body<'tcx> {
/// pass will be named after the type, and it will consist of a main
/// loop that goes over each available MIR and applies `run_pass`.
pub trait MirPass<'tcx> {
fn name(&self) -> &str {
fn name(&self) -> &'static str {
let name = std::any::type_name::<Self>();
if let Some((_, tail)) = name.rsplit_once(':') { tail } else { name }
}
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/dump_mir.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ use rustc_session::config::OutputType;
pub struct Marker(pub &'static str);

impl<'tcx> MirPass<'tcx> for Marker {
fn name(&self) -> &str {
fn name(&self) -> &'static str {
self.0
}

8 changes: 4 additions & 4 deletions compiler/rustc_mir_transform/src/pass_manager.rs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ use crate::{validate, MirPass};

/// Just like `MirPass`, except it cannot mutate `Body`.
pub trait MirLint<'tcx> {
fn name(&self) -> &str {
fn name(&self) -> &'static str {
let name = std::any::type_name::<Self>();
if let Some((_, tail)) = name.rsplit_once(':') { tail } else { name }
}
@@ -26,7 +26,7 @@ impl<'tcx, T> MirPass<'tcx> for Lint<T>
where
T: MirLint<'tcx>,
{
fn name(&self) -> &str {
fn name(&self) -> &'static str {
self.0.name()
}

@@ -49,7 +49,7 @@ impl<'tcx, T> MirPass<'tcx> for WithMinOptLevel<T>
where
T: MirPass<'tcx>,
{
fn name(&self) -> &str {
fn name(&self) -> &'static str {
self.1.name()
}

@@ -121,7 +121,7 @@ fn run_passes_inner<'tcx>(
validate_body(tcx, body, format!("before pass {}", name));
}

pass.run_pass(tcx, body);
tcx.sess.time(name, || pass.run_pass(tcx, body));

if dump_enabled {
dump_mir_for_pass(tcx, body, &name, true);
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/simplify.rs
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ pub fn simplify_cfg<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
}

impl<'tcx> MirPass<'tcx> for SimplifyCfg {
fn name(&self) -> &str {
fn name(&self) -> &'static str {
&self.name()
}

30 changes: 18 additions & 12 deletions compiler/rustc_monomorphize/src/partitioning/mod.rs
Original file line number Diff line number Diff line change
@@ -250,13 +250,13 @@ where
cgu.create_size_estimate(tcx);
}

debug_dump(tcx, "INITIAL PARTITIONING:", initial_partitioning.codegen_units.iter());
debug_dump(tcx, "INITIAL PARTITIONING", &initial_partitioning.codegen_units);

// Merge until we have at most `max_cgu_count` codegen units.
{
let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_merge_cgus");
partitioner.merge_codegen_units(cx, &mut initial_partitioning);
debug_dump(tcx, "POST MERGING:", initial_partitioning.codegen_units.iter());
debug_dump(tcx, "POST MERGING", &initial_partitioning.codegen_units);
}

// In the next step, we use the inlining map to determine which additional
@@ -272,7 +272,7 @@ where
cgu.create_size_estimate(tcx);
}

debug_dump(tcx, "POST INLINING:", post_inlining.codegen_units.iter());
debug_dump(tcx, "POST INLINING", &post_inlining.codegen_units);

// Next we try to make as many symbols "internal" as possible, so LLVM has
// more freedom to optimize.
@@ -322,6 +322,8 @@ where

result.sort_by(|a, b| a.name().as_str().cmp(b.name().as_str()));

debug_dump(tcx, "FINAL", &result);

result
}

@@ -346,33 +348,37 @@ struct PostInliningPartitioning<'tcx> {
internalization_candidates: FxHashSet<MonoItem<'tcx>>,
}

fn debug_dump<'a, 'tcx, I>(tcx: TyCtxt<'tcx>, label: &str, cgus: I)
where
I: Iterator<Item = &'a CodegenUnit<'tcx>>,
'tcx: 'a,
{
fn debug_dump<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx>, label: &str, cgus: &[CodegenUnit<'tcx>]) {
let dump = move || {
use std::fmt::Write;

let num_cgus = cgus.len();
let max = cgus.iter().map(|cgu| cgu.size_estimate()).max().unwrap();
let min = cgus.iter().map(|cgu| cgu.size_estimate()).min().unwrap();
let ratio = max as f64 / min as f64;

let s = &mut String::new();
let _ = writeln!(s, "{label}");
let _ = writeln!(
s,
"{label} ({num_cgus} CodegenUnits, max={max}, min={min}, max/min={ratio:.1}):"
);
for cgu in cgus {
let _ =
writeln!(s, "CodegenUnit {} estimated size {} :", cgu.name(), cgu.size_estimate());
writeln!(s, "CodegenUnit {} estimated size {}:", cgu.name(), cgu.size_estimate());

for (mono_item, linkage) in cgu.items() {
let symbol_name = mono_item.symbol_name(tcx).name;
let symbol_hash_start = symbol_name.rfind('h');
let symbol_hash = symbol_hash_start.map_or("<no hash>", |i| &symbol_name[i..]);

let _ = writeln!(
let _ = with_no_trimmed_paths!(writeln!(
s,
" - {} [{:?}] [{}] estimated size {}",
mono_item,
linkage,
symbol_hash,
mono_item.size_estimate(tcx)
);
));
}

let _ = writeln!(s);
1 change: 1 addition & 0 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -238,6 +238,7 @@ impl<'a> DerefMut for SnapshotParser<'a> {

impl<'a> Parser<'a> {
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_span_err<S: Into<MultiSpan>>(
&self,
sp: S,
1 change: 1 addition & 0 deletions compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
@@ -1732,6 +1732,7 @@ fn early_error_handler(output: config::ErrorOutputType) -> rustc_errors::Handler

#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
#[must_use = "ErrorGuaranteed must be returned from `run_compiler` in order to exit with a non-zero status code"]
pub fn early_error_no_abort(
output: config::ErrorOutputType,
msg: impl Into<DiagnosticMessage>,
2 changes: 1 addition & 1 deletion library/core/src/marker.rs
Original file line number Diff line number Diff line change
@@ -986,7 +986,7 @@ pub trait PointerLike {}
#[rustc_on_unimplemented(message = "`{Self}` can't be used as a const parameter type")]
pub trait ConstParamTy: StructuralEq {}

/// Derive macro generating an impl of the trait `Copy`.
/// Derive macro generating an impl of the trait `ConstParamTy`.
#[rustc_builtin_macro]
#[unstable(feature = "adt_const_params", issue = "95174")]
#[cfg(not(bootstrap))]
15 changes: 15 additions & 0 deletions library/core/tests/mem.rs
Original file line number Diff line number Diff line change
@@ -386,6 +386,21 @@ fn offset_of() {
// Layout of tuples is unstable
assert!(offset_of!((u8, u16), 0) <= size_of::<(u8, u16)>() - 1);
assert!(offset_of!((u8, u16), 1) <= size_of::<(u8, u16)>() - 2);

#[repr(C)]
struct Generic<T> {
x: u8,
y: u32,
z: T
}

// Ensure that this type of generics works
fn offs_of_z<T>() -> usize {
offset_of!(Generic<T>, z)
}

assert_eq!(offset_of!(Generic<u8>, z), 8);
assert_eq!(offs_of_z::<u8>(), 8);
}

#[test]
4 changes: 2 additions & 2 deletions src/bootstrap/Cargo.lock
Original file line number Diff line number Diff line change
@@ -89,9 +89,9 @@ version = "0.1.0"

[[package]]
name = "cc"
version = "1.0.73"
version = "1.0.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4"

[[package]]
name = "cfg-if"
1 change: 0 additions & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
@@ -942,7 +942,6 @@ impl<'a> Builder<'a> {
self.run_step_descriptions(&Builder::get_step_descriptions(Kind::Doc), paths);
}

/// NOTE: keep this in sync with `rustdoc::clean::utils::doc_rust_lang_org_channel`, or tests will fail on beta/stable.
pub fn doc_rust_lang_org_channel(&self) -> String {
let channel = match &*self.config.channel {
"stable" => &self.version,
22 changes: 11 additions & 11 deletions tests/rustdoc-gui/source-code-page.goml
Original file line number Diff line number Diff line change
@@ -40,24 +40,24 @@ define-function: (

call-function: ("check-colors", {
"theme": "ayu",
"color": "rgb(92, 103, 115)",
"background_color": "rgba(0, 0, 0, 0)",
"highlight_color": "rgb(112, 128, 144)",
"color": "#5c6773",
"background_color": "transparent",
"highlight_color": "#708090",
"highlight_background_color": "rgba(255, 236, 164, 0.06)",
})
call-function: ("check-colors", {
"theme": "dark",
"color": "rgb(59, 145, 226)",
"background_color": "rgba(0, 0, 0, 0)",
"highlight_color": "rgb(59, 145, 226)",
"highlight_background_color": "rgb(10, 4, 47)",
"color": "#3b91e2",
"background_color": "transparent",
"highlight_color": "#3b91e2",
"highlight_background_color": "#0a042f",
})
call-function: ("check-colors", {
"theme": "light",
"color": "rgb(198, 126, 45)",
"background_color": "rgba(0, 0, 0, 0)",
"highlight_color": "rgb(198, 126, 45)",
"highlight_background_color": "rgb(253, 255, 211)",
"color": "#c67e2d",
"background_color": "transparent",
"highlight_color": "#c67e2d",
"highlight_background_color": "#fdffd3",
})

// This is to ensure that the content is correctly align with the line numbers.
12 changes: 12 additions & 0 deletions tests/ui/lint/unused/auxiliary/must-use-foreign.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// edition:2021

use std::future::Future;

pub struct Manager;

impl Manager {
#[must_use]
pub async fn new() -> (Self, impl Future<Output = ()>) {
(Manager, async {})
}
}
15 changes: 15 additions & 0 deletions tests/ui/lint/unused/must-use-foreign.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// edition:2021
// aux-build:must-use-foreign.rs
// check-pass

extern crate must_use_foreign;

use must_use_foreign::Manager;

async fn async_main() {
Manager::new().await.1.await;
}

fn main() {
let _ = async_main();
}
2 changes: 1 addition & 1 deletion tests/ui/lint/unused/unused-async.rs
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ async fn test() {
foo().await; //~ ERROR unused output of future returned by `foo` that must be used
bar(); //~ ERROR unused return value of `bar` that must be used
//~^ ERROR unused implementer of `Future` that must be used
bar().await; //~ ERROR unused output of future returned by `bar` that must be used
bar().await; // ok, it's not an async fn
baz(); //~ ERROR unused implementer of `Future` that must be used
baz().await; // ok
}
13 changes: 1 addition & 12 deletions tests/ui/lint/unused/unused-async.stderr
Original file line number Diff line number Diff line change
@@ -52,17 +52,6 @@ help: use `let _ = ...` to ignore the resulting value
LL | let _ = bar();
| +++++++

error: unused output of future returned by `bar` that must be used
--> $DIR/unused-async.rs:36:5
|
LL | bar().await;
| ^^^^^^^^^^^
|
help: use `let _ = ...` to ignore the resulting value
|
LL | let _ = bar().await;
| +++++++

error: unused implementer of `Future` that must be used
--> $DIR/unused-async.rs:37:5
|
@@ -71,5 +60,5 @@ LL | baz();
|
= note: futures do nothing unless you `.await` or poll them

error: aborting due to 7 previous errors
error: aborting due to 6 previous errors

15 changes: 15 additions & 0 deletions tests/ui/offset-of/offset-of-dst-field.rs
Original file line number Diff line number Diff line change
@@ -26,8 +26,23 @@ struct Gamma {
z: Extern,
}

struct Delta<T: ?Sized> {
x: u8,
y: u16,
z: T,
}

fn main() {
offset_of!(Alpha, z); //~ ERROR the size for values of type
offset_of!(Beta, z); //~ ERROR the size for values of type
offset_of!(Gamma, z); //~ ERROR the size for values of type
}

fn delta() {
offset_of!(Delta<Alpha>, z); //~ ERROR the size for values of type
offset_of!(Delta<Extern>, z); //~ ERROR the size for values of type
}

fn generic_with_maybe_sized<T: ?Sized>() -> usize {
offset_of!(Delta<T>, z) //~ ERROR the size for values of type
}
Loading