1. 18 12月, 2021 13 次提交
    • M
      Rollup merge of #91925 - LegionMammal978:less-inband-privacy, r=nagisa · 44ff0f75
      Matthias Krüger 提交于
      Remove `in_band_lifetimes` from `rustc_privacy`
      
      See #91867 for more information.
      44ff0f75
    • M
      Rollup merge of #91923 - LegionMammal978:less-inband-query_impl, r=michaelwoerister · df428917
      Matthias Krüger 提交于
      Remove `in_band_lifetimes` from `rustc_query_impl`
      
      See #91867 for more information.
      df428917
    • M
      Rollup merge of #91858 - semarie:runpath, r=petrochenkov · 069ffec6
      Matthias Krüger 提交于
      pass -Wl,-z,origin to set DF_ORIGIN when using rpath
      
      DF_ORIGIN flag signifies that the object being loaded may make reference to the $ORIGIN substitution string.
      
      Some implementations are just ignoring [DF_ORIGIN](http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#df_flags) and do [substitution](http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#substitution) for $ORIGIN if present (whatever DF_ORIGIN presence or not) like glibc. But some others mandate the present of DF_ORIGIN for the substitution (like OpenBSD).
      
      Set the flag inconditionally if rpath is wanted.
      
      One possible fallout is if the linker rejects `-z origin` option.
      069ffec6
    • B
      Auto merge of #92059 - matthiaskrgr:rollup-bainfyh, r=matthiaskrgr · 208ced64
      bors 提交于
      Rollup of 7 pull requests
      
      Successful merges:
      
       - #87901 (Fix suggestion of additional `pub` when using `pub pub fn ...`)
       - #89090 (Lint bare traits in AstConv.)
       - #91818 (Show the unused type for `unused_results` lint)
       - #91910 (miri: lift restriction on extern types being the only field in a struct)
       - #91928 (Constify (most) `Option` methods)
       - #91975 (Move generator check earlier in inlining.)
       - #92016 (builtin_macros: allow external consumers for AsmArgs parsing)
      
      Failed merges:
      
      r? `@ghost`
      `@rustbot` modify labels: rollup
      208ced64
    • M
      Rollup merge of #92016 - calebcartwright:expose-asm-args-parsing, r=Amanieu · fd445ddf
      Matthias Krüger 提交于
      builtin_macros: allow external consumers for AsmArgs parsing
      
      As discussed in Zulip (https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/parsing.20of.20AsmArgs.20for.20inline.20assembly), we need a function entry point that rustfmt can leverage from a pre-expansion context to get a more structured representation of the asm args without having to duplicate/maintain the token stream parsing
      
      r? ```@Amanieu``` and/or ```@joshtriplett```
      fd445ddf
    • M
      Rollup merge of #91975 - cjgillot:noinline-generator, r=jackh726 · 816cda7e
      Matthias Krüger 提交于
      Move generator check earlier in inlining.
      
      Inlining into generator may create references to other generators. For instance, inlining `Pin::<&mut from_generator::GenFuture<[generator1]>>::new_unchecked` into `generator2`. This cross reference can then create cycles when computing inlining for `generator1`.
      
      In order to avoid this kind of surprises, we forbid all inlining into generators, and rely on LLVM to do the right thing. The existing `remove-zst-query-cycle` already ICEs in inline-mir mode, so we use it as test.
      
      Split from #91743.
      816cda7e
    • M
      Rollup merge of #91928 - fee1-dead:constification1, r=oli-obk · fcc59794
      Matthias Krüger 提交于
      Constify (most) `Option` methods
      
      r? ``@oli-obk``
      fcc59794
    • M
      Rollup merge of #91910 - tmiasko:miri-extern-type, r=RalfJung · 64ce698f
      Matthias Krüger 提交于
      miri: lift restriction on extern types being the only field in a struct
      
      Fixes #91827.
      
      r? ````@RalfJung````
      64ce698f
    • M
      Rollup merge of #91818 - camelid:unused-result-type, r=jackh726 · 24b75e71
      Matthias Krüger 提交于
      Show the unused type for `unused_results` lint
      
      I think it's helpful to know what type was unused when looking at these
      warnings. The type will likely determine whether the result *should* be
      used, or whether it should just be ignored.
      
      Including the type also matches the behavior of the `must_use` lint:
      unused `SomeType` that must be used.
      24b75e71
    • M
      Rollup merge of #89090 - cjgillot:bare-dyn, r=jackh726 · 7a626cf7
      Matthias Krüger 提交于
      Lint bare traits in AstConv.
      
      Removing the lint from lowering allows to:
      - make lowering querification easier;
      - have the lint implementation in only one place.
      
      r? `@estebank`
      7a626cf7
    • M
      Rollup merge of #87901 - poliorcetics:pub-pub-pub, r=jackh726 · 54e7946d
      Matthias Krüger 提交于
      Fix suggestion of additional `pub` when using `pub pub fn ...`
      
      Fix #87694.
      
      Marked as draft to start with because I want to explore doing the same fix for `const const fn` and other repeated-but-valid keywords.
      
      `@rustbot` label A-diagnostics D-invalid-suggestion T-compiler
      54e7946d
    • B
      Auto merge of #89841 - cormacrelf:let-else-typed, r=nagisa · dde825db
      bors 提交于
      Implement let-else type annotations natively
      
      Tracking issue: #87335
      
      Fixes #89688, fixes #89807, edit: fixes  #89960 as well
      
      As explained in https://github.com/rust-lang/rust/issues/89688#issuecomment-940405082, the previous desugaring moved the let-else scrutinee into a dummy variable, which meant if you wanted to refer to it again in the else block, it had moved.
      
      This introduces a new hir type, ~~`hir::LetExpr`~~ `hir::Let`, which takes over all the fields of `hir::ExprKind::Let(...)` and adds an optional type annotation. The `hir::Let` is then treated like a `hir::Local` when type checking a function body, specifically:
      
      * `GatherLocalsVisitor` overrides a new `Visitor::visit_let_expr` and does pretty much exactly what it does for `visit_local`, assigning a local type to the `hir::Let` ~~(they could be deduplicated but they are right next to each other, so at least we know they're the same)~~
      * It reuses the code in `check_decl_local` to typecheck the `hir::Let`, simply returning 'bool' for the expression type after doing that.
      
      * ~~`FnCtxt::check_expr_let` passes this local type in to `demand_scrutinee_type`, and then imitates check_decl_local's pattern checking~~
      * ~~`demand_scrutinee_type` (the blindest change for me, please give this extra scrutiny) uses this local type instead of of creating a new one~~
          * ~~Just realised the `check_expr_with_needs` was passing NoExpectation further down, need to pass the type there too. And apparently this Expectation API already exists.~~
      
      Some other misc notes:
      
      * ~~Is the clippy code supposed to be autoformatted? I tried not to give huge diffs but maybe some rustfmt changes simply haven't hit it yet.~~
      * in `rustc_ast_lowering/src/block.rs`, I noticed some existing `self.alias_attrs()` calls in `LoweringContext::lower_stmts` seem to be copying attributes from the lowered locals/etc to the statements. Is that right? I'm new at this, I don't know.
      dde825db
    • B
      Auto merge of #91838 - scottmcm:array-slice-eq-via-arrays-not-slices, r=dtolnay · 7abab1ef
      bors 提交于
      Do array-slice equality via array equality, rather than always via slices
      
      ~~Draft because it needs a rebase after #91766 eventually gets through bors.~~
      
      This enables the optimizations from #85828 to be used for array-to-slice comparisons too, not just array-to-array.
      
      For example, <https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=5f9ba69b3d5825a782f897c830d3a6aa>
      ```rust
      pub fn demo(x: &[u8], y: [u8; 4]) -> bool {
          *x == y
      }
      ```
      Currently writes the array to stack for no reason:
      ```nasm
      	sub	rsp, 4
      	mov	dword ptr [rsp], edx
      	cmp	rsi, 4
      	jne	.LBB0_1
      	mov	eax, dword ptr [rdi]
      	cmp	eax, dword ptr [rsp]
      	sete	al
      	add	rsp, 4
      	ret
      
      .LBB0_1:
      	xor	eax, eax
      	add	rsp, 4
      	ret
      ```
      Whereas with the change in this PR it just compares it directly:
      ```nasm
      	cmp	rsi, 4
      	jne	.LBB1_1
      	cmp	dword ptr [rdi], edx
      	sete	al
      	ret
      
      .LBB1_1:
      	xor	eax, eax
      	ret
      ```
      7abab1ef
  2. 17 12月, 2021 24 次提交
  3. 16 12月, 2021 3 次提交
    • B
      Fix SB problems in slice sorting · 3a0fa037
      Ben Kimock 提交于
      Most of these problems originate in use of get_unchecked_mut.
      
      When calling ptr::copy_nonoverlapping, using get_unchecked_mut for both
      arguments causes the borrow created to make the second pointer to invalid the
      first.
      
      The pairs of identical MaybeUninit::slice_as_mut_ptr calls similarly
      invalidate each other.
      
      There was also a similar borrow invalidation problem with the use of
      slice::get_unchecked_mut to derive the pointer for the CopyOnDrop.
      3a0fa037
    • B
      Auto merge of #91833 - klensy:rd-minus-alloc, r=jyn514 · 1d01550f
      bors 提交于
      rustdoc: don't clone already owned `Path` and modify it inplace
      1d01550f
    • D
      Fix default_method_body_is_const when used across crates · 4bb65e1c
      Deadbeef 提交于
      4bb65e1c