Skip to content
Closed
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
16768e5
Add the two licences to LICENCES/ that `reuse` reported missing
jonathanpallant Nov 21, 2023
ce0051a
include submodules in the collected license metadata
pietroalbini Mar 13, 2023
d45eac3
Report missing licenses or copyright text.
jonathanpallant Nov 21, 2023
c6eb03b
condense llvm licensing into a single item
jonathanpallant Nov 22, 2023
daf6121
Put copyright on a line by itself.
jonathanpallant Nov 22, 2023
2d1cd45
Fix generate-copyright tool.
jonathanpallant Nov 22, 2023
7a49ac5
Add missing CC-BY-SA-4.0.
jonathanpallant Nov 22, 2023
c1577e5
Update reuse command to include submodules.
jonathanpallant Nov 23, 2023
efa4416
Change LLVM reuse dep5 line to say AND.
jonathanpallant Nov 29, 2023
f2f5d23
codegen: panic when trying to compute size/align of extern type
RalfJung Dec 2, 2023
ef73668
reject projecting to fields whose offset we cannot compute
RalfJung Dec 2, 2023
564fb4a
remove a cranelift test that doesn't make sense any more
RalfJung Dec 2, 2023
9f0c6f1
Simplify and comment the special-casing for Windows colors
jyn514 Dec 8, 2023
96b027f
use magenta instead of bold for highlighting
jyn514 Dec 8, 2023
32e48fc
use different revisions for testing colors on windows
jyn514 Dec 9, 2023
f4d8faa
make it more clear what comments refer to; avoid dangling unaligned r…
RalfJung Dec 11, 2023
5f5e6b9
test that both size_of_val and align_of_val panic
RalfJung Dec 11, 2023
289044f
also test projecting to some sized fields at non-zero offset in struc…
RalfJung Dec 11, 2023
3415957
also add a Miri test
RalfJung Dec 11, 2023
eba02ab
Reinstate the names of the Ayu dark theme developers.
jonathanpallant Dec 11, 2023
0564de1
remove some redundant clones
matthiaskrgr Dec 11, 2023
ef1831a
End locals' live range before suspending coroutine
tmiasko Dec 9, 2023
eaaa290
Remove redundant special case for resume argument
tmiasko Dec 10, 2023
0a65dd3
Monomorphize args while building Instance body
celinval Dec 11, 2023
b9d9cc5
Wesley is not on vacation
wesleywiser Dec 12, 2023
189f764
Rollup merge of #118445 - ferrocene:jp-support-reuse-in-submodules, r…
compiler-errors Dec 12, 2023
b422c11
Rollup merge of #118534 - RalfJung:extern-type-size-of-val, r=WaffleL…
compiler-errors Dec 12, 2023
b4dee53
Rollup merge of #118756 - jyn514:colors, r=estebank
compiler-errors Dec 12, 2023
8f117dc
Rollup merge of #118797 - tmiasko:dead-coro, r=davidtwco
compiler-errors Dec 12, 2023
a677f2d
Rollup merge of #118840 - matthiaskrgr:cloooooone, r=compiler-errors
compiler-errors Dec 12, 2023
7a4bc59
Rollup merge of #118844 - celinval:smir-mono-args, r=compiler-errors
compiler-errors Dec 12, 2023
baa11d1
Rollup merge of #118848 - wesleywiser:vacation, r=wesleywiser
compiler-errors Dec 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 37 additions & 11 deletions .reuse/dep5
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# WARNING: this metadata is currently incomplete, do not rely on it yet.

Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Files-Excluded:
src/llvm-project

# Note that we're explicitly listing the individual files at the root of the
# repository rather than just having `Files: *`. This is explicitly done to
@@ -39,13 +37,8 @@ Files: compiler/*
Copyright: The Rust Project Developers (see https://thanks.rust-lang.org)
License: MIT or Apache-2.0

Files: compiler/rustc_codegen_cranelift/src/cranelift_native.rs
Copyright: The Cranelift Project Developers
The Rust Project Developers (see https://thanks.rust-lang.org)
License: Apache-2.0 WITH LLVM-exception AND (Apache-2.0 OR MIT)

Files: compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp
Copyright: LLVM authors
Copyright: 2003-2019 University of Illinois at Urbana-Champaign.
The Rust Project Developers (see https://thanks.rust-lang.org)
License: Apache-2.0 WITH LLVM-exception AND (Apache-2.0 OR MIT)

@@ -85,11 +78,44 @@ Files: src/librustdoc/html/static/css/normalize.css
Copyright: Nicolas Gallagher and Jonathan Neal
License: MIT

Files: src/librustdoc/html/static/css/themes/ayu.css
Copyright: Ike Ku, Jessica Stokes, Leon Guan
Files: src/librustdoc/html/static/css/rustdoc.css
Copyright: 2016 Ike Ku, Jessica Stokes and Leon Guan
The Rust Project Developers (see https://thanks.rust-lang.org)
License: MIT OR Apache-2.0

Files: src/doc/rustc-dev-guide/mermaid.min.js
Copyright: Knut Sveidqvist
Copyright: 2014-2021 Knut Sveidqvist
License: MIT

Files: library/backtrace/*
Copyright: 2014 Alex Crichton
The Rust Project Developers (see https://thanks.rust-lang.org)
License: MIT OR Apache-2.0

Files: src/doc/embedded-book/*
Copyright: Rust on Embedded Devices Working Group
The Rust Project Developers (see https://thanks.rust-lang.org)
License: MIT OR Apache-2.0 OR CC-BY-SA-4.0

Files: src/doc/rust-by-example/*
Copyright: 2014 Jorge Aparicio
The Rust Project Developers (see https://thanks.rust-lang.org)
License: MIT OR Apache-2.0

# Reuse cannot process the LLVM source tree, and so the copyrights for the LLVM
# submodule are written out here manually. The collect-licence-metadata tool
# has a specific exception coded within it to ignore ./src/llvm-project so
# any time LLVM is updated, please revisit this section. The copyrights are
# taken from the relevant LLVM sub-folders: llvm, lld, lldb, compiler-rt and libunwind.
#
# The git hash for the CREDITS.TXT file is taken from the current git submodule
# commit for ./src/llvm-project.
#
# The copyright years were compiled by looking at all the relevant
# ./src/llvm-project/*/LICENSE.txt files

Files: src/llvm-project/*
Copyright: 2003-2019 by the contributors listed in [CREDITS.TXT](https://github.com/rust-lang/llvm-project/blob/7738295178045041669876bf32b0543ec8319a5c/llvm/CREDITS.TXT)
2010 Apple Inc
2003-2019 University of Illinois at Urbana-Champaign.
License: NCSA AND Apache-2.0 WITH LLVM-exception
319 changes: 319 additions & 0 deletions LICENSES/CC-BY-3.0.txt

Large diffs are not rendered by default.

427 changes: 427 additions & 0 deletions LICENSES/CC-BY-SA-4.0.txt

Large diffs are not rendered by default.

121 changes: 121 additions & 0 deletions LICENSES/CC0-1.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
Creative Commons Legal Code

CC0 1.0 Universal

CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.

Statement of Purpose

The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").

Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.

For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.

1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:

i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.

2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.

3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.

4. Limitations and Disclaimers.

a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
29 changes: 29 additions & 0 deletions LICENSES/NCSA.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Copyright (c) <YEAR> <OWNER ORGANIZATION NAME>. All rights reserved.

Developed by: <NAME OF DEVELOPMENT GROUP>
<NAME OF INSTITUTION>
<URL FOR DEVELOPMENT GROUP/INSTITUTION>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal with
the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to
do so, subject to the following conditions:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimers.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimers in the documentation
and/or other materials provided with the distribution.
* Neither the names of <NAME OF DEVELOPMENT GROUP>, <NAME OF INSTITUTION>,
nor the names of its contributors may be used to endorse or promote products
derived from this Software without specific prior written permission.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
SOFTWARE.

2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
@@ -1204,7 +1204,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
};
err.multipart_suggestion_verbose(
msg,
sugg.clone(),
sugg,
Applicability::MaybeIncorrect,
);
for error in errors {
5 changes: 0 additions & 5 deletions compiler/rustc_codegen_cranelift/build_system/tests.rs
Original file line number Diff line number Diff line change
@@ -75,11 +75,6 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
"example/arbitrary_self_types_pointers_and_wrappers.rs",
&[],
),
TestCase::build_bin_and_run(
"aot.issue_91827_extern_types",
"example/issue-91827-extern-types.rs",
&[],
),
TestCase::build_lib("build.alloc_system", "example/alloc_system.rs", "lib"),
TestCase::build_bin_and_run("aot.alloc_example", "example/alloc_example.rs", &[]),
TestCase::jit_bin("jit.std_example", "example/std_example.rs", ""),

This file was deleted.

2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/lib.rs
Original file line number Diff line number Diff line change
@@ -51,10 +51,10 @@ pub mod codegen_attrs;
pub mod common;
pub mod debuginfo;
pub mod errors;
pub mod glue;
pub mod meth;
pub mod mir;
pub mod mono_item;
pub mod size_of_val;
pub mod target_features;
pub mod traits;

22 changes: 9 additions & 13 deletions compiler/rustc_codegen_ssa/src/mir/intrinsic.rs
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@ use super::FunctionCx;
use crate::common::IntPredicate;
use crate::errors;
use crate::errors::InvalidMonomorphization;
use crate::glue;
use crate::meth;
use crate::size_of_val;
use crate::traits::*;
use crate::MemFlags;

@@ -88,21 +88,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
sym::va_end => bx.va_end(args[0].immediate()),
sym::size_of_val => {
let tp_ty = fn_args.type_at(0);
if let OperandValue::Pair(_, meta) = args[0].val {
let (llsize, _) = glue::size_and_align_of_dst(bx, tp_ty, Some(meta));
llsize
} else {
bx.const_usize(bx.layout_of(tp_ty).size.bytes())
}
let meta =
if let OperandValue::Pair(_, meta) = args[0].val { Some(meta) } else { None };
let (llsize, _) = size_of_val::size_and_align_of_dst(bx, tp_ty, meta);
llsize
}
sym::min_align_of_val => {
let tp_ty = fn_args.type_at(0);
if let OperandValue::Pair(_, meta) = args[0].val {
let (_, llalign) = glue::size_and_align_of_dst(bx, tp_ty, Some(meta));
llalign
} else {
bx.const_usize(bx.layout_of(tp_ty).align.abi.bytes())
}
let meta =
if let OperandValue::Pair(_, meta) = args[0].val { Some(meta) } else { None };
let (_, llalign) = size_of_val::size_and_align_of_dst(bx, tp_ty, meta);
llalign
}
sym::vtable_size | sym::vtable_align => {
let vtable = args[0].immediate();
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/src/mir/operand.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ use super::place::PlaceRef;
use super::{FunctionCx, LocalRef};

use crate::base;
use crate::glue;
use crate::size_of_val;
use crate::traits::*;
use crate::MemFlags;

@@ -466,13 +466,13 @@ impl<'a, 'tcx, V: CodegenObject> OperandValue<V> {
.ty;

let OperandValue::Ref(llptr, Some(llextra), _) = self else {
bug!("store_unsized called with a sized value")
bug!("store_unsized called with a sized value (or with an extern type)")
};

// Allocate an appropriate region on the stack, and copy the value into it. Since alloca
// doesn't support dynamic alignment, we allocate an extra align - 1 bytes, and align the
// pointer manually.
let (size, align) = glue::size_and_align_of_dst(bx, unsized_ty, Some(llextra));
let (size, align) = size_of_val::size_and_align_of_dst(bx, unsized_ty, Some(llextra));
let one = bx.const_usize(1);
let align_minus_1 = bx.sub(align, one);
let size_extra = bx.add(size, align_minus_1);
23 changes: 9 additions & 14 deletions compiler/rustc_codegen_ssa/src/mir/place.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ use super::operand::OperandValue;
use super::{FunctionCx, LocalRef};

use crate::common::IntPredicate;
use crate::glue;
use crate::size_of_val;
use crate::traits::*;

use rustc_middle::mir;
@@ -99,6 +99,8 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
let offset = self.layout.fields.offset(ix);
let effective_field_align = self.align.restrict_for_offset(offset);

// `simple` is called when we don't need to adjust the offset to
// the dynamic alignment of the field.
let mut simple = || {
let llval = match self.layout.abi {
_ if offset.bytes() == 0 => {
@@ -141,28 +143,21 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
};

// Simple cases, which don't need DST adjustment:
// * no metadata available - just log the case
// * known alignment - sized types, `[T]`, `str` or a foreign type
// * known alignment - sized types, `[T]`, `str`
// * offset 0 -- rounding up to alignment cannot change the offset
// Note that looking at `field.align` is incorrect since that is not necessarily equal
// to the dynamic alignment of the type.
match field.ty.kind() {
_ if self.llextra.is_none() => {
debug!(
"unsized field `{}`, of `{:?}` has no metadata for adjustment",
ix, self.llval
);
return simple();
}
_ if field.is_sized() => return simple(),
ty::Slice(..) | ty::Str | ty::Foreign(..) => return simple(),
ty::Slice(..) | ty::Str => return simple(),
_ if offset.bytes() == 0 => return simple(),
_ => {}
}

// We need to get the pointer manually now.
// We do this by casting to a `*i8`, then offsetting it by the appropriate amount.
// We do this instead of, say, simply adjusting the pointer from the result of a GEP
// because the field may have an arbitrary alignment in the LLVM representation
// anyway.
// because the field may have an arbitrary alignment in the LLVM representation.
//
// To demonstrate:
//
@@ -179,7 +174,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
let unaligned_offset = bx.cx().const_usize(offset.bytes());

// Get the alignment of the field
let (_, mut unsized_align) = glue::size_and_align_of_dst(bx, field.ty, meta);
let (_, mut unsized_align) = size_of_val::size_and_align_of_dst(bx, field.ty, meta);

// For packed types, we need to cap alignment.
if let ty::Adt(def, _) = self.layout.ty.kind()
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
//!
//
// Code relating to drop glue.
//! Computing the size and alignment of a value.
use crate::common;
use crate::common::IntPredicate;
use crate::meth;
use crate::traits::*;
use rustc_hir::LangItem;
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
use rustc_middle::ty::{self, Ty};
use rustc_target::abi::WrappingRange;

@@ -14,7 +15,7 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
info: Option<Bx::Value>,
) -> (Bx::Value, Bx::Value) {
let layout = bx.layout_of(t);
debug!("size_and_align_of_dst(ty={}, info={:?}): layout: {:?}", t, info, layout);
trace!("size_and_align_of_dst(ty={}, info={:?}): layout: {:?}", t, info, layout);
if layout.is_sized() {
let size = bx.const_usize(layout.size.bytes());
let align = bx.const_usize(layout.align.abi.bytes());
@@ -51,7 +52,31 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx.const_usize(unit.align.abi.bytes()),
)
}
_ => {
ty::Foreign(_) => {
// `extern` type. We cannot compute the size, so panic.
let msg_str = with_no_visible_paths!({
with_no_trimmed_paths!({
format!("attempted to compute the size or alignment of extern type `{t}`")
})
});
let msg = bx.const_str(&msg_str);

// Obtain the panic entry point.
let (fn_abi, llfn) = common::build_langcall(bx, None, LangItem::PanicNounwind);

// Generate the call.
// Cannot use `do_call` since we don't have a MIR terminator so we can't create a `TerminationCodegenHelper`.
// (But we are in good company, this code is duplicated plenty of times.)
let fn_ty = bx.fn_decl_backend_type(fn_abi);

bx.call(fn_ty, /* fn_attrs */ None, Some(fn_abi), llfn, &[msg.0, msg.1], None);

// This function does not return so we can now return whatever we want.
let size = bx.const_usize(layout.size.bytes());
let align = bx.const_usize(layout.align.abi.bytes());
(size, align)
}
ty::Adt(..) | ty::Tuple(..) => {
// First get the size of all statically known fields.
// Don't use size_of because it also rounds up to alignment, which we
// want to avoid, as the unsized field's alignment could be smaller.
@@ -122,5 +147,6 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(

(size, align)
}
_ => bug!("size_and_align_of_dst: {t} not supported"),
}
}
11 changes: 7 additions & 4 deletions compiler/rustc_const_eval/src/interpret/projection.rs
Original file line number Diff line number Diff line change
@@ -174,12 +174,15 @@ where
};
(base_meta, offset.align_to(align))
}
None => {
// For unsized types with an extern type tail we perform no adjustments.
// NOTE: keep this in sync with `PlaceRef::project_field` in the codegen backend.
assert!(matches!(base_meta, MemPlaceMeta::None));
None if offset == Size::ZERO => {
// If the offset is 0, then rounding it up to alignment wouldn't change anything,
// so we can do this even for types where we cannot determine the alignment.
(base_meta, offset)
}
None => {
// We don't know the alignment of this field, so we cannot adjust.
throw_unsup_format!("`extern type` does not have a known offset")
}
}
} else {
// base_meta could be present; we might be accessing a sized field of an unsized
22 changes: 11 additions & 11 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
@@ -2674,6 +2674,14 @@ fn from_stderr(color: ColorConfig) -> Destination {
}
}

/// On Windows, BRIGHT_BLUE is hard to read on black. Use cyan instead.
///
/// See #36178.
#[cfg(windows)]
const BRIGHT_BLUE: Color = Color::Cyan;
#[cfg(not(windows))]
const BRIGHT_BLUE: Color = Color::Blue;

impl Style {
fn color_spec(&self, lvl: Level) -> ColorSpec {
let mut spec = ColorSpec::new();
@@ -2688,11 +2696,7 @@ impl Style {
Style::LineNumber => {
spec.set_bold(true);
spec.set_intense(true);
if cfg!(windows) {
spec.set_fg(Some(Color::Cyan));
} else {
spec.set_fg(Some(Color::Blue));
}
spec.set_fg(Some(BRIGHT_BLUE));
}
Style::Quotation => {}
Style::MainHeaderMsg => {
@@ -2707,19 +2711,15 @@ impl Style {
}
Style::UnderlineSecondary | Style::LabelSecondary => {
spec.set_bold(true).set_intense(true);
if cfg!(windows) {
spec.set_fg(Some(Color::Cyan));
} else {
spec.set_fg(Some(Color::Blue));
}
spec.set_fg(Some(BRIGHT_BLUE));
}
Style::HeaderMsg | Style::NoStyle => {}
Style::Level(lvl) => {
spec = lvl.color();
spec.set_bold(true);
}
Style::Highlight => {
spec.set_bold(true);
spec.set_bold(true).set_fg(Some(Color::Magenta));
}
}
spec
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/consts.rs
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ impl<'tcx> IntoKind for Const<'tcx> {
type Kind = ConstKind<'tcx>;

fn kind(self) -> ConstKind<'tcx> {
self.kind().clone()
self.kind()
}
}

23 changes: 15 additions & 8 deletions compiler/rustc_mir_transform/src/coroutine.rs
Original file line number Diff line number Diff line change
@@ -527,12 +527,26 @@ impl<'tcx> MutVisitor<'tcx> for TransformVisitor<'tcx> {
resume_arg
};

let storage_liveness: GrowableBitSet<Local> =
self.storage_liveness[block].clone().unwrap().into();

for i in 0..self.always_live_locals.domain_size() {
let l = Local::new(i);
let needs_storage_dead = storage_liveness.contains(l)
&& !self.remap.contains_key(&l)
&& !self.always_live_locals.contains(l);
if needs_storage_dead {
data.statements
.push(Statement { source_info, kind: StatementKind::StorageDead(l) });
}
}

self.suspension_points.push(SuspensionPoint {
state,
resume,
resume_arg,
drop,
storage_liveness: self.storage_liveness[block].clone().unwrap().into(),
storage_liveness,
});

VariantIdx::new(state)
@@ -1496,13 +1510,6 @@ fn create_cases<'tcx>(

// Create StorageLive instructions for locals with live storage
for i in 0..(body.local_decls.len()) {
if i == 2 {
// The resume argument is live on function entry. Don't insert a
// `StorageLive`, or the following `Assign` will read from uninitialized
// memory.
continue;
}

let l = Local::new(i);
let needs_storage_live = point.storage_liveness.contains(l)
&& !transform.remap.contains_key(&l)
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
@@ -1002,7 +1002,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
UNUSED_IMPORTS,
id,
import.span,
msg.to_string(),
msg,
BuiltinLintDiagnostics::RedundantImportVisibility {
max_vis: max_vis.to_string(def_id, self.tcx),
span: import.span,
6 changes: 5 additions & 1 deletion compiler/rustc_smir/src/rustc_smir/builder.rs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
use crate::rustc_smir::{Stable, Tables};
use rustc_middle::mir;
use rustc_middle::mir::visit::MutVisitor;
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt};

/// Builds a monomorphic body for a given instance.
pub struct BodyBuilder<'tcx> {
@@ -68,6 +68,10 @@ impl<'tcx> MutVisitor<'tcx> for BodyBuilder<'tcx> {
self.super_constant(constant, location);
}

fn visit_args(&mut self, args: &mut GenericArgsRef<'tcx>, _: mir::Location) {
*args = self.monomorphize(*args);
}

fn tcx(&self) -> TyCtxt<'tcx> {
self.tcx
}
2 changes: 1 addition & 1 deletion compiler/stable_mir/src/target.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ pub struct MachineInfo {

impl MachineInfo {
pub fn target() -> MachineInfo {
with(|cx| cx.target_info().clone())
with(|cx| cx.target_info())
}

pub fn target_endianess() -> Endian {
2 changes: 1 addition & 1 deletion src/ci/docker/host-x86_64/mingw-check/Dockerfile
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ ENV SCRIPT python3 ../x.py --stage 2 test src/tools/expand-yaml-anchors && \
RUSTDOCFLAGS=\"--document-private-items --document-hidden-items\" python3 ../x.py doc --stage 0 library/test && \
/scripts/validate-toolstate.sh && \
/scripts/validate-error-codes.sh && \
reuse lint && \
reuse --include-submodules lint && \
# Runs checks to ensure that there are no ES5 issues in our JS code.
es-check es6 ../src/librustdoc/html/static/js/*.js && \
eslint -c ../src/librustdoc/html/static/.eslintrc.js ../src/librustdoc/html/static/js/*.js && \
10 changes: 10 additions & 0 deletions src/tools/collect-license-metadata/src/main.rs
Original file line number Diff line number Diff line change
@@ -6,6 +6,16 @@ use crate::licenses::LicensesInterner;
use anyhow::Error;
use std::path::PathBuf;

// Some directories have too many slight license differences that'd result in a
// huge report, and could be considered a standalone project anyway. Those
// directories are "condensed" into a single licensing block for ease of
// reading, merging the licensing information.
//
// For every `(dir, file)``, every file in `dir` is considered to have the
// license info of `file`.
const CONDENSED_DIRECTORIES: &[(&str, &str)] =
&[("./src/llvm-project/", "./src/llvm-project/README.md")];

fn main() -> Result<(), Error> {
let reuse_exe: PathBuf = std::env::var_os("REUSE_EXE").expect("Missing REUSE_EXE").into();
let dest: PathBuf = std::env::var_os("DEST").expect("Missing DEST").into();
56 changes: 51 additions & 5 deletions src/tools/collect-license-metadata/src/path_tree.rs
Original file line number Diff line number Diff line change
@@ -4,14 +4,15 @@
//! passes over the tree to remove redundant information.
use crate::licenses::{License, LicenseId, LicensesInterner};
use std::collections::BTreeMap;
use std::collections::{BTreeMap, BTreeSet};
use std::path::{Path, PathBuf};

#[derive(serde::Serialize)]
#[serde(rename_all = "kebab-case", tag = "type")]
pub(crate) enum Node<L> {
Root { children: Vec<Node<L>> },
Directory { name: PathBuf, children: Vec<Node<L>>, license: Option<L> },
CondensedDirectory { name: PathBuf, licenses: Vec<L> },
File { name: PathBuf, license: L },
Group { files: Vec<PathBuf>, directories: Vec<PathBuf>, license: L },
Empty,
@@ -57,9 +58,9 @@ impl Node<LicenseId> {
Node::Directory { name, mut children, license: None } => {
directories.entry(name).or_insert_with(Vec::new).append(&mut children);
}
file @ Node::File { .. } => {
files.push(file);
}
file @ Node::File { .. } => files.push(file),
// Propagate condensed directories as-is.
condensed @ Node::CondensedDirectory { .. } => files.push(condensed),
Node::Empty => {}
Node::Root { .. } => {
panic!("can't have a root inside another element");
@@ -86,6 +87,7 @@ impl Node<LicenseId> {
}
Node::Empty => {}
Node::File { .. } => {}
Node::CondensedDirectory { .. } => {}
Node::Group { .. } => {
panic!("Group should not be present at this stage");
}
@@ -132,6 +134,7 @@ impl Node<LicenseId> {
}
}
Node::File { .. } => {}
Node::CondensedDirectory { .. } => {}
Node::Group { .. } => panic!("group should not be present at this stage"),
Node::Empty => {}
}
@@ -174,6 +177,9 @@ impl Node<LicenseId> {
Node::Directory { name: child_child_name, .. } => {
*child_child_name = child_name.join(&child_child_name);
}
Node::CondensedDirectory { name: child_child_name, .. } => {
*child_child_name = child_name.join(&child_child_name);
}
Node::File { name: child_child_name, .. } => {
*child_child_name = child_name.join(&child_child_name);
}
@@ -188,6 +194,7 @@ impl Node<LicenseId> {
}
Node::Empty => {}
Node::File { .. } => {}
Node::CondensedDirectory { .. } => {}
Node::Group { .. } => panic!("Group should not be present at this stage"),
}
}
@@ -255,6 +262,7 @@ impl Node<LicenseId> {
}
}
Node::File { .. } => {}
Node::CondensedDirectory { .. } => {}
Node::Group { .. } => panic!("FileGroup should not be present at this stage"),
Node::Empty => {}
}
@@ -270,6 +278,7 @@ impl Node<LicenseId> {
}
children.retain(|child| !matches!(child, Node::Empty));
}
Node::CondensedDirectory { .. } => {}
Node::Group { .. } => {}
Node::File { .. } => {}
Node::Empty => {}
@@ -293,7 +302,24 @@ pub(crate) fn build(mut input: Vec<(PathBuf, LicenseId)>) -> Node<LicenseId> {
// Ensure reproducibility of all future steps.
input.sort();

for (path, license) in input {
let mut condensed_directories = BTreeMap::new();
'outer: for (path, license) in input {
// Files in condensed directories are handled separately.
for (condensed_directory, allowed_file) in super::CONDENSED_DIRECTORIES {
if path.starts_with(condensed_directory) {
if path.as_path() == Path::new(allowed_file) {
// The licence on our allowed file is used to represent the entire directory
condensed_directories
.entry(*condensed_directory)
.or_insert_with(BTreeSet::new)
.insert(license);
} else {
// don't add the file
}
continue 'outer;
}
}

let mut node = Node::File { name: path.file_name().unwrap().into(), license };
for component in path.parent().unwrap_or_else(|| Path::new(".")).components().rev() {
node = Node::Directory {
@@ -306,6 +332,22 @@ pub(crate) fn build(mut input: Vec<(PathBuf, LicenseId)>) -> Node<LicenseId> {
children.push(node);
}

for (path, licenses) in condensed_directories {
let path = Path::new(path);
let mut node = Node::CondensedDirectory {
name: path.file_name().unwrap().into(),
licenses: licenses.iter().copied().collect(),
};
for component in path.parent().unwrap_or_else(|| Path::new(".")).components().rev() {
node = Node::Directory {
name: component.as_os_str().into(),
children: vec![node],
license: None,
};
}
children.push(node);
}

Node::Root { children }
}

@@ -334,6 +376,10 @@ pub(crate) fn expand_interned_licenses(
Node::Group { files, directories, license } => {
Node::Group { files, directories, license: interner.resolve(license) }
}
Node::CondensedDirectory { name, licenses } => Node::CondensedDirectory {
name,
licenses: licenses.into_iter().map(|license| interner.resolve(license)).collect(),
},
Node::Empty => Node::Empty,
}
}
8 changes: 5 additions & 3 deletions src/tools/collect-license-metadata/src/reuse.rs
Original file line number Diff line number Diff line change
@@ -17,9 +17,11 @@ pub(crate) fn collect(

let mut result = Vec::new();
for file in document.file_information {
let concluded_license = file.concluded_license.expect("File should have licence info");
let copyright_text = file.copyright_text.expect("File should have copyright text");
let license = interner.intern(License {
spdx: file.concluded_license.to_string(),
copyright: file.copyright_text.split('\n').map(|s| s.into()).collect(),
spdx: concluded_license.to_string(),
copyright: copyright_text.split('\n').map(|s| s.into()).collect(),
});

result.push((file.file_name.into(), license));
@@ -30,7 +32,7 @@ pub(crate) fn collect(

fn obtain_spdx_document(reuse_exe: &Path) -> Result<String, Error> {
let output = Command::new(reuse_exe)
.args(&["spdx", "--add-license-concluded", "--creator-person=bors"])
.args(&["--include-submodules", "spdx", "--add-license-concluded", "--creator-person=bors"])
.stdout(Stdio::piped())
.spawn()?
.wait_with_output()?;
37 changes: 29 additions & 8 deletions src/tools/generate-copyright/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::Error;
use std::collections::BTreeSet;
use std::io::Write;
use std::path::PathBuf;

@@ -26,7 +27,7 @@ fn render_recursive(node: &Node, buffer: &mut Vec<u8>, depth: usize) -> Result<(
}
}
Node::Directory { name, children, license } => {
render_license(&prefix, std::iter::once(name), license, buffer)?;
render_license(&prefix, std::iter::once(name), license.iter(), buffer)?;
if !children.is_empty() {
writeln!(buffer, "{prefix}")?;
writeln!(buffer, "{prefix}*Exceptions:*")?;
@@ -36,11 +37,19 @@ fn render_recursive(node: &Node, buffer: &mut Vec<u8>, depth: usize) -> Result<(
}
}
}
Node::CondensedDirectory { name, licenses } => {
render_license(&prefix, std::iter::once(name), licenses.iter(), buffer)?;
}
Node::Group { files, directories, license } => {
render_license(&prefix, directories.iter().chain(files.iter()), license, buffer)?;
render_license(
&prefix,
directories.iter().chain(files.iter()),
std::iter::once(license),
buffer,
)?;
}
Node::File { name, license } => {
render_license(&prefix, std::iter::once(name), license, buffer)?;
render_license(&prefix, std::iter::once(name), std::iter::once(license), buffer)?;
}
}

@@ -50,15 +59,26 @@ fn render_recursive(node: &Node, buffer: &mut Vec<u8>, depth: usize) -> Result<(
fn render_license<'a>(
prefix: &str,
names: impl Iterator<Item = &'a String>,
license: &License,
licenses: impl Iterator<Item = &'a License>,
buffer: &mut Vec<u8>,
) -> Result<(), Error> {
let mut spdxs = BTreeSet::new();
let mut copyrights = BTreeSet::new();
for license in licenses {
spdxs.insert(&license.spdx);
for copyright in &license.copyright {
copyrights.insert(copyright);
}
}

for name in names {
writeln!(buffer, "{prefix}**`{name}`** ")?;
}
writeln!(buffer, "{prefix}License: `{}` ", license.spdx)?;
for (i, copyright) in license.copyright.iter().enumerate() {
let suffix = if i == license.copyright.len() - 1 { "" } else { " " };
for spdx in spdxs.iter() {
writeln!(buffer, "{prefix}License: `{spdx}` ")?;
}
for (i, copyright) in copyrights.iter().enumerate() {
let suffix = if i == copyrights.len() - 1 { "" } else { " " };
writeln!(buffer, "{prefix}Copyright: {copyright}{suffix}")?;
}

@@ -74,7 +94,8 @@ struct Metadata {
#[serde(rename_all = "kebab-case", tag = "type")]
pub(crate) enum Node {
Root { children: Vec<Node> },
Directory { name: String, children: Vec<Node>, license: License },
Directory { name: String, children: Vec<Node>, license: Option<License> },
CondensedDirectory { name: String, licenses: Vec<License> },
File { name: String, license: License },
Group { files: Vec<String>, directories: Vec<String>, license: License },
}
29 changes: 29 additions & 0 deletions src/tools/miri/tests/fail/extern-type-field-offset.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#![feature(extern_types)]

extern "C" {
type Opaque;
}

struct Newtype(Opaque);

struct S {
i: i32,
j: i32,
a: Newtype,
}

fn main() {
let buf = [0i32; 4];

let x: &Newtype = unsafe { &*(&buf as *const _ as *const Newtype) };
// Projecting to the newtype works, because it is always at offset 0.
let _field = &x.0;

let x: &S = unsafe { &*(&buf as *const _ as *const S) };
// Accessing sized fields is perfectly fine, even at non-zero offsets.
let _field = &x.i;
let _field = &x.j;
// This needs to compute the field offset, but we don't know the type's alignment,
// so this panics.
let _field = &x.a; //~ERROR: does not have a known offset
}
14 changes: 14 additions & 0 deletions src/tools/miri/tests/fail/extern-type-field-offset.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error: unsupported operation: `extern type` does not have a known offset
--> $DIR/extern-type-field-offset.rs:LL:CC
|
LL | let _field = &x.a;
| ^^^^ `extern type` does not have a known offset
|
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
= note: BACKTRACE:
= note: inside `main` at $DIR/extern-type-field-offset.rs:LL:CC

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to 1 previous error

3 changes: 2 additions & 1 deletion src/tools/rust-analyzer/crates/stdx/src/anymap.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! This file is a port of only the necessary features from https://github.com/chris-morgan/anymap version 1.0.0-beta.2 for use within rust-analyzer.
//! Copyright © 2014–2022 Chris Morgan. COPYING: https://github.com/chris-morgan/anymap/blob/master/COPYING"
//! Copyright © 2014–2022 Chris Morgan.
//! COPYING: https://github.com/chris-morgan/anymap/blob/master/COPYING
//! Note that the license is changed from Blue Oak Model 1.0.0 or MIT or Apache-2.0 to MIT OR Apache-2.0
//!
//! This implementation provides a safe and convenient store for one value of each type.
2 changes: 1 addition & 1 deletion src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ use std::path::{Path, PathBuf};
const ENTRY_LIMIT: usize = 900;
// FIXME: The following limits should be reduced eventually.
const ISSUES_ENTRY_LIMIT: usize = 1852;
const ROOT_ENTRY_LIMIT: usize = 866;
const ROOT_ENTRY_LIMIT: usize = 867;

const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
"rs", // test source files
Original file line number Diff line number Diff line change
@@ -178,6 +178,10 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:15:18: 18:2}>,
StorageLive(_20);
_20 = ();
_0 = Poll::<()>::Pending;
StorageDead(_3);
StorageDead(_4);
StorageDead(_19);
StorageDead(_20);
discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2}))) = 3;
return;
}
@@ -276,6 +280,9 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:15:18: 18:2}>,
StorageLive(_36);
_36 = ();
_0 = Poll::<()>::Pending;
StorageDead(_21);
StorageDead(_35);
StorageDead(_36);
discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2}))) = 4;
return;
}
Original file line number Diff line number Diff line change
@@ -55,6 +55,9 @@ fn main::{closure#0}(_1: Pin<&mut {coroutine@$DIR/coroutine_tiny.rs:20:16: 20:24
StorageLive(_7);
_7 = ();
_0 = CoroutineState::<(), ()>::Yielded(move _7);
StorageDead(_4);
StorageDead(_6);
StorageDead(_7);
discriminant((*(_1.0: &mut {coroutine@$DIR/coroutine_tiny.rs:20:16: 20:24}))) = 3;
return;
}
Original file line number Diff line number Diff line change
@@ -89,6 +89,7 @@
+
+ bb6: {
+ _1 = CoroutineState::<i32, bool>::Yielded(move _8);
+ StorageDead(_8);
+ discriminant((*_6)) = 3;
+ goto -> bb2;
+ }
Original file line number Diff line number Diff line change
@@ -103,6 +103,7 @@
+
+ bb8: {
+ _1 = CoroutineState::<i32, bool>::Yielded(move _8);
+ StorageDead(_8);
+ discriminant((*_6)) = 3;
+ goto -> bb4;
+ }
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Test that we can handle unsized types with an extern type tail part.
// Regression test for issue #91827.

#![feature(extern_types)]

use std::ptr::addr_of;

extern "C" {
type Opaque;
}

struct Newtype(Opaque);

struct S {
i: i32,
j: i32,
a: Newtype,
}

const NEWTYPE: () = unsafe {
let buf = [0i32; 4];
let x: &Newtype = &*(&buf as *const _ as *const Newtype);

// Projecting to the newtype works, because it is always at offset 0.
let field = &x.0;
};

const OFFSET: () = unsafe {
let buf = [0i32; 4];
let x: &S = &*(&buf as *const _ as *const S);

// Accessing sized fields is perfectly fine, even at non-zero offsets.
let field = &x.i;
let field = &x.j;

// This needs to compute the field offset, but we don't know the type's alignment, so this
// fails.
let field = &x.a;
//~^ ERROR: evaluation of constant value failed
//~| does not have a known offset
};

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0080]: evaluation of constant value failed
--> $DIR/issue-91827-extern-types-field-offset.rs:38:17
|
LL | let field = &x.a;
| ^^^^ `extern type` does not have a known offset

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0080`.
59 changes: 0 additions & 59 deletions tests/ui/consts/const-eval/issue-91827-extern-types.rs

This file was deleted.

22 changes: 22 additions & 0 deletions tests/ui/error-emitter/highlighting.not-windows.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
error[E0308]: mismatched types
 --> $DIR/highlighting.rs:26:11
 |
LL |  query(wrapped_fn);
 |  ----- ^^^^^^^^^^ one type is more general than the other
 |  |
 |  arguments to this function are incorrect
 |
 = note: expected fn pointer `for<'a> fn(Box<(dyn Any + Send + 'a)>) -> Pin<_>`
 found fn item `fn(Box<(dyn Any + Send + 'static)>) -> Pin<_> {wrapped_fn}`
note: function defined here
 --> $DIR/highlighting.rs:15:4
 |
LL | fn query(_: fn(Box<(dyn Any + Send + '_)>) -> Pin<Box<(
 |  ____^^^^^_-
LL | |  dyn Future<Output = Result<Box<(dyn Any + 'static)>, String>> + Send + 'static
LL | | )>>) {}
 | |___-

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0308`.
27 changes: 27 additions & 0 deletions tests/ui/error-emitter/highlighting.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Make sure "highlighted" code is colored purple

// compile-flags: --error-format=human --color=always
// error-pattern:for<'a> 
// edition:2018

// revisions: windows not-windows
// [windows]only-windows
// [not-windows]ignore-windows

use core::pin::Pin;
use core::future::Future;
use core::any::Any;

fn query(_: fn(Box<(dyn Any + Send + '_)>) -> Pin<Box<(
dyn Future<Output = Result<Box<(dyn Any + 'static)>, String>> + Send + 'static
)>>) {}

fn wrapped_fn<'a>(_: Box<(dyn Any + Send)>) -> Pin<Box<(
dyn Future<Output = Result<Box<(dyn Any + 'static)>, String>> + Send + 'static
)>> {
Box::pin(async { Err("nope".into()) })
}

fn main() {
query(wrapped_fn);
}
22 changes: 22 additions & 0 deletions tests/ui/error-emitter/highlighting.windows.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
error[E0308]: mismatched types
 --> $DIR/highlighting.rs:26:11
 |
LL |  query(wrapped_fn);
 |  ----- ^^^^^^^^^^ one type is more general than the other
 |  |
 |  arguments to this function are incorrect
 |
 = note: expected fn pointer `for<'a> fn(Box<(dyn Any + Send + 'a)>) -> Pin<_>`
 found fn item `fn(Box<(dyn Any + Send + 'static)>) -> Pin<_> {wrapped_fn}`
note: function defined here
 --> $DIR/highlighting.rs:15:4
 |
LL | fn query(_: fn(Box<(dyn Any + Send + '_)>) -> Pin<Box<(
 |  ____^^^^^_-
LL | |  dyn Future<Output = Result<Box<(dyn Any + 'static)>, String>> + Send + 'static
LL | | )>>) {}
 | |___-

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0308`.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error[E0106]: missing lifetime specifier
 --> $DIR/multiline-multipart-suggestion.rs:4:34
 --> $DIR/multiline-multipart-suggestion.rs:8:34
 |
LL | fn short(foo_bar: &Vec<&i32>) -> &i32 {
LL | fn short(foo_bar: &Vec<&i32>) -> &i32 {
 |  ---------- ^ expected named lifetime parameter
 |
 = help: this function's return type contains a borrowed value, but the signature does not say which one of `foo_bar`'s 2 lifetimes it is borrowed from
help: consider introducing a named lifetime parameter
 |
LL | fn short<'a>(foo_bar: &'a Vec<&'a i32>) -> &'a i32 {
LL | fn short<'a>(foo_bar: &'a Vec<&'a i32>) -> &'a i32 {
 | ++++ ++ ++ ++

error[E0106]: missing lifetime specifier
 --> $DIR/multiline-multipart-suggestion.rs:11:6
 --> $DIR/multiline-multipart-suggestion.rs:15:6
 |
LL |  foo_bar: &Vec<&i32>,
 |  ----------
@@ -22,22 +22,22 @@
 = help: this function's return type contains a borrowed value, but the signature does not say which one of `foo_bar`'s 2 lifetimes it is borrowed from
help: consider introducing a named lifetime parameter
 |
LL ~ fn long<'a>(
LL ~ fn long<'a>(
LL ~  foo_bar: &'a Vec<&'a i32>,
LL |  something_very_long_so_that_the_line_will_wrap_around__________: i32,
LL ~ ) -> &'a i32 {
 |

error[E0106]: missing lifetime specifier
 --> $DIR/multiline-multipart-suggestion.rs:16:29
 --> $DIR/multiline-multipart-suggestion.rs:20:29
 |
LL |  foo_bar: &Vec<&i32>) -> &i32 {
 |  ---------- ^ expected named lifetime parameter
 |
 = help: this function's return type contains a borrowed value, but the signature does not say which one of `foo_bar`'s 2 lifetimes it is borrowed from
help: consider introducing a named lifetime parameter
 |
LL ~ fn long2<'a>(
LL ~ fn long2<'a>(
LL ~  foo_bar: &'a Vec<&'a i32>) -> &'a i32 {
 |

Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
// compile-flags: --error-format=human --color=always
// ignore-windows
// error-pattern: missing lifetime specifier

fn short(foo_bar: &Vec<&i32>) -> &i32 { //~ ERROR missing lifetime specifier
// revisions: windows not-windows
// [windows]only-windows
// [not-windows]ignore-windows

fn short(foo_bar: &Vec<&i32>) -> &i32 {
&12
}

fn long( //~ ERROR missing lifetime specifier
fn long(
foo_bar: &Vec<&i32>,
something_very_long_so_that_the_line_will_wrap_around__________: i32,
) -> &i32 {
&12
}

fn long2( //~ ERROR missing lifetime specifier
fn long2(
foo_bar: &Vec<&i32>) -> &i32 {
&12
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
error[E0106]: missing lifetime specifier
 --> $DIR/multiline-multipart-suggestion.rs:8:34
 |
LL | fn short(foo_bar: &Vec<&i32>) -> &i32 {
 |  ---------- ^ expected named lifetime parameter
 |
 = help: this function's return type contains a borrowed value, but the signature does not say which one of `foo_bar`'s 2 lifetimes it is borrowed from
help: consider introducing a named lifetime parameter
 |
LL | fn short<'a>(foo_bar: &'a Vec<&'a i32>) -> &'a i32 {
 | ++++ ++ ++ ++

error[E0106]: missing lifetime specifier
 --> $DIR/multiline-multipart-suggestion.rs:15:6
 |
LL |  foo_bar: &Vec<&i32>,
 |  ----------
LL |  something_very_long_so_that_the_line_will_wrap_around__________: i32,
LL | ) -> &i32 {
 |  ^ expected named lifetime parameter
 |
 = help: this function's return type contains a borrowed value, but the signature does not say which one of `foo_bar`'s 2 lifetimes it is borrowed from
help: consider introducing a named lifetime parameter
 |
LL ~ fn long<'a>(
LL ~  foo_bar: &'a Vec<&'a i32>,
LL |  something_very_long_so_that_the_line_will_wrap_around__________: i32,
LL ~ ) -> &'a i32 {
 |

error[E0106]: missing lifetime specifier
 --> $DIR/multiline-multipart-suggestion.rs:20:29
 |
LL |  foo_bar: &Vec<&i32>) -> &i32 {
 |  ---------- ^ expected named lifetime parameter
 |
 = help: this function's return type contains a borrowed value, but the signature does not say which one of `foo_bar`'s 2 lifetimes it is borrowed from
help: consider introducing a named lifetime parameter
 |
LL ~ fn long2<'a>(
LL ~  foo_bar: &'a Vec<&'a i32>) -> &'a i32 {
 |

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0106`.
32 changes: 32 additions & 0 deletions tests/ui/extern/extern-types-field-offset.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// run-fail
// check-run-results
// normalize-stderr-test "panicking\.rs:\d+:\d+:" -> "panicking.rs:"
#![feature(extern_types)]

extern "C" {
type Opaque;
}

struct Newtype(Opaque);

struct S {
i: i32,
j: i32,
a: Newtype,
}

fn main() {
let buf = [0i32; 4];

let x: &Newtype = unsafe { &*(&buf as *const _ as *const Newtype) };
// Projecting to the newtype works, because it is always at offset 0.
let field = &x.0;

let x: &S = unsafe { &*(&buf as *const _ as *const S) };
// Accessing sized fields is perfectly fine, even at non-zero offsets.
let field = &x.i;
let field = &x.j;
// This needs to compute the field offset, but we don't know the type's alignment,
// so this panics.
let field = &x.a;
}
4 changes: 4 additions & 0 deletions tests/ui/extern/extern-types-field-offset.run.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
thread 'main' panicked at library/core/src/panicking.rs:
attempted to compute the size or alignment of extern type `Opaque`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
4 changes: 4 additions & 0 deletions tests/ui/extern/extern-types-size_of_val.align.run.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
thread 'main' panicked at library/core/src/panicking.rs:
attempted to compute the size or alignment of extern type `A`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
13 changes: 10 additions & 3 deletions tests/ui/extern/extern-types-size_of_val.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// run-pass
// run-fail
// check-run-results
// revisions: size align
// normalize-stderr-test "panicking\.rs:\d+:\d+:" -> "panicking.rs:"
#![feature(extern_types)]

use std::mem::{align_of_val, size_of_val};
@@ -10,6 +13,10 @@ extern "C" {
fn main() {
let x: &A = unsafe { &*(1usize as *const A) };

assert_eq!(size_of_val(x), 0);
assert_eq!(align_of_val(x), 1);
// These don't have a dynamic size, so this should panic.
if cfg!(size) {
assert_eq!(size_of_val(x), 0);
} else {
assert_eq!(align_of_val(x), 1);
}
}
4 changes: 4 additions & 0 deletions tests/ui/extern/extern-types-size_of_val.size.run.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
thread 'main' panicked at library/core/src/panicking.rs:
attempted to compute the size or alignment of extern type `A`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
2 changes: 1 addition & 1 deletion triagebot.toml
Original file line number Diff line number Diff line change
@@ -631,7 +631,7 @@ cc = ["@nnethercote"]
[assign]
warn_non_default_branch = true
contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html"
users_on_vacation = ["jyn514", "oli-obk", "wesleywiser"]
users_on_vacation = ["jyn514", "oli-obk"]

[assign.adhoc_groups]
compiler-team = [