Skip to content

Commit

Permalink
Auto merge of rust-lang#102995 - JohnTitor:rollup-yomkwge, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 7 pull requests

Successful merges:

 - rust-lang#102641 (Support casting boxes to dyn*)
 - rust-lang#102836 (rustc_target: Fix json target specs using LLD linker flavors in link args)
 - rust-lang#102949 (should-skip-this: add missing backslash)
 - rust-lang#102967 (Add test for issue 102964)
 - rust-lang#102971 (tidy: error if a lang feature is already present)
 - rust-lang#102974 (Fix small word dupe typos)
 - rust-lang#102980 (rustdoc: merge separate `.item-info` CSS)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Oct 13, 2022
2 parents 2a92176 + e802936 commit 3cf5fc5
Show file tree
Hide file tree
Showing 25 changed files with 226 additions and 159 deletions.
9 changes: 9 additions & 0 deletions compiler/rustc_codegen_ssa/src/mir/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use rustc_middle::ty::cast::{CastTy, IntTy};
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
use rustc_middle::ty::{self, adjustment::PointerCast, Instance, Ty, TyCtxt};
use rustc_span::source_map::{Span, DUMMY_SP};
use rustc_target::abi::Size;

impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
#[instrument(level = "trace", skip(self, bx))]
Expand Down Expand Up @@ -285,6 +286,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
bug!("Only valid to do a DynStar cast into a DynStar type")
};
let vtable = get_vtable(bx.cx(), source.ty(self.mir, bx.tcx()), trait_ref);
let vtable = bx.pointercast(vtable, bx.cx().type_ptr_to(bx.cx().type_isize()));
// FIXME(dyn-star): this is probably not the best way to check if this is
// a pointer, and really we should ensure that the value is a suitable
// pointer earlier in the compilation process.
let data = match operand.layout.pointee_info_at(bx.cx(), Size::ZERO) {
Some(_) => bx.ptrtoint(data, bx.cx().type_isize()),
None => data,
};
OperandValue::Pair(data, vtable)
}
mir::CastKind::Pointer(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_error_codes/src/error_codes/E0591.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ unsafe {
```

Here, transmute is being used to convert the types of the fn arguments.
This pattern is incorrect because, because the type of `foo` is a function
**item** (`typeof(foo)`), which is zero-sized, and the target type (`fn()`)
This pattern is incorrect because the type of `foo` is a function **item**
(`typeof(foo)`), which is zero-sized, and the target type (`fn()`)
is a function pointer, which is not zero-sized.
This pattern should be rewritten. There are a few possible ways to do this:

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ impl<'tcx> InferCtxt<'tcx> {
assert!(old_value.is_none());
}

/// Process the region constraints and return any any errors that
/// Process the region constraints and return any errors that
/// result. After this, no more unification operations should be
/// done -- or the compiler will panic -- but it is legal to use
/// `resolve_vars_if_possible` as well as `fully_resolve`.
Expand Down
14 changes: 9 additions & 5 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1739,11 +1739,15 @@ impl TargetOptions {
self.lld_flavor_json,
self.linker_is_gnu_json,
);
match linker_flavor {
LinkerFlavor::Gnu(_, Lld::Yes)
| LinkerFlavor::Darwin(_, Lld::Yes)
| LinkerFlavor::Msvc(Lld::Yes) => {}
_ => add_link_args_iter(args, linker_flavor, args_json.iter().cloned()),
// Normalize to no lld to avoid asserts.
let linker_flavor = match linker_flavor {
LinkerFlavor::Gnu(cc, _) => LinkerFlavor::Gnu(cc, Lld::No),
LinkerFlavor::Darwin(cc, _) => LinkerFlavor::Darwin(cc, Lld::No),
LinkerFlavor::Msvc(_) => LinkerFlavor::Msvc(Lld::No),
_ => linker_flavor,
};
if !args.contains_key(&linker_flavor) {
add_link_args_iter(args, linker_flavor, args_json.iter().cloned());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/io/error/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fn test_errorkind_packing() {
assert_eq!(Error::from(ErrorKind::NotFound).kind(), ErrorKind::NotFound);
assert_eq!(Error::from(ErrorKind::PermissionDenied).kind(), ErrorKind::PermissionDenied);
assert_eq!(Error::from(ErrorKind::Uncategorized).kind(), ErrorKind::Uncategorized);
// Check that the innards look like like what we want.
// Check that the innards look like what we want.
assert_matches!(
Error::from(ErrorKind::OutOfMemory).repr.data(),
ErrorData::Simple(ErrorKind::OutOfMemory),
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/unix/kernel_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//! Since those syscalls have requirements that cannot be fully checked in advance and
//! gathering additional information about file descriptors would require additional syscalls
//! anyway it simply attempts to use them one after another (guided by inaccurate hints) to
//! figure out which one works and and falls back to the generic read-write copy loop if none of them
//! figure out which one works and falls back to the generic read-write copy loop if none of them
//! does.
//! Once a working syscall is found for a pair of file descriptors it will be called in a loop
//! until the copy operation is completed.
Expand Down
2 changes: 1 addition & 1 deletion src/ci/scripts/should-skip-this.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if [[ -n "${CI_ONLY_WHEN_SUBMODULES_CHANGED-}" ]]; then
# those files are present in the diff a submodule was updated.
echo "Submodules were updated"
elif ! (git diff --quiet "$BASE_COMMIT" -- \
src/tools/clippy src/tools/rustfmt src/tools/miri
src/tools/clippy src/tools/rustfmt src/tools/miri \
library/std/src/sys); then
# There is not an easy blanket search for subtrees. For now, manually list
# the subtrees.
Expand Down
9 changes: 3 additions & 6 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -692,16 +692,13 @@ pre, .rustdoc.source .example-wrap {

.item-info {
display: block;
margin-left: 24px;
}

.content .item-info code {
.item-info code {
font-size: 0.875rem;
}

.content .item-info {
margin-left: 24px;
}

#main-content > .item-info {
margin-top: 0;
margin-left: 0;
Expand Down Expand Up @@ -1945,7 +1942,7 @@ in storage.js plus the media query with (min-width: 701px)
}

/* Align summary-nested and unnested item-info gizmos. */
.content .impl-items > .item-info {
.impl-items > .item-info {
margin-left: 34px;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/async-await/issue-64130-1-sync.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![feature(negative_impls)]
// edition:2018

// This tests the the specialized async-await-specific error when futures don't implement an
// This tests the specialized async-await-specific error when futures don't implement an
// auto trait (which is specifically Sync) due to some type that was captured.

struct Foo;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/async-await/issue-64130-2-send.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![feature(negative_impls)]
// edition:2018

// This tests the the specialized async-await-specific error when futures don't implement an
// This tests the specialized async-await-specific error when futures don't implement an
// auto trait (which is specifically Send) due to some type that was captured.

struct Foo;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/async-await/issue-64130-3-other.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![feature(negative_impls)]
// edition:2018

// This tests the the unspecialized async-await-specific error when futures don't implement an
// This tests the unspecialized async-await-specific error when futures don't implement an
// auto trait (which is not Send or Sync) due to some type that was captured.

auto trait Qux {}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/const-generics/occurs-check/unused-substs-2.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

// The goal is is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(_#1t)` subst.
// The goal is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(_#1t)` subst.
//
// If we are then able to infer `ty::Infer(TyVar(_#1t) := Ty<ct>` we introduced an
// artificial inference cycle.
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/const-generics/occurs-check/unused-substs-3.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

// The goal is is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(_#1t)` subst.
// The goal is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(_#1t)` subst.
//
// If we are then able to infer `ty::Infer(TyVar(_#1t) := Ty<ct>` we introduced an
// artificial inference cycle.
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/deprecation/deprecation-lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ mod cross_crate {

let _ = nested::DeprecatedTupleStruct (1); //~ ERROR use of deprecated tuple struct `deprecation_lint::nested::DeprecatedTupleStruct`: text

// At the moment, the lint checker only checks stability in
// At the moment, the lint checker only checks stability
// in the arguments of macros.
// Eventually, we will want to lint the contents of the
// macro in the module *defining* it. Also, stability levels
Expand Down
17 changes: 17 additions & 0 deletions src/test/ui/dyn-star/box.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// run-pass
// compile-flags: -C opt-level=0

#![feature(dyn_star)]
#![allow(incomplete_features)]

use std::fmt::Display;

fn make_dyn_star() -> dyn* Display {
Box::new(42) as dyn* Display
}

fn main() {
let x = make_dyn_star();

println!("{x}");
}
4 changes: 2 additions & 2 deletions src/test/ui/explain.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ unsafe {
```

Here, transmute is being used to convert the types of the fn arguments.
This pattern is incorrect because, because the type of `foo` is a function
**item** (`typeof(foo)`), which is zero-sized, and the target type (`fn()`)
This pattern is incorrect because the type of `foo` is a function **item**
(`typeof(foo)`), which is zero-sized, and the target type (`fn()`)
is a function pointer, which is not zero-sized.
This pattern should be rewritten. There are a few possible ways to do this:

Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/issues/issue-102964.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use std::rc::Rc;
type Foo<'a, T> = &'a dyn Fn(&T);
type RcFoo<'a, T> = Rc<Foo<'a, T>>;

fn bar_function<T>(function: Foo<T>) -> RcFoo<T> {
//~^ ERROR mismatched types
let rc = Rc::new(function);
}

fn main() {}
19 changes: 19 additions & 0 deletions src/test/ui/issues/issue-102964.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0308]: mismatched types
--> $DIR/issue-102964.rs:5:41
|
LL | fn bar_function<T>(function: Foo<T>) -> RcFoo<T> {
| ------------ ^^^^^^^^ expected struct `Rc`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
|
= note: expected struct `Rc<&dyn for<'a> Fn(&'a T)>`
found unit type `()`
help: consider returning the local binding `rc`
|
LL ~ let rc = Rc::new(function);
LL + rc
|

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-29746.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ macro_rules! zip {
zip!([$($rest),*], $a.zip($b), (x,y), [x,y])
};

// Intermediate steps to build the zipped expression, the match pattern, and
// Intermediate steps to build the zipped expression, the match pattern
// and the output tuple of the closure, using macro hygiene to repeatedly
// introduce new variables named 'x'.
([$a:expr, $($rest:expr),*], $zip:expr, $pat:pat, [$($flat:expr),*]) => {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-75907.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Test for for diagnostic improvement issue #75907
// Test for diagnostic improvement issue #75907

mod foo {
pub(crate) struct Foo(u8);
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-75907_b.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Test for for diagnostic improvement issue #75907, extern crate
// Test for diagnostic improvement issue #75907, extern crate
// aux-build:issue-75907.rs

extern crate issue_75907 as a;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/lint/lint-stability-deprecated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ mod cross_crate {
let _ = UnstableTupleStruct (1);
let _ = StableTupleStruct (1);

// At the moment, the lint checker only checks stability in
// At the moment, the lint checker only checks stability
// in the arguments of macros.
// Eventually, we will want to lint the contents of the
// macro in the module *defining* it. Also, stability levels
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/proc-macro/meta-macro-hygiene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ macro_rules! produce_it {
// `print_def_site!` will respan the `$crate` identifier
// with `Span::def_site()`. This should cause it to resolve
// relative to `meta_macro`, *not* `make_macro` (despite
// the fact that that `print_def_site` is produced by
// a `macro_rules!` macro in `make_macro`).
// the fact that `print_def_site` is produced by a
// `macro_rules!` macro in `make_macro`).
meta_macro::print_def_site!($crate::dummy!());
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/proc-macro/meta-macro-hygiene.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ macro_rules! produce_it
// `print_def_site!` will respan the `$crate` identifier
// with `Span::def_site()`. This should cause it to resolve
// relative to `meta_macro`, *not* `make_macro` (despite
// the fact that that `print_def_site` is produced by
// a `macro_rules!` macro in `make_macro`).
// the fact that `print_def_site` is produced by a
// `macro_rules!` macro in `make_macro`).
}
}

Expand Down
Loading

0 comments on commit 3cf5fc5

Please sign in to comment.