| Age | Commit message (Collapse) | Author | Lines |
|
(Re-)Implement `impl_trait_in_bindings`
This reimplements the `impl_trait_in_bindings` feature for local bindings.
"`impl Trait` in bindings" serve as a form of *trait* ascription, where the type basically functions as an infer var but additionally registering the `impl Trait`'s trait bounds for the infer type. These trait bounds can be used to enforce that predicates hold, and can guide inference (e.g. for closure signature inference):
```rust
let _: impl Fn(&u8) -> &u8 = |x| x;
```
They are implemented as an additional set of bounds that are registered when the type is lowered during typeck, and then these bounds are tied to a given `CanonicalUserTypeAscription` for borrowck. We enforce these `CanonicalUserTypeAscription` bounds during borrowck to make sure that the `impl Trait` types are sensitive to lifetimes:
```rust
trait Static: 'static {}
impl<T> Static for T where T: 'static {}
let local = 1;
let x: impl Static = &local;
//~^ ERROR `local` does not live long enough
```
r? oli-obk
cc #63065
---
Why can't we just use TAIT inference or something? Well, TAITs in bodies have the problem that they cannot reference lifetimes local to a body. For example:
```rust
type TAIT = impl Display;
let local = 0;
let x: TAIT = &local;
//~^ ERROR `local` does not live long enough
```
That's because TAITs requires us to do *opaque type inference* which is pretty strict, since we need to remap all of the lifetimes of the hidden type to universal regions. This is simply not possible here.
---
I consider this part of the "impl trait everywhere" experiment. I'm not certain if this needs yet another lang team experiment.
|
|
Rollup of 8 pull requests
Successful merges:
- #134252 (Fix `Path::is_absolute` on Hermit)
- #134254 (Fix building `std` for Hermit after `c_char` change)
- #134255 (Update includes in `/library/core/src/error.rs`.)
- #134261 (Document the symbol Visibility enum)
- #134262 (Arbitrary self types v2: adjust diagnostic.)
- #134265 (Rename `ty_def_id` so people will stop using it by accident)
- #134271 (Arbitrary self types v2: better feature gate test)
- #134274 (Add check-pass test for `&raw`)
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
|
|
Rename `ty_def_id` so people will stop using it by accident
This function is just for cycle detection, but people keep using it because they think it's the right way of getting the def id from a `Ty` (and I can't blame them necessarily).
|
|
A bunch of cleanups (part 2)
Just like https://github.com/rust-lang/rust/pull/133567 these were all found while looking at the respective code, but are not blocking any other changes I want to make in the short term.
|
|
Tweak multispan rendering to reduce output length
Consider comments and bare delimiters the same as an "empty line" for purposes of hiding rendered code output of long multispans. This results in more aggressive shortening of rendered output without losing too much context, specially in `*.stderr` tests that have "hidden" comments. We do that check not only on the first 4 lines of the multispan, but now also on the previous to last line as well.
|
|
Rollup of 7 pull requests
Successful merges:
- #133900 (Advent of `tests/ui` (misc cleanups and improvements) [1/N])
- #133937 (Keep track of parse errors in `mod`s and don't emit resolve errors for paths involving them)
- #133938 (`rustc_mir_dataflow` cleanups, including some renamings)
- #134058 (interpret: reduce usage of TypingEnv::fully_monomorphized)
- #134130 (Stop using driver queries in the public API)
- #134140 (Add AST support for unsafe binders)
- #134229 (Fix typos in docs on provenance)
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
Don't consider `///` and `//!` docstrings to be empty for the purposes of multiline span rendering.
|
|
|
|
|
|
Add AST support for unsafe binders
I'm splitting up #130514 into pieces. It's impossible for me to keep up with a huge PR like that. I'll land type system support for this next, probably w/o MIR lowering, which will come later.
r? `@oli-obk`
cc `@BoxyUwU` and `@lcnr` who also may want to look at this, though this PR doesn't do too much yet
|
|
estebank:silence-resolve-errors-from-mod-with-parse-errors, r=davidtwco
Keep track of parse errors in `mod`s and don't emit resolve errors for paths involving them
When we expand a `mod foo;` and parse `foo.rs`, we now track whether that file had an unrecovered parse error that reached the end of the file. If so, we keep that information around in the HIR and mark its `DefId` in the `Resolver`. When resolving a path like `foo::bar`, we do not emit any errors for "`bar` not found in `foo`", as we know that the parse error might have caused `bar` to not be parsed and accounted for.
When this happens in an existing project, every path referencing `foo` would be an irrelevant compile error. Instead, we now skip emitting anything until `foo.rs` is fixed. Tellingly enough, we didn't have any test for errors caused by expansion of `mod`s with parse errors.
Fix https://github.com/rust-lang/rust/issues/97734.
|
|
Move impl constness into impl trait header
This PR is kind of the opposite of the rejected https://github.com/rust-lang/rust/pull/134114
Instead of moving more things into the `constness` query, we want to keep them where their corresponding hir nodes are lowered. So I gave this a spin for impls, which have an obvious place to be (the impl trait header). And surprisingly it's also a perf improvement (likely just slightly better query & cache usage).
The issue was that removing anything from the `constness` query makes it just return `NotConst`, which is wrong. So I had to change it to `bug!` out if used wrongly, and only then remove the impl blocks from the `constness` query. I think this change is good in general, because it makes using `constness` more robust (as can be seen by how few sites that had to be changed, so it was almost solely used specifically for the purpose of asking for functions' constness). The main thing where this change was not great was in clippy, which was using the `constness` query as a general DefId -> constness map. I added a `DefKind` filter in front of that. If it becomes a more common pattern we can always move that helper into rustc.
|
|
It is treated as a map already. This is using FxIndexMap rather than
UnordMap because the latter doesn't provide an api to pick a single
value iff all values are equal, which each_linked_rlib depends on.
|
|
|
|
span rendering
|
|
Consider comments and bare delimiters the same as an "empty line" for purposes of hiding rendered code output of long multispans. This results in more aggressive shortening of rendered output without losing too much context, specially in `*.stderr` tests that have "hidden" comments.
|
|
|
|
This reverts commit b282774aaf0aa05b4a9855d973b67e7e424c2136, reversing
changes made to e0f3db0056288a06b1ae36cdd70741a4e0b3584a.
|
|
Rollup of 6 pull requests
Successful merges:
- #132975 (De-duplicate and improve definition of core::ffi::c_char)
- #133598 (Change `GetManyMutError` to match T-libs-api decision)
- #134148 (add comments in check_expr_field)
- #134163 (coverage: Rearrange the code for embedding per-function coverage metadata)
- #134165 (wasm(32|64): update alignment string)
- #134170 (Subtree update of `rust-analyzer`)
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
constness
|
|
fix: Swallow rustfmt parsing panics
|
|
|
|
|
|
|
|
|
|
Remove more traces of anonymous ADTs
Anonymous ADTs were removed in #131045, but I forgot to remove this.
|
|
feat: Add diagnostic fix to remove unnecessary wrapper in type mismatch
|
|
Hash completion items to properly match them during /resolve
|
|
minor: Migrate `generate_enum_variant` to `SyntaxEditor`
|
|
feat: preserve order of parameters in extract_functions
|
|
|
|
run-make: Fix `assert_stderr_not_contains_regex`
It asserted on **stdout**, not stderr.
r? ``@jieyouxu``
|
|
|
|
involving them
When we expand a `mod foo;` and parse `foo.rs`, we now track whether that file had an unrecovered parse error that reached the end of the file. If so, we keep that information around. When resolving a path like `foo::bar`, we do not emit any errors for "`bar` not found in `foo`", as we know that the parse error might have caused `bar` to not be parsed and accounted for.
When this happens in an existing project, every path referencing `foo` would be an irrelevant compile error. Instead, we now skip emitting anything until `foo.rs` is fixed. Tellingly enough, we didn't have any test for errors caused by `mod` expansion.
Fix #97734.
|
|
|
|
|
|
|
|
I recursively added all constructors it depends on. I also changed the old `make::` constructors to support more of the grammar.
|
|
Rollup of 11 pull requests
Successful merges:
- #133478 (jsondocck: Parse, don't validate commands.)
- #133967 ([AIX] Pass -bnoipath when adding rust upstream dynamic crates)
- #133970 ([AIX] Replace sa_sigaction with sa_union.__su_sigaction for AIX)
- #133980 ([AIX] Remove option "-n" from AIX "ln" command)
- #134008 (Make `Copy` unsafe to implement for ADTs with `unsafe` fields)
- #134017 (Don't use `AsyncFnOnce::CallOnceFuture` bounds for signature deduction)
- #134023 (handle cygwin environment in `install::sanitize_sh`)
- #134041 (Use SourceMap to load debugger visualizer files)
- #134065 (Move `write_graphviz_results`)
- #134106 (Add compiler-maintainers who requested to be on review rotation)
- #134123 (bootstrap: Forward cargo JSON output to stdout, not stderr)
Failed merges:
- #134120 (Remove Felix from ping groups and review rotation)
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
Make `Copy` unsafe to implement for ADTs with `unsafe` fields
As a rule, the application of `unsafe` to a declaration requires that use-sites of that declaration also entail `unsafe`. For example, a field declared `unsafe` may only be read in the lexical context of an `unsafe` block.
For nearly all safe traits, the safety obligations of fields are explicitly discharged when they are mentioned in method definitions. For example, idiomatically implementing `Clone` (a safe trait) for a type with unsafe fields will require `unsafe` to clone those fields.
Prior to this commit, `Copy` violated this rule. The trait is marked safe, and although it has no explicit methods, its implementation permits reads of `Self`.
This commit resolves this by making `Copy` conditionally safe to implement. It remains safe to implement for ADTs without unsafe fields, but unsafe to implement for ADTs with unsafe fields.
Tracking: #132922
r? ```@compiler-errors```
|
|
jsondocck: Parse, don't validate commands.
Centralizes knowledge of jsondocck syntax into the parser, so the checker doesn't need to know what the indexes are.
[Vaguely related zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/jsondocck.20rewrite)
I'm very happy this is negative LoC, despite adding a big, documented enum!
r? ``@fmease``
|
|
* Use Base64 to minify the hash representation in the JSON data
* Do hash checks only for items with similar labels
|
|
* Exclude documentation field from hashing
* Do less cloning during initial completion list generation
|
|
It asserted on **stdout**, not stderr.
|
|
r=Noratrieb
Miscellaneous fixes for nix-dev-shell
this makes it so files in `src/nix-dev-shell` are *not* ignored, as they
should not be. note that `flake.lock` is still ignored globally.
r? `@Noratrieb`
See individual commits for more info.
cc #131176 (it added gitignore entries I'm changing).
|
|
fix ICE on type error in promoted
Fixes https://github.com/rust-lang/rust/issues/133968
Ensure that when we turn a type error into a "this promoted failed to evaluate" error, we do record this as something that may happen even in "infallible" promoteds.
|
|
Add licenses + Run `cargo update`
Replaces #131311
try-job: dist-x86_64-linux
License changes:
- `unicode_ident` 1.0.14 introduces `(MIT OR Apache-2.0) AND Unicode-3.0`, but `unicode_ident` 1.0.12 (`(MIT OR Apache-2.0) AND Unicode-DFS-2016`) is still in tree
- `instant` and its license exception are no longer used
```
compiler & tools dependencies:
Updating allocator-api2 v0.2.18 -> v0.2.20
Updating anyhow v1.0.92 -> v1.0.93
Removing bitflags v1.3.2
Updating blake3 v1.5.4 -> v1.5.5
Updating bstr v1.10.0 -> v1.11.0
Updating bytes v1.8.0 -> v1.9.0
Updating cargo-platform v0.1.8 -> v0.1.9
Updating cc v1.2.0 -> v1.2.2
Updating clap v4.5.20 -> v4.5.21
Updating clap_builder v4.5.20 -> v4.5.21
Updating clap_complete v4.5.36 -> v4.5.38
Updating clap_lex v0.7.2 -> v0.7.3
Updating color-print v0.3.6 -> v0.3.7
Updating color-print-proc-macro v0.3.6 -> v0.3.7
Updating cpufeatures v0.2.14 -> v0.2.16
Updating curl-sys v0.4.77+curl-8.10.1 -> v0.4.78+curl-8.11.0
Updating errno v0.3.9 -> v0.3.10
Updating fastrand v2.1.1 -> v2.2.0
Updating flate2 v1.0.34 -> v1.0.35
Updating handlebars v5.1.2 -> v6.2.0
Adding icu_collections v1.5.0
Adding icu_normalizer v1.5.0
Adding icu_normalizer_data v1.5.0
Adding icu_properties v1.5.1
Adding icu_properties_data v1.5.0
Updating idna v0.5.0 -> v1.0.3
Adding idna_adapter v1.2.0
Updating indexmap v2.6.0 -> v2.7.0
Updating indicatif v0.17.8 -> v0.17.9
Removing instant v0.1.13
Updating itoa v1.0.11 -> v1.0.14
Updating js-sys v0.3.72 -> v0.3.74
Updating libc v0.2.164 -> v0.2.167
Updating libloading v0.8.5 -> v0.8.6
Updating litemap v0.7.3 -> v0.7.4
Updating mdbook v0.4.40 -> v0.4.43
Adding num-modular v0.6.1
Adding num-order v1.2.0
Updating pathdiff v0.2.2 -> v0.2.3
Updating portable-atomic v1.9.0 -> v1.10.0
Updating proc-macro2 v1.0.89 -> v1.0.92
Updating regex-automata v0.4.8 -> v0.4.9
Updating rustc-hash v2.0.0 -> v2.1.0
Updating rustc_apfloat v0.2.1+llvm-462a31f5a5ab -> v0.2.2+llvm-462a31f5a5ab
Updating rustix v0.38.38 -> v0.38.41
Updating schannel v0.1.26 -> v0.1.27
Updating serde v1.0.214 -> v1.0.215
Updating serde_derive v1.0.214 -> v1.0.215
Updating serde_json v1.0.132 -> v1.0.133
Updating socket2 v0.5.7 -> v0.5.8
Updating spdx v0.10.6 -> v0.10.7
Updating syn v2.0.87 -> v2.0.90
Updating tempfile v3.13.0 -> v3.14.0
Updating terminal_size v0.4.0 -> v0.4.1
Updating thiserror v1.0.66 -> v1.0.69 (available: v2.0.3)
Updating thiserror-impl v1.0.66 -> v1.0.69
Updating tokio v1.41.0 -> v1.41.1
Updating tracing-attributes v0.1.27 -> v0.1.28
Updating tracing-error v0.2.0 -> v0.2.1
Removing unicode-bidi v0.3.17
Updating unicode-ident v1.0.13 -> v1.0.14
Updating url v2.5.2 -> v2.5.4
Adding utf16_iter v1.0.5
Adding utf8_iter v1.0.4
Updating wasm-bindgen v0.2.95 -> v0.2.97
Updating wasm-bindgen-backend v0.2.95 -> v0.2.97
Updating wasm-bindgen-macro v0.2.95 -> v0.2.97
Updating wasm-bindgen-macro-support v0.2.95 -> v0.2.97
Updating wasm-bindgen-shared v0.2.95 -> v0.2.97
Updating wasm-encoder v0.220.0 -> v0.221.0
Adding wasmparser v0.221.0
Updating wast v219.0.1 -> v221.0.0
Updating wat v1.219.1 -> v1.221.0
Adding web-time v1.1.0
Adding write16 v1.0.0
Updating yoke v0.7.4 -> v0.7.5
Updating yoke-derive v0.7.4 -> v0.7.5
Updating zerofrom v0.1.4 -> v0.1.5
Updating zerofrom-derive v0.1.4 -> v0.1.5
library dependencies:
Updating allocator-api2 v0.2.18 -> v0.2.20
Updating cc v1.2.0 -> v1.2.2
Updating libc v0.2.162 -> v0.2.164
Updating unwinding v0.2.3 -> v0.2.4
rustbook dependencies:
Updating anstream v0.6.17 -> v0.6.18
Updating anyhow v1.0.92 -> v1.0.93
Updating bstr v1.10.0 -> v1.11.0
Updating cc v1.2.0 -> v1.2.2
Updating clap v4.5.20 -> v4.5.21
Updating clap_builder v4.5.20 -> v4.5.21
Updating clap_complete v4.5.36 -> v4.5.38
Updating clap_lex v0.7.2 -> v0.7.3
Updating cpufeatures v0.2.14 -> v0.2.16
Adding displaydoc v0.2.5
Updating errno v0.3.9 -> v0.3.10
Updating fastrand v2.1.1 -> v2.2.0
Updating flate2 v1.0.34 -> v1.0.35
Updating hashbrown v0.15.0 -> v0.15.2
Adding icu_collections v1.5.0
Adding icu_locid v1.5.0
Adding icu_locid_transform v1.5.0
Adding icu_locid_transform_data v1.5.0
Adding icu_normalizer v1.5.0
Adding icu_normalizer_data v1.5.0
Adding icu_properties v1.5.1
Adding icu_properties_data v1.5.0
Adding icu_provider v1.5.0
Adding icu_provider_macros v1.5.0
Updating idna v0.5.0 -> v1.0.3
Adding idna_adapter v1.2.0
Updating indexmap v2.6.0 -> v2.7.0
Updating itoa v1.0.11 -> v1.0.14
Updating js-sys v0.3.72 -> v0.3.74
Updating libc v0.2.161 -> v0.2.167
Adding litemap v0.7.4
Updating mdbook v0.4.42 -> v0.4.43
Updating pathdiff v0.2.2 -> v0.2.3
Updating proc-macro2 v1.0.89 -> v1.0.92
Updating regex-automata v0.4.8 -> v0.4.9
Updating rustix v0.38.38 -> v0.38.41
Updating serde v1.0.214 -> v1.0.215
Updating serde_derive v1.0.214 -> v1.0.215
Updating serde_json v1.0.132 -> v1.0.133
Adding stable_deref_trait v1.2.0
Updating syn v2.0.87 -> v2.0.90
Adding synstructure v0.13.1
Updating tempfile v3.13.0 -> v3.14.0
Updating terminal_size v0.4.0 -> v0.4.1
Updating thiserror v1.0.66 -> v1.0.69
Updating thiserror-impl v1.0.66 -> v1.0.69
Adding tinystr v0.7.6
Removing tinyvec v1.8.0
Removing tinyvec_macros v0.1.1
Removing unicode-bidi v0.3.17
Updating unicode-ident v1.0.13 -> v1.0.14
Removing unicode-normalization v0.1.24
Updating url v2.5.2 -> v2.5.4
Adding utf16_iter v1.0.5
Adding utf8_iter v1.0.4
Updating wasm-bindgen v0.2.95 -> v0.2.97
Updating wasm-bindgen-backend v0.2.95 -> v0.2.97
Updating wasm-bindgen-macro v0.2.95 -> v0.2.97
Updating wasm-bindgen-macro-support v0.2.95 -> v0.2.97
Updating wasm-bindgen-shared v0.2.95 -> v0.2.97
Adding write16 v1.0.0
Adding writeable v0.5.5
Adding yoke v0.7.5
Adding yoke-derive v0.7.5
Adding zerofrom v0.1.5
Adding zerofrom-derive v0.1.5
Adding zerovec v0.10.4
Adding zerovec-derive v0.10.3
```
|
|
minor: enhance name suggestion for `Arc<T>` and `Rc<T>`
|
|
Rollup of 9 pull requests
Successful merges:
- #133996 (Move most tests for `-l` and `#[link(..)]` into `tests/ui/link-native-libs`)
- #134012 (Grammar fixes)
- #134032 (docs: better examples for `std::ops::ControlFlow`)
- #134040 (bootstrap: print{ln}! -> eprint{ln}! (take 2))
- #134043 (Add test to check unicode identifier version)
- #134053 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 10))
- #134055 (interpret: clean up deduplicating allocation functions)
- #134073 (dataflow_const_prop: do not eval a ptr address in SwitchInt)
- #134084 (Fix typo in RFC mention 3598 -> 3593)
r? `@ghost`
`@rustbot` modify labels: rollup
|