summary refs log tree commit diff
path: root/src
AgeCommit message (Collapse)AuthorLines
2022-05-17Drop needless match to clippy's nurseryMark Rousskov-3/+2
This lint has a false positive and there's not an easy backport available, particularly given how late in the cycle we are at this point.
2022-05-16Switch to stable channelMark Rousskov-1/+1
2022-05-14Add a test with both passing and erroneous cases.Camille GILLOT-0/+146
2022-05-14Forbid nested opaque types to reference HRTB from opaque types.Camille GILLOT-94/+75
2022-05-13Revert #92191 Prefer projection candidates instead of param_env candidates ↵Jack Huey-1/+56
for Sized predicates
2022-05-13Fix UI testMark Rousskov-1/+0
2022-05-13Move only_used_in_recursion to nurseryflip1995-3/+9
2022-05-13Prevent infinite (exponential) recursion in only_used_in_recursionflip1995-31/+16
This simplifies the visitor code a bit and prevents checking expressions multiple times. I still think this lint should be removed for now, because its code isn't really tested.
2022-05-13Taking review hints into account.ricked-twice-8/+7
2022-05-13Quick fix for #96223.ricked-twice-0/+81
2022-05-03Rollup merge of #96516 - oli-obk:impl_trait_inference_accidental_permitted, ↵Dylan DPC-384/+91
r=jackh726 Revert diagnostic duplication and accidental stabilization fixes #96460 this is an accidental stabilization that we should put into the beta. I believe it is low-risk, because it was literally what we had before #94081 The effect on tests is massive, but mostly deduplication of diagnostics and some minor span changes.
2022-05-03Auto merge of #96490 - dtolnay:writetmpbackport, r=Mark-Simulacrumbors-7/+7
Make [e]println macros eagerly drop temporaries (for backport) This PR extracts the subset of #96455 which is only the parts necessary for fixing the 1.61-beta regressions in #96434. My larger PR #96455 contains a few other changes relative to the pre-#94868 behavior; those are not necessary to backport into 1.61. argument position | before #94868 | after #94868 | after this PR --- |:---:|:---:|:---: `write!($tmp, "…", …)` | :rage: | :rage: | :rage: `write!(…, "…", $tmp)` | :rage: | :rage: | :rage: `writeln!($tmp, "…", …)` | :rage: | :rage: | :rage: `writeln!(…, "…", $tmp)` | :rage: | :rage: | :rage: `print!("…", $tmp)` | :rage: | :rage: | :rage: `println!("…", $tmp)` | :smiley_cat: | :rage: | :smiley_cat: `eprint!("…", $tmp)` | :rage: | :rage: | :rage: `eprintln!("…", $tmp)` | :smiley_cat: | :rage: | :smiley_cat: `panic!("…", $tmp)` | :smiley_cat: | :smiley_cat: | :smiley_cat:
2022-05-03[beta] Update cargoEric Huss-0/+0
2022-04-24Bless tests.Camille GILLOT-30/+30
2022-04-24Check that all hidden types are the same and then deduplicate them.Oli Scherer-0/+30
2022-04-08bump stage0 to 1.60.0Pietro Albini-340/+283
2022-04-05bump rlsPietro Albini-0/+0
2022-04-04bump channel to betaPietro Albini-1/+1
2022-04-04Auto merge of #95031 - compiler-errors:param-env-cache, r=Aaron1011bors-1/+2
Do not use `ParamEnv::and` when building a cache key from a param-env and trait eval candidate Do not use `ParamEnv::and` to cache a param-env with a selection/evaluation candidate. This is because if the param-env is `RevealAll` mode, and the candidate looks global (i.e. it has erased regions, which can show up when we normalize a projection type under a binder<sup>1</sup>), then when we use `ParamEnv::and` to pair the candidate and the param-env for use as a cache key, we will throw away the param-env's caller bounds, and we'll end up caching a candidate that we inferred from the param-env with a empty param-env, which may cause cache-hit later when we have an empty param-env, and possibly mess with normalization like we see in the referenced issue during codegen. Not sure how to trigger this with a more structured test, but changing `check-pass` to `build-pass` triggers the case that https://github.com/rust-lang/rust/issues/94903 detected. <sup>1.</sup> That is, we will replace the late-bound region with a placeholder, which gets canonicalized and turned into an infererence variable, which gets erased during region freshening right before we cache the result. Sorry, it's quite a few steps. Fixes #94903 r? `@Aaron1011` (or reassign as you see fit)
2022-04-03Rollup merge of #95613 - GuillaumeGomez:fix-rustdoc-attr-display, r=notriddleDylan DPC-1/+13
Fix rustdoc attribute display Fixes #81482. r? `@notriddle`
2022-04-03Rollup merge of #95553 - jam1garner:naked-function-compile-error, r=tmiaskoDylan DPC-1/+38
Don't emit non-asm contents error for naked function composed of errors ## Motivation For naked functions an error is emitted when they are composed of anything other than a single asm!() block. However, this error triggers in a couple situations in which it adds no additional information or is actively misleading. One example is if you do have an asm!() block but simply one with a syntax error: ```rust #[naked] unsafe extern "C" fn compiler_errors() { asm!(invalid_syntax) } ``` This results in two errors, one for the syntax error itself and another telling you that you need an asm block in your function: ```rust error[E0787]: naked functions must contain a single asm block --> src/main.rs:6:1 | 6 | / unsafe extern "C" fn naked_compile_error() { 7 | | asm!(blah) 8 | | } | |_^ ``` This issue also comes up when [utilizing `compile_error!()` for improving your diagnostics](https://twitter.com/steveklabnik/status/1509538243020218372), such as raising a compiler error when compiling for an unsupported target. ## Implementation The rules this PR implements are as follows: 1. If any non-erroneous non-asm statement is included, an error will still occur 2. If multiple asm statements are included, an error will still occur 3. If 0 or 1 asm statements are present, as well as any non-zero number of erroneous statements, then this error will *not* be raised as it is likely either redundant or incorrect The rule of thumb is effectively "if an error is present and its correction could change things, don't raise an error".
2022-04-03Add test for attribute display in rustdocGuillaume Gomez-0/+7
2022-04-03Fix display of attributes in rustdocGuillaume Gomez-1/+6
2022-04-03Auto merge of #88672 - camelid:inc-parser-sugg, r=davidtwcobors-0/+277
Suggest `i += 1` when we see `i++` or `++i` Closes #83502 (for `i++` and `++i`; `--i` should be covered by #82987, and `i--` is tricky to handle). This is a continuation of #83536. r? `@estebank`
2022-04-02Auto merge of #95590 - GuillaumeGomez:multi-line-attr-handling-doctest, ↵bors-8/+80
r=notriddle Fix multiline attributes handling in doctests Fixes #55713. I needed to have access to the `unclosed_delims` field in order to check that the attribute was completely parsed and didn't have missing parts, so I created a getter for it. r? `@notriddle`
2022-04-02Auto merge of #95600 - Dylan-DPC:rollup-580y2ra, r=Dylan-DPCbors-0/+46
Rollup of 4 pull requests Successful merges: - #95587 (Remove need for associated_type_bounds in std.) - #95589 (Include a header in .rlink files) - #95593 (diagnostics: add test case for bogus T:Sized suggestion) - #95597 (Refer to u8 by absolute path in expansion of thread_local) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-02Rollup merge of #95597 - dtolnay:threadlocalu8, r=Dylan-DPCDylan DPC-0/+15
Refer to u8 by absolute path in expansion of thread_local The standard library's `thread_local!` macro previously referred to `u8` just as `u8`, resolving to whatever `u8` existed in the type namespace at the call site. This PR replaces those with `$crate::primitive::u8` which always refers to `std::primitive::u8` regardless of what's in scope at the call site. Unambiguously naming primitives inside macro-generated code is the reason that std::primitive was introduced in the first place. <details> <summary>Here is the error message prior to this PR ⬇️</summary> ```console error[E0308]: mismatched types --> src/main.rs:6:1 | 6 | / std::thread_local! { 7 | | pub static A: i32 = f(); 8 | | pub static B: i32 = const { 0 }; 9 | | } | |_^ expected struct `u8`, found integer | = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> src/main.rs:6:1 | 6 | / std::thread_local! { 7 | | pub static A: i32 = f(); 8 | | pub static B: i32 = const { 0 }; 9 | | } | | ^ | | | | |_expected struct `u8`, found integer | this expression has type `u8` | = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> src/main.rs:6:1 | 6 | / std::thread_local! { 7 | | pub static A: i32 = f(); 8 | | pub static B: i32 = const { 0 }; 9 | | } | |_^ expected `u8`, found struct `u8` | = note: expected raw pointer `*mut u8` (`u8`) found raw pointer `*mut u8` (struct `u8`) = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> src/main.rs:6:1 | 6 | / std::thread_local! { 7 | | pub static A: i32 = f(); 8 | | pub static B: i32 = const { 0 }; 9 | | } | |_^ expected `u8`, found struct `u8` | = note: expected fn pointer `unsafe extern "C" fn(*mut u8)` found fn item `unsafe extern "C" fn(*mut u8) {destroy}` = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> src/main.rs:6:1 | 6 | / std::thread_local! { 7 | | pub static A: i32 = f(); 8 | | pub static B: i32 = const { 0 }; 9 | | } | | ^ | | | | |_expected struct `u8`, found integer | expected due to this type | = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0369]: binary operation `==` cannot be applied to type `u8` --> src/main.rs:6:1 | 6 | / std::thread_local! { 7 | | pub static A: i32 = f(); 8 | | pub static B: i32 = const { 0 }; 9 | | } | | ^ | | | | |_u8 | {integer} | note: an implementation of `PartialEq<_>` might be missing for `u8` --> src/main.rs:4:1 | 4 | struct u8; | ^^^^^^^^^^ must implement `PartialEq<_>` = note: this error originates in the macro `$crate::assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `u8` with `#[derive(PartialEq)]` | 4 | #[derive(PartialEq)] | error[E0277]: `u8` doesn't implement `Debug` --> src/main.rs:6:1 | 6 | / std::thread_local! { 7 | | pub static A: i32 = f(); 8 | | pub static B: i32 = const { 0 }; 9 | | } | |_^ `u8` cannot be formatted using `{:?}` | = help: the trait `Debug` is not implemented for `u8` = note: add `#[derive(Debug)]` to `u8` or manually `impl Debug for u8` = note: this error originates in the macro `$crate::assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) ``` </details>
2022-04-02Rollup merge of #95593 - notriddle:notriddle/size-of-in-const-context, ↵Dylan DPC-0/+24
r=compiler-errors diagnostics: add test case for bogus T:Sized suggestion Closes #69228
2022-04-02Rollup merge of #95589 - Kobzol:rlink-header, r=bjorn3Dylan DPC-0/+7
Include a header in .rlink files I couldn't find the right place where to put tests. Is there some location that tests `.rlink` creation and loading? I only found `src/test/run-make-fulldeps/separate-link/Makefile`, but I'm not sure how to check the error message in the Makefile. Fixes: https://github.com/rust-lang/rust/issues/95297 r? `@bjorn3`
2022-04-02Add test for multi-line attribute handling in doctestsGuillaume Gomez-0/+18
2022-04-02Fix doctest multi-line mod attributes handlingGuillaume Gomez-8/+62
2022-04-02Add test of thread_local! breaking on redefined u8David Tolnay-0/+15
2022-04-02Auto merge of #94911 - jackh726:gats_extended_2, r=compiler-errorsbors-30/+162
Make GATs object safe under generic_associated_types_extended feature Based on #94869 Let's say we have ```rust trait StreamingIterator { type Item<'a> where Self: 'a; } ``` And `dyn for<'a> StreamingIterator<Item<'a> = &'a i32>`. If we ask `(dyn for<'a> StreamingIterator<Item<'a> = &'a i32>): StreamingIterator`, then we have to prove that `for<'x> (&'x i32): Sized`. So, we generate *new* bound vars to subst for the GAT generics. Importantly, this doesn't fully verify that these are usable and sound. r? `@nikomatsakis`
2022-04-02Make GATs object safe under generic_associated_types_extended featureJack Huey-30/+162
2022-04-02diagnostics: add test case for bogus T:Sized suggestionMichael Howell-0/+24
Closes #69228
2022-04-02Auto merge of #95568 - GuillaumeGomez:fix-invalid-dom-generation, r=notriddlebors-2/+2
Fix invalid DOM generation Fixes #64371. r? `@notriddle`
2022-04-02Address review comments and add a testJakub Beránek-0/+7
2022-04-02Auto merge of #95571 - petrochenkov:nowrapident2, r=Aaron1011bors-18/+6
ast_lowering: Stop wrapping `ident` matchers into groups The lowered forms goes to metadata, for example during encoding of macro definitions. This is a missing part of https://github.com/rust-lang/rust/pull/92472. Fixes https://github.com/rust-lang/rust/issues/95569 r? `@Aaron1011`
2022-04-02Auto merge of #95581 - Dylan-DPC:rollup-2suh5h1, r=Dylan-DPCbors-16/+90
Rollup of 8 pull requests Successful merges: - #95354 (Handle rustc_const_stable attribute in library feature collector) - #95373 (invalid_value lint: detect invalid initialization of arrays) - #95430 (Disable #[thread_local] support on i686-pc-windows-msvc) - #95544 (Add error message suggestion for missing noreturn in naked function) - #95556 (Implement provenance preserving methods on NonNull) - #95557 (Fix `thread_local!` macro to be compatible with `no_implicit_prelude`) - #95559 (small type system refactoring) - #95560 (convert more `DefId`s to `LocalDefId`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-02Rollup merge of #95557 - niluxv:issue-95533, r=dtolnayDylan DPC-0/+8
Fix `thread_local!` macro to be compatible with `no_implicit_prelude` Fixes issue #95533.
2022-04-02Rollup merge of #95544 - jam1garner:improve-naked-noreturn-diagnostic, r=tmiaskoDylan DPC-0/+25
Add error message suggestion for missing noreturn in naked function I had to google the syntax for inline asm's `noreturn` option when I got this error earlier today, so I figured I'd save others the trouble and add the syntax/fix as a suggestion in the error.
2022-04-02Rollup merge of #95373 - RalfJung:invalid_value, r=davidtwcoDylan DPC-11/+52
invalid_value lint: detect invalid initialization of arrays
2022-04-02Rollup merge of #95354 - dtolnay:rustc_const_stable, r=lcnrDylan DPC-5/+5
Handle rustc_const_stable attribute in library feature collector The library feature collector in [compiler/rustc_passes/src/lib_features.rs](https://github.com/rust-lang/rust/blob/551b4fa395fa588d91cbecfb0cdfe1baa02670cf/compiler/rustc_passes/src/lib_features.rs) has only been looking at `#[stable(…)]`, `#[unstable(…)]`, and `#[rustc_const_unstable(…)]` attributes, while ignoring `#[rustc_const_stable(…)]`. The consequences of this were: - When any const feature got stabilized (changing one or more `rustc_const_unstable` to `rustc_const_stable`), users who had previously enabled that unstable feature using `#![feature(…)]` would get told "unknown feature", rather than rustc's nicer "the feature … has been stable since … and no longer requires an attribute to enable". This can be seen in the way that https://github.com/rust-lang/rust/pull/93957#issuecomment-1079794660 failed after rebase: ```console error[E0635]: unknown feature `const_ptr_offset` --> $DIR/offset_from_ub.rs:1:35 | LL | #![feature(const_ptr_offset_from, const_ptr_offset)] | ^^^^^^^^^^^^^^^^ ``` - We weren't enforcing that a particular feature is either stable everywhere or unstable everywhere, and that a feature that has been stabilized has the same stabilization version everywhere, both of which we enforce for the other stability attributes. This PR updates the library feature collector to handle `rustc_const_stable`, and fixes places in the standard library and test suite where `rustc_const_stable` was being used in a way that does not meet the rules for a stability attribute.
2022-04-01update MiriRalf Jung-8/+21
2022-04-02ast_lowering: Stop wrapping `ident` matchers into groupsVadim Petrochenkov-18/+6
The lowered forms goes to metadata, for example during encoding of macro definitions
2022-04-01Fix invalid DOM generationGuillaume Gomez-2/+2
2022-04-01Auto merge of #95552 - matthiaskrgr:rollup-bxminn9, r=matthiaskrgrbors-67/+305
Rollup of 6 pull requests Successful merges: - #95032 (Clean up, categorize and sort unstable features in std.) - #95260 (Better suggestions for `Fn`-family trait selection errors) - #95293 (suggest wrapping single-expr blocks in square brackets) - #95344 (Make `impl Debug for rustdoc::clean::Item` easier to read) - #95388 (interpret: make isize::MAX the limit for dynamic value sizes) - #95530 (rustdoc: do not show primitives and keywords as private) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-01Add regression test for naked functions with invalid asm syntaxjam1garner-1/+13
2022-04-01Reword purpose description of noreturn in naked functionjam1garner-5/+5
2022-04-01Don't emit non-asm contents error for naked function composed of errorsjam1garner-1/+26