about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2022-01-31Fix invalid special casing of the unreachable! macroLoïc BRANSTETT-6/+33
2022-01-31Auto merge of #93498 - matthiaskrgr:rollup-k5shwrc, r=matthiaskrgrbors-70/+155
Rollup of 8 pull requests Successful merges: - #90277 (Improve terminology around "after typeck") - #92918 (Allow eliding GATs in expression position) - #93039 (Don't suggest inaccessible fields) - #93155 (Switch pretty printer to block-based indentation) - #93214 (Respect doc(hidden) when suggesting available fields) - #93347 (Make `char::DecodeUtf16::size_hist` more precise) - #93392 (Clarify documentation on char::MAX) - #93444 (Fix some CSS warnings and errors from VS Code) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-01-31Rollup merge of #93461 - dtolnay:fmtyield, r=davidtwcoMatthias Krüger-4/+51
Accommodate yield points in the format_args expansion Fixes #93274. For the case `println!("{} {:?}", "", async {}.await)` in the issue, the expansion before: ```rust ::std::io::_print( ::core::fmt::Arguments::new_v1( &["", " ", "\n"], &[ ::core::fmt::ArgumentV1::new(&"", ::core::fmt::Display::fmt), ::core::fmt::ArgumentV1::new(&async {}.await, ::core::fmt::Debug::fmt), ], ), ); ``` After: ```rust ::std::io::_print( ::core::fmt::Arguments::new_v1( &["", " ", "\n"], &match (&"", &async {}.await) { _args => [ ::core::fmt::ArgumentV1::new(_args.0, ::core::fmt::Display::fmt), ::core::fmt::ArgumentV1::new(_args.1, ::core::fmt::Debug::fmt), ], }, ), ); ```
2022-01-31Rollup merge of #93395 - camelid:reserved-sugg, r=davidtwcoMatthias Krüger-4/+4
Improve suggestion for escaping reserved keywords r? `@davidtwco`
2022-01-31Rollup merge of #93214 - ibraheemdev:issue-93210, r=davidtwcoMatthias Krüger-9/+32
Respect doc(hidden) when suggesting available fields Resolves #93210
2022-01-31Rollup merge of #93155 - dtolnay:blockindent, r=nagisaMatthias Krüger-32/+69
Switch pretty printer to block-based indentation This PR backports https://github.com/dtolnay/prettyplease/commit/401d60c04213e6c66565e0e69a95b4588db5fdba from the `prettyplease` crate into `rustc_ast_pretty`. A before and after: ```diff - let res = - ((::alloc::fmt::format as - for<'r> fn(Arguments<'r>) -> String {format})(((::core::fmt::Arguments::new_v1 - as - fn(&[&'static str], &[ArgumentV1]) -> Arguments {Arguments::new_v1})((&([("test" - as - &str)] - as - [&str; 1]) - as - &[&str; 1]), - (&([] - as - [ArgumentV1; 0]) - as - &[ArgumentV1; 0])) - as - Arguments)) - as String); + let res = + ((::alloc::fmt::format as + for<'r> fn(Arguments<'r>) -> String {format})(((::core::fmt::Arguments::new_v1 + as + fn(&[&'static str], &[ArgumentV1]) -> Arguments {Arguments::new_v1})((&([("test" + as &str)] as [&str; 1]) as + &[&str; 1]), + (&([] as [ArgumentV1; 0]) as &[ArgumentV1; 0])) as + Arguments)) as String); ``` Previously the pretty printer would compute indentation always relative to whatever column a block begins at, like this: ```rust fn demo(arg1: usize, arg2: usize); ``` This is never the thing to do in the dominant contemporary Rust style. Rustfmt's default and the style used by the vast majority of Rust codebases is block indentation: ```rust fn demo( arg1: usize, arg2: usize, ); ``` where every indentation level is a multiple of 4 spaces and each level is indented relative to the indentation of the previous line, not the position that the block starts in. By itself this PR doesn't get perfect formatting in all cases, but it is the smallest possible step in clearly the right direction. More backports from `prettyplease` to tune the ibox/cbox indent levels around various AST node types are upcoming.
2022-01-31Rollup merge of #93039 - terrarier2111:fix-field-help, r=nagisaMatthias Krüger-9/+19
Don't suggest inaccessible fields Fixes: https://github.com/rust-lang/rust/issues/92999
2022-01-31Rollup merge of #92918 - compiler-errors:gat-expr-lifetime-elision, r=jackh726Matthias Krüger-2/+15
Allow eliding GATs in expression position Thoughts on whether this is worthwhile? Fixes #92836 r? ``@jackh726``
2022-01-31Rollup merge of #90277 - pierwill:fix-70258-inference-terms, r=jackh726Matthias Krüger-18/+20
Improve terminology around "after typeck" Closes #70258.
2022-01-30Restore a visual alignment mode for block commentsDavid Tolnay-4/+30
2022-01-30Fix some double indents on exprs containing blocksDavid Tolnay-10/+18
The `print_expr` method already places an `ibox(INDENT_UNIT)` around every expr that gets printed. Some exprs were then using `self.head` inside of that, which does its own `cbox(INDENT_UNIT)`, resulting in two levels of indentation: while true { stuff; } This commit fixes those cases to produce the expected single level of indentation within every expression containing a block. while true { stuff; }
2022-01-30Compute indent never relative to current columnDavid Tolnay-19/+22
Previously the pretty printer would compute indentation always relative to whatever column a block begins at, like this: fn demo(arg1: usize, arg2: usize); This is never the thing to do in the dominant contemporary Rust style. Rustfmt's default and the style used by the vast majority of Rust codebases is block indentation: fn demo( arg1: usize, arg2: usize, ); where every indentation level is a multiple of 4 spaces and each level is indented relative to the indentation of the previous line, not the position that the block starts in.
2022-01-31Auto merge of #90891 - nbdd0121:format, r=Mark-Simulacrumbors-45/+35
Create `core::fmt::ArgumentV1` with generics instead of fn pointer Split from (and prerequisite of) #90488, as this seems to have perf implication. `@rustbot` label: +T-libs
2022-01-30Mac callsDavid Tolnay-3/+5
2022-01-30Accommodate yield points in the format_args expansionDavid Tolnay-4/+49
2022-01-30Rollup merge of #93192 - theidexisted:patch-1, r=wesleywiserEric Huss-1/+1
Add VS 2022 into error message
2022-01-30Rollup merge of #92908 - dtolnay:rustdoc, r=GuillaumeGomezEric Huss-1/+1
Render more readable macro matcher tokens in rustdoc Follow-up to #92334. This PR lifts some of the token rendering logic from https://github.com/dtolnay/prettyplease into rustdoc so that even the matchers for which a source code snippet is not available (because they are macro-generated, or any other reason) follow some baseline good assumptions about where the tokens in the macro matcher are appropriate to space. The below screenshots show an example of the difference using one of the gnarliest macros I could find. Some things to notice: - In the **before**, notice how a couple places break in between `$(....)`↵`*`, which is just about the worst possible place that it could break. - In the **before**, the lines that wrapped are weirdly indented by 1 space of indentation relative to column 0. In the **after**, we use the typical way of block indenting in Rust syntax which is put the open/close delimiters on their own line and indent their contents by 4 spaces relative to the previous line (so 8 spaces relative to column 0, because the matcher itself is indented by 4 relative to the `macro_rules` header). - In the **after**, macro_rules metavariables like `$tokens:tt` are kept together, which is how just about everybody writing Rust today writes them. ## Before ![Screenshot from 2022-01-14 13-05-53](https://user-images.githubusercontent.com/1940490/149585105-1f182b78-751f-421f-a234-9dbc04fa3bbd.png) ## After ![Screenshot from 2022-01-14 13-06-04](https://user-images.githubusercontent.com/1940490/149585118-d4b52ea7-3e67-4b6e-a12b-31dfb8172f86.png) r? `@camelid`
2022-01-30Rollup merge of #92887 - pietroalbini:pa-bootstrap-update, r=Mark-SimulacrumEric Huss-18/+4
Bootstrap compiler update r? ``@Mark-Simulacrum``
2022-01-30Rollup merge of #93463 - dtolnay:_args, r=cjgillotMatthias Krüger-4/+4
Rename _args -> args in format_args expansion As observed in https://github.com/rust-lang/rust/pull/91359#discussion_r786058960, prior to that PR this variable was sometimes never used, such as in the case of: ```rust println!(""); // used to expand to: ::std::io::_print( ::core::fmt::Arguments::new_v1( &["\n"], &match () { _args => [], }, ), ); ``` so the leading underscore in `_args` was used to suppress an unused variable lint. However after #91359 the variable is always used when present, as the unused case would instead expand to: ```rust ::std::io::_print(::core::fmt::Arguments::new_v1(&["\n"], &[])); ```
2022-01-30Rollup merge of #93362 - compiler-errors:ice-gat-in-rpit, r=oli-obkMatthias Krüger-7/+9
Do not register infer var for GAT projection in RPIT Fixes #93340 Fixes #91603 r? ```@oli-obk```
2022-01-30Rollup merge of #93358 - compiler-errors:is-not-const, r=fee1-deadMatthias Krüger-12/+44
Add note suggesting that predicate may be satisfied, but is not `const` Not sure if we should be printing this in addition to, or perhaps _instead_ of the help message: ``` help: the trait `~const Add` is not implemented for `NonConstAdd` ``` Also added `ParamEnv::is_const` and `PolyTraitPredicate::is_const_if_const` and, in a separate commit, used those in other places instead of `== hir::Constness::Const`, etc. r? ````@fee1-dead````
2022-01-29Rename _args -> args in format_args expansionDavid Tolnay-4/+4
2022-01-29Create `core::fmt::ArgumentV1` with generics instead of fn pointerGary Guo-45/+35
2022-01-29Rollup merge of #93431 - lqd:remove-jemallocator, r=Mark-SimulacrumMatthias Krüger-5/+1
remove unused `jemallocator` crate When it was noticed that the rustc binary wasn't actually using jemalloc via `#[global_allocator]` and that was removed, the dependency remained. Tests pass locally with a `jemalloc = true` build, but I'll trigger a try build to ensure I haven't missed an edge-case somewhere. r? ```@ghost``` until that completes
2022-01-29Rollup merge of #93424 - lcnr:nit, r=spastorinoMatthias Krüger-1/+1
fix nit
2022-01-29Rollup merge of #92274 - woppopo:const_deallocate, r=oli-obkMatthias Krüger-0/+43
Add `intrinsics::const_deallocate` Tracking issue: #79597 Related: #91884 This allows deallocation of a memory allocated by `intrinsics::const_allocate`. At the moment, this can be only used to reduce memory usage, but in the future this may be useful to detect memory leaks (If an allocated memory remains after evaluation, raise an error...?).
2022-01-29Rollup merge of #88205 - danii:e0772, r=GuillaumeGomezMatthias Krüger-1/+90
Add Explanation For Error E0772 I've added an error explanation for the error code E0772. Assists with #61137
2022-01-28Auto merge of #93427 - matthiaskrgr:rollup-esd3ixl, r=matthiaskrgrbors-75/+71
Rollup of 10 pull requests Successful merges: - #92611 (Add links to the reference and rust by example for asm! docs and lints) - #93158 (wasi: implement `sock_accept` and enable networking) - #93239 (Add os::unix::net::SocketAddr::from_path) - #93261 (Some unwinding related cg_ssa cleanups) - #93295 (Avoid double panics when using `TempDir` in tests) - #93353 (Unimpl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}<$t> for Saturating<$t>) - #93356 (Edit docs introduction for `std::cmp::PartialOrd`) - #93375 (fix typo `documenation`) - #93399 (rustbuild: Fix compiletest warning when building outside of root.) - #93404 (Fix a typo from #92899) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-01-28Add Explanation For Error E0772Daniel Conley-1/+90
2022-01-28remove unused `jemallocator` crateRémy Rakic-5/+1
2022-01-28Rollup merge of #93261 - bjorn3:cg_ssa_refactor6, r=cjgillotMatthias Krüger-75/+63
Some unwinding related cg_ssa cleanups These should make it a bit easier for alternative codegen backends to implement unwinding.
2022-01-28Rollup merge of #92611 - Amanieu:asm-reference, r=m-ou-seMatthias Krüger-0/+8
Add links to the reference and rust by example for asm! docs and lints These were previously removed in #91728 due to broken links. cc ``@ehuss`` since this updates the rust-by-example submodule
2022-01-28fix nitlcnr-1/+1
2022-01-28update cfg(bootstrap)sPietro Albini-18/+4
2022-01-28Auto merge of #93006 - michaelwoerister:fix-unsized-ptr-debuginfo, ↵bors-174/+238
r=davidtwco,oli-obk Fix debuginfo for pointers/references to unsized types This PR makes the compiler emit fat pointer debuginfo in all cases. Before, we sometimes got thin-pointer debuginfo, making it impossible to fully interpret the pointed to memory in debuggers. The code is actually cleaner now, especially around generation of trait object pointer debuginfo. Fixes https://github.com/rust-lang/rust/issues/92718 ~~Blocked on https://github.com/rust-lang/rust/pull/92729.~~
2022-01-28Auto merge of #90677 - bobrippling:suggest-tuple-parens, r=camelidbors-6/+68
Suggest tuple-parentheses for enum variants This follows on from #86493 / #86481, making the parentheses suggestion. To summarise, given the following code: ```rust fn f() -> Option<(i32, i8)> { Some(1, 2) } ``` The current output is: ``` error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied --> b.rs:2:5 | 2 | Some(1, 2) | ^^^^ - - supplied 2 arguments | | | expected 1 argument error: aborting due to previous error For more information about this error, try `rustc --explain E0061`. ``` With this change, `rustc` will now suggest parentheses when: - The callee is expecting a single tuple argument - The number of arguments passed matches the element count in the above tuple - The arguments' types match the tuple's fields ``` error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied --> b.rs:2:5 | 2 | Some(1, 2) | ^^^^ - - supplied 2 arguments | help: use parentheses to construct a tuple | 2 | Some((1, 2)) | + + ```
2022-01-28[debuginfo] Fix and unify handling of fat pointers in debuginfo: Don't mark ↵Michael Woerister-2/+2
fat pointer fields as artificial. LLDB does not seem to see fields if they are marked with DW_AT_artificial which breaks pretty printers that use these fields for decoding fat pointers.
2022-01-28Auto merge of #93343 - lqd:attrs, r=spastorinobors-18/+25
Only traverse attrs once while checking for coherence override attributes In coherence, while checking for negative impls override attributes: only traverse the `DefId`s' attributes once. This PR is an easy way to get back some of the small perf loss in #93175
2022-01-27Improve suggestion for escaping reserved keywordsNoah Lev-4/+4
2022-01-27Rollup merge of #93365 - nnethercote:more-arena-cleanups, r=oli-obkMatthias Krüger-21/+40
More arena cleanups A sequel to #90990. r? `@oli-obk`
2022-01-27Rollup merge of #93363 - lcnr:pass-by-value, r=petrochenkovMatthias Krüger-26/+35
`#[rustc_pass_by_value]` cleanup
2022-01-27Rollup merge of #93357 - nnethercote:clarify-usage-of-qualified-ty, r=lcnrMatthias Krüger-1/+1
Clarify the `usage-of-qualified-ty` error message. I found this message confusing when I encountered it. This commit makes it clearer that you have to import the unqualified type yourself. r? `@lcnr`
2022-01-27Rollup merge of #93325 - tmiasko:lev, r=davidtwcoMatthias Krüger-42/+60
Introduce a limit to Levenshtein distance computation Incorporate distance limit from `find_best_match_for_name` directly into Levenshtein distance computation. Use the string size difference as a lower bound on the distance and exit early when it exceeds the specified limit. After finding a candidate within a limit, lower the limit further to restrict the search space.
2022-01-27Rollup merge of #93193 - Kobzol:stable-hash-permutation-test, r=the8472Matthias Krüger-0/+42
Add test for stable hash uniqueness of adjacent field values This PR adds a simple test to check that stable hash will produce a different hash if the order of two values that have the same combined bit pattern changes. r? `@the8472`
2022-01-28Clarify `ArenaAllocatable`'s second parameter.Nicholas Nethercote-5/+10
It's simply a binary thing to allow different behaviour for `Copy` vs `!Copy` types. The new code makes this much clearer; I was scratching my head over the old code for some time.
2022-01-28Add some comments.Nicholas Nethercote-7/+21
2022-01-27[debuginfo] Fix and unify handling of fat pointers in debuginfo: Change doc ↵Michael Woerister-13/+13
comment so it is not interpreted as doc-test.
2022-01-27try apply `rustc_pass_by_value` to `Span`lcnr-23/+32
2022-01-27update pass_by_valuelcnr-3/+3
2022-01-26do not register infer var for GAT projection in opaqueMichael Goulet-7/+9