Skip to content

normalize better - #7

Closed
lukas-code wants to merge 776 commits into
masterfrom
metadata-normalize
Closed

normalize better#7
lukas-code wants to merge 776 commits into
masterfrom
metadata-normalize

Conversation

@lukas-code

@lukas-codelukas-code commented Jan 23, 2024

Copy link
Copy Markdown
Owner
// u*, i*, f*, bool, char, !, arrays, references, pointers, fn pointers,// fn items, dyn* (dyn-star), closures, coroutines, enums, unionsimplPointeefor{trivially_sized}{defaulttypeMetadata = ();}implPointeefor{extern_type}{defaulttypeMetadata = ();}implPointeefor[{ty}]{default type Metadata = usize;}implPointee for str{default type Metadata = usize;}implPointee for dyn{predicates} + '{lifetime}{default type Metadata = DynMetadata<dyn{predicates} + '{lifetime}>;}// any struct without fields, including `PhantomData`implPointee for {unit_struct}{default type Metadata = ();}// project to the last field of the structimplPointee for {non_unit_struct}{default type Metadata = <{shallow_struct_tail}asPointee>::Metadata;}// this specialization takes priority of all other impls for sized typesimpl<T> PointeeforT{typeMetadata = ();}

@lukas-codelukas-code self-assigned this Jan 23, 2024
@lukas-codelukas-code mentioned this pull request Jan 23, 2024
18 tasks
@lukas-code
lukas-codeforce-pushed the metadata-normalize branch 6 times, most recently from 3501908 to e580ae6CompareJanuary 27, 2024 12:24
chenyukangand others added 2 commits January 30, 2024 12:43
Handle out of memory errors in io:Read::read_to_end()
rust-lang#116570 got stuck due to a [procedural confusion](rust-lang#116570 (comment)). Retrying so that it can get FCP with the proper team now. cc `@joshtriplett` `@BurntSushi`
----
I'd like to propose handling of out-of-memory errors in the default implementation of `io::Read::read_to_end()` and `fs::read()`. These methods create/grow a `Vec` with a size that is external to the program, and could be arbitrarily large.
Due to being I/O methods, they can already fail in a variety of ways, in theory even including `ENOMEM` from the OS too, so another failure case should not surprise anyone.
While this may not help much Linux with overcommit, it's useful for other platforms like WASM. [Internals thread](https://internals.rust-lang.org/t/io-read-read-to-end-should-handle-oom/19662).
I've added documentation that makes it explicit that the OOM handling is a nice-to-have, and not a guarantee of the trait.
I haven't changed the implementation of `impl Read for &[u8]` and `VecDeque` out of caution, because in these cases users could assume `read` can't fail.
This code uses `try_reserve()` + `extend_from_slice()` which is optimized since rust-lang#117503.
lnicolaand others added 19 commits January 30, 2024 08:43
…-errors
only assemble alias bound candidates for rigid aliases
fixesrust-lang/trait-system-refactor-initiative#77
This also causes `<Wrapper<?0> as Trait>::Unwrap: Trait` to always be ambig, as we now normalize the self type before checking whether it is an inference variable.
I cannot think of an approach to the underlying issues here which does not require the "may-define means must-define" restriction for opaque types. Going to go ahead with this and added this restriction to the tracking issue for the new solver to make sure we don't stabilize it without getting types + lang signoff here.
r? `@compiler-errors`
Because it's almost always static.
This makes `impl IntoDiagnosticArg for DiagnosticArgValue` trivial,
which is nice.
There are a few diagnostics constructed in
`compiler/rustc_mir_build/src/check_unsafety.rs` and
`compiler/rustc_mir_transform/src/errors.rs` that now need symbols
converted to `String` with `to_string` instead of `&str` with `as_str`,
but that' no big deal, and worth it for the simplifications elsewhere.
Because the `&'a str` fields can be trivially converted to `String`
without causing any extra allocations.
It's identical to the one in `rustc_errors`; use that instead.
Also remove some `rustc_errors::` qualifiers.
Because it's always static.
I'm surprised the compiler allowed this unused lifetime without any
complaint.
…=Nilstrieb
Add triagebot mentions entry for simd intrinsics
Fixesrust-lang#119119
cc `@antoyo,` `@GuillaumeGomez,` `@rust-lang/project-portable-simd`
Reject infinitely-sized reads from io::Repeat
These calls would always run out of memory.
Related to rust-lang#117925
…Simulacrum
bootstrap: add more unit tests
self-explanatory
rustdoc: Prevent JS injection from localStorage
It turns out that you can execute arbitrary JavaScript on the rustdocs settings page. Here's how:
1. Open `settings.html` on a rustdocs site.
2. Set "preferred light theme" to "dark" to initialize the corresponding localStorage value.
3. Plant a payload by executing this in your browser's dev console: ``Object.keys(localStorage).forEach(key=>localStorage.setItem(key,`javascript:alert()//*/javascript:javascript:"/*'/*\`/*--></noscript></title></textarea></style></template></noembed></script><html " onmouseover=/*&lt;svg/*/onload=alert()onload=alert()//><svg onload=alert()><svg onload=alert()>*/</style><script>alert()</script><style>`));``
4. Refresh the page -- you should see an alert.
This could be particularly dangerous if rustdocs are deployed on a domain hosting some other application. Malicious code could circumvent `same-origin` policies and do mischievous things with user data.
This change ensures that only defined themes can actually be selected (arbitrary strings from localStorage will not be written to the document), and for good measure sanitizes the theme name.
Update codegen test for LLVM 18
r? ```````@cuviper```````
…li-obk
interpret/memory: fix safety comment for large array memset optimization
Also fix the doc comment for `check_and_deref_ptr`.
…i-obk
Bound errors span label cleanup
Consolidate span labels for "this type doesn't satisfy a bound" for more compact diagnostic output.
…tree, r=cjgillot
Make the coroutine def id of an async closure the child of the closure def id
Adjust def collection to make the (inner) coroutine returned by an async closure be a def id child of the (outer) closure. This makes it easy to map from coroutine -> closure by using `tcx.parent`, since currently it's not trivial to do this.
…, r=onur-ozkan
Add instructions of how to use pre-vendored 'rustc-src'
This PR closesrust-lang#110163.
I had to move the URL to the left, making it not aligned as it is three lines above, but the tidy check would yell at me otherwise. If that's not acceptable, I'd love some suggestions on how to make it better.
One question: in the original issue (rust-lang#110163 (comment)), it was suggested to mention how to download specific commit tarballs; however, it was said it's not documented anywhere, so I did not include that yet. If there is a want to have that, I'd gladly amend the commit.
raw pointer metadata API: data address -> data pointer
A pointer consists of [more than just an address](rust-lang/rfcs#3559), so let's not equate "pointer" and "address" in these docs.
…Nilstrieb
Remove unnecessary unit returns in query declarations
For consistency with normal functions.
matthiaskrgrand others added 22 commits February 4, 2024 19:42
…m-diags, r=oli-obk
Improve the diagnostics for unused generic parameters
* Don't emit two errors (namely E0091 *and* E0392) for unused type parameters on *lazy* type aliases
* Fix the diagnostic help message of E0392 for *lazy* type aliases: Don't talk about the “fields” of lazy type aliases (use the term “body” instead) and don't suggest `PhantomData` for them, it doesn't make much sense
* Consolidate the diagnostics for E0091 (unused type parameters in type aliases) and E0392 (unused generic parameters due to bivariance) and make it translatable
* Still keep the error codes distinct (for now)
* Naturally leads to better diagnostics for E0091
r? ```@oli-obk``` (to ballast your review load :P) or compiler
…iaskrgr
Rollup of 10 pull requests
Successful merges:
- rust-lang#119543 (add avx512fp16 to x86 target features)
- rust-lang#120004 (Release notes for 1.76)
- rust-lang#120562 (Revert unsound libcore changes)
- rust-lang#120566 (coverage: Use normal `edition:` headers in coverage tests)
- rust-lang#120570 (Suggest changing type to const parameters if we encounter a type in the trait bound position)
- rust-lang#120571 (Miscellaneous diagnostics cleanups)
- rust-lang#120573 (Remove `BorrowckErrors::tainted_by_errors`)
- rust-lang#120592 (Remove unnecessary `.to_string()`/`.as_str()`s)
- rust-lang#120610 (hir: Remove the generic type parameter from `MaybeOwned`)
- rust-lang#120616 (Fix ICE on field access on a tainted type after const-eval failure)
Failed merges:
- rust-lang#120569 (coverage: Improve handling of function/closure spans)
r? `@ghost`
`@rustbot` modify labels: rollup
…iaskrgr
Rollup of 8 pull requests
Successful merges:
- rust-lang#120484 (Avoid ICE when is_val_statically_known is not of a supported type)
- rust-lang#120516 (pattern_analysis: cleanup manual impls)
- rust-lang#120517 (never patterns: It is correct to lower `!` to `_`.)
- rust-lang#120523 (Improve `io::Read::read_buf_exact` error case)
- rust-lang#120528 (Store SHOULD_CAPTURE as AtomicU8)
- rust-lang#120529 (Update data layouts in custom target tests for LLVM 18)
- rust-lang#120531 (Remove a bunch of `has_errors` checks that have no meaningful or the wrong effect)
- rust-lang#120533 (Correct paths for hexagon-unknown-none-elf platform doc)
r? `@ghost`
`@rustbot` modify labels: rollup
…iaskrgr
Rollup of 8 pull requests
Successful merges:
- rust-lang#119759 (Add FileCheck annotations to dataflow-const-prop tests)
- rust-lang#120323 (On E0277 be clearer about implicit `Sized` bounds on type params and assoc types)
- rust-lang#120473 (Only suggest removal of `as_*` and `to_` conversion methods on E0308)
- rust-lang#120540 (add test for try-block-in-match-arm)
- rust-lang#120547 (`#![feature(inline_const_pat)]` is no longer incomplete)
- rust-lang#120552 (Correctly check `never_type` feature gating)
- rust-lang#120555 (put pnkfelix (me) back on the review queue.)
- rust-lang#120556 (Improve the diagnostics for unused generic parameters)
r? `@ghost`
`@rustbot` modify labels: rollup
This improves the coverage instrumentation of closures declared in macros, as
seen in `closure_macro.rs` and `closure_macro_async.rs`.
This sidesteps the normal span refinement code in cases where we know that we
are only dealing with the special signature span that represents having called
an async function.
Move predicate, region, and const stuff into their own modules in middle
This PR mostly moves things around, and in a few cases adds some `ty::` to the beginning of names to avoid one-off imports.
I don't mean this to be the most *thorough* move/refactor. I just generally wanted to begin to split up `ty/mod.rs` and `ty/sty.rs` which are huge and hard to distinguish, and have a lot of non-ty stuff in them.
r? lcnr
Update cargo
24 commits in 7bb7b539558dc88bea44cee4168b6269bf8177b0..cdf84b69d0416c57ac9dc3459af80dfb4883d27a
2024-01-20 00:15:32 +0000 to 2024-02-02 19:39:16 +0000
- Apply `-Zpanic-abort-tests` to doctests too (rust-lang/cargo#13388)
- Don't print rustdoc command lines on failure by default (rust-lang/cargo#13387)
- Ensure `nonzero_exit_code` test isn't affected by developers `RUST_BACKTRACE` setting (rust-lang/cargo#13385)
- Add `docsrs` cfg as a well known `--check-cfg` (rust-lang/cargo#13383)
- fix(new): Print a note, rather than a comment, for more information (rust-lang/cargo#13371)
- Change tests to support changes to suggestion (rust-lang/cargo#13382)
- chore(ci): enable m1 runner (rust-lang/cargo#13377)
- fix(toml): Improve map/sequence error message (rust-lang/cargo#13376)
- fix(diagnostic): Don't panic on empty spans (rust-lang/cargo#13375)
- doc: Hide `cargo-fetch` description in offline man page (rust-lang/cargo#13364)
- feat: stabilize lockfile v4 (rust-lang/cargo#12852)
- fix(new): Print a 'Creating', rather than 'Created' status (rust-lang/cargo#13367)
- fix: use spec id instead of name to match package (rust-lang/cargo#13335)
- refactor(shell): Use new fancy anstyle API (rust-lang/cargo#13368)
- feat(cargo-update): `--precise` to allow yanked versions (rust-lang/cargo#13333)
- refactor: remove unnecessary Option in `Freshness::Dirty` (rust-lang/cargo#13361)
- doc: Replace version with `latest` for jobserver link (rust-lang/cargo#13366)
- test: data layout fix for `x86_64-unknown-none-gnu` (rust-lang/cargo#13362)
- docs(ref): Try to improve reg auth docs (rust-lang/cargo#13351)
- fix typo of rustbuild, instead of rustuild (rust-lang/cargo#13357)
- fix(config): Deprecate non-extension files (rust-lang/cargo#13349)
- fix(cli): Improve errors related to cargo script (rust-lang/cargo#13346)
- fix list option description starting with uppercase (rust-lang/cargo#13344)
- Fix typo in test (rust-lang/cargo#13342)
…le, r=Mark-Simulacrum
Clarify ambiguity in select_nth_unstable docs
Original docs for `select_nth_unstable` family of functions were ambiguous as to whether "the element at `index`" was the element at `index` before the function reordered the elements or after the function reordered the elements.
The most helpful change in this PR is to change the given examples to make this absolutely clear. Before, "the element at `index`" was the same value before and after the reordering, so it didn't help disambiguate the meaning. I've changed the example for `select_nth_unstable` and `select_nth_unstable_by` so that "the element at `index`" is different before and after the reordering, which clears up the ambiguity. The function `select_nth_unstable_by_key` already had an example that was unambiguous.
In an attempt to clear up the ambiguity from the get-go, I've added a bit of redundancy to the text. Now the docs refer to "the element at `index` *after the reordering*".
…-Simulacrum
Document `&CStr` to `CString` conversion
Related to rust-lang#51430
coverage: Improve handling of function/closure spans
This is a combination of some loosely-related changes that touch the same code:
1. Make unexpansion of closure bodies more precise, by unexpanding back to the context of the closure declaration, instead of unexpanding all the way back to the top-level context. This preserves the way we handle async desugaring and closures containing a single bang-macro, while also giving better results for closures defined in macros.
2. Skip the normal span-refinement code when dealing with the trivial outer part of an async function.
3. Be more explicit about the fact that `fn_sig_span` has been extended to the start of the function body, and is not necessarily present.
---
`@rustbot` label +A-code-coverage
Update libc to 0.2.153
Bumps libc dependency to 0.2.153, which includes this fix, required for building std for the vita: rust-lang/libc#3552
…RalfJung
miri: normalize struct tail in ABI compat check
fixesrust-lang/miri#3282
extracted from rust-lang#120354, see rust-lang#120354 (comment) for context
r? ```@RalfJung```
fixrust-lang#120603 by adding a check in default_read_buf
Fixesrust-lang#120603 by checking the returned read n is in-bounds of the cursor.
Interestingly, I noticed that `BorrowedBuf` side-steps this issue by using checked accesses. Maybe this can be switched to unchecked to mirror what BufReader does https://github.com/rust-lang/rust/blob/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/core/src/io/borrowed_buf.rs#L95
rustdoc: trait.impl, type.impl: sort impls to make it not depend on serialization order
Can be tested by running `cargo doc` with different rust versions on some crate and comparing `doc` folders: files in `trait.impl` and `type.impl` will sometimes have different order of impls.
…iaskrgr
Rollup of 9 pull requests
Successful merges:
- rust-lang#119481 (Clarify ambiguity in select_nth_unstable docs)
- rust-lang#119600 (Remove outdated references to librustc_middle)
- rust-lang#120458 (Document `&CStr` to `CString` conversion)
- rust-lang#120569 (coverage: Improve handling of function/closure spans)
- rust-lang#120572 (Update libc to 0.2.153)
- rust-lang#120587 (miri: normalize struct tail in ABI compat check)
- rust-lang#120607 (fixrust-lang#120603 by adding a check in default_read_buf)
- rust-lang#120636 (Subtree update of `rust-analyzer`)
- rust-lang#120641 (rustdoc: trait.impl, type.impl: sort impls to make it not depend on serialization order)
r? `@ghost`
`@rustbot` modify labels: rollup
@lukas-code
lukas-code deleted the metadata-normalize branch February 10, 2024 23:13
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

20 participants

@lukas-code@chenyukang@bors@lnicola@nnethercote@Veykril@GuillaumeGomez@petrochenkov@Young-Flash@davidsemakula@Urhengulas@clubby789@Nadrieril@compiler-errors@onur-ozkan@davidbarsky@Teapot4195@estebank@the8472@a1phyr