Skip to content

Rollup of 8 pull requests #141113

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 19 commits into from
May 17, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f918b89
Wf is not coinductive
compiler-errors Apr 28, 2025
38c05a6
Adjust tests
compiler-errors Apr 29, 2025
292ecd5
Remove some unnecessary erases
compiler-errors May 8, 2025
ab1c49a
Add `#[must_use]` to Array::map
JulianKnodt May 13, 2025
7b2dcf2
Async drop fix for dropee from another crate (#140858)
azhogin May 15, 2025
839534e
ci: split the dist-ohos job
marcoieni May 15, 2025
a64ed16
Lowercase git url for rust-lang/enzyme.git
erickt May 15, 2025
cf878d8
HIR: explain in comment why `ExprKind::If` "then" is an `Expr`
samueltardieu May 15, 2025
43ff885
Add ui test macro-shorthand-issue-140659
xizheyin May 16, 2025
742c27b
Do not emit help when shorthand from macro when suggest `?` or `expect`
xizheyin May 16, 2025
1c17324
Create tests/ui/typeck/suggestions/ and move some tests in tests/ui/t…
xizheyin May 16, 2025
8c14588
Rollup merge of #140208 - compiler-errors:wf-coinductive, r=lcnr
matthiaskrgr May 17, 2025
642cd65
Rollup merge of #140957 - JulianKnodt:array_must_use, r=Mark-Simulacrum
matthiaskrgr May 17, 2025
04bc9d1
Rollup merge of #141031 - azhogin:azhogin/async-drop-dependency-fix, …
matthiaskrgr May 17, 2025
0031282
Rollup merge of #141036 - marcoieni:split-dist-ohos, r=Kobzol
matthiaskrgr May 17, 2025
8e30998
Rollup merge of #141051 - compiler-errors:less-erase, r=nnethercote
matthiaskrgr May 17, 2025
4c52b5d
Rollup merge of #141056 - erickt:enzyme, r=Mark-Simulacrum
matthiaskrgr May 17, 2025
59ad0cb
Rollup merge of #141059 - samueltardieu:push-trvpulpskwwp, r=compiler…
matthiaskrgr May 17, 2025
14f3ef9
Rollup merge of #141070 - xizheyin:issue-140659, r=chenyukang
matthiaskrgr May 17, 2025
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
1 change: 1 addition & 0 deletions compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2043,6 +2043,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
};

let sugg = match self.tcx.hir_maybe_get_struct_pattern_shorthand_field(expr) {
Some(_) if expr.span.from_expansion() => return false,
Some(ident) => format!(": {ident}{sugg}"),
None => sugg.to_string(),
};
Expand Down
56 changes: 56 additions & 0 deletions tests/ui/typeck/suggestions/macro-shorthand-issue-140659.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
trait Reencode {
type Error;
fn tag_index(&mut self, tag: u32) -> Result<u32, Self::Error>;
}

struct Reencoder;
impl Reencode for Reencoder {
type Error = &'static str;
fn tag_index(&mut self, tag: u32) -> Result<u32, Self::Error> {
Ok(tag)
}
}


enum Operator {
Suspend { tag_index: u32 },
}

enum Instruction {
Suspend { tag_index: u32 },
}


macro_rules! for_each_operator {
($m:ident) => {
$m! {
Suspend { tag_index: u32 } => visit_suspend
}
};
}


fn process<T: Reencode>(op: &Operator, reencoder: &mut T) -> Instruction {
macro_rules! translate {
(Suspend { tag_index: $ty:ty } => $visit:ident) => {
match op {
Operator::Suspend { tag_index } => {
let tag_index = reencoder.tag_index(*tag_index);

// KEY POINT: Using field shorthand syntax where the compiler gets confused
// Here tag_index is a Result<u32, E> but we're using it where u32 is expected
Instruction::Suspend { tag_index } //~ ERROR mismatched types [E0308]
}
}
};
}

for_each_operator!(translate)
}

fn main() {
let mut reencoder = Reencoder;
let op = Operator::Suspend { tag_index: 1 };

let _ = process(&op, &mut reencoder);
}
16 changes: 16 additions & 0 deletions tests/ui/typeck/suggestions/macro-shorthand-issue-140659.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
error[E0308]: mismatched types
--> $DIR/macro-shorthand-issue-140659.rs:42:44
|
LL | Instruction::Suspend { tag_index }
| ^^^^^^^^^ expected `u32`, found `Result<u32, <T as Reencode>::Error>`
...
LL | for_each_operator!(translate)
| ----------------------------- in this macro invocation
|
= note: expected type `u32`
found enum `Result<u32, <T as Reencode>::Error>`
= note: this error originates in the macro `translate` which comes from the expansion of the macro `for_each_operator` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0308`.
Loading