(&mut self, id: TypeId, mode: TypeMode)
| 1896 | } |
| 1897 | |
| 1898 | fn print_tyid(&mut self, id: TypeId, mode: TypeMode) { |
| 1899 | let ty = &self.resolve.types[id]; |
| 1900 | if ty.name.is_some() { |
| 1901 | // NB: Most of the heavy lifting of `TypeMode` and what to do here |
| 1902 | // has already happened in `type_mode_for*`. Here though a little |
| 1903 | // more happens because this is where `OnlyTopBorrowed` is |
| 1904 | // processed. |
| 1905 | // |
| 1906 | // Specifically what should happen is that in the case of an |
| 1907 | // argument to an imported function if only the top value is |
| 1908 | // borrowed then we want to render it as `&T`. If this all is |
| 1909 | // applicable then the lifetime is rendered here before the type. |
| 1910 | // The `mode` is then switched to `Owned` and recalculated for the |
| 1911 | // type we're rendering here to avoid accidentally giving it a |
| 1912 | // lifetime type parameter when it otherwise doesn't have it. |
| 1913 | let mode = if mode.style == TypeOwnershipStyle::OnlyTopBorrowed { |
| 1914 | if let Some(lt) = mode.lifetime { |
| 1915 | self.push_str("&"); |
| 1916 | if lt != "'_" { |
| 1917 | self.push_str(lt); |
| 1918 | self.push_str(" "); |
| 1919 | } |
| 1920 | self.type_mode_for_id(id, TypeOwnershipStyle::Owned, lt) |
| 1921 | } else { |
| 1922 | mode |
| 1923 | } |
| 1924 | } else { |
| 1925 | mode |
| 1926 | }; |
| 1927 | let name = self.type_path( |
| 1928 | id, |
| 1929 | match mode.style { |
| 1930 | TypeOwnershipStyle::Owned => true, |
| 1931 | TypeOwnershipStyle::OnlyTopBorrowed | TypeOwnershipStyle::Borrowed => false, |
| 1932 | }, |
| 1933 | ); |
| 1934 | self.push_str(&name); |
| 1935 | self.print_generics(mode.lifetime); |
| 1936 | return; |
| 1937 | } |
| 1938 | |
| 1939 | let mut anonymous_type_gen = AnonTypeGenerator { |
| 1940 | mode, |
| 1941 | resolve: self.resolve, |
| 1942 | interface: self, |
| 1943 | }; |
| 1944 | anonymous_type_gen.define_anonymous_type(id); |
| 1945 | } |
| 1946 | |
| 1947 | fn print_list(&mut self, ty: &Type, mode: TypeMode) { |
| 1948 | let next_mode = self.filter_mode(ty, mode); |
no test coverage detected