rust/compiler
Scott McMurray 89a18cb600 Add unsigned_offset_from on pointers
Like we have `add`/`sub` which are the `usize` version of `offset`, this adds the `usize` equivalent of `offset_from`.  Like how `.add(d)` replaced a whole bunch of `.offset(d as isize)`, you can see from the changes here that it's fairly common that code actually knows the order between the pointers and *wants* a `usize`, not an `isize`.

As a bonus, this can do `sub nuw`+`udiv exact`, rather than `sub`+`sdiv exact`, which can be optimized slightly better because it doesn't have to worry about negatives.  That's why the slice iterators weren't using `offset_from`, though I haven't updated that code in this PR because slices are so perf-critical that I'll do it as its own change.

This is an intrinsic, like `offset_from`, so that it can eventually be allowed in CTFE.  It also allows checking the extra safety condition -- see the test confirming that CTFE catches it if you pass the pointers in the wrong order.
2022-05-11 17:16:25 -07:00
..
rustc Propagate parallel_compiler feature through rustc crates. Turned off feature gives change of builded crates: 238 -> 224. 2022-03-28 08:41:12 +03:00
rustc_apfloat Addressed comments by @compiler-errors and @bjorn3 2022-03-30 17:04:46 -04:00
rustc_arena mark FIXMES for all the places found that are probably offset_from 2022-03-29 20:18:28 -04:00
rustc_ast ast: Introduce some traits to get AST node properties generically 2022-05-11 12:43:27 +03:00
rustc_ast_lowering Auto merge of #96770 - flip1995:fix-trait-type-in-bounds, r=cjgillot 2022-05-08 14:10:12 +00:00
rustc_ast_passes Feature-gate do yeet inside cfgs too 2022-04-30 18:10:01 -07:00
rustc_ast_pretty ast: Introduce some traits to get AST node properties generically 2022-05-11 12:43:27 +03:00
rustc_attr Use native duplicate attribute check 2022-04-14 21:19:48 -04:00
rustc_borrowck Auto merge of #96736 - oli-obk:tait_missing_wf_check, r=davidtwco 2022-05-10 13:39:43 +00:00
rustc_builtin_macros ast: Introduce some traits to get AST node properties generically 2022-05-11 12:43:27 +03:00
rustc_codegen_cranelift Add unsigned_offset_from on pointers 2022-05-11 17:16:25 -07:00
rustc_codegen_gcc Merge new_metadata into codegen_allocator 2022-04-30 21:20:08 +02:00
rustc_codegen_llvm Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errors 2022-05-07 06:30:29 +00:00
rustc_codegen_ssa Add unsigned_offset_from on pointers 2022-05-11 17:16:25 -07:00
rustc_const_eval Add unsigned_offset_from on pointers 2022-05-11 17:16:25 -07:00
rustc_data_structures Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errors 2022-05-07 06:30:29 +00:00
rustc_driver errors: lazily load fallback fluent bundle 2022-04-13 02:44:59 +01:00
rustc_error_codes Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errors 2022-05-09 04:47:30 +00:00
rustc_error_messages Auto merge of #96715 - cjgillot:trait-alias-loop, r=compiler-errors 2022-05-10 00:40:57 +00:00
rustc_errors Fixed typo in docs and correct doc links 2022-05-08 17:24:15 +02:00
rustc_expand ast: Introduce some traits to get AST node properties generically 2022-05-11 12:43:27 +03:00
rustc_feature Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errors 2022-05-09 04:47:30 +00:00
rustc_fs_util
rustc_graphviz eplace usages of vec![].into_iter with [].into_iter 2022-01-09 14:09:25 +11:00
rustc_hir review 2022-05-09 18:40:18 +02:00
rustc_hir_pretty Store all generic bounds as where predicates. 2022-04-30 13:55:13 +02:00
rustc_incremental fix most compiler/ doctests 2022-05-02 17:40:30 -07:00
rustc_index Add element iterator for ChunkedBitSet 2022-04-30 16:40:49 +02:00
rustc_infer Auto merge of #96155 - jackh726:param-heuristics-followup, r=estebank 2022-05-08 04:05:36 +00:00
rustc_interface Move lint expectation checking into a separate query (RFC 2383) 2022-05-08 14:37:14 +02:00
rustc_lexer Reduce max hash in raw strings from u16 to u8 2022-03-23 22:13:55 +01:00
rustc_lint ast: Introduce some traits to get AST node properties generically 2022-05-11 12:43:27 +03:00
rustc_lint_defs Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errors 2022-05-09 04:47:30 +00:00
rustc_llvm RustWrapper: explicitly don't handle DXILPointerTyID 2022-04-28 13:53:52 -04:00
rustc_log rustc_log: add env var to set verbose entry/exit behavior 2022-05-11 09:14:31 +02:00
rustc_macros macros: allow Vec fields in diagnostic derive 2022-05-06 03:43:30 +01:00
rustc_metadata review 2022-05-09 18:40:18 +02:00
rustc_middle Use lifetimes on type-alias-impl-trait used in function signatures to infer output type lifetimes 2022-05-10 14:50:31 +00:00
rustc_mir_build Auto merge of #96888 - Aaron1011:fake-borrow-no-sort, r=petrochenkov 2022-05-11 04:09:45 +00:00
rustc_mir_dataflow Use sparse representation of switch sources 2022-05-08 23:48:23 +02:00
rustc_mir_transform simplify length count 2022-05-10 20:42:45 +02:00
rustc_monomorphize Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errors 2022-05-07 06:30:29 +00:00
rustc_parse ast: Introduce some traits to get AST node properties generically 2022-05-11 12:43:27 +03:00
rustc_parse_format Make rustc_parse_format compile on stable 2022-05-03 11:26:58 +02:00
rustc_passes Auto merge of #96473 - lcnr:querify-codegen-fn-attrs, r=cjgillot 2022-05-09 19:52:59 +00:00
rustc_plugin_impl
rustc_privacy rustc: Panic by default in DefIdTree::parent 2022-05-02 01:56:50 +03:00
rustc_query_impl Move lint expectation checking into a separate query (RFC 2383) 2022-05-08 14:37:14 +02:00
rustc_query_system Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errors 2022-05-07 06:30:29 +00:00
rustc_resolve Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errors 2022-05-07 06:30:29 +00:00
rustc_save_analysis rustc: Panic by default in DefIdTree::parent 2022-05-02 01:56:50 +03:00
rustc_serialize Remove unused macro rules 2022-04-18 23:28:06 +02:00
rustc_session sess: add create_{err,warning} 2022-05-06 03:44:41 +01:00
rustc_span Add unsigned_offset_from on pointers 2022-05-11 17:16:25 -07:00
rustc_symbol_mangling review 2022-05-09 18:40:18 +02:00
rustc_target make Size and Align debug-printing a bit more compact 2022-05-06 10:57:03 +02:00
rustc_trait_selection Auto merge of #96736 - oli-obk:tait_missing_wf_check, r=davidtwco 2022-05-10 13:39:43 +00:00
rustc_traits Remove opaque type obligation and just register opaque types as they are encountered. 2022-03-28 16:57:45 +00:00
rustc_ty_utils Avoid accessing HIR from MIR queries. 2022-04-10 13:08:36 +02:00
rustc_type_ir fix most compiler/ doctests 2022-05-02 17:40:30 -07:00
rustc_typeck Add unsigned_offset_from on pointers 2022-05-11 17:16:25 -07:00