Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 12 pull requests #72187

Merged
merged 38 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
079817d
Make `prefix` immutable
ldm0 Apr 25, 2020
c9f1162
Rephrase the any::type_name docs a bit.
ltratt May 4, 2020
93f877c
Document that lifetimes do not currently appear in any::type_name()'s…
ltratt May 4, 2020
876001c
Fix typo.
ltratt May 4, 2020
5cb2fa4
Document From trait for Option implementations
Dolpheyn May 4, 2020
73f07a4
Fix comment position
Dolpheyn May 5, 2020
2badd41
Fix example
Dolpheyn May 5, 2020
d80ac64
Fix link to `map` documentation in example
Dolpheyn May 10, 2020
41f6b95
Remove ty::UnnormalizedProjection
jackh726 May 12, 2020
3fccdb3
Pointer printing: do not print 0 offset
RalfJung May 1, 2020
61fbe57
Clean up E0581 explanation
GuillaumeGomez May 12, 2020
5063297
Add doc comment for `rustc_middle::mir::mono::Linkage`
wesleywiser May 12, 2020
34b2072
Fix bootstrap failing on win32
jcotton42 May 7, 2020
003ed80
Map to -> return.
ltratt May 12, 2020
722b3df
Update books
ehuss May 12, 2020
bb2ff59
Clean up E0582 explanation
GuillaumeGomez May 13, 2020
46e9cbe
Update src/libcore/option.rs
Dolpheyn May 13, 2020
4588c26
Update src/libcore/option.rs
Dolpheyn May 13, 2020
a9e7d57
Update src/libcore/option.rs
Dolpheyn May 13, 2020
644bb24
Update src/libcore/option.rs
Dolpheyn May 13, 2020
adc2bf0
Update src/libcore/option.rs
Dolpheyn May 13, 2020
f445a82
Update src/libcore/option.rs
Dolpheyn May 13, 2020
ef1688d
Update src/libcore/option.rs
Dolpheyn May 13, 2020
6c3856f
Update src/libcore/option.rs
Dolpheyn May 13, 2020
e44f87f
docs: fix link
tshepang May 13, 2020
dab3a58
Fix Arc::decr_strong_count doc test
tmiasko May 14, 2020
32ea6a1
Rollup merge of #71525 - ldm0:intosug, r=Mark-Simulacrum
RalfJung May 14, 2020
7893d9a
Rollup merge of #71741 - RalfJung:pointer-print, r=oli-obk
RalfJung May 14, 2020
720ec68
Rollup merge of #71870 - ltratt:more_specific_type_name_doc, r=kennytm
RalfJung May 14, 2020
a6c1f61
Rollup merge of #71909 - Dolpheyn:doc-from-trait-for-option, r=stevek…
RalfJung May 14, 2020
577da45
Rollup merge of #71964 - jcotton42:bootstrap_decode_none_windows, r=M…
RalfJung May 14, 2020
0b8b38c
Rollup merge of #72137 - GuillaumeGomez:cleanup-e0581, r=Dylan-DPC
RalfJung May 14, 2020
18d7c34
Rollup merge of #72138 - wesleywiser:add_doc_comment, r=matthewjasper
RalfJung May 14, 2020
e5f31e0
Rollup merge of #72150 - jackh726:unnorm_projection, r=nikomatsakis
RalfJung May 14, 2020
39f91b1
Rollup merge of #72151 - ehuss:update-books, r=ehuss
RalfJung May 14, 2020
71f460b
Rollup merge of #72163 - tshepang:nonexistent-link, r=matthewjasper
RalfJung May 14, 2020
864eae7
Rollup merge of #72169 - GuillaumeGomez:cleanup-e0582, r=Dylan-DPC
RalfJung May 14, 2020
56986be
Rollup merge of #72183 - tmiasko:decr-strong-count, r=Mark-Simulacrum
RalfJung May 14, 2020
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
9 changes: 6 additions & 3 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,16 @@ def format_build_time(duration):
def default_build_triple():
"""Build triple as in LLVM"""
default_encoding = sys.getdefaultencoding()
required = not sys.platform == 'win32'
ostype = require(["uname", "-s"], exit=required).decode(default_encoding)
cputype = require(['uname', '-m'], exit=required).decode(default_encoding)
required = sys.platform != 'win32'
ostype = require(["uname", "-s"], exit=required)
cputype = require(['uname', '-m'], exit=required)

if ostype is None or cputype is None:
return 'x86_64-pc-windows-msvc'

ostype = ostype.decode(default_encoding)
cputype = cputype.decode(default_encoding)

# The goal here is to come up with the same triple as LLVM would,
# at least for the subset of platforms we're willing to target.
ostype_mapper = {
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book
2 changes: 1 addition & 1 deletion src/doc/edition-guide
2 changes: 1 addition & 1 deletion src/doc/nomicon
2 changes: 1 addition & 1 deletion src/doc/reference
2 changes: 1 addition & 1 deletion src/doc/rust-by-example
8 changes: 5 additions & 3 deletions src/liballoc/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,12 +835,14 @@ impl<T: ?Sized> Arc<T> {
///
/// unsafe {
/// let ptr = Arc::into_raw(five);
/// Arc::decr_strong_count(ptr);
/// Arc::incr_strong_count(ptr);
///
/// // This assertion is deterministic because we haven't shared
/// // Those assertions are deterministic because we haven't shared
/// // the `Arc` between threads.
/// let five = Arc::from_raw(ptr);
/// assert_eq!(0, Arc::strong_count(&five));
/// assert_eq!(2, Arc::strong_count(&five));
/// Arc::decr_strong_count(ptr);
/// assert_eq!(1, Arc::strong_count(&five));
/// }
/// ```
#[inline]
Expand Down
16 changes: 9 additions & 7 deletions src/libcore/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,16 @@ impl TypeId {
/// # Note
///
/// This is intended for diagnostic use. The exact contents and format of the
/// string are not specified, other than being a best-effort description of the
/// type. For example, `type_name::<Option<String>>()` could return the
/// `"Option<String>"` or `"std::option::Option<std::string::String>"`, but not
/// `"foobar"`. In addition, the output may change between versions of the
/// compiler.
/// string returned are not specified, other than being a best-effort
/// description of the type. For example, amongst the strings
/// that `type_name::<Option<String>>()` might return are `"Option<String>"` and
/// `"std::option::Option<std::string::String>"`.
///
/// The type name should not be considered a unique identifier of a type;
/// multiple types may share the same type name.
/// The returned string must not be considered to be a unique identifier of a
/// type as multiple types may map to the same type name. Similarly, there is no
/// guarantee that all parts of a type will appear in the returned string: for
/// example, lifetime specifiers are currently not included. In addition, the
/// output may change between versions of the compiler.
///
/// The current implementation uses the same infrastructure as compiler
/// diagnostics and debuginfo, but this is not guaranteed.
Expand Down
45 changes: 45 additions & 0 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1357,20 +1357,65 @@ impl<'a, T> IntoIterator for &'a mut Option<T> {

#[stable(since = "1.12.0", feature = "option_from")]
impl<T> From<T> for Option<T> {
/// Copies `val` into a new `Some`.
///
/// # Examples
///
/// ```
/// let o: Option<u8> = Option::from(67);
///
/// assert_eq!(Some(67), o);
/// ```
fn from(val: T) -> Option<T> {
Some(val)
}
}

#[stable(feature = "option_ref_from_ref_option", since = "1.30.0")]
impl<'a, T> From<&'a Option<T>> for Option<&'a T> {
/// Converts from `&Option<T>` to `Option<&T>`.
///
/// # Examples
///
/// Converts an `Option<`[`String`]`>` into an `Option<`[`usize`]`>`, preserving the original.
/// The [`map`] method takes the `self` argument by value, consuming the original,
/// so this technique uses `as_ref` to first take an `Option` to a reference
/// to the value inside the original.
///
/// [`map`]: ../../std/option/enum.Option.html#method.map
/// [`String`]: ../../std/string/struct.String.html
/// [`usize`]: ../../std/primitive.usize.html
///
/// ```
/// let s: Option<String> = Some(String::from("Hello, Rustaceans!"));
/// let o: Option<usize> = Option::from(&s).map(|ss: &String| ss.len());
///
/// println!("Can still print s: {:?}", s);
///
/// assert_eq!(o, Some(18));
/// ```
fn from(o: &'a Option<T>) -> Option<&'a T> {
o.as_ref()
}
}

#[stable(feature = "option_ref_from_ref_option", since = "1.30.0")]
impl<'a, T> From<&'a mut Option<T>> for Option<&'a mut T> {
/// Converts from `&mut Option<T>` to `Option<&mut T>`
///
/// # Examples
///
/// ```
/// let mut s = Some(String::from("Hello"));
/// let o: Option<&mut String> = Option::from(&mut s);
///
/// match o {
/// Some(t) => *t = String::from("Hello, Rustaceans!"),
/// None => (),
/// }
///
/// assert_eq!(s, Some(String::from("Hello, Rustaceans!")));
/// ```
fn from(o: &'a mut Option<T>) -> Option<&'a mut T> {
o.as_mut()
}
Expand Down
1 change: 0 additions & 1 deletion src/librustc_codegen_ssa/debuginfo/type_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ pub fn push_debuginfo_type_name<'tcx>(
ty::Error
| ty::Infer(_)
| ty::Placeholder(..)
| ty::UnnormalizedProjection(..)
| ty::Projection(..)
| ty::Bound(..)
| ty::Opaque(..)
Expand Down
9 changes: 6 additions & 3 deletions src/librustc_error_codes/error_codes/E0581.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
In a `fn` type, a lifetime appears only in the return type,
In a `fn` type, a lifetime appears only in the return type
and not in the arguments types.

Erroneous code example:
Expand All @@ -10,8 +10,11 @@ fn main() {
}
```

To fix this issue, either use the lifetime in the arguments, or use
`'static`. Example:
The problem here is that the lifetime isn't contrained by any of the arguments,
making it impossible to determine how long it's supposed to live.

To fix this issue, either use the lifetime in the arguments, or use the
`'static` lifetime. Example:

```
fn main() {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_error_codes/error_codes/E0582.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
A lifetime appears only in an associated-type binding,
and not in the input types to the trait.
A lifetime is only present in an associated-type binding, and not in the input
types to the trait.

Erroneous code example:

Expand Down
1 change: 0 additions & 1 deletion src/librustc_infer/infer/canonical/canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
| ty::Never
| ty::Tuple(..)
| ty::Projection(..)
| ty::UnnormalizedProjection(..)
| ty::Foreign(..)
| ty::Param(..)
| ty::Opaque(..) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/error_reporting/need_type_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
let output = bound_output.skip_binder();
err.span_label(e.span, &format!("this method call resolves to `{:?}`", output));
let kind = &output.kind;
if let ty::Projection(proj) | ty::UnnormalizedProjection(proj) = kind {
if let ty::Projection(proj) = kind {
if let Some(span) = self.tcx.hir().span_if_local(proj.item_def_id) {
err.span_label(span, &format!("`{:?}` defined here", output));
}
Expand Down
1 change: 0 additions & 1 deletion src/librustc_infer/infer/freshen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
| ty::Never
| ty::Tuple(..)
| ty::Projection(..)
| ty::UnnormalizedProjection(..)
| ty::Foreign(..)
| ty::Param(..)
| ty::Closure(..)
Expand Down
1 change: 0 additions & 1 deletion src/librustc_lint/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,6 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
| ty::Generator(..)
| ty::GeneratorWitness(..)
| ty::Placeholder(..)
| ty::UnnormalizedProjection(..)
| ty::Projection(..)
| ty::Opaque(..)
| ty::FnDef(..) => bug!("unexpected type in foreign function: {:?}", ty),
Expand Down
28 changes: 18 additions & 10 deletions src/librustc_middle/mir/interpret/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,35 @@ pub struct Pointer<Tag = ()> {

static_assert_size!(Pointer, 16);

/// Print the address of a pointer (without the tag)
fn print_ptr_addr<Tag>(ptr: &Pointer<Tag>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// Forward `alternate` flag to `alloc_id` printing.
if f.alternate() {
write!(f, "{:#?}", ptr.alloc_id)?;
} else {
write!(f, "{:?}", ptr.alloc_id)?;
}
// Print offset only if it is non-zero.
if ptr.offset.bytes() > 0 {
write!(f, "+0x{:x}", ptr.offset.bytes())?;
}
Ok(())
}

// We want the `Debug` output to be readable as it is used by `derive(Debug)` for
// all the Miri types.
// We have to use `Debug` output for the tag, because `()` does not implement
// `Display` so we cannot specialize that.
impl<Tag: fmt::Debug> fmt::Debug for Pointer<Tag> {
default fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if f.alternate() {
write!(f, "{:#?}+0x{:x}[{:?}]", self.alloc_id, self.offset.bytes(), self.tag)
} else {
write!(f, "{:?}+0x{:x}[{:?}]", self.alloc_id, self.offset.bytes(), self.tag)
}
print_ptr_addr(self, f)?;
write!(f, "[{:?}]", self.tag)
}
}
// Specialization for no tag
impl fmt::Debug for Pointer<()> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if f.alternate() {
write!(f, "{:#?}+0x{:x}", self.alloc_id, self.offset.bytes())
} else {
write!(f, "{:?}+0x{:x}", self.alloc_id, self.offset.bytes())
}
print_ptr_addr(self, f)
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/librustc_middle/mir/mono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ pub struct CodegenUnit<'tcx> {
size_estimate: Option<usize>,
}

/// Specifies the linkage type for a `MonoItem`.
///
/// See https://llvm.org/docs/LangRef.html#linkage-types for more details about these variants.
#[derive(Copy, Clone, PartialEq, Debug, RustcEncodable, RustcDecodable, HashStable)]
pub enum Linkage {
External,
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_middle/traits/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,6 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
| ty::Infer(_)
| ty::Bound(..)
| ty::Generator(..) => false,

ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
}
}

Expand Down
1 change: 0 additions & 1 deletion src/librustc_middle/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,6 @@ impl<'tcx> TyCtxt<'tcx> {
Bound,
Param,
Infer,
UnnormalizedProjection,
Projection,
Opaque,
Foreign
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_middle/ty/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ impl<'tcx> ty::TyS<'tcx> {
ty::Infer(ty::FreshIntTy(_)) => "fresh integral type".into(),
ty::Infer(ty::FreshFloatTy(_)) => "fresh floating-point type".into(),
ty::Projection(_) => "associated type".into(),
ty::UnnormalizedProjection(_) => "non-normalized associated type".into(),
ty::Param(p) => format!("type parameter `{}`", p).into(),
ty::Opaque(..) => "opaque type".into(),
ty::Error => "type error".into(),
Expand Down Expand Up @@ -323,7 +322,6 @@ impl<'tcx> ty::TyS<'tcx> {
ty::Placeholder(..) => "higher-ranked type".into(),
ty::Bound(..) => "bound type variable".into(),
ty::Projection(_) => "associated type".into(),
ty::UnnormalizedProjection(_) => "associated type".into(),
ty::Param(_) => "type parameter".into(),
ty::Opaque(..) => "opaque type".into(),
}
Expand Down
1 change: 0 additions & 1 deletion src/librustc_middle/ty/fast_reject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ pub fn simplify_type(
ty::Never => Some(NeverSimplifiedType),
ty::Tuple(ref tys) => Some(TupleSimplifiedType(tys.len())),
ty::FnPtr(ref f) => Some(FunctionSimplifiedType(f.skip_binder().inputs().len())),
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
ty::Projection(_) | ty::Param(_) => {
if can_simplify_params {
// In normalized types, projections don't unify with
Expand Down
5 changes: 0 additions & 5 deletions src/librustc_middle/ty/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ impl FlagComputation {
self.add_projection_ty(data);
}

&ty::UnnormalizedProjection(ref data) => {
self.add_flags(TypeFlags::HAS_TY_PROJECTION);
self.add_projection_ty(data);
}

&ty::Opaque(_, substs) => {
self.add_flags(TypeFlags::HAS_TY_OPAQUE);
self.add_substs(substs);
Expand Down
9 changes: 3 additions & 6 deletions src/librustc_middle/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1241,11 +1241,9 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
tcx.layout_raw(param_env.and(normalized))?
}

ty::Bound(..)
| ty::Placeholder(..)
| ty::UnnormalizedProjection(..)
| ty::GeneratorWitness(..)
| ty::Infer(_) => bug!("Layout::compute: unexpected type `{}`", ty),
ty::Bound(..) | ty::Placeholder(..) | ty::GeneratorWitness(..) | ty::Infer(_) => {
bug!("Layout::compute: unexpected type `{}`", ty)
}

ty::Param(_) | ty::Error => {
return Err(LayoutError::Unknown(ty));
Expand Down Expand Up @@ -2138,7 +2136,6 @@ where
}

ty::Projection(_)
| ty::UnnormalizedProjection(..)
| ty::Bound(..)
| ty::Placeholder(..)
| ty::Opaque(..)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_middle/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ bitflags! {
| TypeFlags::HAS_CT_PLACEHOLDER.bits
| TypeFlags::HAS_FREE_LOCAL_REGIONS.bits;

/// Does this have [Projection] or [UnnormalizedProjection]?
/// Does this have [Projection]?
const HAS_TY_PROJECTION = 1 << 10;
/// Does this have [Opaque]?
const HAS_TY_OPAQUE = 1 << 11;
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_middle/ty/outlives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ fn compute_components(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, out: &mut SmallVec<[Compo
}
}

ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),

// We assume that inference variables are fully resolved.
// So, if we encounter an inference variable, just record
// the unresolved variable as a component.
Expand Down
1 change: 0 additions & 1 deletion src/librustc_middle/ty/print/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ pub fn characteristic_def_id_of_type(ty: Ty<'_>) -> Option<DefId> {
| ty::FnPtr(_)
| ty::Projection(_)
| ty::Placeholder(..)
| ty::UnnormalizedProjection(..)
| ty::Param(_)
| ty::Opaque(..)
| ty::Infer(_)
Expand Down
1 change: 0 additions & 1 deletion src/librustc_middle/ty/print/obsolete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ impl DefPathBasedNames<'tcx> {
| ty::Bound(..)
| ty::Infer(_)
| ty::Placeholder(..)
| ty::UnnormalizedProjection(..)
| ty::Projection(..)
| ty::Param(_)
| ty::GeneratorWitness(_)
Expand Down
3 changes: 0 additions & 3 deletions src/librustc_middle/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,6 @@ pub trait PrettyPrinter<'tcx>:
p!(print_def_path(def_id, &[]));
}
ty::Projection(ref data) => p!(print(data)),
ty::UnnormalizedProjection(ref data) => {
p!(write("Unnormalized("), print(data), write(")"))
}
ty::Placeholder(placeholder) => p!(write("Placeholder({:?})", placeholder)),
ty::Opaque(def_id, substs) => {
// FIXME(eddyb) print this with `print_def_path`.
Expand Down
Loading