Commit Graph

2826 Commits

Author SHA1 Message Date
Ralf Jung
a0ac13d8a1 gracefully handle type-too-large layout errors 2022-04-30 17:09:44 +02:00
Ben Kimock
cddd85e2f3 Move SB diagnostics to a module 2022-04-30 10:26:26 -04:00
Ben Kimock
5861d137b2 Set the current span (somewhat) lazily 2022-04-30 10:25:52 -04:00
Ben Kimock
f3f7e083dc Print spans where tags are created and invalidated 2022-04-30 10:25:51 -04:00
bors
cf5e75389d Auto merge of #2090 - dtolnay-contrib:addcarry, r=oli-obk
Implement llvm.x86.addcarry.64

This is the only new shim I need for https://github.com/dtolnay/precise/issues/2. It's used by the `num-bigint` crate for bigint addition.
2022-04-30 09:07:16 +00:00
David Tolnay
96036c65bf
Keep remaining clippy ignores 2022-04-29 16:03:38 -07:00
David Tolnay
d35c82f79f
Resolve clippy::useless_conversion
error: useless conversion to the same type: `rustc_const_eval::interpret::Pointer<std::option::Option<machine::Tag>>`
       --> src/helpers.rs:668:36
        |
    668 |                 this.get_ptr_alloc(ptr.offset(len, this)?.into(), size1, Align::ONE)?.unwrap(); // not a ZST, so we will get a result
        |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `ptr.offset(len, this)?`
        |
        = note: `-D clippy::useless-conversion` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `rustc_const_eval::interpret::Pointer<std::option::Option<machine::Tag>>`
       --> src/helpers.rs:678:29
        |
    678 |         this.read_bytes_ptr(ptr.into(), len)
        |                             ^^^^^^^^^^ help: consider removing `.into()`: `ptr`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `rustc_const_eval::interpret::Pointer<std::option::Option<machine::Tag>>`
       --> src/helpers.rs:690:44
        |
    690 |             let alloc = this.get_ptr_alloc(ptr.into(), size2, align2)?.unwrap(); // not a ZST, so we will get a result
        |                                            ^^^^^^^^^^ help: consider removing `.into()`: `ptr`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `rustc_const_eval::interpret::OpTy<machine::Tag>`
       --> src/shims/intrinsics.rs:778:42
        |
    778 |                         .read_immediate(&this.operand_index(index, i)?.into())?
        |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `this.operand_index(index, i)?`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `u32`
        --> src/shims/posix/fs.rs:1171:26
         |
    1171 |             builder.mode(mode.into());
         |                          ^^^^^^^^^^^ help: consider removing `.into()`: `mode`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `std::ffi::OsString`
      --> src/shims/env.rs:67:53
       |
    67 |                     ecx.machine.env_vars.map.insert(OsString::from(name), var_ptr);
       |                                                     ^^^^^^^^^^^^^^^^^^^^ help: consider removing `OsString::from()`: `name`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `rustc_const_eval::interpret::Scalar<machine::Tag>`
       --> src/shims/tls.rs:102:44
        |
    102 |                 Ok(value.unwrap_or_else(|| Scalar::null_ptr(cx).into()))
        |                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `Scalar::null_ptr(cx)`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `u32`
      --> src/thread.rs:73:26
       |
    73 |         Scalar::from_u32(u32::try_from(self.0).unwrap())
       |                          ^^^^^^^^^^^^^^^^^^^^^
       |
       = help: consider removing `u32::try_from()`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
2022-04-29 16:02:11 -07:00
David Tolnay
4b523fce18
Resolve clippy::unnecessary_mut_passed
error: the method `validate_lock_acquire` doesn't need a mutable reference
       --> src/sync.rs:477:49
        |
    477 |                 data_race.validate_lock_acquire(&mut condvar.data_race, waiter.thread);
        |                                                 ^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: `-D clippy::unnecessary-mut-passed` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_mut_passed
2022-04-29 15:59:19 -07:00
David Tolnay
1986f90c6a
Resolve clippy::single_char_pattern
error: single-character string constant used as pattern
       --> src/helpers.rs:805:36
        |
    805 |         .map(|crates| crates.split(",").map(|krate| krate.to_string()).collect::<Vec<_>>())
        |                                    ^^^ help: try using a `char` instead: `','`
        |
        = note: `-D clippy::single-char-pattern` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_pattern
2022-04-29 15:58:34 -07:00
David Tolnay
277d0b53a7
Resolve clippy::single_char_add_str
error: calling `push_str()` using a single-character string literal
       --> src/diagnostics.rs:299:9
        |
    299 |         helps.last_mut().unwrap().1.push_str("\n");
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `helps.last_mut().unwrap().1.push('\n')`
        |
        = note: `-D clippy::single-char-add-str` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_add_str
2022-04-29 15:57:54 -07:00
David Tolnay
2f32221fe4
Resolve clippy::redundant_field_names
error: redundant field names in struct initialization
       --> src/helpers.rs:199:34
        |
    199 |         let place = mir::Place { local: local, projection: List::empty() };
        |                                  ^^^^^^^^^^^^ help: replace it with: `local`
        |
        = note: `-D clippy::redundant-field-names` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

    error: redundant field names in struct initialization
       --> src/thread.rs:238:13
        |
    238 |             threads: threads,
        |             ^^^^^^^^^^^^^^^^ help: replace it with: `threads`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
2022-04-29 15:57:16 -07:00
David Tolnay
48f4f2734d
Resolve clippy::redundant_closure
error: redundant closure
       --> src/data_race.rs:787:18
        |
    787 |             .map(|idx| VectorIdx::new(idx))
        |                  ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `VectorIdx::new`
        |
        = note: `-D clippy::redundant-closure` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure

    error: redundant closure
      --> src/thread.rs:61:31
       |
    61 |         u32::try_from(id).map(|id_u32| Self(id_u32))
       |                               ^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `Self`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
2022-04-29 15:56:27 -07:00
David Tolnay
95510587ff
Resolve clippy::op_ref
error: taken reference of right operand
      --> src/shims/env.rs:53:63
       |
    53 |                     true => !excluded_env_vars.iter().any(|v| v.as_str() == &name),
       |                                                               ^^^^^^^^^^^^^^-----
       |                                                                             |
       |                                                                             help: use the right value directly: `name`
       |
       = note: `-D clippy::op-ref` implied by `-D clippy::all`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#op_ref

    error: taken reference of right operand
      --> src/shims/env.rs:54:71
       |
    54 |                     false => config.forwarded_env_vars.iter().any(|v| v.as_str() == &name),
       |                                                                       ^^^^^^^^^^^^^^-----
       |                                                                                     |
       |                                                                                     help: use the right value directly: `name`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#op_ref
2022-04-29 15:55:30 -07:00
David Tolnay
519755a823
Resolve clippy::needless_return
error: unneeded `return` statement
       --> src/helpers.rs:734:13
        |
    734 |             return Ok(());
        |             ^^^^^^^^^^^^^^ help: remove `return`: `Ok(())`
        |
        = note: `-D clippy::needless-return` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

    error: unneeded `return` statement
       --> src/range_map.rs:113:9
        |
    113 |         return true;
        |         ^^^^^^^^^^^^ help: remove `return`: `true`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

    error: unneeded `return` statement
       --> src/shims/posix/fs.rs:648:25
        |
    648 |                 None => return this.handle_not_found(),
        |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove `return`: `this.handle_not_found()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

    error: unneeded `return` statement
      --> src/shims/panic.rs:62:9
       |
    62 |         return Ok(());
       |         ^^^^^^^^^^^^^^ help: remove `return`: `Ok(())`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

    error: unneeded `return` statement
       --> src/shims/panic.rs:115:9
        |
    115 |         return Ok(());
        |         ^^^^^^^^^^^^^^ help: remove `return`: `Ok(())`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

    error: unneeded `return` statement
       --> src/thread.rs:477:9
        |
    477 |         return free_tls_statics;
        |         ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove `return`: `free_tls_statics`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

    error: unneeded `return` statement
       --> src/thread.rs:459:17
        |
    459 |                 return false;
        |                 ^^^^^^^^^^^^^ help: remove `return`: `false`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
2022-04-29 15:53:48 -07:00
David Tolnay
a893618854
Implement llvm.x86.addcarry.64 2022-04-29 15:51:01 -07:00
David Tolnay
6e2297fde0
Resolve clippy::needless_question_mark
error: question mark operator is useless here
      --> src/helpers.rs:86:16
       |
    86 |         return Ok(const_val.check_init()?);
       |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `const_val.check_init()`
       |
       = note: `-D clippy::needless-question-mark` implied by `-D clippy::all`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark
2022-04-29 15:48:01 -07:00
David Tolnay
c6bd81bbf3
Resolve clippy::needless_lifetimes
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
      --> src/range_map.rs:66:5
       |
    66 |     pub fn iter<'a>(&'a self, offset: Size, len: Size) -> impl Iterator<Item = (Size, &'a T)> + 'a {
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = note: `-D clippy::needless-lifetimes` implied by `-D clippy::all`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes

    error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
      --> src/range_map.rs:86:5
       |
    86 |     pub fn iter_mut_all<'a>(&'a mut self) -> impl Iterator<Item = &'a mut T> + 'a {
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes

    error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
       --> src/range_map.rs:122:5
        |
    122 | /     pub fn iter_mut<'a>(
    123 | |         &'a mut self,
    124 | |         offset: Size,
    125 | |         len: Size,
    126 | |     ) -> impl Iterator<Item = (Size, &'a mut T)> + 'a
        | |_____________________________________________________^
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes

    error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
        --> src/shims/intrinsics.rs:1391:1
         |
    1391 | fn simd_element_to_bool<'tcx>(elem: ImmTy<'tcx, Tag>) -> InterpResult<'tcx, bool> {
         | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
2022-04-29 15:47:19 -07:00
David Tolnay
2ca7f3b45d
Resolve clippy::needless_borrow
error: this expression creates a reference which is immediately dereferenced by the compiler
       --> src/data_race.rs:565:34
        |
    565 |         this.validate_atomic_rmw(&place, atomic)?;
        |                                  ^^^^^^ help: change this to: `place`
        |
        = note: `-D clippy::needless-borrow` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
        --> src/data_race.rs:1413:27
         |
    1413 |         clocks.clock.join(&lock);
         |                           ^^^^^ help: change this to: `lock`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
       --> src/helpers.rs:326:51
        |
    326 |                         .size_and_align_of_mplace(&place)?
        |                                                   ^^^^^^ help: change this to: `place`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
       --> src/helpers.rs:365:17
        |
    365 |                 &self.ecx
        |                 ^^^^^^^^^ help: change this to: `self.ecx`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
       --> src/helpers.rs:634:47
        |
    634 |         let seconds_place = this.mplace_field(&tp, 0)?;
        |                                               ^^^ help: change this to: `tp`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
       --> src/helpers.rs:637:51
        |
    637 |         let nanoseconds_place = this.mplace_field(&tp, 1)?;
        |                                                   ^^^ help: change this to: `tp`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
       --> src/machine.rs:547:73
        |
    547 |         let link_name = match ecx.tcx.sess.first_attr_value_str_by_name(&attrs, sym::link_name) {
        |                                                                         ^^^^^^ help: change this to: `attrs`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
       --> src/machine.rs:576:56
        |
    576 |             Some(data_race::AllocExtra::new_allocation(&data_race, alloc.size(), kind))
        |                                                        ^^^^^^^^^^ help: change this to: `data_race`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
       --> src/shims/foreign_items.rs:241:43
        |
    241 |             .first_attr_value_str_by_name(&attrs, sym::link_name)
        |                                           ^^^^^^ help: change this to: `attrs`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
       --> src/shims/intrinsics.rs:778:61
        |
    778 |                         .read_immediate(&this.operand_index(&index, i)?.into())?
        |                                                             ^^^^^^ help: change this to: `index`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
        --> src/shims/intrinsics.rs:1195:44
         |
    1195 |                 this.write_immediate(*old, &dest)?; // old value is returned
         |                                            ^^^^^ help: change this to: `dest`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
        --> src/shims/intrinsics.rs:1200:44
         |
    1200 |                 this.write_immediate(*old, &dest)?; // old value is returned
         |                                            ^^^^^ help: change this to: `dest`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
      --> src/shims/posix/fs.rs:54:12
       |
    54 |         Ok(&self)
       |            ^^^^^ help: change this to: `self`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
       --> src/shims/posix/fs.rs:654:49
        |
    654 |                 let io_result = maybe_sync_file(&file, *writable, File::sync_all);
        |                                                 ^^^^^ help: change this to: `file`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
       --> src/shims/posix/fs.rs:746:52
        |
    746 |                 file_descriptor.write(communicate, &bytes)?.map(|c| i64::try_from(c).unwrap());
        |                                                    ^^^^^^ help: change this to: `bytes`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
        --> src/shims/posix/fs.rs:1494:45
         |
    1494 |             let io_result = maybe_sync_file(&file, *writable, File::sync_all);
         |                                             ^^^^^ help: change this to: `file`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
        --> src/shims/posix/fs.rs:1516:45
         |
    1516 |             let io_result = maybe_sync_file(&file, *writable, File::sync_data);
         |                                             ^^^^^ help: change this to: `file`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
        --> src/shims/posix/fs.rs:1561:45
         |
    1561 |             let io_result = maybe_sync_file(&file, *writable, File::sync_data);
         |                                             ^^^^^ help: change this to: `file`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
       --> src/shims/env.rs:232:65
        |
    232 |             let var_ptr = alloc_env_var_as_c_str(&name, &value, &mut this)?;
        |                                                                 ^^^^^^^^^ help: change this to: `this`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
       --> src/shims/env.rs:277:68
        |
    277 |             let var_ptr = alloc_env_var_as_wide_str(&name, &value, &mut this)?;
        |                                                                    ^^^^^^^^^ help: change this to: `this`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
       --> src/shims/env.rs:328:37
        |
    328 |         let buf = this.read_pointer(&buf_op)?;
        |                                     ^^^^^^^ help: change this to: `buf_op`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

    error: this expression creates a reference which is immediately dereferenced by the compiler
       --> src/shims/env.rs:329:37
        |
    329 |         let size = this.read_scalar(&size_op)?.to_machine_usize(&*this.tcx)?;
        |                                     ^^^^^^^^ help: change this to: `size_op`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
2022-04-29 15:43:14 -07:00
David Tolnay
16c2400737
Resolve clippy::mem_replace_with_default
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
      --> src/helpers.rs:54:29
       |
    54 |                 for item in mem::replace(&mut items, Default::default()).iter() {
       |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut items)`
       |
       = note: `-D clippy::mem-replace-with-default` implied by `-D clippy::all`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default
2022-04-29 15:39:56 -07:00
David Tolnay
168e87682f
Resolve clippy::len_zero
error: length comparison to one
       --> src/shims/posix/thread.rs:102:12
        |
    102 |         if args.len() < 1 {
        |            ^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `args.is_empty()`
        |
        = note: `-D clippy::len-zero` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
2022-04-29 15:38:42 -07:00
David Tolnay
1fa63f1e9b
Resolve clippy::extra_unused_lifetimes
error: this lifetime isn't used in the function definition
      --> src/helpers.rs:46:20
       |
    46 | fn try_resolve_did<'mir, 'tcx>(tcx: TyCtxt<'tcx>, path: &[&str]) -> Option<DefId> {
       |                    ^^^^
       |
       = note: `-D clippy::extra-unused-lifetimes` implied by `-D clippy::all`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes

    error: this lifetime isn't used in the function definition
      --> src/shims/posix/fs.rs:49:12
       |
    49 |     fn dup<'tcx>(&mut self) -> io::Result<Box<dyn FileDescriptor>>;
       |            ^^^^
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes

    error: this lifetime isn't used in the function definition
      --> src/shims/os_str.rs:81:41
       |
    81 |         pub fn u16vec_to_osstring<'tcx, 'a>(u16_vec: Vec<u16>) -> InterpResult<'tcx, OsString> {
       |                                         ^^
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes

    error: this lifetime isn't used in the function definition
      --> src/thread.rs:72:26
       |
    72 |     pub fn to_u32_scalar<'tcx>(&self) -> Scalar<Tag> {
       |                          ^^^^
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes
2022-04-29 15:38:12 -07:00
David Tolnay
9125cc1c28
Resolve clippy::clone_on_copy
error: using `clone` on type `std::option::Option<u128>` which implements the `Copy` trait
       --> src/shims/tls.rs:307:24
        |
    307 |         let last_key = this.machine.tls.dtors_running[&active_thread].last_dtor_key.clone();
        |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `this.machine.tls.dtors_running[&active_thread].last_dtor_key`
        |
        = note: `-D clippy::clone-on-copy` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

    error: using `clone` on type `stacked_borrows::Item` which implements the `Copy` trait
       --> src/stacked_borrows.rs:317:21
        |
    317 |                     item.clone(),
        |                     ^^^^^^^^^^^^ help: try dereferencing it: `*item`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
2022-04-29 15:37:35 -07:00
David Tolnay
0389745203
Resolve clippy::assign_op_pattern
error: manual implementation of an assign operation
       --> src/helpers.rs:673:17
        |
    673 |                 len = len + size1;
        |                 ^^^^^^^^^^^^^^^^^ help: replace it with: `len += size1`
        |
        = note: `-D clippy::assign-op-pattern` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assign_op_pattern
2022-04-29 15:36:58 -07:00
David Tolnay
b0a51720c6
Suppress all currently triggered clippy lints 2022-04-29 15:26:54 -07:00
Oli Scherer
a192a199a8 Rename flag, datastructure and messaging around muting stdout and stderr 2022-04-26 09:33:20 +00:00
Gary Guo
f8f776fee9 Update export_symbols 2022-04-25 22:12:57 +01:00
Oli Scherer
1d0fe1b6bb Implement the output dropping for windows, too 2022-04-25 14:22:55 +00:00
Oli Scherer
4d4855c762 Add a command line flag to avoid printing to stdout and stderr 2022-04-25 13:12:55 +00:00
Ralf Jung
b472ef5bd8
be explicit about types 2022-04-21 16:19:28 +02:00
y86-dev
bf17dbebc9 Added support for multiple tracked pointers, allocs and calls
- Changed arg parsing to handle comma seperated list of `u64`'s.
- Changed type and field names of config, executor and global state
  to hold a set of tracked ids.
- Adjusted Readme:
    - explained list format
    - arguments do not overwrite, instead append
    - no effect on duplication
- Created a parsing function for comma separated lists
- Added error printing to alloc_id parsing
2022-04-21 10:40:11 +02:00
Ralf Jung
f1023fbdc9 avoid into_pointer_or_addr and into_parts in visit_freeze_sensitive 2022-04-20 08:40:19 -04:00
Ralf Jung
ec1dc749a3 adjust for provenance cleanup 2022-04-20 08:40:19 -04:00
Ralf Jung
763ff1c49f do not consider thread-local allocations read-only 2022-04-19 14:56:07 -04:00
Ralf Jung
5a3ec3780e add size assertions for some core types 2022-04-17 21:58:36 -04:00
Ralf Jung
db2c4b6dfa implement strerror_r 2022-04-16 22:54:38 -04:00
Ralf Jung
0669b22759 rustup 2022-04-16 08:41:34 -04:00
Ralf Jung
507c09f45f use new format string syntax in some places 2022-04-09 11:32:49 -04:00
Ralf Jung
855af088b8 remove no longer needed imports 2022-04-09 11:32:49 -04:00
Ralf Jung
d2cb11cc15 rustup 2022-04-09 09:41:29 -04:00
bors
be72564a64 Auto merge of #2055 - RalfJung:rustup, r=RalfJung
Rustup

Fixes https://github.com/rust-lang/miri/issues/1717
2022-04-08 13:57:45 +00:00
Ralf Jung
c8553d8162 fix Windows stdout/stderr 2022-04-08 09:57:25 -04:00
Ralf Jung
cac48dd734 treat prctl like a variadic function 2022-04-07 16:20:19 -04:00
Ralf Jung
59ee672fef for variadic functions, accept arbitrary trailing arguments but make sure we check all leading arguments 2022-04-07 16:19:00 -04:00
Ralf Jung
e1556c8576 add machine hook tcx parameters 2022-04-07 15:05:47 -04:00
Mara Bos
03417de176 Use let = if; instead of let; if. 2022-04-06 23:55:02 +02:00
Mara Bos
53ed500c92 Fully support FUTEX_*_BITSET. 2022-04-06 23:48:14 +02:00
Mara Bos
12c88886b0 Formatting. 2022-04-06 23:13:47 +02:00
Mara Bos
37cefa32d2 Add support for FUTEX_WAIT_BITSET(bitset=MAX). 2022-04-06 23:03:52 +02:00
bors
955bacc103 Auto merge of #2047 - RalfJung:no-extras, r=RalfJung
adjust for MemoryExtra being merged into Machine

The Miri side of https://github.com/rust-lang/rust/pull/95620
2022-04-05 15:14:12 +00:00
Ralf Jung
6e1f3cd8ff adjust for MemoryExtra being merged into Machine 2022-04-05 11:11:53 -04:00
bors
ec51594521 Auto merge of #2046 - RalfJung:very-strict, r=RalfJung
make strict-provenance imply check-number-validity

I feel like Miri not catching [this example](https://github.com/rust-lang/unsafe-code-guidelines/issues/286#issuecomment-1085144431) with strict provenance checking enabled is surprising.

OTOH, Miri suddenly complaining about uninit data in integers with `-Zmiri-strict-provenance` also might be surprising. Which one is more surprising? I don't know. We *could* go out of our way and have a mode where uninit integers are okay but provenance is not, but I am not sure if that is truly worth it. It'd be quite annoying to implement.
2022-04-04 19:54:01 +00:00
Ralf Jung
830cc58f8a rustup 2022-04-03 20:00:03 -04:00
Ralf Jung
1d79b60a1e make strict-provenance imply check-number-validity 2022-04-01 23:59:16 -04:00
bors
732461b4cd Auto merge of #2045 - RalfJung:strict-provenance, r=RalfJung
add -Zmiri-strict-provenance

This implements [strict provenance](https://github.com/rust-lang/rust/issues/95228) in Miri. The only change is that casting an integer to a pointer does not even attempt to produce a good provenance for the given address; instead, it always uses the invalid provenance. This stricter than even `-Zmiri-tag-raw-pointers` in that it also rejects the following example (which does not even involve Stacked Borrows):
```rust
fn main() {
    let x = 22;
    let ptr = &x as *const _ as *const u8;
    let roundtrip = ptr as usize as *const u8;
    let _ = unsafe { roundtrip.offset(1) };
}
```
The new flag also implies `-Zmiri-tag-raw-pointers` since the only reason one would *not* want to tag raw pointers is to support ptr-int-ptr roundtrips.

Note that the flag does *not* check against ptr-to-int *transmutes*; that still requires `-Zmiri-check-number-validity`. You can also check for strict provenance *without* Stacked Borrows by adding `-Zmiri-disable-stacked-borrows`.

The new "Miri hard mode" flags for maximal checking are `-Zmiri-strict-provenance -Zmiri-check-number-validity`. (Add `-Zmiri-symbolic-alignment-check` if you feel extra spicy today.)
2022-04-01 22:40:26 +00:00
Ralf Jung
aa04dc1eeb Rust values can be up to isize::MAX in size 2022-04-01 17:22:01 -04:00
Ralf Jung
9af03bf342 add -Zmiri-strict-provenance 2022-04-01 14:10:24 -04:00
Ralf Jung
552b77e3b9 fix types in env shim to avoid ptr-int transmutes 2022-03-26 14:33:13 -04:00
Ralf Jung
65469fe85b test remove_dir_all 2022-03-20 10:36:27 -04:00
bors
57786678d4 Auto merge of #1975 - DrMeepster:backtrace_fix, r=RalfJung
Make backtraces work with #[global_allocator]

Currently, backtraces break when the global allocator is overridden because the allocator will attempt to deallocate memory allocated directly by Miri.

~~This PR fixes that by using a new memory kind and providing a function to deallocate it. We can't call the custom allocator to allocate because it's not possible to call a function in the middle of a shim.~~

This PR fixes that by adding a new version of the backtrace API accessible by setting `flags` to 1. Existing code still functions.

backtrace-rs PR: rust-lang/backtrace-rs#462

Fixes https://github.com/rust-lang/miri/issues/1996
2022-03-20 02:37:09 +00:00
DrMeepster
2c670b10df add new version of backtrace api using flags=1 2022-03-19 18:14:11 -07:00
Ben Kimock
65125df1cd Consider the cargo workspace when checking if a frame is local 2022-03-18 16:28:13 -04:00
Ralf Jung
1b1321a685 fix simd_bitmask shorter than a byte on big-endian 2022-03-17 13:14:16 -04:00
Ralf Jung
b5d3a25b49 detect when unused bits of a SIMD bitmask are non-0 2022-03-17 13:08:01 -04:00
Ralf Jung
bfed3c4f0d implement simd bitmask intrinsics 2022-03-17 13:08:01 -04:00
bors
670dc7d551 Auto merge of #1971 - saethlin:sb-details, r=RalfJung
Add a lot more information to SB fatal errors

In fatal errors, this clarifies the difference between a tag not being present in the borrow stack at all, and the tag being present but granting SRO. It also introduces a little notation for memory ranges so we can mention to the user that the span may point to code that operates on multiple memory locations, but we are reporting an error at a particular offset.

This also gets rid of the unqualified phrase "the borrow stack" in errors, and clarifies that it is the borrow stack _for some location_.

The crate `pdqselect` v0.1.1:
Before:
```
2103 |     unsafe { copy_nonoverlapping(src, dst, count) }
     |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item granting read access to tag <2357> at alloc1029 found in borrow stack.
```
After:
```
2103 |     unsafe { copy_nonoverlapping(src, dst, count) }
     |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |              |
     |              attempting a read access using <2357> at alloc1029[0x0], but that tag does not exist in the borrow stack for this location
     |              this error occurs as part of an access at alloc1029[0x0..0x4]
```

And the crate `half` v1.8.2
Before:
```
131 |     unsafe { &mut *ptr::slice_from_raw_parts_mut(data, len) }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to reborrow for Unique at alloc1051, but parent tag <2091> does not have an appropriate item in the borrow stack
```
After:
```
131 |     unsafe { &mut *ptr::slice_from_raw_parts_mut(data, len) }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |              |
    |              trying to reborrow <2091> for Unique permission at alloc1051[0x0], but that tag only grants SharedReadOnly permission for this location
    |              this error occurs as part of a reborrow at alloc1051[0x0..0x6]
```
2022-03-17 13:26:29 +00:00
Ralf Jung
4fd5dca27c implement SIMD sqrt and fma 2022-03-16 22:13:43 -04:00
Ben Kimock
730cd27248 Print more in SB error diagnostics
This tries to clarify exactly why an access is not valid by printing
what memory range the access was over, which in combination with
tag-tracking may help a user figure out the source of the problem.
2022-03-16 20:12:04 -04:00
Ralf Jung
1f237b3b7d implement SIMD float rounding functions 2022-03-16 18:53:36 -04:00
Ralf Jung
202964127b implement fabs using soft floats 2022-03-16 18:33:59 -04:00
Jake Vossen
559e495195 missing backtick on miri-isolation warning help 2022-03-16 10:18:51 -06:00
bors
a12a48bf72 Auto merge of #2018 - RalfJung:term, r=oli-obk
exclude TERM env var by default

Fixes https://github.com/rust-lang/miri/issues/1702

r? `@oli-obk`
2022-03-12 19:12:53 +00:00
bors
9029fa4aa9 Auto merge of #2021 - RalfJung:write-fields-refactor, r=RalfJung
add write_int_fields to replace write_packed_immediates

This avoids having to explicitly list the types of all fields -- we derive them from the type of the struct instead.

Also add write_int_fields_named, to give the fields by name instead of ordered by index.
2022-03-12 17:18:24 +00:00
Ralf Jung
47f8218d0d add write_int_fields to replace write_packed_immediates
for stat, lookup fields by name
2022-03-12 12:17:23 -05:00
Ralf Jung
4bd6bc9098 use dirent64_layout and field projections for writing dirent info 2022-03-12 12:03:33 -05:00
Ralf Jung
3c5cb89f63 exclude TERM by default 2022-03-12 10:14:07 -05:00
Ralf Jung
9a6450af95 also accept odd number of hex digits; add README section on randomized alignment testing 2022-03-12 10:09:15 -05:00
Ralf Jung
27d5b846ee rustup 2022-03-12 09:46:10 -05:00
Ralf Jung
41ffce1145 implement simd_scatter 2022-03-09 19:29:05 -05:00
Ralf Jung
576e2bbed5 implement gather 2022-03-09 19:29:05 -05:00
Ralf Jung
3eba7fcf73 implement simd_shuffle 2022-03-09 19:29:05 -05:00
Ralf Jung
d54c5fb668 rustup 2022-03-07 20:07:44 -05:00
Ralf Jung
6d3506adef fs: add and test for DirectoryNotEmpty error variant 2022-03-07 18:30:12 -05:00
Tavian Barnes
0886419524 Implement a readdir64() shim for Linux
Partial fix for #1966.
2022-03-07 16:19:03 -05:00
Tavian Barnes
0088715411 Rename MiriMemoryKind::Env to Runtime
In preparation to use it for other runtime-internal allocations.
2022-03-07 16:19:03 -05:00
Ralf Jung
735bee2736 implement simd_saturating intrinsics 2022-03-07 14:12:59 -05:00
Ralf Jung
b87a9c90e1 fix handling of NaNs in simd max/min 2022-03-07 09:49:35 -05:00
Ralf Jung
2f97eb68a0 implement simd_fmax/fmin 2022-03-07 09:40:23 -05:00
Ralf Jung
9851b743c1 implement simd_reduce_min/max 2022-03-07 09:40:23 -05:00
Ralf Jung
db06d4998f implement simd_cast, simd_as 2022-03-07 09:40:23 -05:00
Ralf Jung
594a70a289 rustup 2022-03-07 09:39:32 -05:00
Ralf Jung
b491b72673 implement simd_reduce_{add,mul} 2022-03-05 19:02:00 -05:00
Ralf Jung
3ed8ad4423 avoid repeated string matching, and add more simd_reduce intrinsics 2022-03-05 18:46:14 -05:00
bors
3854a76ace Auto merge of #1970 - asquared31415:open_unix_varargs, r=RalfJung
Allow varargs for libc::open when it is allowed by the second argument

This PR allows `libc::open` to be called using two or three arguments as defined in https://man7.org/linux/man-pages/man2/open.2.html

The presence of the third argument depends on the value of the second argument.  If the second argument dictates that the third argument is *required* miri will emit an error if the argument is missing.  If the second argument does *not* require a third argument, then the argument is ignored and passed as 0 internally (it would be ignored by libc anyway)
2022-03-05 22:47:51 +00:00
asquared31415
8e97599af4 allow varargs for libc::open when it is allowed by the second argument 2022-03-05 17:29:48 -05:00
bors
926af6493b Auto merge of #1999 - RalfJung:forward-env, r=oli-obk
add flag to forward specific env vars (while isolation remains enabled)

The flag is called `-Zmiri-env-forward=<var>`, but I am open to bikeshedding. ;)
2022-03-05 19:36:10 +00:00
Ralf Jung
90207a5484 implement missing SIMD comparison operators, simd_xor, and simd_reduce_all 2022-03-05 13:45:13 -05:00
Ralf Jung
ceec2b3ceb avoid env var forwarding logic panicking for non-UTF-8 env vars 2022-03-05 11:14:37 -05:00
Ralf Jung
3adc203c1c add flag to forward specific env vars (while isolation remains enabled) 2022-03-05 11:14:37 -05:00
Ralf Jung
0d4902f12f implement simd_neg and simd_fabs 2022-03-03 14:54:54 -05:00
Ralf Jung
0147b88ce5 use binary_op over overflowing_binary_op 2022-03-03 14:44:50 -05:00