Galvanize: Pure Rust CDB reader/writer
OpaqueDebug implementation
Javascript Canvas based fighting game engine
HTML5+JS diff display
My HTML resume. It's self-contained with no external dependencies. Emphasis on readability across User Agents.
Rust text diffing and assertion library
CLI Tool to interact with CDBs.
PySmell is an attempt to create an IDE completion helper for python.
trying things out
Pull request review commentrust-lang/rust
Suggest calling await on method call and field access
impl<'a, 'tcx> InferCtxt<'a, 'tcx> { self.note_error_origin(diag, cause, exp_found); } + pub fn get_impl_future_output_ty(&self, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
That sounds good.
comment created time in 10 minutes
pull request commentrust-lang/rust
r? @oli-obk who's more familiar with the nuance here.
comment created time in 3 hours
pull request commentrust-lang/rust
impl<A, B> IntoIterator for (A, B) as Zip
I really like this change, but am slightly concerned about the insta-stabilization. r=me on the code, but defer to @rust-lang/libs
@rfcbot fcp merge
comment created time in 3 hours
Pull request review commentrust-lang/rust
Suggest calling await on method call and field access
impl<'a, 'tcx> InferCtxt<'a, 'tcx> { self.note_error_origin(diag, cause, exp_found); } + pub fn get_impl_future_output_ty(&self, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
Whenever you have a ty::Ty<'tcx> it is easier to do it this way, when you have access to the hir::Ty that comes from the return type of the hir fn return type it easier to use that directly.
We might be able to unify these two methods, but I've found in the past that I've had to have the same logic twice, one for the hir and another for ty, so I wouldn't be too torn about the "duplication".
comment created time in 3 hours
push eventestebank/rust
commit sha 15c74d57f01f30412b50cf50d72766f7b9724fa3
Do not skip "type annotation needed"/`Sized` error
commit sha 0d3f077ac723e2c679cadb97661d66f928ae0cc0
Skip lifetimes in turbofish suggestions
commit sha 1ae1a1347280351dc31ce0628558b5d5bce2db97
Fix new ICE caused by derred arg `Sized` check
commit sha f26b748303f1795c86f4ee331551af8b8d0457ac
Suggest `&[_]` instead of `&[_; N]` on inference error
commit sha 654a4129159eaac624c84f2db3aaba2712e1b990
Fix rebase
push time in 4 hours
push eventestebank/rust
commit sha 05c9c0ee5dcd935f518db151bee2dc88380fb92f
Modify executable checking to be more universal This uses a dummy file to check if the filesystem being used supports the executable bit in general.
commit sha 1ff7da6551a7cdf6ace2a9d00e92bbab550334ee
Move `slice::check_range` to `RangeBounds`
commit sha 1095dcab96d524e700b11edf366d45a0fd173fa0
Fix links
commit sha eb63168e007058dad4af758faf1dca449c049777
Fix doctests
commit sha f055b0bb0847ecf08fe452a270faae8324b55b05
Rename method to `assert_len`
commit sha fd22e87afc9082522bc7b52e32d25d43c64594e6
fix flag computation for `ExistentialPredicate::Projection`
commit sha 7652b4b1d9cec0ad22f529a4335d05f7d7792521
guard against `skip_binder` errors during FlagComputation
commit sha a7bd6c449aef07dc8daa889f4ddbdda326593e32
Link to "Contributing to Rust" rather than "Getting Started". Change to link to "Contributing to Rust" chapter of `rustc` Dev Guide, primarily on the basis that the GitHub "first contribution" Issue "pop-up" says "Be sure to review the [contributing guidelines] and [code of conduct]" and links to this file. When/if the guide/"Getting Started" section gets revised to not be `rustc`-specific the linked section can be changed. In the meantime this prevents leading first time contributors into a confusing cul de sac.
commit sha 549f861f7d53811521cf929cf58fb6828a2a88d9
Use correct article in help message for conversion or cast Before it always used `an`; now it uses the correct article for the type.
commit sha 81edbbc2bfacd29558a5020990d49fc07ed80ac7
Implement TryFrom between NonZero types.
commit sha 094f14c554c3a1f103a5d6778d4b4e131c297f11
Add article after "to" Also added missing backtick in "you can cast" message.
commit sha 8a6831a7fd3fc624643b50f494212e0ceaad3c28
Say "doesn't" instead of "wouldn't" in convert message
commit sha 77e6c56ab6f108fdbb8acbd176497be9f074af9a
Unify `&mut` and `&raw mut` const-checking errors
commit sha c1494d60dbad39c218e7b0825bfe590cc22bf2fa
Bless tests
commit sha 9c302f55bd07a04305dfa2bd815d2559deb8468f
normalize in codegen_fulfill_obligations
commit sha f0487cee7439f3a4b4c7daec0e7f2a0ccc21053c
normalize substs during inlining
commit sha 32739a2ff1b7b6e5c1b475341b01f4a499830a84
add regression test
commit sha ac893b8a02788eec6f6fad0cc89de0177b0c0a50
add test for should_inline incorrect param_env
commit sha 64839ee00ab4076d797901ddea55f2613c5b75b5
Add Pin::new_static.
commit sha 390883e888c580d054ab4a2584c851aba50865e9
Make Pin::new_static const.
push time in 4 hours
pull request commentrust-lang/rust
Do not ICE with TraitPredicates containing [type error]
@bors r=eddyb
comment created time in 5 hours
push eventestebank/rust
commit sha e023158145ece18176a2e93420600ccda0d0bc58
Permit uninhabited enums to cast into ints This essentially reverts part of #6204.
commit sha 990a39596cf3b33e550f2045f78a62970f8d78f8
Prevent ICE on uninhabited MIR interpretation
commit sha a02014280586b53997622c501db00398376967a8
Refactor io/buffered.rs into submodules
commit sha 96229f02402e82914ec6100b28ad2cbdd273a0d4
move buffered.rs to mod.rs
commit sha 6d75cdfc9ed9e6987bd23add6cf3954d2499dce2
Added updated compiler diagnostic
commit sha da700cba08a2b194d19e63d3c51ebadce96fe46b
Stabilize move_ref_pattern
commit sha afb9eeb1b9ea16ca65e38673a0ef3e7be81d7252
Disabled error `E0007` from rustc_error_codes
commit sha 05c9c0ee5dcd935f518db151bee2dc88380fb92f
Modify executable checking to be more universal This uses a dummy file to check if the filesystem being used supports the executable bit in general.
commit sha c4280af8285c61b367a87c8f6eef9876011a8150
Retry fix error reporting suggestions
commit sha 1ff7da6551a7cdf6ace2a9d00e92bbab550334ee
Move `slice::check_range` to `RangeBounds`
commit sha 1095dcab96d524e700b11edf366d45a0fd173fa0
Fix links
commit sha eb63168e007058dad4af758faf1dca449c049777
Fix doctests
commit sha f055b0bb0847ecf08fe452a270faae8324b55b05
Rename method to `assert_len`
commit sha fd22e87afc9082522bc7b52e32d25d43c64594e6
fix flag computation for `ExistentialPredicate::Projection`
commit sha 7652b4b1d9cec0ad22f529a4335d05f7d7792521
guard against `skip_binder` errors during FlagComputation
commit sha a7bd6c449aef07dc8daa889f4ddbdda326593e32
Link to "Contributing to Rust" rather than "Getting Started". Change to link to "Contributing to Rust" chapter of `rustc` Dev Guide, primarily on the basis that the GitHub "first contribution" Issue "pop-up" says "Be sure to review the [contributing guidelines] and [code of conduct]" and links to this file. When/if the guide/"Getting Started" section gets revised to not be `rustc`-specific the linked section can be changed. In the meantime this prevents leading first time contributors into a confusing cul de sac.
commit sha 549f861f7d53811521cf929cf58fb6828a2a88d9
Use correct article in help message for conversion or cast Before it always used `an`; now it uses the correct article for the type.
commit sha 81edbbc2bfacd29558a5020990d49fc07ed80ac7
Implement TryFrom between NonZero types.
commit sha 094f14c554c3a1f103a5d6778d4b4e131c297f11
Add article after "to" Also added missing backtick in "you can cast" message.
commit sha 8a6831a7fd3fc624643b50f494212e0ceaad3c28
Say "doesn't" instead of "wouldn't" in convert message
push time in 5 hours
Pull request review commentrust-lang/rust
Tweak `if let` suggestion to be more liberal with suggestion and to not ICE
+error[E0308]: mismatched types+ --> $DIR/issue-77218.rs:3:11+ |+LL | while Some(0) = value.get(0) {+ | ^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
Fixed.
comment created time in 6 hours
push eventestebank/rust
commit sha fd22e87afc9082522bc7b52e32d25d43c64594e6
fix flag computation for `ExistentialPredicate::Projection`
commit sha 7652b4b1d9cec0ad22f529a4335d05f7d7792521
guard against `skip_binder` errors during FlagComputation
commit sha a7bd6c449aef07dc8daa889f4ddbdda326593e32
Link to "Contributing to Rust" rather than "Getting Started". Change to link to "Contributing to Rust" chapter of `rustc` Dev Guide, primarily on the basis that the GitHub "first contribution" Issue "pop-up" says "Be sure to review the [contributing guidelines] and [code of conduct]" and links to this file. When/if the guide/"Getting Started" section gets revised to not be `rustc`-specific the linked section can be changed. In the meantime this prevents leading first time contributors into a confusing cul de sac.
commit sha 81edbbc2bfacd29558a5020990d49fc07ed80ac7
Implement TryFrom between NonZero types.
commit sha 77e6c56ab6f108fdbb8acbd176497be9f074af9a
Unify `&mut` and `&raw mut` const-checking errors
commit sha c1494d60dbad39c218e7b0825bfe590cc22bf2fa
Bless tests
commit sha 64839ee00ab4076d797901ddea55f2613c5b75b5
Add Pin::new_static.
commit sha 390883e888c580d054ab4a2584c851aba50865e9
Make Pin::new_static const.
commit sha bd135674814d74ca6fca3ab79d778ecaaeb02cf5
Allow setting up git hooks from other worktrees
commit sha 0ec3ea9e697ea9c2ce225ba0b9f3715434fc773e
const keyword: brief paragraph on 'const fn'
commit sha c8405d2251ce78651f591ed8a2189c41593f5110
fix markdown reference Co-authored-by: Dariusz Niedoba <[email protected]>
commit sha 39b0e7928579c4ce3a42e849695f9380b7869d62
Remove generic argument from `QueryConfig`.
commit sha 104c0f0194177442ff16cf14907a96d2f8d200dd
Rename Pin::new_static to Pin::static_ref.
commit sha 2c71f682d74d13ae6673dc701a9bb3a0562f57c0
Add Pin::static_mut.
commit sha 0c32e811577fbf2ff46a607897f9ea7b6b95b364
Fixing escaping to ensure generation of welformed json.
commit sha f83446b836900ce9afbaa0816a5b4feda654b51e
Reword safety guarantee of Pin::static_{ref,mut}. Co-authored-by: Peter Todd <[email protected]>
commit sha a93f58f5e6c9e4e1fbc076d966a9e1e853ea06fd
Join map operators Signed-off-by: wcampbell <[email protected]>
commit sha 964a5ac962d32c280d036df42b2e747809939cc4
Use is_ok() instead of empty Ok(_) Signed-off-by: wcampbell <[email protected]>
commit sha abfbd1bd719bd1440132ead24ec64c0acd293f41
Avoid extraneous space between visibility kw and ident for statics Today, given a static like `static mut FOO: usize = 1`, rustdoc would emit `static mut FOO: usize = 1`, as it emits both the mutability kw with a space and reserves a space after the mutability kw. This patch fixes that misformatting. This patch also adds some tests for emit of other statics, as I could not find an existing test devoted to statics.
commit sha e60072f5c65c619263d137daf9afab9c6cb94c8e
fixup! Avoid extraneous space between visibility kw and ident for statics
push time in 6 hours
pull request commentrust-lang/rust
Do not try to report on closures to avoid ICE
@bors r+
comment created time in 7 hours
PR opened rust-lang/rust
When encountering a failing method or field resolution on a Future,
look at the Output and try the same operation on it. If successful,
suggest calling .await on the Future.
This had already been introduced in #72784, but at some point they stopped working.
Built on top of #78214, only last commit is relevant.
r? @oli-obk
pr created time in 7 hours
pull request commentrust-lang/rust
Await on mismatched future types
These suggestions became dead code at some point (😩), but will be emitted again after https://github.com/rust-lang/rust/pull/78214.
comment created time in 8 hours
Pull request review commentrust-lang/rust
Tweak match arm semicolon removal suggestion to account for futures
impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { if self.predicate_may_hold(&try_obligation) && impls_future { if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) { if snippet.ends_with('?') {- err.span_suggestion(- span,- "consider using `.await` here",- format!("{}.await?", snippet.trim_end_matches('?')),+ err.span_suggestion_verbose(+ span.with_hi(span.hi() - BytePos(1)).shrink_to_hi(),
We have a few in rustc, but I try to avoid them like the plague* whenever feasible.
- Really need to stop using that phrase, some people embrace the plague.
comment created time in 9 hours
push eventestebank/rust
commit sha a7bd6c449aef07dc8daa889f4ddbdda326593e32
Link to "Contributing to Rust" rather than "Getting Started". Change to link to "Contributing to Rust" chapter of `rustc` Dev Guide, primarily on the basis that the GitHub "first contribution" Issue "pop-up" says "Be sure to review the [contributing guidelines] and [code of conduct]" and links to this file. When/if the guide/"Getting Started" section gets revised to not be `rustc`-specific the linked section can be changed. In the meantime this prevents leading first time contributors into a confusing cul de sac.
commit sha 81edbbc2bfacd29558a5020990d49fc07ed80ac7
Implement TryFrom between NonZero types.
commit sha 0c32e811577fbf2ff46a607897f9ea7b6b95b364
Fixing escaping to ensure generation of welformed json.
commit sha a93f58f5e6c9e4e1fbc076d966a9e1e853ea06fd
Join map operators Signed-off-by: wcampbell <[email protected]>
commit sha 964a5ac962d32c280d036df42b2e747809939cc4
Use is_ok() instead of empty Ok(_) Signed-off-by: wcampbell <[email protected]>
commit sha abfbd1bd719bd1440132ead24ec64c0acd293f41
Avoid extraneous space between visibility kw and ident for statics Today, given a static like `static mut FOO: usize = 1`, rustdoc would emit `static mut FOO: usize = 1`, as it emits both the mutability kw with a space and reserves a space after the mutability kw. This patch fixes that misformatting. This patch also adds some tests for emit of other statics, as I could not find an existing test devoted to statics.
commit sha e60072f5c65c619263d137daf9afab9c6cb94c8e
fixup! Avoid extraneous space between visibility kw and ident for statics
commit sha 000ec5e2f8e7bf3f5da59f6f219fe02dff42d116
Made slice sort documentation consistent between stable and unstable versions
commit sha 8446d949f1d53b2c7ee4155f8fbf3d1390e3f203
Following #74010 by converting some newer cases of backticked O notations to be italicized
commit sha b9db54b3a238124b19856a03eccef7ae3ae86d91
Bump nzint_try_from_nzint_conv stabilization version to 1.49. Missed the 1.48 cycle.
commit sha 5948e62f3443df626cc803fd3a08bc24e42209e8
Sync LLVM submodule if it has been initialized Since having enabled the download-ci-llvm option, and having rebased on top of f05b47ccdfa63f8b4b9fb47a9aa92381801d3ff1, I've noticed that I had to update the llvm-project submodule manually if it was checked out. Orignally, the submodule update logic was introduced to reduce the friction for contributors to manage the submodules, or in other words, to prevent getting PRs that have unwanted submodule rollbacks because the contributors didn't run git submodule update. This commit adds logic to ensure there is no inadvertent LLVM submodule rollback in a PR if download-ci-llvm (or llvm-config) is enabled. It will detect whether the llvm-project submodule is initialized, and if so, update it in any case. If it is not initialized, behaviour is kept to not do any update/initialization. An alternative to the chosen implementation would be to not pass the --init command line arg to `git submodule update` for the src/llvm-project submodule. This would show a confusing error message however on all builds with an uninitialized repo. We could pass the --silent param, but we still want it to print something if it is initialized and has to update something. So we just do a manual check for whether the submodule is initialized.
commit sha e852a4abf01f605aa71cd529887c17c4c64f33ed
Update cargo
commit sha e0b61111f83d4465fcc439d4186710f860b05a4b
Mark `repr128` as `incomplete_features`
commit sha d725da129e76963ec4309edc49a34471a2b21038
Clean up and improve some docs * compiler docs * Don't format list as part of a code block * Clean up some other formatting * rustdoc book * Update CommonMark spec version to latest (0.28 -> 0.29) * Clean up some various wording and formatting
commit sha 769b4108e288c4074b502336a38a5c39bfff555a
Make closures inherit the parent function's target features
commit sha 683db310c4a2e205bd954ea030cff3ce2fa9ef68
Fix clippy tests
commit sha b4a9854afe0ab75f1b0e0c46a9342c835d5bf7b9
Fixup: add missing trailing newline
commit sha 36a5244da311b9cd9a4ee04a75f15e23cf9fe891
Explain where the closure return type was inferred Fixes #78193
commit sha 954b5a81b46f60df640f36cfc83f04cd2a965051
Rename parse_const_expr to parse_const_block
commit sha f8842b9bacaf277430fa5c6cdf430b046dc7f323
Make inline const work in range patterns
push time in 10 hours
Pull request review commentrust-lang/rust
Tweak match arm semicolon removal suggestion to account for futures
impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { if self.predicate_may_hold(&try_obligation) && impls_future { if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) { if snippet.ends_with('?') {- err.span_suggestion(- span,- "consider using `.await` here",- format!("{}.await?", snippet.trim_end_matches('?')),+ err.span_suggestion_verbose(+ span.with_hi(span.hi() - BytePos(1)).shrink_to_hi(),
We could add a method Span::shrink_by_one(Self) to avoid the BytePos play, but two calls would still be needed.
comment created time in 10 hours
push eventestebank/rust
commit sha 226ac27e973274c03a4f613c28fe84140a9eb080
Suggest semicolon removal and boxing when appropriate
push time in a day
push eventestebank/rust
commit sha 981eab09742bd23e4f911a4a8f429d8feb0b1380
Add test case for different `impl Future`s
commit sha e9f9942cbfdf081879107e7409a0b674c1763759
Add more `.await` suggestions on E0308
push time in a day
Pull request review commentrust-lang/rust
Tweak match arm semicolon removal suggestion to account for futures
error[E0277]: the `?` operator can only be applied to values that implement `Try --> $DIR/incorrect-syntax-suggestions.rs:16:19 | LL | let _ = await bar()?;
Done. We also silence the await in non-async fn error for this case in particular, but that should be fine.
comment created time in a day
push eventestebank/rust
commit sha 77e6c56ab6f108fdbb8acbd176497be9f074af9a
Unify `&mut` and `&raw mut` const-checking errors
commit sha c1494d60dbad39c218e7b0825bfe590cc22bf2fa
Bless tests
commit sha 64839ee00ab4076d797901ddea55f2613c5b75b5
Add Pin::new_static.
commit sha 390883e888c580d054ab4a2584c851aba50865e9
Make Pin::new_static const.
commit sha 39b0e7928579c4ce3a42e849695f9380b7869d62
Remove generic argument from `QueryConfig`.
commit sha 104c0f0194177442ff16cf14907a96d2f8d200dd
Rename Pin::new_static to Pin::static_ref.
commit sha 2c71f682d74d13ae6673dc701a9bb3a0562f57c0
Add Pin::static_mut.
commit sha f83446b836900ce9afbaa0816a5b4feda654b51e
Reword safety guarantee of Pin::static_{ref,mut}. Co-authored-by: Peter Todd <[email protected]>
commit sha df95dcebf5f98cefdc60c9b9d818fb285ac07d5b
Add missing `mut`. Co-authored-by: David Tolnay <[email protected]>
commit sha 7b652d341e9a476658af8a9186972ce73ec38c3c
Haiku: explicitly set CMAKE_SYSTEM_NAME when cross-compiling This resolves issues where the cross-build of LLVM fails because it tries to link to the host's system libraries instead of the target's system libraries.
commit sha 64c239cbd6d694dbe2a5a13198c265669d7a8f8e
Add codegen test for issue #73827
commit sha 1d07d696d22a6d5a1ea1a41e0408ea5e990b25ae
Optimize const value interning for ZST types Interning can skip any inhabited ZST type in general.
commit sha cc0b718aaa35bfb2a9ca5dd59078ae7e54dbc4bb
Mark inout asm! operands as used in liveness pass
commit sha fd193f2d7f7ebed086de9977951cac76211533b0
Treat InOut variables like other input variables
commit sha 7b33ae642e29635f8446fed7641b5665d0c149e6
Improve wording of "cannot multiply" type error For example, if you had this code: fn foo(x: i32, y: f32) -> f32 { x * y } You would get this error: error[E0277]: cannot multiply `f32` to `i32` --> src/lib.rs:2:7 | 2 | x * y | ^ no implementation for `i32 * f32` | = help: the trait `Mul<f32>` is not implemented for `i32` However, that's not usually how people describe multiplication. People usually describe multiplication like how the division error words it: error[E0277]: cannot divide `i32` by `f32` --> src/lib.rs:2:7 | 2 | x / y | ^ no implementation for `i32 / f32` | = help: the trait `Div<f32>` is not implemented for `i32` So that's what this change does. It changes this: error[E0277]: cannot multiply `f32` to `i32` --> src/lib.rs:2:7 | 2 | x * y | ^ no implementation for `i32 * f32` | = help: the trait `Mul<f32>` is not implemented for `i32` To this: error[E0277]: cannot multiply `i32` by `f32` --> src/lib.rs:2:7 | 2 | x * y | ^ no implementation for `i32 * f32` | = help: the trait `Mul<f32>` is not implemented for `i32`
commit sha 003516f91a80dd8d440c932352b2fd6c6dc900b7
BTreeMap: split off most code of remove and split_off
commit sha 762ded17f83a9309c5d8a626e2bc30a544048007
we can test std and core panic macros together
commit sha 66c1fc4c87215d6555941909996afb18eb1402ea
Move orphan module-name/mod.rs files into module-name.rs files
commit sha 4e2c59a970695b2809a0f68f2ffe415ebdb04913
Greatly improve display for small mobile devices screens
commit sha 48060f1a63aa8b1ae04b34c3597f691d4b5e13db
rustdoc: Show the correct source filename, without `.html` Previously the title would be lib.rs.html -- source if `lib.rs` was the actual source filename. Now the title is lib.rs – source (note the en dash).
push time in a day
Pull request review commentrust-lang/rust
Tweak match arm semicolon removal suggestion to account for futures
error[E0277]: the `?` operator can only be applied to values that implement `Try --> $DIR/incorrect-syntax-suggestions.rs:16:19 | LL | let _ = await bar()?;
I'll fix it in this PR after all.
comment created time in a day
Pull request review commentrust-lang/rust
Tweak match arm semicolon removal suggestion to account for futures
error[E0277]: the `?` operator can only be applied to values that implement `Try --> $DIR/incorrect-syntax-suggestions.rs:16:19 | LL | let _ = await bar()?;
I just took a look: this is because await bar()? gets recovered as bar()?.await instead of bar().await?. Either one will be a pure guess. We could avoid the subsequent errors by not recovering and just leaving an error node in the AST...
comment created time in a day
Pull request review commentrust-lang/rust
Tweak match arm semicolon removal suggestion to account for futures
static_assert_size!(ObligationCauseCode<'_>, 32); #[derive(Clone, Debug, PartialEq, Eq, Hash, Lift)] pub struct MatchExpressionArmCause<'tcx> { pub arm_span: Span,- pub semi_span: Option<Span>,+ pub semi_span: Option<(Span, bool)>,
Done.
comment created time in a day
push eventestebank/rust
commit sha 7302584eb64997666dfa91dda45442f369f93c7d
Review comments: use newtype instead of `bool`
push time in a day
Pull request review commentrust-lang/rust
Tweak match arm semicolon removal suggestion to account for futures
impl<'a, 'tcx> FnCtxt<'a, 'tcx> { _ => return None, }; let last_expr_ty = self.node_ty(last_expr.hir_id);- if matches!(last_expr_ty.kind(), ty::Error(_))- || self.can_sub(self.param_env, last_expr_ty, expected_ty).is_err()+ let needs_box = match (last_expr_ty.kind(), expected_ty.kind()) {+ (ty::Opaque(last_def_id, last_bounds), ty::Opaque(exp_def_id, exp_bounds)) => {+ debug!(
I tried that, but by boxing both types. I'll try only with one.
comment created time in a day
Pull request review commentrust-lang/rust
Tweak match arm semicolon removal suggestion to account for futures
error[E0277]: the `?` operator can only be applied to values that implement `Try --> $DIR/incorrect-syntax-suggestions.rs:16:19 | LL | let _ = await bar()?;
It's indeed not. This is a pre-existing suggestion artifact that I would rather tackle in a separate PR.
comment created time in 2 days
issue commentrust-lang/rust
Nonsensical error when trying to use associated const in array
I'm pretty sure there was an existing ticket for this 😅 but yeah, unless anyone has spare cycles it will become moot once min_const_generics is stabilized. Do not close the ticket though.
comment created time in 2 days
issue closedrust-lang/rust
rust missing features like powerful text formatting
rust doesn't have printf or scanf function so we can specify the %4d or %5.4f (to format the text) and do like:
int main(void){
char c='d';
printf("%d",c);
}
which would print the char as the ASCII value and allow all sorts of text manipulation
closed time in 2 days
anshul-birajdarissue commentrust-lang/rust
rust missing features like powerful text formatting
You can also try out C/Python style format strings and rustc will show you the Rust way to represent the same formatting string.
You have to use println!("format str", args); in Rust.
I would advice you read the freely available Rust Book and visit https://users.rust-lang.org/ for support. This issue tracker is for bug reporting and feature requests.
comment created time in 2 days
pull request commentrust-lang/rust
Tweak match arm semicolon removal suggestion to account for futures
r? @oli-obk
comment created time in 2 days
PR opened rust-lang/rust
- Suggest removal of semicolon on prior match arm
- Account for
impl Futurewhen suggesting semicolon removal
Thanks to https://twitter.com/a_hoverbear/status/1318960787105353728 for pointing this out!
pr created time in 2 days
push eventestebank/rust
commit sha fd22e87afc9082522bc7b52e32d25d43c64594e6
fix flag computation for `ExistentialPredicate::Projection`
commit sha 7652b4b1d9cec0ad22f529a4335d05f7d7792521
guard against `skip_binder` errors during FlagComputation
commit sha bd135674814d74ca6fca3ab79d778ecaaeb02cf5
Allow setting up git hooks from other worktrees
commit sha 0ec3ea9e697ea9c2ce225ba0b9f3715434fc773e
const keyword: brief paragraph on 'const fn'
commit sha c8405d2251ce78651f591ed8a2189c41593f5110
fix markdown reference Co-authored-by: Dariusz Niedoba <[email protected]>
commit sha 058699d0a2fca02127761f014d0ecfce1c5541ec
[net] clippy: needless_update warning: struct update has no effect, all the fields in the struct have already been specified --> library/std/src/net/addr.rs:367:19 | 367 | ..unsafe { mem::zeroed() } | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(clippy::needless_update)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_update
commit sha e6dc604e8b184b1224ae7acf58f06fa021ece82c
[net] clippy: match_like_matches_macro warning: match expression looks like `matches!` macro --> library/std/src/net/ip.rs:459:9 | 459 | / match self.octets() { 460 | | [169, 254, ..] => true, 461 | | _ => false, 462 | | } | |_________^ help: try this: `matches!(self.octets(), [169, 254, ..])` | = note: `#[warn(clippy::match_like_matches_macro)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro Signed-off-by: wcampbell <[email protected]>
commit sha 7a75f4418313da0173192ed4d2f198e505e11428
[net] clippy: identity_op warning: the operation is ineffective. Consider reducing it to `self.segments()[0]` --> library/std/src/net/ip.rs:1265:9 | 1265 | (self.segments()[0] & 0xffff) == 0xfe80 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(clippy::identity_op)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_op warning: the operation is ineffective. Consider reducing it to `self.segments()[1]` --> library/std/src/net/ip.rs:1266:16 | 1266 | && (self.segments()[1] & 0xffff) == 0 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_op warning: the operation is ineffective. Consider reducing it to `self.segments()[2]` --> library/std/src/net/ip.rs:1267:16 | 1267 | && (self.segments()[2] & 0xffff) == 0 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_op warning: the operation is ineffective. Consider reducing it to `self.segments()[3]` --> library/std/src/net/ip.rs:1268:16 | 1268 | && (self.segments()[3] & 0xffff) == 0 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_op Signed-off-by: wcampbell <[email protected]>
commit sha 39867f3c9fea0e01b5b199d8c2b6b0889284cc85
Fixed false positive for `unused_parens` lint
commit sha 7da0e58da4f1a4a7f102eb5478dbd4e7fa7edbaf
use matches! in library/std/src/net/ip.rs Apply suggestion from review Co-authored-by: LingMan <[email protected]>
commit sha ce04836327e6aebab6a834d89e7305d1b1be958b
fmt Signed-off-by: wcampbell <[email protected]>
commit sha 608f2600de26a37000e5ba0c76891d7cef13a3c5
Rename some RFC dirs to be sorted alphabetically
commit sha d87c17d22f6e5dce477dbd5d26e35847682f3a9c
Migrate from `associated-const` to `associated-consts`
commit sha 3113c077c042cdcbc0a071c11452118e7711a1c4
Migrate from `associated-type` to `associated-types`
commit sha 72b3807a09fd46a8650915dd4118eee4369ae6b8
Clarify the `mod` dir name not to make confusion with the `modules`
commit sha 3156310eb342bfe441d49bad5249b18ead651cdc
Migrate from `generic` to `generics`
commit sha 488b999fc20896318192f8e22709095cccd0a6bf
BTreeMap: test invariants more thoroughly and more readably
commit sha 736c27ec0b2cd8c79fedd66e5487b47b8746b7c0
Revert "[net] clippy: needless_update" This reverts commit 058699d0a2fca02127761f014d0ecfce1c5541ec.
commit sha 34c80aaffd6fb7104460489952c58238eaea92ab
change name in mailmap
commit sha f6aec82d4d7c9a75698808c28454d601aceac06f
Avoid cloning the contents of a `TokenStream` in a few places
push time in 3 days
push eventestebank/rust
commit sha b017f312f27ad745940e3923382d03304b3398a2
Add regression test for ICE
push time in 4 days
pull request commentrust-lang/rust
Tweak `if let` suggestion to be more liberal with suggestion and to not ICE
The ICE is in the beta now.
comment created time in 4 days
Pull request review commentrust-lang/rust
Tweak `if let` suggestion to be more liberal with suggestion and to not ICE
impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut err = self.demand_suptype_diag(expr.span, expected_ty, actual_ty).unwrap(); let lhs_ty = self.check_expr(&lhs); let rhs_ty = self.check_expr(&rhs);- if self.can_coerce(lhs_ty, rhs_ty) {- if !lhs.is_syntactic_place_expr() {- // Do not suggest `if let x = y` as `==` is way more likely to be the intention.- if let hir::Node::Expr(hir::Expr {- kind: ExprKind::Match(_, _, hir::MatchSource::IfDesugar { .. }),- ..- }) = self.tcx.hir().get(- self.tcx.hir().get_parent_node(self.tcx.hir().get_parent_node(expr.hir_id)),- ) {- // Likely `if let` intended.- err.span_suggestion_verbose(- expr.span.shrink_to_lo(),- "you might have meant to use pattern matching",- "let ".to_string(),- Applicability::MaybeIncorrect,- );- }+ let (mut msg, applicability, eq) = if self.can_coerce(rhs_ty, lhs_ty) {+ ("likely", Applicability::MachineApplicable, true)+ } else {+ ("might have", Applicability::MaybeIncorrect, false)
Addressed, now we only use "might have" regardless of applicability.
comment created time in 4 days
push eventestebank/rust
commit sha 5a7218009ec093f03bc0d2eb3ea2444ed4276f23
Rollup merge of #77429 - WaffleLapkin:doc_link_default_hasher_new, r=jyn514 Link `new` method in `DefautHasher`s doc FIXME referenced #56922 which was resolved r? @jyn514
commit sha f9d7720be7805d24f5f9c14e33b22f7ca3c7b964
Disable the SimplifyArmIdentity mir-opt The optimization still has some bugs that need to be worked out such as #77359. We can try re-enabling this again after the known issues are resolved.
commit sha 0801263279bbd44b7dbe88d5039a6b810a037f3b
Fix missing diagnostic span for `impl Trait` with const generics
commit sha f283d3f02cf3ed261a519afe05cde9e23d1d9278
Auto merge of #77436 - JohnTitor:rollup-65dh7rp, r=JohnTitor Rollup of 11 pull requests Successful merges: - #76851 (Fix 'FIXME' about using NonZeroU32 instead of u32.) - #76979 (Improve std::sys::windows::compat) - #77111 (Stabilize slice_ptr_range.) - #77147 (Split sys_common::Mutex in StaticMutex and MovableMutex.) - #77312 (Remove outdated line from `publish_toolstate` hook) - #77362 (Fix is_absolute on WASI) - #77375 (rustc_metadata: Do not forget to encode inherent impls for foreign types) - #77385 (Improve the example for ptr::copy) - #77389 (Fix some clippy lints) - #77399 (BTreeMap: use Unique::from to avoid a cast where type information exists) - #77429 (Link `new` method in `DefautHasher`s doc) Failed merges: r? `@ghost`
commit sha 1db05e032db798b3162926ee4b72072d3c4de56f
Add various `min_const_generics` regression tests
commit sha cd506eaea3064c396e851cc9e92b3405e8bc77c6
Fix AVR stack corruption bug Updates the Rust LLVM fork to pull in a fix for a stack corruption bug in AVR platform interrupt code lowering. Fixes #75504
commit sha e91202cf683b7265eec484ad311b5a9d3b56fc3e
Allow exponent separator Fixes #6096
commit sha ddd19866a739deb7cf798218d3b5b52a77b04a7a
Clean up on example doc fixes for ptr::copy Follow up of #77385
commit sha cadd12b5f020b9b2c7bb0c5e7078b81fbdcfb6d8
Implement Make `handle_alloc_error` default to panic (for no_std + liballoc) Related: https://github.com/rust-lang/rust/issues/66741 Guarded with `#![feature(default_alloc_error_handler)]` a default `alloc_error_handler` is called, if a custom allocator is used and no other custom `#[alloc_error_handler]` is defined. The panic message does not contain the size anymore, because it would pull in the fmt machinery, which would blow up the code size significantly.
commit sha 7d5a6203ec08ef6f5cf2349ba478f54ca1513989
Fix span for incorrect pattern field and add label
commit sha a8c2d4fc3d29496aa0a3563ec9d44f6222597fe3
Move boxing and mutex checking logic of condvar into sys_common.
commit sha 58deb7001deceb74cec38590a161d781d5d953b4
Make it possible to have unboxed mutexes on specific platforms. This commit keeps all mutexes boxed on all platforms, but makes it trivial to remove the box on some platforms later.
commit sha def5188ca887e36efdccd2cfda159eb1f3b89f9b
No longer put cloudabi mutexes in a box. Cloudabi mutexes may be moved safely.
commit sha 2f0386771d17703d8e5ea9abef3359770b51af3f
No longer put mutexes on the 'unsupported' platform in a box. These mutexes are just a bool (in a cell), so can be moved without problems.
commit sha 4f1353e54f9cdca82487b5e69f94e54047d8ea2f
No longer put wasm mutexes in a box. These mutexes are just an AtomicUsize, so can be moved without problems.
commit sha dc81cbdcb14bfaed773f0cd32f050caa108938e2
No longer put windows mutexes in a box. Windows SRW locks are movable (while not borrowed) according to their documentation.
commit sha b181f5a9231c133e2809277932d3a92cb2627b70
Make it possible to have unboxed condvars on specific platforms. This commit keeps all condvars boxed on all platforms, but makes it trivial to remove the box on some platforms later.
commit sha 5769a46788ec00338519fd8f87558419f0d6dd67
No longer put cloudabi condvars in a box. Cloudabi condvars may be moved safely.
commit sha 7f56a354114dffbbee8b12f134518d50d3aefe6a
No longer put condvars on the 'unsupported' platform in a box. These condvars are unsupported and implemented as a ZST, so can be moved without problems.
commit sha ec69a858e44992b37af3d559479777c0dfec1c7a
No longer put wasm condvars in a box. These condvars are just an AtomicUsize, so can be moved without problems.
push time in 4 days
Pull request review commentrust-lang/rust
Tweak `if let` suggestion to be more liberal with suggestion and to not ICE
impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut err = self.demand_suptype_diag(expr.span, expected_ty, actual_ty).unwrap(); let lhs_ty = self.check_expr(&lhs); let rhs_ty = self.check_expr(&rhs);- if self.can_coerce(lhs_ty, rhs_ty) {- if !lhs.is_syntactic_place_expr() {- // Do not suggest `if let x = y` as `==` is way more likely to be the intention.- if let hir::Node::Expr(hir::Expr {- kind: ExprKind::Match(_, _, hir::MatchSource::IfDesugar { .. }),- ..- }) = self.tcx.hir().get(- self.tcx.hir().get_parent_node(self.tcx.hir().get_parent_node(expr.hir_id)),- ) {- // Likely `if let` intended.- err.span_suggestion_verbose(- expr.span.shrink_to_lo(),- "you might have meant to use pattern matching",- "let ".to_string(),- Applicability::MaybeIncorrect,- );- }+ let (mut msg, applicability, eq) = if self.can_coerce(rhs_ty, lhs_ty) {
Yes, the expression we want to take as "ground truth" to detect if foo = bar when if let foo = bar was meant is the rhs.
comment created time in 4 days
Pull request review commentrust-lang/rust
error[E0038]: the trait `Trait` cannot be made into an object --> $DIR/associated-const-in-trait.rs:9:6 |-LL | trait Trait {- | ----- this trait cannot be made into an object...-LL | const N: usize;- | - ...because it contains this associated `const`-... LL | impl dyn Trait { | ^^^^^^^^^ the trait `Trait` cannot be made into an object
Changed the label to be less verbose, but it is still close to the main message.
comment created time in 4 days
push eventestebank/rust
commit sha e023158145ece18176a2e93420600ccda0d0bc58
Permit uninhabited enums to cast into ints This essentially reverts part of #6204.
commit sha 990a39596cf3b33e550f2045f78a62970f8d78f8
Prevent ICE on uninhabited MIR interpretation
commit sha a02014280586b53997622c501db00398376967a8
Refactor io/buffered.rs into submodules
commit sha 96229f02402e82914ec6100b28ad2cbdd273a0d4
move buffered.rs to mod.rs
commit sha 6d75cdfc9ed9e6987bd23add6cf3954d2499dce2
Added updated compiler diagnostic
commit sha da700cba08a2b194d19e63d3c51ebadce96fe46b
Stabilize move_ref_pattern
commit sha afb9eeb1b9ea16ca65e38673a0ef3e7be81d7252
Disabled error `E0007` from rustc_error_codes
commit sha 05c9c0ee5dcd935f518db151bee2dc88380fb92f
Modify executable checking to be more universal This uses a dummy file to check if the filesystem being used supports the executable bit in general.
commit sha c4280af8285c61b367a87c8f6eef9876011a8150
Retry fix error reporting suggestions
commit sha 1ff7da6551a7cdf6ace2a9d00e92bbab550334ee
Move `slice::check_range` to `RangeBounds`
commit sha 1095dcab96d524e700b11edf366d45a0fd173fa0
Fix links
commit sha eb63168e007058dad4af758faf1dca449c049777
Fix doctests
commit sha f055b0bb0847ecf08fe452a270faae8324b55b05
Rename method to `assert_len`
commit sha 549f861f7d53811521cf929cf58fb6828a2a88d9
Use correct article in help message for conversion or cast Before it always used `an`; now it uses the correct article for the type.
commit sha 094f14c554c3a1f103a5d6778d4b4e131c297f11
Add article after "to" Also added missing backtick in "you can cast" message.
commit sha 8a6831a7fd3fc624643b50f494212e0ceaad3c28
Say "doesn't" instead of "wouldn't" in convert message
commit sha 13dfbb64d313137b7d3c33067910e90f27bc6345
Suggest imports of unresolved macros
commit sha 479298e05e8177b171c6d6bcd35fc7553b424bee
Re-run tests with --bless
commit sha ea7cf6106864ce7929eb9f3cfe580f05ee418ac8
Don't suggest macros that out of scope
commit sha 0b923d3ca0b7f5a1a611564ee48c1e92f896d79e
add `str::{Split,RSplit}::as_str` methods This commit introduses 2 methods under "str_split_as_str" gate with common signature of `&Split<'a, _> -> &'a str'`. Both of them work like `Chars::as_str` - return unyield part of the inner string.
push time in 4 days
pull request commentrust-lang/rust
Improve `skip_binder` usage during FlagComputation
@bors r+ rollup=never
Just in case this causes a regression, I'd like to have it merged on its own.
comment created time in 4 days
Pull request review commentrust-lang/rust
pub fn expand_assert<'cx>( // `core::panic` and `std::panic` are different macros, so we use call-site // context to pick up whichever is currently in scope. let sp = cx.with_call_site_ctxt(sp);- let tokens = custom_message.unwrap_or_else(|| {- TokenStream::from(TokenTree::token(- TokenKind::lit(- token::Str,- Symbol::intern(&format!(- "assertion failed: {}",- pprust::expr_to_string(&cond_expr).escape_debug()- )),- None,- ),- DUMMY_SP,- ))- });- let args = P(MacArgs::Delimited(DelimSpan::from_single(sp), MacDelimiter::Parenthesis, tokens));- let panic_call = MacCall {- path: Path::from_ident(Ident::new(sym::panic, sp)),- args,- prior_type_ascription: None,++ let panic_call = {
Is the open brace here necessary for anything?
comment created time in 4 days
Pull request review commentrust-lang/rust
+use crate::{LateContext, LateLintPass, LintContext};+use rustc_ast as ast;+use rustc_errors::Applicability;+use rustc_hir as hir;+use rustc_middle::ty;+use rustc_span::sym;++declare_lint! {+ /// The `panic_fmt` lint detects `panic!("..")` with `{` or `}` in the string literal.+ ///+ /// ### Example+ ///+ /// ```rust,no_run+ /// panic!("{}");+ /// ```+ ///+ /// {{produces}}+ ///+ /// ### Explanation+ ///+ /// `panic!("{}")` panics with the message `"{}"`, as a `panic!()` invocation+ /// with a single argument does not use `format_args!()`.+ /// A future version of Rust will interpret this string as format string,+ /// which would break this.+ PANIC_FMT,+ Warn,+ "detect braces in single-argument panic!() invocations",+ report_in_external_macro+}++declare_lint_pass!(PanicFmt => [PANIC_FMT]);++impl<'tcx> LateLintPass<'tcx> for PanicFmt {+ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) {+ if let hir::ExprKind::Call(f, [arg]) = &expr.kind {+ if let &ty::FnDef(def_id, _) = cx.typeck_results().expr_ty(f).kind() {+ if Some(def_id) == cx.tcx.lang_items().begin_panic_fn()+ || Some(def_id) == cx.tcx.lang_items().panic_fn()+ {+ check_panic(cx, f, arg);+ }+ }+ }+ }+}++fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tcx hir::Expr<'tcx>) {+ if let hir::ExprKind::Lit(lit) = &arg.kind {+ if let ast::LitKind::Str(sym, _) = lit.node {+ let mut expn = f.span.ctxt().outer_expn_data();+ if let Some(id) = expn.macro_def_id {+ if cx.tcx.is_diagnostic_item(sym::std_panic_macro, id)+ || cx.tcx.is_diagnostic_item(sym::core_panic_macro, id)+ {+ let s = sym.as_str();+ if !s.contains(&['{', '}'][..]) {+ return;+ }+ let s = s.replace("{{", "").replace("}}", "");+ let looks_like_placeholder =+ s.find('{').map_or(false, |i| s[i + 1..].contains('}'));+ // Unwrap another level of macro expansion if this panic!()+ // was expanded from assert!() or debug_assert!().+ for &assert in &[sym::assert_macro, sym::debug_assert_macro] {+ let parent = expn.call_site.ctxt().outer_expn_data();+ if parent+ .macro_def_id+ .map_or(false, |id| cx.tcx.is_diagnostic_item(assert, id))+ {+ expn = parent;+ }+ }+ if looks_like_placeholder {+ cx.struct_span_lint(PANIC_FMT, arg.span.source_callsite(), |lint| {+ let mut l = lint.build("Panic message contains an unused formatting placeholder");+ l.note("This message is not used as a format string when given without arguments, but will be in a future Rust version");+ if expn.call_site.contains(arg.span) {+ l.span_suggestion(+ arg.span.shrink_to_hi(),+ "add the missing argument(s)",+ ", argument".into(),+ Applicability::HasPlaceholders,
We could actively parse the potential fmt string to get the accurate arg count, but this might be follow up work.
comment created time in 4 days
Pull request review commentrust-lang/rust
+use crate::{LateContext, LateLintPass, LintContext};+use rustc_ast as ast;+use rustc_errors::Applicability;+use rustc_hir as hir;+use rustc_middle::ty;+use rustc_span::sym;++declare_lint! {+ /// The `panic_fmt` lint detects `panic!("..")` with `{` or `}` in the string literal.+ ///+ /// ### Example+ ///+ /// ```rust,no_run+ /// panic!("{}");+ /// ```+ ///+ /// {{produces}}+ ///+ /// ### Explanation+ ///+ /// `panic!("{}")` panics with the message `"{}"`, as a `panic!()` invocation+ /// with a single argument does not use `format_args!()`.+ /// A future version of Rust will interpret this string as format string,+ /// which would break this.+ PANIC_FMT,+ Warn,+ "detect braces in single-argument panic!() invocations",+ report_in_external_macro+}++declare_lint_pass!(PanicFmt => [PANIC_FMT]);++impl<'tcx> LateLintPass<'tcx> for PanicFmt {+ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) {+ if let hir::ExprKind::Call(f, [arg]) = &expr.kind {+ if let &ty::FnDef(def_id, _) = cx.typeck_results().expr_ty(f).kind() {+ if Some(def_id) == cx.tcx.lang_items().begin_panic_fn()+ || Some(def_id) == cx.tcx.lang_items().panic_fn()+ {+ check_panic(cx, f, arg);+ }+ }+ }+ }+}++fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tcx hir::Expr<'tcx>) {+ if let hir::ExprKind::Lit(lit) = &arg.kind {+ if let ast::LitKind::Str(sym, _) = lit.node {+ let mut expn = f.span.ctxt().outer_expn_data();+ if let Some(id) = expn.macro_def_id {+ if cx.tcx.is_diagnostic_item(sym::std_panic_macro, id)+ || cx.tcx.is_diagnostic_item(sym::core_panic_macro, id)+ {
A common approach I take to avoid deeply nested fns is to use early returns like
let lit = match &arg.kind {
hir::ExprKind::Lit(lit) => lit,
_ => return,
};
}
Not necessary to do that now.
comment created time in 4 days
Pull request review commentrust-lang/rust
+use crate::{LateContext, LateLintPass, LintContext};+use rustc_ast as ast;+use rustc_errors::Applicability;+use rustc_hir as hir;+use rustc_middle::ty;+use rustc_span::sym;++declare_lint! {+ /// The `panic_fmt` lint detects `panic!("..")` with `{` or `}` in the string literal.+ ///+ /// ### Example+ ///+ /// ```rust,no_run+ /// panic!("{}");+ /// ```+ ///+ /// {{produces}}+ ///+ /// ### Explanation+ ///+ /// `panic!("{}")` panics with the message `"{}"`, as a `panic!()` invocation+ /// with a single argument does not use `format_args!()`.+ /// A future version of Rust will interpret this string as format string,+ /// which would break this.+ PANIC_FMT,+ Warn,+ "detect braces in single-argument panic!() invocations",+ report_in_external_macro+}++declare_lint_pass!(PanicFmt => [PANIC_FMT]);++impl<'tcx> LateLintPass<'tcx> for PanicFmt {+ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) {+ if let hir::ExprKind::Call(f, [arg]) = &expr.kind {+ if let &ty::FnDef(def_id, _) = cx.typeck_results().expr_ty(f).kind() {+ if Some(def_id) == cx.tcx.lang_items().begin_panic_fn()+ || Some(def_id) == cx.tcx.lang_items().panic_fn()+ {+ check_panic(cx, f, arg);+ }+ }+ }+ }+}++fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tcx hir::Expr<'tcx>) {+ if let hir::ExprKind::Lit(lit) = &arg.kind {+ if let ast::LitKind::Str(sym, _) = lit.node {+ let mut expn = f.span.ctxt().outer_expn_data();+ if let Some(id) = expn.macro_def_id {+ if cx.tcx.is_diagnostic_item(sym::std_panic_macro, id)+ || cx.tcx.is_diagnostic_item(sym::core_panic_macro, id)+ {+ let s = sym.as_str();+ if !s.contains(&['{', '}'][..]) {+ return;+ }+ let s = s.replace("{{", "").replace("}}", "");+ let looks_like_placeholder =+ s.find('{').map_or(false, |i| s[i + 1..].contains('}'));+ // Unwrap another level of macro expansion if this panic!()+ // was expanded from assert!() or debug_assert!().+ for &assert in &[sym::assert_macro, sym::debug_assert_macro] {+ let parent = expn.call_site.ctxt().outer_expn_data();+ if parent+ .macro_def_id+ .map_or(false, |id| cx.tcx.is_diagnostic_item(assert, id))+ {+ expn = parent;+ }+ }+ if looks_like_placeholder {+ cx.struct_span_lint(PANIC_FMT, arg.span.source_callsite(), |lint| {+ let mut l = lint.build("Panic message contains an unused formatting placeholder");+ l.note("This message is not used as a format string when given without arguments, but will be in a future Rust version");
let mut l = lint.build("panic message contains an unused formatting placeholder");
l.span_label(arg.span, "this is not used as a format string when given without arguments, but will be in a future Rust version");
comment created time in 4 days
Pull request review commentrust-lang/rust
fn quoted_tt_to_string(tt: &mbe::TokenTree) -> String { mbe::TokenTree::MetaVar(_, name) => format!("${}", name), mbe::TokenTree::MetaVarDecl(_, name, kind) => format!("${}:{}", name, kind), _ => panic!(- "unexpected mbe::TokenTree::{{Sequence or Delimited}} \+ "{}",+ "unexpected mbe::TokenTree::{Sequence or Delimited} \ in follow set checker" ),
Oh! I see. Makes sense.
comment created time in 4 days
pull request commentrust-lang/rust
Improve wording of "cannot multiply" type error
@bors r+
comment created time in 4 days
Pull request review commentrust-lang/rust
+warning: Panic message contains a brace+ --> $DIR/panic-brace.rs:5:5+ |+LL | panic!("here's a brace: {");+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^+ |+ = note: `#[warn(panic_fmt)]` on by default+ = note: This message is not used as a format string, but will be in a future Rust version+help: add a "{}" format string to use the message literally+ |+LL | panic!("{}", "here's a brace: {");+ | ^^^^^++warning: Panic message contains a brace+ --> $DIR/panic-brace.rs:6:5+ |+LL | std::panic!("another one: }");+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^+ |+ = note: This message is not used as a format string, but will be in a future Rust version+help: add a "{}" format string to use the message literally+ |+LL | std::panic!("{}", "another one: }");+ | ^^^^^++warning: Panic message contains an unused formatting placeholder+ --> $DIR/panic-brace.rs:7:18+ |+LL | core::panic!("Hello {}");+ | ^^^^^^^^^^+ |+ = note: This message is not used as a format string when given without arguments, but will be in a future Rust version+help: add the missing argument(s)+ |+LL | core::panic!("Hello {}", argument);+ | ^^^^^^^^^^+help: or add a "{}" format string to use the message literally+ |+LL | core::panic!("{}", "Hello {}");+ | ^^^^^++warning: Panic message contains an unused formatting placeholder+ --> $DIR/panic-brace.rs:8:20+ |+LL | assert!(false, "{:03x} bla");+ | ^^^^^^^^^^^^+ |+ = note: This message is not used as a format string when given without arguments, but will be in a future Rust version+help: add the missing argument(s)+ |+LL | assert!(false, "{:03x} bla", argument);+ | ^^^^^^^^^^+help: or add a "{}" format string to use the message literally+ |+LL | assert!(false, "{}", "{:03x} bla");+ | ^^^^^
I feel that the second suggestion should be for assert!(false, "{{:03x}} bla"); instead.
comment created time in 4 days
Pull request review commentrust-lang/rust
fn quoted_tt_to_string(tt: &mbe::TokenTree) -> String { mbe::TokenTree::MetaVar(_, name) => format!("${}", name), mbe::TokenTree::MetaVarDecl(_, name, kind) => format!("${}:{}", name, kind), _ => panic!(- "unexpected mbe::TokenTree::{{Sequence or Delimited}} \+ "{}",+ "unexpected mbe::TokenTree::{Sequence or Delimited} \ in follow set checker" ),
I would have imagined that this case would be accepted as correct: the panic message is explicitly escaping the braces.
comment created time in 4 days
issue commentrust-lang/rust
ICE: type_of.rs:115:26: unexpected anon const res PrimTy(Uint(Usize)) in path
The solution might be as simple as merging the linked match arm with the previous error one, making this a delay_span_bug and ignoring it.
comment created time in 5 days
push eventestebank/rust
commit sha e023158145ece18176a2e93420600ccda0d0bc58
Permit uninhabited enums to cast into ints This essentially reverts part of #6204.
commit sha 990a39596cf3b33e550f2045f78a62970f8d78f8
Prevent ICE on uninhabited MIR interpretation
commit sha a02014280586b53997622c501db00398376967a8
Refactor io/buffered.rs into submodules
commit sha 96229f02402e82914ec6100b28ad2cbdd273a0d4
move buffered.rs to mod.rs
commit sha 6d75cdfc9ed9e6987bd23add6cf3954d2499dce2
Added updated compiler diagnostic
commit sha da700cba08a2b194d19e63d3c51ebadce96fe46b
Stabilize move_ref_pattern
commit sha afb9eeb1b9ea16ca65e38673a0ef3e7be81d7252
Disabled error `E0007` from rustc_error_codes
commit sha c4280af8285c61b367a87c8f6eef9876011a8150
Retry fix error reporting suggestions
commit sha 13dfbb64d313137b7d3c33067910e90f27bc6345
Suggest imports of unresolved macros
commit sha 479298e05e8177b171c6d6bcd35fc7553b424bee
Re-run tests with --bless
commit sha ea7cf6106864ce7929eb9f3cfe580f05ee418ac8
Don't suggest macros that out of scope
commit sha 0b923d3ca0b7f5a1a611564ee48c1e92f896d79e
add `str::{Split,RSplit}::as_str` methods This commit introduses 2 methods under "str_split_as_str" gate with common signature of `&Split<'a, _> -> &'a str'`. Both of them work like `Chars::as_str` - return unyield part of the inner string.
commit sha 4747215d778abd9f280202d07f279fdeaea519f8
add `str::{SplitN, RSplitN, SplitTerminator, RSplitTerminator}::as_str` methods This commit entroduce 4 methods smililar to `Split::as_str` all under the same gate "str_split_as_str".
commit sha 076514c8a82591547116a7a2212c4de4bdc56f76
add `str::SplitInclusive::as_str` method This commit entroduces `core::str::SplitInclusive::as_str` method similar to `core::str::Split::as_str`, but under different gate - "str_split_inclusive_as_str" (this is done so because `SplitInclusive` is itself unstable).
commit sha 8fe61546696b626ecf68ef838d5d82e393719e80
Use posix_spawn() on unix if program is a path Previously `Command::spawn` would fall back to the non-posix_spawn based implementation if the `PATH` environment variable was possibly changed. On systems with a modern (g)libc `posix_spawn()` can be significantly faster. If program is a path itself the `PATH` environment variable is not used for the lookup and it should be safe to use the `posix_spawnp()` method. [1] We found this, because we have a cli application that effectively runs a lot of subprocesses. It would sometimes noticeably hang while printing output. Profiling showed that the process was spending the majority of time in the kernel's `copy_page_range` function while spawning subprocesses. During this time the process is completely blocked from running, explaining why users were reporting the cli app hanging. Through this we discovered that `std::process::Command` has a fast and slow path for process execution. The fast path is backed by `posix_spawnp()` and the slow path by fork/exec syscalls being called explicitly. Using fork for process creation is supposed to be fast, but it slows down as your process uses more memory. It's not because the kernel copies the actual memory from the parent, but it does need to copy the references to it (see `copy_page_range` above!). We ended up using the slow path, because the command spawn implementation in falls back to the slow path if it suspects the PATH environment variable was changed. Here is a smallish program demonstrating the slowdown before this code change: ``` use std::process::Command; use std::time::Instant; fn main() { let mut args = std::env::args().skip(1); if let Some(size) = args.next() { // Allocate some memory let _xs: Vec<_> = std::iter::repeat(0) .take(size.parse().expect("valid number")) .collect(); let mut command = Command::new("/bin/sh"); command .arg("-c") .arg("echo hello"); if args.next().is_some() { println!("Overriding PATH"); command.env("PATH", std::env::var("PATH").expect("PATH env var")); } let now = Instant::now(); let child = command .spawn() .expect("failed to execute process"); println!("Spawn took: {:?}", now.elapsed()); let output = child.wait_with_output().expect("failed to wait on process"); println!("Output: {:?}", output); } else { eprintln!("Usage: prog [size]"); std::process::exit(1); } () } ``` Running it and passing different amounts of elements to use to allocate memory shows that the time taken for `spawn()` can differ quite significantly. In latter case the `posix_spawnp()` implementation is 30x faster: ``` $ cargo run --release 10000000 ... Spawn took: 324.275µs hello $ cargo run --release 10000000 changepath ... Overriding PATH Spawn took: 2.346809ms hello $ cargo run --release 100000000 ... Spawn took: 387.842µs hello $ cargo run --release 100000000 changepath ... Overriding PATH Spawn took: 13.434677ms hello ``` [1]: https://github.com/bminor/glibc/blob/5f72f9800b250410cad3abfeeb09469ef12b2438/posix/execvpe.c#L81
commit sha f84f01c0148cfb2451775fcbf299a2e7b10b1e81
Use futex-based thread-parker for Wasm32.
commit sha 54a71e89546886951e32035960aa82a15a343668
For backtrace, use StaticMutex instead of a raw sys Mutex.
commit sha e6d61ade9c1523dc2dd7cbd97206d6ebc5b5d481
Use slice_as_mut_ptr instead of first_ptr_mut. This function was renamed.
commit sha 0f26578f2e2e41c51279f3b2bd967785241d316d
Get rid of UnsafeCell<MaybeUninit>s in cloudabi mutex.
commit sha 41066beb4dd3a7618e1f7617d60704f5c4425bf7
Get rid of UnsafeCell in cloudabi rwlock.
push time in 6 days
Pull request review commentrust-lang/rust
Make it more clear what an about async fn's returns when referring to what it returns
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { None => String::new(), }; - let (span_1, span_2, main_label, span_label) = match (sup_is_ret_type, sub_is_ret_type) {- (None, None) => {- let (main_label_1, span_label_1) = if ty_sup.hir_id == ty_sub.hir_id {+ let (span_1, span_2, main_label, span_label, future_span) =+ match (sup_is_ret_type, sub_is_ret_type) {+ (None, None) => {+ let (main_label_1, span_label_1) = if ty_sup.hir_id == ty_sub.hir_id {+ (+ "this type is declared with multiple lifetimes...".to_owned(),+ "...but data with one lifetime flows into the other here".to_owned(),+ )+ } else {+ (+ "these two types are declared with different lifetimes...".to_owned(),+ format!("...but data{} flows{} here", span_label_var1, span_label_var2),+ )+ };+ (ty_sup.span, ty_sub.span, main_label_1, span_label_1, None)+ }++ (Some(ret_span), _) => {+ let sup_future = self.future_return_type(scope_def_id_sup);+ let (return_type, action) = if let Some(_) = sup_future {+ ("returned future", "held across an await point")+ } else {+ ("return type", "returned")+ };+ (- "this type is declared with multiple lifetimes...".to_owned(),- "...but data with one lifetime flows into the other here".to_owned(),+ ty_sub.span,+ ret_span,+ format!(+ "this parameter and the {} are declared with different lifetimes...",+ return_type+ ),+ format!("...but data{} is {} here", span_label_var1, action),+ sup_future, )- } else {+ }+ (_, Some(ret_span)) => {+ let sub_future = self.future_return_type(scope_def_id_sub);+ let (return_type, action) = if let Some(_) = sub_future {+ ("returned future", "held across an await point")+ } else {+ ("return type", "returned")+ };+ (- "these two types are declared with different lifetimes...".to_owned(),- format!("...but data{} flows{} here", span_label_var1, span_label_var2),+ ty_sup.span,+ ret_span,+ format!(+ "this parameter and the {} are declared with different lifetimes...",+ return_type+ ),+ format!("...but data{} is {} here", span_label_var1, action),+ sub_future, )- };- (ty_sup.span, ty_sub.span, main_label_1, span_label_1)- }-- (Some(ret_span), _) => (- ty_sub.span,- ret_span,- "this parameter and the return type are declared with different lifetimes..."- .to_owned(),- format!("...but data{} is returned here", span_label_var1),- ),- (_, Some(ret_span)) => (- ty_sup.span,- ret_span,- "this parameter and the return type are declared with different lifetimes..."- .to_owned(),- format!("...but data{} is returned here", span_label_var1),- ),- };+ }+ }; - struct_span_err!(self.tcx().sess, span, E0623, "lifetime mismatch")- .span_label(span_1, main_label)- .span_label(span_2, String::new())- .span_label(span, span_label)- .emit();+ let mut e = struct_span_err!(self.tcx().sess, span, E0623, "lifetime mismatch");++ e.span_label(span_1, main_label);+ e.span_label(span_2, String::new());+ e.span_label(span, span_label);++ if let Some(s) = future_span {+ e.span_note(s, "`async fn`s return an `impl Future<Output={return type}`");
Ty<'_> implements Display.
comment created time in 6 days
pull request commentrust-lang/rust
resolve: further improvements to "try using the enum's variant" diagnostic
@bors r+
comment created time in 8 days
Pull request review commentrust-lang/rust
Provide appropriate types in turbofish suggestions
+error[E0283]: type annotations needed+ --> $DIR/appropriate-type-param-turbofish.rs:3:35+ |+LL | vec![1, 2, 3].into_iter().collect();+ | ^^^^^^^ cannot infer type for type parameter `B` declared on the associated function `collect`+ |+ = note: cannot satisfy `_: FromIterator<i32>`+help: consider specifying the type argument in the method call+ |+LL | vec![1, 2, 3].into_iter().collect::<Vec<T>>();
Only thing I would like to do is replace the type params in the suggestions with _ to avoid "T doesn't exist" errors when applying the change.
comment created time in 8 days
push eventestebank/rust
commit sha 85715061a161d2a6cf3c98478fb9e55075f1cd89
Suggest `&[_]` instead of `&[_; N]` on inference error
push time in 8 days
Pull request review commentrust-lang/rust
Provide appropriate types in turbofish suggestions
error[E0282]: type annotations needed for `&[_; 0]` --> $DIR/issue-7813.rs:2:13 | LL | let v = &[];- | - ^^^ cannot infer type- | |- | consider giving `v` the explicit type `&[_; 0]`, with the type parameters specified+ | ^^^ cannot infer type+ |+help: consider giving this binding the explicit type `&[_; 0]`, with the type parameters specified+ |+LL | let v: &[_; 0] = &[];+ | ^^^^^^^^^
Resolved in the last commit.
comment created time in 8 days
push eventestebank/rust
commit sha 3b5db52b11d608ee50e16d12c0caafaab3043f10
Suggest `&[_]` instead of `&[_: N]` on inference error
push time in 8 days
push eventestebank/rust
commit sha a215151cd357945acdb2675010708cb2d10bb4c0
Allow ascii whitespace char for doc aliases
commit sha accc26abc0e53067d7a97d0fb19800c37a24f844
Add test for whitespace in doc alias
commit sha 11f3476c59ee013c017e669676cfaca00a67b3f1
Enforce whitespace ascii character check for doc alias
commit sha 07627a3aa3dc7e0e961b523808dfd55bb86bde3e
Add a regression test for issue-52843
commit sha 32bc245bc09c724699cb1fed63c2ea17a20532c4
Add a regression test for issue-53448
commit sha ebc1f89ecf3a8de6da0ed6c5809586105f5d7fae
Add a regression test for issue-54108
commit sha 3a4fe97052cf9d3f244fcab885e338a6384cefa6
Add a regression test for issue-65581
commit sha 83370efdb64058397b4cd99ee2d31cf94b91757c
Add a regression test for issue-65934
commit sha e4fa906c44b5f746107d1bbfc648a2edeb29b627
Add a regression test for issue-70292
commit sha fb4d62759b6d4a5165f1a4401eb8c55c9f7f6211
Add a regression test for issue-71443
commit sha 9f7eab4548388cc93fed635aacc1d59475bed89f
Use `ty::Binder::bind` to fix debug-assertions ICEs
commit sha dc183702da942f4a25bff99b2bb6073d1aa7c9f9
Replace tuple of infer vars for upvar_tys with single infer var This commit allows us to decide the number of captures required after completing capture ananysis, which is required as part of implementing RFC-2229. Co-authored-by: Aman Arora <[email protected]> Co-authored-by: Jenny Wills <[email protected]>
commit sha 08d1ab0bf1c01948135548f5404eb625e454160e
Always return tupled_upvar_tys for Closure/Generator consituent tys Depending on if upvar_tys inferred or not, we were returning either an inference variable which later resolves to a tuple or else the upvar tys themselves Co-authored-by: Roxane Fruytier <[email protected]>
commit sha 3c46fd67f8b4831da9f2e8a536d34f498cf70241
traits diagnostics: Don't print closure/generator upvar_tys tuple Co-authored-by: Roxane Fruytier <[email protected]>
commit sha 861b8921c08e3cbe2ff8176679cc0cb3216bb2e3
Clean up rustdoc HTML tags check pass
commit sha 0009cbaabd6f2ba986e7631905612aa83d5970f8
Add check for HTML comments
commit sha ab614b0f010e68b74b8f8a6ce26d53302fb4f14a
Implement "if-available" option for download-ci-llvm
commit sha b8ae4c5e36d5ce36bf255dbaa66f64450b21efa5
Handle included config in bootstrap.py
commit sha 585e737ec1844e13bbf2f50f3dc1057057a52184
Validate references to source scopes
commit sha de4bcfd33133a8c7e6947e13a0711de5352197aa
Include aarch64-pc-windows-msvc in the dist manifests
push time in 8 days
pull request commentrust-lang/rust
ensure arguments are included in count mismatch span
@bors r+
comment created time in 8 days
issue commentrust-lang/rust
I think the issue is the hiding of the expected error.
comment created time in 8 days
Pull request review commentrust-lang/rust
ensure arguments are included in count mismatch span
impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); } - if let Some(def_s) = def_span.map(|sp| tcx.sess.source_map().guess_head_span(sp)) {- err.span_label(def_s, "defined here");+ if let Some(def_id) = def_id {+ if let Some(node) = tcx.hir().get_if_local(def_id) {+ let mut spans: MultiSpan = node+ .ident()+ .map(|ident| ident.span)+ .unwrap_or_else(|| tcx.hir().span(node.hir_id().unwrap()))
error[E0599]: no method named `hir_id` found for enum `rustc_hir::Node<'_>` in the current scope
--> compiler/rustc_typeck/src/check/fn_ctxt/checks.rs:180:64
|
180 | .unwrap_or_else(|| tcx.hir().span(node.hir_id().unwrap()))
| ^^^^^^ method not found in `rustc_hir::Node<'_>`
comment created time in 9 days
push eventestebank/rust
commit sha a27473bf3b3d880cae97b910eca65f1125ef64bb
Skip lifetimes in turbofish suggestions
push time in 9 days
push eventestebank/rust
commit sha b3d614c340b38bb8e114ac4b2b0fad2cd5f2046b
Do not skip "type annotation needed"/`Sized` error
push time in 9 days
Pull request review commentrust-lang/rust
Added better error message for shared borrow treated as unique for purposes of lifetimes
impl<'cx, 'tcx> crate::borrow_check::MirBorrowckCtxt<'cx, 'tcx> { err.span_label( new_loan_span, format!(- "mutable borrow starts here in previous \- iteration of loop{}",+ "mutable already borrowed in the previous \+ iteration of the loop{}", opt_via
You probably want to use desc here:
"{} was borrowed mutably in the previous iteration of the loop{}",
desc,
opt_via,
comment created time in 9 days
pull request commentrust-lang/rust
Include trailing comma in field/variant spans
In that case a comma_span field would be more than enough, then.
comment created time in 9 days
pull request commentrust-lang/rust
Include trailing comma in field/variant spans
@Aaron1011 could we make a change were we add a second span to the variant and see how that impacts perf? That would be my preferred solution here so that we could keep the current output but we still have an alternate span to refer to the whole thing.
comment created time in 9 days
Pull request review commentrust-lang/rust
resolve: further improvements to "try using the enum's variant" diagnostic
error[E0423]: expected value, found enum `E` LL | let _: E = E; | ^ |- = help: you might have meant to use one of the enum's other variants that have fields-help: try using one of the enum's variants+help: try using the enum's variant which have fields | LL | let _: E = E::Unit; | ^^^^^^^+help: try using one of the enum's variants which have fields+ |+LL | let _: E = (E::Fn(/* fields */));+ | ^^^^^^^^^^^^^^^^^^^^^+LL | let _: E = (E::Struct { /* fields */ });+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
What about
help: you might have meant to use the following enum variant(s)
|
help: alternatively, the following enum variants are also available
|
comment created time in 9 days
Pull request review commentrust-lang/rust
resolve: further improvements to "try using the enum's variant" diagnostic
impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { )); } } else {- let made_suggestion = non_suggestable_variant_count != variants.len();- if made_suggestion {- if non_suggestable_variant_count == 1 {- err.help(- "you might have meant to use the enum's other variant that has fields",- );- } else if non_suggestable_variant_count >= 1 {- err.help(- "you might have meant to use one of the enum's other variants that \- have fields",- );- }- } else {- if non_suggestable_variant_count == 1 {- err.help("you might have meant to use the enum's variant");- } else if non_suggestable_variant_count >= 1 {- err.help("you might have meant to use one of the enum's variants");+ let needs_placeholder = |def_id: DefId, kind: CtorKind| {+ let has_no_fields =+ self.r.field_names.get(&def_id).map(|f| f.is_empty()).unwrap_or(false);+ match kind {+ CtorKind::Const => false,+ CtorKind::Fn | CtorKind::Fictive if has_no_fields => false,+ _ => true, }- }- }+ };
I think it would be useful to either include the field names in the suggestion (instead of /*fields*/) with some placeholder per field, or to have a span pointing at the def, otherwise you are forcing people to consult the docs/code to fix the issue.
comment created time in 9 days