Skip to content

Rollup of 9 pull requests #129595

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
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a97b41f
Use subtyping for UnsafeFnPointer coercion, too
compiler-errors Aug 20, 2024
147bb17
Rework how we emit errors for unresolved object lifetimes
compiler-errors Aug 24, 2024
6df0ccf
rustdoc: clean up tuple <-> primitive conversion docs
notriddle Aug 24, 2024
e7f11b6
Removes dead code from the compiler
mu001999 Aug 8, 2024
c29e328
gitignore: ignore ICE reports regardless of directory
GrigorenkoPV Aug 24, 2024
ba24121
tweak rustc_allow_const_fn_unstable hint, and add back test for stabl…
RalfJung Aug 25, 2024
8750e24
Fixing span manipulation and indentation of the suggestion introduced…
surechen Aug 22, 2024
48f43fa
Avoid taking reference of &TyKind
compiler-errors Aug 25, 2024
ecd2d11
Remove redundant flags that can be inferred from the HIR
compiler-errors Aug 24, 2024
1c58522
Use FxHasher on new solver unconditionally
compiler-errors Aug 24, 2024
621f272
Rollup merge of #129288 - compiler-errors:unsafe-fn-coercion, r=lcnr
matthiaskrgr Aug 25, 2024
6228bd6
Rollup merge of #129405 - surechen:fix_span_x, r=cjgillot
matthiaskrgr Aug 25, 2024
5a07308
Rollup merge of #129518 - GrigorenkoPV:gitignore-library-ice, r=tgross35
matthiaskrgr Aug 25, 2024
ae21236
Rollup merge of #129519 - compiler-errors:lowering-flags, r=fmease
matthiaskrgr Aug 25, 2024
aa26e1a
Rollup merge of #129525 - notriddle:notriddle/fake-variadic-tuple-arr…
matthiaskrgr Aug 25, 2024
a8a242c
Rollup merge of #129526 - compiler-errors:fx, r=lqd
matthiaskrgr Aug 25, 2024
c6e0068
Rollup merge of #129544 - mu001999-contrib:dead-code/clean, r=compile…
matthiaskrgr Aug 25, 2024
0a8e305
Rollup merge of #129553 - RalfJung:const-stability, r=compiler-errors
matthiaskrgr Aug 25, 2024
d6a3aa4
Rollup merge of #129590 - compiler-errors:ref-tykind, r=fmease
matthiaskrgr Aug 25, 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
Prev Previous commit
Next Next commit
Fixing span manipulation and indentation of the suggestion introduced…
  • Loading branch information
surechen committed Aug 25, 2024
commit 8750e2424744f6365fbbfd3a42059eb51091e736
Original file line number Diff line number Diff line change
Expand Up @@ -4667,10 +4667,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
if let hir::ExprKind::Block(b, _) = body.value.kind
&& b.expr.is_none()
{
// The span of '}' in the end of block.
let span = self.tcx.sess.source_map().end_point(b.span);
sugg_spans.push((
// The span will point to the closing curly brace `}` of the block.
b.span.shrink_to_hi().with_lo(b.span.hi() - BytePos(1)),
"\n Ok(())\n}".to_string(),
span.shrink_to_lo(),
format!(
"{}{}",
" Ok(())\n",
self.tcx.sess.source_map().indentation_before(span).unwrap_or_default(),
),
));
}
err.multipart_suggestion_verbose(
Expand Down
18 changes: 6 additions & 12 deletions tests/ui/return/return-from-residual-sugg-issue-125997.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ use std::io::prelude::*;
fn test1() -> Result<(), Box<dyn std::error::Error>> {
let mut _file = File::create("foo.txt")?;
//~^ ERROR the `?` operator can only be used in a function

Ok(())
}

fn test2() -> Result<(), Box<dyn std::error::Error>> {
let mut _file = File::create("foo.txt")?;
//~^ ERROR the `?` operator can only be used in a function
println!();

Ok(())
}

Expand All @@ -27,9 +25,8 @@ macro_rules! mac {
let mut _file = File::create("foo.txt")?;
//~^ ERROR the `?` operator can only be used in a function
println!();

Ok(())
}
Ok(())
}
};
}

Expand All @@ -39,23 +36,20 @@ impl A {
fn test4(&self) -> Result<(), Box<dyn std::error::Error>> {
let mut _file = File::create("foo.txt")?;
//~^ ERROR the `?` operator can only be used in a method

Ok(())
}
Ok(())
}

fn test5(&self) -> Result<(), Box<dyn std::error::Error>> {
let mut _file = File::create("foo.txt")?;
//~^ ERROR the `?` operator can only be used in a method
println!();

Ok(())
}
Ok(())
}
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut _file = File::create("foo.txt")?;
//~^ ERROR the `?` operator can only be used in a function
mac!();

Ok(())
}
21 changes: 6 additions & 15 deletions tests/ui/return/return-from-residual-sugg-issue-125997.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ help: consider adding return type
LL ~ fn test1() -> Result<(), Box<dyn std::error::Error>> {
LL | let mut _file = File::create("foo.txt")?;
LL |
LL +
LL + Ok(())
LL + }
|

error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
Expand All @@ -32,9 +30,7 @@ LL ~ fn test2() -> Result<(), Box<dyn std::error::Error>> {
LL | let mut _file = File::create("foo.txt")?;
LL |
LL | println!();
LL +
LL + Ok(())
LL + }
|

error[E0277]: the `?` operator can only be used in a method that returns `Result` or `Option` (or another type that implements `FromResidual`)
Expand All @@ -51,9 +47,8 @@ help: consider adding return type
LL ~ fn test4(&self) -> Result<(), Box<dyn std::error::Error>> {
LL | let mut _file = File::create("foo.txt")?;
LL |
LL ~
LL + Ok(())
LL + }
LL ~ Ok(())
LL ~ }
|

error[E0277]: the `?` operator can only be used in a method that returns `Result` or `Option` (or another type that implements `FromResidual`)
Expand All @@ -71,9 +66,8 @@ LL ~ fn test5(&self) -> Result<(), Box<dyn std::error::Error>> {
LL | let mut _file = File::create("foo.txt")?;
LL |
LL | println!();
LL ~
LL + Ok(())
LL + }
LL ~ Ok(())
LL ~ }
|

error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
Expand All @@ -91,9 +85,7 @@ LL ~ fn main() -> Result<(), Box<dyn std::error::Error>> {
LL | let mut _file = File::create("foo.txt")?;
LL |
LL | mac!();
LL +
LL + Ok(())
LL + }
|

error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
Expand All @@ -115,9 +107,8 @@ LL ~ fn test3() -> Result<(), Box<dyn std::error::Error>> {
LL | let mut _file = File::create("foo.txt")?;
LL |
LL | println!();
LL ~
LL + Ok(())
LL + }
LL ~ Ok(())
LL ~ }
|

error: aborting due to 6 previous errors
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/try-trait/try-operator-on-main.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ LL ~ fn main() -> Result<(), Box<dyn std::error::Error>> {
LL | // error for a `Try` type on a non-`Try` fn
...
LL | try_trait_generic::<()>();
LL +
LL + Ok(())
LL + }
|

error[E0277]: the `?` operator can only be applied to values that implement `Try`
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy