about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2023-12-04Update doctestEric Holk-2/+2
2023-12-04Update doctestEric Holk-2/+2
2023-12-05Consider only `#[no_mangle]` as builtin functionsDianQK-2/+3
2023-12-04Remove bad mergeEric Holk-199/+0
2023-12-04Remove bad mergeEric Holk-199/+0
2023-12-04Address code review feedbackEric Holk-36/+53
2023-12-04Auto merge of #118618 - GuillaumeGomez:rollup-24ur21r, r=GuillaumeGomezbors-56/+116
Rollup of 4 pull requests Successful merges: - #118508 (rustdoc: do not escape quotes in body text) - #118565 (interpret: make numeric_intrinsic accessible from Miri) - #118591 (portable-simd: fix test suite build) - #118600 ([rustdoc] Don't generate the "Fields" heading if there is no field displayed) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-04Structured `use` suggestion on privacy errorEsteban Küber-6/+140
When encoutering a privacy error on an item through a re-export that is accessible in an alternative path, provide a structured suggestion with that path. ``` error[E0603]: module import `mem` is private --> $DIR/private-std-reexport-suggest-public.rs:4:14 | LL | use foo::mem; | ^^^ private module import | note: the module import `mem` is defined here... --> $DIR/private-std-reexport-suggest-public.rs:8:9 | LL | use std::mem; | ^^^^^^^^ note: ...and refers to the module `mem` which is defined here --> $SRC_DIR/std/src/lib.rs:LL:COL | = note: you could import this help: import `mem` through the re-export | LL | use std::mem; | ~~~~~~~~ ``` Fix #42909.
2023-12-04Fix rebaseEsteban Küber-3/+3
2023-12-04Provide more suggestions for cloning immutable bindingsEsteban Küber-10/+196
When encountering multiple mutable borrows, suggest cloning and adding derive annotations as needed. ``` error[E0596]: cannot borrow `sm.x` as mutable, as it is behind a `&` reference --> $DIR/accidentally-cloning-ref-borrow-error.rs:32:9 | LL | foo(&mut sm.x); | ^^^^^^^^^ `sm` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: `Str` doesn't implement `Clone`, so this call clones the reference `&Str` --> $DIR/accidentally-cloning-ref-borrow-error.rs:31:21 | LL | let mut sm = sr.clone(); | ^^^^^^^ help: consider annotating `Str` with `#[derive(Clone)]` | LL + #[derive(Clone)] LL | struct Str { | help: consider specifying this binding's type | LL | let mut sm: &mut Str = sr.clone(); | ++++++++++ ``` ``` error[E0596]: cannot borrow `*inner` as mutable, as it is behind a `&` reference --> $DIR/issue-91206.rs:14:5 | LL | inner.clear(); | ^^^^^ `inner` is a `&` reference, so the data it refers to cannot be borrowed as mutable | help: you can `clone` the `Vec<usize>` value and consume it, but this might not be your desired behavior --> $DIR/issue-91206.rs:11:17 | LL | let inner = client.get_inner_ref(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider specifying this binding's type | LL | let inner: &mut Vec<usize> = client.get_inner_ref(); | +++++++++++++++++ ```
2023-12-04Deduplicate some logicEsteban Küber-181/+161
2023-12-04On "this .clone() is on the reference", provide more infoEsteban Küber-1/+158
When encountering a case where `let x: T = (val: &T).clone();` and `T: !Clone`, already mention that the reference is being cloned. We now also suggest `#[derive(Clone)]` not only on `T` but also on type parameters to satisfy blanket implementations. ``` error[E0308]: mismatched types --> $DIR/assignment-of-clone-call-on-ref-due-to-missing-bound.rs:17:39 | LL | let mut x: HashSet<Day> = v.clone(); | ------------ ^^^^^^^^^ expected `HashSet<Day>`, found `&HashSet<Day>` | | | expected due to this | = note: expected struct `HashSet<Day>` found reference `&HashSet<Day>` note: `HashSet<Day>` does not implement `Clone`, so `&HashSet<Day>` was cloned instead --> $DIR/assignment-of-clone-call-on-ref-due-to-missing-bound.rs:17:39 | LL | let mut x: HashSet<Day> = v.clone(); | ^ = help: `Clone` is not implemented because the trait bound `Day: Clone` is not satisfied help: consider annotating `Day` with `#[derive(Clone)]` | LL + #[derive(Clone)] LL | enum Day { | ``` Case taken from # #41825.
2023-12-04Mark more tests as `run-rustfix`Esteban Küber-3/+50
2023-12-04Tweak output on specific caseEsteban Küber-2/+22
2023-12-04Suggest cloning and point out obligation errors on move errorEsteban Küber-65/+310
When encountering a move error, look for implementations of `Clone` for the moved type. If there is one, check if all its obligations are met. If they are, we suggest cloning without caveats. If they aren't, we suggest cloning while mentioning the unmet obligations, potentially suggesting `#[derive(Clone)]` when appropriate. ``` error[E0507]: cannot move out of a shared reference --> $DIR/suggest-clone-when-some-obligation-is-unmet.rs:20:28 | LL | let mut copy: Vec<U> = map.clone().into_values().collect(); | ^^^^^^^^^^^ ------------- value moved due to this method call | | | move occurs because value has type `HashMap<T, U, Hash128_1>`, which does not implement the `Copy` trait | note: `HashMap::<K, V, S>::into_values` takes ownership of the receiver `self`, which moves value --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL help: you could `clone` the value and consume it, if the `Hash128_1: Clone` trait bound could be satisfied | LL | let mut copy: Vec<U> = <HashMap<T, U, Hash128_1> as Clone>::clone(&map.clone()).into_values().collect(); | ++++++++++++++++++++++++++++++++++++++++++++ + help: consider annotating `Hash128_1` with `#[derive(Clone)]` | LL + #[derive(Clone)] LL | pub struct Hash128_1; | ``` Fix #109429.
2023-12-04Tweak `.clone()` suggestion to work in more casesEsteban Küber-18/+86
When going through auto-deref, the `<T as Clone>` impl sometimes needs to be specified for rustc to actually clone the value and not the reference. ``` error[E0507]: cannot move out of dereference of `S` --> $DIR/needs-clone-through-deref.rs:15:18 | LL | for _ in self.clone().into_iter() {} | ^^^^^^^^^^^^ ----------- value moved due to this method call | | | move occurs because value has type `Vec<usize>`, which does not implement the `Copy` trait | note: `into_iter` takes ownership of the receiver `self`, which moves value --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL help: you can `clone` the value and consume it, but this might not be your desired behavior | LL | for _ in <Vec<usize> as Clone>::clone(&self.clone()).into_iter() {} | ++++++++++++++++++++++++++++++ + ``` CC #109429.
2023-12-04Fix some broken testsEric Holk-2/+2
2023-12-04Option<CoroutineKind>Eric Holk-3/+12
2023-12-04Option<CoroutineKind>Eric Holk-122/+117
2023-12-04Merge Async and Gen into CoroutineKindEric Holk-3/+202
2023-12-04Merge Async and Gen into CoroutineKindEric Holk-238/+442
2023-12-04Auto merge of #16018 - lnicola:no-debug, r=Veykrilbors-1/+1
minor: Disable debuginfo again I suspect this wasn't intentional, right?
2023-12-04Disable debuginfo againLaurențiu Nicola-1/+1
2023-12-04Auto merge of #15959 - Veykril:macro-shower3, r=lnicolabors-4166/+5364
TokenMap -> SpanMap rewrite Opening early so I can have an overview over the full diff more easily, still very unfinished and lots of work to be done. The gist of what this PR does is move away from assigning IDs to tokens in arguments and expansions and instead gives the subtrees the text ranges they are sourced from (made relative to some item for incrementality). This means we now only have a single map per expension, opposed to map for expansion and arguments. A few of the things that are not done yet (in arbitrary order): - [x] generally clean up the current mess - [x] proc-macros, have been completely ignored so far - [x] syntax fixups, has been commented out for the time being needs to be rewritten on top of some marker SyntaxContextId - [x] macro invocation syntax contexts are not properly passed around yet, so $crate hygiene does not work in all cases (but most) - [x] builtin macros do not set spans properly, $crate basically does not work with them rn (which we use) ~~- [ ] remove all uses of dummy spans (or if that does not work, change the dummy entries for dummy spans so that tests will not silently pass due to havin a file id for the dummy file)~~ - [x] de-queryfy `macro_expand`, the sole caller of it is `parse_macro_expansion`, and both of these are lru-cached with the same limit so having it be a query is pointless - [x] docs and more docs - [x] fix eager macro spans and other stuff - [x] simplify include! handling - [x] Figure out how to undo the sudden `()` expression wrapping in expansions / alternatively prioritize getting invisible delimiters working again - [x] Simplify InFile stuff and HirFIleId extensions ~~- [ ] span crate containing all the file ids, span stuff, ast ids. Then remove the dependency injection generics from tt and mbe~~ Fixes https://github.com/rust-lang/rust-analyzer/issues/10300 Fixes https://github.com/rust-lang/rust-analyzer/issues/15685
2023-12-04Rollup merge of #118600 - GuillaumeGomez:fields-heading, r=notriddleGuillaume Gomez-1/+29
[rustdoc] Don't generate the "Fields" heading if there is no field displayed Fixes https://github.com/rust-lang/rust/issues/118195. If no field is displayed, we should not generate the `Fields` heading in enum struct variants. r? ``@notriddle``
2023-12-04Rollup merge of #118591 - RalfJung:portable-simd-build-fix, ↵Guillaume Gomez-1/+1
r=workingjubilee,calebzulawski portable-simd: fix test suite build ``@workingjubilee`` ``@calebzulawski`` don't we run these portable-simd tests on rustc CI? Currently they don't even build here.
2023-12-04Rollup merge of #118565 - RalfJung:numeric_intrinsic, r=davidtwcoGuillaume Gomez-46/+36
interpret: make numeric_intrinsic accessible from Miri This will let us share the code of the cttz and simd_cttz intrinsics (and same for ctlz).
2023-12-04Rollup merge of #118508 - notriddle:notriddle/fmt-newline, r=GuillaumeGomezGuillaume Gomez-8/+50
rustdoc: do not escape quotes in body text Escaping quote marks is only needed in attributes, not text. ```console $ du -hs doc-old/ doc-new/ 670M doc-old/ 669M doc-new/ ```
2023-12-04Auto merge of #16017 - lnicola:sync-from-rust, r=lnicolabors-1/+1
minor: sync from downstream
2023-12-04Temporarily revert delay_bug to delayed_bug changeLaurențiu Nicola-1/+1
2023-12-04Merge branch 'master' into sync-from-rustLaurențiu Nicola-1/+5
2023-12-04Add a basic test for gen fnEric Holk-0/+18
2023-12-04Make async gen fn an errorEric Holk-0/+34
2023-12-04gate gen fn behind gen_blocksEric Holk-3/+9
2023-12-04Lower return types for gen fn to impl IteratorEric Holk-80/+167
2023-12-04Add genness to FnHeaderEric Holk-5/+26
2023-12-04Finish implementing `RustcInternal` for `TyKind`Celina G. Val-13/+186
This will allow us to provide methods to create `Ty` inside the stable MIR, which can be helpful while handling pointers and other stuff.
2023-12-04Add Variant and a few more APIs to stable_mirCelina G. Val-39/+153
2023-12-04Fix parser ICE when recovering `dyn`/`impl` after `for<...>`sjwang05-11/+23
2023-12-04Auto merge of #118592 - lnicola:sync-from-ra, r=lnicolabors-170/+821
Subtree update of `rust-analyzer` r? `@ghost`
2023-12-04Insert fn call parens only if the parens inserted around field namedfireBird-6/+31
2023-12-04Update booksrustbot-0/+0
2023-12-04Don't include destruction scopes in THIRMatthew Jasper-468/+235
They are not used by anyone, and add memory/performance overhead.
2023-12-04Use default params until effects in desugaringDeadbeef-6/+44
2023-12-04Auto merge of #118602 - TaKO8Ki:rollup-njcouns, r=TaKO8Kibors-209/+854
Rollup of 5 pull requests Successful merges: - #118495 (Restrict what symbols can be used in `#[diagnostic::on_unimplemented]` format strings) - #118540 (codegen, miri: fix computing the offset of an unsized field in a packed struct) - #118551 (more targeted errors when extern types end up in places they should not) - #118573 (rustc: Harmonize `DefKind` and `DefPathData`) - #118586 (Improve example in `slice::windows()` doc) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-04Avoid adding compiler-used functions to `symbols.o`DianQK-2/+27
2023-12-04Auto merge of #118597 - lnicola:cargotest-no-branch, r=Mark-Simulacrumbors-1/+1
Don't ask for a specific branch in cargotest Tentative fix for https://github.com/rust-lang/rust/pull/118592#issuecomment-1838180918. `servo` [just renamed](https://github.com/servo/servo/pull/30788) their `master` branch to `main`, but `cargotest` does a `git fetch $URL master; git reset --hard $SHA`. Let's try to change that to `git fetch $URL $SHA; git reset --hard $SHA`, which appears to work, but I can't confirm for sure because I'm having some trouble with `x.py`: ``` --> library/rustc-std-workspace-core/lib.rs:4:9 | 4 | pub use core::*; | ^^^^ | = note: the following crate versions were found: crate `core` compiled by rustc 1.76.0-nightly (85a4bd8f5 2023-12-04): ./build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcore-70719e8645e6f000.rmeta = help: please recompile that crate using this compiler (rustc 1.76.0-nightly (5808b7248 2023-12-04)) (consider running `cargo clean` first) ```
2023-12-04Rollup merge of #118586 - gurry:118571-improve-slice-doc-example, r=thomccTakayuki Maeda-5/+5
Improve example in `slice::windows()` doc Fixes #118571 Now using a window of 3 instead 2 because it removes any confusion about exactly how consecutive windows overlap
2023-12-04Rollup merge of #118573 - petrochenkov:pathdatakind, r=TaKO8KiTakayuki Maeda-132/+133
rustc: Harmonize `DefKind` and `DefPathData` Follow up to https://github.com/rust-lang/rust/pull/118188. `DefPathData::(ClosureExpr,ImplTrait)` are renamed to match `DefKind::(Closure,OpaqueTy)`. `DefPathData::ImplTraitAssocTy` is replaced with `DefPathData::TypeNS(kw::Empty)` because both correspond to `DefKind::AssocTy`. It's possible that introducing `(DefKind,DefPathData)::AssocOpaqueTy` instead could be a better solution, but that would be a much more invasive change. Const generic parameters introduced for effects are moved from `DefPathData::TypeNS` to `DefPathData::ValueNS`, because constants are values. `DefPathData` is no longer passed to `create_def` functions to avoid redundancy.
2023-12-04Rollup merge of #118551 - RalfJung:extern-types-bugs, r=compiler-errorsTakayuki Maeda-0/+22
more targeted errors when extern types end up in places they should not Cc https://github.com/rust-lang/rust/issues/115709 -- this does not fix that bug but it makes the panics less obscure and makes it more clear that this is a deeper issue than just a little codegen oversight. (In https://github.com/rust-lang/rust/pull/116115 we decided we'd stick to causing ICEs here for now, rather than nicer errors. We can't currently show any errors pre-mono and probably we don't want post-mono checks when this gets stabilized anyway.)