Skip to content

Commit f6a07ef

Browse files
committed
Auto merge of #151224 - matthiaskrgr:rollup-SLK4owB, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #151196 (Ship LLVM (`rust-dev`) in fast try builds again) - #151198 (Add an additional help note to the ambiguity lint error) - #151215 (Add missing closing brackets to THIR output.) - #151218 (compiletest: Add `AuxCrate` struct with docs.) r? @ghost
2 parents 503745e + 2c2b622 commit f6a07ef

23 files changed

+1067
-37
lines changed

compiler/rustc_mir_build/src/thir/print.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,8 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
618618
print_indented!(self, format!("args: {:?}", adt_expr.args), depth_lvl + 1);
619619
print_indented!(self, format!("user_ty: {:?}", adt_expr.user_ty), depth_lvl + 1);
620620

621-
for (i, field_expr) in adt_expr.fields.iter().enumerate() {
622-
print_indented!(self, format!("field {}:", i), depth_lvl + 1);
621+
for field_expr in adt_expr.fields.iter() {
622+
print_indented!(self, format!("field {}:", field_expr.name.as_u32()), depth_lvl + 1);
623623
self.print_expr(field_expr.expr, depth_lvl + 2);
624624
}
625625

@@ -643,6 +643,7 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
643643
print_indented!(self, format!("variants: {:?}", adt_def.variants()), depth_lvl + 1);
644644
print_indented!(self, format!("flags: {:?}", adt_def.flags()), depth_lvl + 1);
645645
print_indented!(self, format!("repr: {:?}", adt_def.repr()), depth_lvl + 1);
646+
print_indented!(self, "}", depth_lvl);
646647
}
647648

648649
fn print_fru_info(&mut self, fru_info: &FruInfo<'tcx>, depth_lvl: usize) {
@@ -653,6 +654,7 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
653654
for ty in fru_info.field_types.iter() {
654655
print_indented!(self, format!("ty: {:?}", ty), depth_lvl + 2);
655656
}
657+
print_indented!(self, "]", depth_lvl + 1);
656658
print_indented!(self, "}", depth_lvl);
657659
}
658660

@@ -683,7 +685,7 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
683685
fn print_pat(&mut self, pat: &Pat<'tcx>, depth_lvl: usize) {
684686
let &Pat { ty, span, ref kind, ref extra } = pat;
685687

686-
print_indented!(self, "Pat: {", depth_lvl);
688+
print_indented!(self, "Pat {", depth_lvl);
687689
print_indented!(self, format!("ty: {:?}", ty), depth_lvl + 1);
688690
print_indented!(self, format!("span: {:?}", span), depth_lvl + 1);
689691
self.print_pat_extra(extra.as_deref(), depth_lvl + 1);
@@ -913,6 +915,8 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
913915

914916
print_indented!(self, format!("options: {:?}", options), depth_lvl + 1);
915917
print_indented!(self, format!("line_spans: {:?}", line_spans), depth_lvl + 1);
918+
919+
print_indented!(self, "}", depth_lvl);
916920
}
917921

918922
fn print_inline_operand(&mut self, operand: &InlineAsmOperand<'tcx>, depth_lvl: usize) {

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,9 +2064,24 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
20642064
};
20652065
let (b1_note, b1_help_msgs) = could_refer_to(b1, scope1, "");
20662066
let (b2_note, b2_help_msgs) = could_refer_to(b2, scope2, " also");
2067+
let help = if kind == AmbiguityKind::GlobVsGlob
2068+
&& b1
2069+
.parent_module
2070+
.and_then(|m| m.opt_def_id())
2071+
.map(|d| !d.is_local())
2072+
.unwrap_or_default()
2073+
{
2074+
Some(&[
2075+
"consider updating this dependency to resolve this error",
2076+
"if updating the dependency does not resolve the problem report the problem to the author of the relevant crate",
2077+
] as &[_])
2078+
} else {
2079+
None
2080+
};
20672081

20682082
errors::Ambiguity {
20692083
ident,
2084+
help,
20702085
kind: kind.descr(),
20712086
b1_note,
20722087
b1_help_msgs,

compiler/rustc_resolve/src/errors.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,7 @@ pub(crate) struct UnknownDiagnosticAttributeTypoSugg {
14641464
pub(crate) struct Ambiguity {
14651465
pub ident: Ident,
14661466
pub kind: &'static str,
1467+
pub help: Option<&'static [&'static str]>,
14671468
pub b1_note: Spanned<String>,
14681469
pub b1_help_msgs: Vec<String>,
14691470
pub b2_note: Spanned<String>,
@@ -1476,6 +1477,11 @@ impl Ambiguity {
14761477
diag.span_label(self.ident.span, "ambiguous name");
14771478
diag.note(format!("ambiguous because of {}", self.kind));
14781479
diag.span_note(self.b1_note.span, self.b1_note.node);
1480+
if let Some(help) = self.help {
1481+
for help in help {
1482+
diag.help(*help);
1483+
}
1484+
}
14791485
for help_msg in self.b1_help_msgs {
14801486
diag.help(help_msg);
14811487
}

src/tools/compiletest/src/directives.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use tracing::*;
88

99
use crate::common::{CodegenBackend, Config, Debugger, FailMode, PassMode, RunFailMode, TestMode};
1010
use crate::debuggers::{extract_cdb_version, extract_gdb_version};
11-
pub(crate) use crate::directives::auxiliary::AuxProps;
1211
use crate::directives::auxiliary::parse_and_update_aux;
12+
pub(crate) use crate::directives::auxiliary::{AuxCrate, AuxProps};
1313
use crate::directives::directive_names::{
1414
KNOWN_DIRECTIVE_NAMES_SET, KNOWN_HTMLDOCCK_DIRECTIVE_NAMES, KNOWN_JSONDOCCK_DIRECTIVE_NAMES,
1515
};

src/tools/compiletest/src/directives/auxiliary.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ use super::directives::{AUX_BIN, AUX_BUILD, AUX_CODEGEN_BACKEND, AUX_CRATE, PROC
77
use crate::common::Config;
88
use crate::directives::DirectiveLine;
99

10+
/// The value of an `aux-crate` directive.
11+
#[derive(Clone, Debug, Default)]
12+
pub struct AuxCrate {
13+
/// With `aux-crate: foo=bar.rs` this will be `foo`.
14+
/// With `aux-crate: noprelude:foo=bar.rs` this will be `noprelude:foo`.
15+
pub name: String,
16+
/// With `aux-crate: foo=bar.rs` this will be `bar.rs`.
17+
pub path: String,
18+
}
19+
1020
/// Properties parsed from `aux-*` test directives.
1121
#[derive(Clone, Debug, Default)]
1222
pub(crate) struct AuxProps {
@@ -17,7 +27,7 @@ pub(crate) struct AuxProps {
1727
pub(crate) bins: Vec<String>,
1828
/// Similar to `builds`, but a list of NAME=somelib.rs of dependencies
1929
/// to build and pass with the `--extern` flag.
20-
pub(crate) crates: Vec<(String, String)>,
30+
pub(crate) crates: Vec<AuxCrate>,
2131
/// Same as `builds`, but for proc-macros.
2232
pub(crate) proc_macros: Vec<String>,
2333
/// Similar to `builds`, but also uses the resulting dylib as a
@@ -34,7 +44,7 @@ impl AuxProps {
3444
iter::empty()
3545
.chain(builds.iter().map(String::as_str))
3646
.chain(bins.iter().map(String::as_str))
37-
.chain(crates.iter().map(|(_, path)| path.as_str()))
47+
.chain(crates.iter().map(|c| c.path.as_str()))
3848
.chain(proc_macros.iter().map(String::as_str))
3949
.chain(codegen_backend.iter().map(String::as_str))
4050
}
@@ -63,10 +73,10 @@ pub(super) fn parse_and_update_aux(
6373
}
6474
}
6575

66-
fn parse_aux_crate(r: String) -> (String, String) {
76+
fn parse_aux_crate(r: String) -> AuxCrate {
6777
let mut parts = r.trim().splitn(2, '=');
68-
(
69-
parts.next().expect("missing aux-crate name (e.g. log=log.rs)").to_string(),
70-
parts.next().expect("missing aux-crate value (e.g. log=log.rs)").to_string(),
71-
)
78+
AuxCrate {
79+
name: parts.next().expect("missing aux-crate name (e.g. log=log.rs)").to_string(),
80+
path: parts.next().expect("missing aux-crate value (e.g. log=log.rs)").to_string(),
81+
}
7282
}

src/tools/compiletest/src/runtest.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::common::{
1818
TestSuite, UI_EXTENSIONS, UI_FIXED, UI_RUN_STDERR, UI_RUN_STDOUT, UI_STDERR, UI_STDOUT, UI_SVG,
1919
UI_WINDOWS_SVG, expected_output_path, incremental_dir, output_base_dir, output_base_name,
2020
};
21-
use crate::directives::TestProps;
21+
use crate::directives::{AuxCrate, TestProps};
2222
use crate::errors::{Error, ErrorKind, load_errors};
2323
use crate::output_capture::ConsoleOut;
2424
use crate::read2::{Truncated, read2_abbreviated};
@@ -1285,9 +1285,9 @@ impl<'test> TestCx<'test> {
12851285
}
12861286
};
12871287

1288-
for (aux_name, aux_path) in &self.props.aux.crates {
1289-
let aux_type = self.build_auxiliary(&aux_path, &aux_dir, None);
1290-
add_extern(rustc, aux_name, aux_path, aux_type);
1288+
for AuxCrate { name, path } in &self.props.aux.crates {
1289+
let aux_type = self.build_auxiliary(&path, &aux_dir, None);
1290+
add_extern(rustc, name, path, aux_type);
12911291
}
12921292

12931293
for proc_macro in &self.props.aux.proc_macros {

src/tools/opt-dist/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,11 +442,12 @@ fn main() -> anyhow::Result<()> {
442442
// Skip components that are not needed for fast try builds to speed them up
443443
if is_fast_try_build() {
444444
log::info!("Skipping building of unimportant components for a fast try build");
445+
// Note for future onlookers: do not ignore rust-dev here. We need it for try builds when
446+
// a PR makes a change to how LLVM is built.
445447
for target in [
446448
"rust-docs",
447449
"rustc-docs",
448450
"rustc-dev",
449-
"rust-dev",
450451
"rust-docs-json",
451452
"rust-analyzer",
452453
"rustc-src",

tests/ui/imports/ambiguous-2.stderr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ note: `id` could refer to the function defined here
1212
|
1313
LL | pub use self::evp::*;
1414
| ^^^^^^^^^
15+
= help: consider updating this dependency to resolve this error
16+
= help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate
1517
note: `id` could also refer to the function defined here
1618
--> $DIR/auxiliary/../ambiguous-1.rs:15:13
1719
|
@@ -36,6 +38,8 @@ note: `id` could refer to the function defined here
3638
|
3739
LL | pub use self::evp::*;
3840
| ^^^^^^^^^
41+
= help: consider updating this dependency to resolve this error
42+
= help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate
3943
note: `id` could also refer to the function defined here
4044
--> $DIR/auxiliary/../ambiguous-1.rs:15:13
4145
|

tests/ui/imports/ambiguous-4.stderr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ note: `id` could refer to the function defined here
1212
|
1313
LL | pub use evp::*;
1414
| ^^^
15+
= help: consider updating this dependency to resolve this error
16+
= help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate
1517
note: `id` could also refer to the function defined here
1618
--> $DIR/auxiliary/../ambiguous-4-extern.rs:14:9
1719
|
@@ -36,6 +38,8 @@ note: `id` could refer to the function defined here
3638
|
3739
LL | pub use evp::*;
3840
| ^^^
41+
= help: consider updating this dependency to resolve this error
42+
= help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate
3943
note: `id` could also refer to the function defined here
4044
--> $DIR/auxiliary/../ambiguous-4-extern.rs:14:9
4145
|

tests/ui/imports/glob-conflict-cross-crate-1.stderr

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ note: `f` could refer to the function defined here
1212
|
1313
LL | pub use m1::*;
1414
| ^^
15+
= help: consider updating this dependency to resolve this error
16+
= help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate
1517
note: `f` could also refer to the function defined here
1618
--> $DIR/auxiliary/glob-conflict.rs:13:9
1719
|
@@ -33,6 +35,8 @@ note: `f` could refer to the function defined here
3335
|
3436
LL | pub use m1::*;
3537
| ^^
38+
= help: consider updating this dependency to resolve this error
39+
= help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate
3640
note: `f` could also refer to the function defined here
3741
--> $DIR/auxiliary/glob-conflict.rs:13:9
3842
|
@@ -56,6 +60,8 @@ note: `f` could refer to the function defined here
5660
|
5761
LL | pub use m1::*;
5862
| ^^
63+
= help: consider updating this dependency to resolve this error
64+
= help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate
5965
note: `f` could also refer to the function defined here
6066
--> $DIR/auxiliary/glob-conflict.rs:13:9
6167
|
@@ -78,6 +84,8 @@ note: `f` could refer to the function defined here
7884
|
7985
LL | pub use m1::*;
8086
| ^^
87+
= help: consider updating this dependency to resolve this error
88+
= help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate
8189
note: `f` could also refer to the function defined here
8290
--> $DIR/auxiliary/glob-conflict.rs:13:9
8391
|

0 commit comments

Comments
 (0)