Skip to content

Rollup of 8 pull requests #104970

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 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7f66914
Change multiline span ASCII art visual order
estebank Nov 23, 2022
d84cff7
Tweak output
estebank Nov 23, 2022
c256bd2
Remove redundant `all` in cfg
ChrisDenton Nov 26, 2022
2ab3f76
Remove more redundant `all`s
ChrisDenton Nov 26, 2022
e06b61c
explain how to get the discriminant out of a `#[repr(T)] enum`
Nov 25, 2022
4b2a1eb
Support unit tests for jsondoclint
aDotInTheVoid Nov 26, 2022
946d51e
fix broken link fragment
Nov 26, 2022
09818a8
Add a test that makes sense
aDotInTheVoid Nov 26, 2022
74de78a
rustdoc: improve popover focus handling JS
notriddle Nov 26, 2022
c96d888
Pretty-print generators with their `generator_kind`
Swatinem Nov 25, 2022
c26074a
rustdoc: pass "true" to reset focus for notable traits
notriddle Nov 26, 2022
2343353
Avoid ICE if the Clone trait is not found while building error sugges…
mucinoab Nov 26, 2022
353cef9
Use target exe_suffix for doctests
workingjubilee Apr 9, 2022
47ddca6
Attempt to solve problem with globs
workingjubilee Nov 27, 2022
72ae08d
Rollup merge of #95836 - workingjubilee:doctest-exe, r=notriddle
matthiaskrgr Nov 27, 2022
7d7c2be
Rollup merge of #104795 - estebank:multiline-spans, r=TaKO8Ki
matthiaskrgr Nov 27, 2022
8070817
Rollup merge of #104892 - lukas-code:discriminant, r=scottmcm
matthiaskrgr Nov 27, 2022
b947fa2
Rollup merge of #104931 - Swatinem:async-pretty, r=eholk
matthiaskrgr Nov 27, 2022
cc8c2a8
Rollup merge of #104934 - ChrisDenton:all-anybody-wants, r=thomcc
matthiaskrgr Nov 27, 2022
95e3ba6
Rollup merge of #104944 - aDotInTheVoid:jsondoclint-unit-tests, r=jyn514
matthiaskrgr Nov 27, 2022
be3bc0a
Rollup merge of #104946 - notriddle:notriddle/popover-menu-focus, r=G…
matthiaskrgr Nov 27, 2022
3f25e34
Rollup merge of #104956 - mucinoab:issue-104870, r=compiler-errors
matthiaskrgr Nov 27, 2022
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
16 changes: 9 additions & 7 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,13 +732,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let tcx = self.infcx.tcx;
// Try to find predicates on *generic params* that would allow copying `ty`
let infcx = tcx.infer_ctxt().build();
if infcx
.type_implements_trait(
tcx.lang_items().clone_trait().unwrap(),
[tcx.erase_regions(ty)],
self.param_env,
)
.must_apply_modulo_regions()

if let Some(clone_trait_def) = tcx.lang_items().clone_trait()
&& infcx
.type_implements_trait(
clone_trait_def,
[tcx.erase_regions(ty)],
self.param_env,
)
.must_apply_modulo_regions()
{
err.span_suggestion_verbose(
span.shrink_to_hi(),
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_gcc/example/alloc_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@

// The minimum alignment guaranteed by the architecture. This value is used to
// add fast paths for low alignment values.
#[cfg(all(any(target_arch = "x86",
#[cfg(any(target_arch = "x86",
target_arch = "arm",
target_arch = "mips",
target_arch = "powerpc",
target_arch = "powerpc64")))]
target_arch = "powerpc64"))]
const MIN_ALIGN: usize = 8;
#[cfg(all(any(target_arch = "x86_64",
#[cfg(any(target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "mips64",
target_arch = "s390x",
target_arch = "sparc64")))]
target_arch = "sparc64"))]
const MIN_ALIGN: usize = 16;

pub struct System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ impl<'tcx> NonConstOp<'tcx> for Generator {
ccx: &ConstCx<'_, 'tcx>,
span: Span,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let msg = format!("{}s are not allowed in {}s", self.0, ccx.const_kind());
let msg = format!("{}s are not allowed in {}s", self.0.descr(), ccx.const_kind());
if let hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Block) = self.0 {
ccx.tcx.sess.create_feature_err(
UnallowedOpInConstContext { span, msg },
Expand Down
10 changes: 8 additions & 2 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2282,7 +2282,7 @@ impl FileWithAnnotatedLines {
}

// Find overlapping multiline annotations, put them at different depths
multiline_annotations.sort_by_key(|&(_, ref ml)| (ml.line_start, ml.line_end));
multiline_annotations.sort_by_key(|&(_, ref ml)| (ml.line_start, usize::MAX - ml.line_end));
for (_, ann) in multiline_annotations.clone() {
for (_, a) in multiline_annotations.iter_mut() {
// Move all other multiline annotations overlapping with this one
Expand All @@ -2300,8 +2300,14 @@ impl FileWithAnnotatedLines {
}

let mut max_depth = 0; // max overlapping multiline spans
for (file, ann) in multiline_annotations {
for (_, ann) in &multiline_annotations {
max_depth = max(max_depth, ann.depth);
}
// Change order of multispan depth to minimize the number of overlaps in the ASCII art.
for (_, a) in multiline_annotations.iter_mut() {
a.depth = max_depth - a.depth + 1;
}
for (file, ann) in multiline_annotations {
let mut end_ann = ann.as_end();
if !ann.overlaps_exactly {
// avoid output like
Expand Down
108 changes: 54 additions & 54 deletions compiler/rustc_expand/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,13 @@ error: foo
--> test.rs:3:3
|
3 | X0 Y0
| ____^__-
| | ___|
| ___^__-
| |___|
| ||
4 | || X1 Y1
5 | || X2 Y2
| ||____^__- `Y` is a good letter too
| |____|
| |_____|
| `X` is a good letter

"#,
Expand Down Expand Up @@ -311,12 +311,12 @@ error: foo
--> test.rs:3:3
|
3 | X0 Y0
| ____^__-
| | ___|
| ___^__-
| |___|
| ||
4 | || Y1 X1
| ||____-__^ `X` is a good letter
| |_____|
| |____|
| `Y` is a good letter too

"#,
Expand Down Expand Up @@ -351,13 +351,13 @@ error: foo
--> test.rs:3:6
|
3 | X0 Y0 Z0
| ______^
4 | | X1 Y1 Z1
| |_________-
| _______^
4 | | X1 Y1 Z1
| | _________-
5 | || X2 Y2 Z2
| ||____^ `X` is a good letter
6 | | X3 Y3 Z3
| |_____- `Y` is a good letter too
6 | | X3 Y3 Z3
| |____- `Y` is a good letter too

"#,
);
Expand Down Expand Up @@ -395,15 +395,15 @@ error: foo
--> test.rs:3:3
|
3 | X0 Y0 Z0
| _____^__-__-
| | ____|__|
| || ___|
| ___^__-__-
| |___|__|
| ||___|
| |||
4 | ||| X1 Y1 Z1
5 | ||| X2 Y2 Z2
| |||____^__-__- `Z` label
| ||____|__|
| |____| `Y` is a good letter too
| ||_____|__|
| |______| `Y` is a good letter too
| `X` is a good letter

"#,
Expand Down Expand Up @@ -487,17 +487,17 @@ error: foo
--> test.rs:3:6
|
3 | X0 Y0 Z0
| ______^
4 | | X1 Y1 Z1
| |____^_-
| _______^
4 | | X1 Y1 Z1
| | ____^_-
| ||____|
| | `X` is a good letter
5 | | X2 Y2 Z2
| |____-______- `Y` is a good letter too
| ____|
| |
6 | | X3 Y3 Z3
| |________- `Z`
| | `X` is a good letter
5 | | X2 Y2 Z2
| |___-______- `Y` is a good letter too
| ___|
| |
6 | | X3 Y3 Z3
| |_______- `Z`

"#,
);
Expand Down Expand Up @@ -570,14 +570,14 @@ error: foo
--> test.rs:3:6
|
3 | X0 Y0 Z0
| ______^
4 | | X1 Y1 Z1
| |____^____-
| _______^
4 | | X1 Y1 Z1
| | ____^____-
| ||____|
| | `X` is a good letter
5 | | X2 Y2 Z2
6 | | X3 Y3 Z3
| |___________- `Y` is a good letter too
| | `X` is a good letter
5 | | X2 Y2 Z2
6 | | X3 Y3 Z3
| |__________- `Y` is a good letter too

"#,
);
Expand Down Expand Up @@ -941,18 +941,18 @@ error: foo
--> test.rs:3:6
|
3 | X0 Y0 Z0
| ______^
4 | | X1 Y1 Z1
| |____^____-
| _______^
4 | | X1 Y1 Z1
| | ____^____-
| ||____|
| | `X` is a good letter
5 | | 1
6 | | 2
7 | | 3
... |
15 | | X2 Y2 Z2
16 | | X3 Y3 Z3
| |___________- `Y` is a good letter too
| | `X` is a good letter
5 | | 1
6 | | 2
7 | | 3
... |
15 | | X2 Y2 Z2
16 | | X3 Y3 Z3
| |__________- `Y` is a good letter too

"#,
);
Expand Down Expand Up @@ -996,21 +996,21 @@ error: foo
--> test.rs:3:6
|
3 | X0 Y0 Z0
| ______^
4 | | 1
5 | | 2
6 | | 3
7 | | X1 Y1 Z1
| |_________-
| _______^
4 | | 1
5 | | 2
6 | | 3
7 | | X1 Y1 Z1
| | _________-
8 | || 4
9 | || 5
10 | || 6
11 | || X2 Y2 Z2
| ||__________- `Z` is a good letter too
... |
15 | | 10
16 | | X3 Y3 Z3
| |_______^ `Y` is a good letter
... |
15 | | 10
16 | | X3 Y3 Z3
| |________^ `Y` is a good letter

"#,
);
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1514,9 +1514,9 @@ pub enum AsyncGeneratorKind {
impl fmt::Display for AsyncGeneratorKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match self {
AsyncGeneratorKind::Block => "`async` block",
AsyncGeneratorKind::Closure => "`async` closure body",
AsyncGeneratorKind::Fn => "`async fn` body",
AsyncGeneratorKind::Block => "async block",
AsyncGeneratorKind::Closure => "async closure body",
AsyncGeneratorKind::Fn => "async fn body",
})
}
}
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_hir_typeck/src/generator_interior/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
} else {
let note = format!(
"the type is part of the {} because of this {}",
self.kind, yield_data.source
self.kind.descr(),
yield_data.source
);

self.fcx
Expand Down
25 changes: 10 additions & 15 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,25 +681,20 @@ pub trait PrettyPrinter<'tcx>:
}
ty::Str => p!("str"),
ty::Generator(did, substs, movability) => {
// FIXME(swatinem): async constructs used to be pretty printed
// as `impl Future` previously due to the `from_generator` wrapping.
// lets special case this here for now to avoid churn in diagnostics.
let generator_kind = self.tcx().generator_kind(did);
if matches!(generator_kind, Some(hir::GeneratorKind::Async(..))) {
let return_ty = substs.as_generator().return_ty();
p!(write("impl Future<Output = {}>", return_ty));

return Ok(self);
}

p!(write("["));
match movability {
hir::Movability::Movable => {}
hir::Movability::Static => p!("static "),
let generator_kind = self.tcx().generator_kind(did).unwrap();
let should_print_movability =
self.should_print_verbose() || generator_kind == hir::GeneratorKind::Gen;

if should_print_movability {
match movability {
hir::Movability::Movable => {}
hir::Movability::Static => p!("static "),
}
}

if !self.should_print_verbose() {
p!("generator");
p!(write("{}", generator_kind));
// FIXME(eddyb) should use `def_span`.
if let Some(did) = did.as_local() {
let span = self.tcx().def_span(did);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_span/src/analyze_source_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn analyze_source_file(
}

cfg_if::cfg_if! {
if #[cfg(all(any(target_arch = "x86", target_arch = "x86_64")))] {
if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
fn analyze_source_file_dispatch(src: &str,
source_file_start_pos: BytePos,
lines: &mut Vec<BytePos>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2673,7 +2673,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
let sp = self.tcx.def_span(def_id);

// Special-case this to say "async block" instead of `[static generator]`.
let kind = tcx.generator_kind(def_id).unwrap();
let kind = tcx.generator_kind(def_id).unwrap().descr();
err.span_note(
sp,
&format!("required because it's used within this {}", kind),
Expand Down
Loading